Skip to content
Merged
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
112 changes: 110 additions & 2 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ concurrency:
cancel-in-progress: true

jobs:
codecov:
twister:
runs-on: self-hosted
container:
image: ghcr.io/zephyrproject-rtos/ci:v0.26.13
Expand Down Expand Up @@ -114,9 +114,117 @@ jobs:
path: coverage/reports/${{ matrix.normalized }}.json
retention-days: 1

babblesim:
runs-on: self-hosted
container:
image: ghcr.io/zephyrproject-rtos/ci:v0.26.13
options: '--entrypoint /bin/bash'
volumes:
- /repo-cache/embeint:/github/cache/embeint
env:
BASE_REF: ${{ github.base_ref }}
ZEPHYR_TOOLCHAIN_VARIANT: zephyr
BSIM_OUT_PATH: /github/cache/embeint/tools/bsim
BSIM_COMPONENTS_PATH: /github/cache/embeint/tools/bsim/components/

steps:
- name: Workspace cleanup
run: |
rm -rf ./{*,.*}
rm -rf infuse-sdk

- name: Clone cached Embeint SDK repository
continue-on-error: true
run: |
git config --global --add safe.directory '*'
git clone --shared /github/cache/embeint/infuse-sdk infuse-sdk
cd infuse-sdk
git remote set-url origin ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}

- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
path: infuse-sdk
fetch-depth: 0
persist-credentials: false

- name: Environment Setup
working-directory: infuse-sdk
run: |
if [ "${{github.event_name}}" = "pull_request" ]; then
git config --global user.email "[email protected]"
git config --global user.name "Embeint CI"
rm -fr ".git/rebase-apply"
git rebase origin/${BASE_REF}
git log --pretty=oneline | head -n 10
fi

west init -l . || true
west config --global update.narrow true
west config manifest.group-filter -- +babblesim
west update --path-cache /github/cache/embeint 2>&1 1> west.update.log || west update --path-cache /github/cache/embeint 2>&1 1> west.update.log || ( rm -rf ../modules ../bootloader ../tools && west update --path-cache /github/cache/embeint)
west forall -c 'git reset --hard HEAD'

pip3 install gcovr==6.0

echo "ZEPHYR_SDK_INSTALL_DIR=/opt/toolchains/zephyr-sdk-$( cat SDK_VERSION )" >> $GITHUB_ENV

- name: nRF Hardware Models patch
working-directory: modules/bsim_hw_models/nrf_hw_models
run: |
# Apply temporary patch until latest upstream can be used
git apply ../../../infuse-sdk/tests/bsim/nrf_hw_models.patch

- name: BabbleSim build
run: |
cd ${BSIM_OUT_PATH}
make everything -j 8

- name: Check Environment
run: |
cmake --version
gcc --version
ls -la /opt/toolchains
ls -la
echo "github.ref: ${{ github.ref }}"
echo "github.base_ref: ${{ github.base_ref }}"
echo "github.ref_name: ${{ github.ref_name }}"

- name: Run Bluetooth Tests with BabbleSim
run: |
export ZEPHYR_BASE=${PWD}/zephyr
export INFUSE_BASE=${PWD}/infuse-sdk
export WORK_DIR=${PWD}/bsim_out
$INFUSE_BASE/tests/bsim/ci.bt.sh

- name: Generate coverage report
run: |
export INFUSE_BASE=${PWD}/infuse-sdk
export WORK_DIR=${PWD}/bsim_out

mkdir -p coverage/reports
gcovr -r $INFUSE_BASE \
--gcov-ignore-parse-errors=negative_hits.warn_once_per_file \
--gcov-executable gcov -e tests/* -e .*generated.* -e .*/tests/.* -e .*/samples/.* \
--exclude-branches-by-pattern "(^\s*LOG_(?:HEXDUMP_)?(?:DBG|INF|WRN|ERR)\(.*)|(^\s*__ASSERT(?:_EVAL|_NO_MSG|_POST_ACTION)?\(.*)" \
--merge-mode-functions=separate --json \
-o coverage/reports/nrf52_bsim.json \
$WORK_DIR

- name: Upload Coverage Results
uses: actions/upload-artifact@v4
with:
name: Coverage Data (BabbleSim)
path: coverage/reports/nrf52_bsim.json
if-no-files-found: ignore
retention-days: 1

codecov-results:
name: "Publish Coverage Results"
needs: codecov
needs:
- twister
- babblesim
runs-on: ubuntu-22.04
# the codecov job might be skipped, we don't need to run this job then
if: success() || failure()
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/twister.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- name: Clone cached Embeint SDK repository
continue-on-error: true
run: |
git config --global --add safe.directory /github/cache/embeint/infuse-sdk/.git
git config --global --add safe.directory '*'
git clone --shared /github/cache/embeint/infuse-sdk infuse-sdk
cd infuse-sdk
git remote set-url origin ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Build folders
build
bsim_out
doc/_build

