Hi
I am writing a C++ script for the Kinetis K22F Bootloader to flash some application via USB-HID. I already implemented the getProperty command. Next I want to write the FlashEraseRegion command. However, I am not sure how to find out the end-adress of the application.
Is it correct to assume that end-adress is start-adress + application size? Because I recieve different end-adress compared to the results from the KinetisFlashTool.
Thanks in advance!
Solved! Go to Solution.
Hi,
One easiest way is erase the full chip except the bootloader. If your flash is big, it may takes a bit long time. If you want only erase the application, you should calculate how many sectors the application takes up. Then erase memory. Range is the bootloader start address ~ the sector's end address. The erase operation is always do sector erasing.
Have a great day,
TIC
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 days after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------
Hi,
thank you two (nxf56274 and mykepredkomimet) for the replies. I managed to flash an application now.
At first, I did not realize that the FlashEraseRegion is erasing sectrowise. So what I do now is I calculate the size of my application, round it up to the number of necessary sectors and erase them. This works for me.
Regarding the start a address, I took the one from the reference manual, which is 0xA000. But I am a little confused now after mykepredkomimet post, whether or not I am doing something wrong.
Also I am wondering what the first two bytes of the header in the data phase mean. My header is 02 00 20 00. I already figured out that the last two bytes stand for the size of the message to be send.
Kind regards,
CK3
Hi,
You use 0xa000 for application start address. It means your bootloader size should smaller than the 0xa000. His thoughts is that the application start address should change with the bootloader size changing. A fixed address is OK. You just need confirm your bootloader won't be bigger than 0xa000.
Where do you use the header?
Have a great day,
TIC
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 days after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------
Hi,
I use the header when sending the application to the flash. I divide the application size into parts of 32 bytes and attach the 4 byte long header before each write command.
Thanks!
Hi,
I am not sure. May be it is just a head frame.
Have a great day,
TIC
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 days after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------
Hi @CK3
I think you're asking multiple questions here and it's a bit confusing.
If I were to break it out you have a bootloader that takes up some amount of space and you want to load application after it (which needs the Flash after it to be erased before loading in the application). So you need:
To calculate the Application Start Address, use the statement:
applicationStartAddress = (bootloaderSize * (~(FSL_FEATURE_FLASH_PFLASH_BLOCK_SECTOR_SIZE - 1))) + FSL_FEATURE_FLASH_PFLASH_SECTOR_SIZE;
This will place your application at the start of the sector following the end of the bootloader and is the first sector that you can erase without affecting the bootloader code.
The "applicationStartAddress" is also the first sector you start erasing to the end of the devices Flash before the bootloader loads the application.
Good luck!
myke
Hi,
One easiest way is erase the full chip except the bootloader. If your flash is big, it may takes a bit long time. If you want only erase the application, you should calculate how many sectors the application takes up. Then erase memory. Range is the bootloader start address ~ the sector's end address. The erase operation is always do sector erasing.
Have a great day,
TIC
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 days after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------