esp-idf/components/esp_rom
Marius Vikhammer 35a6671072 Merge branch 'feature/c6_misc_core' into 'master'
feat(system): misc core-system C61 bringup changes

Closes IDF-10954, IDF-10986, IDF-10957, IDF-9281, and IDF-9257

See merge request espressif/esp-idf!33297
2024-09-12 09:46:30 +08:00
..
esp32 change(esp_rom): optimize target-specific header files layout in components/esp_rom 2024-06-27 11:24:45 +08:00
esp32c2 feat(wifi): add protect for softap send no bss deauth 2024-09-10 14:23:43 +08:00
esp32c3 fix(wifi): fix esp32s2 get ack rssi issue 2024-08-27 21:53:31 +08:00
esp32c5 feat(wifi): add wifi support for esp32c61 2024-08-30 20:43:06 +08:00
esp32c6 fix(wifi): fix esp32s2 get ack rssi issue 2024-08-27 21:53:31 +08:00
esp32c61 feat(pm): support basic pmu sleep 2024-09-10 10:44:13 +08:00
esp32h2 Merge branch 'bugfix/fix_newlib_nano_float_printf_issues' into 'master' 2024-07-26 17:37:03 +08:00
esp32p4 Merge branch 'bugfix/fix_newlib_nano_float_printf_issues' into 'master' 2024-07-26 17:37:03 +08:00
esp32s2 change(esp_rom): RM esp_rom header files from check_public_headers_exceptions.txt 2024-07-03 11:05:15 +08:00
esp32s3 fix(wifi): fix esp32s2 get ack rssi issue 2024-08-27 21:53:31 +08:00
include fix(gpio): patched esp_rom_gpio_connect_out_signal for esp32 and esp32s2 2024-08-15 16:36:18 +08:00
linux change(esp_rom): optimize target-specific header files layout in components/esp_rom 2024-06-27 11:24:45 +08:00
patches Merge branch 'feat/support_esp32c2_eco4_rom_systimer_hal' into 'master' 2024-09-06 16:06:10 +08:00
test_apps ci(system): re-enable system test app for C61 2024-09-11 14:05:11 +08:00
CMakeLists.txt Merge branch 'feat/support_esp32c2_eco4_rom_mbedtls_v3.6.0_lts' into 'master' 2024-09-09 16:53:53 +08:00
Kconfig.projbuild build-system: include soc_caps defines into kconfig 2021-12-06 12:37:07 +08:00
linker.lf fix(cache): fixed cache writeback/invalidate cannot reach higher vaddr parts 2024-09-05 18:47:02 +08:00
README.md esp32h4: removed esp32h4 related codes 2023-04-23 12:03:07 +00:00

esp_rom Component

Function Description

esp_rom component contains each chip's ROM functions, which are used in the ROM bootloader, 2nd bootloader, esp_tool flash stub and some driver code (e.g. GPIO matrix). ROM functions as not treated as public APIs, attentions are required when you use ROM functions:

  1. ROM functions are not thread-safe in RTOS, extra locks are needed to be around the ROM functions.
  2. Names/signatures/behaviors of ROM function may be different between chips.
  3. ROM functions are not guaranteed to exist across all chips.

When using ROM functions in esp-idf, the including convention is <target>/rom/<header_file>.h. This can prevent you from using a nonexistent ROM function for a specific <target>. Thus ROM functions are recommended for use in a target-specific source file. For example, bootloader_esp32.c can include esp32/rom/<header_file>.h without any violations. However, this is not the case when it comes to a common source file that also wants to use some of the ROM functions. The include list would be quite extensive:

#if CONFIG_IDF_TARGET_ESP32
#include "esp32/rom/uart.h"
#elif CONFIG_IDF_TARGET_ESP32C3
#include "esp32c3/rom/uart.h"
#elif CONFIG_IDF_TARGET_ESP32S3
#include "esp32s3/rom/uart.h"
...

So, we added a wrapper for those commonly used ROM functions. They're declared in esp_rom/include/esp_rom_xxx.h. Unlike the original ROM functions, these extracted ones are expected to exist across all chips. If some of them are missed in the new chips, we will implement them again in esp_rom/patches. These ROM APIs are always prefixed with the name esp_rom (e.g. esp_rom_printf), so that it's obvious to know whether a function is linked to ROM.

Most of the time, the ROM wrapper APIs are just alias to the original ROM functions by linker script esp_rom/<target>/ld/<target>.rom.api.ld. For example, esp_rom_printf is alias to ets_printf in the following way:

PROVIDE ( esp_rom_printf = ets_printf );

If some original ROM functions have changed the behavior or have bugs, we should override them in the wrapper layer. A common example is the esp_rom_install_uart_printf(), on ESP32 and ESP32S2, it's just alias to ets_install_uart_printf, but on other chips, it's re-implemented in the esp_rom/patches/esp_rom_uart.c. To some extent, the ROM wrapper layer works like an anti-corrosion layer between esp-rom project and esp-idf project.

As ROM functions are unique to each target, features are as well. For example, ESP32 has the tjpgd library built into the ROM, but ESP32S2 hasn't. We have a header file esp_rom/<target>/esp_rom_caps.h declaring the features that are supported by each target. Based on the macros defined there, we can decide whether a function should be patched or whether a feature should be re-implemented.

Directory Structure

.
├── CMakeLists.txt
├── <target/chip_name>
│   ├── esp_rom_caps.h
│   └── ld
│       ├── <target>.rom.api.ld
│       ├── <target>.rom.ld
│       ├── <target>.rom.libgcc.ld
│       ├── <target>.rom.newlib.ld
│       ├── <target>.rom.newlib-nano.ld
│       ├── <target>.rom.version.ld
│       └── ... // other ROM linker scripts, added when bring up new chip
├── include
│   ├── <target/chip_name>
│   │   └── rom
│   │       ├── cache.h
│   │       ├── efuse.h
│   │       ├── esp_flash.h
│   │       ├── ets_sys.h
│   │       ├── gpio.h
│   │       ├── uart.h
│   │       └── ... // other original ROM header files, added when bring up new chip
│   ├── esp_rom_gpio.h
│   ├── esp_rom_md5.h
│   ├── esp_rom_sys.h
│   ├── esp_rom_uart.h
│   └── ... // other ROM wrapper api files
├── Kconfig.projbuild
├── linker.lf
├── patches
│   ├── esp_rom_sys.c
│   ├── esp_rom_uart.c
│   └── ... // other patched source files
├── README.md
└── test
    ├── CMakeLists.txt
    ├── test_miniz.c
    └── ... // other ROM function unit tests