cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F746 Page Size

Daniel Hatcher
Associate II
Posted on January 15, 2018 at 17:31

Hi, 

I am in the process and nearly completely writing a bootloader. The bootloader will load small sized programs, however if I load a large file then it goes wrong. I ave tracked this does to the writing by reading the device memory after erasing/flashing and comparing with the original file. 

I am using the function below to write to the flash. 

#define BUFFERSIZE ((uint16_t)1*8192)

uint8_t RAMBuf[BUFFERSIZE] = { 0x00 };

static uint32_t LastPGAddress = APPLICATION_ADDRESS;

__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) {

return DOWNLOAD_FILE_FAIL;

}

/* 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) {

return DOWNLOAD_WRITE_FAIL;

}

/* Update last programmed address value */

LastPGAddress = LastPGAddress + tmp_read_size;

}

I am 99% sure it has something to do with the 

BUFFERSIZE because when comparing the flashed program and the orignal file, it does wrong after 1FFF which is 8192. The while loop should take of writing the next 8192 bytes until the file has all been flashed. 

So is there a page size (like on other processors I have used) that I need to set correctly. 

Thanks

3 REPLIES 3
Daniel Hatcher
Associate II
Posted on January 17, 2018 at 12:05

Issue solved!!!

Daniel Hatcher
Associate II
Posted on January 17, 2018 at 12:44

I read back the device and then checked which areas of the processor are programmed and which areas are not. I then calculated how large my program was. Then found that I needed to change 

#define BUFFERSIZE ((uint16_t)1*8192) 

to

#define BUFFERSIZE ((uint32_t)16*8192)

I then added on extra to allow for updates to expand. I checked this numberous times with different programs and it works. 

Also, I had cpu cache enable in both the bootloader and the application. This causes it to crash, so I only had it in the bootloader application. 

Posted on January 17, 2018 at 12:29

Hi

daniel.014

,

We are interested to know how you resolved this issue. It may be helpful for other users.

Best Regards,

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen