Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
jonlamb-gh committed Feb 13, 2024
1 parent cf34b05 commit bd757f9
Show file tree
Hide file tree
Showing 51 changed files with 4,103 additions and 0 deletions.
116 changes: 116 additions & 0 deletions .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: Integration Tests
#on: [workflow_dispatch]
on: [push]

env:
MODALITY_URL: "http://localhost:14181/v1"
MODALITY_WORKSPACE: "ci-tests"
RENODE_CI_MODE: YES

jobs:
demo:
name: Run, collect, and test
timeout-minutes: 30
runs-on: ubuntu-22.04
steps:
- name: Print Environment
run: |
echo "GITHUB_WORKFLOW=$GITHUB_WORKFLOW"
echo "GITHUB_RUN_ID=$GITHUB_RUN_ID"
echo "GITHUB_RUN_NUMBER=$GITHUB_RUN_NUMBER"
echo "GITHUB_JOB=$GITHUB_JOB"
echo "GITHUB_ACTION=$GITHUB_ACTION"
echo "GITHUB_ACTOR=$GITHUB_ACTOR"
echo "GITHUB_REF=$GITHUB_REF"
echo "GITHUB_SHA=$GITHUB_SHA"
docker --version
- name: Checkout Sources
uses: actions/checkout@v4

- name: Install system packages
run: |
sudo apt-get update
sudo apt-get install -y libusb-1.0-0-dev libftdi1-dev libudev-dev bridge-utils gcc-arm-none-eabi binutils-arm-none-eabi
- name: Install renode (latest)
run: |
cd /opt
sudo wget --quiet --output-document renode.tar.gz https://builds.renode.io/renode-latest.linux-portable.tar.gz
sudo mkdir renode
sudo tar xf renode.tar.gz -C renode --strip-components 1
sudo pip install -r /opt/renode/tests/requirements.txt
echo "PATH=/opt/renode:${PATH}" >> $GITHUB_ENV
- name: Install toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
toolchain: stable

- name: Build release binary
run: cargo build --release

- name: Install Auxon packages
env:
DEBIAN_FRONTEND: noninteractive
run: |
wget --no-verbose --quiet https://get.keygen.sh/auxon-io/auxon.deb -O /tmp/auxon.deb
sudo apt-get install -y /tmp/auxon.deb
sudo apt-get update
sudo apt-get install -y --no-install-recommends modalityd modality-client modality-reflector conform deviant
- name: Setup Modality server
run: |
sudo systemctl stop modalityd
echo 'license-key = "'"${{secrets.MODALITY_LICENSE_KEY}}"'"' | sudo tee -a /etc/modalityd/config.toml
sudo systemctl start modalityd
sudo systemctl status modalityd --no-pager --full
curl --retry-max-time 30 --retry 10 --retry-connrefused ${{env.MODALITY_URL}}/alive
- name: Setup initial Modality configuration
run: |
modality --version
modality config --modalityd ${{env.MODALITY_URL}}
modality user create --use ci
echo "MODALITY_AUTH_TOKEN=$(modality user auth-token)" >> $GITHUB_ENV
modality workspace create --use ${{env.MODALITY_WORKSPACE}} test_system/workspace.toml
- name: Update reflector plugins
run: |
sudo cp target/release/modality-trace-recorder-importer /usr/lib/modality-reflector-plugins/importers/
sudo cp target/release/modality-trace-recorder-tcp-collector /usr/lib/modality-reflector-plugins/collectors/
sudo cp target/release/modality-trace-recorder-itm-collector /usr/lib/modality-reflector-plugins/collectors/
- name: Create specs
run: |
conform spec create --file test_system/specs/device.speqtr device-specs
- name: Setup test network
working-directory: test_system
run: ./scripts/setup-network.sh &

- name: Build test system
working-directory: test_system
run: ./scripts/build.sh

- name: Run the system
working-directory: test_system
env:
MODALITY_AUTH_TOKEN: ${{env.MODALITY_AUTH_TOKEN}}
run: ./scripts/run.sh

- name: Inspect data
env:
MODALITY_AUTH_TOKEN: ${{env.MODALITY_AUTH_TOKEN}}
run: |
modality workspace list
modality workspace inspect ${{env.MODALITY_WORKSPACE}}
modality segment list
- name: Evaluate specs
continue-on-error: true
env:
MODALITY_AUTH_TOKEN: ${{env.MODALITY_AUTH_TOKEN}}
run: |
conform spec eval --name device-specs
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ description = "A Modality reflector plugin suite and ingest adapter library for
license = "Apache-2.0"
repository = "https://github.com/auxoncorp/modality-trace-recorder-plugin"
documentation = "https://docs.rs/modality-trace-recorder-plugin"
exclude = ["test_system/"]

