[SOLVED] Open loader elf file requirements

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [SOLVED] Open loader elf file requirements

    I'm implementing an open loader (actually I had it working on the ST-Link debugger but that sw has bugs) and I'm using IAR EWARM. I see the wiki page for the open loader specifies that all the code should be in a section called PrgCode and all program data should be in a section called PrgData. I have all my Init() functions and friends implemented and my struct FlashDevice filled out etc.

    I'm getting an error when loading the openloader in jlink "****** Error: Error while loading flash algo ELF file: C:\Program Files (x86)\SEGGER\JLink\W25QXX_EXT.elf
    No valid device has been selected."

    I looked at the elf file of one of the compiled openloaders and noticed that my IAR elf file differs in that the section headers of mine are named differently. Before I get into the details of that, I was wondering if there is a document that specifies exactly what jlink is looking for in the elf file in order to load the code and data into memory? For example, is it looking for two Program headers, one for code and data and the other for the info? Is it looking for section headers? When does it look for the Init() (and friends) function address?
  • So to be quite specific, I have:

    “…


    SEGMENTS:



    Type Offset Virtual Physical File Sz Mem Sz Flags Align
    ---- ------ ------- -------- ------- ------ ----- -----

    0: load 0x34 0x2000'0000 0x2000'0000 0x10a0 0x10a0 0x4 R 0x4

    1: load 0x10d4 0x2000'2000 0x2000'2000 0x120 0x120 0x4 R 0x4

    2: load 0x11f4 0x2000'2340 0x2000'2340 0x400 0x400 0x4 R 0x4

    3: load 0x15f4 0x2000'2740 0x2000'2740 0x1f46 0x1f46 0x5 X R 0x4


    SECTIONS:

    Name Type Addr Offset Size Aln Lnk Inf ESz Flags

    ---- ---- ---- ------ ---- --- --- --- --- -----
    1: .shstrtab strtab 0xc1c0 0x77 0x4

    2: .strtab strtab 0xc238 0xe57 0x4

    3: .symtab symtab 0xd090 0x1b00 0x4 2 323 16

    4: DevDscr pbits 0x2000'0000 0x34 0x10a0 0x4 1 0x2 A

    5: PrgData pbits 0x2000'2000 0x10d4 0x120 0x4 1 0x2 A

    6: .data nobits 0x2000'2120 0x11f4 0x68 0x4 1 0x3 WA

    7: .bss nobits 0x2000'2188 0x11f4 0x1b7 0x4 1 0x3 WA

    8: .heap pbits 0x2000'2340 0x11f4 0x400 0x4 1 0x2 A

    9: PrgCode pbits 0x2000'2740 0x15f4 0x1f46 0x4 1 0x6 AX

    10: .debug_frame pbits 0x353c 0x1da9 1

    11: .comment pbits 0x52e8 0x6e29 1

    12: .iar.rtmodel pbits 0xc114 0x7d 1

    13: .ARM.attributes arm_attr 0xc194 0x2a 1

    …”


    whereas one of the example .elf files had:

    “…


    SEGMENTS:



    Type Offset Virtual Physical File Sz Mem Sz Flags Align
    ---- ------ ------- -------- ------- ------ ----- -----

    0: load 0x74 0x2000'0000 0x2000'0000 0x18f8 0x191c 0x7 XWR 0x4

    1: load 0x196c 0x2000'191c 0x2000'191c 0x10a0 0x10a0 0x4 R 0x4


    SECTIONS:

    Name Type Addr Offset Size Aln Lnk Inf ESz Flags
    ---- ---- ---- ------ ---- --- --- --- --- -----

    1: PrgCode pbits 0x2000'0000 0x74 0x18f8 0x4 0x6 AX

    2: .relPrgCode rel 0x6ce0 0x138 0x4 23 1 8 0x40 I

    3: PrgData nobits 0x2000'18f8 0x196c 0x24 0x4 0x3 WA

    4: DevDscr pbits 0x2000'191c 0x196c 0x10a0 0x4 0x2 A

    5: .debug_info pbits 0x2a0c 0x15ae

    6: .rel.debug_info rel 0x6e18 0xa78 0x4 23 5 8 0x40 I

    7: .debug_abbrev pbits 0x3fba 0x424

    8: .debug_pubnames pbits 0x43de 0x22b

    9: .rel.debug_pubnames rel 0x7890 0x18 0x4 23 8 8 0x40 I

    10: .debug_pubtypes pbits 0x4609 0x2c5

    11: .rel.debug_pubtypes rel 0x78a8 0x18 0x4 23 10 8 0x40 I

    12: .debug_aranges pbits 0x48ce 0xf0

    13: .rel.debug_aranges rel 0x78c0 0xc0 0x4 23 12 8 0x40 I

    14: .debug_line pbits 0x49be 0x878

    15: .rel.debug_line rel 0x7980 0xa8 0x4 23 14 8 0x40 I

    16: .debug_str pbits 0x5236 0xc97 1 0x30 MS

    17: .comment pbits 0x5ecd 0x4c 1 0x30 MS

    18: .ARM.attributes arm_attr 0x5f19 0x2f

    19: .debug_frame pbits 0x5f48 0x298 0x4

    20: .rel.debug_frame rel 0x7a28 0x150 0x4 23 19 8 0x40 I

    21: .debug_ranges pbits 0x61e0 0xb8

    22: .rel.debug_ranges rel 0x7b78 0x150 0x4 23 21 8 0x40 I

    23: .symtab symtab 0x6298 0x690 0x4 24 69 16

    24: .strtab strtab 0x6928 0x3b5

    25: .shstrtab strtab 0x7cc8 0xe7

    …”


    You can see the example .elf has two segments, one with the PrgCode and PrgData sections mapped in. Mine has 4 segments and I'm pretty sure that's why I'm getting the error, but i can't be certain until I see the .elf requirements. I'm still getting the load error yet I've met the requirements of having the data in the PrgData section and the code in the PrgCode section and the info struct in the DevDscr section. I have the functions required Init() etc

    351: 20000d11 94 FUNC GLOBAL DEFAULT 4 Init
    352: 20000d6f 14 FUNC GLOBAL DEFAULT 4 UnInit
    353: 20000d7d 32 FUNC GLOBAL DEFAULT 4 EraseSector
    354: 20000d9d 32 FUNC GLOBAL DEFAULT 4 EraseChip
    355: 20000dbd 38 FUNC GLOBAL DEFAULT 4 ProgramPage
    356: 20000de3 38 FUNC GLOBAL DEFAULT 4 SEGGER_OPEN_Read
    357: 20000e09 38 FUNC GLOBAL DEFAULT 4 SEGGER_OPEN_Program
    358: 20000e2f 42 FUNC GLOBAL DEFAULT 4 SEGGER_OPEN_Erase



    Any ideas? Surely the segger engineers don't expect people to guess what's really required in the .elf file?

    The post was edited 2 times, last by mattb351 ().