--SREC-LEN 0X10 not aligning to 16 bytes

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

--SREC-LEN 0X10 not aligning to 16 bytes

1,282 Views
barrypurtymun
Contributor II

As many others before me, I am trying to make a custom bootloader (reinventing the wheel, I guess).  I have found the same problem as others with the K64 (I am using the K60). My srec lines are not aligned to 16 bytes, and when I write to flash, this causes a hard fault.  I need to make my boot loader more robust to handle these situation, but then I found an "easy" answer.  I am supposed to be able to put --srec-leg 0x10 in my project flash file settings and have the srec lines aligned to 8 byte lengths.  It seems to do something (after experimenting with different lengths), but not fully work correctly.  I still have lines in my srec file that are shorter than 16 bytes, like some of the lines below.

S214080CA00000FF1FF8B500BFF8BC08BC9E4670479A
S210080CB0F8B500BFF8BC08BC9E467047AC
S20C080CBCA8F7FF7F0100000005
S208080CC435040800DE
S208080CC811040800FE
S214080CCC000000000000000000000000000000000B

If I could make these all be 16 byte lengths, my bootloader would work fine.  Is there anything I am doing wrong that would make this feature work correctly?  I have attached a snip of my output.  

0 Kudos
4 Replies

807 Views
BlackNight
NXP Employee
NXP Employee

Hello,

in addition to what Marc said:

--SREC-LEN affects the number of bytes per line, not the alignment.

For alignment see

Aligning S19 Records to 64-bit Boundaries | MCU on Eclipse 

I hope this helps,

Erich

0 Kudos

807 Views
mjbcswitzerland
Specialist V


Hi Barry

It is not a good idea to require the SREC to be aligned. It is better if the Flash driver has a long word/phrase buffer to temporarily store any dangling bytes in until they can be written; this will avoid potential problems in the future and give you a correctly engineered solution.

You can copy this from the uTasker flash driver [see /Hardware/Kinetis/kinetis_FLASH.h] and see how its SREC/iHEX boot loader does it [\Applications\uTaskerSerialBoot\serial_loader.c] which supports this via USB-MSD, USB-CDC or UART.Git link below.

Regards

Mark


uTasker developer and supporter (+5'000 hours experience on +60 Kinetis derivatives in +80 product developments)
Kinetis: http://www.utasker.com/kinetis.html

Free Open Source solution: https://github.com/uTasker/uTasker-Kinetis
Working project in 15 minutes video: https://youtu.be/K8ScSgpgQ6M

Serial loader user's guide: http://www.utasker.com/docs/uTasker/uTaskerSerialLoader.pdf

0 Kudos

807 Views
barrypurtymun
Contributor II

Mark,

I agree with your advice. You will have to forgive my inexperience. I notice many great applications and drivers are available from utasker. Can you point me to some instructions on how to implement these with KDS. I have always just started projects from scratch.

Thank you,

Barry Purtymun

Link Engineering Company

623-505-9245 Direct

480-862-5015 Mobile

623-505-9250 Main

http://www.linkeng.com<http://www.linkeng.com/>;

0 Kudos

807 Views
mjbcswitzerland
Specialist V

Hi Barry

There is a video at https://youtu.be/K8ScSgpgQ6M showing how to download the project and import it to KDS.
Additional details relevant for KDS are at http://www.utasker.com/kinetis/compilers.html#KDS

Once imported you can select the processor that you work with and configure a serial loader of your choice. The SREC UART one has been used for many years (and since 2011 in many Kinetis devices) so you will immediately have a complete and industrially proven solution that will need no further maintenance.

Regards

Mark


uTasker developer and supporter (+5'000 hours experience on +60 Kinetis derivatives in +80 product developments)
Kinetis: http://www.utasker.com/kinetis.html

0 Kudos