HEX files and customized bootloader

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

HEX files and customized bootloader

1,268 次查看
bouhady
Contributor II

I'm working with K64 and KDS .

since there is no USB Host Bootloader for this device I'm tring to implement my own Bootloader.

Based on a "BM USB Host" example for this device (USB Host Project with KSDK 1.3 and Processor Expert ) I create a tool which read and parse .hex file in order to program it automatically.

I edited the original linker file for the code to push adresses by 0x020000 so all the data should be writen in the rest of the memory.

When I'm asking the KDS complier to create in addition to the elf file a HEX file there is just one critical problem : somewhere in the middle of the HEX file one of the packets size takes just 4/8 bytes and then the addresses of the rest of the file now is starting from a XXX8 and XXXC address which is not aligned anymore.

tring to program this packets on the flash returns with FTFx_ERR_SIZE (0x2000) error for the first 4 Byte packet and with FTFx_ERR_ACCERR (0x0020) error for the rest packets probably since the data is not 16 byte aligned anymore.

What is the solution for this situation? is there a simple way to enforce the compiler to create a 16 bytes aligned HEX file or i should invest more time with better robust algorithm for handeling the non-align data?

152607_152607.png2016-05-30_16-46-01.png

标签 (1)
3 回复数

670 次查看
bobpaddock
Senior Contributor III

You can use http://srecord.sf.net to filter/transform .HEX files or convert between S19 and HEX.

0 项奖励
回复

670 次查看
TICS_Fiona
NXP Employee
NXP Employee

Hello Yaniv

I have no knowledge with your bootloader, so I cannot tell exactly why it returns  ERR_SIZE and ERR_ACCERR error. Below is only a tip for your hex data align question.

The HEX file is not generated by compiler, it is created by tool “arm-none-eabi-objcopy.exe” from ELF file, this tool locates at:

C:\Freescale\CW MCU v10.6.4\Cross_Tools\arm-none-eabi-gcc-4_7_3\bin

For its options, please run “arm-none-eabi-objcopy.exe -help” to get the descriptions. Or refer to this link:

https://manned.org/arm-none-eabi-objcopy

Unfortunately This tool does not support align Hex data, I found a workaround, that is to first generate S-record file as below (this tool supports to align S-record data):

s-record.png

Then run “arm-none-eabi-objcopy.exe” to convert S-record data into hex, like below:

arm-none-eabi-objcopy.exe -I srec -O ihex sfs.srec fixed_result.hex

This is the comparison of HEX file generated in KDS IDE,  and the one converted from S-record file.

comparison .png

Best Regards

Fiona Kuang

TIC - Technical Information Center

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Mark Correct button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

670 次查看
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Yani,

When you erase ,it return the FTFx_ERR_SIZE , it is not the reason of the HEX file .

What about the part number of your chip ? What about the size of one sector ?

And when you erase , the least size is one sector , please check. You can show how do

you call the function of "FlashEraseSector()" .

Hope it helps

Alice

0 项奖励
回复