How to edit the value of the FOPT register?

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

How to edit the value of the FOPT register?

Jump to solution
2,279 Views
laszlomonda
Contributor V

Hi guys,

I'd like to edit the value of the FOPT register of the KL03. According to my knowledge, the startup_MKL03Z4.S needs to be edited, but I'm quite clueless regarding the exact byte to edit. Which line / byte should I edit? Also, do I have to negate the bits of the desired value when writing into this file?

Thanks in Advance!

- Laci

1 Solution
1,664 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Laci,

    From the KL03 reference manual, you can get that the FOPT flash address is 0x40D:

pastedImage_1.png

  So you just need to modify the 0x40d in the startup_MKL03Z4.s.

/* Flash Configuration */
    .section .FlashConfig, "a"
    .long 0xFFFFFFFF  /* address 0x400- 0x403 */
    .long 0xFFFFFFFF  /* address 0x404- 0x407 */
    .long 0xFFFFFFFF  /* address 0x408- 0x40b */
    .long 0xFFFF3DFE /* address 0x40c- 0x40f */ //0x3d is the address 40d, if you want to change it, just change it to the data which you want.

    .text
    .thumb

About FOPT register each bit meaning, please refer to the following table:

pastedImage_3.png

Wish it helps you!


Have a great day,
Kerry

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

View solution in original post

0 Kudos
Reply
6 Replies
1,664 Views
danieltruong
Contributor IV

Hi Kerry,

I'm in the same situation where I wish to change the boot option via FOPT flash address 0x40D.

Currently in the start-up file, the 0x40D location has value 0x3F (which means boot from flash). I want to change it to 0xFF (boot from ROM). The reason for this change is I want the bootloader in ROM to perform firmware upgrade with the host when such case is needed. 

After updating the start-up file as mentioned above, compiling and downloading the application into my board, the code got stuck in a small loop in the start-up file as follows (line 191, 192) and never got out of it.

Capture.PNG

Do you know why ? I'm using KDS 3.2.0 and J-Link debugger in my development.

Your help would be greatly appreciated.

--Daniel Truong

0 Kudos
Reply
1,664 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hello Daniel Truong,

   After you download it, your code will enter in ROM.

   So, please exit the debug mode, then use the KBOOT2.0 tool kinetisflash tool to download your application code.

   Please try to download your application code at first.

   If you still have question, please create the your own question post and write assign to kerry zhou,  then tell me the link, I will reply you directly in your own post.


Have a great day,
Kerry

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

1,664 Views
danieltruong
Contributor IV

Kerry,

I followed your advice and it worked!

Thanks,

Daniel

0 Kudos
Reply
1,664 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hello Daniel,

    That's good!

     If you have the new question in the future, welcome to create the new question post.

Best Regards,

Kerry

0 Kudos
Reply
1,665 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Laci,

    From the KL03 reference manual, you can get that the FOPT flash address is 0x40D:

pastedImage_1.png

  So you just need to modify the 0x40d in the startup_MKL03Z4.s.

/* Flash Configuration */
    .section .FlashConfig, "a"
    .long 0xFFFFFFFF  /* address 0x400- 0x403 */
    .long 0xFFFFFFFF  /* address 0x404- 0x407 */
    .long 0xFFFFFFFF  /* address 0x408- 0x40b */
    .long 0xFFFF3DFE /* address 0x40c- 0x40f */ //0x3d is the address 40d, if you want to change it, just change it to the data which you want.

    .text
    .thumb

About FOPT register each bit meaning, please refer to the following table:

pastedImage_3.png

Wish it helps you!


Have a great day,
Kerry

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

0 Kudos
Reply
1,664 Views
laszlomonda
Contributor V

Thank you very much, Kerry! Works perfectly!

0 Kudos
Reply