[lib]
name = "modality_trace_recorder_plugin"
Expand Down
1 change: 1 addition & 0 deletions test_system/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
3 changes: 3 additions & 0 deletions test_system/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build
.gdb_history
tags
257 changes: 257 additions & 0 deletions test_system/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
cmake_minimum_required(VERSION 3.5)

project(demo-firmware LANGUAGES C ASM)

include(FetchContent)

message(STATUS "Fetching dependencies")

FetchContent_Declare(
freertos
GIT_REPOSITORY "https://github.com/FreeRTOS/FreeRTOS-Kernel.git"
GIT_TAG "V10.5.0"
)

FetchContent_Declare(
freertostcp
GIT_REPOSITORY "https://github.com/auxoncorp/FreeRTOS-Plus-TCP.git"
GIT_TAG "V3.1.0-1-g2359a20"
)

FetchContent_Declare(
tracerecorder
GIT_REPOSITORY "https://github.com/percepio/TraceRecorderSource.git"
GIT_TAG "Tz4/4.8/v4.8.2"
)

FetchContent_Declare(
stm32cubef4
GIT_REPOSITORY "https://github.com/STMicroelectronics/STM32CubeF4.git"
GIT_TAG "v1.27.1"
)

# Use FetchContent_Populate instead of FetchContent_MakeAvailable because
# we're defining build rules locally and don't want cmake to automatically
# call add_subdirectory on these
FetchContent_Populate(freertos)
FetchContent_Populate(freertostcp)
FetchContent_Populate(tracerecorder)
FetchContent_Populate(stm32cubef4)

set(
KERNEL_SOURCES
${freertos_SOURCE_DIR}/portable/GCC/ARM_CM4F/port.c
${freertos_SOURCE_DIR}/portable/MemMang/heap_4.c
${freertos_SOURCE_DIR}/queue.c
${freertos_SOURCE_DIR}/tasks.c
${freertos_SOURCE_DIR}/timers.c
${freertos_SOURCE_DIR}/event_groups.c
${freertos_SOURCE_DIR}/stream_buffer.c
${freertos_SOURCE_DIR}/list.c)
set(
KERNEL_INCLUDES
${freertos_SOURCE_DIR}/include
${freertos_SOURCE_DIR}/portable/GCC/ARM_CM3)

set(
TCPIP_SOURCES
${freertostcp_SOURCE_DIR}/source/FreeRTOS_DNS.c
${freertostcp_SOURCE_DIR}/source/FreeRTOS_DHCP.c
${freertostcp_SOURCE_DIR}/source/FreeRTOS_ARP.c
${freertostcp_SOURCE_DIR}/source/FreeRTOS_ICMP.c
${freertostcp_SOURCE_DIR}/source/FreeRTOS_Stream_Buffer.c
${freertostcp_SOURCE_DIR}/source/FreeRTOS_IP.c
${freertostcp_SOURCE_DIR}/source/FreeRTOS_TCP_IP.c
${freertostcp_SOURCE_DIR}/source/FreeRTOS_TCP_Transmission.c
${freertostcp_SOURCE_DIR}/source/FreeRTOS_TCP_WIN.c
${freertostcp_SOURCE_DIR}/source/FreeRTOS_TCP_State_Handling.c
${freertostcp_SOURCE_DIR}/source/FreeRTOS_TCP_Reception.c
${freertostcp_SOURCE_DIR}/source/FreeRTOS_TCP_Utils.c
${freertostcp_SOURCE_DIR}/source/FreeRTOS_UDP_IP.c
${freertostcp_SOURCE_DIR}/source/FreeRTOS_Sockets.c
${freertostcp_SOURCE_DIR}/source/FreeRTOS_IP_Utils.c
${freertostcp_SOURCE_DIR}/source/FreeRTOS_IP_Timers.c
${freertostcp_SOURCE_DIR}/source/portable/BufferManagement/BufferAllocation_2.c
${freertostcp_SOURCE_DIR}/source/portable/NetworkInterface/Common/phyHandling.c
${freertostcp_SOURCE_DIR}/source/portable/NetworkInterface/STM32Fxx/NetworkInterface.c
${freertostcp_SOURCE_DIR}/source/portable/NetworkInterface/STM32Fxx/stm32fxx_hal_eth.c)
set(
TCPIP_INCLUDES
${freertostcp_SOURCE_DIR}/source/include
${freertostcp_SOURCE_DIR}/source/portable/NetworkInterface/include
${freertostcp_SOURCE_DIR}/source/portable/NetworkInterface/STM32Fxx
${freertostcp_SOURCE_DIR}/source/portable/Compiler/GCC)

