cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass argument -O ihex toSTM32CubeIDE trough bash

RajeevAroraCrcEvans
Associate III

Dear @Khouloud ZEMMELI , @Imen.D ,

I am building IOC file with help of a make release file which I execute under bash.

The (default) STM32CubeIDE project has Debug as the Active configuration and also has the "-O ihex" enabled under the MCU Post build outputs settings.

I want to also pass the "Convert to Intel HEx file (-O ihex)" setting as input to STM32CubeIDE when I execute below under bash

 

C:/ST/STM32CubeIDE_1.14.1/STM32CubeIDE/stm32cubeidec.exe -nosplash -application org.eclipse.cdt.managedbuilder.core.headlessbuild -cleanBuild ${BLD_TYPE} -importAll ./ -data ${TMPDIR} > BuildResult.Log

 

 

Please suggest how this shall be achieved.

I assume the number / id / optionid 1613718931 will differ for different projects,

 

							<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.converthex.1613718931" name="Convert to Intel Hex file (-O ihex)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.converthex" useByScannerDiscovery="false" value="true" valueType="boolean"/>

 

I am unaware what to use with -T option

 

Invalid Arguments: [-cleanBuild, all, -importAll, ./, -T, 1613718931=true]
Error: Index 6 out of bounds for length 6

 


Please suggest a solution that if possible is independent of the optionid number

More info added:
If above is not possible how do I execute below, without having to bother about the location of arm-none-eabi-objcopy executable

	arm-none-eabi-objcopy  -O ihex $(EXECUTABLES) "Project_HEX_File.hex"

 

Thanks!

Rajeev

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Pavel A. 

I've created a bash script that helps me find paths and execute required executables from bash itself.

#!/bin/bash
source "$(dirname $0)/test.config"

declare -i Index=1
for s in $(MSYS_NO_PATHCONV=1 reg.exe query HKLM\\software\\STMicroelectronics\\STM32CubeIDE /s /v Path /reg:32)
do
	((Index++))
	if [ ${Index} -ne 6 ]; then
		continue
	else
		STM232CUBE_IDE_PATH=${s}
	fi
done

if [ -n "${STM232CUBE_IDE_PATH}" ]; then
	_CIDE_INST_PATH=$(cygpath -u ${STM232CUBE_IDE_PATH})/STM32CubeIDE
	if [ -f "${_CIDE_INST_PATH}/stm32cubeide.exe" ]; then
		echo EXE exists
		RS=$(grep ^"\-Declipse.buildId=Version " ${_CIDE_INST_PATH}/stm32cubeide.ini)
		echo STM32CubeIDE ${RS#\-Declipse.buildId=}
		PATH_ELF_TO_HEX=$(find "${_CIDE_INST_PATH}/plugins" -type d -iname "com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32*")/tools/bin
		${PATH_ELF_TO_HEX}/arm-none-eabi-objcopy --help
	fi
fi

View solution in original post

7 REPLIES 7
Imen.D
ST Employee

Hello @RajeevAroraCrcEvans ,

Try this link that may help you on your issue. 

Please, keep us informed about your progress on this issue and feel free to share feedback with us.

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

Hello @Imen.D 

The bash is unaware of the path to arm-none-eabi-objcopy

Also the path to the executable is pretty long.

With STM32CubeMX and STM32CubeIDE newer versions being released, I will also have to change below to something more generic, or otherwise rely on the tool installer (from ST) to remove previous path from PATH variable and add the latest path of the tool to it:

C:/ST/STM32CubeIDE_1.14.1/STM32CubeIDE

 Please share your views.

Thanks,

Rajeev

Pavel A.
Evangelist III

@RajeevAroraCrcEvans The option  "Convert to Intel Hex file" is already set in your CubeIDE projects, so when your projects build, the hex files should be created.

If you want to run objcopy separately, you'll have to figure out location of the cross tools from the location of CubeIDE.exe. This is tedious but not rocket science.

The options for Eclipse CDT headless build are documented here.

Attached: script to find installed CubeIDE and toolchains for Windows.

Dear @Pavel A. ,

Thanks for sharing the script! I will go through it.

Currently after I generate a project from IOC file:

1. by default the Debug configuration gets used when I build the code through STM32CubeIDE. In order to use the Release configuration, I need to manually select it. (I am not aware of whether there is some difference between the two besides the code size options -O0 verses -O3. After setting optimization to none for both Debug and Release (for testing) I find the generated elf information is alike.)

2. I have to manually open the project settings and enable option -O ihex for the project. I wanted to avoid this step as my teammates will use the .cproject / ,project with default settings and makerelease file to generate the hex file.

Regards,

Rajeev

Dear @Pavel A. , @Imen.D 
I opened registry (regedit.exe) and observe that path HKLM\software\STMicroelectronics does not exist in registry. I am using Windows 11.

Has the location for storing information about the installed STM32CubeIDE (And STM32CubeMX) tool(s) changed?

Regards,

Rajeev

Hi @RajeevAroraCrcEvans The path is in 32-bit part of the registry: HKLM\Software\WOW6432NODE\STMicroelectronics . Reg.exe looks there automatically.

Hi @Pavel A. 

I've created a bash script that helps me find paths and execute required executables from bash itself.

#!/bin/bash
source "$(dirname $0)/test.config"

declare -i Index=1
for s in $(MSYS_NO_PATHCONV=1 reg.exe query HKLM\\software\\STMicroelectronics\\STM32CubeIDE /s /v Path /reg:32)
do
	((Index++))
	if [ ${Index} -ne 6 ]; then
		continue
	else
		STM232CUBE_IDE_PATH=${s}
	fi
done

if [ -n "${STM232CUBE_IDE_PATH}" ]; then
	_CIDE_INST_PATH=$(cygpath -u ${STM232CUBE_IDE_PATH})/STM32CubeIDE
	if [ -f "${_CIDE_INST_PATH}/stm32cubeide.exe" ]; then
		echo EXE exists
		RS=$(grep ^"\-Declipse.buildId=Version " ${_CIDE_INST_PATH}/stm32cubeide.ini)
		echo STM32CubeIDE ${RS#\-Declipse.buildId=}
		PATH_ELF_TO_HEX=$(find "${_CIDE_INST_PATH}/plugins" -type d -iname "com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32*")/tools/bin
		${PATH_ELF_TO_HEX}/arm-none-eabi-objcopy --help
	fi
fi