Compare commits

...

5 commits

Author SHA1 Message Date
047b48ab1b Updated lists
Updated the lists of the notes with current information.
2025-01-24 23:39:46 -08:00
b1b0e14209 Added notes
Added notes on the compiler warning flags and such.
2025-01-24 23:39:26 -08:00
aed74f5710 Added lots of comments.
Added comments about the file, specs, compile and build options.
2025-01-24 23:30:39 -08:00
0f71a0cfd0 Added questions section 2025-01-24 23:30:07 -08:00
f045204a2c removing bad line from include dirs 2025-01-24 23:30:01 -08:00
3 changed files with 38 additions and 43 deletions

View file

@ -21,6 +21,10 @@ endif()
# For being able to used LSP # For being able to used LSP
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
#"-Wall":: Enable all warnings.
#"-Werror":: Treat all warnings as errors.
#"-Wpedantic":: Issue all warnings demanded by strict ISO
# Request C 17 standard features # Request C 17 standard features
set(CMAKE_C_STANDARD 17) set(CMAKE_C_STANDARD 17)
set(CMAKE_C_STANDARD_REQUIRED True) set(CMAKE_C_STANDARD_REQUIRED True)
@ -53,7 +57,6 @@ if (UNIT_TESTING)
include_directories( include_directories(
${CPPUTEST_INCLUDE_DIRS} ${CPPUTEST_INCLUDE_DIRS}
/usr/include/c++/11/
./inc ./inc
./mocks ./mocks
) )

View file

@ -26,5 +26,10 @@ development board.
- [X] Remove Unity test framework stuff. - [X] Remove Unity test framework stuff.
- [X] Remove HAL stuff. - [X] Remove HAL stuff.
- [X] Remove doxygen stuff from toolchain file. - [X] Remove doxygen stuff from toolchain file.
- [ ] Check through debuging flags in toolchain file. - [X] Check through debuging flags in toolchain file.
## Questions
- [X] What is semi-hosting in stm32 context.
- [X] What are mthumb or thumb?
- [ ]

View file

