FlashX file names -- what do they mean?

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

FlashX file names -- what do they mean?

Jump to solution
1,619 Views
michaelschwager
Contributor III

I'm using MQX 4.1.2 or whatever the version is with the FlashX examples on K60 with 512kB Flash size

I can get the FlashX swap example working, but I don't fully understand the three filenames used in the fopen(...) calls:

flashx:code

flashx:swap0

flashx:swap1

Clearly these refer to the two different flash banks.

1. Does flashx:code always refer to the "current" bank, whether it's 0 or 1?  Or does it refer to the "other" bank? 

2. Does flashx:swap0 always refer to absolute bank 0?

3. Does flashx:swap1 always refer to absolute bank 1?

4. The example always seems to clone from flashx:swap1 to flashx:code, and then call FLASH_IOCTL_SWAP_FLASH_AND_RESET on flashx:swap0, so I'm not sure how it's swapping.  I'm guessing the meaning of the above filenames changes depending on which bank you're swapped into, but then I'm not sure why you'd need three; two would suffice.  Not enough documentation in MQXIOUG.pdf.

5. I have 512kB Flash size, but the function that checks available size (fseek to IO_SEEK_END) returns some value other than 262144 bytes, which would be exactly one bank (from 0x0000_0000 to 0x0003_ffff, or 0004_0000 to 0007_ffff).  The number is close (about 260,000) but not exactly.  Why the differences?

6. How does the function that checks current image size (fseek to IO_SEEK_END) know where to stop?  It currently returns one byte short of the .bin file size I'm using to load the Flash.

7. How do I check which bank I'm currently executing out of?

8. Does MQX provide any sort of CRC function?  I plan to use IAR linker's ability to add CRC to image.

9. The example upon first executing finds in the Flash memory some "bank swap" or similar text to put in the swapmark structure.  Is my IAR linker adding this?  I'm not sure where it comes from.


thanks

Labels (1)
0 Kudos
Reply
1 Solution
888 Views
RadekS
NXP Employee
NXP Employee

1,2,3)

flashx:code, flashx:swap0, flashx:swap1 are defined in init_flashx.c.

_bsp_flashx_file_blocks constant describes files from software point of view and there isn’t direct connection to physical flash banks.

So, bank0 is here defined as memory range from 0x0000_0000 to 0x0003_ffff and bank1 as memory range from 0x0004_0000 to 0x0007_ffff. It doesn’t reflect current situation in swapping - it is not connected to physical flash bank.

Swap0 is here defined as memory range from 0x0000_0000 to (0x0003_ffff minus one sector size).

Swap1 is here defined as memory range from 0x0004_0000 to (0x0007_ffff minus one sector size).

Last sector from every swap area is used for storing swap configuration. It is price which we pay when we want use swapping feature.

flashx:code is defined as memory range from 0x0000_0000 to end of your code (in default configuration it is calculated automatically by linker).

4)

No, clone_application() function in example code always copy from flashx:code to flashx:swap1.

It doesn’t not big sense copy different way because flashx:code typically represents area from which currently code runs.

5)

Last sector from every swap area is used for storing swap configuration. It is price which we pay when we want use swapping feature.

6)

fseek to IO_SEEK_END is standard IO function. File size is defined in init_flashx.c (you can modified it).

7)

It should be possible, however current flashX driver do not provide such feature.

If you really need it (bank parameters are the same), you can simply use messages in swapmark (part of example code) or implement your own solution.

8)

Unfortunately no, currently we do not provide any example code for calculation/store/verify CRC of binary file.

9)

No, this text is stored into last sector of flash swap are by flashX swap code (do_write_message(&swapmark);).

Note: MQX 4.1.2 will be released in near future but it will be designed just for Vybrid MCUs. Current version is MQX 4.1.1 and next version for K60 will be probably MQX4.2 (Q1/Q2 2015).

I hope it helps you.


Have a great day,
RadekS

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

View solution in original post

0 Kudos
Reply
4 Replies
889 Views
RadekS
NXP Employee
NXP Employee

1,2,3)

flashx:code, flashx:swap0, flashx:swap1 are defined in init_flashx.c.

_bsp_flashx_file_blocks constant describes files from software point of view and there isn’t direct connection to physical flash banks.

So, bank0 is here defined as memory range from 0x0000_0000 to 0x0003_ffff and bank1 as memory range from 0x0004_0000 to 0x0007_ffff. It doesn’t reflect current situation in swapping - it is not connected to physical flash bank.

Swap0 is here defined as memory range from 0x0000_0000 to (0x0003_ffff minus one sector size).

Swap1 is here defined as memory range from 0x0004_0000 to (0x0007_ffff minus one sector size).

Last sector from every swap area is used for storing swap configuration. It is price which we pay when we want use swapping feature.

flashx:code is defined as memory range from 0x0000_0000 to end of your code (in default configuration it is calculated automatically by linker).

4)

No, clone_application() function in example code always copy from flashx:code to flashx:swap1.

It doesn’t not big sense copy different way because flashx:code typically represents area from which currently code runs.

5)

Last sector from every swap area is used for storing swap configuration. It is price which we pay when we want use swapping feature.

6)

fseek to IO_SEEK_END is standard IO function. File size is defined in init_flashx.c (you can modified it).

7)

It should be possible, however current flashX driver do not provide such feature.

If you really need it (bank parameters are the same), you can simply use messages in swapmark (part of example code) or implement your own solution.

8)

Unfortunately no, currently we do not provide any example code for calculation/store/verify CRC of binary file.

9)

No, this text is stored into last sector of flash swap are by flashX swap code (do_write_message(&swapmark);).

Note: MQX 4.1.2 will be released in near future but it will be designed just for Vybrid MCUs. Current version is MQX 4.1.1 and next version for K60 will be probably MQX4.2 (Q1/Q2 2015).

I hope it helps you.


Have a great day,
RadekS

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

0 Kudos
Reply
888 Views
michaelschwager
Contributor III

Thank you very much, this explains everything! ☺ Apparently the first call to read_swapmark was reading some previous value, because when I tried it again today it just read a bunch of 0xff.

I’m currently now able to upload a new flash image in my application, but I haven’t yet implemented the swap feature. I know it’s just one function call, but it’s part of a bigger API so I need to set it up correctly. I still need to implement CRC. I’ve found a few existing libraries out there.

Thanks again for your help.

0 Kudos
Reply
888 Views
Fan_xy
Contributor III

Hello Michael ,

I want to use MQX 4.1.2 , can you tell me where can find it , thank you very much !

Best Regards,

Linda

0 Kudos
Reply
888 Views
michaelschwager
Contributor III

Should be on one of the hundreds of download pages…

Sorry I think I just have 4.1.1. I think 4.1.2 doesn’t exist yet.

http://www.freescale.com/webapp/sps/site/overview.jsp?code=MQXSWDW

0 Kudos
Reply