2024-12-09 11:59 AM
After testing trying to write a byte to Flash I seemed to have bricked board. I thought board just went out, so I bought another one, programmed it and now that board is broken too. I commented code out, tried 3rd board and it works fine.
Here is the code I tried
uint32_t Flash_Address = 0x80FFF00;
HAL_FLASH_Unlock();
FLASH_Erase_Sector(11, FLASH_VOLTAGE_RANGE_2); // Use appropriate sector number and voltage range
HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE, Flash_Address, 0xAA);
HAL_FLASH_Lock();
The error I get now is:
Target not halted after reset. Force halt
Failed to halt target
Target not halted
Error in initializing ST-LINK device.
Reason: Target not halted.
Error in final launch sequence:
Failed to execute MI command:
target remote localhost:61234
Error message from debugger back end:
localhost:61234: Connection timed out.
Failed to execute MI command:
target remote localhost:61234
Error message from debugger back end:
localhost:61234: Connection timed out.
localhost:61234: Connection timed out.
I tried using STLINK utility to erase. but they won't connect!
Did I use wrong voltage (FLASH_VOLTAGE_RANGE_2)? Not sure if the boards are truly damaged?
Solved! Go to Solution.
2024-12-09 03:54 PM
You're not using a part with 24 sectors
The F746 has 8, describing 1MB
The F767 (24), and F722 (8 for 512KB) might have different array sizes.
As I recollect there are some F4 devices with 2MB, two banks of 1MB in a 16KB*4,64KB*1,128KB*7 pattern
2024-12-09 12:49 PM - edited 2024-12-09 12:52 PM
That doesn't make a lot of sense. Was there code in that location, or within 128KB? (0x080E0000)
It shouldn't brick the board.
Use STM32 Cube Programmer, or ST-LINK Utilities, try Connect Under Reset, try finding BOOT0 pin/pad and pulling to VDD (HIGH) and connecting that way. When connected, Mass Erase
BOOT0 to 3V3, short pads for R42
2024-12-09 01:29 PM
I was able to recover boards. Unplug USB, Jumper R42, which is BOOT0 pull up to VCC. Connect USB, Use st-link to erase. Unplug USB and remove jumper. Now you can program as normal.
2024-12-09 01:47 PM
Yes, that is what I did.
And I wrote to an address to section 7 address 0x0807FF00 without issue.
Here is the issue with writing sector 11: There are only 8 sectors defined in stm32f746xx.h
/******************************************************************************/
/* */
/* FLASH */
/* */
/******************************************************************************/
/*
* @brief FLASH Total Sectors Number
*/
#define FLASH_SECTOR_TOTAL 8
So how do you access other sectors 9-11?
2024-12-09 01:57 PM
You're probably thinking of the STM32F4, which had a different mix of different sized sectors.
"On STM32F756xx and STM32F74xx devices, a main memory block divided into 4
sectors of 32 Kbytes, 1 sector of 128 Kbytes and 3 sectors of 256 Kbytes"
Other options on banked devices would be side-to-side (double wide flash lines), or end-to-end
2024-12-09 03:28 PM
Am I supposed to change FLASH_SECTOR_TOTAL to 24?
in stm32f7xx_hal_flash.h
/******************************************************************************/
/* */
/* FLASH */
/* */
/******************************************************************************/
/*
* @brief FLASH Total Sectors Number
*/
#define FLASH_SECTOR_TOTAL 8
in stm32f7xx_hal_flash_ex.h
#if (FLASH_SECTOR_TOTAL == 8)
#define IS_FLASH_SECTOR(SECTOR) (((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\
((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\
((SECTOR) == FLASH_SECTOR_4) || ((SECTOR) == FLASH_SECTOR_5) ||\
((SECTOR) == FLASH_SECTOR_6) || ((SECTOR) == FLASH_SECTOR_7))
#define IS_OB_WRP_SECTOR(SECTOR) ((((SECTOR) & 0xFF00FFFFU) == 0x00000000U) && ((SECTOR) != 0x00000000U))
#endif /* FLASH_SECTOR_TOTAL == 8 */
#if (FLASH_SECTOR_TOTAL == 24)
#define IS_FLASH_SECTOR(SECTOR) (((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\
((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\
((SECTOR) == FLASH_SECTOR_4) || ((SECTOR) == FLASH_SECTOR_5) ||\
((SECTOR) == FLASH_SECTOR_6) || ((SECTOR) == FLASH_SECTOR_7) ||\
((SECTOR) == FLASH_SECTOR_8) || ((SECTOR) == FLASH_SECTOR_9) ||\
((SECTOR) == FLASH_SECTOR_10) || ((SECTOR) == FLASH_SECTOR_11) ||\
((SECTOR) == FLASH_SECTOR_12) || ((SECTOR) == FLASH_SECTOR_13) ||\
((SECTOR) == FLASH_SECTOR_14) || ((SECTOR) == FLASH_SECTOR_15) ||\
((SECTOR) == FLASH_SECTOR_16) || ((SECTOR) == FLASH_SECTOR_17) ||\
((SECTOR) == FLASH_SECTOR_18) || ((SECTOR) == FLASH_SECTOR_19) ||\
((SECTOR) == FLASH_SECTOR_20) || ((SECTOR) == FLASH_SECTOR_21) ||\
((SECTOR) == FLASH_SECTOR_22) || ((SECTOR) == FLASH_SECTOR_23))
2024-12-09 03:54 PM
You're not using a part with 24 sectors
The F746 has 8, describing 1MB
The F767 (24), and F722 (8 for 512KB) might have different array sizes.
As I recollect there are some F4 devices with 2MB, two banks of 1MB in a 16KB*4,64KB*1,128KB*7 pattern