cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to flash new firmware on STM32L031C6

javqui
Associate II

I have been flashing ST with the Flash Loader Demo utility successfully for long time, directly to my PCB design. BOOT0 pin is high, everything around the STM32 is quite (no activity on peripherals connected). Reset properly connected to a Resistor with a small Cap.

I try with a second PCB board and got the same issue.

Googled the issue, read the Q&A, Try the CubeProgrammer, try the FlashLoader demo and try bootloader commands using a serial terminal. All tests with some interaction but unable to flash a new firmware.

Flash Loader demo: It connects, shows "Target is readable. Please click Next to proceed. "remove protection" button is disabled. Next screen No target list, PID 0x45 (correct) BID: NA and version 3.1. Can't do anything more here. Flash Loader is not useful anymore after this point.

Manual bootloader codes: Sent the 0x7F and received the ACK, Sent the 0x00 0xFF, received the proper answer (1F 79 0B 31 00 01 02 11 21 31 44 63 73 82 92 79) , Just in case sent the readout unprotect command 0x92 0x6D, received correctly the 79 79. So it looks ok.

STM32CubeProgrammer: after click the button Coonect, looks like is connected, but the top bar red label shows "Not connected" here is the Verbose level 2 detail:

13:21:07:470 : Serial Port COM25 is successfully opened.
13:21:07:472 : Port configuration: parity = even, baudrate = 115200, data-bit = 8,                     stop-bit = 1.0, flow-control = off
13:21:07:473 : No Init bits value is : 0 
13:21:07:473 : Sending init command: 
13:21:07:473 : byte 0x7F sent successfully to target
13:21:07:487 : Wait ends after 1 loop, dataready = 1, delay = 16
13:21:07:487 : Received response from target: 0x79
13:21:07:500 : Activating device: OK
13:21:07:500 : Sending GetID command and its XOR:
13:21:07:500 : byte 0x02 sent successfully to target
13:21:07:501 : byte 0xFD sent successfully to target
13:21:07:508 : Wait ends after 1 loop, dataready = 1, delay = 6
13:21:07:508 : Received response from target: 0x79
13:21:07:508 : Received response from target: 0x01042579
13:21:07:508 : Chip ID: 0x425 
13:21:07:508 : Sending Get command and its XOR:
13:21:07:509 : byte 0x00 sent successfully to target
13:21:07:517 : byte 0xFF sent successfully to target
13:21:07:533 : Wait ends after 1 loop, dataready = 1, delay = 15
13:21:07:533 : Received response from target: 0x79
13:21:07:533 : Received response from target: 0x0b
13:21:07:534 : size of bytes in the response: 11
13:21:07:534 : Received response from target: 0x31000102112131446373829279
13:21:07:534 : Full received response: 0b31000102112131446373829279
13:21:07:534 : BootLoader protocol version: 3.1
13:21:07:536 : byte 0x11 sent successfully to target
13:21:07:536 : byte 0xEE sent successfully to target
13:21:07:556 : data sent successfully to target: 0x0800000008
13:21:07:564 : byte 0x00 sent successfully to target
13:21:07:564 : byte 0xFF sent successfully to target
13:21:07:575 : Sending GetID command and its XOR:
13:21:07:577 : byte 0x02 sent successfully to target
13:21:07:577 : byte 0xFD sent successfully to target
13:21:07:589 : Wait ends after 1 loop, dataready = 1, delay = 15
13:21:07:590 : Received response from target: 0x79
13:21:07:590 : Received response from target: 0x01042579
13:21:07:726 : byte 0x11 sent successfully to target
13:21:07:730 : byte 0xEE sent successfully to target
13:21:07:730 : data sent successfully to target: 0x0800000008
13:21:07:743 : byte 0x00 sent successfully to target
13:21:07:754 : byte 0xFF sent successfully to target
13:21:07:759 : Sending Read command and its XOR:
13:21:07:766 : byte 0x11 sent successfully to target
13:21:07:767 : byte 0xEE sent successfully to target
13:21:07:780 : Wait ends after 1 loop, dataready = 1, delay = 15
13:21:07:783 : Received response from target: 0x79
13:21:07:783 : Sending Read address and its checksum:
13:21:07:784 : data sent successfully to target: 0x1ff80000e7
13:21:07:804 : Wait ends after 1 loop, dataready = 1, delay = 15
13:21:07:804 : Received response from target: 0x79
13:21:07:806 : Sending number of bytes to be read - 1 and its checksum:
13:21:07:806 : data sent successfully to target: 0x03fc
13:21:07:826 : Wait ends after 1 loop, dataready = 1, delay = 15
13:21:07:826 : Received response from target: 0x79
13:21:07:827 : Received response from target: 0xaa0055ff
13:21:07:829 : Database: Config 0 is active.
13:21:07:829 : byte 0x11 sent successfully to target
13:21:07:829 : byte 0xEE sent successfully to target
13:21:07:829 : data sent successfully to target: 0x0800000008
13:21:07:868 : byte 0x00 sent successfully to target
13:21:07:869 : byte 0xFF sent successfully to target
13:21:09:253 : byte 0x11 sent successfully to target
13:21:09:253 : bytesToWrite before send = 1 
13:21:09:253 : bFlushRet = 1, bytesToWrite after flush() = 1 
13:21:09:253 : waitForBytesWritten Error : The wait operation timed out.
13:21:09:253 : byte 0xEE sent successfully to target
13:21:09:254 : data sent successfully to target: 0x0800000008
13:21:09:254 : byte 0x00 sent successfully to target
13:21:09:254 : byte 0xFF sent successfully to target
13:21:09:255 : UPLOADING OPTION BYTES DATA ...
13:21:09:255 :   Bank          : 0x00
13:21:09:255 :   Address       : 0x1ff80000
13:21:09:255 :   Size          : 20 Bytes
13:21:09:256 : Sending Read command and its XOR:
13:21:09:257 : byte 0x11 sent successfully to target
13:21:09:257 : byte 0xEE sent successfully to target
13:21:09:257 : Wait ends after 1 loop, dataready = 1, delay = 13
13:21:09:257 : Received response from target: 0x79
13:21:09:258 : Sending Read address and its checksum:
13:21:09:258 : data sent successfully to target: 0x1ff80000e7
13:21:09:258 : Wait ends after 1 loop, dataready = 1, delay = 15
13:21:09:259 : Received response from target: 0x79
13:21:09:259 : Sending number of bytes to be read - 1 and its checksum:
13:21:09:259 : data sent successfully to target: 0x13ec
13:21:09:259 : Wait ends after 1 loop, dataready = 1, delay = 15
13:21:09:259 : Received response from target: 0x79
13:21:09:260 : Received response from target: 0xaa0055ff70808f7f0000ffff0000ffff00000000
13:21:09:260 : UPLOADING OPTION BYTES DATA ...
13:21:09:261 :   Bank          : 0x00
13:21:09:261 :   Address       : 0x1ff80000
13:21:09:261 :   Size          : 20 Bytes
13:21:09:261 : Sending Read command and its XOR:
13:21:09:262 : byte 0x11 sent successfully to target
13:21:09:262 : byte 0xEE sent successfully to target
13:21:09:262 : Wait ends after 1 loop, dataready = 1, delay = 12
13:21:09:262 : Received response from target: 0x79
13:21:09:263 : Sending Read address and its checksum:
13:21:09:263 : data sent successfully to target: 0x1ff80000e7
13:21:09:263 : Wait ends after 1 loop, dataready = 1, delay = 15
13:21:09:263 : Received response from target: 0x79
13:21:09:264 : Sending number of bytes to be read - 1 and its checksum:
13:21:09:264 : data sent successfully to target: 0x13ec
13:21:09:264 : Wait ends after 1 loop, dataready = 1, delay = 16
13:21:09:264 : Received response from target: 0x79
13:21:09:264 : Received response from target: 0xaa0055ff70808f7f0000ffff0000ffff00000000

