Skip to main content
Anand Ram
Associate III
Mar 25, 2021 7:17 AM UTC
Solved

after using flash functions for flash write code is jumping into hardfault handler

my code is jumping into hardfault handler 0693W000008xrWeQAI.pngduring/after flash write procedure.some problem with mutex or task handling,

can somebody explains how to hold the thread until the flash write is complete.

note: flash write functions are called inside the "below normal " priority thread.

This topic has been closed for replies.
Anand Ram
Anand RamBest answer
Associate III
Apr 19, 2021 1:21 PM UTC

hi, i have fixed this issue,

there is problem in flashing of 96 K in 5 millisecond task, and other tasks are halt and ended with trap.

I have implemented a semaphore concept to flash block by block and the task un-interruption is solved.

5 replies

Javier1
Principal
Mar 25, 2021 7:52 AM UTC

can we see your "flash function" ?

Are you erasing flash pages before writting them?

Also, there is a lock unlock flash logic you should pay attention to.

Maybe this helps

flashaddr=0x8015000	
uint32_t *p0=&mydata;
	for (uint32_t i = 0; i < (sizeof(mydata)/4); ++i) {
		HAL_FLASH_Unlock();
		HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, (flashaddr), (uint32_t)*(p0+i));
		CLEAR_BIT (FLASH->CR, (FLASH_CR_PG));
		HAL_FLASH_Lock();
		flashaddr+=4;
	}

hit me up in https://www.linkedin.com/in/javiermuñoz/
Anand Ram
Anand RamAuthor
Associate III
Mar 25, 2021 8:27 AM UTC

_disable_irq();

 do{

  sl_ret = BPC_FLASH_Block_Erase_l(FLASH_BANK_SECTOR_6, FLASH_BANK_2, ERASE_SECTOR_PARAM);

 }while(sl_ret!=B_TRUE);

 osDelay(2000);

 BPC_FLASH_FlashWrite_l(&infoBlock1,pccom_adr_flash, (U_INT8 *)pccom_adr_ram, laenge_long);

 __enable_irq();

but i guess , since i copy 96 kb of data from RAM to flash during write leads to thread lock and then causes systick exception with hardfault handler

Javier1
Principal
Mar 25, 2021 9:27 AM UTC

i dont have experience about your specific setup but isnt disable_irq() dissabling your RTOS scheduler?

and maybe breaking something else?

hit me up in https://www.linkedin.com/in/javiermuñoz/
Anand Ram
Anand RamAuthorBest answer
Associate III
Apr 19, 2021 1:21 PM UTC

hi, i have fixed this issue,

there is problem in flashing of 96 K in 5 millisecond task, and other tasks are halt and ended with trap.

I have implemented a semaphore concept to flash block by block and the task un-interruption is solved.