Not sure if it's more appropriate to post here or on the nanopb github, but I've noticed to get nanopb to work I have to do:
set(CMAKE_TOOLCHAIN_FILE "/home/blaberj/stm32-cmake/cmake/stm32_gcc.cmake")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mcpu=cortex-m4 -mfloat-abi=hard") # Needed for nanopb to work
I assume this is because during:
The following object files are created:
[2/36] /usr/bin/arm-none-eabi-gcc --sysroot=/usr/arm-none-eabi -I/home/blaberj/nanopb -mcpu=cortex-m4 -mfloat-abi=hard -MD -MT CMakeFiles/nanopb.dir/home/blaberj/nanopb/pb_common.c.obj -MF CMakeFiles/nanopb.dir/home/blaberj/nanopb/pb_common.c.obj.d -o CMakeFiles/nanopb.dir/home/blaberj/nanopb/pb_common.c.obj -c /home/blaberj/nanopb/pb_common.c
[3/36] /usr/bin/arm-none-eabi-gcc --sysroot=/usr/arm-none-eabi -I/home/blaberj/nanopb -mcpu=cortex-m4 -mfloat-abi=hard -MD -MT CMakeFiles/nanopb.dir/home/blaberj/nanopb/pb_encode.c.obj -MF CMakeFiles/nanopb.dir/home/blaberj/nanopb/pb_encode.c.obj.d -o CMakeFiles/nanopb.dir/home/blaberj/nanopb/pb_encode.c.obj -c /home/blaberj/nanopb/pb_encode.c
[4/36] /usr/bin/arm-none-eabi-gcc --sysroot=/usr/arm-none-eabi -I/home/blaberj/nanopb -mcpu=cortex-m4 -mfloat-abi=hard -MD -MT CMakeFiles/nanopb.dir/home/blaberj/nanopb/pb_decode.c.obj -MF CMakeFiles/nanopb.dir/home/blaberj/nanopb/pb_decode.c.obj.d -o CMakeFiles/nanopb.dir/home/blaberj/nanopb/pb_decode.c.obj -c /home/blaberj/nanopb/pb_decode.c
[5/36] : && /home/blaberj/clion-2023.3.4/bin/cmake/linux/x64/bin/cmake -E rm -f libnanopb.a && /usr/bin/arm-none-eabi-ar qc libnanopb.a CMakeFiles/nanopb.dir/home/blaberj/nanopb/pb_decode.c.obj CMakeFiles/nanopb.dir/home/blaberj/nanopb/pb_encode.c.obj CMakeFiles/nanopb.dir/home/blaberj/nanopb/pb_common.c.obj && /usr/bin/arm-none-eabi-ranlib libnanopb.a
Without the set(CMAKE_C_FLAGS <>) those flags aren't added. In some scenarios it compiles and usb works but will hang when I try to send a protobuf. This took forever to figure out, but was wondering if stm32-cmake should handle this somehow? I've worked around tinyusb's cmake implementation, they add:
set(TOOLCHAIN_COMMON_FLAGS
-mthumb
-mcpu=cortex-m4
-mfloat-abi=hard
-mfpu=fpv4-sp-d16
)
to their toolchain file which makes this work opaquely after setting it. Wondering if that's a better approach here or not.
Not sure if it's more appropriate to post here or on the nanopb github, but I've noticed to get nanopb to work I have to do:
I assume this is because during:
The following object files are created:
Without the
set(CMAKE_C_FLAGS <>)those flags aren't added. In some scenarios it compiles and usb works but will hang when I try to send a protobuf. This took forever to figure out, but was wondering if stm32-cmake should handle this somehow? I've worked around tinyusb's cmake implementation, they add:to their toolchain file which makes this work opaquely after setting it. Wondering if that's a better approach here or not.