-deleted-
9 years ago.

IAP for Nucleo STM32?

I would appreciate any suggestions for IAP support.

The following is a similar question: http://developer.mbed.org/questions/7149/Writing-to-Flash-Memory-for-NUCLEO-F401R/

Question relating to:

ST
A world leader in providing the semiconductor solutions that make a positive contribution to people’s lives, both today and in the future.

3 Answers

9 years ago.

Hi Ed,

I did a quick search through mbed and, like you, I didn't find anything. I found a document called "STM32F4 in-application programming (IAP) using the USART" on the ST website that might put you on the right path. It even looks like they include some drivers for it.

Here's the page: http://www.st.com/web/en/catalog/tools/PF257903

Hope that helps, Brian

Thank you Brian.

I looked at the C code from your link for AN3965. Placing all of these functions in upper flash seems possible.

posted by -deleted- 20 Apr 2015
9 years ago.

There are the standard STM drivers which afaik include code for flash self-programming. However personally I would just grab the reference manual and do it myself.

Thanks Erik.

Is this the correct reference manual: http://www.st.com/web/en/resource/technical/document/programming_manual/DM00046982.pdf

posted by -deleted- 20 Apr 2015

That one is for programming it externally. This is the reference manual: http://www.st.com/web/en/resource/technical/document/reference_manual/DM00031020.pdf. Chapter 3 discusses the flash controller.

posted by Erik - 20 Apr 2015
8 years ago.

Relating to this discussion...

How can i put a function into specific/certain flash address with only use C (i.e. not modifiying linker scripts)?

The function i mentioned here will get USART data i.e. bin or hex data stream and will put it again a specific location in flash then check lenght/ CRC etc.... Then move it to 0x8000... for STM...

The link provided above provides general structure and codes by using ymodem functions.

Is it possible just with mbed and by not using ymodem?

Yep, put in front of your function:

__attribute__((section(".ARM.__at_0x10000")))

And then of course the address where you want to have it. The compiler will complain if you try to put two things in the same location, so you don't need to worry about that.

See for example also the files in: https://developer.mbed.org/users/Sissors/code/Bootloader_K64F/file/76c37fd3780a/bootloader.cpp

posted by Erik - 28 Mar 2016

Hello Erik,

I must get over this bootloader issue. So i need to ask you more, if possible?

My idea is very similar to your application... But still i need some guidance... I saw example files alxo.. Thx...

1. I must update my application (firmware) over RF... 2. If i use RF i can't send data as steam... I need to divide it 100 - 120 byte packages... (FOTA - Firmware over the air update) 3. I must start bootlader function via command from Rf.. For example if i send "BOOTLOADER" string over RF my nucleo will jump to boot function in specific address and wait for USART data input (i.e. bin or hex file packages) 4. At the end of each data packet i need to send carriage return "\r". So do you think that following USART ISR can handle this? i.e. i will discard the "\r";

void rf_rx_isr()
{
    node.rf_buffer_char = node_rf.getc();
    if (node.rf_buffer_char != '\r') {
        node.rf_input_buffer[node.rf_input_buffer_counter] = node.rf_buffer_char;
        node.rf_input_buffer_counter++;
    } else if (node.rf_buffer_char == '\r') {
        node_rf.attach(NULL, Serial::RxIrq);
        node.rf_input_buffer_counter = 0;
        node.rf_interrupt_complete = true;
    }
}

or what if my bin or hex file contains "\r" ?? This is problematic. Maybe i can read 100 bytes every time which i know that 101st is "\r", by using another USART Rx ISR whick does not take into consideration of "\r"? And then store next packet starting from 100th element of array?

5. Must i store this hex or bin in an array? If so below array can be used? i.e. byte array...??

uint8_t storage[FILESIZE]

6. How can i copy the stored hex/bin from array (RAM) to 0x0800 0000 of STM??

Thx for support...

posted by Kamil M 28 Mar 2016

Making a bootloader is not really trivial. Regarding point 1, you can try opening a hex file, I think they contain \r, but it might also be only \n. Or you can use the natural line size of a hex file to send it per line over RF.

When you use a bin file the only options you have are counting bytes, or using a timeout where you assume if nothing new arrives for a while it is done. You cannot check for \r since every character can be in a bin file.

You can store this hex/bin in an array, but your RAM is alot smaller than your flash, so you can store only little in your RAM. Either you need to program directly such as in my Freescale example (but then you cannot use for example getc()), or first program it to an unused part of your flash, and then copy it to the start of your flash. For this you need to make IAP functions.

posted by Erik - 29 Mar 2016