Skip to content

Commit

Permalink
Sync with new build from puddly
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerivec committed Oct 27, 2024
1 parent 830267e commit 69b25bb
Show file tree
Hide file tree
Showing 387 changed files with 10,967 additions and 29,939 deletions.
35 changes: 18 additions & 17 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:
name: Run pre-commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- name: Install pre-commit
run: |
pip install pre-commit
Expand All @@ -37,9 +37,9 @@ jobs:
permissions:
packages: write
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4.1.4
- name: Log in to the GitHub container registry
uses: docker/login-action@v3
uses: docker/login-action@v3.1.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
Expand Down Expand Up @@ -85,10 +85,10 @@ jobs:
echo "image_name=$image_name" >> $GITHUB_OUTPUT
echo "container_name=${{ env.REGISTRY }}/$image_name:$tag_name" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@v3.3.0
if: steps.read-repo-info.outputs.build_image == 'true'
- name: Build and Push
uses: docker/build-push-action@v6
uses: docker/build-push-action@v5.3.0
if: steps.read-repo-info.outputs.build_image == 'true'
with:
context: .
Expand All @@ -102,13 +102,14 @@ jobs:
image_name: ${{ steps.read-repo-info.outputs.image_name }}
container_name: ${{ steps.read-repo-info.outputs.container_name }}


