cancel
Showing results for 
Search instead for 
Did you mean: 

Flash with bootloader uart issue stm32f405

SBaro.11
Associate III

Hi,

I'm trying to flash overt build in uart bootlader stm32 slave device. Here is my setup :
Master STM32F4 with tinyUSB

Slave STM32WLE5 device

 

Master and slave are connected together over uart. Master has control of boot0 and reset ligne of slave device.

Master UART2 PD5/PD6

Slave UART2 PA2/PA3

 

I'm able to put slave device into bootloader mode, but when I'm trying to connect with stm32cubeprogrammer over my usb I got NACK command from getId command

 

Here is the output of verbose mode cube programmer:

12:43:06:195 : UR connection mode is defined with the HWrst reset mode 12:43:06:257 : RTS low 12:43:06:257 : DTR low 12:43:06:277 : Serial Port cu.usbmodem123 is successfully opened. 12:43:06:277 : Port configuration: parity = even, baudrate = 115200, data-bit = 8, stop-bit = 1.0, flow-control = off 12:43:06:277 : No Init bits value is : 0 12:43:06:277 : Sending init command: 12:43:06:277 : byte 0x7F sent successfully to target 12:43:06:277 : Wait ends after 1 loop, dataready = 1, delay = 5 12:43:06:277 : Received response from target: 0x79 12:43:06:277 : Activating device: OK 12:43:06:277 : Board : -- 12:43:06:277 : Sending GetID command and its XOR: 12:43:06:278 : byte 0x02 sent successfully to target 12:43:06:278 : byte 0xFD sent successfully to target 12:43:06:278 : Wait ends after 1 loop, dataready = 1, delay = 6 12:43:06:278 : Received response from target: 0x1f 12:43:06:278 : Response received from device: NACK 12:43:06:278 : Error: GETID command not acknowledged! 12:43:06:278 : Reemission of GetID command 12:43:06:278 : Sending GetID command and its XOR: 12:43:06:278 : byte 0x02 sent successfully to target 12:43:06:278 : byte 0xFD sent successfully to target 12:43:06:278 : Wait ends after 1 loop, dataready = 1, delay = 7 12:43:06:278 : Received response from target: 0x1f 12:43:06:278 : Response received from device: NACK 12:43:06:278 : Error: GETID command not acknowledged! 12:43:06:278 : Reemission of GetID command 12:43:06:278 : Sending GetID command and its XOR: 12:43:06:278 : byte 0x02 sent successfully to target 12:43:06:278 : byte 0xFD sent successfully to target 12:43:06:278 : Wait ends after 1 loop, dataready = 1, delay = 6 12:43:06:278 : Received response from target: 0x1f 12:43:06:278 : Response received from device: NACK 12:43:06:278 : Error: GETID command not acknowledged! 12:43:06:278 : Chip ID: 0x0 12:43:06:278 : UART PORT CLOSE
View more

 

Sometimes I'm able to get bootloader version and chip id and sometime not. My problem look realy similar to this post 

If I try to use even parity my slave device never respond to 0x7F

 

EDIT: sometimes I can get chip id