set(
TRACING_SOURCES
${tracerecorder_SOURCE_DIR}/kernelports/FreeRTOS/trcKernelPort.c
${tracerecorder_SOURCE_DIR}/trcAssert.c
${tracerecorder_SOURCE_DIR}/trcCounter.c
${tracerecorder_SOURCE_DIR}/trcDiagnostics.c
${tracerecorder_SOURCE_DIR}/trcEntryTable.c
${tracerecorder_SOURCE_DIR}/trcError.c
${tracerecorder_SOURCE_DIR}/trcEventBuffer.c
${tracerecorder_SOURCE_DIR}/trcEvent.c
${tracerecorder_SOURCE_DIR}/trcExtension.c
${tracerecorder_SOURCE_DIR}/trcHardwarePort.c
${tracerecorder_SOURCE_DIR}/trcHeap.c
${tracerecorder_SOURCE_DIR}/trcInternalEventBuffer.c
${tracerecorder_SOURCE_DIR}/trcInterval.c
${tracerecorder_SOURCE_DIR}/trcISR.c
${tracerecorder_SOURCE_DIR}/trcMultiCoreEventBuffer.c
${tracerecorder_SOURCE_DIR}/trcObject.c
${tracerecorder_SOURCE_DIR}/trcPrint.c
${tracerecorder_SOURCE_DIR}/trcStackMonitor.c
${tracerecorder_SOURCE_DIR}/trcStateMachine.c
${tracerecorder_SOURCE_DIR}/trcStaticBuffer.c
${tracerecorder_SOURCE_DIR}/trcString.c
${tracerecorder_SOURCE_DIR}/trcTask.c
${tracerecorder_SOURCE_DIR}/trcTimestamp.c
${tracerecorder_SOURCE_DIR}/trcStreamingRecorder.c)
set(
TRACING_INCLUDES
${tracerecorder_SOURCE_DIR}/kernelports/FreeRTOS/include
${tracerecorder_SOURCE_DIR}/include)

set(
HAL_SOURCES
${stm32cubef4_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c
${stm32cubef4_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c
${stm32cubef4_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_usart.c
${stm32cubef4_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c
${stm32cubef4_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c)
set(
HAL_INCLUDES
${stm32cubef4_SOURCE_DIR}/Drivers/CMSIS/Include
${stm32cubef4_SOURCE_DIR}/Drivers/CMSIS/Device/ST/STM32F4xx/Include/
${stm32cubef4_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Inc)

add_library(
hal
STATIC
${HAL_SOURCES})

target_include_directories(
hal
PRIVATE
config
PUBLIC
${HAL_INCLUDES})

target_compile_definitions(
hal
PUBLIC
STM32F4xx
STM32F407xx
HSE_VALUE=8000000
_FPU_PRESENT=1
_FPU_USED=1
ARM_MATH_CM4)

add_library(
freertos
STATIC
${TRACING_SOURCES}
${KERNEL_SOURCES})

target_include_directories(
freertos
PRIVATE
config
include
${HAL_INCLUDES}
PUBLIC
${TRACING_INCLUDES}
${KERNEL_INCLUDES})

add_library(
freertos_tcpip
STATIC
${TCPIP_SOURCES})

target_include_directories(
freertos_tcpip
PRIVATE
config
include
${HAL_INCLUDES}
PUBLIC
${TCPIP_INCLUDES})

target_compile_options(
freertos_tcpip
PRIVATE
-Wno-format
-Wno-shadow)

target_compile_definitions(
freertos_tcpip
PUBLIC
HEAP4)

target_link_libraries(
freertos_tcpip
hal
freertos)

add_executable(
${PROJECT_NAME}
src/main.c
src/modality.c
src/logging.c
src/stats.c
src/ip.c
src/comms.c
src/sensor.c
src/actuator.c
src/led.c
src/syscall.c
src/hooks.c
src/timer.c
src/trcStreamPort.c
${stm32cubef4_SOURCE_DIR}/Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c
${stm32cubef4_SOURCE_DIR}/Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/startup_stm32f407xx.s)

target_include_directories(
${PROJECT_NAME}
PRIVATE
config
include)

target_compile_definitions(
${PROJECT_NAME}
PRIVATE
HEAP4)

target_link_libraries(
${PROJECT_NAME}
hal
freertos
freertos_tcpip)

add_custom_target(
emulate
DEPENDS ${PROJECT_NAME})

add_custom_command(
TARGET emulate
POST_BUILD
MAIN_DEPENDENCY ${PROJECT_NAME}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
COMMAND renode emulate.resc --hide-monitor
COMMENT "Emulating firmware with Renode")

add_custom_target(
emulate-with-monitor
DEPENDS ${PROJECT_NAME})

add_custom_command(
TARGET emulate-with-monitor
POST_BUILD
MAIN_DEPENDENCY ${PROJECT_NAME}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
COMMAND renode emulate.resc
COMMENT "Emulating firmware with Renode")

print_exec_size()
elf_to_bin()
Loading

0 comments on commit bd757f9

Please sign in to comment.