# Python files
Expand Down
2 changes: 2 additions & 0 deletions Kconfig.defaults.bluetooth
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ configdefault BT_PERIPHERAL
# While extended advertising can support 255 bytes, iOS only supports 124 bytes
configdefault BT_CTLR_ADV_DATA_LEN_MAX
default 124
configdefault BT_CTLR_SCAN_DATA_LEN_MAX
default 124

# GATT central options
configdefault BT_GATT_CLIENT
Expand Down
2 changes: 1 addition & 1 deletion Kconfig.defaults.core
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ configdefault DEBUG_INFO
configdefault DEBUG_THREAD_INFO
default y
configdefault OUTPUT_DISASSEMBLY
default y if !ZTEST
default y if !ZTEST && !SOC_SERIES_BSIM_NRFXX

# Memfault options
configdefault MEMFAULT_NRF_CONNECT_SDK
Expand Down
27 changes: 27 additions & 0 deletions scripts/bsim_coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env sh

echo "BabbleSim Coverage"

export ZEPHYR_BASE=`pwd`/zephyr
export INFUSE_BASE=`pwd`/infuse-sdk
export WORK_DIR=`pwd`/bsim_out
# Run BabbleSim tests
$INFUSE_BASE/tests/bsim/ci.bt.sh

# Disable branch coverage on LOG_ and __ASSERT macros
BRANCH_LOG="(^\s*LOG_(?:HEXDUMP_)?(?:DBG|INF|WRN|ERR)\(.*)"
BRANCH_ASSERT="(^\s*__ASSERT(?:_EVAL|_NO_MSG|_POST_ACTION)?\(.*)"

# Generate coverage.json
gcovr -r $INFUSE_BASE \
--gcov-ignore-parse-errors=negative_hits.warn_once_per_file \
--gcov-executable gcov -e tests/* -e .*generated.* -e .*/tests/.* -e .*/samples/.* \
--exclude-branches-by-pattern "$BRANCH_LOG|$BRANCH_ASSERT" \
--merge-mode-functions=separate --json \
-o $WORK_DIR/coverage.json \
$WORK_DIR

