User forums > Embedded development
How to force CB compile sequence (generally) to mimic makefile on STM32F4
philcal:
How do you get CB, to invoke compiler on group of srcfiles and object copy, rather than individually compile each and then link.
I am trying to compile a simple STM32F4 project from a net example. The guts of the makefile is only two lines yet I cannot seem to be able to replicate this natively in CB and get linker error.
I think the different compile sequences is at the root cause.
####################################
codeblocks sequence:-
((compile individually))
arm-none-eabi-gcc .....flags..... -c firstsrcfile.c -o firstsrcfile.o
.
.
arm-none-eabi-gcc .....flags..... -c an-asm-file.s -o lastsrcfile.o
((link))
arm-none-eabi-ld list-of-source-objectfilesfrom above -s -Tstm32_flash.ld ....libraries
((resultingerror))
main.o uses VFP register arguments, cbjh does not
((note: in CB compiler toolchain executables settings arm-none-eabi-ld is not set (arm-none-eabi-objcopy is set for static linker) yet somehow CB invokes ld and its this part that is causing the grief))
##################################
makefile sequence:-
((compile combined))
arm-none-eabi-gcc .....flags..... the-list-of-c-source-objectfiles -o main.elf ....libraries
arm-none-eabi-objcopy -O binary main.elf main.bin
((successfully links))
((relevant makefile command which does this firstline is arm-none-eabi-gcc $(CFLAGS) $^ -o $@ ...libraries
($^ being a list of source files, $@ corresponding objectfile )))
How does one achieve the second method sequence in Codeblocks?
I suspect an answer might be to point to a script, but should this be necessary for a simple project? If anyone cares to answer are there any aailable general methods that one can adapt a makefile into the CB environment? As a noobie I have noted advice to avoid using the makefile approach. I cannot agree more after observing the cumbersome inpenetratable makefile code, but?
PS I started another topic on this (with 15 reads) but deleted it as I now suspect the cause of the problem was the above.
the example code I'm trying to compile is from git clone git://github.com/jeremyherbert/stm32-templates.git
http://jeremyherbert.net/get/stm32f4_getting_started
philcal:
update: "the-list-of-c-source-objectfiles" should read "the-list-of-c-source-asm" files ie a one pass compile
stahta01:
--- Quote from: philcal on April 20, 2013, 05:50:03 am ---
makefile sequence:-
((compile combined))
arm-none-eabi-gcc .....flags..... the-list-of-c-source-objectfiles -o main.elf ....libraries
arm-none-eabi-objcopy -O binary main.elf main.bin
((successfully links))
((relevant makefile command which does this firstline is arm-none-eabi-gcc $(CFLAGS) $^ -o $@ ...libraries
($^ being a list of source files, $@ corresponding objectfile )))
How does one achieve the second method sequence in Codeblocks?
--- End quote ---
Step 1: Learn how the Compiler and Linker works using the normal two step process (compile then link as the two steps)
Step 2: Write the compile step on the command line so it works
Step 3: Write the linker step on the command line so it works
Step 4: Write the objcopy step on the command line so it works
Step 5: Post the commands that work on the command line so you can ask how to do this using Code::Blocks.
My guess is the command use in Step 4 will be a post build step.
Till I or someone else sees the commands for steps 2 and 3; no one but an arm-none-eabi-gcc user can answer the question except with guesses.
The more knowledgeable they are about GCC the better the guesses will be.
Tim S.
philcal:
Thanks for your reply but I think you have missed my point. I was trying to find a general solution as indicated in the topic subject and nothing specific to the arm compiler. However you did make me see the issue more clearly.
In essence I think I have a combined compilerANDlinker rather than two separate components, Presumably the linker bit is invoked when passing more than one source file to it.
--- Quote from: stahta01 on April 20, 2013, 08:59:20 am ---
Step 1: Learn how the Compiler and Linker works using the normal two step process (compile then link as the two steps)
Step 2: Write the compile step on the command line so it works
Step 3: Write the linker step on the command line so it works
Step 4: Write the objcopy step on the command line so it works
Tim S.
--- End quote ---
Step1&2 As above I believe I have a combined program. One command line call passing it source files produces a single main.elf output. I have included the command below FWIW.
Step3 There is no explicit linker call. As an aside, trawling thru the terminal output of the above command with verbose output I did not find any reference to the stand alone arm linker arm-none-eabi-ld.
Step4 This is furphy as it is involves no linking step and my problem occurs before this.
So unless I'm wrong it seems in my CB project I need to pass a group of files to the "compiler" and not have CB process individually -and not specifically call the "linker". I now see part of my solution maybe to eliminate any linker executable in my CB toolchain list but I still need to pass a list of files.
single command line command produces a single output file: arm-none-eabi-gcc -g -v -O2 -Wall -Tstm32_flash.ld -mlittle-endian -mthumb -mcpu=cortex-m4 -mthumb-interwork -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Iinc -Ilib -Ilib/inc -Ilib/inc/core -Ilib/inc/peripherals src/system_stm32f4xx.c src/main.c src/stm32f4xx_it.c lib/startup_stm32f4xx.s -o main.elf -Llib -lstm32f4
Extract of my CB default.conf file:
<C_COMPILER>
<str>
<![CDATA[arm-none-eabi-gcc]]>
</str>
</C_COMPILER>
<CPP_COMPILER>
<str>
<![CDATA[arm-none-eabi-g++]]>
</str>
</CPP_COMPILER>
<LINKER>
<str>
<![CDATA[arm-none-eabi-gcc]]>
</str>
</LINKER>
<LIB_LINKER>
<str>
<![CDATA[arm-none-eabi-objcopy]]>
</str>
</LIB_LINKER>
<DEBUGGER_CONFIG>
<str>
<![CDATA[gdb_debugger:Default]]>
</str>
stahta01:
If you are NOT will to put forth the effort to learn how your compiler works; DO NOT expect any help from me.
If you wish to use a makefile use one; if you wish to use the normal CB build system use it.
You CAN NOT do both in the same CB project.
Tim S.
Navigation
[0] Message Index
[#] Next page
Go to full version