Commit 561f31bb authored by Sylvio Alves's avatar Sylvio Alves Committed by Carles Cufi
Browse files

soc: espressif: esp32s3: update to hal_espressif v5.1



Modify and reorganize SoC to meet updated hal.

Signed-off-by: default avatarSylvio Alves <sylvio.alves@espressif.com>
Signed-off-by: default avatarLucas Tamborrino <lucas.tamborrino@espressif.com>
parent 072ea896
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@
			device_type = "cpu";
			compatible = "cdns,tensilica-xtensa-lx7";
			reg = <0>;
			cpu-power-states = <&light_sleep &deep_sleep>;
		};

		cpu1: cpu@1 {
@@ -40,6 +41,21 @@
			reg = <1>;
		};

		power-states {
			light_sleep: light_sleep {
				compatible = "zephyr,power-state";
				power-state-name = "standby";
				min-residency-us = <200>;
				exit-latency-us = <133>;
			};

			deep_sleep: deep_sleep {
				compatible = "zephyr,power-state";
				power-state-name = "soft-off";
				min-residency-us = <2000>;
				exit-latency-us = <382>;
			};
		};
	};

	wifi: wifi {
+2 −4
Original line number Diff line number Diff line
@@ -21,10 +21,8 @@
#define ESP32_CLK_CPU_240M             240000000

/* Supported XTAL Frequencies */
#define ESP32_CLK_XTAL_24M             0U
#define ESP32_CLK_XTAL_26M             1U
#define ESP32_CLK_XTAL_40M             2U
#define ESP32_CLK_XTAL_AUTO            3U
#define ESP32_CLK_XTAL_32M             32
#define ESP32_CLK_XTAL_40M             40

/* Supported RTC fast clock frequencies */
#define ESP32_RTC_FAST_CLK_FREQ_8M     8500000U
+25 −46
Original line number Diff line number Diff line
@@ -6,8 +6,8 @@ else()
  zephyr_sources(
    soc.c
    soc_cache.c
    loader.c
    esp32s3-mp.c
    ../common/loader.c
    )
endif()

@@ -15,65 +15,39 @@ zephyr_include_directories(.)

zephyr_library_sources_ifdef(CONFIG_NEWLIB_LIBC newlib_fix.c)

# Power Management
zephyr_library_sources_ifdef(CONFIG_PM power.c)
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")

if(CONFIG_BOOTLOADER_ESP_IDF)
  include(ExternalProject)

  ## we use hello-world project, but I think any can be used.
  set(espidf_components_dir   ${ESP_IDF_PATH}/components)
  set(espidf_prefix    ${CMAKE_BINARY_DIR}/esp-idf)
  set(espidf_build_dir ${espidf_prefix}/build)

  ExternalProject_Add(
    EspIdfBootloader
    PREFIX ${espidf_prefix}
    SOURCE_DIR ${espidf_components_dir}/bootloader/subproject
    BINARY_DIR ${espidf_build_dir}/bootloader
    CONFIGURE_COMMAND
    ${CMAKE_COMMAND} -G${CMAKE_GENERATOR}
    -S ${espidf_components_dir}/bootloader/subproject
    -B ${espidf_build_dir}/bootloader -DSDKCONFIG=${espidf_build_dir}/sdkconfig
    -DIDF_PATH=${ESP_IDF_PATH} -DIDF_TARGET=${CONFIG_SOC_SERIES}
    -DPYTHON_DEPS_CHECKED=1
    -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
    -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
    -DCMAKE_ASM_COMPILER=${CMAKE_ASM_COMPILER}
    -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
    -DPYTHON=${PYTHON_EXECUTABLE}
    BUILD_COMMAND
    ${CMAKE_COMMAND} --build .
    INSTALL_COMMAND ""      # This particular build system has no install command
    )

  ExternalProject_Add(
    EspPartitionTable
    SOURCE_DIR ${espidf_components_dir}/partition_table
    BINARY_DIR ${espidf_build_dir}
    CONFIGURE_COMMAND ""
    BUILD_COMMAND
    ${PYTHON_EXECUTABLE} ${ESP_IDF_PATH}/components/partition_table/gen_esp32part.py -q
    --offset 0x8000 --flash-size ${esptoolpy_flashsize}MB ${ESP_IDF_PATH}/components/partition_table/partitions_singleapp.csv ${espidf_build_dir}/partitions_singleapp.bin
    INSTALL_COMMAND ""
    )
  set(bootloader_dir "${ZEPHYR_HAL_ESPRESSIF_MODULE_DIR}/zephyr/blobs/lib/${CONFIG_SOC_SERIES}")

  set_property(TARGET bintools PROPERTY disassembly_flag_inline_source)

  add_dependencies(app EspIdfBootloader EspPartitionTable)
  if(EXISTS "${bootloader_dir}/bootloader-${CONFIG_SOC_SERIES}.bin")
    file(COPY "${bootloader_dir}/bootloader-${CONFIG_SOC_SERIES}.bin" DESTINATION ${CMAKE_BINARY_DIR})
    file(RENAME "${CMAKE_BINARY_DIR}/bootloader-${CONFIG_SOC_SERIES}.bin" "${CMAKE_BINARY_DIR}/bootloader.bin")
  endif()

  board_finalize_runner_args(esp32 "--esp-flash-bootloader=${espidf_build_dir}/bootloader/bootloader.bin")
  if(EXISTS "${bootloader_dir}/partition-table-${CONFIG_SOC_SERIES}.bin")
    file(COPY "${bootloader_dir}/partition-table-${CONFIG_SOC_SERIES}.bin" DESTINATION ${CMAKE_BINARY_DIR})
    file(RENAME "${CMAKE_BINARY_DIR}/partition-table-${CONFIG_SOC_SERIES}.bin" "${CMAKE_BINARY_DIR}/partition-table.bin")
  endif()
  board_finalize_runner_args(esp32 "--esp-flash-bootloader=${CMAKE_BINARY_DIR}/bootloader.bin")

  board_finalize_runner_args(esp32 "--esp-flash-partition_table=${espidf_build_dir}/partitions_singleapp.bin")
  board_finalize_runner_args(esp32 "--esp-flash-partition_table=${CMAKE_BINARY_DIR}/partition-table.bin")

  board_finalize_runner_args(esp32 "--esp-partition-table-address=0x8000")

endif()

if(CONFIG_MCUBOOT OR CONFIG_BOOTLOADER_ESP_IDF)

  if(CONFIG_BUILD_OUTPUT_BIN)
    set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
      COMMAND ${PYTHON_EXECUTABLE} ${ESP_IDF_PATH}/components/esptool_py/esptool/esptool.py
      COMMAND ${PYTHON_EXECUTABLE} ${ESP_IDF_PATH}/tools/esptool_py/esptool.py
      ARGS --chip esp32s3 elf2image --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)
