mirror of
https://github.com/espressif/esp-idf.git
synced 2025-10-02 10:00:57 +02:00
change(esp_rom): move roms.json from tools to esp_rom component
This commit is contained in:
@@ -74,3 +74,25 @@ As ROM functions are unique to each target, features are as well. For example, E
|
||||
├── test_miniz.c
|
||||
└── ... // other ROM function unit tests
|
||||
```
|
||||
|
||||
## Adding New Chip Support For Debugging
|
||||
|
||||
1. Dump .rodata strings via `riscv32-esp-elf-readelf -p .rodata esp32c5_rev0_rom.elf`
|
||||
2. Locate the build date in the output (e.g. `[ 23c4] Mar 29 2024`).
|
||||
3. Get start address of .rodata section via `riscv32-esp-elf-readelf -S esp32c5_rev0_rom.elf | grep rodata`
|
||||
4. Compute the absolute address by adding the offset from step 2 to the base address from step 3.
|
||||
5. Verify with GDB:
|
||||
```
|
||||
riscv32-esp-elf-gdb esp32c5_rev0_rom.elf -ex "p (char*) 0x4004b3c4" --batch
|
||||
$1 = 0x4004b3c4 "Mar 29 2024"
|
||||
```
|
||||
6. Update roms.json:
|
||||
```
|
||||
"esp32c5": [
|
||||
{
|
||||
"rev": 0,
|
||||
"build_date_str_addr": "0x4004b3c4",
|
||||
"build_date_str": "Mar 29 2024"
|
||||
}
|
||||
],
|
||||
```
|
||||
|
@@ -7,8 +7,7 @@ import os
|
||||
import sys
|
||||
from textwrap import indent
|
||||
|
||||
IDF_PATH = os.getenv('IDF_PATH', '')
|
||||
ROMS_JSON = os.path.join(IDF_PATH, 'tools', 'idf_py_actions', 'roms.json') # type: ignore
|
||||
ROMS_JSON = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'roms.json')
|
||||
|
||||
|
||||
# Direct string extraction and comparison is not feasible due to:
|
||||
@@ -20,7 +19,7 @@ ROMS_JSON = os.path.join(IDF_PATH, 'tools', 'idf_py_actions', 'roms.json') # ty
|
||||
def get_rom_if_condition_str(date_addr: int, date_str: str) -> str:
|
||||
r = []
|
||||
for i in range(0, len(date_str), 4):
|
||||
value = hex(int.from_bytes(bytes(date_str[i:i + 4], 'utf-8'), 'little'))
|
||||
value = hex(int.from_bytes(bytes(date_str[i : i + 4], 'utf-8'), 'little'))
|
||||
r.append(f'(*(int*) {hex(date_addr + i)}) == {value}')
|
||||
return 'if ' + ' && '.join(r)
|
||||
|
||||
@@ -29,12 +28,13 @@ def generate_gdbinit_rom_add_symbols(target: str) -> str:
|
||||
base_ident = ' '
|
||||
rom_elfs_dir = os.getenv('ESP_ROM_ELF_DIR')
|
||||
if not rom_elfs_dir:
|
||||
raise EnvironmentError(
|
||||
'ESP_ROM_ELF_DIR environment variable is not defined. Please try to run IDF "install" and "export" scripts.')
|
||||
raise OSError(
|
||||
'ESP_ROM_ELF_DIR environment variable is not defined. Please try to run IDF "install" and "export" scripts.'
|
||||
)
|
||||
if os.name == 'nt':
|
||||
# convert to posix-path for windows
|
||||
rom_elfs_dir = rom_elfs_dir.replace('\\', '/')
|
||||
with open(ROMS_JSON, 'r') as f:
|
||||
with open(ROMS_JSON) as f:
|
||||
roms = json.load(f)
|
||||
if target not in roms:
|
||||
msg_body = f'Warning: ROM ELF is not supported yet for "{target}".' # noqa: E713
|
||||
|
@@ -9,22 +9,21 @@ import jsonschema
|
||||
from elftools.elf.elffile import ELFFile
|
||||
from idf_build_apps.constants import SUPPORTED_TARGETS
|
||||
|
||||
IDF_PATH = os.getenv('IDF_PATH', '')
|
||||
ROMS_JSON = os.path.join(IDF_PATH, 'tools', 'idf_py_actions', 'roms.json') # type: ignore
|
||||
ROMS_JSON = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'roms.json')
|
||||
|
||||
|
||||
def test_roms_validate_json() -> None:
|
||||
with open(ROMS_JSON, 'r') as f:
|
||||
with open(ROMS_JSON) as f:
|
||||
roms_json = json.load(f)
|
||||
|
||||
json_schema_path = os.path.join(os.path.dirname(ROMS_JSON), 'roms_schema.json')
|
||||
with open(json_schema_path, 'r') as f:
|
||||
with open(json_schema_path) as f:
|
||||
schema_json = json.load(f)
|
||||
jsonschema.validate(roms_json, schema_json)
|
||||
|
||||
|
||||
def test_roms_check_supported_chips() -> None:
|
||||
with open(ROMS_JSON, 'r') as f:
|
||||
with open(ROMS_JSON) as f:
|
||||
roms_json = json.load(f)
|
||||
for chip in SUPPORTED_TARGETS:
|
||||
assert chip in roms_json, f'Have no ROM data for chip {chip}'
|
||||
@@ -43,7 +42,7 @@ def test_roms_validate_build_date() -> None:
|
||||
return result
|
||||
|
||||
rom_elfs_dir = os.getenv('ESP_ROM_ELF_DIR', '')
|
||||
with open(ROMS_JSON, 'r') as f:
|
||||
with open(ROMS_JSON) as f:
|
||||
roms_json = json.load(f)
|
||||
|
||||
for chip in roms_json:
|
||||
|
Reference in New Issue
Block a user