cancel
Showing results for 
Search instead for 
Did you mean: 

I am using Nucleo-32 with STM32F042K6 and trying to use flash (32KB, 1K pages). I can erase, read right each page starting at page 18 (18,432) up through page 31 (31,744), except page 21 (21,504). Page 21 hard faults on erase.

RGord.2
Associate II

-Using the HAL in STM32 Cube IDE.

-I can examine the FLASH pointer in the hard fault ISR and the registers appear to be just like when accessing any other page.

-I am unlocking the Flash and the option bytes.

-I have not modified the option bytes.

-It does not matter how many pages I have erased before, whether it is 5 or none, page 21 hard faults.

Thank You

5 REPLIES 5
Uwe Bonnes
Principal II

Supply voltage too low? Flash already weared out by too many erase cycle? Did you perhaps use that page as EEPROM substitute for some time? Brokken part, do more chips behave that way?

What does STLink Utility (or it's cuboid counterpart) say, can they erase/program this sector?

Option bytes are set how?

JW

RGord.2
Associate II

Thanks for responding. To answer both sets of questions:

  • Supply voltage too low: Not likely, several boards behave the exact same way. Here is a summary of known hard faults. All other cases result in success.
    • HAL_FLASHEx_Erase (Non-Interrupt), Timer2 interrupt enabled, erasing sector 21 hard faults.
    • HAL_FLASHEx_Erase (Non-Interrupt), Timer2 interrupt disabled, erasing sector 30 hard faults.
    • HAL_FLASHEx_Erase_IT (Interrupt), Timer2 interrupt disabled or disabled, erasing sector 17 hard faults.
  • Worn-out flash: Chips are very new and behavior identical across several items.
  • Never used as EEPROM
  • Multiple chips behave same way.
  • Using STM32 Cube programmer works just fine. We can erase the entire 32KB, erase page by page, program page by page. Everything works fine.

I am attaching some screenshots of the FLASH registers and the CPU register immediately before and after a sample hard fault.

Flash registers just before hard fault.

0693W000008GMsTQAW.png 

CPU registers just before hard fault.

0693W000008GMsiQAG.png 

FLASH registers just after hard fault.

0693W000008GMssQAG.png 

CPU registers just after hard fault.

0693W000008GMsxQAG.png 

Any help will be greatly appreciated. Thank you.

RGord.2
Associate II

I apologize. My images show FLASH->AR as 0x4400, which is the offset into flash, not the page address. I just re-ran with FLASH->AR as 0x08004400 and got the same hard fault. There is no change before the fault except for FLASH->AR. After the hardfault, the FLASH registers are the same (except AR), but the processor registers are different. Here they are. I apologize for the confusion.

0693W000008GMwaQAG.png

RGord.2
Associate II

Here are the clocks.

0693W000008GMwzQAG.png