cancel
Showing results for 
Search instead for 
Did you mean: 

How to compile a project created with STM32CubeIDE from terminal on Linux?

PADAM.1
Associate III

After having created a project with STM32CubeIDE, I want to compile it from cmd line interface in Ubuntu.

After "cd <projectdir>/Debug", I do "make -j8 all" but get error message:

arm-none-eabi-size  <projectname>.elf

make: arm-none-eabi-size: Command not found

makefile:71: recipe for target 'default.size.stdout' failed

make: *** [default.size.stdout] Error 127

How to compile (e.g.: inside a bash script) the project? What are the tasks STM32CubeIDE executes (e.g. set path of compiler or binutils) before calling make?

5 REPLIES 5
Pavel A.
Evangelist III

I don't have CubeIDE (until to comes to version 2 at least...) but try this:

https://gnu-mcu-eclipse.github.io/advanced/headless-builds/

-- pa

toroid
Associate III

It should work after installing gcc-arm-none-eabi by apt (ubuntu 18.04) and running 'make all' in the Debug folder. I have it working like this on my PC. You can also use a command 'make all -C Debug' in the project root. The -j8 option sets how many jobs will run in parallel to speed up the compilation.

A related issue that I am having now is that I cannot use the abovementioned command anymore to compile in Docker (in gitlab CI). The docker image is an ubuntu 16.04 that has gcc-arm-none-eabi installed. This used to work.... Maybe changes between CubeIde versions broke it, not sure. I cannot install Stm32cubeIde in Docker to do what Pavel suggested.

The problem is somehow related to the makefile and objects.list that stm32cubeide generates when built by docker.

Docker shows:

$ make all -C ./Debug/

make: Entering directory '/builds/project-0/Debug'

arm-none-eabi-gcc -o "projectname.elf" @"objects.list"  -mcpu=cortex-m4 -T"../STM32F427VGTX_FLASH.ld" --specs=nosys.specs -Wl,-Map="projectname.map" -Wl,--gc-sections -static --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -Wl,--start-group -lc -lm -Wl,--end-group

Gives an error:

arm-none-eabi-gcc: error: Core/Src/adc.o: No such file or directory

.... and a lot of errors of the same type looping through the objects.list file.

To my understanding the .o files should be created during compilation, but that does not seem to happen. Probably it's something silly but cannot find it...

If I remove objects.list the compiler will stop at error not finding objects.list. With an empty objects.list file the build succeeds but with an unusable output binary.

Compiling and building inside CubeIde works fine. Also works fine when I do 'make all -C Debug' in the local PC.

Does anyone have ideas how to make this Docker stuff work? Preferably without manually modifying the makefile.

KnarfB
Principal III

If your project was generated from a .ioc file, you can open the .ioc file in the stand-alone STM32CubeMX tool and generate a generic Makefile for it (Project Manager > Toolchain Makefile + Generate Code). If not, you can generate that Makefile for a similar dummy project and re-use that, see attached example.

If you really want to re-use the Eclipe generated makefiles, you can add a post-build step to Eclipse dumping out the environment. Like "set" for Windows or "env" or thelike for Linux and copy as much from it as needed (path,...).

The headless build in Eclipse CDT is not as easy as running make - not in recent versions.

Either the makefiles do not exist (If you use "internal builder") or need to be created by the CDT "external" builder.

So no, sorry, have to get the Eclipse working (resolve those pesky java issues...)

Good news is that CubeIDE can be installed on other machine where this works and copied into a container. So failure to install is not a blocker.

-- pa

Thanks for the quick responses. Yes, it's a cubemx project. Excellent idea, I will try the makefile project option in cubemx.