- Fully open toolchain: arm-none-eabi-gcc inside Podman/Docker container - Platform-agnostic build via justfile (auto-detects podman vs docker) - CMake + Ninja build system with arm-none-eabi toolchain file - nRF52840 linker script and startup with full 64-entry vector table - Register access via typed bitfield unions (include/regs.h) - FHSS channel sequencer: AES-128-ECB PRNG over 40 channels (2402-2480 MHz) - Low-power sleep via SYSTEM_ON WFI + GPIOTE wakeup on button press - Vendor deps as shallow git submodules: nrfx, CMSIS_5, tiny-AES-c
72 lines
1.5 KiB
CMake
72 lines
1.5 KiB
CMake
cmake_minimum_required(VERSION 3.22)
|
|
|
|
# must be set before project()
|
|
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/cmake/arm-none-eabi.cmake")
|
|
|
|
project(ptt_fhss C ASM)
|
|
|
|
set(CMAKE_C_STANDARD 11)
|
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
|
|
|
# sources
|
|
add_executable(firmware
|
|
src/startup.c
|
|
src/main.c
|
|
src/radio.c
|
|
src/fhss.c
|
|
src/power.c
|
|
vendor/tiny-aes-c/aes.c
|
|
)
|
|
|
|
# include paths
|
|
target_include_directories(firmware PRIVATE
|
|
include
|
|
vendor/nrfx/mdk # nRF52840 device headers (nrf52840.h etc.)
|
|
vendor/CMSIS_5/CMSIS/Core/Include # core_cm4.h, cmsis_gcc.h etc.
|
|
vendor/tiny-aes-c
|
|
)
|
|
|
|
# preprocessor defines
|
|
target_compile_definitions(firmware PRIVATE
|
|
NRF52840_XXAA # device variant required by nrfx/mdk headers
|
|
)
|
|
|
|
# compiler flags
|
|
set(CPU_FLAGS
|
|
-mcpu=cortex-m4
|
|
-mthumb
|
|
-mfpu=fpv4-sp-d16
|
|
-mfloat-abi=hard
|
|
)
|
|
|
|
target_compile_options(firmware PRIVATE
|
|
${CPU_FLAGS}
|
|
-Os
|
|
-ffunction-sections
|
|
-fdata-sections
|
|
-fno-exceptions
|
|
-Wall
|
|
-Wextra
|
|
-Werror
|
|
)
|
|
|
|
# linker
|
|
target_link_options(firmware PRIVATE
|
|
${CPU_FLAGS}
|
|
-T ${CMAKE_SOURCE_DIR}/link/nrf52840.ld
|
|
-Wl,--gc-sections
|
|
-Wl,--print-memory-usage
|
|
-nostartfiles
|
|
-specs=nano.specs
|
|
-specs=nosys.specs
|
|
)
|
|
|
|
# post-build: .hex + size report
|
|
add_custom_command(TARGET firmware POST_BUILD
|
|
COMMAND arm-none-eabi-objcopy
|
|
-O ihex $<TARGET_FILE:firmware>
|
|
${CMAKE_BINARY_DIR}/firmware.hex
|
|
COMMAND arm-none-eabi-size $<TARGET_FILE:firmware>
|
|
VERBATIM
|
|
)
|