list-manifests:
name: List firmware manifests
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4.1.4
- id: set-matrix
run: |
echo "matrix=$(find manifests -type f \( -name "*.yaml" -o -name "*.yml" \) -print | sort | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
Expand All @@ -124,19 +125,19 @@ jobs:
matrix:
manifest: ${{ fromJson(needs.list-manifests.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4.1.4

- name: Install SDK extensions
run: |
# XXX: slc-cli does not actually work when the extensions aren't in the SDK!
for sdk in /simplicity_sdk*; do
for sdk in /*_sdk_*; do
slc signature trust --sdk "$sdk"
# ln -s $PWD/simplicity_sdk_extensions "$sdk"/extension
ln -s $PWD/gecko_sdk_extensions "$sdk"/extension
# for ext in "$sdk"/extension/*/; do
# slc signature trust --sdk "$sdk" --extension-path "$ext"
# done
for ext in "$sdk"/extension/*/; do
slc signature trust --sdk "$sdk" --extension-path "$ext"
done
done
- name: Build firmware
Expand All @@ -147,7 +148,7 @@ jobs:
# Pass all SDKs as consecutive `--sdk ...` arguments
sdk_args=""
for sdk_dir in /simplicity_sdk*; do
for sdk_dir in /*_sdk*; do
sdk_args="$sdk_args --sdk $sdk_dir"
done
Expand Down Expand Up @@ -177,10 +178,10 @@ jobs:
if: ${{ env.ACT }}
run: |
curl -fsSL https://deb.nodesource.com/nsolid_setup_deb.sh | bash -s 20
apt-get update && apt-get install -y nodejs
apt-get install -y nodejs
- name: Upload artifact
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v4.3.3
with:
name: firmware-build-${{ steps.build-firmware.outputs.output_basename }}
path: outputs/*
Expand All @@ -203,6 +204,6 @@ jobs:
pattern: firmware-build-*

- name: Upload artifacts
uses: softprops/action-gh-release@v2
uses: softprops/action-gh-release@v1
with:
files: artifacts/*.gbl
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@ autogen/
*.project.mak
*.Makefile
build/
build_*/
artifact/
artifacts/
trashed_modified_files/
src/**/*.bak
src/**/*.bak0
misc/**/*.bak
misc/**/*.bak0
misc/**/*.bak
13 changes: 6 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ RUN \
python3 \
python3-ruamel.yaml \
unzip \
xz-utils \
&& rm -rf /var/lib/apt/lists/*
xz-utils

# Install Simplicity Commander (unfortunately no stable URL available, this
# is known to be working with Commander_linux_x86_64_1v15p0b1306.tar.bz).
Expand All @@ -40,17 +39,17 @@ RUN \

ENV PATH="$PATH:/opt/slc_cli"

# GCC Embedded Toolchain 12.2.rel1 (for Simplicity SDK)
# GCC Embedded Toolchain 12.2.rel1 (for Gecko SDK 4.4.0+)
RUN \
curl -O https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu/12.2.rel1/binrel/arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi.tar.xz \
&& tar -C /opt -xf arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi.tar.xz \
&& rm arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi.tar.xz

# Simplicity SDK
# Simplicity SDK 2024.6.2
RUN \
curl -o simplicity_sdk.zip -L https://github.com/SiliconLabs/simplicity_sdk/releases/download/v2024.6.2/gecko-sdk.zip \
&& unzip -q -d simplicity_sdk simplicity_sdk.zip \
&& rm simplicity_sdk.zip
curl -o simplicity_sdk_2024.6.2.zip -L https://github.com/SiliconLabs/simplicity_sdk/releases/download/v2024.6.2/gecko-sdk.zip \
&& unzip -q -d simplicity_sdk_2024.6.2 simplicity_sdk_2024.6.2.zip \
&& rm simplicity_sdk_2024.6.2.zip

ARG USERNAME=builder
ARG USER_UID=1000
Expand Down
91 changes: 90 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,90 @@
# Silicon Labs firmware builder
# Silicon Labs firmware builder repository
This repository contains tools for building firmwares for the Home Assistant Connect
ZBT-1/SkyConnect and the Home Assistant Yellow's IEEE 802.15.4 radio. The firmware
manifests are entirely generic, however, and are intended to be written easily for any
Silicon Labs EFR32 device.

It uses the Silicon Labs Gecko/Simplicity SDK and proprietary Silicon Labs tools such as
the Silicon Labs Configurator (slc) and the Simplicity Commander standalone utility.

## Background
The project templates in this repository are configured and built for specific boards
using manifest files. For example, the [`skyconnect_zigbee_ncp.yaml`](https://github.com/NabuCasa/silabs-firmware-builder/blob/main/manifests/skyconnect_zigbee_ncp.yaml)
manifest file configures the Zigbee firmware for the SkyConnect/Connect ZBT-1.

## Setting up Simplicity Studio (for development)
If you are going to be developing using Simplicity Studio, note that each project can
potentially use a different Simplicity SDK release. It is recommended to forego the typical
Simplicity Studio SDK management workflow and manually manage SDKs:

1. Clone a specific version of the Simplicity SDK:
```bash
# For macOS
mkdir ~/SimplicityStudio/SDKs/simplicity_sdk_2024.6.2
cd ~/SimplicityStudio/SDKs/simplicity_sdk_2024.6.2

git clone -b v2024.6.2 https://github.com/SiliconLabs/simplicity_sdk .
git checkout -b branch_tag
```

2. Open preferences, navigate to **Simplicity Studio > SDKs**, click the `Add SDK...` button, and browse to the above location.

Repeat this process for every necessary SDK version.

> [!TIP]
> If you have build issues after switching commits, make sure to delete any
> `simplicity_sdk_*`, `gecko_sdk_*`, and `template` folders from the project working tree.
## Building with a firmware manifest (for building device firmware)
Command line building requires:
- [`slc-cli`](https://docs.silabs.com/simplicity-studio-5-users-guide/latest/ss-5-users-guide-tools-slc-cli/02-installation)
- [Simplicity Commander](https://www.silabs.com/developers/mcu-programming-options) (`commander`)
- The exact Simplicity SDK version required by the project. Note that this doesn't have to be a Git working tree, you can use [a GitHub release](https://github.com/SiliconLabs/gecko_sdk/releases).
- A compatible toolchain. Take a look at the `Dockerfile` for the necessary toolchains.

> [!TIP]
> If you have set up Simplicity Studio on macOS, everything will be automatically
> detected with the exception of `slc`. This is the only tool you need to download.
> [!WARNING]
> M1 users should set `JAVA_HOME=$(/usr/libexec/java_home -a x86_64)` when running the
> build command to make sure the correct Java version is picked by slc-cli. It currently
> is not compatible with ARM Java.
`slc-cli` maintains its own SDK and extension trust store so you first must trust all
SDK extensions for every SDK you plan to use:

```bash
slc signature trust --sdk ~/SimplicityStudio/SDKs/simplicity_sdk_2024.6.2
slc signature trust --sdk ~/SimplicityStudio/SDKs/simplicity_sdk_2024.6.2 --extension-path ~/SimplicityStudio/SDKs/simplicity_sdk_2024.6.2/extension/nc_efr32_watchdog_extension
```

`tools/build_project.py` is the main entry point for building firmwares. Provide paths
to potential SDKs and toolchains with the `--sdk` and `--toolchain` flags. The build
tool will automatically determine which SDK and toolchain to use.

> [!TIP]
> If you have set up Simplicity Studio on macOS, the default toolchain and SDK paths are
> automatically found so these flags can be omitted.
```bash
pip install ruamel.yaml # Only dependency

python tools/build_project.py \
# The following SDK and toolchain flags can be omitted on macOS, they are all autodetected
--sdk ~/SimplicityStudio/SDKs/gecko_sdk_4.4.4 \
--sdk ~/SimplicityStudio/SDKs/simplicity_sdk_2024.6.0 \
--toolchain '/Applications/Simplicity Studio.app/Contents/Eclipse/developer/toolchains/gnu_arm/10.3_2021.10' \
--toolchain '/Applications/Simplicity Studio.app/Contents/Eclipse/developer/toolchains/gnu_arm/12.2.rel1_2023.7' \

--manifest manifests/skyconnect_ncp-uart-hw.yaml \
--build-dir build \
--output-dir output \

# Generate `.gbl`, `.out`, and `.hex` firmwares
--output gbl \
--output out \
--output hex
```

Once the build is complete, the firmwares will be in the `output` directory.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/***************************************************************************//**
* @file app.c
* @brief Callbacks implementation and application specific code.
* @file nc_efr32_wdog.h
* @brief Legacy HAL Watchdog
*******************************************************************************
* # License
* <b>Copyright 2021 Silicon Laboratories Inc. www.silabs.com</b>
* <b>Copyright 2022 Silicon Laboratories, Inc, www.silabs.com</b>
*******************************************************************************
*
* The licensor of this software is Silicon Laboratories Inc. Your use of this
Expand All @@ -15,24 +15,11 @@
*
******************************************************************************/

#include PLATFORM_HEADER
#include "sl_zigbee.h"
#include <stdio.h>
#include "em_cmu.h"
#include "em_wdog.h"
#include "em_rmu.h"
#include "sl_component_catalog.h"

//----------------------
// Implemented Callbacks

/** @brief
*
* Application framework equivalent of ::sl_zigbee_radio_needs_calibrating_handler
*/
void sl_zigbee_af_radio_needs_calibrating_cb(void)
{
sl_mac_calibrate_current_channel();
}

/** @brief Init
* Application init function
*/
void sl_zigbee_af_main_init_cb(void)
{
}
void nc_enable_watchdog(void);
void nc_poke_watchdog(void);
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
root_path: ./
id: nc_efr32_watchdog
label: EFR32 Watchdog
package: ext-comp
category: External Components
quality: production
description: >
EFR32 Watchdog.
requires:
- name: component_catalog
- name: emlib_wdog
- name: emlib_wdog
provides:
- name: nc_efr32_watchdog

source:
- path: src/nc_efr32_wdog.c

include:
- path: inc
file_list:
- path: nc_efr32_wdog.h

template_contribution:
- name: component_catalog
value: nc_efr32_watchdog
- name: event_handler
value:
event: service_init
include: "nc_efr32_wdog.h"
handler: nc_enable_watchdog
priority: 9999 # load very very late
- name: event_handler
value:
event: service_process_action
include: "nc_efr32_wdog.h"
handler: nc_poke_watchdog
priority: 9999 # run last
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
id: "nc_efr32_watchdog"
label: "EFR32 Watchdog"
version: "1.0.0"
sdk:
id: "gecko_sdk"
version: 4.3.2
component_path:
- path: "./"
Loading

0 comments on commit 69b25bb

Please sign in to comment.