Skip to content

Commit ae7e02a

Browse files
committed
Build and Release via GH Actions
1 parent f66c4a2 commit ae7e02a

9 files changed

Lines changed: 150 additions & 132 deletions

File tree

.github/workflows/build.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Build and Release
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- name: Docker build
17+
run: docker build --platform linux/amd64 --tag si-moko .
18+
19+
- name: Docker run
20+
run: docker run --platform linux/amd64 --env "PUBLIC_KEY_HEX=${{ secrets.PUBLIC_KEY_HEX }}" --name firmware-container si-moko
21+
22+
- name: Copy firmware from container
23+
run: docker cp firmware-container:/spaceinvader/firmware.bin $GITHUB_WORKSPACE/firmware.bin
24+
25+
- name: Create Release
26+
id: create_release
27+
uses: actions/create-release@v1
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
with:
31+
tag_name: ${{ github.ref }}
32+
release_name: Release ${{ github.ref }}
33+
34+
- name: Upload Release Asset
35+
uses: actions/upload-release-asset@v1
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
with:
39+
upload_url: ${{ steps.create_release.outputs.upload_url }}
40+
asset_path: $GITHUB_WORKSPACE/firmware.bin
41+
asset_name: firmware.bin
42+
asset_content_type: application/octet-stream

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@ dkms.conf
5454
apps/firmware/build/_build/
5555
.DS_Store
5656
apps/firmware/dfu_images/private.key
57-
apps/firmware/dfu_images/public_key.c
57+
# apps/firmware/dfu_images/public_key.c
5858
_build/

Dockerfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
FROM debian:bookworm-slim as build-env
2+
3+
# Install OS packages
4+
RUN apt-get update
5+
RUN apt-get install -y git build-essential wget
6+
7+
# https://github.com/micropython/micropython/issues/8685
8+
RUN wget --quiet "https://developer.arm.com/-/media/Files/downloads/gnu/11.3.rel1/binrel/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi.tar.xz?rev=95edb5e17b9d43f28c74ce824f9c6f10&hash=D5ACE3A6F75F603551D7702E00ED7B29" -O /tmp/arm-gnu-toolchain.tar.xz
9+
RUN tar -xf /tmp/arm-gnu-toolchain.tar.xz -C /usr/local/
10+
ENV PATH="/usr/local/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin:${PATH}"
11+
12+
# Install nrfutil
13+
RUN echo "deb http://ftp.dk.debian.org/debian bullseye main" >/etc/apt/sources.list
14+
RUN apt-get update
15+
RUN apt-get install -y python2 python2-dev
16+
RUN wget --quiet "https://bootstrap.pypa.io/pip/2.7/get-pip.py" -O /tmp/get-pip.py
17+
RUN python2 /tmp/get-pip.py
18+
RUN pip install nrfutil
19+
# mergehex is not included in nrfutil
20+
RUN apt-get install -y libusb-1.0-0
21+
RUN wget --quiet "https://nsscprodmedia.blob.core.windows.net/prod/software-and-other-downloads/desktop-software/nrf-command-line-tools/sw/versions-10-x-x/10-23-2/nrf-command-line-tools_10.23.2_amd64.deb" -O /tmp/nrf-command-line-tools.deb
22+
RUN dpkg -i /tmp/nrf-command-line-tools.deb
23+
ENV PATH="/opt/nrf-command-line-tools/bin:${PATH}"
24+
25+
# Copy all files from the current directory into the build-env container
26+
RUN mkdir -p /spaceinvader
27+
COPY . /spaceinvader
28+
29+
ENTRYPOINT ["/spaceinvader/build.sh"]

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022 SpaceInvader Europe Aps
3+
Copyright (c) 2022 SpaceInvader Europe ApS
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

