2021-11-23 12:59 AM
Hi Team,
We are building a Braille Display for the Blind people, for the device, we are trying to give IAP through SD card on our board.
My problem is whenever we try to erase or program the STM32H753 chip, the program comes out of Debugger at the first occurance of FLASH_WaitForLastOperation in the HAL_FLASHEx_Erasefunction. Keil gives " cannot access target. Shutting down Debug session" error.
I have tried commenting the Erase function and then running the code. but then it gives same error in the programming function.
Instead of using my code, I have also tried the code that comes with your eval board (STM32Cube_FW_H7_V1.5.0) but same thing happens.
I have changed the chip twice but invein.
Please suggest the remedy for this ASAP, as we are running out of time.
2021-11-23 05:28 AM
Are you erasing flash still in use by the program?
If you run the program without a debugger, does it work? If not, where in the process does it fail?
2021-11-23 06:28 AM
Hi,
My bootloader program is at 0x8000000. And I am erasing the memory from 0x8020000.
The program does not work even without the debugger. It stucks at the same point, this I can assume because I have toggled the LED before and after the erase function. And the LED does not turn off.
2021-11-23 08:04 AM
With the following lines it works fine for erase one entire sector with same MCU family:
FLASH_Erase_Sector(FLASH_SECTOR_0, FLASH_BANK_1, FLASH_VOLTAGE_RANGE_3);
FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE, FLASH_BANK_1); /* Wait for last operation to be completed */
works with any FLASH_SECTOR_n
2021-11-23 08:44 PM
Hi Simosilva,
The erase function worked fine. Do we have a similar function for programming also? Because it gives the same error (flash_waitforlastoperation) for HAL_FLASH_Program(Flash_TYPEPROGRAM_FLASHWORD, address, 32 bit data);
2021-11-24 12:50 AM
Sure.
for (i = 0; (i < BufLen) && (*FlashAddress <= (USER_FLASH_END_ADDRESS-4)); i++)
{
HAL_FLASH_Program(FLASH_TYPEPROGRAM_FLASHWORD, *FlashAddress, (uint32_t)(pBuf+i));
{
/* Check the written value */
if (*(uint32_t*)*FlashAddress != *(uint32_t*)(pBuf+i))
{
/* Flash content doesn't match SRAM content */
return(2);
}
/* Increment FLASH address */
*FlashAddress += 4;
}
}
Every write must be 32 bit alligned, the pBuf point to a uint32_t array containing the buffer to be written.
Programming without the FLASH_WaitForLastOperation works fine.
Try it and let me know
2021-11-24 01:40 AM
FLASH_WaitForLastOperation is executed directly into HAL_FLASH_Program
2021-11-24 10:40 PM
Hi Simosilva,
Programming worked fine. Thanks for the help.
Now my next code is
jumpadd = *(__IO uint 32_t*) (FLASH_USER_START_ADDRESS+4);
Jump = (pFunction) jumped;
__set_MSP(*(__IO uint32_t*) FLASH_USER_START_ADDRESS);
Jump();
Right?
The binary file is having VECT_TAB_OFFSET 0x00020000UL
And
SCB->VTOR = FLASH_BANK1_BASE| | VECT_TAB_OFFSET;
Do we need to define anything else?
Because on Jump(); my code gives hardfault and enters in HardFault_Handler.
2021-11-25 12:32 AM
first check stm community on Jump topic:
https://community.st.com/s/question/0D53W00001ANUB0SAP/jump-issue-with-custom-bootloader-stm32h7
:eyes:
2021-11-28 08:31 PM
No luck... The program still enters in hard fault handler at jump....