2023-11-09 07:34 PM - edited 2023-11-09 07:35 PM
Due to engineering requirements, the code is divided into two parts: USB DFU, including encrypted signature verification, and the APP code with header signature file. Currently, there is an attempt to rewrite the flash in the USB DFU orange section from the APP code, but it has not been successful. The reason has not been identified yet. Are there any other directions to test, considering that writing Flash data at the end of the APP code is working fine?
The MCU in use is STM32F401RET6.
code as below
int pending_len = writing_len;//writing_len=374
int wr_idx = 0;
ret = HAL_FLASH_Unlock();
if (ret != 0) {
uart_printf("flash unlock failed\n");
goto failed;
}
Solved! Go to Solution.
2023-11-10 02:16 PM
>>HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, 0x800F7FF + wr_idx, *src32);
Writing words to odd misalign addresses is NOT permitted.
2023-11-10 01:23 PM
The usual suggestions - what IS the error code that you get? Debug the code, stepping into the HAL_FLASH_Program() function and see where/why it generates that error. Or do you get an "OK" response but the FLASH isn't actually programmed?
ret = HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, 0x800F7FF + wr_idx, *src32);
The first time this is called, wr_idx = 0 so you are trying to write to 0x0800F7FF. Is that really the first address of the ununsed area? I would have expected 0x0800F800. Is the DFU area write protected or otherwise restricted?
2023-11-10 02:16 PM
>>HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, 0x800F7FF + wr_idx, *src32);
Writing words to odd misalign addresses is NOT permitted.