From fee5612088f270f3e98977f381ba331225a3d0d2 Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 12 Dec 2023 18:02:26 +0700 Subject: [PATCH 1/4] try to add gh action --- .github/workflows/build.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..3453a51e --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,36 @@ +name: Build + +on: + workflow_dispatch: + push: + pull_request: + branches: [ master ] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + build-esp: + runs-on: ubuntu-latest + steps: + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + - name: Pull ESP-IDF docker + run: docker pull espressif/idf:v3.3.1 + + - name: Checkout + uses: actions/checkout@v3 + + - name: Build + run: docker run --rm -v $PWD:/project -w /project espressif/idf:v3.3.1 make firmware + + - name: Upload Artifacts + uses: actions/upload-artifact@v3 + with: + name: NINA_W102-${{ github.sha }} + path: | + NINA_W102*.bin From f808187589a75c408ef0186c4177eb2aab507e56 Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 12 Dec 2023 18:14:40 +0700 Subject: [PATCH 2/4] gh action upload bin when making release --- .github/workflows/build.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3453a51e..5fbe322e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,7 @@ concurrency: cancel-in-progress: true jobs: - build-esp: + build: runs-on: ubuntu-latest steps: - name: Setup Python @@ -34,3 +34,10 @@ jobs: name: NINA_W102-${{ github.sha }} path: | NINA_W102*.bin + + - name: Upload Release Asset + uses: softprops/action-gh-release@v1 + if: ${{ github.event_name == 'release' }} + with: + files: | + NINA_W102*.bin From 052e25993a36d178ee66744d79c107426fbeba97 Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 12 Dec 2023 18:16:33 +0700 Subject: [PATCH 3/4] more gh action update --- .github/workflows/build.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5fbe322e..6b15dad3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,10 +1,13 @@ name: Build on: - workflow_dispatch: + repository_dispatch: push: pull_request: branches: [ master ] + release: + types: + - created concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} From a399c40f534418cc33217ddc7a72022031fa16e1 Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 12 Dec 2023 19:04:15 +0700 Subject: [PATCH 4/4] reduce version duplication - combine.py extract version from CommandHandler.cpp - make load-nina use wildcard to load bin file --- Makefile | 2 +- README.md | 4 +--- combine.py | 15 ++++++++++++++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 779a317c..5cdbf2ee 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ load-passthrough: cp passthrough.UF2 $(BOOT_VOLUME) load-nina: - esptool.py --port $(M4_PORT) --before no_reset --baud $(UPLOAD_BAUD) write_flash 0 NINA_W102-1.7.6.bin + esptool.py --port $(M4_PORT) --before no_reset --baud $(UPLOAD_BAUD) write_flash 0 $(wildcard NINA_W102-*.bin) load-circuitpython: cp $(CIRCUITPYTHON_UF2) $(BOOT_VOLUME) diff --git a/README.md b/README.md index b7e6c62e..f047d910 100644 --- a/README.md +++ b/README.md @@ -15,10 +15,8 @@ Contributors who follow the [Code of Conduct](https://github.com/adafruit/nina-f are welcome to submit pull requests and they will be promptly reviewed by project admins. Please join the [Discord](https://adafru.it/discord) too. -The NINA firmware version needs to be updated in four places in this repo: +The NINA firmware version needs to be updated in two places in this repo: 1. CommandHandler.cpp -1. combine.py -1. Makefile 1. CHANGELOG ## Building diff --git a/combine.py b/combine.py index 92fad82a..22478016 100644 --- a/combine.py +++ b/combine.py @@ -2,6 +2,17 @@ import sys; + +def extract_firmware_version(): + with open('main/CommandHandler.cpp', 'r') as file: + for line in file: + if 'const char FIRMWARE_VERSION[6] = ' in line: + # The line format is `const char FIRMWARE_VERSION[6] = "1.7.6";` + # Split by double quote and get the second element + version = line.split('"')[1] + return version + + booloaderData = open("build/bootloader/bootloader.bin", "rb").read() partitionData = open("build/partitions.bin", "rb").read() appData = open("build/nina-fw.bin", "rb").read() @@ -31,7 +42,9 @@ # zero terminate the pem file outputData[0x10000 + len(certsData)] = 0 -outputFilename = "NINA_W102-1.7.6.bin" +version = extract_firmware_version() +outputFilename = f"NINA_W102-{version}.bin" + if (len(sys.argv) > 1): outputFilename = sys.argv[1]