Splitting bin file for programming flash A/B banks via USB & LPCscrypt

cancel
Showing results for 
Search instead for 
Did you mean: 

Splitting bin file for programming flash A/B banks via USB & LPCscrypt

1,078 Views
quex
Contributor I

I have a two-core application running on LPC4357. The application for the M4 core is located in the Flash bank A and the application for M0 is located in the bank B.

I'd like to program both flash areas through USB using LPCScrypt.

The IDE (LPCXpresso / MCUXpresso) generates one large bin file.

Could you please recommend a convenient way to generate/extract the two parts?

I've done it using a HEX editor. It works, but I wouldn't call that approach convenient.

Thanks

0 Kudos
3 Replies

863 Views
quex
Contributor I

Hello Bob,

thank you. SRecord is a nice tool.

I am able to to extract the BankA part using the crop filter:

srec_cat source.bin -binary -crop 0x00 0x080000 -o BankA.bin -binary

And the BankB part using the offset filter:

srec_cat source.bin -binary -offset -0x01000000 -o BankB.bin -binary

The only problem is that I end up with the BankA.bin padded with zeros up to the size of the flash and the BankB.bin without additional zeros. That is just a cosmetic problem, but does anybody know how to get rid of those zeros when I do not know the length of the actual data? (Alternatively how to add the zero padding to the BankB binary and pretend that it's intentional ;o)

0 Kudos

863 Views
bobpaddock
Senior Contributor III

Here are some examples plucked from my Makefiles.
Note the -Fill with -over option.

As well as how to align to a given block size and the use of parentheses to nest commands.


It might make sense to do the Fill on split Hex files before the bin conversion.

-----

# Find out the size:
srec_info $(OBJDIR)/$(TARGET).org.s19


# Note we build two CRC's the old one we always used so older boards can still be loaded by older program, then the new one used by newer BootLoaders:
srec_cat $(OBJDIR)/$(TARGET).org.hex -Intel -Little_Endian_CRC16 -MAximum-Address $(OBJDIR)/$(TARGET).org.hex -Intel -Cyclic_Redundancy_Check16_XMODEM -Fill 0xFF -OVER $(OBJDIR)/$(TARGET).org.hex -Intel -Output $(OBJDIR)/$(TARGET).hex.xmd -Intel
srec_cat $(OBJDIR)/$(TARGET).hex.xmd -Intel -Fill 0xFF -over $(OBJDIR)/$(TARGET).hex.xmd -Intel -o $(OBJDIR)/$(TARGET).flash.bin.1 -binary

# Align to 8 byte boundary:
# srec_cat test4.s19 -Output_Block_Size 8 -Output_Block_Packing -output test4new.s19
#
# Align to 64 byte boundary, which prevents internal breaks in srec_cat's implementation:
# srec_cat test4.s19 -Output_Block_Size 64 -Output_Block_Packing -output test4new64.s19


srec_cat \
'(' $(OBJDIR)/$(TARGET).org.s19 -Motorola -Fill 0xFF -Over $(OBJDIR)/$(TARGET).org.s19 -Motorola ')' \
-Output $(OBJDIR)/$(TARGET).$(NEW_BUILDNUMBER).bin -Binary

srec_cat -Output_Block_Size 64 -Output_Block_Packing \
'(' $(OBJDIR)/$(TARGET).org.s19 -Motorola -Fill 0xFF -Over $(OBJDIR)/$(TARGET).org.s19 -Motorola ')' \
-Output $(OBJDIR)/$(TARGET).$(NEW_BUILDNUMBER).s19 -Motorola

# Show what is in the Boot Config Area:
@echo KBOOT BCA:
srec_cat $(TARGET_DIR)/$(TARGET).bin -binary -crop 0x3c0 0x400 -output - -hex_dump
srec_cat $(TARGET_DIR)/$(TARGET).bin -binary -crop 0x400 0x410 -output - -hex_dump

srec_cat RadioBinaries/Model$(GPSPATH)/Radio_Model$(GPSPATH)_NoBootloader.hex -Intel -Output RadioBinaries/Model$(GPSPATH)/Radio_Model(GPSPATH)_flash.c -C_Array Radio_Flash

0 Kudos

862 Views
bobpaddock
Senior Contributor III

SRecord is generally useful for file transformations, such as format conversions and spitting.

https://sourceforge.net/projects/srecord/

0 Kudos