2025-04-19 7:39 AM - edited 2025-04-19 12:43 PM
Hi,
so i have a strange problem with SDMMC and USB msc :
- custom board with H743ZI , 2x sd-card , 1x USB msc , for USB stick data;
- software using HAL, FatFS etc; made on IDE 1.10 , migrate ...13, 15, 17, 18, now 1.18.1 (actual)
- program working fine since > 1 year , but without DMA on sdmmc and usb/host ;
- for debug/messages with SWO, SWV working , as it should;
Now i tried using the DMA setting for sd and usb - no, nothing working.
SD stays on waiting for first data transfer, USB hangs in a loop: connecting-disconnected-connecting....
So i made a dummy test project, just debug + SDMMC1 + USB host, msc :
surprisingly works "out of the box", can mount sd and usb and read, ok; but no SWV at all - nothing!
Then i checked with CubeProgrammer (has SWV also) and it shows : something is sent, but hangs him up,
last thing CubeProg showing is this : <unknown packet> (then need to kill the prog, not any reaction)
And now the really strange thing: on same hardware, same 200M core clock, same settings for used pins:
- the old program cannot work with sd or usb + DMA , but sending SWO correct.
- the dummy program working fine with sd1+usb DMA enabled, but no SWO messages at all.
- the dummy program not working with sdmmc2+ DMA enabled, but no SWO messages at all.
- both programs working with sdmmc1+2+USB , but no DMA , and no SWO messages at dummy prog.
Then i compared the used/included :
- libs from HAL etc : same
- startup code : same
- looked in ioc files : "same" (i could not find any important diff, besides the many more pins + periph used in the program, dummy uses only the needed pins for debug, sd , usb)
So i have no idea, why this all is so different in errors , on same IDE, compiler, libs, settings , and same hardware .
Do i anything wrong ?
Would be great, if someone has a good idea...
+ update:
made a new project,dummiii, same hardware, at 200M, but only : debug + swv , nothing else.
and this .... can send swv, no problem !
so i copy the send "program" to first dummy-prog, but now : no debug, just :
Info : STLINK V2J46S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.267200
Info : clock speed 4000 kHz
Info : stlink_dap_op_connect(connect)
Info : SWD DPIDR 0x6ba02477
Info : [STM32H743ZITx.ap2] Examination succeed
Error: Failed to read memory at 0x5c001000
Error: [STM32H743ZITx.cm7] Examination failed
Warn : target STM32H743ZITx.cm7 examination failed
Info : gdb port disabled
Info : starting gdb server for STM32H743ZITx.cm7 on 3333
Info : Listening on port 3333 for gdb connections
Info : accepting 'gdb' connection on tcp/3333
Error: Target not examined yet
Error: auto_probe failed
.. debug dont remember the H743 ??? or what ?
+
then i set on dummiii optimizer to -O2 (was -O0 , default)
now, also no debug:
File download complete
Time elapsed during download operation: 00:00:01.001
Verifying ...
Download verified successfully
Shutting down...
Exit.
so flash ok, but then...exit.
perfect.
So checking, what was flashed, with CubeProgrammer, it shows:
Fine, dummiii flashed, and swo working. But IDE cannot debug any more , what it just flashed ??
After 3 attempts, unplug st-link, try again...suddenly it works again :
(Better, i dont write, what i think now.)
Then tried dummy , with optimizer set to -O3 , no debug , it tells:
Info : flash size probed value 1024k
Info : STM32H7 flash has dual banks
Info : Bank (0) size is 512 kb, base address is 0x08000000
Info : Device: STM32H74x/75x
Info : flash size probed value 1024k
Info : STM32H7 flash has dual banks
Info : Bank (1) size is 512 kb, base address is 0x08100000
Info : New GDB Connection: 1, Target STM32H743ZITx.cm7, state: running
Warn : GDB connection 1 on target STM32H743ZITx.cm7 not halted
undefined debug reason 8 (UNDEFINED) - target needs reset
Error: Failed to read memory at 0xe00e3fc8
Error executing event gdb-detach on target STM32H743ZITx.cm7:
read_memory: failed to read memory
Info : dropped 'gdb' connection
shutdown command invoked
hmmm - so check with connect on CubeProgrammer : hey, it has new info for me !!!! see:
btw I never played around with trustZone or chip protection levels.
Soo... ?
2025-04-19 12:46 PM - edited 2025-04-19 1:03 PM
un-re plugging st-link , CubeProgrammer :
So still dummiii prog running, and swo works.
-------------------------------------------
Then set debug in IDE to GDB, un-re-plug st-link, debug ends:
STM32CubeProgrammer v2.19.0
-------------------------------------------------------------------
Log output file: /tmp/STM32CubeProgrammer_2zXUa4.log
ST-LINK SN : 56FF68064972495625570387
ST-LINK FW : V2J46S7
Board : --
Voltage : 3,26V
SWD freq : 4000 KHz
Connect mode: Under Reset
Reset mode : Hardware reset
Device ID : 0x450
Revision ID : Rev V
Device name : STM32H7xx
Flash size : 1 MBytes
Device type : MCU
Device CPU : Cortex-M7
BL Version : 0x91
Opening and parsing file: ST-LINK_GDB_server_JLABD4.srec
Memory Programming ...
File : ST-LINK_GDB_server_JLABD4.srec
Size : 64.39 KB
Address : 0x08000000
Erasing memory corresponding to sector 0:
Erasing internal memory sector 0
Download in Progress:
File download complete
Time elapsed during download operation: 00:00:01.445
Verifying ...
Download verified successfully
Shutting down...
Exit.
--- and CubeProgrammer ..?
obviously dummy flashed, but still no correct swo:
So set debug to OCD, debug hangs in startup and exit. After third attempt, suddenly strt debug:
--- but still no swo , correct swo.
Finish for today.