ReadMe.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# OpenHaystack - Moko
2+
3+
This is an internal project developed by [Antonio Calatrava](https://github.com/acalatrava) for [SpaceInvader](https://www.spaceinvader.com/) to create a OpenHaystack compatible device on a Moko M1 and Moko M2.
4+
5+
In November 2023, SpaceInvader open sourced the project under the MIT license.
6+
7+
Currently the firmware is compatible with the following models:
8+
9+
- Moko M1-PNDA
10+
- Moko M2-PNDA-HA
11+
12+
The firmware support DFU updating.
13+
14+
### Compile the firmware
15+
16+
Follow instructions in the `apps` and `apps/firmware` folders.
17+
18+
### Compile via Docker
19+
20+
docker build --platform linux/amd64 --tag si-moko .
21+
docker run --rm --platform linux/amd64 --env "PUBLIC_KEY_HEX=0x00" si-moko

apps/README.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,32 @@
1-
# openhaystack_moko
2-
This is an internal project developed by Antonio Calatrava for SpaceInvader Europe Aps to create a OpenHaystack compatible device on a Moko M1 and Moko M2 devices.
1+
# OpenHaystack - Moko
32

4-
In November 2023, SpaceInvader Europe Aps open sourced the project under the MIT license so others may benefit and contribute further.
3+
This is an internal project developed by [Antonio Calatrava](https://github.com/acalatrava) for [SpaceInvader](https://www.spaceinvader.com/) to create a OpenHaystack compatible device on a Moko M1 and Moko M2 devices.
4+
5+
In November 2023, SpaceInvader open sourced the project under the MIT license so others may benefit and contribute further.
56

67
Currently this firmware is compatible with the following models:
7-
Moko M1-PNDA
8-
Moko M2-PNDA-HA
8+
9+
- Moko M1-PNDA
10+
- Moko M2-PNDA-HA
911

1012
This firmware support DFU updating, this way you can generate tags and deploy them over the air.
1113

12-
## Setting up
14+
## Setting up (Mac)
1315

1416
### Get submodules
17+
1518
```
1619
git submodule init
1720
git submodule update
1821
```
1922

2023
### Install required dependencies
21-
- nRF command line tools
22-
`brew tap homebrew/cask-drivers; brew install --cask nordic-nrf-command-line-tools`
2324

24-
- binutils
25-
`brew install binutils`
25+
- nRF command line tools
26+
`brew tap homebrew/cask-drivers; brew install --cask nordic-nrf-command-line-tools`
2627

27-
- gcc-arm-none-eabi
28-
`brew install --cask gcc-arm-embedded`
28+
- binutils
29+
`brew install binutils`
2930

30-
### Compile the firmware
31-
Follow instructions on the `apps` folder
31+
- gcc-arm-none-eabi
32+
`brew install --cask gcc-arm-embedded`

apps/firmware/dfu_images/generate_dat.js

Lines changed: 0 additions & 116 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include "compiler_abstraction.h"
2+
#include "stdint.h"
3+
4+
/** @brief Public key used to verify DFU images */
5+
__ALIGN(4)
6+
const uint8_t pk[64] = {/* PUBLIC_KEY_PLACEHOLDER */};

build.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/sh
2+
3+
# Set working directory
4+
WORKSPACE=/spaceinvader
5+
6+
# Initialize and update git submodules
7+
git submodule init
8+
git submodule update
9+
10+
# Compile micro-ecc library
11+
cd $WORKSPACE/apps/secure_bootloader/micro-ecc-build
12+
make
13+
14+
# Set the public key for the secure bootloader
15+
sed -i "s/\/\* PUBLIC_KEY_PLACEHOLDER \*\//$PUBLIC_KEY_HEX/" $WORKSPACE/apps/firmware/dfu_images/public_key.c
16+
17+
# Compile secure bootloader
18+
cd $WORKSPACE/apps/secure_bootloader/build
19+
make
20+
cp $WORKSPACE/apps/firmware/build/_build/secure_bootloader_moko.hex $WORKSPACE/apps/firmware/dfu_images
21+
22+
# Compile firmware
23+
cd $WORKSPACE/apps/firmware/build
24+
make
25+
26+
# Generate DFU settings
27+
cd $WORKSPACE/apps/firmware/dfu_images
28+
cp $WORKSPACE/apps/firmware/build/_build/nrf52810_xxaa.hex .
29+
nrfutil settings generate --family NRF52810 --application nrf52810_xxaa.hex --application-version 1 --bootloader-version 1 --bl-settings-version 2 bl_settings.hex
30+
31+
# Merge hex files
32+
mergehex -m bl_settings.hex secure_bootloader_moko.hex nrf52810_xxaa.hex ../../../nRF5_SDK_17.0.2_d674dde/components/softdevice/s112/hex/s112_nrf52_7.2.0_softdevice.hex --output full_dfu.hex
33+
34+
# Convert the HEX file to a BIN file
35+
arm-none-eabi-objcopy -I ihex -O binary full_dfu.hex $WORKSPACE/firmware.bin

0 commit comments

Comments
 (0)