Skip to content

Commit

Permalink
Merge pull request #137 from gyroflow/add-build-ci
Browse files Browse the repository at this point in the history
Add build ci
  • Loading branch information
DusKing1 authored Jun 23, 2022
2 parents eda4f30 + f888dad commit b0a1673
Show file tree
Hide file tree
Showing 10 changed files with 157 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Build Firmware

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

workflow_dispatch:
branches: [ master ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup Python
uses: actions/setup-python@v3
with:
python-version: "3.10.4"

- name: Build modules
run: |
python3 tools/build.py
- name: Prepare esp-idf and micropython
run: |
git clone -b v4.2 --recursive https://github.com/espressif/esp-idf.git
git clone https://github.com/micropython/micropython.git micropython
- name: Install modules
run: |
cp -a build/. micropython/ports/esp32/modules/
- name: Build ESP32 GENERIC v1.19.1
run: |
cd esp-idf
./install.sh
source export.sh
cd ..
cd micropython
git checkout 9b486340da22931cde82872f79e1c34db959548b
git submodule update --init --recursive
make -C mpy-cross
cd ports/esp32
make submodules
make
- name: Upload artifacts
uses: actions/upload-artifact@v1
with:
name: flowshutter-${{ github.run_number }}
path: micropython/ports/esp32/build-GENERIC/firmware.bin
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ pymakr.conf
.DS_Store
*~
check_sha.json
build
micropython
esp-idf
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"yaml.schemas": {
"https://json.schemastore.org/github-workflow.json": "file:///f%3A/GitHub/flowshutter/.github/workflows/build.yml"
}
}
13 changes: 13 additions & 0 deletions build/_boot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import gc
import uos
from flashbdev import bdev

try:
if bdev:
uos.mount(bdev, "/")
except OSError:
import inisetup

vfs = inisetup.setup()

gc.collect()
8 changes: 8 additions & 0 deletions build/apa106.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# APA106driver for MicroPython on ESP32
# MIT license; Copyright (c) 2016 Damien P. George

from neopixel import NeoPixel


class APA106(NeoPixel):
ORDER = (0, 1, 2, 3)
7 changes: 7 additions & 0 deletions build/flashbdev.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from esp32 import Partition

# MicroPython's partition table uses "vfs", TinyUF2 uses "ffat".
bdev = Partition.find(Partition.TYPE_DATA, label="vfs")
if not bdev:
bdev = Partition.find(Partition.TYPE_DATA, label="ffat", block_size=512)
bdev = bdev[0] if bdev else None
47 changes: 47 additions & 0 deletions build/inisetup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import uos
from flashbdev import bdev


def check_bootsec():
buf = bytearray(bdev.ioctl(5, 0)) # 5 is SEC_SIZE
bdev.readblocks(0, buf)
empty = True
for b in buf:
if b != 0xFF:
empty = False
break
if empty:
return True
fs_corrupted()


def fs_corrupted():
import time

while 1:
print(
"""\
The filesystem appears to be corrupted. If you had important data there, you
may want to make a flash snapshot to try to recover it. Otherwise, perform
factory reprogramming of MicroPython firmware (completely erase flash, followed
by firmware programming).
"""
)
time.sleep(3)


def setup():
check_bootsec()
print("Performing initial setup")
uos.VfsLfs2.mkfs(bdev)
vfs = uos.VfsLfs2(bdev)
uos.mount(vfs, "/")
with open("boot.py", "w") as f0:
f0.write("import startup")
f0.close()

with open("main.py", "w") as f1:
f1.write("import entry")
f1.close()

return vfs
18 changes: 18 additions & 0 deletions tools/build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import os

files = os.listdir("src/")

try:
files.remove("boot.py")
files.remove("LICENSE")
files.remove("main.py")
files.remove("README.md")
files.remove("sha.json")
except ValueError:
pass

files = sorted(files)

import shutil
for f in files:
shutil.copyfile('src/'+f, 'build/'+f)
Binary file removed tools/esp32-20220117-v1.18.bin
Binary file not shown.
Binary file added tools/esp32-20220618-v1.19.1.bin
Binary file not shown.

0 comments on commit b0a1673

Please sign in to comment.