How do you write data to internal P-Flash for MK22F51212?

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

How do you write data to internal P-Flash for MK22F51212?

1,428 Views
brendanmerna
Contributor IV

I need to write a value to the flash as a check bit for the bootloader. So the bootloader can determine whether to stay in bootloader to update the program or jump to the existing application.

Tags (1)
0 Kudos
6 Replies

1,173 Views
brendanmerna
Contributor IV

Here I attached the relevant flash files that I made.

-Brendan

0 Kudos

1,173 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi Brendan,

Sorry for the later reply.

Please make sure the erased sector is not in Flash protection range.

Could you provide the FTFE_FPROTn registers value for double check?


Have a great day,
Ma Hui

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

0 Kudos

1,173 Views
brendanmerna
Contributor IV

Ma Hui,

Do you mean the FTFA_FPROTn? Using the EmbSys Register tab in kinetis those registers are all 0xFF. Seems like that would mean nothing is protected.

-Brendan

0 Kudos

1,173 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi Brendan,

Please check [Erase Flash Sector Command] info with K22 reference manual:
pastedImage_1.png

The ACCERR with below condition, please check if the provided Flash address is no phrase aligned (flash_address[2:0] = 000).

pastedImage_2.png

And could you check with MCUXpresso SDK for TWR-K22F120M [flash] demo, which located with below path:

..\SDK_2.2_TWR-K22F120M\boards\twrk22f120m\driver_examples\flash\pflash\iar

If that demo also with same issue on your site? Thanks.


Have a great day,
Ma Hui

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

0 Kudos

1,173 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

If using runtime routine to program data at Flash address, customer could refer TFS Flash Driver Software for Kinetis® and ColdFire+ Microcontrollers(REV 1.03) provided [demo_normal].
https://www.nxp.com/downloads/en/device-drivers/C90TFS_FLASH_DRIVER.exe

Customer could refer [MK21FN1M0xxx10] chip related code as an example.

Wish it helps.


Have a great day,
Ma Hui

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

0 Kudos

1,173 Views
brendanmerna
Contributor IV

Hey Ma Hui,

I implemented the driver examples in the SDK, but its causing an error return when I try to go erase the flash. The result I get back is kStatus_FLASH_AccessError. Is there another step I need to do to unlock something.

-Brendan

0 Kudos