Files
bacnet_stack/ports/at91sam7s/CMakeLists.txt
T
Steve Karg 770be70688 Chore/bacnet-sc-unrelated-cleanup (#620)
* Added required linux Ethernet library for ethernet build

* Added .obj to gitignore

* Fixed BACnet port for APPLE to use BSD in CMake

* Changed format in CMake to enable cleaner SC merge

* Added create-object and delete-object recipes in GCC Makefile

* Added datalink timer to all example OS apps

* Changed most microcontroller ports to use BACAPP_MINIMAL to specify which datatypes can be written.

* Fixed zephyr OS for BACnet/IP warning

* Fixed zephyr OS log to not require log_strdup

* Added writefile API to file object example

* Added API to device-client to make it more robust.

* Added API in network-port object for getting the ASCII object-name

* Added debug print with a timestamp option

* Added debug print with hex dump print

* Added API to network port object for activate and discard

* Added default define for debug with timestamp

* Added prototype in header for disabled debug printf.

* Added fifo peek ahead function to peek at more than one byte.

* Added get-mac value for network port that uses buffer rather than octetstring
2024-04-19 12:54:56 -05:00

232 lines
6.8 KiB
CMake

# This is a CMake example for AT91SAM7S-EK development board
# using the ARM GCC compiler
#
# MCU AT91SAM7S64
# CPU ARM7
# Clock 180MHz
# RAM 16K
# Flash 64K
#
# To build this project you need to install:
# - ARM GCC compiler
# - CMake
#
# To build this project you need to run:
# - cmake -S . -B build
# - cmake --build build
#
# To flash this project you need to run:
# - st-flash write build/bacnet-mstp.hex 0x8000000
#
# To debug this project you need to run:
# - arm-none-eabi-gdb -q build/bacnet-mstp.elf
# - (gdb) target extended-remote localhost:3333
# - (gdb) monitor reset halt
# - (gdb) load
# - (gdb) monitor reset halt
# - (gdb) monitor reset init
# - (gdb) monitor reset run
# - (gdb) monitor reset exit
# - (gdb) quit
#
# You can also use VSCode with Cortex-Debug extension
#
# This example was tested with:
# - ARM GCC 10.3.1
# - CMake 3.22.1
# - BACnet Stack V1.3.2
#
cmake_minimum_required(VERSION 3.20)
# Cross compilers and tools
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
set(CMAKE_CXX_COMPILER arm-none-eabi-g++)
set(CMAKE_ASM_COMPILER arm-none-eabi-gcc)
set(CMAKE_AR arm-none-eabi-ar)
set(CMAKE_OBJCOPY arm-none-eabi-objcopy)
set(CMAKE_OBJDUMP arm-none-eabi-objdump)
set(SIZE arm-none-eabi-size)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
project(bacnet-mstp)
enable_language(C ASM)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS ON)
# Specific ARM microcontroller compiler and linker settings
add_compile_options(-mcpu=arm7tdmi)
add_compile_options(-mno-thumb-interwork)
add_link_options(-mcpu=arm7tdmi)
add_link_options(-mno-thumb-interwork)
# Code size reduction using garbage collection sections
add_compile_options(-ffunction-sections -fdata-sections)
add_compile_options(-fno-common -fmessage-length=0)
add_link_options(-Wl,-gc-sections,--print-memory-usage)
# Build types
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
message(STATUS "Maximum optimization for speed")
add_compile_options(-Ofast)
elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
message(STATUS "Maximum optimization for speed, debug info included")
add_compile_options(-Ofast -g)
elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "MinSizeRel")
message(STATUS "Maximum optimization for size")
add_compile_options(-Os)
else ()
message(STATUS "Minimal optimization, debug info included")
add_compile_definitions(DEBUG)
add_compile_options(-Og -g3)
endif ()
# eliminate the deprecated function warnings
option(BACNET_STACK_DEPRECATED_DISABLE "Disable deprecation compile warnings" ON)
if(BACNET_STACK_DEPRECATED_DISABLE)
add_definitions(-DBACNET_STACK_DEPRECATED_DISABLE)
endif()
set(LIBRARY_BACNET_INC "../../src")
set(LIBRARY_BACNET_CORE "../../src/bacnet")
set(LIBRARY_BACNET_BASIC "../../src/bacnet/basic")
set(BACNET_PROJECT_SOURCE
${CMAKE_SOURCE_DIR}/crt.s
${CMAKE_SOURCE_DIR}/at91sam7s256.h
${CMAKE_SOURCE_DIR}/board.h
# CPU interfaces
${CMAKE_SOURCE_DIR}/main.c
${CMAKE_SOURCE_DIR}/init.c
${CMAKE_SOURCE_DIR}/isr.c
${CMAKE_SOURCE_DIR}/blinker.c
${CMAKE_SOURCE_DIR}/rs485.c
${CMAKE_SOURCE_DIR}/timer.c
# MSTP datalink
${CMAKE_SOURCE_DIR}/dlmstp.c
# BACnet objects
${CMAKE_SOURCE_DIR}/device.c
${CMAKE_SOURCE_DIR}/netport.c
${CMAKE_SOURCE_DIR}/ai.c
${CMAKE_SOURCE_DIR}/av.c
${CMAKE_SOURCE_DIR}/bi.c
${CMAKE_SOURCE_DIR}/bv.c
# BACnet basic services
${LIBRARY_BACNET_BASIC}/service/h_dcc.c
${LIBRARY_BACNET_BASIC}/service/h_apdu.c
${LIBRARY_BACNET_BASIC}/npdu/h_npdu.c
${LIBRARY_BACNET_BASIC}/service/h_rd.c
${LIBRARY_BACNET_BASIC}/service/h_rp.c
${LIBRARY_BACNET_BASIC}/service/h_rpm.c
${LIBRARY_BACNET_BASIC}/service/h_whohas.c
${LIBRARY_BACNET_BASIC}/service/h_whois.c
${LIBRARY_BACNET_BASIC}/service/h_wp.c
${LIBRARY_BACNET_BASIC}/service/h_noserv.c
${LIBRARY_BACNET_BASIC}/service/s_iam.c
${LIBRARY_BACNET_BASIC}/service/s_ihave.c
${LIBRARY_BACNET_BASIC}/tsm/tsm.c
# BACnet basic system modules
${LIBRARY_BACNET_BASIC}/sys/debug.c
${LIBRARY_BACNET_BASIC}/sys/ringbuf.c
${LIBRARY_BACNET_BASIC}/sys/fifo.c
${LIBRARY_BACNET_BASIC}/sys/mstimer.c
# BACnet core modules
${LIBRARY_BACNET_CORE}/abort.c
${LIBRARY_BACNET_CORE}/bacaddr.c
${LIBRARY_BACNET_CORE}/bacapp.c
${LIBRARY_BACNET_CORE}/bacdcode.c
${LIBRARY_BACNET_CORE}/bacdest.c
${LIBRARY_BACNET_CORE}/bacdevobjpropref.c
${LIBRARY_BACNET_CORE}/bacerror.c
${LIBRARY_BACNET_CORE}/bacint.c
${LIBRARY_BACNET_CORE}/bacreal.c
${LIBRARY_BACNET_CORE}/bacstr.c
${LIBRARY_BACNET_CORE}/datalink/cobs.c
${LIBRARY_BACNET_CORE}/datalink/crc.c
# ${LIBRARY_BACNET_CORE}/datalink/dlmstp.c
# ${LIBRARY_BACNET_CORE}/datalink/mstp.c
${LIBRARY_BACNET_CORE}/datalink/mstptext.c
${LIBRARY_BACNET_CORE}/datetime.c
${LIBRARY_BACNET_CORE}/dcc.c
${LIBRARY_BACNET_CORE}/indtext.c
${LIBRARY_BACNET_CORE}/iam.c
${LIBRARY_BACNET_CORE}/ihave.c
${LIBRARY_BACNET_CORE}/hostnport.c
${LIBRARY_BACNET_CORE}/lighting.c
${LIBRARY_BACNET_CORE}/memcopy.c
${LIBRARY_BACNET_CORE}/npdu.c
${LIBRARY_BACNET_CORE}/proplist.c
${LIBRARY_BACNET_CORE}/rd.c
${LIBRARY_BACNET_CORE}/reject.c
${LIBRARY_BACNET_CORE}/rp.c
${LIBRARY_BACNET_CORE}/rpm.c
${LIBRARY_BACNET_CORE}/timestamp.c
${LIBRARY_BACNET_CORE}/weeklyschedule.c
${LIBRARY_BACNET_CORE}/dailyschedule.c
${LIBRARY_BACNET_CORE}/calendar_entry.c
${LIBRARY_BACNET_CORE}/special_event.c
${LIBRARY_BACNET_CORE}/bactimevalue.c
${LIBRARY_BACNET_CORE}/whohas.c
${LIBRARY_BACNET_CORE}/whois.c
${LIBRARY_BACNET_CORE}/wp.c
)
set(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/at91sam7s256.ld)
set(EXECUTABLE ${PROJECT_NAME}.elf)
add_executable(${EXECUTABLE} ${BACNET_PROJECT_SOURCE})
target_compile_definitions(${EXECUTABLE} PRIVATE
-DNDEBUG
-DUSE_STDPERIPH_DRIVER
-DSTM32F4XX
-DBACDL_MSTP
-DMAX_APDU=480
-DBIG_ENDIAN=0
-DPRINT_ENABLED=0
-DMAX_TSM_TRANSACTIONS=0
-DCRC_USE_TABLE
-DBACAPP_MINIMAL
)
# inhibit pedantic warnings
target_compile_options(${EXECUTABLE} PRIVATE
-Wall
-Wno-comment
-Wno-missing-braces
-Wno-unused-variable
-Wno-char-subscripts
)
target_include_directories(${EXECUTABLE} PRIVATE
${CMAKE_SOURCE_DIR}
${LIBRARY_CMSIS_INC}
${LIBRARY_CMSIS_GCC_INC}
${LIBRARY_STM32_INC}
${LIBRARY_BACNET_INC}
)
target_link_options(${EXECUTABLE} PRIVATE
-T${LINKER_SCRIPT}
-specs=nano.specs
-lm
-lnosys
-Wl,-Map=${PROJECT_NAME}.map,--cref
-Wl,--gc-sections
)
# Print executable size
add_custom_command(TARGET ${EXECUTABLE}
POST_BUILD
COMMAND arm-none-eabi-size ${EXECUTABLE}
)
# Create hex file
add_custom_command(TARGET ${EXECUTABLE}
POST_BUILD
COMMAND arm-none-eabi-objcopy -O ihex ${EXECUTABLE} ${PROJECT_NAME}.hex
COMMAND arm-none-eabi-objcopy -O binary ${EXECUTABLE} ${PROJECT_NAME}.bin
)