cancel
Showing results for 
Search instead for 
Did you mean: 

Porting IAP

Daniel Hatcher
Associate II
Posted on January 03, 2018 at 10:16

Hello, I am new to STM 32 devices so go easy. I would like to port over the IAP included in the AN4854 which is for a STM32072B Evaluation board over to a STM32f746 Discovery board. I have read through the application note a few times. I have previous experience with IAP on other devices so the memory mapping is not the issue....at the moment. What I am struggling on is after changing the device name, my understanding is I then have to change the HAL drivers. What is the best way to go about this without incurring lots of errors?

Thank you

#stm32-f7 #stm32f7-hal #stm32-iap
13 REPLIES 13
Andrew Neil
Evangelist III
Posted on January 04, 2018 at 09:59

STM32072B Evaluation board

So an STM32F072VBT6 microcontroller, then?

http://www.st.com/en/evaluation-tools/stm32072b-eval.html

 

So Cortex-M0

to a STM32f746

Which is Cortex-M7.

Is there not something closer to start with?

after changing the device name

Where?

You haven't said what tools you are using.

change the HAL drivers

Yes - you will need the particular HAL drivers for the chip in question.

The easiest way is often (usually?) to start a fresh project 

for the chip in question, and merge/port other code into that ...

Posted on January 04, 2018 at 10:24

Thanks for the reply. 

I am totally new to ST chips so please forgive me. I was advised to use the IAP example then port it over to the correct device. 

I am using system workbench for STM32. I have also created another project using STM32CubeMX. 

I have used an example project for the

STM32f746 Discovery board and create my own application which include a display.

So would it be better to create my own project using 

STM32CubeMX, then add in the function and header files which are needed for the IAP. I can then set the correct locations in the linker for my application. 

Andrew Neil
Evangelist III
Posted on January 04, 2018 at 12:42

Some suggestions here:

https://community.st.com/0D50X00009XkXMoSAN

Posted on January 04, 2018 at 12:26

Daniel Hatcher wrote:

I am totally new to ST chips so please forgive me.

Not really specific to ST.

While the Flash subsystem (and other peripherals) is not directly related to the core type, my point with Cortex-M0 vs M7 is that M0 is 'bottom of the range', and M7 'top of the range' - so it is quite likely that an M7-based chip will probably also have a 'beefed-up' flash subsystem to match.

I was advised to use the (sic?) IAP example

Who advised?

I think there are several IAP examples - have you checked if there's one specifically for the 

STM32f7...

 ?

would it be better to create my own project using 

STM32CubeMX, then add in the function and header files which are needed for the IAP.

Probably.

then set the correct locations in the linker for my application. 

That's probably not the only thing that'll need changing ...

Posted on January 04, 2018 at 13:17

Slightly different FLASH banking options, but a bit closer on target..

Repository\STM32Cube_FW_F7_V1.8.0\Projects\STM32F769I_EVAL\Applications\IAP

If you've written bootloaders before you might want to see if that is a better starting point, and merge in the FLASH/ST specific stuff. Review how the FLASH is organized via the Reference Manual. Most concepts from other ARM architectures are highly portable to ST's implementations. From a PIC, AVR or 8051 the scale and organization perhaps more dramatically different.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Daniel Hatcher
Associate II
Posted on January 05, 2018 at 09:16

Thank you very much for the help. I will crack on today with your suggestion to start with the project located...

Repository\STM32Cube_FW_F7_V1.8.0\Projects\STM32F769I_EVAL\Applications\IAP and give you an update later on. Thanks 

Daniel Hatcher
Associate II
Posted on January 08, 2018 at 16:29

I have created a project for my board. I can erase and write to a single address then read the address to check that the value has been written correctly which is does. I have then used the function in the examples for writing the whole file to flash and incrementing the address. I have also used a jump to application function for after the flashing. However, after flashing and jump to application the code does not seem to run.

I know that my jump to application function is correct, because if I set the address to jump to the start i.e.0x08000000. The code will then start to reflash and continue in this loop of erase/flash/jump to start.

So it seems to be something to do with my writing. Below is my writing to flash function.

__IO uint32_t read_size = 0x00, tmp_read_size = 0x00;

uint32_t read_flag = TRUE;

/* Erase address init */

LastPGAddress = APPLICATION_ADDRESS;

/* While file still contain data */

while (read_flag == TRUE)

{

/* Read maximum 'BUFFERSIZE' Kbyte from the selected file */

if (f_read(&MyFile, RAMBuf, BUFFERSIZE, (uint_t*) &read_size) != FR_OK)

{

}

/* Temp variable */

tmp_read_size = read_size;

/* The read data < 'BUFFERSIZE' Kbyte */

if (tmp_read_size < BUFFERSIZE) {

read_flag = FALSE;

}

/* Program flash memory */

if (FLASH_If_Write(LastPGAddress, (uint32_t*) RAMBuf, read_size) != FLASHIF_OK)

{

}

/* Update last programmed address value */

LastPGAddress = LastPGAddress + tmp_read_size;

}

f_close(&MyFile);

I have set my linker scripts to the following

Bootloader

FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 64K

RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 320K

Application

FLASH (rx) : ORIGIN = 0x08010000, LENGTH = 960K

RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 320K

#define VECT_TAB_OFFSET 0x10000

I am jumping to the address

0x08010000 too.

Is there a way back to read the device once programmed to see what exactly has been programmed and where? Any help on why my writing function does not work too would be greatly appreciated.

________________

Attachments :

mainV2.c.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HyD0&d=%2Fa%2F0X0000000b4c%2FBkHcWeL_ATbzxhmN9E3TT6SW2B2Ydxvxx9bbgKbIsoE&asPdf=false
Posted on January 08, 2018 at 16:43

The ST-LINK Utilites can read back the device content. You could also save content back onto the SDCard.

Would tend to CRC the data written to FLASH and compare that to the binary file I generated in the linker. Use serial port to output progress/telemetry.

The debugger should permit you to walk into your own code. Have a Hard Fault handler that outputs diagnostics if you end up there, and make sure SCB->VTOR is actually set properly. ie use SCB->VTOR = &__Vectors; rather than the VECT_TAB_OFFSET nonsense.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on January 08, 2018 at 17:17

I have used the ST LINK Utilites software and have found that as I suspected the application is not being flashed. I have debugged the function and it fails due to 

if (tmp_read_size < BUFFERSIZE) {

read_flag = FALSE;

}