cancel
Showing results for 
Search instead for 
Did you mean: 

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

Anand Ram
Associate III

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Anand Ram
Associate III

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.

View solution in original post

5 REPLIES 5
Javier1
Principal

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;
	}

we dont need to firmware by ourselves, lets talk
Anand Ram
Associate III

_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

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

and maybe breaking something else?

we dont need to firmware by ourselves, lets talk

To add to what Javier already said... Why are you disabling interrupts at all? Why is there a delay function? Have you read the FLASH section in the reference manual and understand how it works?

Anand Ram
Associate III

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.