So it is this. Been using keil for small projects under 32k but finally decided to do something bigger and quickly ran out of space even with -Os.
So here my goal is to use keil IDE simply as IDE / project management / debugger, and build with arm gnu toolchain as available here:
https://developer.arm.com/Tools%20and%20Software/GNU%20Toolchain
I went to project/items and checked Use GCC compiler for arm projects, confirmed the warnings, and re-entered all the define and include paths.
under CC options, I have unchecked all the stuff under code generation, added relative paths to include folders inside my project, and added some things to misc controls like --specs=nano.specs -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16
However looking at the "compiler control line", I see the following ugly mess:
-c -mcpu=cortex-m4 -mthumb -gdwarf-2 -MD -Wall -O0 -I ./lib/CMSIS -I ./lib/CMSIS/Include -I ./lib/STM32F4xx_StdPeriph_Driver/inc -I ./lib/fatfs -I ./lib/RTT -I ./lib/wiznet --specs=nosys.specs -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -IC:/KEIL/ARM/CMSIS/Include -IC:/KEIL/ARM/INC/ST/STM32F4xx -IF:/programs/arm-gnu-toolchain-13.2.Rel1-mingw-w64-i686-arm-none-eabi/arm-none-eabi/include -IF:/programs/arm-gnu-toolchain-13.2.Rel1-mingw-w64-i686-arm-none-eabi/lib/gcc/arm-none-eabi/13.2.1/include -IF:/programs/arm-gnu-toolchain-13.2.Rel1-mingw-w64-i686-arm-none-eabi/arm-none-eabi/include/c++/13.2.1 -IF:/programs/arm-gnu-toolchain-13.2.Rel1-mingw-w64-i686-arm-none-eabi/arm-none-eabi/include/c++/13.2.1/arm-none-eabi -D__UVISION_VERSION="538" -D__GCC -D__GCC_VERSION="1321" -DUSE_STDPERIPH_DRIVER -DSTM32F40_41xxx -DHSE_VALUE="8000000" -o *.o
In armcc version, there's a "no default includes" checkbox and I always check it because I don't want any files outside the project folder to affect anything I build to keep it portable.
However here, it seems to assume that I for some reason want stuff from C:\Keil and other places included with no way to force it out.
It also seems to ignore --specs because I keep getting libc link errors even tho nano/nosys shouldn't include full-sized libc...
Anyway, how do I fix this to just build? I have a normal Makefile to match this project
CFLAGS = -Wall $(OPTFLAGS) -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -ggdb -ffunction-sections -fdata-sections $(INCLUDES) $(DEFINES)LDFLAGS = -Tflash.ld -Wl,--gc-sections
with these settings and everything builds fine outside of the IDE.
1) You said "In armcc version, there's a "no default includes" checkbox"
… You are correct, the µVision IDE does not have a "no default includes" option when using the GCC compiler.
2) If you want to minimize the number of included header files to 6, you could:
a) download and install the legacy pack "Arm Cortex-M" as described in the section " Legacy Pack Download" in:
https://developer.arm.com/documentation/101407/0539/Creating-Applications/Tips-and-Tricks/Use-MDK-Version-4-Projects
b) Then, when you create a new project, instead choose "Legacy Device Database [No RTE]" as in:
developer.arm.com/.../Setup-the-Project
3) It looked like you used "--specs" instead of "-specs". Using arm-gnu-toolchain-13.2.rel1-mingw-w64-i686-arm-none-eabi from
https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads
… in µVision under Project -> Options For Target -> CC, for Misc Controls, I entered: "-specs=foo.specs"
If I don't include the specs file, I would get 3 warnings. If I do include the .specs file, I get zero warnings.
Inside my foo.specs file:
*cc1:-Wno-unknown-pragmas -DSTM32F40_41xxx