Hallo zusammen,
ich hab 2 ELFs für AVR:
1. ./default_2/Application.elf
2. ./default_btl/Bootloader.elf (kompiliert mit .text=0x1E000)
Ziel:
Beide sollen in 1 ELF, Fuses & Lockbits aus Application übernehmen.
Klar hab ich gegoogelt und sowohl hier als auch in anderen Foren bereits
einiges dazu gesehen, ich wende mich an Euch, weil ich dennoch nicht
weiter komme...
schaut man in die ELFs zeigt sich folgendes für den Bootloader:
avr-readelf -S ./default_btl/bootloader.elf
1 | There are 7 section headers, starting at offset 0x18fc:
|
2 |
|
3 | Section Headers:
|
4 | [Nr] Name Type Addr Off Size ES Flg Lk Inf Al
|
5 | [ 0] NULL 00000000 000000 000000 00 0 0 0
|
6 | [ 1] .data PROGBITS 00800200 0018a8 000028 00 WA 0 0 1
|
7 | [ 2] .text PROGBITS 0001e000 0000d4 0017d4 00 AX 0 0 2
|
8 | [ 3] .bss NOBITS 00800228 0018d0 0006ab 00 WA 0 0 1
|
9 | [ 4] .fuse PROGBITS 00820000 0018d0 000003 00 WA 0 0 1
|
10 | [ 5] .lock PROGBITS 00830000 0018d3 000001 00 WA 0 0 1
|
11 | [ 6] .shstrtab STRTAB 00000000 0018d4 000028 00 0 0 1
|
und folgendes für die Applikation:
avr-readelf -S ./default_2/Application.elf
1 | There are 8 section headers, starting at offset 0xba7c:
|
2 |
|
3 | Section Headers:
|
4 | [Nr] Name Type Addr Off Size ES Flg Lk Inf Al
|
5 | [ 0] NULL 00000000 000000 000000 00 0 0 0
|
6 | [ 1] .data PROGBITS 00800200 00b7c2 000184 00 WA 0 0 1
|
7 | [ 2] .text PROGBITS 00000000 0000f4 00b6ce 00 AX 0 0 2
|
8 | [ 3] .fw_data PROGBITS 0001df00 00b946 000100 00 A 0 0 1
|
9 | [ 4] .bss NOBITS 00800384 00ba46 00069a 00 WA 0 0 1
|
10 | [ 5] .fuse PROGBITS 00820000 00ba46 000003 00 WA 0 0 1
|
11 | [ 6] .lock PROGBITS 00830000 00ba49 000001 00 WA 0 0 1
|
12 | [ 7] .shstrtab STRTAB 00000000 00ba4a 000031 00 0 0 1
|
Ich habe es also mit avr-objcopy probiert:
1 | avr-objcopy --add-section .bootloader=Bootloader.elf Application.elf
|
--> .bootloader taucht dann zwar auf, aber bei Addr. 0, also:
1 | avr-objcopy --change-section-address .bootloader=0x1e000 Application.elf
|
--> .bootloader taucht an richtiger (Byte-)Adresse auf: 0x1E000, jedoch
ohne Flags, also:
1 | avr-objcopy --set-section-flags .bootloader=code,readonly Application.elf
|
und das kommt raus:
avr-readelf -S ./default_2/Application.elf
1 | There are 9 section headers, starting at offset 0xd4a4:
|
2 |
|
3 | Section Headers:
|
4 | [Nr] Name Type Addr Off Size ES Flg Lk Inf Al
|
5 | [ 0] NULL 00000000 000000 000000 00 0 0 0
|
6 | [ 1] .data PROGBITS 00800200 00b7c2 000184 00 WA 0 0 1
|
7 | [ 2] .text PROGBITS 00000000 0000f4 00b6ce 00 AX 0 0 2
|
8 | [ 3] .fw_data PROGBITS 0001df00 00b946 000100 00 A 0 0 1
|
9 | [ 4] .bss NOBITS 00800384 00ba46 00069a 00 WA 0 0 1
|
10 | [ 5] .fuse PROGBITS 00820000 00ba46 000003 00 WA 0 0 1
|
11 | [ 6] .lock PROGBITS 00830000 00ba49 000001 00 WA 0 0 1
|
12 | [ 7] .bootloader PROGBITS 0001e000 00ba4a 001a1c 00 X 0 0 1
|
13 | [ 8] .shstrtab STRTAB 00000000 00d466 00003d 00 0 0 1
|
Ich flashe die so erstelle Application.elf ins Target.
Er bootet dort in die Application, springt dann zum Bootloader mit:
1 | void (*start)( void ) = 0xF000; // word-adr of bootloader start
|
2 | start();
|
Nach dem Sprung zuckt das Display kurz, danach ist er leider wieder in
der Application.
Testweise lasse ich den Bootloader blinken und Chars am UART ausgeben.
Beides ist nach dem Sprung nicht zu sehen.
Folgendes funktioniert:
Bootloader.hex flashen
Bootloader.hex flashen (ohne Erase Device)
--> jump to 0xF000 ... blinkt und zeigt Chars am UART
--> Der Fehler muss also in meiner avr-objcopy Akrobatik liegen.
Was auffällt:
- die "size" von .text in Bootloader.elf ist nur 17d4
- die "size" von .bootloader in Application.elf ist 1a1c
Frage:
- wie kann man die beiden ELFs wie gewünscht mischen?