Skip to main content
AMerc.4
Senior
June 13, 2020
Solved

Problem with custom external loader

  • June 13, 2020
  • 13 replies
  • 3053 views

Hello i created a custom external loader following this guide. My check code in the main (see the video) works. I can read in memory mapped mode, i can write and i can erase sectors and full chip.

I can write to it simple bin files using stM32 Programmer, but, when i try to upload a touchGFX application (created following this video) the programmer say error "Error: failed to download Segment[1]". The full log is

00:50:06 : STM32CubeProgrammer API v2.4.0
00:50:12 : ST-LINK SN : 51FF6A064882575053240587
00:50:12 : ST-LINK FW : V2J36S7
00:50:12 : Voltage : 3.28V
00:50:12 : SWD freq : 4000 KHz
00:50:12 : Connect mode: Normal
00:50:12 : Reset mode : Software reset
00:50:12 : Device ID : 0x451
00:50:13 : UPLOADING OPTION BYTES DATA ...
00:50:13 : Bank : 0x00
00:50:13 : Address : 0x40023c14
00:50:13 : Size : 8 Bytes
00:50:13 : UPLOADING ...
00:50:13 : Size : 1024 Bytes
00:50:13 : Address : 0x8000000
00:50:13 : Read progress:
00:50:13 : Data read successfully
00:50:13 : Time elapsed during the read operation is: 00:00:00.007
00:50:24 : Flash sector erase ...
00:50:24 : Existing specified sectors are erased successfully Protected sectors are not erased
00:50:28 : Memory Programming ...
00:50:28 : Opening and parsing file: arlix3.elf
00:50:28 : File : arlix3.elf
00:50:28 : Size : 384660 Bytes
00:50:28 : Address : 0x08000000
00:50:28 : Erasing memory corresponding to segment 0:
00:50:28 : Erasing internal memory sectors [0 4]
00:50:30 : Erasing memory corresponding to segment 1:
00:50:30 : Erasing external memory sectors [0 3]
00:50:32 : Download in Progress:
00:50:41 : Error: failed to download Segment[1]
00:50:41 : Error: failed to download the File

I really need that this works, and i know that is maybe something stupid. I hope you can help me.

This topic has been closed for replies.
Best answer by AMerc.4

Ok, i changed the FLASH memory to a much supported by examples like MT25QL128ABA1EW9. I added a pullup resistor to CS pin, and i added a decoupler capacitor to VCC and now it works! So i don't know the problem, but now works and i'm happy!

13 replies

Tesla DeLorean
Guru
June 13, 2020

Turn the log verbose level to 3

