Bootloader - problem to Flash data

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

Bootloader - problem to Flash data

Jump to solution
1,212 Views
engenheiroeletr
Contributor I

Microcontroller: MK22FX512

I have a problem with the Bootloader.

The bootloader was working perfectly, but now it is presenting a problem in a specific point (near to the end) of the .srec file.

This is the end of a .srec file that can be flashed with no problem.

S214025DF84956454C20202020A55A000100000001E3
S214025E08020000000300808080808080808080906E
S214025E189090909080808080808080808080808033
S214025E288080808080801804040404040404040427
S214025E380404040404040202020202020202020227
S214025E4804040404040404434343434343414141D2
S214025E584141414141414141414141414141414123
S214025E684104040404040423232323232321212195
S214025E782121212121212121212121212121212103
S214025E882104040404800000000000000000000052
S214025E9800000000000000000000000000000000F3
S214025EA800000000000000000000000000000000E3
S214025EB800000000000000000000000000000000D3
S214025EC800000000000000000000000000000000C3
S214025ED800000000000000000000000000000000B3
S214025EE800000000000000000000000000000000A3
S214025EF80000000000000000000000000000000093
S20C025F0800000000000000008A
S214025F1014086400C800000001010101000100002D
S214025F20010102021E0A0A010100000010003000F0
S214025F306400000002000000050A1432030032006A
S214025F406400DC05030150050200B80B0A231E009C
S214025F500102010101010264FFFFFFFFFFFFFFFFD5
S20C025F603200050F01010000EA
S214025F68105F02000080FF1F58000000685F0200F2
S214025F7800000020000000000000000000000000F2
S208025F88000000000E
S80401919DCC

This is the end of a .srec file that can't be flashed

S2140262F041444F20A55A00010000000102000000A0
S2140263000300808080808080808080909090909033
S2140263108080808080808080808080808080808076
S214026320808018040404040404040404040404041A
S214026330040402020202020202020202040404042A
S21402634004040443434343434341414141414141E1
S21402635041414141414141414141414141040404DD
S2140263600404042323232323232121212121212161
S214026370212121212121212121212121210404045D
S2140263800480000000000000000000000000000082
S21402639000000000000000000000000000000000F6
S2140263A000000000000000000000000000000000E6
S2140263B000000000000000000000000000000000D6
S2140263C000000000000000000000000000000000C6
S2140263D000000000000000000000000000000000B6
S2140263E000000000000000000000000000000000A6
S2140263F00000000000000000000000000000000096
S2080264000000000091
S21402640414086400C8000000010101010001000034
S214026414010102021E0A0A010100000010003000F7
S2140264246400000002000000050A14320300320071
S2140264346400DC05030150050200B80B0A231E00A3
S2140264440102010101010264FFFFFFFFFFFFFFFFDC
S20C0264543200050F01010000F1
S21402645C046402000080FF1F580000005C64020007
S21402646C00000020000000000000000000000000F9
S20802647C0000000015
S80401942541

When the bootloader have to flash the bold line above, the problem occurs.

Debug:

Until the address 0x26434 the flasher is ok

pastedImage_8.png

The image below shows what happen when it flashs the address 0x26444 

pastedImage_9.png

Then the CPU stops and goes to:

PE_ISR(Cpu_Interrupt)
{
   /* This code can be changed using the CPU component property "Build Options / Unhandled int code" */
   PE_DEBUGHALT();
}

Attemps to solve the problem:

I reduced the code to check if the problem occurs just in this address (0x26444), but the problem occurs in others address too, but always when flash the datas of the line (0102010101010264FFFFFFFFFFFFFFFF)

Does anybody have idea what can be happen?

0 Kudos
1 Solution
956 Views
mjbcswitzerland
Specialist V

Hi

The K22FX512 user phrase programming (8 aligned bytes at a time). You show 0x26440 programmed betfore the line starting at 0x26444, which would be an illegal operation (it is not allowed to program the first phrase again with a different value since it damages the flash and generally causes the sector to become unreadable [with hard fault later]).
Therefore you need to store the value 0x0a231e00 which is to be programmed to 0x26400 until you get the start of the following line (the 0x01020101 for 0x26444) and write it as a single phase of 0x0a231e0001020101).

In case of difficulties, copy the SREC loader from the open source uTasker project (links below - document http://www.utasker.com/docs/uTasker/uTaskerSerialLoader.pdf) or its flash driver interface which handles all such details.

Regards

Mark


Kinetis: http://www.utasker.com/kinetis.html
Kinetis K22:
- http://www.utasker.com/kinetis/FRDM-K22F.html
- http://www.utasker.com/kinetis/TWR-K22F120M.html
- http://www.utasker.com/kinetis/BLAZE_K22.html
- http://www.utasker.com/kinetis/tinyK22.html
Serial Loader: http://www.utasker.com/docs/uTasker/uTaskerSerialLoader.pdf

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

For better, faster, cheaper product developments consider the uTasker developer's version, professional Kinetis support, one-on-one training and complete fast-track project solutions to set you apart from the herd : http://www.utasker.com/support.html

View solution in original post

0 Kudos
6 Replies
957 Views
mjbcswitzerland
Specialist V

Hi

The K22FX512 user phrase programming (8 aligned bytes at a time). You show 0x26440 programmed betfore the line starting at 0x26444, which would be an illegal operation (it is not allowed to program the first phrase again with a different value since it damages the flash and generally causes the sector to become unreadable [with hard fault later]).
Therefore you need to store the value 0x0a231e00 which is to be programmed to 0x26400 until you get the start of the following line (the 0x01020101 for 0x26444) and write it as a single phase of 0x0a231e0001020101).

In case of difficulties, copy the SREC loader from the open source uTasker project (links below - document http://www.utasker.com/docs/uTasker/uTaskerSerialLoader.pdf) or its flash driver interface which handles all such details.

Regards

Mark


Kinetis: http://www.utasker.com/kinetis.html
Kinetis K22:
- http://www.utasker.com/kinetis/FRDM-K22F.html
- http://www.utasker.com/kinetis/TWR-K22F120M.html
- http://www.utasker.com/kinetis/BLAZE_K22.html
- http://www.utasker.com/kinetis/tinyK22.html
Serial Loader: http://www.utasker.com/docs/uTasker/uTaskerSerialLoader.pdf

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

For better, faster, cheaper product developments consider the uTasker developer's version, professional Kinetis support, one-on-one training and complete fast-track project solutions to set you apart from the herd : http://www.utasker.com/support.html

0 Kudos
956 Views
engenheiroeletr
Contributor I

Is there a way to configure CodeWarrior to generate srec file with 8 aligned bytes?

All srec file is aligned, but just in the end it is changed.

0 Kudos
956 Views
mjbcswitzerland
Specialist V

Hi

You could write an SREC to SREC conversion program that ensures alignment but it seems a poor engineering solution. It is better to correct the loader problem (flash driver) rater than require a non-standard input to be required (it only takes a few lines of additional code to buffer unaligned content until it can safely be committed).

Regards

Mark

0 Kudos
956 Views
engenheiroeletr
Contributor I

Thanks mjbcswitzerland‌. I solved the problem aligning the 8 bytes before flash them.

0 Kudos
956 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi engenheiroeletronico,

    Please tell me what the bootloader your are using for MK22FX512, if you always meet problem with 0102010101010264FFFFFFFFFFFFFFFF, I think it is maybe caused by the bootloader code. Now please check these points:

1. Check your bootloader code, especially check the flash write code for the .srec

    Whether it check the data is 0XFF before it do the program.

    This is very important.

 2. If you have interest,     I think you can try to modify: 0102010101010264FFFFFFFFFFFFFFFF to other data, especially modify FFFFFFFFFFFFFFFF, you can modify some FF to other none ff data, but at last, you also need to calculate the correct checksum data, checksum = NOT(length + address + data).

Please check it on your bootloader code, then debug the code and check the flash according address.

Wish it helps you!

Any updated information, please kindly let me know!


Have a great day,
Kerry

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

0 Kudos
956 Views
engenheiroeletr
Contributor I

Hi Kerry,

1. Check your bootloader code, especially check the flash write code for the .srec

    Whether it check the data is 0XFF before it do the program.

    This is very important.

Yes, the function check 0xFF.

I am using the function generated by the Processor Expert:

IFsh1_SetBlockFlash((IFsh1_TDataAddress)data_addr, flash_addr, nofDataBytes)

 2. If you have interest,     I think you can try to modify: 0102010101010264FFFFFFFFFFFFFFFF to other data, especially modify FFFFFFFFFFFFFFFF, you can modify some FF to other none ff data, but at last, you also need to calculate the correct checksum data, checksum = NOT(length + address + data).

Instead modify the line, I erased it, Then the problem happend in the address 0x2646C. Please see the images bellow.

S2140262F041444F20A55A00010000000102000000A0
S2140263000300808080808080808080909090909033
S2140263108080808080808080808080808080808076
S214026320808018040404040404040404040404041A
S214026330040402020202020202020202040404042A
S21402634004040443434343434341414141414141E1
S21402635041414141414141414141414141040404DD
S2140263600404042323232323232121212121212161
S214026370212121212121212121212121210404045D
S2140263800480000000000000000000000000000082
S21402639000000000000000000000000000000000F6
S2140263A000000000000000000000000000000000E6
S2140263B000000000000000000000000000000000D6
S2140263C000000000000000000000000000000000C6
S2140263D000000000000000000000000000000000B6
S2140263E000000000000000000000000000000000A6
S2140263F00000000000000000000000000000000096
S2080264000000000091
S21402640414086400C8000000010101010001000034
S214026414010102021E0A0A010100000010003000F7
S2140264246400000002000000050A14320300320071
S2140264346400DC05030150050200B80B0A231E00A3
S20C0264543200050F01010000F1
S21402645C046402000080FF1F580000005C64020007
S21402646C00000020000000000000000000000000F9
S20802647C0000000015
S80401942541

pastedImage_6.png

pastedImage_7.png

0 Kudos