I can not erase the flash or flash a new firmware, or check the option bytes. (no activity, no messages)

CubeProgrammer didn't show the Flash size, and never show "connected".

I'm empty of options now, any help will be really appreciated.

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Alex R
Senior

Do you have access to the JTAG programming pins on your PCB?

Have you tried with SMT32 ST-Link Utility?

View solution in original post

4 REPLIES 4
Alex R
Senior

Do you have access to the JTAG programming pins on your PCB?

Have you tried with SMT32 ST-Link Utility?

javqui
Associate II

I jump directly to a test for production PCB, it means, I usually don't consider debug or ST-link pins on a test before production board. So the answer is I don't have access to debug / st-link pins, Didn't check in detail, but probably will need to remove some components to have access to this pins to connect an ST-link interface.

javqui
Associate II

Curious notes and observations;

  • If I send the bootloader commands manually, I need to introduce a short pause between bytes, otherwise, the bootloader didn't recognize the individual bytes ( 0x00 pause 0xFF .... )
  • I'm curious why the bootloader works (response to basic commands and report itself with the right ID) but neither ST utilities are able to do something more with the STM32L03.
  • According with AN3155 Application note (Usart protocol used in the STM32 bootloader), for 3.1 version (pag 35):

"When a Read Memory command or Write Memory command is

