Hello Everyone,
I hope this message finds you well.
I am currently working with a custom board based on the STM32G474RE microcontroller and attempting to program it using PLECS Coder. Unfortunately, I’m encountering an issue during the build and flashing process. Even a simple LED blinking test fails.
To clarify:
- The custom board functions correctly when tested with STM32CubeIDE.
- The PLECS simulation is also working properly, as the same test (blinking an LED) runs fine on a standard STM32G474RE board.
- The issue arises when I try to connect and program my custom board via PLECS
I get this error :
Error in build step #6 (Make): Make process exited with code 2:
“C:/Users/Sajjad/Desktop/Coder_Targert/tsp_stm32/bin/c2p-gdb/c2p-gdb” load --server-cmd “"C:/Users/Sajjad/Desktop/Coder_Targert/tsp_stm32/bin/openocd/bin/openocd" -s "C:/Users/Sajjad/Desktop/Coder_Targert/tsp_stm32/bin/openocd/share/openocd/scripts" -f board/stm32g431.cfg” --server-start-delay 1000 --port 3333 --nvic 0x8000000 ./output_STM32G474RE/G474RE.elf
Architecture: arm
Unable to load binary “./output_STM32G474RE/G474RE.elf”. Unable to erase flash.
Healthy exit.
G474RE.mk:237: recipe for target ‘download’ failed
Open On-Chip Debugger 0.11.0 (2021-12-23-14:02)
Licensed under GNU GPL v2
For bug reports, read
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : clock speed 2000 kHz
Info : STLINK V3J16M7B5S1 (API v3) VID:PID 0483:374F
Info : Target voltage: 3.292615
Info : stm32g4x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : starting gdb server for stm32g4x.cpu on 3333
Info : Listening on port 3333 for gdb connections
Info : accepting ‘gdb’ connection on tcp/3333
target halted due to debug-request, current mode: Handler HardFault
xPSR: 0x01000003 pc: 0xfffffffe msp: 0xffffffd8
Info : device idcode = 0x20036469 (STM32G47/G48xx - Rev ‘unknown’ : 0x2003)
Info : flash size = 512kbytes
Info : flash mode : dual-bank
Info : Unable to match requested speed 2000 kHz, using 1000 kHz
Info : Unable to match requested speed 2000 kHz, using 1000 kHz
Error: timed out while waiting for target halted
TARGET: stm32g4x.cpu - Not halted
in procedure ‘ocd_gdb_restart’
Info : Unable to match requested speed 2000 kHz, using 1000 kHz
Info : Unable to match requested speed 2000 kHz, using 1000 kHz
Error: timed out while waiting for target halted
Error executing event gdb-flash-erase-start on target stm32g4x.cpu:
TARGET: stm32g4x.cpu - Not halted
Error: Target not halted
Error: failed erasing sectors 0 to 9
Error: flash_erase returned -304
Info : dropped ‘gdb’ connection
make: *** [download] Error 1
Could you please help me identify what might be causing this issue? Is there a specific configuration required in PLECS or OpenOCD for custom STM32G4 boards?
Thank you in advance for your support.
Best regards,
Sajjad