cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L452 SPI Bootloader (internal, from system memory)

Denis Krasutski
Associate III
Posted on May 23, 2017 at 11:18

Hello everyone, 

   I have the following issue: when I try to flash firmware over SPI Bootloader and send data by command 0x31U (Write Memory)  then read data by 0x11U  (Read Memory) I got corrupted data, some words still have 0xFFFFFFFF value. 

Command 'read memory' return the correct(real) data, I checked it by st-link directly. It is mean command 'Write Memory' work incorrect. 

If I try to write data and then verify it again,  after ~15 attempts, finally, I am getting the correct result.

I implemented delay as provided in the documentation but this can't improve the situation.

Document 

DocID024458 Rev 4, 

AN4286, 

SPI protocol used in the STM32 bootloader

Note: In some operating conditions, the Master has to wait for a delay of 1 ms after receiving the

Acknowledge and before sending the data frame (number of bytes to be written, data to be

written and checksum).

Detail:

Bootloader version: 0x11

Chip Id: 0x0462

Payload size: 256 

HW

SPI Clock = 1MHz

LSE is present,

HSE is absent 

Power = 1V8

Command sequence:

1. Sync word, wait for ack

2. Get version

3. Get Chip ID

4. Read the first page

5. Mass Erase if the first page not empty

6. Write 256 bytes

7. Read 256

8. Verify

9. Goto step6 if Verify failed.

10. Write next 256 bytes and verify and etc...

What do I wrong? Could you provide some advice?

BR,

Denis

#system-memory #spi-bootloader #stm32l4
1 REPLY 1
Denis Krasutski
Associate III
Posted on May 25, 2017 at 15:17

Thank you guys!)

I figured out the reason!

The problem in VDDUSB, my circuit provide VDDUSB when USB is connected, otherwise VDDUSB = 0.

I suppose USB error interrupts don't allow work correctly. I observed similar behavior in my application when USB was initialized but VDD = USB0,

Workarounds:

1. USB is connected: Initialize SPI bootloader before will activate USB DFU.

2. USB is disconnected and VDDUSB = 0: You must have the possibility to pull up USBVDD pin. In my case, I have external_power signal on the second MCU connected to

USBVDD, and reinit pin to output, I do it shortly, after shortly high-level bootloader work correctly, 

 don't hesitate about level ~1V fix it problem

MySTM32 SPI Bootloader Client here: 

https://github.com/Krasutski/stm32_spi_bootloader_client/