External loader can output it's own diagnostic/telemetry via a UART

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
AMerc.4
AMerc.4Author
Senior
June 13, 2020
05:54:51 : STM32CubeProgrammer API v2.4.0
05:54:59 : ST-LINK SN : 51FF6A064882575053240587
05:54:59 : ST-LINK FW : V2J36S7
05:54:59 : Voltage : 3.27V
05:54:59 : SWD freq : 4000 KHz
05:54:59 : Connect mode: Normal
05:54:59 : Reset mode : Software reset
05:54:59 : Device ID : 0x451
05:55:00 : UPLOADING OPTION BYTES DATA ...
05:55:00 : Bank : 0x00
05:55:00 : Address : 0x40023c14
05:55:00 : Size : 8 Bytes
05:55:00 : UPLOADING ...
05:55:00 : Size : 1024 Bytes
05:55:00 : Address : 0x8000000
05:55:00 : Read progress:
05:55:00 : Data read successfully
05:55:00 : Time elapsed during the read operation is: 00:00:00.007
05:55:15:713 : Memory Programming ...
05:55:15:715 : Opening and parsing file: arlix3.elf
05:55:15:731 : File : arlix3.elf
05:55:15:732 : Size : 384660 Bytes
05:55:15:733 : Address : 0x08000000
05:55:15:734 : Erasing Segment <0> Address <0x08000000> Size <147048>Bytes
05:55:15:734 : Erasing memory corresponding to segment 0:
05:55:15:910 : Memory erase...
05:55:16:034 : halt ap 0
05:55:16:035 : w ap 0 reg 15 PC (0x20000000)
05:55:16:037 : w ap 0 reg 17 MSP (0x20000500)
05:55:16:039 : w ap 0 reg 16 xPSR (0x01000000)
05:55:16:041 : w ap 0 @0x20001100 0x00000200 bytes
05:55:16:044 : w ap 0 @0x20000000 0x00000004 bytes
05:55:16:063 : w ap 0 @0x20000004 0x00000CD4 bytes
05:55:16:063 : Erasing internal memory sectors [0 4]
05:55:16:064 : Init flashloader...
05:55:16:069 : halt ap 0
05:55:16:072 : w ap 0 reg 0 R0 0x00000001
05:55:16:072 : w ap 0 reg 1 R1 0x00000000
05:55:16:073 : w ap 0 reg 2 R2 0x00000000
05:55:16:073 : w ap 0 reg 3 R3 0x00000000
05:55:16:073 : w ap 0 reg 4 R4 0x00000000
05:55:16:073 : w ap 0 reg 5 R5 0x00000000
05:55:16:073 : w ap 0 reg 6 R6 0x00000000
05:55:16:074 : w ap 0 reg 7 R7 0x00000000
05:55:16:074 : w ap 0 reg 8 R8 0x00000000
05:55:16:074 : w ap 0 reg 9 R9 0x00000000
05:55:16:074 : w ap 0 reg 10 R10 0x00000000
05:55:16:074 : w ap 0 reg 11 R11 0x00000000
05:55:16:075 : w ap 0 reg 12 R12 0x00000000
05:55:16:079 : w ap 0 reg 13 SP 0x00000000
05:55:16:079 : w ap 0 reg 14 LR 0x20000001
05:55:16:079 : w ap 0 reg 15 PC 0x20000005
05:55:16:080 : w ap 0 reg 16 xPSR 0x01000000
05:55:16:080 : w ap 0 reg 17 MSP 0x200010D4
05:55:16:081 : w ap 0 reg 18 PSP 0x00000000
05:55:16:081 : run ap 0
05:55:16:123 : halt ap 0
05:55:16:123 : r ap 0 reg 0 R0 0x00000001
05:55:16:124 : Loader sector erase...
05:55:16:124 : w ap 0 reg 0 R0 0x08000000
05:55:16:124 : w ap 0 reg 1 R1 0x08020000
05:55:16:124 : w ap 0 reg 2 R2 0x00000002
05:55:16:124 : w ap 0 reg 3 R3 0x00000000
05:55:16:124 : w ap 0 reg 4 R4 0x00000000
05:55:16:125 : w ap 0 reg 5 R5 0x00000000
05:55:16:128 : w ap 0 reg 6 R6 0x00000000
05:55:16:131 : w ap 0 reg 7 R7 0x00000000
05:55:16:137 : w ap 0 reg 8 R8 0x00000000
05:55:16:140 : w ap 0 reg 9 R9 0x00000000
05:55:16:143 : w ap 0 reg 10 R10 0x00000000
05:55:16:146 : w ap 0 reg 11 R11 0x00000000
05:55:16:146 : w ap 0 reg 12 R12 0x00000000
05:55:16:146 : w ap 0 reg 13 SP 0x00000000
05:55:16:147 : w ap 0 reg 14 LR 0x20000001
05:55:16:147 : w ap 0 reg 15 PC 0x20000281
05:55:16:147 : w ap 0 reg 16 xPSR 0x01000000
05:55:16:147 : w ap 0 reg 17 MSP 0x200010D4
05:55:16:148 : w ap 0 reg 18 PSP 0x00000000
05:55:16:148 : run ap 0
05:55:17:384 : halt ap 0
05:55:17:385 : r ap 0 reg 0 R0 0x00000001
05:55:17:385 : erase: 1654ms
05:55:17:386 : Erasing Segment <1> Address <0x90000000> Size <237612>Bytes
05:55:17:386 : Erasing memory corresponding to segment 1:
05:55:17:581 : Memory erase...
05:55:17:769 : halt ap 0
05:55:17:769 : w ap 0 reg 15 PC (0x20000000)
05:55:17:774 : w ap 0 reg 17 MSP (0x20000500)
05:55:17:785 : w ap 0 reg 16 xPSR (0x01000000)
05:55:17:785 : w ap 0 @0x2000ED40 0x00000200 bytes
05:55:17:786 : w ap 0 @0x20000000 0x00000004 bytes
05:55:18:197 : w ap 0 @0x20000004 0x0000E90C bytes
05:55:18:198 : Erasing external memory sectors [0 3]
05:55:18:200 : Init flashloader...
05:55:18:201 : halt ap 0
05:55:18:202 : w ap 0 reg 0 R0 0x00000001
05:55:18:202 : w ap 0 reg 1 R1 0x00000000
05:55:18:203 : w ap 0 reg 2 R2 0x00000000
05:55:18:204 : w ap 0 reg 3 R3 0x00000000
05:55:18:205 : w ap 0 reg 4 R4 0x00000000
05:55:18:206 : w ap 0 reg 5 R5 0x00000000
05:55:18:234 : w ap 0 reg 6 R6 0x00000000
05:55:18:235 : w ap 0 reg 7 R7 0x00000000
05:55:18:250 : w ap 0 reg 8 R8 0x00000000
05:55:18:262 : w ap 0 reg 9 R9 0x00000000
05:55:18:270 : w ap 0 reg 10 R10 0x00000000
05:55:18:286 : w ap 0 reg 11 R11 0x00000000
05:55:18:287 : w ap 0 reg 12 R12 0x00000000
05:55:18:297 : w ap 0 reg 13 SP 0x00000000
05:55:18:306 : w ap 0 reg 14 LR 0x20000001
05:55:18:318 : w ap 0 reg 15 PC 0x200008D9
05:55:18:319 : w ap 0 reg 16 xPSR 0x01000000
05:55:18:327 : w ap 0 reg 17 MSP 0x2000ED0C
05:55:18:328 : w ap 0 reg 18 PSP 0x00000000
05:55:18:329 : run ap 0
05:55:18:337 : halt ap 0
05:55:18:337 : r ap 0 reg 0 R0 0x00000001
05:55:18:338 : Loader sector erase...
05:55:18:338 : w ap 0 reg 0 R0 0x90000000
05:55:18:339 : w ap 0 reg 1 R1 0x90030000
05:55:18:339 : w ap 0 reg 2 R2 0x00000002
05:55:18:340 : w ap 0 reg 3 R3 0x00000000
05:55:18:340 : w ap 0 reg 4 R4 0x00000000
05:55:18:341 : w ap 0 reg 5 R5 0x00000000
05:55:18:341 : w ap 0 reg 6 R6 0x00000000
05:55:18:342 : w ap 0 reg 7 R7 0x00000000
05:55:18:342 : w ap 0 reg 8 R8 0x00000000
05:55:18:342 : w ap 0 reg 9 R9 0x00000000
05:55:18:358 : w ap 0 reg 10 R10 0x00000000
05:55:18:359 : w ap 0 reg 11 R11 0x00000000
05:55:18:359 : w ap 0 reg 12 R12 0x00000000
05:55:18:359 : w ap 0 reg 13 SP 0x00000000
05:55:18:360 : w ap 0 reg 14 LR 0x20000001
05:55:18:360 : w ap 0 reg 15 PC 0x200009A9
05:55:18:361 : w ap 0 reg 16 xPSR 0x01000000
05:55:18:361 : w ap 0 reg 17 MSP 0x2000ED0C
05:55:18:362 : w ap 0 reg 18 PSP 0x00000000
05:55:18:362 : run ap 0
05:55:20:071 : halt ap 0
05:55:20:071 : r ap 0 reg 0 R0 0x00000001
05:55:20:071 : erase: 2686ms

