@henglosio/board-rpi-pico 0.0.0-stage → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +80 -0
- package/README.md +18 -3
- package/manifest.yaml +23 -0
- package/package.json +13 -3
- package/src/board.schema.yaml +89 -0
- package/src/firmware.ts +100 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Sustainable Use License
|
|
2
|
+
|
|
3
|
+
Version 1.0
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2026 Henglos — the licensor of Henglos IO.
|
|
6
|
+
|
|
7
|
+
Henglos IO is fair-code: these terms let you use and modify it for your own or your company's
|
|
8
|
+
internal use, and share it free of charge for non-commercial purposes. Any other use — selling it,
|
|
9
|
+
or offering it to others as a paid product or service — needs a separate commercial agreement with
|
|
10
|
+
the licensor.
|
|
11
|
+
|
|
12
|
+
## Acceptance
|
|
13
|
+
|
|
14
|
+
By using the software, you agree to all of the terms and conditions below.
|
|
15
|
+
|
|
16
|
+
## Copyright License
|
|
17
|
+
|
|
18
|
+
The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license
|
|
19
|
+
to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject
|
|
20
|
+
to the limitations below.
|
|
21
|
+
|
|
22
|
+
## Limitations
|
|
23
|
+
|
|
24
|
+
You may use or modify the software only for your own internal business purposes or for non-commercial or
|
|
25
|
+
personal use. You may distribute the software or provide it to others only if you do so free of charge for
|
|
26
|
+
non-commercial purposes. You may not alter, remove, or obscure any licensing, copyright, or other notices of
|
|
27
|
+
the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.
|
|
28
|
+
|
|
29
|
+
## Patents
|
|
30
|
+
|
|
31
|
+
The licensor grants you a license, under any patent claims the licensor can license, or becomes able to
|
|
32
|
+
license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case
|
|
33
|
+
subject to the limitations and conditions in this license. This license does not cover any patent claims that
|
|
34
|
+
you cause to be infringed by modifications or additions to the software. If you or your company make any
|
|
35
|
+
written claim that the software infringes or contributes to infringement of any patent, your patent license
|
|
36
|
+
for the software granted under these terms ends immediately. If your company makes such a claim, your patent
|
|
37
|
+
license ends immediately for work on behalf of your company.
|
|
38
|
+
|
|
39
|
+
## Notices
|
|
40
|
+
|
|
41
|
+
You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these
|
|
42
|
+
terms. If you modify the software, you must include in any modified copies of the software a prominent notice
|
|
43
|
+
stating that you have modified the software.
|
|
44
|
+
|
|
45
|
+
## No Other Rights
|
|
46
|
+
|
|
47
|
+
These terms do not imply any licenses other than those expressly granted in these terms.
|
|
48
|
+
|
|
49
|
+
## Termination
|
|
50
|
+
|
|
51
|
+
If you use the software in violation of these terms, such use is not licensed, and your license will
|
|
52
|
+
automatically terminate. If the licensor provides you with a notice of your violation, and you cease all
|
|
53
|
+
violation of this license no later than 30 days after you receive that notice, your license will be reinstated
|
|
54
|
+
retroactively. However, if you violate these terms after such reinstatement, any additional violation of these
|
|
55
|
+
terms will cause your license to terminate automatically and permanently.
|
|
56
|
+
|
|
57
|
+
## No Liability
|
|
58
|
+
|
|
59
|
+
As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will
|
|
60
|
+
not be liable to you for any damages arising out of these terms or the use or nature of the software, under
|
|
61
|
+
any kind of legal claim.
|
|
62
|
+
|
|
63
|
+
## Definitions
|
|
64
|
+
|
|
65
|
+
The “licensor” is the entity offering these terms.
|
|
66
|
+
|
|
67
|
+
The “software” is the software the licensor makes available under these terms, including any portion of it.
|
|
68
|
+
|
|
69
|
+
“You” refers to the individual or entity agreeing to these terms.
|
|
70
|
+
|
|
71
|
+
“Your company” is any legal entity, sole proprietorship, or other kind of organization that you work for, plus
|
|
72
|
+
all organizations that have control over, are under the control of, or are under common control with that
|
|
73
|
+
organization. Control means ownership of substantially all the assets of an entity, or the power to direct its
|
|
74
|
+
management and policies by vote, contract, or otherwise. Control can be direct or indirect.
|
|
75
|
+
|
|
76
|
+
“Your license” is the license granted to you for the software under these terms.
|
|
77
|
+
|
|
78
|
+
“Use” means anything you do with the software requiring your license.
|
|
79
|
+
|
|
80
|
+
“Trademark” means trademarks, service marks, and similar rights.
|
package/README.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# Raspberry Pi Pico
|
|
2
|
+
|
|
3
|
+
`@henglosio/board-rpi-pico` — a Henglos IO board.
|
|
4
|
+
|
|
5
|
+
The Raspberry Pi Pico (RP2040), ready to use with Henglos IO.
|
|
6
|
+
|
|
7
|
+
## What it brings
|
|
8
|
+
|
|
9
|
+
- Its pins, and what each one can do (digital, analog, PWM, UART…), so the studio only offers the right pins.
|
|
10
|
+
- Its firmware: MicroPython with the Henglos IO platform built in, written by UF2 — the Pico's bootloader drive.
|
|
11
|
+
|
|
12
|
+
## Getting it
|
|
13
|
+
|
|
14
|
+
Pick it when you create a workflow, or change to it from the workflow's settings. To flash it, pick its drive (RPI-RP2): a Pico that isn't in its bootloader is put there through its serial port, or hold BOOTSEL while plugging it in.
|
|
15
|
+
|
|
16
|
+
## License
|
|
17
|
+
|
|
18
|
+
Part of Henglos IO, distributed under the [Sustainable Use License](LICENSE).
|
package/manifest.yaml
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
kind: board
|
|
2
|
+
name: Raspberry Pi Pico
|
|
3
|
+
schemaVersion: 1
|
|
4
|
+
|
|
5
|
+
dependences:
|
|
6
|
+
platform: ^3.0.0
|
|
7
|
+
|
|
8
|
+
ui:
|
|
9
|
+
schema: ./src/board.schema.yaml
|
|
10
|
+
|
|
11
|
+
# The RP2040 offers nothing besides its pins (the Pico W adds Wi-Fi — another board).
|
|
12
|
+
capabilities: []
|
|
13
|
+
|
|
14
|
+
# How MicroPython gets onto it: src/firmware.ts builds MicroPython with the
|
|
15
|
+
# runtime frozen in, in the official image for RP2 boards, and writes it by UF2
|
|
16
|
+
# — the drive the Pico shows in its bootloader (BOOTSEL). `micropython` is also
|
|
17
|
+
# what the runtime and the components are compiled for, with the mpy-cross
|
|
18
|
+
# src/firmware.ts builds — bump it together with the version there.
|
|
19
|
+
firmware:
|
|
20
|
+
micropython: 1.29.0
|
|
21
|
+
image: henglosio/workbench-rp2:1.0.0
|
|
22
|
+
script: ./src/firmware.ts
|
|
23
|
+
methods: [uf2]
|
package/package.json
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@henglosio/board-rpi-pico",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "Raspberry Pi Pico board package for HenglosIO",
|
|
5
|
+
"author": "Henglos",
|
|
6
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
"./manifest.yaml": "./manifest.yaml",
|
|
10
|
+
"./package.json": "./package.json"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"manifest.yaml",
|
|
14
|
+
"src"
|
|
15
|
+
]
|
|
6
16
|
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
name: Raspberry Pi Pico
|
|
2
|
+
description: The Raspberry Pi Pico (RP2040) — 26 GPIOs on its pins (3 analog inputs) and the LED on GP25, written by UF2.
|
|
3
|
+
pins:
|
|
4
|
+
- gpio: 0
|
|
5
|
+
type: [digital_in, digital_out, pwm, uart]
|
|
6
|
+
displayName: GP0
|
|
7
|
+
- gpio: 1
|
|
8
|
+
type: [digital_in, digital_out, pwm, uart]
|
|
9
|
+
displayName: GP1
|
|
10
|
+
- gpio: 2
|
|
11
|
+
type: [digital_in, digital_out, pwm]
|
|
12
|
+
displayName: GP2
|
|
13
|
+
- gpio: 3
|
|
14
|
+
type: [digital_in, digital_out, pwm]
|
|
15
|
+
displayName: GP3
|
|
16
|
+
- gpio: 4
|
|
17
|
+
type: [digital_in, digital_out, pwm, uart]
|
|
18
|
+
displayName: GP4
|
|
19
|
+
- gpio: 5
|
|
20
|
+
type: [digital_in, digital_out, pwm, uart]
|
|
21
|
+
displayName: GP5
|
|
22
|
+
- gpio: 6
|
|
23
|
+
type: [digital_in, digital_out, pwm]
|
|
24
|
+
displayName: GP6
|
|
25
|
+
- gpio: 7
|
|
26
|
+
type: [digital_in, digital_out, pwm]
|
|
27
|
+
displayName: GP7
|
|
28
|
+
- gpio: 8
|
|
29
|
+
type: [digital_in, digital_out, pwm, uart]
|
|
30
|
+
displayName: GP8
|
|
31
|
+
- gpio: 9
|
|
32
|
+
type: [digital_in, digital_out, pwm, uart]
|
|
33
|
+
displayName: GP9
|
|
34
|
+
- gpio: 10
|
|
35
|
+
type: [digital_in, digital_out, pwm]
|
|
36
|
+
displayName: GP10
|
|
37
|
+
- gpio: 11
|
|
38
|
+
type: [digital_in, digital_out, pwm]
|
|
39
|
+
displayName: GP11
|
|
40
|
+
- gpio: 12
|
|
41
|
+
type: [digital_in, digital_out, pwm, uart]
|
|
42
|
+
displayName: GP12
|
|
43
|
+
- gpio: 13
|
|
44
|
+
type: [digital_in, digital_out, pwm, uart]
|
|
45
|
+
displayName: GP13
|
|
46
|
+
- gpio: 14
|
|
47
|
+
type: [digital_in, digital_out, pwm]
|
|
48
|
+
displayName: GP14
|
|
49
|
+
- gpio: 15
|
|
50
|
+
type: [digital_in, digital_out, pwm]
|
|
51
|
+
displayName: GP15
|
|
52
|
+
- gpio: 16
|
|
53
|
+
type: [digital_in, digital_out, pwm, uart]
|
|
54
|
+
displayName: GP16
|
|
55
|
+
- gpio: 17
|
|
56
|
+
type: [digital_in, digital_out, pwm, uart]
|
|
57
|
+
displayName: GP17
|
|
58
|
+
- gpio: 18
|
|
59
|
+
type: [digital_in, digital_out, pwm]
|
|
60
|
+
displayName: GP18
|
|
61
|
+
- gpio: 19
|
|
62
|
+
type: [digital_in, digital_out, pwm]
|
|
63
|
+
displayName: GP19
|
|
64
|
+
- gpio: 20
|
|
65
|
+
type: [digital_in, digital_out, pwm]
|
|
66
|
+
displayName: GP20
|
|
67
|
+
- gpio: 21
|
|
68
|
+
type: [digital_in, digital_out, pwm]
|
|
69
|
+
displayName: GP21
|
|
70
|
+
- gpio: 22
|
|
71
|
+
type: [digital_in, digital_out, pwm]
|
|
72
|
+
displayName: GP22
|
|
73
|
+
- gpio: 25
|
|
74
|
+
type: [digital_in, digital_out, pwm]
|
|
75
|
+
displayName: GP25 (LED)
|
|
76
|
+
- gpio: 26
|
|
77
|
+
type: [digital_in, digital_out, analog_in, pwm]
|
|
78
|
+
displayName: GP26
|
|
79
|
+
- gpio: 27
|
|
80
|
+
type: [digital_in, digital_out, analog_in, pwm]
|
|
81
|
+
displayName: GP27
|
|
82
|
+
- gpio: 28
|
|
83
|
+
type: [digital_in, digital_out, analog_in, pwm]
|
|
84
|
+
displayName: GP28
|
|
85
|
+
connection:
|
|
86
|
+
serial:
|
|
87
|
+
# USB CDC: the speed isn't used on the wire, but the driver opens the port
|
|
88
|
+
# at the first one.
|
|
89
|
+
baudrates: [115200, 9600, 19200, 38400, 57600, 230400, 460800, 921600]
|
package/src/firmware.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { BoardFirmware, BoardPrepareContext } from "@henglosio/runner";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
|
|
6
|
+
// ── The board ────────────────────────────────────────────────────────────────
|
|
7
|
+
// MicroPython's port and board (its folder under ports/<port>/boards).
|
|
8
|
+
const PORT = "rp2";
|
|
9
|
+
const BOARD = "RPI_PICO";
|
|
10
|
+
|
|
11
|
+
// The stock MicroPython for the Pico, written when the board has no firmware of
|
|
12
|
+
// its own — same version as the manifest's firmware.micropython. Written by UF2:
|
|
13
|
+
// the Pico shows a drive (RPI-RP2) in its bootloader.
|
|
14
|
+
const STOCK = "https://micropython.org/resources/firmware/RPI_PICO-20260824-v1.29.0.uf2";
|
|
15
|
+
|
|
16
|
+
const MICROPYTHON_REPO = "https://github.com/micropython/micropython.git";
|
|
17
|
+
|
|
18
|
+
type Context = Pick<BoardPrepareContext, "run" | "log">;
|
|
19
|
+
|
|
20
|
+
export default {
|
|
21
|
+
|
|
22
|
+
// Once per MicroPython version (hio runs it under the cache's lock, and only
|
|
23
|
+
// until it succeeds), all in ctx.cache: MicroPython's checkout, the rp2
|
|
24
|
+
// port's submodules (the pico-sdk…), and its mpy-cross — what the runtime and
|
|
25
|
+
// the components are compiled with (the port's build uses it too).
|
|
26
|
+
async prepare(ctx) {
|
|
27
|
+
const micropython = micropythonDir(ctx.cache, ctx.micropython);
|
|
28
|
+
await cloneOnce(ctx, "MicroPython v" + ctx.micropython, MICROPYTHON_REPO, "v" + ctx.micropython, micropython);
|
|
29
|
+
|
|
30
|
+
await ctx.log("[prepare] the " + PORT + " port's submodules (pico-sdk…)\n");
|
|
31
|
+
await ctx.run("make", ["-C", path.join(micropython, "ports", PORT), "BOARD=" + BOARD, "submodules"]);
|
|
32
|
+
|
|
33
|
+
const mpyCross = path.join(micropython, "mpy-cross");
|
|
34
|
+
await ctx.run("make", ["-C", mpyCross, jobs()]);
|
|
35
|
+
return { mpyCross: path.join(mpyCross, "build", "mpy-cross") };
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
// MicroPython with the runtime frozen in, so it runs from flash and the RAM is
|
|
39
|
+
// left to the workflow. Same version and layout as STOCK, so the board's
|
|
40
|
+
// filesystem stays. Incremental: only what changed compiles again.
|
|
41
|
+
async build(ctx) {
|
|
42
|
+
const micropython = micropythonDir(ctx.cache, ctx.micropython);
|
|
43
|
+
const portDir = path.join(micropython, "ports", PORT);
|
|
44
|
+
await ctx.log("[firmware] MicroPython v" + ctx.micropython + " · " + PORT + "/" + BOARD + "\n");
|
|
45
|
+
|
|
46
|
+
// No BUILD= here: a variable on make's command line reaches every sub-make,
|
|
47
|
+
// mpy-cross's too. The port's default, build-<BOARD>, sits in the checkout,
|
|
48
|
+
// which is per version already.
|
|
49
|
+
await ctx.run("make", ["-C", portDir, "BOARD=" + BOARD, "FROZEN_MANIFEST=" + ctx.freezeManifest, jobs()]);
|
|
50
|
+
|
|
51
|
+
fs.copyFileSync(path.join(portDir, "build-" + BOARD, "firmware.uf2"), ctx.firmwareOutput);
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
// ctx.firmware (build's, the runtime frozen in) — or the stock one — by UF2:
|
|
55
|
+
// the driver copies it to the Pico's drive, and the Pico restarts into it. UF2
|
|
56
|
+
// can't erase the flash first (ctx.erase): the filesystem stays where it was.
|
|
57
|
+
async flash(ctx) {
|
|
58
|
+
let firmware = ctx.firmware ?? STOCK;
|
|
59
|
+
if (/^https?:\/\//.test(firmware)) {
|
|
60
|
+
firmware = await downloadOnce(ctx, firmware, path.join(ctx.cache, "firmware", path.basename(firmware.split("?")[0]!)));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (ctx.method !== "uf2") throw new Error("The Raspberry Pi Pico is written by UF2 only.");
|
|
64
|
+
await ctx.send("uf2", { file: firmware });
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
} satisfies BoardFirmware;
|
|
68
|
+
|
|
69
|
+
// ── Helpers ──────────────────────────────────────────────────────────────────
|
|
70
|
+
|
|
71
|
+
// Where MicroPython `version` is checked out, in the cache.
|
|
72
|
+
const micropythonDir = (cache: string, version: string) => path.join(cache, "micropython", "v" + version);
|
|
73
|
+
|
|
74
|
+
// As many make jobs as the container has cores.
|
|
75
|
+
const jobs = () => "-j" + os.availableParallelism();
|
|
76
|
+
|
|
77
|
+
// Clones `ref` of `repo` into `dir`, unless it's there already — through a
|
|
78
|
+
// .partial folder, so an interrupted clone is never mistaken for a finished one.
|
|
79
|
+
async function cloneOnce(ctx: Context, label: string, repo: string, ref: string, dir: string): Promise<void> {
|
|
80
|
+
if (fs.existsSync(path.join(dir, ".git"))) return;
|
|
81
|
+
await ctx.log("[firmware] fetching " + label + "\n");
|
|
82
|
+
const partial = dir + ".partial";
|
|
83
|
+
fs.rmSync(partial, { recursive: true, force: true });
|
|
84
|
+
fs.mkdirSync(path.dirname(dir), { recursive: true });
|
|
85
|
+
await ctx.run("git", ["clone", "--quiet", "--depth", "1", "--branch", ref, repo, partial]);
|
|
86
|
+
fs.renameSync(partial, dir);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Downloads `url` to `file` once — through a .partial file, so a cut download
|
|
90
|
+
// is never used.
|
|
91
|
+
async function downloadOnce(ctx: Context, url: string, file: string): Promise<string> {
|
|
92
|
+
if (fs.existsSync(file)) return file;
|
|
93
|
+
await ctx.log("[flash] downloading " + url + "\n");
|
|
94
|
+
const response = await fetch(url);
|
|
95
|
+
if (!response.ok) throw new Error("Downloading " + url + " failed: HTTP " + response.status);
|
|
96
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
97
|
+
fs.writeFileSync(file + ".partial", Buffer.from(await response.arrayBuffer()));
|
|
98
|
+
fs.renameSync(file + ".partial", file);
|
|
99
|
+
return file;
|
|
100
|
+
}
|