issued with an unsupported memory address and a correct

address checksum (ie. address 0x6000 0000), the command is

aborted by the bootloader device, but the NACK (0x1F) is not

sent to the host. As a result, the next 2 bytes (which are the

number of bytes to be read/written and its checksum) are

considered as a new command and its checksum.�?

Please check the log attached:

after send 0x11 0xEE , the cubeProgrammer didn't wait for the ACK and send the address

13:21:07:536 : byte 0x11 sent successfully to target

13:21:07:536 : byte 0xEE sent successfully to target

13:21:07:556 : data sent successfully to target: 0x0800000008

it repeats again on

13:21:07:726 : byte 0x11 sent successfully to target

13:21:07:730 : byte 0xEE sent successfully to target

13:21:07:730 : data sent successfully to target: 0x0800000008

but not when ask to system memory address

13:21:07:766 : byte 0x11 sent successfully to target

13:21:07:767 : byte 0xEE sent successfully to target

13:21:07:780 : Wait ends after 1 loop, dataready = 1, delay = 15

13:21:07:783 : Received response from target: 0x79

13:21:07:783 : Sending Read address and its checksum:

13:21:07:784 : data sent successfully to target: 0x1ff80000e7

13:21:07:804 : Wait ends after 1 loop, dataready = 1, delay = 15

13:21:07:804 : Received response from target: 0x79

13:21:07:806 : Sending number of bytes to be read - 1 and its checksum:

13:21:07:806 : data sent successfully to target: 0x03fc

13:21:07:826 : Wait ends after 1 loop, dataready = 1, delay = 15

13:21:07:826 : Received response from target: 0x79

13:21:07:827 : Received response from target: 0xaa0055ff

13:21:07:829 : Database: Config 0 is active.

Sometimes a fresh mind could help more than anything.

I was focus on why the UART bootloader doesn't work properly, open a support ticket, guys at support without a single clue about the log. (the formal support could take weeks)

Your alternative started ding in my head, and today afternoon I decide to Just modify a little the PCB manually to switch to the SWD / STlink, the result: SUCESS !!

It means that the PCB is ok, the chip is ok (I was considering issues with temp at the reflow because the high temp with a new no lead profile, and so many crazy things.)

The uart bootloader have issues (at least the tools are not able to flash the STM32L0 properly using the official tools)

Thanks @Alex R​  for the fresh air (idea suggestion) !!