# Error in building the program, Error in build step #6 (Make): Make process exited with code 2 in STM32G474RE

**URL:** <https://forum.plexim.com/t/error-in-building-the-program-error-in-build-step-6-make-make-process-exited-with-code-2-in-stm32g474re/2211>\
**Category:** STM32\
**Tags:** plecs, stm32\
**Created:** [May 30, 2025, 10:27am UTC](https://forum.plexim.com/t/error-in-building-the-program-error-in-build-step-6-make-make-process-exited-with-code-2-in-stm32g474re/2211 "2025-05-30T10:27:23Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![sajjad](https://avatars.discourse-cdn.com/v4/letter/s/90ced4/32.png) [@sajjad](https://forum.plexim.com/u/sajjad)\
**Post date:** [May 30, 2025, 10:27am UTC](https://forum.plexim.com/t/error-in-building-the-program-error-in-build-step-6-make-make-process-exited-with-code-2-in-stm32g474re/2211/1 "2025-05-30T10:27:23Z")

</div>

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

> **[OpenOCD: Bug Reporting](https://openocd.org/doc/doxygen/html/bugs.html)**

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**

---

<div class="post-metadata">

**Author:** ![Beat\_Arnet](https://dub1.discourse-cdn.com/flex006/user_avatar/forum.plexim.com/beat_arnet/32/9_2.png) [@Beat\_Arnet](https://forum.plexim.com/u/Beat_Arnet)\
**Post date:** [June 2, 2025, 3:05pm UTC](https://forum.plexim.com/t/error-in-building-the-program-error-in-build-step-6-make-make-process-exited-with-code-2-in-stm32g474re/2211/2 "2025-06-02T15:05:43Z")

</div>

Hello Sajjad,

Can you please run the following command and report back the output?

```auto
"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 -c "init" -c "reset halt" -c "flash probe 0" -c "flash info 0" -c "shutdown"

```

Thanks,  
Beat Arnet

---

<div class="post-metadata">

**Author:** ![sajjad](https://avatars.discourse-cdn.com/v4/letter/s/90ced4/32.png) [@sajjad](https://forum.plexim.com/u/sajjad)\
**Post date:** [June 3, 2025, 10:02am UTC](https://forum.plexim.com/t/error-in-building-the-program-error-in-build-step-6-make-make-process-exited-with-code-2-in-stm32g474re/2211/3 "2025-06-03T10:02:25Z")

</div>

> [@Beat\_Arnet](#):
>
> `"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 -c "init" -c "reset halt" -c "flash probe 0" -c "flash info 0" -c "shutdown"`

Dear Bear,  
thank you for you response  
i have uploaded the result of command running and also i have uploaded the SC of Plecs configuration.

best regards  
sajjad

 ![1](https://europe1.discourse-cdn.com/flex006/uploads/plecs/original/2X/d/dd3abcbf38a5c02cf76236a97f1e1f90649821bc.png)  
 ![2](https://europe1.discourse-cdn.com/flex006/uploads/plecs/original/2X/3/35d9183161408666140386d7098d4190efd43c4d.png)  
 ![3](https://europe1.discourse-cdn.com/flex006/uploads/plecs/original/2X/b/b0549e030b21acd4f0d2049ce870f56b6a402b3f.png)  
 ![4](https://europe1.discourse-cdn.com/flex006/uploads/plecs/original/2X/c/c3427d2dbcb2f7717121a3b6ce8627f9efd266da.png)  
 ![5](https://europe1.discourse-cdn.com/flex006/uploads/plecs/original/2X/d/d6802fb4498cdd3292471aca82dd7bf278a65e6a.png)

---

<div class="post-metadata">

**Author:** ![Beat\_Arnet](https://dub1.discourse-cdn.com/flex006/user_avatar/forum.plexim.com/beat_arnet/32/9_2.png) [@Beat\_Arnet](https://forum.plexim.com/u/Beat_Arnet)\
**Post date:** [June 3, 2025, 11:05am UTC](https://forum.plexim.com/t/error-in-building-the-program-error-in-build-step-6-make-make-process-exited-with-code-2-in-stm32g474re/2211/4 "2025-06-03T11:05:24Z")

</div>

Are you sure that you executed to **entire** command that I provided, including the `-c` arguments? I would have expected to see information about the flash and its protection settings.

---

<div class="post-metadata">

**Author:** ![sajjad](https://avatars.discourse-cdn.com/v4/letter/s/90ced4/32.png) [@sajjad](https://forum.plexim.com/u/sajjad)\
**Post date:** [June 3, 2025, 11:33am UTC](https://forum.plexim.com/t/error-in-building-the-program-error-in-build-step-6-make-make-process-exited-with-code-2-in-stm32g474re/2211/5 "2025-06-03T11:33:08Z")

</div>

> [@Beat\_Arnet](#):
>
> “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 -c “init” -c “reset halt” -c “flash probe 0” -c “flash info 0” -c “shutdown”

i uploaded the new one  
from # 15: 0x00007800 (0x800 2kB) not protected  
to  
#225: 0x00070800 (0x800 2kB) not protected  
are the same, for this reason i did not take Screen shot between them.

 ![a](https://europe1.discourse-cdn.com/flex006/uploads/plecs/original/2X/3/3f705011a8a31a8ba23b467e65e1fa4c37deeba6.png)  
 ![b](https://europe1.discourse-cdn.com/flex006/uploads/plecs/original/2X/9/9e74ea12b05902a97603634cefda9d0b62a6fd80.png)

---

<div class="post-metadata">

**Author:** ![sajjad](https://avatars.discourse-cdn.com/v4/letter/s/90ced4/32.png) [@sajjad](https://forum.plexim.com/u/sajjad)\
**Post date:** [June 4, 2025, 11:54am UTC](https://forum.plexim.com/t/error-in-building-the-program-error-in-build-step-6-make-make-process-exited-with-code-2-in-stm32g474re/2211/7 "2025-06-04T11:54:42Z")

</div>

> [@Beat\_Arnet](#):
>
> Are you sure that you executed to **entire** command that I provided, including the `-c` arguments? I would have expected to see information about the flash and its protection settings.

Yesterday, the first time I ran the following command:  
“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 -c “init” -c “reset halt” -c “flash probe 0” -c “flash info 0” -c “shutdown” as you suggested.  
I got the output shown in the first screenshot of the CMD window. i am sure that i did not anything, but after running the command again, I received the output in the second screenshot — and the board was successfully programmed. I was even able to use external mode via JTAG.

However, today I’m working with the board again and facing the same issue as before. No matter what I try, nothing seems to solve the problem.

---

<div class="post-metadata">

**Author:** ![sajjad](https://avatars.discourse-cdn.com/v4/letter/s/90ced4/32.png) [@sajjad](https://forum.plexim.com/u/sajjad)\
**Post date:** [June 4, 2025, 12:33pm UTC](https://forum.plexim.com/t/error-in-building-the-program-error-in-build-step-6-make-make-process-exited-with-code-2-in-stm32g474re/2211/8 "2025-06-04T12:33:30Z")

</div>

the problem was solder jumper of NRST on my board  
its soldering was weak.

---

<div class="post-metadata">

**Author:** ![Beat\_Arnet](https://dub1.discourse-cdn.com/flex006/user_avatar/forum.plexim.com/beat_arnet/32/9_2.png) [@Beat\_Arnet](https://forum.plexim.com/u/Beat_Arnet)\
**Post date:** [June 4, 2025, 12:52pm UTC](https://forum.plexim.com/t/error-in-building-the-program-error-in-build-step-6-make-make-process-exited-with-code-2-in-stm32g474re/2211/9 "2025-06-04T12:52:09Z")

</div>

Nice debugging! I am glad you figured it out.
