Skip to main content
Dick Lin
Senior
Jun 20, 2018 10:57 PM UTC
Question

STM32L496ZG flash program issue

Posted on June 21, 2018 at 00:57

Hi,

I am working on STM32 flash program using a sample program from V1.11. The program is pretty straight forward. Erase ADDR_FLASH_PAGE_16 to ADDR_FLASH_PAGE_255 then program.

The program stuck in HardFault_Handler doing HAL_FLASHEx_Erase in the first page erase FLASH_PageErase(page_index, pEraseInit->Banks);

HAL_FLASH_Program()

 also failed on FLASH_Program_DoubleWord().

Anyone experienced same issue? Doesn't this supposed to be working without any changes? 

Thx

STM32Cube_FW_L4_V1.11.0\Projects\NUCLEO-L496ZG\Examples\FLASH\FLASH_EraseProgram

if (HAL_FLASHEx_Erase(&EraseInitStruct, &PAGEError) != HAL_OK)

{

while (1)

{

BSP_LED_On(LED3);

}

}

Address = FLASH_USER_START_ADDR;

while (Address < FLASH_USER_END_ADDR)

{

if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, Address, DATA_64) == HAL_OK)

{

Address = Address + 8;

}

else

{

/* Error occurred while writing data in Flash memory.

User can add here some code to deal with this error */

while (1)

{

BSP_LED_On(LED3);

}

}

}

HAL_FLASH_Lock();

Address = FLASH_USER_START_ADDR;

MemoryProgramStatus = 0x0;

while (Address < FLASH_USER_END_ADDR)

{

data32 = *(__IO uint32_t *)Address;

if (data32 != DATA_32)

{

MemoryProgramStatus++;

}

Address = Address + 4;

}

/*Check if there is an issue to program data*/

if (MemoryProgramStatus == 0)

{

/* No error detected. Switch on LED1*/

BSP_LED_On(LED1);

}

else

{

/* Error detected. Switch on LED2*/

BSP_LED_On(LED2);

}
    This topic has been closed for replies.

    10 replies

    Tesla DeLorean
    Guru
    Jun 20, 2018 11:11 PM UTC
    Posted on June 21, 2018 at 01:11

    >>Doesn't this supposed to be working without any changes? 

    How large is the executable image your tool chain is generating? More than 16KB perhaps?

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Dick Lin
    Dick LinAuthor
    Senior
    Jun 21, 2018 1:20 AM UTC
    Posted on June 21, 2018 at 01:20

    The .elf file is pretty big - 1883 KB. What's the limit of the board?

    Dick Lin
    Dick LinAuthor
    Senior
    Jun 21, 2018 1:44 AM UTC
    Posted on June 21, 2018 at 01:44

    Why the flash HAL function failure has anything to do with code size?