@@ -82,10 +56,12 @@ if(CONFIG_MCUBOOT OR CONFIG_BOOTLOADER_ESP_IDF)
  if(CONFIG_MCUBOOT)
    board_finalize_runner_args(esp32 "--esp-flash-bootloader=${CMAKE_BINARY_DIR}/zephyr/${CONFIG_KERNEL_BIN_NAME}.bin")
  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
@@ -93,7 +69,9 @@ if(CONFIG_SOC_ESP32S3_APPCPU)
      -o ${CMAKE_BINARY_DIR}/zephyr/${CONFIG_KERNEL_BIN_NAME}.c
      -a "esp32s3_appcpu_fw_array")
  endif()

else()

  set_property(TARGET bintools PROPERTY disassembly_flag_inline_source)

  # get code-partition slot0 address
@@ -107,6 +85,7 @@ else()
  board_finalize_runner_args(esp32 "--esp-boot-address=${boot_off}")

  board_finalize_runner_args(esp32 "--esp-app-address=${img_0_off}")

endif()

if(CONFIG_MCUBOOT)
+2 −108
Original line number Diff line number Diff line
@@ -10,6 +10,8 @@ config SOC_SERIES_ESP32S3
	select XIP if !MCUBOOT
	select HAS_ESPRESSIF_HAL
	select CPU_HAS_FPU
	select HAS_PM
	select HAS_POWEROFF

if SOC_SERIES_ESP32S3

@@ -38,95 +40,6 @@ config SOC_ENABLE_APPCPU
	help
	  This hidden configuration lets PROCPU core to map and start APPCPU whenever IPM is enabled.

choice ESP32S3_RTC_CLK_SRC
	prompt "RTC clock source"
	default ESP32S3_RTC_CLK_SRC_INT_RC
	help
	  Choose which clock is used as RTC clock source.

	config ESP32S3_RTC_CLK_SRC_INT_RC
		bool "Internal 150kHz RC oscillator"
	config ESP32S3_RTC_CLK_SRC_EXT_CRYS
		bool "External 32kHz crystal"
		select ESP_SYSTEM_RTC_EXT_XTAL
	config ESP32S3_RTC_CLK_SRC_EXT_OSC
		bool "External 32kHz oscillator at 32K_XP pin"
		select ESP_SYSTEM_RTC_EXT_OSC
	config ESP32S3_RTC_CLK_SRC_INT_8MD256
		bool "Internal 8MHz oscillator, divided by 256 (~32kHz)"
endchoice

