Skip to content

Commit 097d4a6

Browse files
authored
Merge pull request #1 from SpaceInvaderTech/actions
Build and Release via GitHub Actions
2 parents 08563a2 + 67872f6 commit 097d4a6

10 files changed

Lines changed: 178 additions & 149 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/dist/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: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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 "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+
RUN rm /tmp/arm-gnu-toolchain.tar.xz
11+
ENV PATH="/usr/local/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin:${PATH}"
12+
13+
# Install nrfutil
14+
RUN echo "deb http://ftp.us.debian.org/debian bullseye main" >/etc/apt/sources.list
15+
RUN apt-get update
16+
RUN apt-get install -y python2 python2-dev
17+
RUN wget "https://bootstrap.pypa.io/pip/2.7/get-pip.py" -O /tmp/get-pip.py
18+
RUN python2 /tmp/get-pip.py
19+
RUN rm /tmp/get-pip.py
20+
RUN pip install nrfutil
21+
# mergehex is not included in nrfutil
22+
RUN apt-get install -y libusb-1.0-0
23+
RUN wget "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
24+
RUN dpkg -i /tmp/nrf-command-line-tools.deb
25+
RUN rm /tmp/nrf-command-line-tools.deb
26+
ENV PATH="/opt/nrf-command-line-tools/bin:${PATH}"
27+
28+
# Copy all files from the current directory into the build-env container
29+
RUN mkdir -p /spaceinvader
30+
COPY . /spaceinvader
31+
32+
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: 0 additions & 31 deletions
This file was deleted.

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: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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 devices.
4+
5+
In November 2023, SpaceInvader open sourced the project under the MIT license so others may benefit and contribute further.
6+
7+
Currently this firmware is compatible with the following models:
8+
9+
- Moko M1-PNDA
10+
- Moko M2-PNDA-HA
11+
12+
This firmware support DFU updating, this way you can generate tags and deploy them over the air.
13+
14+
## Setting up (Mac)
15+
16+
### Get submodules
17+
18+
```
19+
git submodule init
20+
git submodule update
21+
```
22+
23+
### Install required dependencies
24+
25+
- nRF command line tools
26+
`brew tap homebrew/cask-drivers; brew install --cask nordic-nrf-command-line-tools`
27+
28+
- binutils
29+
`brew install binutils`
30+
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: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/sh
2+
3+
# Exit on error
4+
set -e
5+
6+
# Set working directory
7+
WORKSPACE=/spaceinvader
8+
cd $WORKSPACE
9+
10+
# Make directories for hexadecimal files and the final binary
11+
mkdir $WORKSPACE/hex
12+
mkdir $WORKSPACE/dist
13+
14+
# Initialize and update git submodules
15+
git submodule init
16+
git submodule update
17+
18+
# Compile micro-ecc library
19+
make --directory=$WORKSPACE/apps/secure_bootloader/micro-ecc-build
20+
21+
# Set the public key for the secure bootloader
22+
sed -i "s/\/\* PUBLIC_KEY_PLACEHOLDER \*\//$PUBLIC_KEY_HEX/" $WORKSPACE/apps/firmware/dfu_images/public_key.c
23+
24+
# Compile secure bootloader
25+
make --directory=$WORKSPACE/apps/secure_bootloader/build
26+
mv $WORKSPACE/apps/secure_bootloader/build/_build/secure_bootloader_moko.hex $WORKSPACE/hex
27+
28+
# Compile firmware
29+
make --directory=$WORKSPACE/apps/firmware/build
30+
mv $WORKSPACE/apps/firmware/build/_build/nrf52810_xxaa.hex $WORKSPACE/hex
31+
32+
# Make hexadecimal files
33+
cd $WORKSPACE/hex
34+
35+
# Generate DFU settings
36+
nrfutil settings generate --family NRF52810 --application nrf52810_xxaa.hex --application-version 1 --bootloader-version 1 --bl-settings-version 2 bl_settings.hex
37+
38+
# Merge hex files
39+
cp $WORKSPACE/nRF5_SDK_17.0.2_d674dde/components/softdevice/s112/hex/s112_nrf52_7.2.0_softdevice.hex $WORKSPACE/hex
40+
mergehex --merge bl_settings.hex secure_bootloader_moko.hex nrf52810_xxaa.hex s112_nrf52_7.2.0_softdevice.hex --output firmware.hex
41+
42+
# Convert the HEX file to a BIN file
43+
arm-none-eabi-objcopy --input-target=ihex --output-target=binary firmware.hex $WORKSPACE/dist/firmware.bin

0 commit comments

Comments
 (0)