Commit ed117971 authored by Marek Matej's avatar Marek Matej Committed by Mahesh Mahadevan
Browse files

soc: esp32s3: AMP support

Updates and fixes to support APPCPU.
- fix ld scripts
- fix and update memory layout
- fix build issues
- fix sysbuild

Signed-off-by: default avatarMarek Matej <marek.matej@espressif.com>
parent 82eb8a1f
Loading
Loading
Loading
Loading
+1 −3
Changes for soc/espressif/common/loader.c: 1 added line, 3 removed lines.
Original line number Diff line number Diff line
@@ -84,7 +84,6 @@ void map_rom_segments(uint32_t app_drom_start, uint32_t app_drom_vaddr,
	unsigned int segments = 0;
	unsigned int ram_segments = 0;

	/* Using already fetched bootloader image header from bootloader_init */
	offset += sizeof(esp_image_header_t);

	while (segments++ < 16) {
@@ -223,7 +222,6 @@ void map_rom_segments(uint32_t app_drom_start, uint32_t app_drom_vaddr,
			"IROM",
			app_irom_start_aligned, app_irom_vaddr_aligned,
			app_irom_size, app_irom_size);
	ets_printf("\n\r");
	esp_rom_uart_tx_wait_idle(0);
}

@@ -248,7 +246,7 @@ void __start(void)
	}
#endif

#ifndef CONFIG_MCUBOOT
#if !defined(CONFIG_MCUBOOT) && !defined(CONFIG_SOC_ESP32S3_APPCPU)
	map_rom_segments(_app_drom_start, _app_drom_vaddr, _app_drom_size,
			 _app_irom_start, _app_irom_vaddr, _app_irom_size);
#endif
+1 −2
Changes for soc/espressif/esp32/Kconfig: 1 added line, 2 removed lines.
Original line number Diff line number Diff line
@@ -32,8 +32,7 @@ config ESP32_APPCPU_DRAM
config SOC_ENABLE_APPCPU
	bool
	default y
	depends on IPM && SOC_ESP32_PROCPU
	depends on MBOX && SOC_ESP32_PROCPU
	depends on (IPM || MBOX) && SOC_ESP32_PROCPU
	help
	  This hidden configuration lets PROCPU core to map and start APPCPU whenever IPM is enabled.

+35 −32
Changes for soc/espressif/esp32s3/CMakeLists.txt: 35 added lines, 32 removed lines.
Original line number Diff line number Diff line
# SPDX-License-Identifier: Apache-2.0

if (CONFIG_SOC_ESP32S3_APPCPU)
  zephyr_sources(soc_appcpu.c)

  zephyr_sources(
    soc_appcpu.c
    )

else()

  zephyr_sources(
    soc.c
    soc_cache.c
    esp32s3-mp.c
    ../common/loader.c
    )

endif()

zephyr_include_directories(.)
@@ -22,13 +28,24 @@ zephyr_library_sources_ifdef(CONFIG_POWEROFF poweroff.c)
# Get flash size to use in esptool as string
math(EXPR esptoolpy_flashsize "${CONFIG_FLASH_SIZE} / 0x100000")

# Make rom loader compatible binary file
if(NOT CONFIG_BOOTLOADER_MCUBOOT)
# Get UART baudrate from DT
dt_chosen(dts_shell_uart PROPERTY "zephyr,shell-uart")
if(${dts_shell_uart})
  dt_prop(monitor_baud PATH ${dts_shell_uart} PROPERTY "current-speed")
endif()

board_runner_args(esp32 "--esp-monitor-baud=${monitor_baud}")

message("-- Espressif HAL path: ${ESP_IDF_PATH}")

# Select image processing

if(CONFIG_ESP_SIMPLE_BOOT OR CONFIG_MCUBOOT)

  if(CONFIG_BUILD_OUTPUT_BIN)

    set(ESPTOOL_PY ${ESP_IDF_PATH}/tools/esptool_py/esptool.py)
    message("esptool path: ${ESPTOOL_PY}")
    message("-- Use the esptool.py: ${ESPTOOL_PY}")

    set(ELF2IMAGE_ARG "")
    if(NOT CONFIG_MCUBOOT)
@@ -37,49 +54,35 @@ if(NOT CONFIG_BOOTLOADER_MCUBOOT)

    set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
      COMMAND ${PYTHON_EXECUTABLE} ${ESPTOOL_PY}
      ARGS --chip esp32s3 elf2image ${ELF2IMAGE_ARG}
      ARGS --chip ${CONFIG_SOC} elf2image ${ELF2IMAGE_ARG}
      --flash_mode dio --flash_freq 40m
      --flash_size ${esptoolpy_flashsize}MB
      -o ${CMAKE_BINARY_DIR}/zephyr/${CONFIG_KERNEL_BIN_NAME}.bin
      ${CMAKE_BINARY_DIR}/zephyr/${CONFIG_KERNEL_BIN_NAME}.elf)
  endif()

  endif()