AMerc.4
AMerc.4Author
Senior
June 14, 2020

Is there anyone that can help me?

AME MCU Support Center BB
ST Employee
June 16, 2020

I will assume that you ran different tests in standalone before you do the integration into your application.

Things to try without any internal flash programming - just run tests on the external loader:

Disable interrupts - For that you would need to remove HAL_Delay()

Make sure you don't have the watchdog enabled

Program the external memory without erasing it - assuming the memory is already erased.

Erase different sectors - check if the issue is related to a specific sector

By the way what memory are you using?

Let us know about your findings.

Tesla DeLorean
Guru
June 16, 2020

Per other threads, Winbond W25Q256

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
AMerc.4
AMerc.4AuthorBest answer
Senior
August 7, 2020

Ok, i changed the FLASH memory to a much supported by examples like MT25QL128ABA1EW9. I added a pullup resistor to CS pin, and i added a decoupler capacitor to VCC and now it works! So i don't know the problem, but now works and i'm happy!

Bob Bailey
Senior
December 21, 2020

On threads with "answers", I'm not sure if its better to ask a follow up question here or start a new thread. But, for Octo-spi external loaders is it as "simple" as replacing the qspi calls with ospi calls in the loader code? (or just name our ospi functions with qspi names?)

Any example OSPI loaders ? I'm planning a project with the h735, and will likely need to multiplex my RAM and FLASH. If I use the DISCO port assignments for the FLASH, would the existing DISCO loader work ok?

Thanks,

Bob

Tesla DeLorean
Guru
December 21, 2020

If they are close enough, just wade in, everyone else does. If you think it would be clearer to start your own thread, or the current one is already 10-20 posts deep, do that and cite a couple of relevant threads. For different STM32 and QSPI IC best to start new threads, or be very specific about what you're using/talking about.

If memory chip, clocks and pins are consistent existing loaders can be used. For slight variations they can also be patched/modified in hours rather than days.

Good examples are sparse. ST didn't use HAL/CUBE for some of them, and the examples that do are often necessarily bloated and dependent on interrupts, which isn't necessary. HAL_Delay() issues can be addressed elegantly without.

On QSPI vs OSPI, there might be some L4+ examples floating around, but yes pretty much just need to switch the BSP code, make sure the interface comes up and maps the memory at 0x90000000. Programming dual-quad devices has some challenges as erase/write can complete out-of-order but if you wait for both it all works. Best to test the living snot out of the thing outside of the external loader environment as very difficult to debug otherwise. You can use board level LED's, USART's etc to provide side-band diagnostic output. Figure several man-days to properly implement and test.

These loaders shouldn't be as hard as ST makes them, QA teams need to test the stuff more thoroughly and hold everyone in the chain accountable..

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Bob Bailey
Senior
December 21, 2020

Thanks for your reply.

(Figure several man-days to properly implement and test.) - that's disappointing considering that CubeMX should be able to generate them.

I'll probably have more questions once I get to that phase. Still preliminary here, working on disco boards with "shields". if the 176pin lqfp were more available this wouldn't be an issue (144 pin seems like it will be easier to get in my quantities)

Bob