mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-05-21 17:16:29 +08:00
feat(make): Sync code from esp-idf and modify for ESP8266
Commit ID: f6bfe13e
This commit is contained in:
@ -1 +1,14 @@
|
||||
register_config_only_component()
|
||||
|
||||
# Generate pre-canned flasher args files suitable for passing to esptool.py
|
||||
foreach(part project app bootloader partition_table)
|
||||
configure_file(
|
||||
"${CMAKE_CURRENT_LIST_DIR}/flash_${part}_args.in"
|
||||
"${CMAKE_BINARY_DIR}/flash_${part}_args"
|
||||
)
|
||||
endforeach()
|
||||
|
||||
configure_file(
|
||||
"${CMAKE_CURRENT_LIST_DIR}/flasher_args.json.in"
|
||||
"${CMAKE_BINARY_DIR}/flasher_args.json"
|
||||
)
|
||||
|
@ -70,9 +70,6 @@ APP_BIN_UNSIGNED ?= $(APP_BIN)
|
||||
|
||||
$(APP_BIN_UNSIGNED): $(APP_ELF) $(ESPTOOLPY_SRC)
|
||||
$(ESPTOOLPY) elf2image $(ESPTOOL_FLASH_OPTIONS) $(ESPTOOL_ELF2IMAGE_OPTIONS) -o $@ $<
|
||||
ifdef IS_BOOTLOADER_BUILD
|
||||
@mv $@0x00000.bin $@
|
||||
endif
|
||||
|
||||
flash: all_binaries $(ESPTOOLPY_SRC) $(call prereq_if_explicit,erase_flash)
|
||||
@echo "Flashing binaries to serial port $(ESPPORT) (app at offset $(APP_OFFSET))..."
|
||||
|
@ -1373,7 +1373,7 @@ class ESP8266ROMFirmwareImage(BaseFirmwareImage):
|
||||
|
||||
# everything but IROM goes at 0x00000 in an image file
|
||||
normal_segments = self.get_non_irom_segments()
|
||||
with open("%s0x00000.bin" % basename, 'wb') as f:
|
||||
with open("%s" % basename, 'wb') as f:
|
||||
self.write_common_header(f, normal_segments)
|
||||
checksum = ESPLoader.ESP_CHECKSUM_MAGIC
|
||||
for segment in normal_segments:
|
||||
|
1
components/esptool_py/flash_app_args.in
Normal file
1
components/esptool_py/flash_app_args.in
Normal file
@ -0,0 +1 @@
|
||||
${APP_PARTITION_OFFSET} ${PROJECT_NAME}.bin
|
4
components/esptool_py/flash_bootloader_args.in
Normal file
4
components/esptool_py/flash_bootloader_args.in
Normal file
@ -0,0 +1,4 @@
|
||||
--flash_mode ${ESPFLASHMODE}
|
||||
--flash_size ${ESPFLASHSIZE}
|
||||
--flash_freq ${ESPFLASHFREQ}
|
||||
0x0000 bootloader/bootloader.bin
|
1
components/esptool_py/flash_partition_table_args.in
Normal file
1
components/esptool_py/flash_partition_table_args.in
Normal file
@ -0,0 +1 @@
|
||||
${PARTITION_TABLE_OFFSET} partition_table/partition-table.bin
|
7
components/esptool_py/flash_project_args.in
Normal file
7
components/esptool_py/flash_project_args.in
Normal file
@ -0,0 +1,7 @@
|
||||
--flash_mode ${ESPFLASHMODE}
|
||||
--flash_size ${ESPFLASHSIZE}
|
||||
--flash_freq ${ESPFLASHFREQ}
|
||||
0x0000 bootloader/bootloader.bin
|
||||
${PARTITION_TABLE_OFFSET} partition_table/partition-table.bin
|
||||
${APP_PARTITION_OFFSET} ${PROJECT_NAME}.bin
|
||||
${PHY_PARTITION_OFFSET} ${PHY_PARTITION_BIN_FILE}
|
17
components/esptool_py/flasher_args.json.in
Normal file
17
components/esptool_py/flasher_args.json.in
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"write_flash_args" : [ "--flash_mode", "${ESPFLASHMODE}",
|
||||
"--flash_size", "${ESPFLASHSIZE}",
|
||||
"--flash_freq", "${ESPFLASHFREQ}" ],
|
||||
"flash_files" : {
|
||||
"0x0000" : "bootloader/bootloader.bin",
|
||||
"${PARTITION_TABLE_OFFSET}" : "partition_table/partition-table.bin",
|
||||
"${APP_PARTITION_OFFSET}" : "${PROJECT_NAME}.bin",
|
||||
"${PHY_PARTITION_OFFSET}" : "${PHY_PARTITION_BIN_FILE}"
|
||||
},
|
||||
"bootloader" : { "offset" : "0x1000",
|
||||
"file" : "bootloader/bootloader.bin" },
|
||||
"app" : { "offset" : "${APP_PARTITION_OFFSET}",
|
||||
"file" : "${PROJECT_NAME}.bin" },
|
||||
"partition_table" : { "offset" : "${PARTITION_TABLE_OFFSET}",
|
||||
"file" : "partition_table/partition-table.bin" }
|
||||
}
|
61
components/esptool_py/project_include.cmake
Normal file
61
components/esptool_py/project_include.cmake
Normal file
@ -0,0 +1,61 @@
|
||||
# Set some global esptool.py variables
|
||||
#
|
||||
# Many of these are read when generating flash_app_args & flash_project_args
|
||||
set(ESPCHIP "esp8266")
|
||||
set(ESPTOOLPY "${PYTHON}" "${CMAKE_CURRENT_LIST_DIR}/esptool/esptool.py" --chip "${ESPCHIP}")
|
||||
set(ESPSECUREPY "${PYTHON}" "${CMAKE_CURRENT_LIST_DIR}/esptool/espsecure.py")
|
||||
|
||||
set(ESPFLASHMODE ${CONFIG_ESPTOOLPY_FLASHMODE})
|
||||
set(ESPFLASHFREQ ${CONFIG_ESPTOOLPY_FLASHFREQ})
|
||||
set(ESPFLASHSIZE ${CONFIG_ESPTOOLPY_FLASHSIZE})
|
||||
|
||||
set(ESPTOOLPY_SERIAL "${ESPTOOLPY}" --port "${ESPPORT}" --baud ${ESPBAUD})
|
||||
|
||||
set(ESPTOOLPY_ELF2IMAGE_FLASH_OPTIONS
|
||||
--flash_mode ${ESPFLASHMODE}
|
||||
--flash_freq ${ESPFLASHFREQ}
|
||||
--flash_size ${ESPFLASHSIZE}
|
||||
)
|
||||
|
||||
if(CONFIG_ESPTOOLPY_FLASHSIZE_DETECT)
|
||||
# Set ESPFLASHSIZE to 'detect' *after* elf2image options are generated,
|
||||
# as elf2image can't have 'detect' as an option...
|
||||
set(ESPFLASHSIZE detect)
|
||||
endif()
|
||||
|
||||
# Set variables if the PHY data partition is in the flash
|
||||
if(CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION)
|
||||
set(PHY_PARTITION_OFFSET ${CONFIG_PHY_DATA_OFFSET})
|
||||
set(PHY_PARTITION_BIN_FILE "esp32/phy_init_data.bin")
|
||||
endif()
|
||||
|
||||
if(BOOTLOADER_BUILD)
|
||||
set(ESPTOOL_ELF2IMAGE_OPTIONS "")
|
||||
else()
|
||||
set(ESPTOOL_ELF2IMAGE_OPTIONS "--version=3")
|
||||
endif()
|
||||
|
||||
#
|
||||
# Add 'app.bin' target - generates with elf2image
|
||||
#
|
||||
add_custom_command(OUTPUT "${PROJECT_NAME}.bin"
|
||||
COMMAND ${ESPTOOLPY} elf2image ${ESPTOOLPY_ELF2IMAGE_FLASH_OPTIONS} ${ESPTOOL_ELF2IMAGE_OPTIONS} -o "${PROJECT_NAME}.bin" "${PROJECT_NAME}.elf"
|
||||
DEPENDS ${PROJECT_NAME}.elf
|
||||
VERBATIM
|
||||
)
|
||||
add_custom_target(app ALL DEPENDS "${PROJECT_NAME}.bin")
|
||||
|
||||
#
|
||||
# Add 'flash' target - not all build systems can run this directly
|
||||
#
|
||||
function(esptool_py_custom_target target_name flasher_filename dependencies)
|
||||
add_custom_target(${target_name} DEPENDS ${dependencies}
|
||||
COMMAND ${ESPTOOLPY} -p ${CONFIG_ESPTOOLPY_PORT} -b ${CONFIG_ESPTOOLPY_BAUD}
|
||||
write_flash @flash_${flasher_filename}_args
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
)
|
||||
endfunction()
|
||||
|
||||
esptool_py_custom_target(flash project "app;partition_table;bootloader")
|
||||
esptool_py_custom_target(app-flash app "app")
|
||||
esptool_py_custom_target(bootloader-flash bootloader "bootloader")
|
Reference in New Issue
Block a user