2021-02-17 08:28 AM
Hi !
I try to write 2048 Bytes at once to flash.
I do a page erase first of page 31.
EraseInitStruct.TypeErase = FLASH_TYPEERASE_PAGES;
EraseInitStruct.Banks = FLASH_BANK_1 ;
EraseInitStruct.Page = 31;
EraseInitStruct.NbPages = 1;
the description of the HAL library is not clear, what do they mean with "Fast program a 32 row double-word (64-bit) at a specified address.".
I understand a double word as 32 bit, but the HAL comment says 64 bit?
What do they mean with 32 row ? 32 x double word?
its confusing.
my device is a 65k device STM32G431C8T
PageData is a buffer of 2048 Bytes (uint8_t).
FLASH_EEPROM_BASEADDR = 0x0800F800.
When i execute flash_page_write(FLASH_EEPROM_BASEADDR,(uint64_t*)PageData);
i get HAL_ERROR wirh error code 1010100000
flash_status flash_page_write(uint32_t address, uint64_t *data) {
HAL_FLASH_Unlock();
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_FAST_AND_LAST, address, *data)
!= HAL_OK) {
return FLASH_ERROR_WRITE;
}
HAL_FLASH_Lock();
return FLASH_OK;
}
Thank you
2022-04-13 12:37 PM
In the instruction HAL_FLASH_Program(FLASH_TYPEPROGRAM_FAST, address, *data), the last argument should be an address if your are using FAST mode. I use
(uint64_t)(uintptr_t)data
My function is similar to yours, the flashing address is aligned with a double word and page address, but still doesn't work.
2022-04-13 01:37 PM
You are correct, operating blindly here, in a form equivalent to the OP, I have changed that now.
Does ST have expectations that this needs to run from RAM, or without interrupts?
2022-04-13 03:26 PM
I found my mistake, fast programming requires a mass erase, but I was doing just a page erase of multiple pages.
Thanks for your replies.