# Generate html
mkdir -p $WORK_DIR/html
gcovr -r $INFUSE_BASE --html $WORK_DIR/html/index.html --html-details \
--add-tracefile $WORK_DIR/coverage.json
31 changes: 31 additions & 0 deletions snippets/infuse/boards/nrf52_bsim.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/ {
chosen {
infuse,kv-partition = &storage_partition;
};

epacket_bt_adv: epacket_bt_adv {
compatible = "embeint,epacket-bt-adv";
};

data_logger_bt_adv: data_logger_bt_adv {
compatible = "embeint,data-logger-epacket", "embeint,data-logger";
epacket = <&epacket_bt_adv>;

tdf_logger_bt_adv: tdf_logger_bt_adv {
compatible = "embeint,tdf-data-logger";
};
};

epacket_bt_peripheral: epacket_bt_peripheral {
compatible = "embeint,epacket-bt-peripheral";
};

data_logger_bt_peripheral: data_logger_bt_peripheral {
compatible = "embeint,data-logger-epacket", "embeint,data-logger";
epacket = <&epacket_bt_peripheral>;

tdf_logger_bt_peripheral: tdf_logger_bt_peripheral {
compatible = "embeint,tdf-data-logger";
};
};
};
4 changes: 4 additions & 0 deletions snippets/infuse/snippet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ boards:
append:
EXTRA_DTC_OVERLAY_FILE: boards/mps2_an385.overlay
EXTRA_CONF_FILE: infuse_snippet.conf
nrf52_bsim/native:
append:
EXTRA_DTC_OVERLAY_FILE: boards/nrf52_bsim.overlay
EXTRA_CONF_FILE: infuse_snippet.conf
nrf52840dk/nrf52840:
append:
EXTRA_DTC_OVERLAY_FILE: boards/nrf52840dk_nrf52840.overlay
Expand Down
97 changes: 97 additions & 0 deletions submanifests/babblesim.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
manifest:
remotes:
- name: zephyrproject
url-base: https://github.com/zephyrproject-rtos
- name: babblesim
url-base: https://github.com/BabbleSim
projects:
- name: bsim
remote: zephyrproject
repo-path: babblesim-manifest
revision: 9351ae1ad44864a49c351f9704f65f43046abeb0
path: tools/bsim
groups:
- babblesim
- name: nrf_hw_models
remote: zephyrproject
revision: 6c389b9b5fa0a079cd4502e69d375da4c0c289b7
path: modules/bsim_hw_models/nrf_hw_models
groups:
- babblesim
- name: babblesim_base
remote: babblesim
repo-path: base
path: tools/bsim/components
revision: 4bd907be0b2abec3b31a23fd8ca98db2a07209d2
groups:
- babblesim
- name: babblesim_ext_2G4_libPhyComv1
remote: babblesim
repo-path: ext_2G4_libPhyComv1
path: tools/bsim/components/ext_2G4_libPhyComv1
revision: 93f5eba512c438b0c9ebc1b1a947517c865b3643
groups:
- babblesim
- name: babblesim_ext_2G4_phy_v1
remote: babblesim
repo-path: ext_2G4_phy_v1
path: tools/bsim/components/ext_2G4_phy_v1
revision: 04eeb3c3794444122fbeeb3715f4233b0b50cfbb
groups:
- babblesim
- name: babblesim_ext_2G4_channel_NtNcable
remote: babblesim
repo-path: ext_2G4_channel_NtNcable
path: tools/bsim/components/ext_2G4_channel_NtNcable
revision: 20a38c997f507b0aa53817aab3d73a462fff7af1
groups:
- babblesim
- name: babblesim_ext_2G4_channel_multiatt
remote: babblesim
repo-path: ext_2G4_channel_multiatt
path: tools/bsim/components/ext_2G4_channel_multiatt
revision: bde72a57384dde7a4310bcf3843469401be93074
groups:
- babblesim
- name: babblesim_ext_2G4_modem_magic
remote: babblesim
repo-path: ext_2G4_modem_magic
path: tools/bsim/components/ext_2G4_modem_magic
revision: edfcda2d3937a74be0a59d6cd47e0f50183453da
groups:
- babblesim
- name: babblesim_ext_2G4_modem_BLE_simple
remote: babblesim
repo-path: ext_2G4_modem_BLE_simple
path: tools/bsim/components/ext_2G4_modem_BLE_simple
revision: a38d2d24b04a6f970a225d1316047256ebf5a539
groups:
- babblesim
- name: babblesim_ext_2G4_device_burst_interferer
remote: babblesim
repo-path: ext_2G4_device_burst_interferer
path: tools/bsim/components/ext_2G4_device_burst_interferer
revision: 5b5339351d6e6a2368c686c734dc8b2fc65698fc
groups:
- babblesim
- name: babblesim_ext_2G4_device_WLAN_actmod
remote: babblesim
repo-path: ext_2G4_device_WLAN_actmod
path: tools/bsim/components/ext_2G4_device_WLAN_actmod
revision: 9cb6d8e72695f6b785e57443f0629a18069d6ce4
groups:
- babblesim
- name: babblesim_ext_2G4_device_playback
remote: babblesim
repo-path: ext_2G4_device_playback
path: tools/bsim/components/ext_2G4_device_playback
revision: abb48cd71ddd4e2a9022f4bf49b2712524c483e8
groups:
- babblesim
- name: babblesim_ext_libCryptov1
remote: babblesim
repo-path: ext_libCryptov1
path: tools/bsim/components/ext_libCryptov1
revision: eed6d7038e839153e340bd333bc43541cb90ba64
groups:
- babblesim
20 changes: 20 additions & 0 deletions tests/bsim/bluetooth/advertising/compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
# Copyright 2024 Embeint Inc
# SPDX-License-Identifier: Apache-2.0

# Compile all the applications needed by the bsim tests in these subfolders

# set -x #uncomment this line for debugging
set -ue

: "${ZEPHYR_BASE:?ZEPHYR_BASE must be set to point to the zephyr root directory}"
: "${INFUSE_BASE:?INFUSE_BASE must be set to point to the Infuse-IoT root directory}"

source ${ZEPHYR_BASE}/tests/bsim/compile.source

APP=tests/bsim/bluetooth/advertising/epacket

app_root=$INFUSE_BASE app=$APP conf_file=prj_advertiser.conf snippet=infuse compile
app_root=$INFUSE_BASE app=$APP conf_file=prj_scanner.conf snippet=infuse compile

wait_for_background_jobs
26 changes: 26 additions & 0 deletions tests/bsim/bluetooth/advertising/epacket/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2024 Embeint Inc
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(bsim_test_epacket_bt_adv)

target_sources(app PRIVATE
src/common.c
)

if(CONFIG_BT_CENTRAL)
target_sources(app PRIVATE
src/ext_adv_scanner.c
)
else()
target_sources(app PRIVATE
src/ext_adv_advertiser.c
)
endif()

zephyr_include_directories(
${BSIM_COMPONENTS_PATH}/libUtilv1/src/
${BSIM_COMPONENTS_PATH}/libPhyComv1/src/
)
3 changes: 3 additions & 0 deletions tests/bsim/bluetooth/advertising/epacket/prj_advertiser.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CONFIG_INFUSE_SDK=y
CONFIG_TASK_RUNNER=y
CONFIG_BT=y
4 changes: 4 additions & 0 deletions tests/bsim/bluetooth/advertising/epacket/prj_scanner.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CONFIG_INFUSE_SDK=y
CONFIG_TASK_RUNNER=y
CONFIG_BT=y
CONFIG_BT_CENTRAL=y
Loading