Skip to content

Commit 24ed5b3

Browse files
committed
added custom pio task "Create UF2 file"
1 parent cd92069 commit 24ed5b3

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

create-uf2.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/python3
2+
3+
# Adds PlatformIO post-processing to convert hex files to uf2 files
4+
5+
import os
6+
7+
Import("env")
8+
9+
firmware_hex = "${BUILD_DIR}/${PROGNAME}.hex"
10+
uf2_file = os.environ.get("UF2_FILE_PATH", "${BUILD_DIR}/${PROGNAME}.uf2")
11+
12+
def create_uf2_action(source, target, env):
13+
uf2_cmd = " ".join(
14+
[
15+
'"$PYTHONEXE"',
16+
'"$PROJECT_DIR/bin/uf2conv/uf2conv.py"',
17+
'-f', '0xADA52840',
18+
'-c', firmware_hex,
19+
'-o', uf2_file,
20+
]
21+
)
22+
env.Execute(uf2_cmd)
23+
24+
env.AddCustomTarget(
25+
name="create_uf2",
26+
dependencies=firmware_hex,
27+
actions=create_uf2_action,
28+
title="Create UF2 file",
29+
description="Use uf2conv to convert hex binary into uf2",
30+
always_build=True,
31+
)

platformio.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ platform = https://github.com/pioarduino/platform-espressif32/releases/download/
7676
[nrf52_base]
7777
extends = arduino_base
7878
platform = nordicnrf52
79+
extra_scripts = create-uf2.py
7980
build_flags = ${arduino_base.build_flags}
8081
-D NRF52_PLATFORM
8182
-D LFS_NO_ASSERT=1

0 commit comments

Comments
 (0)