Microzig Generation 2 Build Interface (#82)
* Starts to rework build framework. * First building version. * Documents paths to supported devices. * Tiny fix for MicroZig. * Drops CI --------- Co-authored-by: Felix "xq" Queißner <git@random-projects.net>
This commit is contained in:
parent
2a0c0ff281
commit
d9cbc3654e
|
@ -1,5 +0,0 @@
|
|||
steps:
|
||||
- name: Build Examples
|
||||
command: zig build
|
||||
- name: Test
|
||||
command: zig build test
|
22
.github/workflows/build.yml
vendored
22
.github/workflows/build.yml
vendored
|
@ -1,22 +0,0 @@
|
|||
name: Build
|
||||
on:
|
||||
push:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [
|
||||
ubuntu-latest,
|
||||
windows-latest,
|
||||
macos-latest,
|
||||
]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: goto-bus-stop/setup-zig@v1.3.0
|
||||
with:
|
||||
version: 0.11.0
|
||||
|
||||
- name: Build and Unit Test
|
||||
run: zig build test -Doptimize=ReleaseSmall
|
12
README.adoc
12
README.adoc
|
@ -8,8 +8,10 @@ HAL and register definitions for the RP2040.
|
|||
|
||||
== Supported devices ==
|
||||
|
||||
- Raspberry Pi Pico
|
||||
- (*experimental*) Waveshare RP2040-Plus (4M Flash)
|
||||
- (*experimental*) Waveshare RP2040-Plus (16M Flash)
|
||||
- (*experimental*) Waveshare RP2040-ETH Mini
|
||||
- (*experimental*) Waveshare RP2040-Matrix
|
||||
- Raspberry Pi RP2040 (`chips.rp2040`)
|
||||
- Raspberry Pi Pico (`boards.raspberry_pi.pico`)
|
||||
- (*experimental*) Waveshare RP2040-Plus (4M Flash) (`boards.waveshare.rp2040_plus_4m`)
|
||||
- (*experimental*) Waveshare RP2040-Plus (16M Flash) (`boards.waveshare.rp2040_plus_16m`)
|
||||
- (*experimental*) Waveshare RP2040-ETH Mini (`boards.waveshare.rp2040_eth`)
|
||||
- (*experimental*) Waveshare RP2040-Matrix (`boards.waveshare.rp2040_matrix`)
|
||||
|
||||
|
|
358
build.zig
358
build.zig
|
@ -1,15 +1,101 @@
|
|||
const std = @import("std");
|
||||
const Build = std.Build;
|
||||
const comptimePrint = std.fmt.comptimePrint;
|
||||
|
||||
const microzig = @import("microzig");
|
||||
|
||||
pub const chips = @import("src/chips.zig");
|
||||
pub const boards = @import("src/boards.zig");
|
||||
const microzig = @import("root").dependencies.imports.microzig; // HACK: Please import MicroZig always under the name `microzig`. Otherwise the RP2040 module will fail to be properly imported.
|
||||
|
||||
fn root() []const u8 {
|
||||
return comptime (std.fs.path.dirname(@src().file) orelse ".");
|
||||
}
|
||||
const build_root = root();
|
||||
|
||||
const linkerscript_path = build_root ++ "/rp2040.ld";
|
||||
////////////////////////////////////////
|
||||
// MicroZig Gen 2 Interface //
|
||||
////////////////////////////////////////
|
||||
|
||||
pub fn build(b: *std.Build) !void {
|
||||
// Dummy func to make package manager happy
|
||||
_ = b;
|
||||
}
|
||||
|
||||
pub const chips = struct {
|
||||
// Note: This chip has no flash support defined and requires additional configuration!
|
||||
pub const rp2040 = .{
|
||||
.preferred_format = .{ .uf2 = .RP2040 },
|
||||
.chip = chip,
|
||||
.hal = hal,
|
||||
.board = null,
|
||||
.linker_script = linker_script,
|
||||
};
|
||||
};
|
||||
|
||||
pub const boards = struct {
|
||||
pub const raspberry_pi = struct {
|
||||
pub const pico = .{
|
||||
.preferred_format = .{ .uf2 = .RP2040 },
|
||||
.chip = chip,
|
||||
.hal = hal,
|
||||
.linker_script = linker_script,
|
||||
.board = .{
|
||||
.name = "RaspberryPi Pico",
|
||||
.source_file = .{ .cwd_relative = build_root ++ "/src/boards/raspberry_pi_pico.zig" },
|
||||
.url = "https://www.raspberrypi.com/products/raspberry-pi-pico/",
|
||||
},
|
||||
.configure = rp2040_configure(.w25q080),
|
||||
};
|
||||
};
|
||||
|
||||
pub const waveshare = struct {
|
||||
pub const rp2040_plus_4m = .{
|
||||
.preferred_format = .{ .uf2 = .RP2040 },
|
||||
.chip = chip,
|
||||
.hal = hal,
|
||||
.linker_script = linker_script,
|
||||
.board = .{
|
||||
.name = "Waveshare RP2040-Plus (4M Flash)",
|
||||
.source_file = .{ .cwd_relative = build_root ++ "/src/boards/waveshare_rp2040_plus_4m.zig" },
|
||||
.url = "https://www.waveshare.com/rp2040-plus.htm",
|
||||
},
|
||||
.configure = rp2040_configure(.w25q080),
|
||||
};
|
||||
|
||||
pub const rp2040_plus_16m = .{
|
||||
.preferred_format = .{ .uf2 = .RP2040 },
|
||||
.chip = chip,
|
||||
.hal = hal,
|
||||
.linker_script = linker_script,
|
||||
.board = .{
|
||||
.name = "Waveshare RP2040-Plus (16M Flash)",
|
||||
.source_file = .{ .cwd_relative = build_root ++ "/src/boards/waveshare_rp2040_plus_16m.zig" },
|
||||
.url = "https://www.waveshare.com/rp2040-plus.htm",
|
||||
},
|
||||
.configure = rp2040_configure(.w25q080),
|
||||
};
|
||||
|
||||
pub const rp2040_eth = .{
|
||||
.preferred_format = .{ .uf2 = .RP2040 },
|
||||
.chip = chip,
|
||||
.hal = hal,
|
||||
.linker_script = linker_script,
|
||||
.board = .{
|
||||
.name = "Waveshare RP2040-ETH Mini",
|
||||
.source_file = .{ .cwd_relative = build_root ++ "/src/boards/waveshare_rp2040_eth.zig" },
|
||||
.url = "https://www.waveshare.com/rp2040-eth.htm",
|
||||
},
|
||||
.configure = rp2040_configure(.w25q080),
|
||||
};
|
||||
|
||||
pub const rp2040_matrix = .{
|
||||
.preferred_format = .{ .uf2 = .RP2040 },
|
||||
.chip = chip,
|
||||
.hal = hal,
|
||||
.linker_script = linker_script,
|
||||
.board = .{
|
||||
.name = "Waveshare RP2040-Matrix",
|
||||
.source_file = .{ .cwd_relative = build_root ++ "/src/boards/waveshare_rp2040_matrix.zig" },
|
||||
.url = "https://www.waveshare.com/rp2040-matrix.htm",
|
||||
},
|
||||
.configure = rp2040_configure(.w25q080),
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
pub const BootROM = union(enum) {
|
||||
artifact: *std.build.CompileStep, // provide a custom startup code
|
||||
|
@ -26,24 +112,54 @@ pub const BootROM = union(enum) {
|
|||
legacy,
|
||||
};
|
||||
|
||||
pub const PicoExecutableOptions = struct {
|
||||
name: []const u8,
|
||||
source_file: std.Build.LazyPath,
|
||||
optimize: std.builtin.OptimizeMode = .Debug,
|
||||
|
||||
board: boards.Board = boards.raspberry_pi_pico,
|
||||
|
||||
bootrom: ?BootROM = null,
|
||||
const linker_script = .{
|
||||
.source_file = .{ .cwd_relative = build_root ++ "/rp2040.ld" },
|
||||
};
|
||||
|
||||
pub const addPiPicoExecutable = addExecutable; // Deprecated, use addExecutable!
|
||||
const hal = .{
|
||||
.source_file = .{ .cwd_relative = build_root ++ "/src/hal.zig" },
|
||||
};
|
||||
|
||||
const chip = .{
|
||||
.name = "RP2040",
|
||||
.url = "https://www.raspberrypi.com/products/rp2040/",
|
||||
.cpu = .cortex_m0plus,
|
||||
.register_definition = .{
|
||||
.json = .{ .cwd_relative = build_root ++ "/src/chips/RP2040.json" },
|
||||
},
|
||||
.memory_regions = &.{
|
||||
.{ .kind = .flash, .offset = 0x10000100, .length = (2048 * 1024) - 256 },
|
||||
.{ .kind = .flash, .offset = 0x10000000, .length = 256 },
|
||||
.{ .kind = .ram, .offset = 0x20000000, .length = 256 * 1024 },
|
||||
},
|
||||
};
|
||||
|
||||
/// Returns a configuration function that will add the provided `BootROM` to the firmware.
|
||||
pub fn rp2040_configure(comptime bootrom: BootROM) *const fn (host_build: *std.Build, *microzig.Firmware) void {
|
||||
const T = struct {
|
||||
fn configure(host_build: *std.Build, fw: *microzig.Firmware) void {
|
||||
const bootrom_file = getBootrom(host_build, bootrom);
|
||||
|
||||
// HACK: Inject the file as a dependency to MicroZig.board
|
||||
fw.modules.board.?.dependencies.put(
|
||||
"bootloader",
|
||||
host_build.createModule(.{
|
||||
.source_file = bootrom_file.bin,
|
||||
}),
|
||||
) catch @panic("oom");
|
||||
bootrom_file.bin.addStepDependencies(&fw.artifact.step);
|
||||
}
|
||||
};
|
||||
|
||||
return T.configure;
|
||||
}
|
||||
|
||||
pub const Stage2Bootloader = struct {
|
||||
bin: std.Build.LazyPath,
|
||||
elf: ?std.Build.LazyPath,
|
||||
};
|
||||
|
||||
pub fn getBootrom(b: *Build, rom: BootROM) Stage2Bootloader {
|
||||
pub fn getBootrom(b: *std.Build, rom: BootROM) Stage2Bootloader {
|
||||
const rom_exe = switch (rom) {
|
||||
.artifact => |artifact| artifact,
|
||||
.blob => |blob| return Stage2Bootloader{
|
||||
|
@ -52,7 +168,7 @@ pub fn getBootrom(b: *Build, rom: BootROM) Stage2Bootloader {
|
|||
},
|
||||
|
||||
else => blk: {
|
||||
var target = chips.rp2040.cpu.target;
|
||||
var target = @as(microzig.CpuModel, chip.cpu).getDescriptor().target;
|
||||
target.abi = .eabi;
|
||||
|
||||
const rom_path = b.pathFromRoot(b.fmt("{s}/src/bootroms/{s}.S", .{ build_root, @tagName(rom) }));
|
||||
|
@ -84,134 +200,106 @@ pub fn getBootrom(b: *Build, rom: BootROM) Stage2Bootloader {
|
|||
};
|
||||
}
|
||||
|
||||
pub fn addExecutable(
|
||||
b: *Build,
|
||||
opts: PicoExecutableOptions,
|
||||
) *microzig.EmbeddedExecutable {
|
||||
var exe = microzig.addEmbeddedExecutable(b, .{
|
||||
.name = opts.name,
|
||||
.source_file = opts.source_file,
|
||||
.backing = .{ .board = opts.board.inner },
|
||||
.optimize = opts.optimize,
|
||||
.linkerscript_source_file = .{ .path = linkerscript_path },
|
||||
});
|
||||
/////////////////////////////////////////
|
||||
// MicroZig Legacy Interface //
|
||||
/////////////////////////////////////////
|
||||
|
||||
const i: *std.Build.CompileStep = exe.inner;
|
||||
// // this build script is mostly for testing and verification of this
|
||||
// // package. In an attempt to modularize -- designing for a case where a
|
||||
// // project requires multiple HALs, it accepts microzig as a param
|
||||
// pub fn build(b: *Build) !void {
|
||||
// const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
const bootrom_file = getBootrom(b, opts.bootrom orelse opts.board.bootrom);
|
||||
// const args_dep = b.dependency("args", .{});
|
||||
// const args_mod = args_dep.module("args");
|
||||
|
||||
// HACK: Inject the file as a dependency to MicroZig.board
|
||||
i.modules.get("microzig").?.dependencies.get("board").?.dependencies.put(
|
||||
"bootloader",
|
||||
b.createModule(.{
|
||||
.source_file = bootrom_file.bin,
|
||||
}),
|
||||
) catch @panic("oom");
|
||||
bootrom_file.bin.addStepDependencies(&i.step);
|
||||
// var examples = Examples.init(b, optimize);
|
||||
// examples.install(b);
|
||||
|
||||
return exe;
|
||||
}
|
||||
// const pio_tests = b.addTest(.{
|
||||
// .root_source_file = .{
|
||||
// .path = "src/hal.zig",
|
||||
// },
|
||||
// .optimize = optimize,
|
||||
// });
|
||||
// pio_tests.addIncludePath(.{ .path = "src/hal/pio/assembler" });
|
||||
|
||||
// this build script is mostly for testing and verification of this
|
||||
// package. In an attempt to modularize -- designing for a case where a
|
||||
// project requires multiple HALs, it accepts microzig as a param
|
||||
pub fn build(b: *Build) !void {
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
// const test_step = b.step("test", "run unit tests");
|
||||
// test_step.dependOn(&b.addRunArtifact(pio_tests).step);
|
||||
|
||||
const args_dep = b.dependency("args", .{});
|
||||
const args_mod = args_dep.module("args");
|
||||
// {
|
||||
// const flash_tool = b.addExecutable(.{
|
||||
// .name = "rp2040-flash",
|
||||
// .optimize = .Debug,
|
||||
// .target = .{},
|
||||
// .root_source_file = .{ .path = "tools/rp2040-flash.zig" },
|
||||
// });
|
||||
// flash_tool.addModule("args", args_mod);
|
||||
|
||||
var examples = Examples.init(b, optimize);
|
||||
examples.install(b);
|
||||
// b.installArtifact(flash_tool);
|
||||
// }
|
||||
|
||||
const pio_tests = b.addTest(.{
|
||||
.root_source_file = .{
|
||||
.path = "src/hal.zig",
|
||||
},
|
||||
.optimize = optimize,
|
||||
});
|
||||
pio_tests.addIncludePath(.{ .path = "src/hal/pio/assembler" });
|
||||
// // Install all bootroms for debugging and CI
|
||||
// inline for (comptime std.enums.values(std.meta.Tag(BootROM))) |rom| {
|
||||
// if (rom == .artifact or rom == .blob) {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
const test_step = b.step("test", "run unit tests");
|
||||
test_step.dependOn(&b.addRunArtifact(pio_tests).step);
|
||||
// if (rom == .is25lp080) {
|
||||
// // TODO: https://github.com/ZigEmbeddedGroup/raspberrypi-rp2040/issues/79
|
||||
// // is25lp080.o:(text+0x16): has non-ABS relocation R_ARM_THM_CALL against symbol 'read_flash_sreg'
|
||||
// continue;
|
||||
// }
|
||||
|
||||
{
|
||||
const flash_tool = b.addExecutable(.{
|
||||
.name = "rp2040-flash",
|
||||
.optimize = .Debug,
|
||||
.target = .{},
|
||||
.root_source_file = .{ .path = "tools/rp2040-flash.zig" },
|
||||
});
|
||||
flash_tool.addModule("args", args_mod);
|
||||
// const files = getBootrom(b, rom);
|
||||
// if (files.elf) |elf| {
|
||||
// b.getInstallStep().dependOn(
|
||||
// &b.addInstallFileWithDir(elf, .{ .custom = "stage2" }, b.fmt("{s}.elf", .{@tagName(rom)})).step,
|
||||
// );
|
||||
// }
|
||||
// b.getInstallStep().dependOn(
|
||||
// &b.addInstallFileWithDir(files.bin, .{ .custom = "stage2" }, b.fmt("{s}.bin", .{@tagName(rom)})).step,
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
b.installArtifact(flash_tool);
|
||||
}
|
||||
// pub const Examples = struct {
|
||||
// adc: *microzig.EmbeddedExecutable,
|
||||
// blinky: *microzig.EmbeddedExecutable,
|
||||
// blinky_core1: *microzig.EmbeddedExecutable,
|
||||
// gpio_clk: *microzig.EmbeddedExecutable,
|
||||
// i2c_bus_scan: *microzig.EmbeddedExecutable,
|
||||
// pwm: *microzig.EmbeddedExecutable,
|
||||
// spi_master: *microzig.EmbeddedExecutable,
|
||||
// uart: *microzig.EmbeddedExecutable,
|
||||
// squarewave: *microzig.EmbeddedExecutable,
|
||||
// //uart_pins: microzig.EmbeddedExecutable,
|
||||
// flash_program: *microzig.EmbeddedExecutable,
|
||||
// usb_device: *microzig.EmbeddedExecutable,
|
||||
// usb_hid: *microzig.EmbeddedExecutable,
|
||||
// ws2812: *microzig.EmbeddedExecutable,
|
||||
// random: *microzig.EmbeddedExecutable,
|
||||
|
||||
// Install all bootroms for debugging and CI
|
||||
inline for (comptime std.enums.values(std.meta.Tag(BootROM))) |rom| {
|
||||
if (rom == .artifact or rom == .blob) {
|
||||
continue;
|
||||
}
|
||||
// pub fn init(b: *Build, optimize: std.builtin.OptimizeMode) Examples {
|
||||
// var ret: Examples = undefined;
|
||||
// inline for (@typeInfo(Examples).Struct.fields) |field| {
|
||||
// const path = comptime root() ++ "examples/" ++ field.name ++ ".zig";
|
||||
|
||||
if (rom == .is25lp080) {
|
||||
// TODO: https://github.com/ZigEmbeddedGroup/raspberrypi-rp2040/issues/79
|
||||
// is25lp080.o:(text+0x16): has non-ABS relocation R_ARM_THM_CALL against symbol 'read_flash_sreg'
|
||||
continue;
|
||||
}
|
||||
// @field(ret, field.name) = addExecutable(b, .{
|
||||
// .name = field.name,
|
||||
// .source_file = .{ .path = path },
|
||||
// .optimize = optimize,
|
||||
// });
|
||||
// }
|
||||
|
||||
const files = getBootrom(b, rom);
|
||||
if (files.elf) |elf| {
|
||||
b.getInstallStep().dependOn(
|
||||
&b.addInstallFileWithDir(elf, .{ .custom = "stage2" }, b.fmt("{s}.elf", .{@tagName(rom)})).step,
|
||||
);
|
||||
}
|
||||
b.getInstallStep().dependOn(
|
||||
&b.addInstallFileWithDir(files.bin, .{ .custom = "stage2" }, b.fmt("{s}.bin", .{@tagName(rom)})).step,
|
||||
);
|
||||
}
|
||||
}
|
||||
// return ret;
|
||||
// }
|
||||
|
||||
fn root() []const u8 {
|
||||
return comptime (std.fs.path.dirname(@src().file) orelse ".") ++ "/";
|
||||
}
|
||||
|
||||
pub const Examples = struct {
|
||||
adc: *microzig.EmbeddedExecutable,
|
||||
blinky: *microzig.EmbeddedExecutable,
|
||||
blinky_core1: *microzig.EmbeddedExecutable,
|
||||
gpio_clk: *microzig.EmbeddedExecutable,
|
||||
i2c_bus_scan: *microzig.EmbeddedExecutable,
|
||||
pwm: *microzig.EmbeddedExecutable,
|
||||
spi_master: *microzig.EmbeddedExecutable,
|
||||
uart: *microzig.EmbeddedExecutable,
|
||||
squarewave: *microzig.EmbeddedExecutable,
|
||||
//uart_pins: microzig.EmbeddedExecutable,
|
||||
flash_program: *microzig.EmbeddedExecutable,
|
||||
usb_device: *microzig.EmbeddedExecutable,
|
||||
usb_hid: *microzig.EmbeddedExecutable,
|
||||
ws2812: *microzig.EmbeddedExecutable,
|
||||
random: *microzig.EmbeddedExecutable,
|
||||
|
||||
pub fn init(b: *Build, optimize: std.builtin.OptimizeMode) Examples {
|
||||
var ret: Examples = undefined;
|
||||
inline for (@typeInfo(Examples).Struct.fields) |field| {
|
||||
const path = comptime root() ++ "examples/" ++ field.name ++ ".zig";
|
||||
|
||||
@field(ret, field.name) = addExecutable(b, .{
|
||||
.name = field.name,
|
||||
.source_file = .{ .path = path },
|
||||
.optimize = optimize,
|
||||
});
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
pub fn install(examples: *Examples, b: *Build) void {
|
||||
inline for (@typeInfo(Examples).Struct.fields) |field| {
|
||||
b.getInstallStep().dependOn(
|
||||
&b.addInstallFileWithDir(@field(examples, field.name).inner.getEmittedBin(), .{ .custom = "firmware" }, field.name ++ ".elf").step,
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
// pub fn install(examples: *Examples, b: *Build) void {
|
||||
// inline for (@typeInfo(Examples).Struct.fields) |field| {
|
||||
// b.getInstallStep().dependOn(
|
||||
// &b.addInstallFileWithDir(@field(examples, field.name).inner.getEmittedBin(), .{ .custom = "firmware" }, field.name ++ ".elf").step,
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
.name = "rp2040",
|
||||
.version = "0.0.0",
|
||||
.dependencies = .{
|
||||
.microzig = .{
|
||||
.url = "https://github.com/ZigEmbeddedGroup/microzig/archive/0b3be0a4cc7e6d45714cb09961efc771e364723c.tar.gz",
|
||||
.hash = "1220ada6d01db7b3d0aa8642df89b1af9ee71b681438249e9a7efb2275fc4cf32152",
|
||||
},
|
||||
// .microzig = .{
|
||||
// .url = "https://github.com/ZigEmbeddedGroup/microzig/archive/0b3be0a4cc7e6d45714cb09961efc771e364723c.tar.gz",
|
||||
// .hash = "1220ada6d01db7b3d0aa8642df89b1af9ee71b681438249e9a7efb2275fc4cf32152",
|
||||
// },
|
||||
.args = .{
|
||||
.url = "https://github.com/MasterQ32/zig-args/archive/91d1e89fb89a4d01dec7c9aec95b0a324080ebcc.tar.gz",
|
||||
.hash = "12203d04cafc97f952d74cdb077e74c0ab3414f9f6b5fbd159112c62bfa584a0dbed",
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
const std = @import("std");
|
||||
const microzig = @import("microzig");
|
||||
const rp2040 = @import("../build.zig");
|
||||
const chips = @import("chips.zig");
|
||||
|
||||
fn root_dir() []const u8 {
|
||||
return std.fs.path.dirname(@src().file) orelse ".";
|
||||
}
|
||||
|
||||
fn board_path(comptime path: []const u8) std.Build.LazyPath {
|
||||
return .{
|
||||
.path = std.fmt.comptimePrint("{s}/boards/{s}", .{ root_dir(), path }),
|
||||
};
|
||||
}
|
||||
|
||||
pub const Board = struct {
|
||||
inner: microzig.Board,
|
||||
bootrom: rp2040.BootROM,
|
||||
};
|
||||
|
||||
// https://www.raspberrypi.com/products/raspberry-pi-pico/
|
||||
pub const raspberry_pi_pico = Board{
|
||||
.inner = .{
|
||||
.name = "Raspberry Pi Pico",
|
||||
.source = board_path("raspberry_pi_pico.zig"),
|
||||
.chip = chips.rp2040,
|
||||
},
|
||||
.bootrom = .w25q080,
|
||||
};
|
||||
|
||||
// https://www.waveshare.com/rp2040-plus.htm
|
||||
pub const waveshare_rp2040_plus_4m = Board{
|
||||
.inner = .{
|
||||
.name = "Waveshare RP2040-Plus (4M Flash)",
|
||||
.source = board_path("waveshare_rp2040_plus_4m.zig"),
|
||||
.chip = chips.rp2040,
|
||||
},
|
||||
.bootrom = .w25q080,
|
||||
};
|
||||
|
||||
// https://www.waveshare.com/rp2040-plus.htm
|
||||
pub const waveshare_rp2040_plus_16m = Board{
|
||||
.inner = .{
|
||||
.name = "Waveshare RP2040-Plus (16M Flash)",
|
||||
.source = board_path("waveshare_rp2040_plus_16m.zig"),
|
||||
.chip = chips.rp2040,
|
||||
},
|
||||
.bootrom = .w25q080,
|
||||
};
|
||||
|
||||
// https://www.waveshare.com/rp2040-eth.htm
|
||||
pub const waveshare_rp2040_eth = Board{
|
||||
.inner = .{
|
||||
.name = "Waveshare RP2040-ETH Mini",
|
||||
.source = board_path("waveshare_rp2040_eth.zig"),
|
||||
.chip = chips.rp2040,
|
||||
},
|
||||
.bootrom = .w25q080,
|
||||
};
|
||||
|
||||
// https://www.waveshare.com/rp2040-matrix.htm
|
||||
pub const waveshare_rp2040_matrix = Board{
|
||||
.inner = .{
|
||||
.name = "Waveshare RP2040-Matrix",
|
||||
.source = board_path("waveshare_rp2040_matrix.zig"),
|
||||
.chip = chips.rp2040,
|
||||
},
|
||||
.bootrom = .w25q080,
|
||||
};
|
42
src/bootroms/w25q32jvssiq.S
Normal file
42
src/bootroms/w25q32jvssiq.S
Normal file
|
@ -0,0 +1,42 @@
|
|||
|
||||
// This blob was read from the original RP2040-ETH board
|
||||
// and is assumed to be working with the W25Q32JVSSIQ flash.
|
||||
|
||||
.text
|
||||
.global _stage2_boot
|
||||
_stage2_boot:
|
||||
|
||||
// 00000000 00 b5 32 4b 21 20 58 60 98 68 02 21 88 43 98 60 |..2K! X`.h.!.C.`|
|
||||
// 00000010 d8 60 18 61 58 61 2e 4b 00 21 99 60 02 21 59 61 |.`.aXa.K.!.`.!Ya|
|
||||
// 00000020 01 21 f0 22 99 50 2b 49 19 60 01 21 99 60 35 20 |.!.".P+I.`.!.`5 |
|
||||
// 00000030 00 f0 44 f8 02 22 90 42 14 d0 06 21 19 66 00 f0 |..D..".B...!.f..|
|
||||
// 00000040 34 f8 19 6e 01 21 19 66 00 20 18 66 1a 66 00 f0 |4..n.!.f. .f.f..|
|
||||
// 00000050 2c f8 19 6e 19 6e 19 6e 05 20 00 f0 2f f8 01 21 |,..n.n.n. ../..!|
|
||||
// 00000060 08 42 f9 d1 00 21 99 60 1b 49 19 60 00 21 59 60 |.B...!.`.I.`.!Y`|
|
||||
// 00000070 1a 49 1b 48 01 60 01 21 99 60 eb 21 19 66 a0 21 |.I.H.`.!.`.!.f.!|
|
||||
// 00000080 19 66 00 f0 12 f8 00 21 99 60 16 49 14 48 01 60 |.f.....!.`.I.H.`|
|
||||
// 00000090 01 21 99 60 01 bc 00 28 00 d0 00 47 12 48 13 49 |.!.`...(...G.H.I|
|
||||
// 000000a0 08 60 03 c8 80 f3 08 88 08 47 03 b5 99 6a 04 20 |.`.......G...j. |
|
||||
// 000000b0 01 42 fb d0 01 20 01 42 f8 d1 03 bd 02 b5 18 66 |.B... .B.......f|
|
||||
// 000000c0 18 66 ff f7 f2 ff 18 6e 18 6e 02 bd 00 00 02 40 |.f.....n.n.....@|
|
||||
// 000000d0 00 00 00 18 00 00 07 00 00 03 5f 00 21 22 00 00 |.........._.!"..|
|
||||
// 000000e0 f4 00 00 18 22 20 00 a0 00 01 00 10 08 ed 00 e0 |...." ..........|
|
||||
// 000000f0 00 00 00 00 00 00 00 00 00 00 00 00 74 b2 4e 7a |............t.Nz|
|
||||
|
||||
.byte 0x00, 0xb5, 0x32, 0x4b, 0x21, 0x20, 0x58, 0x60, 0x98, 0x68, 0x02, 0x21, 0x88, 0x43, 0x98, 0x60
|
||||
.byte 0xd8, 0x60, 0x18, 0x61, 0x58, 0x61, 0x2e, 0x4b, 0x00, 0x21, 0x99, 0x60, 0x02, 0x21, 0x59, 0x61
|
||||
.byte 0x01, 0x21, 0xf0, 0x22, 0x99, 0x50, 0x2b, 0x49, 0x19, 0x60, 0x01, 0x21, 0x99, 0x60, 0x35, 0x20
|
||||
.byte 0x00, 0xf0, 0x44, 0xf8, 0x02, 0x22, 0x90, 0x42, 0x14, 0xd0, 0x06, 0x21, 0x19, 0x66, 0x00, 0xf0
|
||||
.byte 0x34, 0xf8, 0x19, 0x6e, 0x01, 0x21, 0x19, 0x66, 0x00, 0x20, 0x18, 0x66, 0x1a, 0x66, 0x00, 0xf0
|
||||
.byte 0x2c, 0xf8, 0x19, 0x6e, 0x19, 0x6e, 0x19, 0x6e, 0x05, 0x20, 0x00, 0xf0, 0x2f, 0xf8, 0x01, 0x21
|
||||
.byte 0x08, 0x42, 0xf9, 0xd1, 0x00, 0x21, 0x99, 0x60, 0x1b, 0x49, 0x19, 0x60, 0x00, 0x21, 0x59, 0x60
|
||||
.byte 0x1a, 0x49, 0x1b, 0x48, 0x01, 0x60, 0x01, 0x21, 0x99, 0x60, 0xeb, 0x21, 0x19, 0x66, 0xa0, 0x21
|
||||
.byte 0x19, 0x66, 0x00, 0xf0, 0x12, 0xf8, 0x00, 0x21, 0x99, 0x60, 0x16, 0x49, 0x14, 0x48, 0x01, 0x60
|
||||
.byte 0x01, 0x21, 0x99, 0x60, 0x01, 0xbc, 0x00, 0x28, 0x00, 0xd0, 0x00, 0x47, 0x12, 0x48, 0x13, 0x49
|
||||
.byte 0x08, 0x60, 0x03, 0xc8, 0x80, 0xf3, 0x08, 0x88, 0x08, 0x47, 0x03, 0xb5, 0x99, 0x6a, 0x04, 0x20
|
||||
.byte 0x01, 0x42, 0xfb, 0xd0, 0x01, 0x20, 0x01, 0x42, 0xf8, 0xd1, 0x03, 0xbd, 0x02, 0xb5, 0x18, 0x66
|
||||
.byte 0x18, 0x66, 0xff, 0xf7, 0xf2, 0xff, 0x18, 0x6e, 0x18, 0x6e, 0x02, 0xbd, 0x00, 0x00, 0x02, 0x40
|
||||
.byte 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x07, 0x00, 0x00, 0x03, 0x5f, 0x00, 0x21, 0x22, 0x00, 0x00
|
||||
.byte 0xf4, 0x00, 0x00, 0x18, 0x22, 0x20, 0x00, 0xa0, 0x00, 0x01, 0x00, 0x10, 0x08, 0xed, 0x00, 0xe0
|
||||
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74, 0xb2, 0x4e, 0x7a
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
const std = @import("std");
|
||||
const microzig = @import("microzig");
|
||||
|
||||
fn root_dir() []const u8 {
|
||||
return std.fs.path.dirname(@src().file) orelse ".";
|
||||
}
|
||||
|
||||
const chip_path = std.fmt.comptimePrint("{s}/chips/RP2040.zig", .{root_dir()});
|
||||
const hal_path = std.fmt.comptimePrint("{s}/hal.zig", .{root_dir()});
|
||||
const json_register_schema_path = std.fmt.comptimePrint("{s}/chips/RP2040.json", .{root_dir()});
|
||||
|
||||
pub const rp2040 = microzig.Chip{
|
||||
.name = "RP2040",
|
||||
.source = .{ .path = chip_path },
|
||||
.hal = .{ .path = hal_path },
|
||||
.cpu = microzig.cpus.cortex_m0plus,
|
||||
.memory_regions = &.{
|
||||
.{ .kind = .flash, .offset = 0x10000100, .length = (2048 * 1024) - 256 },
|
||||
.{ .kind = .flash, .offset = 0x10000000, .length = 256 },
|
||||
.{ .kind = .ram, .offset = 0x20000000, .length = 256 * 1024 },
|
||||
},
|
||||
.json_register_schema = .{
|
||||
.path = json_register_schema_path,
|
||||
},
|
||||
};
|
18145
src/chips/RP2040.zig
18145
src/chips/RP2040.zig
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user