Skip to content

Commit

Permalink
Merge pull request #169 from darkxst/router-fixes
Browse files Browse the repository at this point in the history
Add some fixes to the router builds
  • Loading branch information
darkxst authored Jan 7, 2025
2 parents b36248a + a9ca060 commit 936efc0
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 98 deletions.
168 changes: 87 additions & 81 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,90 +1,96 @@
# 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.
This repository contains Dockerfiles and GitHub actions that build Silicon Labs firmware. It also hosts unofficial Zigbee Coordinator and Thread (OpenThread) firmware builds that community members can experiment with at your own risk.

The firmware builder uses the Silicon Labs [Gecko SDK (GSDK)](https://github.com/SiliconLabs/gecko_sdk) and proprietary Silicon Labs tools such as the Silicon Labs Configurator (slc) and the Simplicity Commander standalone utility. This is a fork of the [Silabs firmware builder by Nabu Casa](https://github.com/NabuCasa/silabs-firmware-builder), adding support for additional radio adapter hardware models.

Again, please note that the pre-compiled firmware builds hosted in this repository are both unofficial and experimental or cutting-edge releases with minimal testing which may brick your radio adapter so that it requires manual recovery via a compatible debug probe adapter, however, the builds offered via the Web Flasher are the latest versions recommended by the community.

## Supported hardware:
* Sonoff ZBDongle-E by ITead (based on EFR32MG21)
* Sonoff iHost by ITead (also based on EFR32MG21 and uses the same firmware as Sonoff ZBDongle-E)
* EasyIot ZB-GW04 v1.1 and v1.2 (based on EFR32MG21)
* SMLIGHT SLZB-07 (which may require unlocked [bootloader](https://github.com/darkxst/silabs-firmware-builder/raw/main/firmware_builds/slzb-07/BTL_SLZB07.gbl) first) (based on EFR32MG21)
* SMLIGHT SLZB-07Mg24 (based on EFR32MG24)
* SMLIGHT SLZB-06M (based on EFR32MG21)
* Aeotec Zi-Stick (model “ZGA008” based on EFR32MG21)
* Sparkfun Things Matter MGM240P (requires [bootloader](https://github.com/darkxst/silabs-firmware-builder/blob/main/firmware_builds/mgm240p/bootloader-uart-xmodem_NCP.hex) to be flashed first using Silabs [Simplicity Commander](https://community.silabs.com/s/article/simplicity-commander?language=en_US)) (based on EFR32MG24)
* Elelabs Zigbee USB Adapter ELU013 (based on EFR32MG13P) [legacy only, 7.4.x builds]
* Elelabs Zigbee Raspberry Pi Shield ELR023 (based on EFR32MG13P) [legacy only, 7.4.x builds]

## Different firmware variants

Three network protocol application firmware variants are available:

* **EmberZNet NCP** = Zigbee NCP (Network Co-Processor) is used as a dedicated Zigbee Coordinator for Zigbee-only environments, for direct use with Zigbee2MQTT, Home Assistant's ZHA integration, other Zigpy based Zigbee Gateway implementations, or other Zigbee gateways/frameworks that support the EZSP (EmberZNet Serial Protocol) interface.
* **OpenThread RCP** firmware (experimental) = This [Thread](https://en.wikipedia.org/wiki/Thread_(network_protocol)) RCP (Radio Co-Processor) is used directly as a dedicated Thread Border Router in Thread-only environments, used for [OpenThread Border Router add-on](https://github.com/home-assistant/addons/blob/master/openthread_border_router/DOCS.md) or wpantund.
* **RCP Multi-PAN** (no longer recommended) = Multiprotocol firmware for concurrent communication over Zigbee and Thread via Home Assistant [SiliconLabs Multiprotocol add-on](https://github.com/home-assistant/addons/blob/master/silabs-multiprotocol/DOCS.md).

**Note!** Beware that the RCP MultiPAN in multiprotocol mode is no longer recommended because running multi-protocol with multiple active networks on a single radio adapter has proven to not be stable when using Zigbee and Thread network protocols simultaneously on the same radio adapter, it also increases the complexity of software component dependencies needed, so if already using RCP Multi-PAN then it is highly recommended that you plan to migrate to separate dedicated radio adapters instead, (using Zigbee NCP and Thread RCP firmware respectively), even if using RCP MultiPAN on a single radio adapter dongle has been working fine for you so far.

External reference explaining these different co-processor designs at a high level:
* https://github.com/home-assistant/addons/blob/master/silabs-multiprotocol/DOCS.md
* https://openthread.io/platforms/co-processor

## Web Flasher
Flash directly from your browser (only Chrome and Edge supported) [SL Web Flasher](https://darkxst.github.io/silabs-firmware-builder/)

Read this [blog post](https://dialedin.com.au/blog/sonoff-zbdongle-e-rcp-firmware) for more details and instructions for using RCP Multi-pan firmware.

## Home Assistant Add-on
**RCP MultiPan firmware ONLY**
You can install this HA add-on to keep your dongle up to date with latest the RCP Multi-Pan firmware. This is only for use if you are using the [SiliconLabs Multiprotocol add-on](https://github.com/home-assistant/addons/blob/master/silabs-multiprotocol/DOCS.md).

> [!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.
[Multipan Flasher Addon](https://github.com/darkxst/multipan_flasher/tree/main)

```bash
pip install ruamel.yaml # Only dependency
It can also be used for the initial conversion to MultiPan firmware, however you will need to disable ZHA or Zigbee2MQTT while you do this initial flash. You can then install and configure the Silabs Multiprotocol Add-on.

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' \
## Pre-Compiled Firmware
Firmware builds can be found in the [firmware_builds](https://github.com/darkxst/silabs-firmware-builder/tree/main/firmware_builds) folder.

--manifest manifests/skyconnect_ncp-uart-hw.yaml \
--build-dir build \
--output-dir output \
`ncp-uart-hw-` EmberZnet pure Zigbee
`rcp-uart-802154-` RCP MultiPan
`ot-rcp-` OpenThread Only

# Generate `.gbl`, `.out`, and `.hex` firmwares
--output gbl \
--output out \
--output hex
ZBDongle-E and ZB-GW04 v1.1 do not support hardware flow control. Yellow, SkyConnect and ZB-GW04 v1.2 are built with hardware flow control. Various baudrates are available as listed at the end of the filename.

Use NabuCasa's [Universal-Silabs-Flasher](https://github.com/NabuCasa/universal-silabs-flasher) to flash the `.gbl` files.


## Building locally

To build a firmware locally the build container can be reused. If you use VSCode then simply open the included devcontainer. Or you can manually start the
container locally using Docker, with a build directory bind-mounted, e.g.

```sh
docker run --rm -it \
--user builder \
-v $(pwd)/build:/build \
ghcr.io/darkxst/silabs-firmware-builder:4.2.2
```

To generate a project, use `slc generate`. To replicate/debug build issues in
an existing GitHub action, it is often helpful to just copy the command from
the "Generate Firmware Project" step.

```sh
slc generate \
--with="MGM210PA32JIA,simple_led:board_activity" \
--project-file="/gecko_sdk/protocol/openthread/sample-apps/ot-ncp/rcp-uart-802154.slcp" \
--export-destination=rcp-uart-802154-yellow \
--copy-proj-sources --new-project --force \
--configuration=""
```

Then build it using commands from the "Build Firmware" step:

```sh
cd rcp-uart-802154-yellow
make -f rcp-uart-802154.Makefile release
```

Once the build is complete, the firmwares will be in the `output` directory.
## Support

If you would like to help support further development of my `Silabs firmware` projects consider buying me a coffee!

<a href="https://www.buymeacoffee.com/darkxst" target="_blank"><img src="img/blue-button.png" alt="Buy Me A Coffee" height="41" width="174"></a>
2 changes: 1 addition & 1 deletion manifests/easyiot/zb-gw04-1v1_openthread_rcp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ c_defines:

SL_CLOCK_MANAGER_HFXO_EN: 1
SL_CLOCK_MANAGER_HFXO_CTUNE: 128
SL_CLOCK_MANAGER_DEFAULT_HF_CLOCK_SOURCE: SL_CLOCK_MANAGER_DEFAULT_HF_CLOCK_SOURCE_HFXO


4 changes: 2 additions & 2 deletions manifests/smlight/slzb06m_zigbee_router.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ json_config:
- file: "config/zcl/zcl_config.zap"
jq: |
( .endpointTypes[].clusters[].attributes[] | select(.name == "date code"))
.defaultValue = "20241104"
.defaultValue = "20250102"
- file: "config/zcl/zcl_config.zap"
jq: |
Expand All @@ -36,7 +36,7 @@ add_components:

configuration:
SL_IOSTREAM_USART_VCOM_BAUDRATE: 115200
SL_IOSTREAM_USART_VCOM_FLOW_CONTROL_TYPE: usartHwFlowControlCtsAndRts
SL_IOSTREAM_USART_VCOM_FLOW_CONTROL_TYPE: usartHwFlowControlNone

c_defines:
SL_CLI_LOCAL_ECHO: 0
Expand Down
4 changes: 2 additions & 2 deletions manifests/smlight/slzb07Mg24_zigbee_router.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ json_config:
- file: "config/zcl/zcl_config.zap"
jq: |
( .endpointTypes[].clusters[].attributes[] | select(.name == "date code"))
.defaultValue = "20241104"
.defaultValue = "20250102"
- file: "config/zcl/zcl_config.zap"
jq: |
Expand All @@ -37,7 +37,7 @@ add_components:

configuration:
SL_IOSTREAM_USART_VCOM_BAUDRATE: 115200
SL_IOSTREAM_USART_VCOM_FLOW_CONTROL_TYPE: usartHwFlowControlCtsAndRts
SL_IOSTREAM_USART_VCOM_FLOW_CONTROL_TYPE: usartHwFlowControlNone

c_defines:
SL_CLI_LOCAL_ECHO: 0
Expand Down
4 changes: 2 additions & 2 deletions manifests/smlight/slzb07_zigbee_router.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ json_config:
- file: "config/zcl/zcl_config.zap"
jq: |
( .endpointTypes[].clusters[].attributes[] | select(.name == "date code"))
.defaultValue = "20241104"
.defaultValue = "20250102"
- file: "config/zcl/zcl_config.zap"
jq: |
Expand All @@ -37,7 +37,7 @@ add_components:

configuration:
SL_IOSTREAM_USART_VCOM_BAUDRATE: 115200
SL_IOSTREAM_USART_VCOM_FLOW_CONTROL_TYPE: usartHwFlowControlCtsAndRts
SL_IOSTREAM_USART_VCOM_FLOW_CONTROL_TYPE: usartHwFlowControlNone

c_defines:
SL_CLI_LOCAL_ECHO: 0
Expand Down
13 changes: 3 additions & 10 deletions src/zigbee_router/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ void sl_zigbee_af_stack_status_cb(sl_status_t status)
sl_zigbee_af_event_set_active(&commissioning_led_event);
} else if (status == SL_STATUS_NETWORK_UP) {
led_turn_on(COMMISSIONING_STATUS_LED);

// Send announcement when coming online so coordinator detects without waiting for ping
sl_zigbee_send_device_announcement();
sl_zigbee_af_event_set_active(&finding_and_binding_event);
}
}
Expand Down Expand Up @@ -367,16 +370,6 @@ void sl_button_on_change(const sl_button_t *handle)
}
#endif // SL_CATALOG_SIMPLE_BUTTON_PRESENT && SL_ZIGBEE_APP_FRAMEWORK_USE_BUTTON_TO_STAY_AWAKE == 0

//Internal testing stuff
#if defined(SL_ZIGBEE_TEST)
void sl_zigbee_af_hal_button_isr_cb(uint8_t button, uint8_t state)
{
if (state == BUTTON_RELEASED) {
sl_zigbee_af_event_set_active(&finding_and_binding_event);
}
}
#endif // SL_ZIGBEE_TEST

#ifdef SL_CATALOG_ZIGBEE_FORCE_SLEEP_AND_WAKEUP_PRESENT
void sli_zigbee_app_framework_force_sleep_callback(void)
{
Expand Down
5 changes: 5 additions & 0 deletions src/zigbee_router/zigbee_router.slcp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,16 @@ component:
- id: zigbee_counters
- id: zigbee_debug_print
- id: zigbee_find_and_bind_target
- id: zigbee_gp
- id: zigbee_green_power_common
- id: zigbee_green_power_client
- id: zigbee_identify
- id: zigbee_interpan
- id: zigbee_network_steering
- id: zigbee_packet_handoff
- id: zigbee_on_off
- id: zigbee_pro_stack
- id: zigbee_reporting
- id: zigbee_scan_dispatch
- id: zigbee_source_route
- id: zigbee_stack_diagnostics
Expand Down

0 comments on commit 936efc0

Please sign in to comment.