This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Jumping to a specific memory address in the Flash memory

Other Parts Discussed in Thread: MSP430F1612

Hi all,

I'm currently working with a MSP430F1612 MCU based device which is running a small operating system in it. In the flash memory of the MCU there's enough space remaining after the point where the operating system image resides. What I'm going to do is copying another executable file into the remaining space in the flash memory and run it independently without overwriting OS. New executable file is coming from an SD card attached the mobile device. A program running with the operating system will copy that executable file from the SD card to the remaining space in flash.

Up to now we have been able to write an application which can access the SD card and copy its content byte by byte to the empty space in flash memory of the MCU. However when we jump to the starting address of the new executable image from the operating system code, the MCU gets reset. Still we couldn't figure out which went wrong.

I doubt that the executable file might not have written to the flash memory properly. When writing to the flash we used a "long pointer variable" which contains the starting address of the memory location (0xa000 in this case)  where we need our executable program laid. Then while copying each byte of the file in SD card to our pointed location we increment the pointer variable in a loop. I think our executable files bytes get scattered in the flash memory without writing continuously since our pointer variable is too large (data type is long). But I couldn't use a smaller data type pointer since it has to keep a large memory address.

(OS image begins at 0x2500 location and it ends somewhere before 0xa000. From that point I need my new program to run independently from OS. So I'm jumping to 0xa000 location from OS code)

Have I done anything wrong there or is this a possible thing that I'm trying to do? Any comments are welcome.

Thanks!

  • Have you tried verifying your newly written program? You should be able to read out the flash of the MSP and then you will see if your code was properly copied over.

    Also have you made sure that you write to the flash using all precautions? If you write to the main flash area your program writing the flash has to be executed from the RAM if I remember correctly, and you have to erase the blocks first before you start writing something to them. And you have to lookout for prolonged writing as only a certain time of sustained writing is allowed.

  • hi Bernhard,

    How can I check whether new program is written to flash properly? How to read out the flash of MCU? (I'm using GNU tool chain for programming the device)

    My flash writing code is executed from the flash itself. I found somewhere in a TI technical document that it's possible. However I'm not taking any precautions that you have mentioned. Only thing I have done in my code is just declare a pointer variable to the memory location I want, dereference it and assign my bytes coming from the SD card. I though it will work but now it seems I have to look at those block erase stuff. right?

  • I don't know if the GNU toolchain has an utility to read the flash, Jens-Michael Gross uses the mspgcc so maybe he knows.

    I think the  FET-Pro430 Lite Software from elprotronic should be able to read out the flash as well if you have a supported FET-device.

    Yes it is possible to write the flash from the flash - I'm just not so sure about how good it works if you want to write a lot of stuff.  Generally you have to erase the block where you are writing to, to make sure that the flash contains 1s and you can write all the 0s to it as expected. If there would be 0s in that area they cannot be written to 1s - only erased.

    It's also important that you don't write too long to the flash as it might damage/shorten the lifetime of it.

  • Bernhard Weller said:
    I don't know if the GNU toolchain has an utility to read the flash, Jens-Michael Gross uses the mspgcc so maybe he knows.

    MSP430-jtag, which is used to flash the MSP, can also read contents into a TXT file.

    Bernhard Weller said:
    I think the  FET-Pro430 Lite Software from elprotronic should be able to read out the flash as well if you have a supported FET-device.

    Yes, it does. Also, if you program the MSP from it, it will do a separate verify run after the programming. Not an 'internal' verify, but a completely independent pass by reading data from MSP and comparing with the loaded binary. (works even if you didn't flash the MSP but want to know whether it already has the firmware you loaded into the tool)

    Bernhard Weller said:
    Yes it is possible to write the flash from the flash - I'm just not so sure about how good it works if you want to write a lot of stuff.

    I do it for writing data into info memory, and I do it from withing flash to copy over a newly received firmware (buffered in an usused section of flash) to the place where it willa ctually run.
    Works flawlessly. The only important thing is that your flash writing function sets the correct parameters (on 5x family, this is automatic).

**Attention** This is a public forum