Firmware upgrade mechanism

cancel
Showing results for 
Search instead for 
Did you mean: 

Firmware upgrade mechanism

Jump to solution
1,519 Views
joseblanco
Contributor II

Hi everyone!

I'm working with K40 and I have to develop a firmware upgrade mechanism. The code has to be able to receive an image data (new Firmware) and test it during a time period. If everything is fine, the old firmware version is discarded and it reboots with the new firmware. Else, the new firmware is discarded, and it reboots with the old version.

The actual firmware version is in Flash at 0x800. I have doubts about how and where I program de new firmware in order not to erase the old version. Is it possible to program the new firmware in FlexMemory, test the new firmware there and, if it runs ok, program the new firmware at 0x800?

It's no possible to program it in flash because there's not enough space for both of the firmwares (actual and new).

What do you suggest me to do?

Thanks!

0 Kudos
1 Solution
246 Views
LuisCasado
NXP Employee
NXP Employee

Hi,

In this case, you have 256K of P-Flash and 256K of D-Flash. You can use the 512K for code. You only have to modify the linker file to support the D-Flash as code.

But you are not using the FlexMemory (4K), you are using the second bank of flash as code memory. If you two firmware sizes are below 512K is ok, You can also make a small bootloader to manage the vector table and program entry point to execute the OLD/NEW firmware.


Luis

View solution in original post

0 Kudos
11 Replies
246 Views
LuisCasado
NXP Employee
NXP Employee


Hello,

I think that you should use the SWAP feature in Kinetis.

Check RM :  29.4.1 Program Flash Memory Swap

Otherwise you would have to put the old  firmware in an external SPI NOR while the new firmware is validated.

Luis

0 Kudos
246 Views
joseblanco
Contributor II

For the devices containing program flash and FlexNVM (K40), since there is only one program flash block, the program flash swap feature is not available and it's not possible to use an external SPI NOR.

Do you think it's viable to program the new FW in Flex memory and test it at runtime?

Thanks for the help.

0 Kudos
246 Views
dieterteuchert
Contributor IV

You mean, you have chosen a device where the combined "old" and "new" firmware fits into program flash plus FlexNVM flash, and now you find it complicated to implement? Why don't you chose a device where everything fits into program flash? I think with the complexity you require, try to keep the implementation as simple as possible.

0 Kudos
246 Views
joseblanco
Contributor II

I'm not saying that I found it complicated to implement, just saying if it is possible to do. I've never used FlexNVM and I'm new in kinetis programming.

0 Kudos
246 Views
LuisCasado
NXP Employee
NXP Employee

Hi,

You have to look at the DS/RM of the part you want to use and see what is the configuration your device have. It depends on the exact partnumber. You can find two 'types' of flash, P-Flash and D-Flash. Both flash are ablr to execute code, but only D-Flash can be used as Flex Memory. So in the Kinetis family, you can have:

One P-Flash bank
Two P-Flash banks (with SWAP mechanism)

One P-Flash and other D-Flash (in some devices, the same size, other P-Flash is bigger than D-Flash)

So, You can use D-Flash (the same used by Flex Memory) to store firmware or execute code, but in this case you manage the D-Flash in the same way you use P-Flash. No real Flex Memory, as Flex memory is limited by the amount of FlexRAM to manage EEPROM functionality.

What is the exact partnumber you want to use?

Regards,

Luis

0 Kudos
246 Views
joseblanco
Contributor II

I'm using MK40X256VLQ100:

CPU frequency: 100Mhz

Pin count: 144

Package:LQFP

Total flash memory: 512KB

Program flash: 256KB

EEPROM: 4KB

SRAM: 64KB

GPIO: 98

0 Kudos
247 Views
LuisCasado
NXP Employee
NXP Employee

Hi,

In this case, you have 256K of P-Flash and 256K of D-Flash. You can use the 512K for code. You only have to modify the linker file to support the D-Flash as code.

But you are not using the FlexMemory (4K), you are using the second bank of flash as code memory. If you two firmware sizes are below 512K is ok, You can also make a small bootloader to manage the vector table and program entry point to execute the OLD/NEW firmware.


Luis

View solution in original post

0 Kudos
246 Views
joseblanco
Contributor II

Thank you very much Luis, it's like I had thought.

I will try to program the second bank of flash (D-Flash) with the new firmware, test it and if everything is fine, program it into first back of memory (P-Flash), after delete the old firmware version. I also have to think how to copy the firmware in D-Flash to P-Flash. I'll notify you!

0 Kudos
246 Views
charliemmao
Contributor II

Hi Jose

Have you solved the problem? If you do can you please help me to solve my problem?

I am using MK60D512, it has only one flash of 512K. I can place both bootloader and firmware on this flash. But it doesn't run when bootloader verified the firmware and jumped to the firmware application.

Thanks a lot!

Charlie

0 Kudos
246 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Charlie:

I recommend you to start a new thread about this, and provide more details about your issue:

- Custom bootloader or FSL example bootloader?

- Using CodeWarrior, IAR, Keil or other?

- Did you redirect vectors in your application?

And any other information that allows community members to help you.

Regards!

Jorge Gonzalez

0 Kudos
246 Views
dieterteuchert
Contributor IV

If you read a little, you will find that FlexNVM is based on a combination of flash and SRAM and if i remember right the flash part can be used as program flash, i mean you can execute from that flash, too. Except you need to configure the extra flash for this mode and except you won't have one continuous address range. So it is easier if you do it with a part that has enough program flash.