2023-01-02 20:15:18 +08:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2024-03-07 10:50:55 +08:00
|
|
|
if (CONFIG_SOC_ESP32S3_APPCPU)
|
2023-08-31 04:10:01 +08:00
|
|
|
zephyr_sources(soc_appcpu.c)
|
|
|
|
else()
|
|
|
|
zephyr_sources(
|
|
|
|
soc.c
|
|
|
|
soc_cache.c
|
|
|
|
esp32s3-mp.c
|
2024-03-07 10:50:55 +08:00
|
|
|
../common/loader.c
|
2023-08-31 04:10:01 +08:00
|
|
|
)
|
|
|
|
endif()
|
2023-01-02 20:15:18 +08:00
|
|
|
|
2022-09-15 04:23:15 +08:00
|
|
|
zephyr_include_directories(.)
|
|
|
|
|
2023-01-02 20:15:18 +08:00
|
|
|
zephyr_library_sources_ifdef(CONFIG_NEWLIB_LIBC newlib_fix.c)
|
|
|
|
|
2024-03-07 10:50:55 +08:00
|
|
|
# Power Management
|
|
|
|
zephyr_library_sources_ifdef(CONFIG_PM power.c)
|
|
|
|
zephyr_library_sources_ifdef(CONFIG_POWEROFF poweroff.c)
|
|
|
|
|
2023-12-14 07:09:17 +08:00
|
|
|
# Get flash size to use in esptool as string
|
2023-01-02 20:15:18 +08:00
|
|
|
math(EXPR esptoolpy_flashsize "${CONFIG_FLASH_SIZE} / 0x100000")
|
|
|
|
|
2023-12-14 07:09:17 +08:00
|
|
|
# Make rom loader compatible binary file
|
|
|
|
if(NOT CONFIG_BOOTLOADER_MCUBOOT)
|
2023-01-02 20:15:18 +08:00
|
|
|
|
2023-12-14 07:09:17 +08:00
|
|
|
if(CONFIG_BUILD_OUTPUT_BIN)
|
2023-01-02 20:15:18 +08:00
|
|
|
|
2023-12-14 07:09:17 +08:00
|
|
|
set(ESPTOOL_PY ${ESP_IDF_PATH}/tools/esptool_py/esptool.py)
|
|
|
|
message("esptool path: ${ESPTOOL_PY}")
|
2023-01-02 20:15:18 +08:00
|
|
|
|
2023-12-14 07:09:17 +08:00
|
|
|
set(ELF2IMAGE_ARG "")
|
|
|
|
if(NOT CONFIG_MCUBOOT)
|
|
|
|
set(ELF2IMAGE_ARG "--ram-only-header")
|
|
|
|
endif()
|
2024-03-07 10:50:55 +08:00
|
|
|
|
2023-05-09 17:10:05 +08:00
|
|
|
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
|
2023-12-14 07:09:17 +08:00
|
|
|
COMMAND ${PYTHON_EXECUTABLE} ${ESPTOOL_PY}
|
|
|
|
ARGS --chip esp32s3 elf2image ${ELF2IMAGE_ARG}
|
|
|
|
--flash_mode dio --flash_freq 40m
|
|
|
|
--flash_size ${esptoolpy_flashsize}MB
|
2023-05-09 17:10:05 +08:00
|
|
|
-o ${CMAKE_BINARY_DIR}/zephyr/${CONFIG_KERNEL_BIN_NAME}.bin
|
|
|
|
${CMAKE_BINARY_DIR}/zephyr/${CONFIG_KERNEL_BIN_NAME}.elf)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
endif()
|
|
|
|
|
2023-08-31 04:10:01 +08:00
|
|
|
## When building for APPCPU
|
2024-03-07 10:50:55 +08:00
|
|
|
if (CONFIG_SOC_ESP32S3_APPCPU)
|
|
|
|
|
2023-08-31 04:10:01 +08:00
|
|
|
if(CONFIG_BUILD_OUTPUT_BIN)
|
|
|
|
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
|
|
|
|
COMMAND ${PYTHON_EXECUTABLE} ${ESP_IDF_PATH}/tools/esp_bin2c_array.py
|
|
|
|
ARGS -i ${CMAKE_BINARY_DIR}/zephyr/${CONFIG_KERNEL_BIN_NAME}.bin
|
|
|
|
-o ${CMAKE_BINARY_DIR}/zephyr/${CONFIG_KERNEL_BIN_NAME}.c
|
|
|
|
-a "esp32s3_appcpu_fw_array")
|
|
|
|
endif()
|
2024-03-07 10:50:55 +08:00
|
|
|
|
2023-08-31 04:10:01 +08:00
|
|
|
else()
|
2024-05-30 00:03:29 +08:00
|
|
|
## Building for PROCPU
|
2024-03-07 10:50:55 +08:00
|
|
|
|
2023-08-31 04:10:01 +08:00
|
|
|
set_property(TARGET bintools PROPERTY disassembly_flag_inline_source)
|
|
|
|
|
2023-12-14 07:09:17 +08:00
|
|
|
# Get code-partition boot address
|
2023-08-31 04:10:01 +08:00
|
|
|
dt_nodelabel(dts_partition_path NODELABEL "boot_partition")
|
|
|
|
dt_reg_addr(boot_off PATH ${dts_partition_path})
|
|
|
|
|
2023-12-14 07:09:17 +08:00
|
|
|
# Get code-partition slot0 address
|
|
|
|
dt_nodelabel(dts_partition_path NODELABEL "slot0_partition")
|
|
|
|
dt_reg_addr(img_0_off PATH ${dts_partition_path})
|
2023-08-31 04:10:01 +08:00
|
|
|
|
2024-09-16 18:54:15 +08:00
|
|
|
if(CONFIG_BOOTLOADER_MCUBOOT)
|
2023-12-14 07:09:17 +08:00
|
|
|
board_finalize_runner_args(esp32 "--esp-app-address=${img_0_off}")
|
2024-09-16 18:54:15 +08:00
|
|
|
else()
|
|
|
|
board_finalize_runner_args(esp32 "--esp-app-address=${boot_off}")
|
2023-12-14 07:09:17 +08:00
|
|
|
endif()
|
2024-03-07 10:50:55 +08:00
|
|
|
|
2023-08-31 04:10:01 +08:00
|
|
|
endif()
|
2023-10-28 03:46:21 +08:00
|
|
|
|
2024-05-30 00:03:29 +08:00
|
|
|
if(CONFIG_MCUBOOT)
|
|
|
|
# search from cross references between bootloader sections
|
|
|
|
message("check_callgraph using: ${ESP_IDF_PATH}/tools/ci/check_callgraph.py")
|
|
|
|
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
|
|
|
|
COMMAND
|
|
|
|
${PYTHON_EXECUTABLE} ${ESP_IDF_PATH}/tools/ci/check_callgraph.py
|
|
|
|
ARGS
|
|
|
|
--rtl-dirs ${CMAKE_BINARY_DIR}/zephyr
|
|
|
|
--elf-file ${CMAKE_BINARY_DIR}/zephyr/${CONFIG_KERNEL_BIN_NAME}.elf
|
|
|
|
find-refs
|
|
|
|
--from-section='.iram0.loader_text'
|
|
|
|
--to-section='.iram0.text'
|
|
|
|
--exit-code)
|
|
|
|
endif()
|
|
|
|
|
2023-10-28 03:46:21 +08:00
|
|
|
if(CONFIG_MCUBOOT)
|
|
|
|
set(SOC_LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/mcuboot.ld CACHE INTERNAL "")
|
|
|
|
elseif(CONFIG_SOC_ESP32S3_APPCPU)
|
|
|
|
set(SOC_LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/default_appcpu.ld CACHE INTERNAL "")
|
|
|
|
else()
|
|
|
|
set(SOC_LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/default.ld CACHE INTERNAL "")
|
|
|
|
endif()
|