Hallo,
besteht eine Möglichkeit dem Linker einen uint32 Wert mitzugeben und
damit eine Konstante zu initialisieren.
1 | const uint32_t app_checksum __attribute__((section(".appdata"), used)) = 0xAABBCCDD;
|
2 | const uint32_t app_numpages __attribute__((section(".appdata"), used)) = 100; // num of 2kB pages
|
1 | /* Constant data into "FLASH" Rom type memory */
|
2 | .rodata :
|
3 | {
|
4 | . = ALIGN(4);
|
5 | *(.rodata) /* .rodata sections (constants, strings, etc.) */
|
6 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
|
7 | KEEP(*(.appdata)) /* checksum and length of the app */
|
8 | . = ALIGN(4);
|
9 | } >FLASH
|
1 | $ arm-none-eabi-objdump.exe -s -j .rodata const_var.elf
|
2 | const_var.elf: file format elf32-littlearm
|
3 | Contents of section .rodata:
|
4 | 8002bc0 00000000 00000000 01020304 06070809 ................
|
5 | 8002bd0 02030405 06070809 0a0b0c0d 0e0f1010 ................
|
6 | 8002be0 01020304 05060708 090a0b0c 0d0e0f10 ................
|
7 | 8002bf0 ddccbbaa 64000000 ....d...
|
8 | ^addr ^value
|
Erste Idee war mit einem Binary Editor den Wert auszutauschen
und dann HEX daraus zu machen. Diese Vorgehensweise lässt sich nicht
robust per Makefile umsetzen, da die Variablenaddressen sich ändern.
Zweite Idee war die GCC Toolchain dafür einzusetzen.
Hat jemand ein Beispiel wie man mit objcopy einen Wert in einer
Sektion austauschen kann? Am besten mit Referenz auf Symbol und
nicht eine Adresse.
Hat jemand vielleicht ein Beispiel wie man mit ld das machen kann?
Kann man da nicht mit
1 | _vorher = .;
|
2 | KEEP(*(.appdata)) /* checksum and length of the app */
|
3 | _nacher = .;
|
die Adresse herausfinden und diese zum Setzen neuer Werte benutzen?
ChatGPT hat mir elftools aufschwatzen wollen. Die elf Datei ist danach
vom 2Meg auf 200Meg gegangen. Warum ist mir noch nicht klar.
Wird da beim Schreiben auf eine Adresse der ganze Adressraum ausgerollt?
Bisher habe ich zum Ablegen der Checksumme srec_cat benutzt.
srec_cat in.hex -intel -crop 0x08000000 0x0803EFFC -STM32 0x0803EFFC -o
out.hex -intel
Allerdings wird hier ganze Page für 32bit Checksumme verbraucht.
Und damit die Checksumme passt, sind -fill 0xFF und -unfill 0xFF Aufrufe
notwendig.
Viele Grüße