AnsweredAssumed Answered

STM32F746 Page Size

Question asked by Daniel Hatcher on Jan 15, 2018
Latest reply on Jan 17, 2018 by Daniel Hatcher



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

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

/* 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.