K60 Flash_LDD Causing hard fault

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

K60 Flash_LDD Causing hard fault

1,488 Views
ETCTim
Contributor I

Hello,

I am creating a Bootloader for my K60FN1M.

I am using the Flash_LDD component in processor expert.

I read and parse a SRecord line, and then write it to Flash.

Occasionally, writing flash causes a Hard Fault. I think this is related to the write size of the Flash being 8 bytes, and sometimes the SRecord lines are not aligned to 8 bytes.

Since Flash can only be written once after an erase cycle, I think the driver is writing to some of the 8 bytes, and then on the next SRecord line, it writes to the additional bytes, causing a hard fault.

Does anyone have an experience with this, or is there a good way to work around this?

Thanks,

Tim

Labels (1)
0 Kudos
Reply
5 Replies

1,118 Views
Kan_Li
NXP TechSupport
NXP TechSupport

The CW 10.4 has provided the Flash_LDD demo , and you may refer to it for details. It locates in "D:\CW MCU v10.4\MCU\CodeWarrior_Examples\Processor_Expert\Kinetis\TWR-K20D72M\FLASH", it is for K20D72M, but should be useful for K60FN1M.

Hope that helps,

B.R

Kan

0 Kudos
Reply

1,118 Views
ETCTim
Contributor I

Hi Kan,

Thanks for your response.

Turns out the K20 has a 4 byte flash write size, which is perfect since it is a 32 bit processor.

The K60 for some reason has a 8 byte flash write size which makes it more difficult.

Thanks,

Tim

0 Kudos
Reply

1,118 Views
DerekLau
Contributor IV

K60F has a 8-byte write size while K60D or K60N has a 4-byte write size. To generate an 8-byte packed s-record, in the link file change ALIGN(4) to ALIGN(8). You may need to add some more . = ALIGN(8);


0 Kudos
Reply

1,118 Views
ETCTim
Contributor I

Hi Derek,

Thanks for the help.

Is there anyway to make the linker create a SRecord with the length of data aligned to 8 bytes? I can adjust the max length, but that doesn't guarantee a data length with a multiple of 8.

For instance, the default 80 max SRecord length produces data of length 76, not a muliple of 8.

If I change it to 84, I get data of length 80. So, for the most part, it works out, but it doesn't guarantee that a shortened line won't screw things up.

Any ideas?

Tim

0 Kudos
Reply

1,118 Views
monXii
Contributor III

hey tim,

why do you read only 1 line of the srecord file ..

just read 2 or multiple lines .. so you have every time 8 bytes to flash ..

only at the last line you have to "fill up" the data with 0xff .. ?!

you can also flash a full sector .. 2048 bytes .. so collect every time 2048 bytes and flash them .. !?

it would even speed it up .. :smileyhappy:

0 Kudos
Reply