15:45:23:537 : Port configuration: parity = even, baudrate = 115200, data-bit = 8, stop-bit = 1.0, flow-control = off 15:45:23:537 : No Init bits value is : 0 15:45:23:538 : Sending init command: 15:45:23:538 : byte 0x7F sent successfully to target 15:45:23:538 : Wait ends after 1 loop, dataready = 1, delay = 5 15:45:23:538 : Received response from target: 0x79 15:45:23:538 : Activating device: OK 15:45:23:538 : Board : -- 15:45:23:538 : Sending GetID command and its XOR: 15:45:23:538 : byte 0x02 sent successfully to target 15:45:23:538 : byte 0xFD sent successfully to target 15:45:23:538 : Wait ends after 1 loop, dataready = 1, delay = 7 15:45:23:538 : Received response from target: 0x1f 15:45:23:538 : Response received from device: NACK 15:45:23:538 : Error: GETID command not acknowledged! 15:45:23:538 : Reemission of GetID command 15:45:23:538 : Sending GetID command and its XOR: 15:45:23:538 : byte 0x02 sent successfully to target 15:45:23:538 : byte 0xFD sent successfully to target 15:45:23:538 : Wait ends after 1 loop, dataready = 1, delay = 6 15:45:23:538 : Received response from target: 0x79 15:45:23:538 : Received 4 data bytes from target : 0x01049779 15:45:23:538 : Chip ID: 0x497 15:45:23:538 : Sending Get command and its XOR: 15:45:23:538 : byte 0x00 sent successfully to target 15:45:23:539 : byte 0xFF sent successfully to target 15:45:23:539 : Wait ends after 1 loop, dataready = 0, delay = 1001 15:45:23:539 : Timeout error occured while waiting for acknowledgement. 15:45:23:539 : No response from target received 15:45:23:539 : Error: GET command not acknowledged! 15:45:23:539 : Reemission of Get command 15:45:23:539 : Sending Get command and its XOR: 15:45:23:539 : byte 0x00 sent successfully to target 15:45:23:539 : byte 0xFF sent successfully to target 15:45:23:539 : Wait ends after 1 loop, dataready = 1, delay = 5 15:45:23:539 : Received response from target: 0x1f 15:45:23:539 : Response received from device: NACK 15:45:23:539 : Error: GET command not acknowledged! 15:45:23:539 : Reemission of Get command 15:45:23:539 : Sending Get command and its XOR: 15:45:23:539 : byte 0x00 sent successfully to target 15:45:23:539 : byte 0xFF sent successfully to target 15:45:23:539 : Wait ends after 1 loop, dataready = 1, delay = 6 15:45:23:539 : Received response from target: 0x1f 15:45:23:539 : Response received from device: NACK 15:45:23:539 : Error: GET command not acknowledged! 15:45:23:539 : UART PORT CLOSE
View more

 If I try to send command directly from serial terminal (coolterm for example) I have the same problem, first I send 0x7F my stm32wl5 respond 0x79

after send: 0x02, 0xFD, I only receive 0x79, 0x01, and sometime I receive all message.... Do we have to respect a precise timing between sending packets? bytes? I have try to send byte by byte same problem

 

Here is a small python script I used to test

import serial import time ser = serial.Serial('myCOM', baudrate=115200, timeout=1) ser.write(b'\x7F') ack = ser.read() print(f"ACK 0x7F: {ack.hex()}") time.sleep(0.5) ser.write(b'\x02') time.sleep(0.5) ser.write(b'\xFD') resp = ser.read(5) print("Get ID:", resp.hex())

 First command always works, but for example second command 0x02,0xFD, if I send 2 bytes together I always got a NACK 0x1F ser.write(b'\x02\xFD'). //always NACK

But If I add a small sleep and send byte by byte 0x02 first and after sleep (0.5s like in my above script) 0xFD I got 0x79,0x01,0x79, why??

 

EDIT: it's look like as soon as I init my UART2 on my master stm32f4 device, I'm not able to connect with uart and stm32cubeprogrammer to my slave stm32. I've try to set parity NONE, EVEN, no change. It's only working if I don't init my UART2 on my master stm...

2 REPLIES 2
Saket_Om
ST Employee

Hello @SBaro.11 


@SBaro.11 wrote:

Hi,

I'm trying to flash overt build in uart bootlader stm32 slave device. Here is my setup :
Master STM32F4 with tinyUSB

Slave STM32WLE5 device

 

Master and slave are connected together over uart. Master has control of boot0 and reset ligne of slave device.

Master UART2 PD5/PD6

Slave UART2 PA2/PA3

 

I'm able to put slave device into bootloader mode, but when I'm trying to connect with stm32cubeprogrammer over my usb I got NACK command from getId command


Could you explain your setup configuration with more details please? 

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Saket_Om
Karl Yamashita
Principal

My initial impression is that you are trying to use the master to update the slave using UART.

But then you mention stm32cubeprogrammer. So now it's unclear what you're trying to achieve with the master and stm32cubeprogrammer to update the slave?

Are you using the stm32cubeprogrammer to update the slave FW over UART using the DFU?

If so, what HW interface are you using and if that is connected to the same UART as the master?

 

 

Don't worry, I won't byte.
TimerCallback tutorial! | UART and DMA Idle tutorial!

If you find my solution useful, please click the Accept as Solution so others see the solution.