gdb can't load cymcuelftool CRC signed hex file due to checksum at location 0x90300000

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
JoLl_4741886
Level 3
Level 3
10 replies posted 10 sign-ins 5 replies posted

My goal is to be able to flash and debug a DFU image that has been CRC-signed. I don't want to flash an unsigned app since it can't be validated by the DFU app. To accomplish this, I am adding commands to POSTBUILD section to copy the CRC-signed hex file over the one that is not signed.

The trouble is that there is a gdb "load error" when starting a debug session with the CRC-signed hex file. It complains that memory location 0x9030000 can't be programmed. The original hex file does not have any lines for address 0x9030000 but the signed hex file does. It appears the cymcuelftool.exe is adding flash locations to the CRC hex file that don't appear in the hex file generated by the gcc build process.

[Edit] I found that 0x90300000 and 0x90500000 are mentioned in the "*.readelf" file. They are labelled .cychecksum and .cymeta. Is there actually something that be be flashed at those locations? I can't find anything in the PSOC6 A-family reference manuals that mention this. Again, I think the debug process is aborting because these locations can't be programmed.

JoLl_4741886_0-1624802310585.png

Here is a snapshot of the end of the hex file. The last few lines show the areas at 0x90300000 and 0x90500000.

JoLl_4741886_0-1624763036712.png

 

0 Likes
1 Solution
JoLl_4741886
Level 3
Level 3
10 replies posted 10 sign-ins 5 replies posted

I solved this by creating a python script to strip the .cychecksum and .cymeta sections from the signed hex file and I added the script to the POSTBUILD commands. The resulting hex file has the main section CRC but doesn't have the ELF checksum and metadata sections. The POSTBUILD also copies the new hex file over the one first generated by the build. Now we can start debug sessions with the bootloader in place.

It seems strange that this problem existed in the first place. Certainly developers would want to start a debug session on a DFU-loaded app.

 

 

# Read hex file line by line and copy to output hex file but skip .cychecksum and .cymeta regions
for line in infile_fp:
    # if line contains the extended address for elf .cychecksum (0x90300000), ignore it
    if line.strip("\n") == ":0200000490303A":
        line = infile_fp.readline()    #throw away line with actual elf checksum
    elif line.strip("\n") == ":0200000490501A":
        line = infile_fp.readline()    #throw away line with metadata
    else:        
        outfile_fp.write(line)

 

 

 

 

View solution in original post

0 Likes
2 Replies
JoLl_4741886
Level 3
Level 3
10 replies posted 10 sign-ins 5 replies posted

Looking at the cymcuelftool documentation, I found that the tool always generates a section for the checksum of the .elf file. I think that is what is causing the issue with gdb loading. 

I can look at writing a utility to strip out the .cymeta and .cychecksum sections from the hex file, but I don't I don't know what gdb will do if the elf file still has those sections.

Any thoughts?

JoLl_4741886_0-1624826736968.png

 

0 Likes
JoLl_4741886
Level 3
Level 3
10 replies posted 10 sign-ins 5 replies posted

I solved this by creating a python script to strip the .cychecksum and .cymeta sections from the signed hex file and I added the script to the POSTBUILD commands. The resulting hex file has the main section CRC but doesn't have the ELF checksum and metadata sections. The POSTBUILD also copies the new hex file over the one first generated by the build. Now we can start debug sessions with the bootloader in place.

It seems strange that this problem existed in the first place. Certainly developers would want to start a debug session on a DFU-loaded app.

 

 

# Read hex file line by line and copy to output hex file but skip .cychecksum and .cymeta regions
for line in infile_fp:
    # if line contains the extended address for elf .cychecksum (0x90300000), ignore it
    if line.strip("\n") == ":0200000490303A":
        line = infile_fp.readline()    #throw away line with actual elf checksum
    elif line.strip("\n") == ":0200000490501A":
        line = infile_fp.readline()    #throw away line with metadata
    else:        
        outfile_fp.write(line)

 

 

 

 

0 Likes