mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
7855aad7e4
19079: cpu/esp32: add periph_flashpage support r=kaspar030 a=gschorcht ### Contribution description This PR provides the `periph_flashpage` support for ESP32x SoCs. For byte-aligned read access to constant data in the flash, the MMU of all ESP32x SoCs allows to map a certain number of 64 kByte pages of the flash into the data address space of the CPU. This address space is called DROM. Normally the whole DROM address space is assigned to the section `.rodata`. The default flash layout used by all ESP32x SoCs is: | Address in Flash | Content | |:-----------------------|:-----------| | `0x0000` or `0x1000` | bootloader | | `0x8000` | parition table | | `0x9000` | `nvs` parition with WiFi data | | `0xf000` | `phy_init` partition with RF data | | `0x10000` | `factory` partition with the app image | The factory partition consists of a number of 64 kByte pages for the sections `.text`, `.rodata`, `.bss` and others. The `.text` and `rodata` sections are page-aligned and are simply mapped into the instruction address space (IROM) and the data address space (DROM), respectively. All other sections are loaded into RAM. If the `periph_flashpage` module is used, the `periph_flashpage` driver - decreases the size of the `.rodata` section in DROM address space by `CONFIG_ESP_FLASHPAGE_CAPACITY`, - adds a section `.flashpage.writable` of size `CONFIG_ESP_FLASHPAGE_CAPACITY` at the end of DROM address space that is mapped into data address space of the CPU, - reserves a region of size `CONFIG_ESP_FLASHPAGE_CAPACITY` starting from `0x10000` in front of the image partition `factory` and - moves the image partition `factory` by `CONFIG_ESP_FLASHPAGE_CAPACITY` to address `0x10000 + CONFIG_ESP_FLASHPAGE_CAPACITY`. The new flash layout is then: | Address in Flash | Content | |:-----------------------|:-----------| | `0x0000` or `0x1000` | bootloader | | `0x8000` | parition table | | `0x9000` | `nvs` parition with WiFi data | | `0xf000` | `phy_init` partition with RF data | | `0x10000` | flashpage region | | `0x10000 + CONFIG_ESP_FLASHPAGE_CAPACITY` | `factory` partition with the app image | This guarantees that the flash pages are not overwritten if a new app image with changed size is flashed. `CONFIG_ESP_FLASHPAGE_CAPACITY` has to be a multiple of 64 kBytes. ~The PR includes PR #19077 and PR #19078 for the moment to be compilable.~ ### Testing procedure The following tests should pass. ``` USEMODULE='esp_log_startup ps shell_cmds_default' BOARD=esp32-wroom-32 make -j8 -C tests/periph_flashpage flash term ``` ``` USEMODULE='esp_log_startup ps shell_cmds_default' BOARD=esp32-wroom-32 make -j8 -C tests/mtd_flashpage flash term ``` ### Issues/PRs references Depends on PR #19077 Depends on PR #19078 Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
187 lines
4.9 KiB
Makefile
187 lines
4.9 KiB
Makefile
# additional modules dependencies
|
|
|
|
include $(RIOTCPU)/esp_common/Makefile.dep
|
|
|
|
USEPKG += esp32_sdk
|
|
|
|
USEMODULE += esp_idf_api
|
|
USEMODULE += esp_idf_common
|
|
USEMODULE += esp_idf_efuse
|
|
USEMODULE += esp_bootloader
|
|
|
|
ifneq (,$(filter newlib,$(USEMODULE)))
|
|
DEFAULT_MODULE += newlib_nano
|
|
endif
|
|
|
|
ifneq (,$(filter cpp,$(USEMODULE)))
|
|
USEMODULE += pthread
|
|
endif
|
|
|
|
ifneq (,$(filter esp_ble,$(USEMODULE)))
|
|
# add additional modules and packages used for any BLE interface
|
|
FEATURES_REQUIRED += esp_ble
|
|
USEMODULE += esp_idf_ble
|
|
USEPKG += esp32_sdk_lib_phy
|
|
ifeq (esp32,$(CPU_FAM))
|
|
FEATURES_REQUIRED += esp_ble_esp32
|
|
USEPKG += esp32_sdk_lib_bt_esp32
|
|
else ifneq (,$(filter esp32c3 esp32s3,$(CPU_FAM)))
|
|
FEATURES_REQUIRED += esp_ble_esp32c3
|
|
USEPKG += esp32_sdk_lib_bt_esp32c3
|
|
endif
|
|
endif
|
|
|
|
ifneq (,$(filter esp_eth,$(USEMODULE)))
|
|
FEATURES_REQUIRED += esp_eth
|
|
USEMODULE += esp_idf_eth
|
|
USEMODULE += esp_idf_event
|
|
USEMODULE += esp_idf_gpio
|
|
USEMODULE += esp_idf_spi_flash
|
|
USEMODULE += netdev_eth
|
|
USEMODULE += netopt
|
|
USEMODULE += ztimer_msec
|
|
endif
|
|
|
|
ifneq (,$(filter esp_wifi_any,$(USEMODULE)))
|
|
# add additional modules and packages used for any WiFi interface
|
|
USEPKG += esp32_sdk_lib_phy
|
|
USEPKG += esp32_sdk_lib_wifi
|
|
USEMODULE += esp_idf_event
|
|
USEMODULE += esp_idf_heap
|
|
USEMODULE += esp_idf_nvs_flash
|
|
USEMODULE += esp_idf_spi_flash
|
|
USEMODULE += esp_idf_wifi
|
|
USEMODULE += esp_idf_wpa_supplicant
|
|
USEMODULE += esp_idf_wpa_supplicant_esp_supplicant
|
|
USEMODULE += esp_idf_wpa_supplicant_port
|
|
USEMODULE += esp_idf_wpa_supplicant_ap
|
|
USEMODULE += esp_idf_wpa_supplicant_common
|
|
USEMODULE += esp_idf_wpa_supplicant_crypto
|
|
USEMODULE += esp_idf_wpa_supplicant_eap_peer
|
|
USEMODULE += esp_idf_wpa_supplicant_rsn_supp
|
|
USEMODULE += esp_idf_wpa_supplicant_tls
|
|
USEMODULE += esp_idf_wpa_supplicant_utils
|
|
USEMODULE += esp_idf_wpa_supplicant_wps
|
|
USEMODULE += pthread
|
|
endif
|
|
|
|
ifneq (,$(filter esp_hw_counter,$(USEMODULE)))
|
|
FEATURES_REQUIRED += esp_hw_counter
|
|
endif
|
|
|
|
ifneq (,$(filter esp_idf_nvs_flash,$(USEMODULE)))
|
|
# add additional modules required by esp_idf_nvs_flash
|
|
USEMODULE += pthread
|
|
USEMODULE += mtd
|
|
endif
|
|
|
|
ifneq (,$(filter esp_idf_wifi,$(USEMODULE)))
|
|
# add additional modules required by esp_idf_wifi
|
|
USEMODULE += esp_idf_adc
|
|
endif
|
|
|
|
ifneq (,$(filter periph_rtt,$(USEMODULE)))
|
|
FEATURES_OPTIONAL += esp_rtc_timer_32k
|
|
endif
|
|
|
|
ifneq (,$(filter esp_rtc_timer_32k,$(FEATURES_USED)))
|
|
USEMODULE += esp_rtc_timer_32k
|
|
endif
|
|
|
|
ifneq (,$(filter periph_gpio,$(USEMODULE)))
|
|
USEMODULE += esp_idf_gpio
|
|
endif
|
|
|
|
ifneq (,$(filter periph_i2c,$(USEMODULE)))
|
|
ifneq (,$(filter esp_i2c_hw,$(USEMODULE)))
|
|
USEMODULE += ztimer_msec
|
|
USEMODULE += periph_i2c_hw
|
|
else
|
|
# PLEASE NOTE: because of the very poor and faulty hardware implementation
|
|
# we use software implementation by default for the moment (if module
|
|
# esp_i2c_hw is not explicitly used)
|
|
USEMODULE += esp_i2c_sw
|
|
USEMODULE += periph_i2c_sw
|
|
endif
|
|
endif
|
|
|
|
ifneq (,$(filter esp_spi_ram,$(USEMODULE)))
|
|
FEATURES_REQUIRED += esp_spi_ram
|
|
FEATURES_OPTIONAL += esp_spi_oct
|
|
USEMODULE += esp_idf_gpio
|
|
USEMODULE += esp_idf_heap
|
|
USEMODULE += esp_idf_spi_flash
|
|
USEMODULE += esp_idf_spi_ram
|
|
endif
|
|
|
|
ifneq (,$(filter esp_spi_oct,$(FEATURES_USED)))
|
|
USEMODULE += esp_spi_oct
|
|
endif
|
|
|
|
ifneq (,$(filter esp_idf_heap,$(USEMODULE)))
|
|
# The ESP-IDF heap component uses the TLSF implementation that is part of
|
|
# the component. To avoid conflicts with modules and packages that use the
|
|
# RIOT package `tlsf`, this package is also used for the ESP-IDF heap instead
|
|
# of its own implementation. There does not seem to be any differences in
|
|
# the implementations of TLSF with the exception of heap poisoning, which
|
|
# is not configured.
|
|
USEPKG += tlsf
|
|
endif
|
|
|
|
ifneq (,$(filter mtd periph_flashpage,$(USEMODULE)))
|
|
USEMODULE += esp_idf_spi_flash
|
|
endif
|
|
|
|
ifneq (,$(filter nimble,$(USEPKG)))
|
|
USEMODULE += esp_ble
|
|
USEMODULE += esp_ble_nimble
|
|
USEMODULE += nimble_host
|
|
USEMODULE += nimble_transport_hci_h4
|
|
USEMODULE += ztimer_msec
|
|
endif
|
|
|
|
ifneq (,$(filter periph_adc,$(USEMODULE)))
|
|
USEMODULE += esp_idf_adc
|
|
endif
|
|
|
|
ifneq (,$(filter periph_rtc,$(USEMODULE)))
|
|
USEMODULE += rtt_rtc
|
|
endif
|
|
|
|
ifneq (,$(filter pm_layered,$(USEMODULE)))
|
|
USEMODULE += periph_rtt
|
|
endif
|
|
|
|
ifneq (,$(filter periph_rtt,$(USEMODULE)))
|
|
USEMODULE += periph_rtt_hw_sys
|
|
USEMODULE += periph_rtt_hw_rtc
|
|
endif
|
|
|
|
ifneq (,$(filter periph_usbdev,$(USEMODULE)))
|
|
USEMODULE += esp_idf_usb
|
|
USEMODULE += usbdev_synopsys_dwc2
|
|
endif
|
|
|
|
ifneq (,$(filter shell,$(USEMODULE)))
|
|
USEMODULE += ps
|
|
endif
|
|
|
|
ifneq (,$(filter stdio_usb_serial_jtag, $(USEMODULE)))
|
|
USEMODULE += tsrb
|
|
ifneq (,$(filter stdin,$(USEMODULE)))
|
|
USEMODULE += stdio_usb_serial_jtag_rx
|
|
endif
|
|
endif
|
|
ifneq (,$(filter stdio_usb_serial_jtag_rx, $(USEMODULE)))
|
|
USEMODULE += isrpipe
|
|
USEMODULE += stdio_available
|
|
endif
|
|
|
|
ifneq (,$(filter tinyusb_portable_espressif,$(USEMODULE)))
|
|
USEMODULE += esp_idf_usb
|
|
endif
|
|
|
|
ifneq (,$(filter esp_jtag,$(USEMODULE)))
|
|
FEATURES_REQUIRED += esp_jtag
|
|
endif
|