@ -2,17 +2,23 @@
# STM32 toolchain file # STM32 toolchain file
# ############################### # ###############################
# ----------------------------------------
# File: stm32-toolchain.cmake
# Description: Cmake file for the stm32 controllers. It has two differnt
# types of kinds things it can output. It can output or build release binaries
# or it output debug builds.
# ----------------------------------------
################################################## ##################################################
# Configurable Section # Configurable Section
################################################## ##################################################
# Specify the cross-compiler # Specify the cross-compiler
set(CROSS_TOOLCHAIN arm-none-eabi-) set(CROSS_TOOLCHAIN arm-none-eabi-)
set(CMAKE_SYSTEM_NAME Generic) set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR arm) set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_CROSSCOMPILING 1) set(DEBUG_BINARY 1)
set(CMAKE_SYSTEM_VERSION 1) set(CMAKE_SYSTEM_VERSION 1)
@ -31,6 +37,8 @@ set(MCU_DIR inc/${MCU}/)
#set(MCU_SPEC cortex-m3) #set(MCU_SPEC cortex-m3)
#set(MCU_SPEC cortex-m4) #set(MCU_SPEC cortex-m4)
set(MCU_SPEC cortex-m0plus) # Might need to change? set(MCU_SPEC cortex-m0plus) # Might need to change?
set(FLOAT_SPEC "") # Use when you have no FPU.
# set(FLOAT_SPEC "-mfloat-abi=hard -mfpu=fpv4-sp-d16") # set(FLOAT_SPEC "-mfloat-abi=hard -mfpu=fpv4-sp-d16")
# The Startup(ASM) files # The Startup(ASM) files
@ -120,7 +128,7 @@ set(CMAKE_CXX_FLAGS_RELEASE "-Os -flto " CACHE INTERNAL "C++ Compiler options fo
set(CMAKE_ASM_FLAGS_RELEASE "" CACHE INTERNAL "ASM Compiler options for release build type") set(CMAKE_ASM_FLAGS_RELEASE "" CACHE INTERNAL "ASM Compiler options for release build type")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-flto " CACHE INTERNAL "Linker options for release build type") set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-flto " CACHE INTERNAL "Linker options for release build type")
if(CMAKE_CROSSCOMPILING STREQUAL "1") if(DEBUG_BINARY STREQUAL "1") # -- START: Debug Binary
# Control specific options if crosscompiling # Control specific options if crosscompiling
message(STATUS "[INFO] Cross compiling for ${MCU}") message(STATUS "[INFO] Cross compiling for ${MCU}")
@ -135,6 +143,12 @@ if(CMAKE_CROSSCOMPILING STREQUAL "1")
#------------------- #-------------------
# General Flags for cross # General Flags for cross
#------------------- #-------------------
# "thumb":: Compressed instructions, 16bits. Using only ARM is an option
# as well.
# "-mcpu":: The selected and in use CPU.
# "-mthumb":: Enable the thumb(16bit) instructions.
# "-mthumb-interwork":: Support calling between ARM and Thumb instructions
# "-mabi":: Generate code for the given application binary interface.
string(APPEND OBJECT_GEN_FLAGS " \ string(APPEND OBJECT_GEN_FLAGS " \
-mcpu=${MCU_SPEC} \ -mcpu=${MCU_SPEC} \
-mthumb \ -mthumb \
@ -142,6 +156,8 @@ if(CMAKE_CROSSCOMPILING STREQUAL "1")
-mabi=aapcs \ -mabi=aapcs \
${FLOAT_SPEC} \ ${FLOAT_SPEC} \
") ")
# "aapcs":: Procedure Call Standard for Arm Architecture
#------------------- #-------------------
# CFLAGS for cross # CFLAGS for cross
@ -178,49 +194,20 @@ if(CMAKE_CROSSCOMPILING STREQUAL "1")
message(FATAL_ERROR "[ERRR] Could not find linker script ${LINKER_SCRIPT}") message(FATAL_ERROR "[ERRR] Could not find linker script ${LINKER_SCRIPT}")
endif() endif()
# semihosting:: is a mechanism that enables code running on an ARM target
# to communicate and use the Input/Output facilities on a host computer
# that is running a debugger.
if("${SEMIHOSTING}" STREQUAL "1") if("${SEMIHOSTING}" STREQUAL "1")
#"rdimon":: remote dispatch interface monitor
string(APPEND CMAKE_EXE_LINKER_FLAGS "--specs=rdimon.specs -lc -lrdimon ") string(APPEND CMAKE_EXE_LINKER_FLAGS "--specs=rdimon.specs -lc -lrdimon ")
else() else()
#"nosys":: systems call are stubbed out.
string(APPEND CMAKE_EXE_LINKER_FLAGS "--specs=nosys.specs ") string(APPEND CMAKE_EXE_LINKER_FLAGS "--specs=nosys.specs ")
endif() endif()
else() else()
# Flags and options to set while compiling natively # Actual build which will go onto the board
message(STATUS "[INFO] Compiling natively") # AKA production build.
#-------------------
# General Flags for native
#-------------------
string(APPEND OBJECT_GEN_FLAGS " \
--coverage \
")
#-------------------
# CFLAGS for native
#-------------------
string(APPEND CMAKE_C_FLAGS " \
${OBJECT_GEN_FLAGS} \
")
#-------------------
# ASMFLAGS for native
#-------------------
string(APPEND CMAKE_ASM_FLAGS " \
${OBJECT_GEN_FLAGS} \
")
#-------------------
# LFLAGS for native
#-------------------
string(APPEND CMAKE_EXE_LINKER_FLAGS " \
${OBJECT_GEN_FLAGS} \
")
endif()
# Actual build which will go onto the board
if(TARGET_GROUP STREQUAL production)
###################################################################### ######################################################################
# @Target: ${PROJECT_NAME}.elf # @Target: ${PROJECT_NAME}.elf
@ -281,7 +268,7 @@ if(TARGET_GROUP STREQUAL production)
) )
else() else()
message(FATAL_ERROR "Given TARGET_GROUP unknown") message(FATAL_ERROR "Given TARGET_GROUP unknown")
endif() endif() # -- END: DEBUG/RELEASE Binary
# Unset all cache # Unset all cache
unset(SEMIHOSTING) unset(SEMIHOSTING)