I tried recently to develop custom app flasher (based on stm32loader python module) for STM32L073xx microcontrollers but I stuck at one point.
This lib tries to obtain flash size from micro because for the same chip UID (0x447 - STM32L07x/L08x/L010) we can have different flash size. Lib sends command to read memory (cmd 0x11 0xEE) and now starts my problem:
- flash size is stored at address 0x1FF8007C (RM0367, section 34.1.1)
- internal bootloader allows to read memory in range of system memory: 0x1FF00000 - 0x1FF01FFF (AN2606 Rev35, ch.56 "Device-dependent bootloader parameters", STM32 series L0, PID 0x447)
It causes that when I try to read flash size from this address, I receive response 0x1F (NACK) and i cannot continue process.
Of course I could copy flash size byte somewhere in RAM before jumping to system bootloader or assume some flash size but then pc application won't be robust for all chips.
How it should be handled in proper way? Is there another address where flash size is stored?
Now I'm able now to read whole flash content, but there is new challenge. I've tried to perform mass erase to prepare flash for writing new content and surprise surprise...bootloader returns NACK for any type of mass erase!
My communication looks like that:
- enter bootloader
- send 0x7F, get 0x79 (ACK)
- send 0x44 0xBB, get 0x79 (ACK) - Extended Erase Memory command
now i tried following:
- send 0xFF 0xFF 0x00, get 0x1F (NACK) - Mass Erase
- send 0xFF 0xFE 0x01, get 0x1F (NACK) - Bank 1 Erase
- send 0xFF 0xFD 0x02, get 0x1F (NACK) - Bank 2 Erase
None of them work...any suggestions?