## When building for APPCPU
if (CONFIG_SOC_ESP32S3_APPCPU)

  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()

else()
  ## Building for PROCPU

  set_property(TARGET bintools PROPERTY disassembly_flag_inline_source)

  # Get code-partition boot address
# Select the image origin depending on the boot configuration
if(CONFIG_SOC_ESP32S3_APPCPU)
  dt_nodelabel(dts_partition_path NODELABEL "slot0_appcpu_partition")
elseif(CONFIG_MCUBOOT)
  dt_nodelabel(dts_partition_path NODELABEL "boot_partition")
elseif(CONFIG_ESP_SIMPLE_BOOT)
  dt_nodelabel(dts_partition_path NODELABEL "boot_partition")
  dt_reg_addr(boot_off PATH ${dts_partition_path})

  # Get code-partition slot0 address
  dt_nodelabel(dts_partition_path NODELABEL "slot0_partition")
  dt_reg_addr(img_0_off PATH ${dts_partition_path})

  if(CONFIG_BOOTLOADER_MCUBOOT)
    board_finalize_runner_args(esp32 "--esp-app-address=${img_0_off}")
else()
    board_finalize_runner_args(esp32 "--esp-app-address=${boot_off}")
  dt_nodelabel(dts_partition_path NODELABEL "slot0_partition")
endif()

endif()
dt_reg_addr(image_off PATH ${dts_partition_path})
board_finalize_runner_args(esp32 "--esp-app-address=${image_off}")

message("-- Image partition ${dts_partition_path}")

# Look for cross references between bootloader sections
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
+2 −22
Changes for soc/espressif/esp32s3/Kconfig: 2 added lines, 22 removed lines.
Original line number Diff line number Diff line
@@ -14,28 +14,6 @@ config SOC_SERIES_ESP32S3

if SOC_SERIES_ESP32S3

config ESP32S3_APPCPU_IRAM
	hex "ESP32S3 APPCPU IRAM size"
	depends on SOC_ESP32S3_PROCPU || SOC_ESP32S3_APPCPU
	default 0x20000
	help
	  Defines APPCPU IRAM area in bytes.

config ESP32S3_APPCPU_DRAM
	hex "ESP32S3 APPCPU DRAM size"
	depends on SOC_ESP32S3_PROCPU || SOC_ESP32S3_APPCPU
	default 0x10000
	help
	  Defines APPCPU DRAM area in bytes.

config SOC_ENABLE_APPCPU
	bool
	default y
	depends on IPM && SOC_ESP32S3_PROCPU
	depends on MBOX && SOC_ESP32S3_PROCPU
	help
	  This hidden configuration lets PROCPU core to map and start APPCPU whenever IPM is enabled.

menu "Cache config"

choice ESP32S3_INSTRUCTION_CACHE_SIZE
@@ -178,4 +156,6 @@ config MAC_BB_PD

endmenu  # Cache config

rsource "Kconfig.amp"

endif # SOC_SERIES_ESP32S3
+31 −0
Changes for soc/espressif/esp32s3/Kconfig.amp: 31 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Copyright (c) 2023 Espressif Systems (Shanghai) Co., Ltd.
# SPDX-License-Identifier: Apache-2.0

if SOC_SERIES_ESP32S3

menu "AMP config"

config ESP32S3_APPCPU_IRAM_SIZE
	hex "ESP32S3 APPCPU IRAM size"
	depends on SOC_ESP32S3_PROCPU || SOC_ESP32S3_APPCPU
	default 0x10000
	help
	  Defines APPCPU IRAM area size in bytes.

config ESP32S3_APPCPU_DRAM_SIZE
	hex "ESP32S3 APPCPU DRAM size"
	depends on SOC_ESP32S3_PROCPU || SOC_ESP32S3_APPCPU
	default 0x10000
	help
	  Defines APPCPU DRAM area size in bytes.

config SOC_ENABLE_APPCPU
	bool
	default y
	depends on (IPM || MBOX) && SOC_ESP32S3_PROCPU
	help
	  This hidden configuration lets PROCPU core to map and start APPCPU whenever IPM is enabled.

endmenu # AMP config

endif # SOC_SERIES_ESP32S3
Loading