2020-06-12 05:51 PM
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.
Solved! Go to Solution.
2020-08-06 06:44 PM
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!
2020-06-12 07:17 PM
Turn the log verbose level to 3
External loader can output it's own diagnostic/telemetry via a UART
2020-06-12 10:58 PM
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
2020-06-12 10:59 PM
05:55:20:072 : Download in Progress:
05:55:20:073 : Size : 147072 Bytes
05:55:20:073 : Address : 0x08000000
05:55:20:074 : Buffer program...
05:55:20:228 : halt ap 0
05:55:20:229 : w ap 0 reg 15 PC (0x20000000)
05:55:20:230 : w ap 0 reg 17 MSP (0x20000500)
05:55:20:231 : w ap 0 reg 16 xPSR (0x01000000)
05:55:20:234 : w ap 0 @0x20001100 0x00000200 bytes
05:55:20:236 : w ap 0 @0x20000000 0x00000004 bytes
05:55:20:257 : w ap 0 @0x20000004 0x00000CD4 bytes
05:55:20:257 : Loader write range...
05:55:20:772 : w ap 0 @0x20001100 0x00011F40 bytes
05:55:20:773 : W B1 in RAM @0x20001100 size 0x00011F40 : 0515ms
05:55:20:774 : Init flashloader...
05:55:20:776 : halt ap 0
05:55:20:779 : w ap 0 reg 0 R0 0x00000001
05:55:20:782 : w ap 0 reg 1 R1 0x00000000
05:55:20:783 : w ap 0 reg 2 R2 0x00000000
05:55:20:783 : w ap 0 reg 3 R3 0x00000000
05:55:20:786 : w ap 0 reg 4 R4 0x00000000
05:55:20:791 : w ap 0 reg 5 R5 0x00000000
05:55:20:792 : w ap 0 reg 6 R6 0x00000000
05:55:20:793 : w ap 0 reg 7 R7 0x00000000
05:55:20:794 : w ap 0 reg 8 R8 0x00000000
05:55:20:797 : w ap 0 reg 9 R9 0x00000000
05:55:20:797 : w ap 0 reg 10 R10 0x00000000
05:55:20:798 : w ap 0 reg 11 R11 0x00000000
05:55:20:799 : w ap 0 reg 12 R12 0x00000000
05:55:20:803 : w ap 0 reg 13 SP 0x00000000
05:55:20:807 : w ap 0 reg 14 LR 0x20000001
05:55:20:809 : w ap 0 reg 15 PC 0x20000005
05:55:20:810 : w ap 0 reg 16 xPSR 0x01000000
05:55:20:811 : w ap 0 reg 17 MSP 0x200010D4
05:55:20:812 : w ap 0 reg 18 PSP 0x00000000
05:55:20:813 : run ap 0
05:55:20:816 : halt ap 0
05:55:20:817 : r ap 0 reg 0 R0 0x00000001
05:55:20:818 : w ap 0 reg 0 R0 0x08000000
05:55:20:818 : w ap 0 reg 1 R1 0x00011F40
05:55:20:819 : w ap 0 reg 2 R2 0x20001100
05:55:20:820 : w ap 0 reg 3 R3 0x00000002
05:55:20:823 : w ap 0 reg 4 R4 0x00000000
05:55:20:825 : w ap 0 reg 5 R5 0x00000000
05:55:20:832 : w ap 0 reg 6 R6 0x00000000
05:55:20:835 : w ap 0 reg 7 R7 0x00000000
05:55:20:839 : w ap 0 reg 8 R8 0x00000000
05:55:20:842 : w ap 0 reg 9 R9 0x00000000
05:55:20:844 : w ap 0 reg 10 R10 0x00000000
05:55:20:844 : w ap 0 reg 11 R11 0x00000000
05:55:20:849 : w ap 0 reg 12 R12 0x00000000
05:55:20:850 : w ap 0 reg 13 SP 0x00000000
05:55:20:853 : w ap 0 reg 14 LR 0x20000001
05:55:20:857 : w ap 0 reg 15 PC 0x20000051
05:55:20:858 : w ap 0 reg 16 xPSR 0x01000000
05:55:20:859 : w ap 0 reg 17 MSP 0x200010D4
05:55:20:859 : w ap 0 reg 18 PSP 0x00000000
05:55:20:860 : run ap 0
05:55:21:317 : w ap 0 @0x20013040 0x00011F40 bytes
05:55:21:318 : W B2 in RAM @0x20040700 size 0x00011F40: 0545ms
05:55:21:320 : r ap 0 reg 0 R0 0x00000001
05:55:21:320 : Wait W B1 in Flash @0x08000000 size 0x00011F40: 0001ms
05:55:21:324 : w ap 0 reg 0 R0 0x08011F40
05:55:21:325 : w ap 0 reg 1 R1 0x00011F40
05:55:21:328 : w ap 0 reg 2 R2 0x20013040
05:55:21:334 : w ap 0 reg 3 R3 0x00000002
05:55:21:336 : w ap 0 reg 4 R4 0x00000000
05:55:21:337 : w ap 0 reg 5 R5 0x00000000
05:55:21:338 : w ap 0 reg 6 R6 0x00000000
05:55:21:339 : w ap 0 reg 7 R7 0x00000000
05:55:21:341 : w ap 0 reg 8 R8 0x00000000
05:55:21:344 : w ap 0 reg 9 R9 0x00000000
05:55:21:349 : w ap 0 reg 10 R10 0x00000000
05:55:21:354 : w ap 0 reg 11 R11 0x00000000
05:55:21:354 : w ap 0 reg 12 R12 0x00000000
05:55:21:355 : w ap 0 reg 13 SP 0x00000000
05:55:21:356 : w ap 0 reg 14 LR 0x20000001
05:55:21:361 : w ap 0 reg 15 PC 0x20000051
05:55:21:362 : w ap 0 reg 16 xPSR 0x01000000
05:55:21:363 : w ap 0 reg 17 MSP 0x200010D4
05:55:21:364 : w ap 0 reg 18 PSP 0x00000000
05:55:21:365 : run ap 0
05:55:21:615 : r ap 0 reg 0 R0 0x00000001
05:55:21:615 : Write elapsed time: 1357ms
05:55:21:615 : Segment[0] downloaded successfully
05:55:21:615 : Size : 237612 Bytes
05:55:21:616 : Address : 0x90000000
05:55:21:616 : Buffer program...
05:55:21:774 : halt ap 0
05:55:21:774 : w ap 0 reg 15 PC (0x20000000)
05:55:21:775 : w ap 0 reg 17 MSP (0x20000500)
05:55:21:776 : w ap 0 reg 16 xPSR (0x01000000)
05:55:21:779 : w ap 0 @0x2000ED40 0x00000200 bytes
05:55:21:780 : w ap 0 @0x20000000 0x00000004 bytes
05:55:22:199 : w ap 0 @0x20000004 0x0000E90C bytes
05:55:22:201 : Loader write range...
05:55:23:044 : w ap 0 @0x2000ED40 0x0001D000 bytes
05:55:23:045 : W B1 in RAM @0x2000ED40 size 0x0001D000 : 0844ms
05:55:23:046 : Init flashloader...
05:55:23:048 : halt ap 0
05:55:23:053 : w ap 0 reg 0 R0 0x00000001
05:55:23:056 : w ap 0 reg 1 R1 0x00000000
05:55:23:057 : w ap 0 reg 2 R2 0x00000000
05:55:23:058 : w ap 0 reg 3 R3 0x00000000
05:55:23:071 : w ap 0 reg 4 R4 0x00000000
05:55:23:071 : w ap 0 reg 5 R5 0x00000000
05:55:23:072 : w ap 0 reg 6 R6 0x00000000
05:55:23:073 : w ap 0 reg 7 R7 0x00000000
05:55:23:074 : w ap 0 reg 8 R8 0x00000000
05:55:23:074 : w ap 0 reg 9 R9 0x00000000
05:55:23:075 : w ap 0 reg 10 R10 0x00000000
05:55:23:076 : w ap 0 reg 11 R11 0x00000000
05:55:23:077 : w ap 0 reg 12 R12 0x00000000
05:55:23:078 : w ap 0 reg 13 SP 0x00000000
05:55:23:079 : w ap 0 reg 14 LR 0x20000001
05:55:23:079 : w ap 0 reg 15 PC 0x200008D9
05:55:23:080 : w ap 0 reg 16 xPSR 0x01000000
05:55:23:081 : w ap 0 reg 17 MSP 0x2000ED0C
05:55:23:087 : w ap 0 reg 18 PSP 0x00000000
05:55:23:087 : run ap 0
05:55:28:002 : halt ap 0
05:55:28:002 : Init function fail with timeout
05:55:28:003 : r ap 0 reg 16 xPSR 0x21000003
05:55:28:838 : w ap 0 @0x2002BD40 0x0001D02C bytes
05:55:28:839 : W B2 in RAM @0x20047540 size 0x0001D02C: 5794ms
05:55:28:840 : r ap 0 reg 0 R0 0x00000000
05:55:29:095 : halt ap 0
05:55:29:096 : w ap 0 reg 15 PC (0x20000000)
05:55:29:096 : w ap 0 reg 17 MSP (0x20000500)
05:55:29:098 : w ap 0 reg 16 xPSR (0x01000000)
05:55:29:098 : Loader write range...
05:55:29:930 : w ap 0 @0x2000ED40 0x0001D000 bytes
05:55:29:930 : W B1 in RAM @0x2000ED40 size 0x0001D000 : 0833ms
05:55:29:980 : halt ap 0
05:55:29:982 : r ap 0 reg 0 R0 0x00000000
05:55:29:982 : Error: failed to download Segment[1]
05:55:29:983 : Error: failed to download the File
2020-06-14 02:16 PM
Is there anyone that can help me?
2020-06-14 02:50 PM
Entry in to Init() the second time doesn't complete, make sure it is not stuck in a loop waiting for completion, or expectation that HAL tick will advance via an interrupt (SysTick or otherwise)
To have some chance of knowing what's happening internally you'll need to instrument the code
2020-06-15 02:48 PM
This is my Init() function copied from the video i cited before
int Init(void) {
*(uint32_t*)0xE000EDF0=0xA05F0000; //enable interrupts in debug
SystemInit();
/* ADAPTATION TO THE DEVICE
*
* change VTOR setting for H7 device
* SCB->VTOR = 0x24000000 | 0x200;
*
* change VTOR setting for other devices
* SCB->VTOR = 0x20000000 | 0x200;
*
* */
SCB->VTOR = 0x20000000 | 0x200;
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
__HAL_RCC_QSPI_FORCE_RESET(); //completely reset peripheral
__HAL_RCC_QSPI_RELEASE_RESET();
if (CSP_QUADSPI_Init() != HAL_OK)
{
HAL_SuspendTick();
return LOADER_FAIL;
}
if (CSP_QSPI_EnableMemoryMappedMode() != HAL_OK)
{
HAL_SuspendTick();
return LOADER_FAIL;
}
HAL_SuspendTick();
return LOADER_OK;
}
all of the functions inside it work.
2020-06-15 08:05 PM
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.
2020-06-15 09:44 PM
Per other threads, Winbond W25Q256
2020-08-06 06:44 PM
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!