config ESP32S3_RTC_CLK_CAL_CYCLES
	int "Number of cycles for RTC_SLOW_CLK calibration"
	default 3000 if ESP32S3_RTC_CLK_SRC_EXT_CRYS || ESP32S3_RTC_CLK_SRC_EXT_OSC || ESP32S3_RTC_CLK_SRC_INT_8MD256
	default 1024 if ESP32S3_RTC_CLK_SRC_INT_RC
	range 0 27000 if ESP32S3_RTC_CLK_SRC_EXT_CRYS || ESP32S3_RTC_CLK_SRC_EXT_OSC || ESP32S3_RTC_CLK_SRC_INT_8MD256
	range 0 32766 if ESP32S3_RTC_CLK_SRC_INT_RC
	help
	  When the startup code initializes RTC_SLOW_CLK, it can perform
	  calibration by comparing the RTC_SLOW_CLK frequency with main XTAL
	  frequency. This option sets the number of RTC_SLOW_CLK cycles measured
	  by the calibration routine. Higher numbers increase calibration
	  precision, which may be important for applications which spend a lot of
	  time in deep sleep. Lower numbers reduce startup time.

	  When this option is set to 0, clock calibration will not be performed at
	  startup, and approximate clock frequencies will be assumed:

	  - 150000 Hz if internal RC oscillator is used as clock source. For this use value 1024.
	  - 32768 Hz if the 32k crystal oscillator is used. For this use value 3000 or more.
	  In case more value will help improve the definition of the launch of the crystal.
	  If the crystal could not start, it will be switched to internal RC.

choice ESP32_UNIVERSAL_MAC_ADDRESSES
	bool "Number of universally administered (by IEEE) MAC address"
	default ESP32_UNIVERSAL_MAC_ADDRESSES_FOUR
	help
	  Configure the number of universally administered (by IEEE) MAC addresses.
	  During initialization, MAC addresses for each network interface are generated or
	  derived from a single base MAC address. If the number of universal MAC addresses is four,
	  all four interfaces (WiFi station, WiFi softap, Bluetooth and Ethernet) receive a universally
	  administered MAC address. These are generated sequentially by adding 0, 1, 2 and 3 (respectively)
	  to the final octet of the base MAC address. If the number of universal MAC addresses is two,
	  only two interfaces (WiFi station and Bluetooth) receive a universally administered MAC address.
	  These are generated sequentially by adding 0 and 1 (respectively) to the base MAC address.
	  The remaining two interfaces (WiFi softap and Ethernet) receive local MAC addresses.
	  These are derived from the universal WiFi station and Bluetooth MAC addresses, respectively.
	  When using the default (Espressif-assigned) base MAC address, either setting can be used.
	  When using a custom universal MAC address range, the correct setting will depend on the
	  allocation of MAC addresses in this range (either 2 or 4 per device.)

config ESP32_UNIVERSAL_MAC_ADDRESSES_TWO
	bool "Two"
	select ESP_MAC_ADDR_UNIVERSE_WIFI_STA
	select ESP_MAC_ADDR_UNIVERSE_BT

config ESP32_UNIVERSAL_MAC_ADDRESSES_FOUR
	bool "Four"
	select ESP_MAC_ADDR_UNIVERSE_WIFI_STA
	select ESP_MAC_ADDR_UNIVERSE_WIFI_AP
	select ESP_MAC_ADDR_UNIVERSE_BT
	select ESP_MAC_ADDR_UNIVERSE_ETH

endchoice # ESP32_UNIVERSAL_MAC_ADDRESSES

config ESP_MAC_ADDR_UNIVERSE_WIFI_AP
	bool

config ESP_MAC_ADDR_UNIVERSE_WIFI_STA
	bool

config ESP_MAC_ADDR_UNIVERSE_BT
	bool

config ESP_MAC_ADDR_UNIVERSE_ETH
	bool

config ESP32_UNIVERSAL_MAC_ADDRESSES
	int
	default 2 if ESP32_UNIVERSAL_MAC_ADDRESSES_TWO
	default 4 if ESP32_UNIVERSAL_MAC_ADDRESSES_FOUR

config ESP32_PHY_MAX_WIFI_TX_POWER
	int "Max WiFi/BLE TX power (dBm)"
	range 10 20
@@ -281,23 +194,4 @@ config MAC_BB_PD

endmenu  # Cache config

menu "PSRAM Clock and CS IO for ESP32S3"
	depends on ESP_SPIRAM

config DEFAULT_PSRAM_CLK_IO
	int "PSRAM CLK IO number"
	range 0 33
	default 30
	help
	  The PSRAM Clock IO can be any unused GPIO, please refer to your hardware design.

config DEFAULT_PSRAM_CS_IO
	int "PSRAM CS IO number"
	range 0 33
	default 26
	help
	  The PSRAM CS IO can be any unused GPIO, please refer to your hardware design.

endmenu # PSRAM clock and cs IO for ESP32S3

endif # SOC_SERIES_ESP32S3
+0 −12
Original line number Diff line number Diff line
@@ -3,18 +3,6 @@

if SOC_SERIES_ESP32S3

config MINIMAL_LIBC_OPTIMIZE_STRING_FOR_SIZE
	default n

config SYS_CLOCK_HW_CYCLES_PER_SEC
	default $(dt_node_int_prop_int,/cpus/cpu@0,clock-frequency)

config XTENSA_CCOUNT_HZ
	default SYS_CLOCK_HW_CYCLES_PER_SEC

config ESPTOOLPY_FLASHFREQ_80M
	default y

config FLASH_SIZE
	default $(dt_node_reg_size_int,/soc/flash-controller@60002000/flash@0,0)

Loading