2024-09-03 06:19 AM - edited 2024-09-03 06:22 AM
Hi,
I'm using a STM32L452 and launching the bootloader in System Memory by setting the Boot0 pin to high and resetting. This launches the bootloader successfully.
I'm using UART1 on PA9 and PA10.
However, when trying to write the flash using the STM32_Programmer_CLI.exe it shows a NACK and the program exits. Here's the command I'm using, see log attached:
"C:\ProgramFiles\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin\STM32_Programmer_CLI.exe" -c port=COM11 -w="C:\FW.hex"
Command line output is as follows:
-------------------------------------------------------------------
STM32CubeProgrammer v2.15.0
-------------------------------------------------------------------
Warning: Wrong connect parameter: -w=C:\FW.hex
Serial Port COM11 is successfully opened.
Port configuration: parity = even, baudrate = 115200, data-bit = 8,
stop-bit = 1.0, flow-control = off
Activating device: OK
Board : --
Chip ID: 0x462
BootLoader protocol version: 3.1
Response received from device: NACK
Device name : STM32L45x/L46x
Flash size : 512 KBytes (default)
Device type : MCU
Revision ID : --
Device CPU : Cortex-M4
However, when using STM32CubeProgrammer and selecting UART and the correct COM port, the hex file is successfully written to flash. Here's the verbose 1 output when using STM32CubeProgrammer (full log verbose 3 attached when flashing the MCU as log2.log):
13:56:18 : Serial Port COM11 is successfully opened.
13:56:18 : Port configuration: parity = even, baudrate = 115200, data-bit = 8, stop-bit = 1.0, flow-control = off
13:56:20 : Activating device: OK
13:56:20 : Board : --
13:56:20 : Chip ID: 0x462
13:56:20 : BootLoader protocol version: 3.1
13:56:20 : Response received from device: NACK
13:56:23 : UPLOADING OPTION BYTES DATA ...
13:56:23 : Bank : 0x00
13:56:23 : Address : 0x1fff7800
13:56:23 : Size : 36 Bytes
13:56:23 : UPLOADING ...
13:56:23 : Size : 1024 Bytes
13:56:23 : Address : 0x8000000
13:56:23 : Read progress:
13:56:25 : Data read successfully
13:56:25 : Time elapsed during the read operation is: 00:00:01.428
However, when using STM32CubeProgrammer and selecting UART and the correct COM port, the hex file is successfully written to flash. Here's the verbose 1 output when using STM32CubeProgrammer (full log verbose 3 attached when flashing the MCU as log2.log):
14:21:51 : Disconnected from device.
14:21:52 : UR connection mode is defined with the HWrst reset mode
14:21:52 : RTS low
14:21:52 : DTR low
14:21:52 : Serial Port COM11 is successfully opened.
14:21:52 : Port configuration: parity = even, baudrate = 115200, data-bit = 8, stop-bit = 1.0, flow-control = off
14:21:54 : Activating device: OK
14:21:54 : Board : --
14:21:54 : Chip ID: 0x462
14:21:54 : BootLoader protocol version: 3.1
14:21:54 : Response received from device: NACK
14:21:57 : UPLOADING OPTION BYTES DATA ...
14:21:57 : Bank : 0x00
14:21:57 : Address : 0x1fff7800
14:21:57 : Size : 36 Bytes
14:21:57 : UPLOADING ...
14:21:57 : Size : 1024 Bytes
14:21:57 : Address : 0x8000000
14:21:57 : Read progress:
14:21:58 : Data read successfully
14:21:58 : Time elapsed during the read operation is: 00:00:01.426
It seems that the option bytes are written and this might be what's missing. Looking at application note AN2606 I didn't find anything relevant.
There's also a somehow similar case in the forum but the solution is not applicable: https://community.st.com/t5/stm32-mcus-embedded-software/stm32-programmer-cli-bootloader-procedure/td-p/182037
Reading the option bytes via CLI (using option "-ob displ"), this is what I get:
-------------------------------------------------------------------
STM32CubeProgrammer v2.15.0
-------------------------------------------------------------------
Serial Port COM11 is successfully opened.
Port configuration: parity = even, baudrate = 115200, data-bit = 8,
stop-bit = 1.0, flow-control = off
Activating device: OK
Board : --
Chip ID: 0x462
BootLoader protocol version: 3.1
Response received from device: NACK
Device name : STM32L45x/L46x
Flash size : 512 KBytes (default)
Device type : MCU
Revision ID : --
Device CPU : Cortex-M4
UPLOADING OPTION BYTES DATA ...
Bank : 0x00
Address : 0x1fff7800
Size : 36 Bytes
██████████████████████████████████████████████████ 100%
OPTION BYTES BANK: 0
Read Out Protection:
RDP : 0xAA (Level 0, no protection)
BOR Level:
BOR_LEV : 0x0 (BOR Level 0, reset level threshold is around 1.7 V)
User Configuration:
IWDG_STOP : 0x1 (IWDG counter active in stop mode)
IWDG_STDBY : 0x1 (IWDG counter active in standby mode)
WWDG_SW : 0x1 (Software window watchdog)
IWDG_SW : 0x1 (Software independent watchdog)
nRST_STOP : 0x1 (No reset generated)
nRST_STDBY : 0x1 (No reset generated)
nRST_SHDW : 0x1 (No reset generated when entering the Shutdown mode)
nBOOT1 : 0x1 (Boot from system memory when BOOT0=1)
SRAM2_PE : 0x1 (SRAM2 parity check disable)
SRAM2_RST : 0x1 (SRAM2 is not erased when a system reset occurs)
nSWBOOT0 : 0x1 (BOOT0 taken from PH3/BOOT0 pin)
nBOOT0 : 0x1 (BOOT0 = 0, boot from system memory when nSWBOOT0=1 and main flash is empty,otherwise, boot from main flash memory)
PCROP Protection:
PCROP1_STRT : 0xFFFF (0x807FFF8)
PCROP1_END : 0x0 (0x8000000)
PCROP_RDP : 0x1 (PCROP zone is erased when RDP is decreased)
Write Protection:
WRP1A_STRT : 0xFF (0x807F800)
WRP1A_END : 0x0 (0x8000000)
WRP1B_STRT : 0xFF (0x807F800)
WRP1B_END : 0x0 (0x8000000)
The option bytes seem to be as expected.
Am I missing something or does anyone know what's happening?
Regards,
Joao