Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boards: Tock: Add Tock support #1390

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "src/peripherals/atecc608a-tnglora-se/cryptoauthlib"]
path = src/peripherals/atecc608a-tnglora-se/cryptoauthlib
url = https://github.com/MicrochipTech/cryptoauthlib
[submodule "src/boards/Tock/libtock-c"]
path = src/boards/Tock/libtock-c
url = https://github.com/tock/libtock-c.git
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ The [Porting Guide](https://stackforce.github.io/LoRaMac-doc/LoRaMac-doc-v4.7.0/
* SAMR34
* [SAMR34 platform documentation](doc/SAMR34-platform.md)

* Tock
* [Tock](doc/Tock.md)

## Getting Started

### Prerequisites
Expand Down
29 changes: 29 additions & 0 deletions cmake/tock.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
## License: Revised BSD License, see LICENSE.TXT file included in the project
## Authors: Alistair Francis <[email protected]>
##
## Tock target specific CMake file
##

if(NOT DEFINED LINKER_SCRIPT)
message(FATAL_ERROR "No linker script defined")
endif(NOT DEFINED LINKER_SCRIPT)
message("Linker script: ${LINKER_SCRIPT}")


#---------------------------------------------------------------------------------------
# Set compiler/linker flags
#---------------------------------------------------------------------------------------

set(STACK_SIZE 2048)
set(APP_HEAP_SIZE 1024)
set(KERNEL_HEAP_SIZE 1024)

# Object build options
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")

set(CMAKE_C_FLAGS "${OBJECT_GEN_FLAGS} -std=gnu99 " CACHE INTERNAL "C Compiler options")
set(CMAKE_CXX_FLAGS "${OBJECT_GEN_FLAGS} -std=c++11 " CACHE INTERNAL "C++ Compiler options")
set(CMAKE_ASM_FLAGS "${OBJECT_GEN_FLAGS} -x assembler-with-cpp " CACHE INTERNAL "ASM Compiler options")

# Linker flags
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")
4 changes: 4 additions & 0 deletions doc/Tock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# TockNAMote72 platform support documents

This is support for the [Tock](https://github.com/tock/tock) operating system,
allowing the library to run as a userspace application on Tock boards.
11 changes: 11 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,17 @@ elseif(BOARD STREQUAL B-L072Z-LRWAN1)

# Configure radio
set(RADIO sx1276 CACHE INTERNAL "Radio sx1276 selected")

elseif(BOARD STREQUAL Tock)
# Configure toolchain for Tock
set(LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/boards/Tock/libtock-c/userland_generic.ld)
include(tock)

# Build platform specific board implementation
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/boards/Tock)

# Configure radio
set(RADIO sx126x CACHE INTERNAL "Radio sx126x selected")
endif()

#---------------------------------------------------------------------------------------
Expand Down
8 changes: 7 additions & 1 deletion src/apps/ping-pong/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,13 @@ target_include_directories(${PROJECT_NAME} PUBLIC

set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 11)

target_link_libraries(${PROJECT_NAME} m)
# TODO: Remove this
target_link_libraries(${PROJECT_NAME}
${CMAKE_CURRENT_SOURCE_DIR}/../../boards/Tock/libtock-c/newlib/cortex-m/v7-m/libc.a
${CMAKE_CURRENT_SOURCE_DIR}/../../boards/Tock/libtock-c/newlib/cortex-m/v7-m/libm.a
${CMAKE_CURRENT_SOURCE_DIR}/../../boards/Tock/libtock-c/libtock/build/cortex-m4/libtock.a
)


#---------------------------------------------------------------------------------------
# Debugging and Binutils
Expand Down
Loading