Loading...
 

Zephyr project on STM32

   Zephyr Workbench, a VSCode extension to manage Zephyr on STM32.
It enables users to easily create, develop, and debug Zephyr applications.
Main features:
  • Install host dependencies.
  • Import toolchain and SDK.
  • Create, configure, build and manage apps.
  • Debug STM32.
You can directly download it from the VSCode marketplace
For more details, visit the Zephyr Workbench

System Workbench for STM32


Project doesn't generate .bin file

After upgrading to STM32CubeMX 4.26 I found, that System Workbench project generated by CubeMX, doesn’t produce .bin file during build. Output directory contains .elf and .hex file. In previous versions there was also .bin file. Probably this is some STM32CubeMX problem. However, having such STM32 Workbench project, I want to know, how it works.

In old version the following information was printed during build:
arm-none-eabi-objcopy -O binary “rcu.elf” “rcu.bin”
Now it prints:
arm-none-eabi-objcopy -O ihex “rcu.elf” “rcu.hex”

I have two questions:
1. How does it work when I press Run or Debug button? Does it burn huge .elf file to the device flash memory? For the same project, bin file size is 90 KB, elf file size is 2900 KB.
2. How to change the project settings, to produce .bin file?

Update. To produce .bin file, I need to change the project by the following way:
Project - Properties - C++ Build - Settings - Buidl Steps - Post-build steps. Replace:
arm-none-eabi-objcopy -O ihex “${BuildArtifactFileBaseName}.elf” “${BuildArtifactFileBaseName}.hex” && arm-none-eabi-size “${BuildArtifactFileName}”
with:
arm-none-eabi-objcopy -O ihex “${BuildArtifactFileBaseName}.elf” “${BuildArtifactFileBaseName}.hex” && arm-none-eabi-size “${BuildArtifactFileName}” && arm-none-eabi-objcopy -O binary “${BuildArtifactFileBaseName}.elf” “${BuildArtifactFileBaseName}.bin”

So, I need an answer to the question #1: how does it work internally, when I press Run or Debug button? Maybe it produces .bin file on the fly and burns it to device?

Tunisia

Hi,

For question 2, you already found the solution.

Now, to answer the first question you need to know that neither the hex nor the bin are used in System Workbench to program (burn) the application.

In fact internally System Workbench - as it is gcc based - uses gdb and openocd to program and debug your application.
Thus means that :
- System Workbench passes the elf file to gdb
- gdb reads the debug informations to grants code comprehension
and extracts the loadable sections (same as in the bin file)
then passes these sections to openocd to burn them.

To conclude, the elf does not contains only the burnable image but others information (such as debug info).
And only the loadable sections are programmed, which is equivalent to program the bin, or hex file.

TIP : even the bin, and hex files have different sizes because the content is represented in different ways (+ hex contains adresses, but the bin does not)

Regards,
Tarek

Tarek, thank you for this explanation.

In System WorkBench
Update. To produce .bin file, I need to change the project by the following way:
Project - Properties - C++ Build - Settings - Buidl Steps - Post-build steps. Replace:
arm-none-eabi-objcopy -O ihex “${BuildArtifactFileBaseName}.elf” “${BuildArtifactFileBaseName}.hex” && arm-none-eabi-size “${BuildArtifactFileName}”
with:
arm-none-eabi-objcopy -O ihex “${BuildArtifactFileBaseName}.elf” “${BuildArtifactFileBaseName}.hex” && arm-none-eabi-size “${BuildArtifactFileName}” && arm-none-eabi-objcopy -O binary “${BuildArtifactFileBaseName}.elf” “${BuildArtifactFileBaseName}.bin”

I am getting following errors :

make --no-print-directory post-build
Generating BIN and Printing size information:
arm-none-eabi-objcopy -O ihex “STM_Fork_Module.elf” “STM_Fork_Module.hex”
arm-none-eabi-objcopy: ‘“STM_Fork_Module.elf”’: No such file
make1: *** post-build Error 1
make: *** STM_Fork_Module.elf Error 2
make: Target `all’ not remade because of errors.

Hi,

Try removing the quotes in the command:

arm-none-eabi-objcopy -O ihex ${BuildArtifactFileBaseName}.elf ${BuildArtifactFileBaseName}.hex && arm-none-eabi-size ${BuildArtifactFileName} && arm-none-eabi-objcopy -O binary ${BuildArtifactFileBaseName}.elf ${BuildArtifactFileBaseName}.bin


Regards,
Kevin.


 

Newest Forum Posts

  1. SPI on Nucleo_STMH533RE by royjamil, 2025-05-04 20:13
  2. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-25 07:37
  3. SPI on Nucleo_STMH533RE by royjamil, 2025-03-23 11:31
  4. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-23 09:33
  5. Configuring DMA for ADC in SW? by sam.hodgson, 2025-03-04 12:58
  6. Build a project in "release" mode by info@creosrl.it, 2025-02-20 18:12
  7. Build a project in "release" mode by info@creosrl.it, 2025-02-20 17:05
  8. Build a project in "release" mode by tang, 2025-02-20 10:36
  9. Build a project in "release" mode by info@creosrl.it, 2025-02-19 17:35
  10. Fail to debug in Win 11 C/C++ by mortenlund, 2024-12-26 20:27

Last-Modified Blogs