we are currently making a shift from another rtos to chibios. As such, we already have a solid C++ based Peripheral Library (STM32PLUS) working on almost all the devices and would like to be able to integrate Chibios/RT (kernel only). Following the RT integration guide all the kernel and port layer related files have been included. The build system of choice is Cmake. I've looked at the .mk files in the demo folder for STM32F429I-discovery and AFAIK all the necessary dependencies have been added. Chibios provided startup scripts are being used. Everything compiles well, but the linker arm-none-eabi-ld (7.2) throws an undefined reference error for "_port_switch" and "_port_thread_start" macro functions.
These are define
following is the output of cmake just to ensure that i have included all the necessary source files for a vanilla build i have added some messages to the cmake files:
Code: Select all
~/seven_hwdrivers/build$ cmake ..
-- Processing Top-Level CMakeLists.txt
-- Release Build
-- found Toolchain file: /home/talha/seven_hwdrivers/src/stm32-cmake/cmake/ToolChain-arm-none-eabi.cmake
-- Chibios Root not defined, using default /home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0
-- Found the project configuration directory: /home/talha/seven_hwdrivers/src/stm32_uavcan/conf
-- chconf.h found:/home/talha/seven_hwdrivers/src/stm32_uavcan/conf/chconf.h
-- RTOS Sources:
-- os/common/startup/ARMCMx/compilers/GCC/crt1.c
-- os/common/startup/ARMCMx/compilers/GCC/vectors.c
-- os/common/startup/ARMCMx/compilers/GCC/crt0_v7m.S
-- os/common/ports/ARMCMx/chcore.c
-- os/common/ports/ARMCMx/chcore_v7m.c
-- os/common/ports/ARMCMx/compilers/GCC/chcoreasm_v7m.S
-- os/rt/src/chsys.c
-- os/rt/src/chdebug.c
-- os/rt/src/chtrace.c
-- os/rt/src/chvt.c
-- os/rt/src/chschd.c
-- os/rt/src/chthreads.c
-- os/rt/src/chtm.c
-- os/rt/src/chregistry.c
-- os/rt/src/chsem.c
-- os/rt/src/chmtx.c
-- os/rt/src/chcond.c
-- os/rt/src/chevents.c
-- os/rt/src/chmsg.c
-- os/rt/src/chdynamic.c
-- os/rt/src/chstats.c
-- os/various/cpp_wrappers/ch.cpp
-- Found Chibios Sources: /home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/common/startup/ARMCMx/compilers/GCC/crt1.c
-- Found Chibios Sources: /home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/common/startup/ARMCMx/compilers/GCC/vectors.c
-- Found Chibios Sources: /home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/common/startup/ARMCMx/compilers/GCC/crt0_v7m.S
-- Found Chibios Sources: /home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/common/ports/ARMCMx/chcore.c
-- Found Chibios Sources: /home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/common/ports/ARMCMx/chcore_v7m.c
-- Found Chibios Sources: /home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/common/ports/ARMCMx/compilers/GCC/chcoreasm_v7m.S
-- Found Chibios Sources: /home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/rt/src/chsys.c
-- Found Chibios Sources: /home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/rt/src/chdebug.c
-- Found Chibios Sources: /home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/rt/src/chtrace.c
-- Found Chibios Sources: /home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/rt/src/chvt.c
-- Found Chibios Sources: /home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/rt/src/chschd.c
-- Found Chibios Sources: /home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/rt/src/chthreads.c
-- Found Chibios Sources: /home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/rt/src/chtm.c
-- Found Chibios Sources: /home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/rt/src/chregistry.c
-- Found Chibios Sources: /home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/rt/src/chsem.c
-- Found Chibios Sources: /home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/rt/src/chmtx.c
-- Found Chibios Sources: /home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/rt/src/chcond.c
-- Found Chibios Sources: /home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/rt/src/chevents.c
-- Found Chibios Sources: /home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/rt/src/chmsg.c
-- Found Chibios Sources: /home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/rt/src/chdynamic.c
-- Found Chibios Sources: /home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/rt/src/chstats.c
-- Found Chibios Sources: /home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/various/cpp_wrappers/ch.cpp
-- including: /home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/license
-- including: /home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/common/startup/ARMCMx/compilers/GCC
-- including: /home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/common/startup/ARMCMx/devices/STM32F4xx
-- including: /home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/common/ext/CMSIS/include
-- including: /home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/rt/include
-- including: /home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/various/cpp_wrappers
-- including: /home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/common/startup/ARMCMx/devices/STM32F4xx
-- including: /home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/common/oslib/include
-- including: /home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/common/ports/ARMCMx
-- including: /home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/common/ports/ARMCMx/compilers/GCC
-- Found Chibios: /home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/license;/home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/common/startup/ARMCMx/compilers/GCC;/home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/common/startup/ARMCMx/devices/STM32F4xx;/home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/common/ext/CMSIS/include;/home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/rt/include;/home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/various/cpp_wrappers;/home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/common/startup/ARMCMx/devices/STM32F4xx;/home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/common/oslib/include;/home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/common/ports/ARMCMx;/home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/common/ports/ARMCMx/compilers/GCC
-- UAVCAN_STM32_NUM_IFACES not set. Please specify using
uavcan_config_num_ifaces. Setting Default to 2
-- Using stm32plus install: /usr/local/arm-none-eabi
-- Using stm32plus prefix: stm32plus-040100
-- Configuring done
-- Generating done
-- Build files have been written to: /home/talha/seven_hwdrivers/build
I am not using the Chibios provided stm32f429xx.h header since the peripheral library being used has some variations to the standard data types. Hope that would not be an issue.
Following is the linker error:
Code: Select all
Scanning dependencies of target stm32test
[ 4%] Building CXX object src/stm32_uavcan/CMakeFiles/stm32test.dir/src/AX2550.cpp.obj
[ 8%] Building CXX object src/stm32_uavcan/CMakeFiles/stm32test.dir/src/main.cpp.obj
[ 12%] Building CXX object src/stm32_uavcan/CMakeFiles/stm32test.dir/src/LibraryHacks.cpp.obj
[ 16%] Building C object src/stm32_uavcan/CMakeFiles/stm32test.dir/src/ringbuf.c.obj
[ 20%] Building C object src/stm32_uavcan/CMakeFiles/stm32test.dir/__/__/thirdparty/ChibiOS_17.6.0/os/common/startup/ARMCMx/compilers/GCC/crt1.c.obj
[ 24%] Building C object src/stm32_uavcan/CMakeFiles/stm32test.dir/__/__/thirdparty/ChibiOS_17.6.0/os/common/startup/ARMCMx/compilers/GCC/vectors.c.obj
[ 28%] Building C object src/stm32_uavcan/CMakeFiles/stm32test.dir/__/__/thirdparty/ChibiOS_17.6.0/os/common/ports/ARMCMx/chcore.c.obj
[ 32%] Building C object src/stm32_uavcan/CMakeFiles/stm32test.dir/__/__/thirdparty/ChibiOS_17.6.0/os/common/ports/ARMCMx/chcore_v7m.c.obj
[ 36%] Building C object src/stm32_uavcan/CMakeFiles/stm32test.dir/__/__/thirdparty/ChibiOS_17.6.0/os/rt/src/chsys.c.obj
[ 40%] Building C object src/stm32_uavcan/CMakeFiles/stm32test.dir/__/__/thirdparty/ChibiOS_17.6.0/os/rt/src/chdebug.c.obj
[ 44%] Building C object src/stm32_uavcan/CMakeFiles/stm32test.dir/__/__/thirdparty/ChibiOS_17.6.0/os/rt/src/chtrace.c.obj
[ 48%] Building C object src/stm32_uavcan/CMakeFiles/stm32test.dir/__/__/thirdparty/ChibiOS_17.6.0/os/rt/src/chvt.c.obj
[ 52%] Building C object src/stm32_uavcan/CMakeFiles/stm32test.dir/__/__/thirdparty/ChibiOS_17.6.0/os/rt/src/chschd.c.obj
[ 56%] Building C object src/stm32_uavcan/CMakeFiles/stm32test.dir/__/__/thirdparty/ChibiOS_17.6.0/os/rt/src/chthreads.c.obj
[ 60%] Building C object src/stm32_uavcan/CMakeFiles/stm32test.dir/__/__/thirdparty/ChibiOS_17.6.0/os/rt/src/chtm.c.obj
[ 64%] Building C object src/stm32_uavcan/CMakeFiles/stm32test.dir/__/__/thirdparty/ChibiOS_17.6.0/os/rt/src/chregistry.c.obj
[ 68%] Building C object src/stm32_uavcan/CMakeFiles/stm32test.dir/__/__/thirdparty/ChibiOS_17.6.0/os/rt/src/chsem.c.obj
[ 72%] Building C object src/stm32_uavcan/CMakeFiles/stm32test.dir/__/__/thirdparty/ChibiOS_17.6.0/os/rt/src/chmtx.c.obj
[ 76%] Building C object src/stm32_uavcan/CMakeFiles/stm32test.dir/__/__/thirdparty/ChibiOS_17.6.0/os/rt/src/chcond.c.obj
[ 80%] Building C object src/stm32_uavcan/CMakeFiles/stm32test.dir/__/__/thirdparty/ChibiOS_17.6.0/os/rt/src/chevents.c.obj
[ 84%] Building C object src/stm32_uavcan/CMakeFiles/stm32test.dir/__/__/thirdparty/ChibiOS_17.6.0/os/rt/src/chmsg.c.obj
[ 88%] Building C object src/stm32_uavcan/CMakeFiles/stm32test.dir/__/__/thirdparty/ChibiOS_17.6.0/os/rt/src/chdynamic.c.obj
[ 92%] Building C object src/stm32_uavcan/CMakeFiles/stm32test.dir/__/__/thirdparty/ChibiOS_17.6.0/os/rt/src/chstats.c.obj
[ 96%] Building CXX object src/stm32_uavcan/CMakeFiles/stm32test.dir/__/__/thirdparty/ChibiOS_17.6.0/os/various/cpp_wrappers/ch.cpp.obj
[100%] Linking CXX executable stm32test
CMakeFiles/stm32test.dir/__/__/thirdparty/ChibiOS_17.6.0/os/rt/src/chschd.c.obj: In function `chSchGoSleepS':
/home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/rt/src/chschd.c:313: undefined reference to `_port_switch'
CMakeFiles/stm32test.dir/__/__/thirdparty/ChibiOS_17.6.0/os/rt/src/chschd.c.obj: In function `chSchWakeupS':
/home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/rt/src/chschd.c:444: undefined reference to `_port_switch'
CMakeFiles/stm32test.dir/__/__/thirdparty/ChibiOS_17.6.0/os/rt/src/chschd.c.obj: In function `chSchDoRescheduleAhead':
/home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/rt/src/chschd.c:553: undefined reference to `_port_switch'
CMakeFiles/stm32test.dir/__/__/thirdparty/ChibiOS_17.6.0/os/rt/src/chthreads.c.obj: In function `chThdCreateStatic':
/home/talha/seven_hwdrivers/thirdparty/ChibiOS_17.6.0/os/rt/src/chthreads.c:366: undefined reference to `_port_thread_start'
collect2: error: ld returned 1 exit status
src/stm32_uavcan/CMakeFiles/stm32test.dir/build.make:693: recipe for target 'src/stm32_uavcan/stm32test' failed
make[2]: *** [src/stm32_uavcan/stm32test] Error 1
CMakeFiles/Makefile2:103: recipe for target 'src/stm32_uavcan/CMakeFiles/stm32test.dir/all' failed
make[1]: *** [src/stm32_uavcan/CMakeFiles/stm32test.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
I dont know how to solve this problem. Any advice would be greatly appreciated. Regards