Skip to content

Commit f044aed

Browse files
committed
boards: Tock: Initial commit of Tock support
Signed-off-by: Alistair Francis <alistair@alistair23.me>
1 parent 2bf36bd commit f044aed

File tree

17 files changed

+1416
-1
lines changed

17 files changed

+1416
-1
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
[submodule "src/peripherals/atecc608a-tnglora-se/cryptoauthlib"]
55
path = src/peripherals/atecc608a-tnglora-se/cryptoauthlib
66
url = https://github.com/MicrochipTech/cryptoauthlib
7+
[submodule "src/boards/Tock/libtock-c"]
8+
path = src/boards/Tock/libtock-c
9+
url = https://github.com/tock/libtock-c.git

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ The [Porting Guide](https://stackforce.github.io/LoRaMac-doc/LoRaMac-doc-v4.7.0/
6262
* SAMR34
6363
* [SAMR34 platform documentation](doc/SAMR34-platform.md)
6464

65+
* Tock
66+
* [Tock](doc/Tock.md)
67+
6568
## Getting Started
6669

6770
### Prerequisites

cmake/tock.cmake

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
## License: Revised BSD License, see LICENSE.TXT file included in the project
2+
## Authors: Alistair Francis <alistair@alistair23.me>
3+
##
4+
## Tock target specific CMake file
5+
##
6+
7+
if(NOT DEFINED LINKER_SCRIPT)
8+
message(FATAL_ERROR "No linker script defined")
9+
endif(NOT DEFINED LINKER_SCRIPT)
10+
message("Linker script: ${LINKER_SCRIPT}")
11+
12+
13+
#---------------------------------------------------------------------------------------
14+
# Set compiler/linker flags
15+
#---------------------------------------------------------------------------------------
16+
17+
set(STACK_SIZE 2048)
18+
set(APP_HEAP_SIZE 1024)
19+
set(KERNEL_HEAP_SIZE 1024)
20+
21+
# Object build options
22+
set(OBJECT_GEN_FLAGS "-mthumb -g2 -fno-builtin -mcpu=cortex-m4 -Wall -Wextra -pedantic -Wno-unused-parameter -ffunction-sections -fdata-sections -fomit-frame-pointer -mabi=aapcs -fno-unroll-loops -ffast-math -ftree-vectorize -frecord-gcc-switches -gdwarf-2 -Os -fdata-sections -ffunction-sections -fstack-usage -Wl,--emit-relocs -fPIC -mthumb -mfloat-abi=soft -msingle-pic-base -mpic-register=r9 -mno-pic-data-is-text-relative -D__TOCK__ -DSVCALL_AS_NORMAL_FUNCTION -DSOFTDEVICE_s130")
23+
24+
set(CMAKE_C_FLAGS "${OBJECT_GEN_FLAGS} -std=gnu99 " CACHE INTERNAL "C Compiler options")
25+
set(CMAKE_CXX_FLAGS "${OBJECT_GEN_FLAGS} -std=c++11 " CACHE INTERNAL "C++ Compiler options")
26+
set(CMAKE_ASM_FLAGS "${OBJECT_GEN_FLAGS} -x assembler-with-cpp " CACHE INTERNAL "ASM Compiler options")
27+
28+
# Linker flags
29+
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--gc-sections --specs=nano.specs --specs=nosys.specs -mthumb -g2 -mcpu=cortex-m4 -mabi=aapcs -T${LINKER_SCRIPT} -Wl,-Map=${CMAKE_PROJECT_NAME}.map -Xlinker --defsym=STACK_SIZE=${STACK_SIZE} -Xlinker --defsym=APP_HEAP_SIZE=${APP_HEAP_SIZE} -Xlinker --defsym=KERNEL_HEAP_SIZE=${KERNEL_HEAP_SIZE} -nostdlib -Wl,--start-group" CACHE INTERNAL "Linker options")

doc/Tock.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# TockNAMote72 platform support documents
2+
3+
This is support for the [Tock](https://github.com/tock/tock) operating system,
4+
allowing the library to run as a userspace application on Tock boards.

src/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,17 @@ elseif(BOARD STREQUAL B-L072Z-LRWAN1)
183183

184184
# Configure radio
185185
set(RADIO sx1276 CACHE INTERNAL "Radio sx1276 selected")
186+
187+
elseif(BOARD STREQUAL Tock)
188+
# Configure toolchain for Tock
189+
set(LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/boards/Tock/libtock-c/userland_generic.ld)
190+
include(tock)
191+
192+
# Build platform specific board implementation
193+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/boards/Tock)
194+
195+
# Configure radio
196+
set(RADIO sx126x CACHE INTERNAL "Radio sx126x selected")
186197
endif()
187198

188199
#---------------------------------------------------------------------------------------

src/apps/ping-pong/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,13 @@ target_include_directories(${PROJECT_NAME} PUBLIC
8383

8484
set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 11)
8585

86-
target_link_libraries(${PROJECT_NAME} m)
86+
# TODO: Remove this
87+
target_link_libraries(${PROJECT_NAME}
88+
${CMAKE_CURRENT_SOURCE_DIR}/../../boards/Tock/libtock-c/newlib/cortex-m/v7-m/libc.a
89+
${CMAKE_CURRENT_SOURCE_DIR}/../../boards/Tock/libtock-c/newlib/cortex-m/v7-m/libm.a
90+
${CMAKE_CURRENT_SOURCE_DIR}/../../boards/Tock/libtock-c/libtock/build/cortex-m4/libtock.a
91+
)
92+
8793

8894
#---------------------------------------------------------------------------------------
8995
# Debugging and Binutils

0 commit comments

Comments
 (0)