Skip to content

Commit

Permalink
Merge pull request #4 from WLANThermo-nano/fix/build
Browse files Browse the repository at this point in the history
Fix/build
  • Loading branch information
sochs committed May 15, 2024
2 parents e1f2ff6 + 5474585 commit d60472d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches:
- master
- develop
- fix/build

jobs:
main:
Expand All @@ -21,7 +22,10 @@ jobs:
pip install -U platformio
pip install -U adafruit-nrfutil
- name: Build
run: platformio run
run: |
wget https://developer.nordicsemi.com/.pc-tools/nrfutil/x64-linux/nrfutil
chmod +x nrfutil
platformio run
- uses: actions/upload-artifact@v1
with:
name: artifacts
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
out
.DS_Store
.vscode/extensions.json
nrfutil
7 changes: 5 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@
core_dir = ./.core

[env]
platform = nordicnrf52@4.0
platform = https://github.com/platformio/platform-nordicnrf52.git#v4.0.0
platform_packages =
; use upstream Git version
framework-arduinoadafruitnrf52 @ https://github.com/tuniii/Adafruit_nRF52_Arduino#0.14.5-fix
framework = arduino
monitor_speed = 115200
build_flags = -DBUILD_TIMESTAMP=$UNIX_TIME
board_build.f_cpu = 64000000L
lib_deps =
ArduinoJson
ArduinoJson@6.13.0 #beim Wechsel auf Version 7 bitte folgendes beachten: www.arduinojson.org/news/2024/01/03/arduinojson-7/
ArduinoLog

[env:wlanthermo_nrf52832]
Expand Down
20 changes: 12 additions & 8 deletions post_extra_script.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Import("env", "projenv")
Import("env")

import shutil
import os
Expand All @@ -8,24 +8,29 @@
import zipfile
import time

if "nrf52840" in str(env["PIOENV"]):
if "nrf52840" in str(env['PIOENV']):
sd_param = "0xB6"
variant = "nrf52840"
else:
sd_param = "0xB7"
variant = "nrf52832"


firmware_file = ".pio/build/" + env["PIOENV"] + "/firmware.hex"
dfu_file = ".pio/build/" + env["PIOENV"] + "/app_dfu_package.zip"
firmware_file = ".pio/build/" + env['PIOENV'] + "/firmware.hex"
dfu_file = ".pio/build/" + env['PIOENV'] + "/app_dfu_package.zip"
out_folder = "out/"
fw_version = env["UNIX_TIME"] #use utc unix time as version
fw_version = int(time.time())

def install_pip(package):
subprocess.call(["pip", "install", "--upgrade", package])

def call_nrfutil():
cmd = "nrfutil pkg generate --hw-version 52 --application-version " + str(fw_version) + " --application " + firmware_file + " --sd-req " + sd_param + " " + dfu_file

# Download from https://www.nordicsemi.com/Products/Development-tools/nRF-Util/Download and put it into project_folder/nrfutil/
cmd = "./nrfutil/nrfutil install nrf5sdk-tools"
args = shlex.split(cmd)
subprocess.call(args)

cmd = "./nrfutil/nrfutil nrf5sdk-tools pkg generate --hw-version 52 --application-version " + str(fw_version) + " --application " + firmware_file + " --sd-req " + sd_param + " " + dfu_file
args = shlex.split(cmd)
subprocess.call(args)

Expand All @@ -45,7 +50,6 @@ def add_version_to_bin_header(header_filename, target_folder, version):

def after_buildprog(source, target, env):
print("Generate DFU files")
install_pip("nrfutil")
call_nrfutil()
if os.path.exists("out") == False:
os.mkdir("out")
Expand Down

0 comments on commit d60472d

Please sign in to comment.