Skip to content

Commit

Permalink
Add support for Raspberry Pi Pico 2 RISC-V boards in build configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
playday3008 committed Jan 8, 2025
1 parent 7b1e305 commit a0108b9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/zig-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
board: [pico, pico_w, pico2, pico2_w]
board: [pico, pico_w, pico2, pico2_w, pico2-riscv, pico2-riscv_w]
optimize: [Debug, ReleaseSafe, ReleaseFast, ReleaseSmall]
zig: [latest]

Expand Down
2 changes: 1 addition & 1 deletion build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ pub fn build(b: *std.Build) !void {
b.fmt("-DHOST_ARCH:STRING={s}", .{@tagName(builtin.cpu.arch)}),
b.fmt("-DPICO_ARCH:STRING={s}", .{board.platform.arch.str()}),
// Pico SDK settings
b.fmt("-DPICO_BOARD:STRING={s}", .{board.name}),
b.fmt("-DPICO_BOARD:STRING={s}", .{if (board.cmake_name) |name| name else board.name}),
b.fmt("-DPICO_PLATFORM:STRING={s}", .{board.platform.str()}),
// Pico C++ settings
b.fmt("-DPICO_CXX_ENABLE_EXCEPTIONS:BOOL={s}", .{"OFF"}),
Expand Down
17 changes: 17 additions & 0 deletions pico.zig
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ const Wireless = enum {
/// Raspberry Pi Pico boards
const Board = struct {
name: [:0]const u8,
cmake_name: ?[:0]const u8 = null,
platform: Platform,
wireless: Wireless,
};
Expand Down Expand Up @@ -160,12 +161,28 @@ pub const Pico2W = Board{
.platform = Pico2.platform,
.wireless = Wireless.CYW43439,
};
/// Raspberry Pi Pico 2 (RISC-V)
pub const Pico2Riscv = Board{
.name = "pico2-riscv",
.cmake_name = "pico2",
.platform = Platform.init(.RP2350, .RISCV),
.wireless = Wireless.None,
};
/// Raspberry Pi Pico 2 W (RISC-V)
pub const Pico2RiscvW = Board{
.name = Pico2Riscv.name ++ "_w",
.cmake_name = Pico2Riscv.cmake_name.? ++ "_w",
.platform = Pico2Riscv.platform,
.wireless = Wireless.CYW43439,
};

pub const Boards = &[_]Board{
Pico,
PicoW,
Pico2,
Pico2W,
Pico2Riscv,
Pico2RiscvW,
};

/// Standard I/O configuration
Expand Down

0 comments on commit a0108b9

Please sign in to comment.