2025-05-26 12:06 AM
I am using NUCLEO-H563ZI and am trying to implement bank swap for firmware update. I am using YMODEM to update firmware. Initially when my code is being executed from BANK 1 and after writing the new firmware at BANK 2. The code execution starts from BANK 2 successfully. But the reverse in not happening. After all the process I checked the address where I am writing the new firmware in BANK 1 and nothing was there which cause hard fault.
Therefore, why the process doesn't fail initially when writing firmware at BANK 2 and it fails only when writing at BANK 1 even though the code is same. Below I have attached some files.
void SerialDownload(void)
{
uint8_t number[11] = {0};
uint32_t size = 0;
COM_StatusTypeDef result;
Serial_PutString((uint8_t *)"\rWaiting for the file to be sent ... (press 'a' to abort)\n\r");
result = Ymodem_Receive( &size );
if (result == COM_OK)
{
if ((erase_operation==1) && (end_of_download_operation ==0))
{
end_of_download_operation = 1;
}
Serial_PutString((uint8_t *)"\n\n\r Programming Completed Successfully!\n\r-----------------------\r\n Name: ");
Serial_PutString(aFileName);
Int2Str(number, size);
Serial_PutString((uint8_t *)"\n\r Size: ");
Serial_PutString(number);
Serial_PutString((uint8_t *)" Bytes\r\n");
Serial_PutString((uint8_t *)"-----------------------\n");
}
else if (result == COM_LIMIT)
{
Serial_PutString((uint8_t *)"\n\n\rThe image size is higher than the allowed space memory!\n\r");
}
else if (result == COM_DATA)
{
Serial_PutString((uint8_t *)"\n\n\rVerification failed! Error while writing to the Flash\n\r");
}
else if (result == COM_ABORT)
{
Serial_PutString((uint8_t *)"\r\n\nAborted by user.\n\r");
}
else if (result == ERASE_ERR)
{
Serial_PutString((uint8_t *)"\r\n\nERROR! Erasing the Flash.\n\r");
}
else
{
Serial_PutString((uint8_t *)"\n\rFailed to receive the file!\n\r");
}
}
Solved! Go to Solution.
2025-05-26 4:14 AM - edited 2025-06-02 10:49 PM
Ok I got it. In my case Bank 1 is at 0x08000000 and Bank 2 is at 0x08100000. So when the SWAP_BANK bit is set it remaps the logical addresses. After reset code is being executed from Bank 2, it is remapped at 0x08000000 and Bank 1 is at 0x08100000. So I was writing the new firmware at 0x08000000 from where the code is being generated so it would fail.
Therefore, whenever I get new firmware I have to write it at 0x08100000. For more reference go through this article:
STM32H5_USB_DFU_Dual_Bank_demo/STM32H5 USB DFU Dual Bank.pdf at main · stm32-hotspot/STM32H5_USB_DFU_Dual_Bank_demo
2025-05-26 1:24 AM
Does it have to do anything with ICACHE?
2025-05-26 4:14 AM - edited 2025-06-02 10:49 PM
Ok I got it. In my case Bank 1 is at 0x08000000 and Bank 2 is at 0x08100000. So when the SWAP_BANK bit is set it remaps the logical addresses. After reset code is being executed from Bank 2, it is remapped at 0x08000000 and Bank 1 is at 0x08100000. So I was writing the new firmware at 0x08000000 from where the code is being generated so it would fail.
Therefore, whenever I get new firmware I have to write it at 0x08100000. For more reference go through this article:
STM32H5_USB_DFU_Dual_Bank_demo/STM32H5 USB DFU Dual Bank.pdf at main · stm32-hotspot/STM32H5_USB_DFU_Dual_Bank_demo