From 193ce99c1888cc9c373aac1aa4f7c307d643bd1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20=22xq=22=20Quei=C3=9Fner?= Date: Tue, 19 Sep 2023 10:05:33 +0200 Subject: [PATCH 1/7] Bootstrap code --- .gitattributes | 1 + .github/workflows/build.yml | 26 ++++++++++++++++++++++++++ .gitignore | 3 +++ build.zig | 19 +++++++++++++++++++ build.zig.zon | 14 ++++++++++++++ ezpkg.sh | 5 +++++ shell.nix | 8 ++++++++ src/blinky.zig | 20 ++++++++++++++++++++ 8 files changed, 96 insertions(+) create mode 100644 .gitattributes create mode 100644 .github/workflows/build.yml create mode 100644 .gitignore create mode 100644 build.zig create mode 100644 build.zig.zon create mode 100755 ezpkg.sh create mode 100644 shell.nix create mode 100644 src/blinky.zig diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..0cb064a --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.zig text=auto eol=lf diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..59cf509 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,26 @@ +name: Build +on: + push: + branches: [main] + pull_request: + branches: [main] + schedule: + - cron: '0 0 * * *' + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [windows-latest, macos-latest, linux-latest] + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup Zig + uses: goto-bus-stop/setup-zig@v2 + with: + version: 0.11.0 + + - name: Build examples + run: zig build diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..eacd52b --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +zig-cache/ +dev-scripts/ +zig-out diff --git a/build.zig b/build.zig new file mode 100644 index 0000000..cac966e --- /dev/null +++ b/build.zig @@ -0,0 +1,19 @@ +const std = @import("std"); +const microzig = @import("microzig"); +const rp2040 = @import("rp2040"); + +pub fn build(b: *std.Build) void { + const optimize = b.standardOptimizeOption(.{}); + + const firmware = microzig.addFirmware(b, .{ + .name = "blinky", + .target = rp2040.chips.rp2040, + .optimize = optimize, + .source_file = .{ .path = "src/blinky.zig" }, + }); + + microzig.installFirmware(firmware, .{ + + .format = .uf2, // .dfu, .bin, .hex, .elf, … + }); +} diff --git a/build.zig.zon b/build.zig.zon new file mode 100644 index 0000000..d661193 --- /dev/null +++ b/build.zig.zon @@ -0,0 +1,14 @@ +.{ + .name = "microzig-examples", + .version = "0.1.0", + .dependencies = .{ + .microzig = .{ + .url = "https://github.com/ZigEmbeddedGroup/microzig/archive/f0a6aa9ce1829df91f2d7f160bbc6f5bc41a3c80.tar.gz", + .hash = "12203f8cb7803a82dff1310ab0917055c0055bc7385f1321bbaf0de998b26a00b44d", + }, + .rp2040 = .{ + .url = "https://github.com/ZigEmbeddedGroup/raspberrypi-rp2040/archive/2a0c0ff2814a716a163822211c2686d84801a97a.tar.gz", + .hash = "12208735720ddf172a28943f1b17375f7b16370140be9c458f1482076025e465c3b0", + }, + }, +} diff --git a/ezpkg.sh b/ezpkg.sh new file mode 100755 index 0000000..b1f61da --- /dev/null +++ b/ezpkg.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +exec ezpkg \ + microzig=/home/felix/projects/zeg/microzig \ + rp2040=/home/felix/projects/zeg/device-support-package/rp2040 \ No newline at end of file diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..3c88ea0 --- /dev/null +++ b/shell.nix @@ -0,0 +1,8 @@ +{pkgs ? import {}}: +pkgs.mkShell { + nativeBuildInputs = [ + pkgs.zig_0_11_0 + pkgs.picotool + ]; + buildInputs = []; +} diff --git a/src/blinky.zig b/src/blinky.zig new file mode 100644 index 0000000..5632fe3 --- /dev/null +++ b/src/blinky.zig @@ -0,0 +1,20 @@ +const std = @import("std"); +const microzig = @import("microzig"); +const rp2040 = microzig.hal; +const time = rp2040.time; + +const pin_config = rp2040.pins.GlobalConfiguration{ + .GPIO25 = .{ + .name = "led", + .direction = .out, + }, +}; + +pub fn main() !void { + const pins = pin_config.apply(); + + while (true) { + pins.led.toggle(); + time.sleep_ms(250); + } +} From e14f0a1e53002556e62928fc3848882cdaa7597a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20=22xq=22=20Quei=C3=9Fner?= Date: Tue, 19 Sep 2023 10:10:15 +0200 Subject: [PATCH 2/7] Adds some documentation comments --- build.zig | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/build.zig b/build.zig index cac966e..c351ebc 100644 --- a/build.zig +++ b/build.zig @@ -5,15 +5,30 @@ const rp2040 = @import("rp2040"); pub fn build(b: *std.Build) void { const optimize = b.standardOptimizeOption(.{}); + // `addFirmware` basically works like addExecutable, but takes a + // `microzig.Target` for target instead of a `std.zig.CrossTarget`. + // + // The target will convey all necessary information on the chip, + // cpu and potentially the board as well. const firmware = microzig.addFirmware(b, .{ .name = "blinky", - .target = rp2040.chips.rp2040, + .target = rp2040.boards.raspberrypi.pico, .optimize = optimize, .source_file = .{ .path = "src/blinky.zig" }, }); + // Pendant to `getEmittedBin()`: Always returns the path to the output elf file + _ = firmware.getEmittedElf(); + + // Extension of `getEmittedElf()` that will also convert the file to the given + // binary format. + _ = firmware.getEmittedBin(.uf2); + + // `installFirmware()` is the MicroZig pendant to `Build.installArtifact()` + // and allows installing the firmware as a typical firmware file. + // + // This will also install into `$prefix/firmware` instead of `$prefix/bin`. microzig.installFirmware(firmware, .{ - .format = .uf2, // .dfu, .bin, .hex, .elf, … }); } From 8a124a68dbf0e6f6f0a576c16ca410788fe78d07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20=22xq=22=20Quei=C3=9Fner?= Date: Wed, 20 Sep 2023 00:42:15 +0200 Subject: [PATCH 3/7] First build again. No verification of 'works' --- .gitignore | 1 + build.zig | 12 ++++++------ build.zig.zon | 8 ++++---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index eacd52b..f975728 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ zig-cache/ dev-scripts/ zig-out +.envrc diff --git a/build.zig b/build.zig index c351ebc..d961288 100644 --- a/build.zig +++ b/build.zig @@ -1,8 +1,10 @@ const std = @import("std"); -const microzig = @import("microzig"); const rp2040 = @import("rp2040"); +const microzig_build = @import("microzig"); pub fn build(b: *std.Build) void { + const microzig = microzig_build.init(b, "microzig"); + const optimize = b.standardOptimizeOption(.{}); // `addFirmware` basically works like addExecutable, but takes a @@ -12,7 +14,7 @@ pub fn build(b: *std.Build) void { // cpu and potentially the board as well. const firmware = microzig.addFirmware(b, .{ .name = "blinky", - .target = rp2040.boards.raspberrypi.pico, + .target = rp2040.boards.raspberry_pi.pico, .optimize = optimize, .source_file = .{ .path = "src/blinky.zig" }, }); @@ -22,13 +24,11 @@ pub fn build(b: *std.Build) void { // Extension of `getEmittedElf()` that will also convert the file to the given // binary format. - _ = firmware.getEmittedBin(.uf2); + _ = firmware.getEmittedBin(null); // `null` is preferred format, in this case uf2 // `installFirmware()` is the MicroZig pendant to `Build.installArtifact()` // and allows installing the firmware as a typical firmware file. // // This will also install into `$prefix/firmware` instead of `$prefix/bin`. - microzig.installFirmware(firmware, .{ - .format = .uf2, // .dfu, .bin, .hex, .elf, … - }); + microzig.installFirmware(b, firmware, .{}); } diff --git a/build.zig.zon b/build.zig.zon index d661193..c1350ee 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -3,12 +3,12 @@ .version = "0.1.0", .dependencies = .{ .microzig = .{ - .url = "https://github.com/ZigEmbeddedGroup/microzig/archive/f0a6aa9ce1829df91f2d7f160bbc6f5bc41a3c80.tar.gz", - .hash = "12203f8cb7803a82dff1310ab0917055c0055bc7385f1321bbaf0de998b26a00b44d", + .url = "https://github.com/ZigEmbeddedGroup/microzig/archive/44ab82cac86ab7fbd4e6718021d51a2bb8c4a42c.tar.gz", + .hash = "122039437ab5c8946e3f1f77dec17092f0c6cae9fcd830bce89f03725e75a02d101b", }, .rp2040 = .{ - .url = "https://github.com/ZigEmbeddedGroup/raspberrypi-rp2040/archive/2a0c0ff2814a716a163822211c2686d84801a97a.tar.gz", - .hash = "12208735720ddf172a28943f1b17375f7b16370140be9c458f1482076025e465c3b0", + .url = "https://github.com/ZigEmbeddedGroup/raspberrypi-rp2040/archive/b9c361be68215d48657ec3684c8a30ebbc74efd5.tar.gz", + .hash = "1220aa6da071763468a358e82af753db23513e12120cf749bdb8bb4f8ea2a8b6da7b", }, }, } From 2b25d1fe1c56c60205283642c4fc5986ceb87357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20=22xq=22=20Quei=C3=9Fner?= Date: Wed, 20 Sep 2023 14:26:52 +0200 Subject: [PATCH 4/7] Adds building support for STM32 --- README.md | 1 + build.zig | 66 ++++++++++++++++++++++++++++++++------------------- build.zig.zon | 12 ++++++---- ezpkg.sh | 6 ++++- src/empty.zig | 6 +++++ 5 files changed, 62 insertions(+), 29 deletions(-) create mode 100644 src/empty.zig diff --git a/README.md b/README.md index c3bfa27..dda5683 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ # microzig-examples + Examples for embedded zig! diff --git a/build.zig b/build.zig index d961288..9ed2c21 100644 --- a/build.zig +++ b/build.zig @@ -1,34 +1,52 @@ const std = @import("std"); const rp2040 = @import("rp2040"); -const microzig_build = @import("microzig"); +const stm32 = @import("stm32"); pub fn build(b: *std.Build) void { - const microzig = microzig_build.init(b, "microzig"); - + const microzig = @import("microzig").init(b, "microzig"); const optimize = b.standardOptimizeOption(.{}); - // `addFirmware` basically works like addExecutable, but takes a - // `microzig.Target` for target instead of a `std.zig.CrossTarget`. - // - // The target will convey all necessary information on the chip, - // cpu and potentially the board as well. - const firmware = microzig.addFirmware(b, .{ - .name = "blinky", - .target = rp2040.boards.raspberry_pi.pico, - .optimize = optimize, - .source_file = .{ .path = "src/blinky.zig" }, - }); + const TargetDesc = struct { + target: @import("microzig").Target, + name: []const u8, + }; + + const available_targets = [_]TargetDesc{ + // RP2040 + .{ .name = "pico", .target = rp2040.boards.raspberry_pi.pico }, + .{ .name = "rp2040-eth", .target = rp2040.boards.waveshare.rp2040_eth }, + .{ .name = "rp2040-plus-4m", .target = rp2040.boards.waveshare.rp2040_plus_4m }, + .{ .name = "rp2040-plus-16m", .target = rp2040.boards.waveshare.rp2040_plus_16m }, + .{ .name = "rp2040-matrix", .target = rp2040.boards.waveshare.rp2040_matrix }, - // Pendant to `getEmittedBin()`: Always returns the path to the output elf file - _ = firmware.getEmittedElf(); + // STM32 + .{ .name = "stm32f103x8", .target = stm32.chips.stm32f103x8 }, + .{ .name = "stm32f303vc", .target = stm32.chips.stm32f303vc }, + .{ .name = "stm32f407vg", .target = stm32.chips.stm32f407vg }, + .{ .name = "stm32f429zit6u", .target = stm32.chips.stm32f429zit6u }, + .{ .name = "stm32f3discovery", .target = stm32.boards.stm32f3discovery }, + .{ .name = "stm32f4discovery", .target = stm32.boards.stm32f4discovery }, + .{ .name = "stm3240geval", .target = stm32.boards.stm3240geval }, + .{ .name = "stm32f429idiscovery", .target = stm32.boards.stm32f429idiscovery }, + }; - // Extension of `getEmittedElf()` that will also convert the file to the given - // binary format. - _ = firmware.getEmittedBin(null); // `null` is preferred format, in this case uf2 + for (available_targets) |dest| { + // `addFirmware` basically works like addExecutable, but takes a + // `microzig.Target` for target instead of a `std.zig.CrossTarget`. + // + // The target will convey all necessary information on the chip, + // cpu and potentially the board as well. + const firmware = microzig.addFirmware(b, .{ + .name = b.fmt("empty-{s}", .{dest.name}), + .target = dest.target, + .optimize = optimize, + .source_file = .{ .path = "src/empty.zig" }, + }); - // `installFirmware()` is the MicroZig pendant to `Build.installArtifact()` - // and allows installing the firmware as a typical firmware file. - // - // This will also install into `$prefix/firmware` instead of `$prefix/bin`. - microzig.installFirmware(b, firmware, .{}); + // `installFirmware()` is the MicroZig pendant to `Build.installArtifact()` + // and allows installing the firmware as a typical firmware file. + // + // This will also install into `$prefix/firmware` instead of `$prefix/bin`. + microzig.installFirmware(b, firmware, .{}); + } } diff --git a/build.zig.zon b/build.zig.zon index c1350ee..e44e0ba 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -3,12 +3,16 @@ .version = "0.1.0", .dependencies = .{ .microzig = .{ - .url = "https://github.com/ZigEmbeddedGroup/microzig/archive/44ab82cac86ab7fbd4e6718021d51a2bb8c4a42c.tar.gz", - .hash = "122039437ab5c8946e3f1f77dec17092f0c6cae9fcd830bce89f03725e75a02d101b", + .url = "https://github.com/ZigEmbeddedGroup/microzig/archive/c6c9ec4516f57638e751141085c9d76120990312.tar.gz", + .hash = "1220af58bdaa721b8189f3a7adfda660517dd354463463388e96d69fe4ceccf80b92", }, .rp2040 = .{ - .url = "https://github.com/ZigEmbeddedGroup/raspberrypi-rp2040/archive/b9c361be68215d48657ec3684c8a30ebbc74efd5.tar.gz", - .hash = "1220aa6da071763468a358e82af753db23513e12120cf749bdb8bb4f8ea2a8b6da7b", + .url = "https://github.com/ZigEmbeddedGroup/raspberrypi-rp2040/archive/67d36eebb0fbd89633db1a51d6d2bcb049f2066a.tar.gz", + .hash = "122094bf268f45b188f3916f9e5964f4257414afaafba98a455ac47d25389a456832", + }, + .stm32 = .{ + .url = "https://github.com/ZigEmbeddedGroup/stmicro-stm32/archive/cb2893707efa6aa289fa72f02959ad5f2d9db2a1.tar.gz", + .hash = "12208cab5f60ef97cac4165ad694f3ba0c7b28f279538c1539b74f7c152f34fe306d", }, }, } diff --git a/ezpkg.sh b/ezpkg.sh index b1f61da..577c8b4 100755 --- a/ezpkg.sh +++ b/ezpkg.sh @@ -2,4 +2,8 @@ exec ezpkg \ microzig=/home/felix/projects/zeg/microzig \ - rp2040=/home/felix/projects/zeg/device-support-package/rp2040 \ No newline at end of file + microzig.uf2=/home/felix/projects/zeg/uf2 \ + microzig.regz=/home/felix/projects/zeg/regz \ + rp2040=/home/felix/projects/zeg/device-support-package/rp2040 \ + stm32=/home/felix/projects/zeg/device-support-package/stmicro-stm32 + \ No newline at end of file diff --git a/src/empty.zig b/src/empty.zig new file mode 100644 index 0000000..7c6dbbe --- /dev/null +++ b/src/empty.zig @@ -0,0 +1,6 @@ +const std = @import("std"); +const microzig = @import("microzig"); + +pub fn main() void { + // +} From 9e40dda94b40b9e00803d66e1f1f20b3454bb96c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20=22xq=22=20Quei=C3=9Fner?= Date: Wed, 20 Sep 2023 17:50:55 +0200 Subject: [PATCH 5/7] Fixes CI runner --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 59cf509..1935023 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [windows-latest, macos-latest, linux-latest] + os: [windows-latest, macos-latest, ubuntu-latest] steps: - name: Checkout uses: actions/checkout@v2 From 991d757eff2aa6a36bfef74e239cdc1bdf84043f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20=22xq=22=20Quei=C3=9Fner?= Date: Thu, 21 Sep 2023 10:19:02 +0200 Subject: [PATCH 6/7] Adds more working devices. --- .github/workflows/build.yml | 2 -- build.zig | 25 +++++++++++++++++++++++++ build.zig.zon | 20 ++++++++++++++++++++ ezpkg.sh | 8 ++++++-- 4 files changed, 51 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1935023..af725e6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,8 +4,6 @@ on: branches: [main] pull_request: branches: [main] - schedule: - - cron: '0 0 * * *' jobs: build: diff --git a/build.zig b/build.zig index 9ed2c21..3aeb293 100644 --- a/build.zig +++ b/build.zig @@ -1,6 +1,9 @@ const std = @import("std"); const rp2040 = @import("rp2040"); const stm32 = @import("stm32"); +const lpc = @import("lpc"); +const gd32 = @import("gd32"); +const nrf5x = @import("nrf5x"); pub fn build(b: *std.Build) void { const microzig = @import("microzig").init(b, "microzig"); @@ -28,6 +31,28 @@ pub fn build(b: *std.Build) void { .{ .name = "stm32f4discovery", .target = stm32.boards.stm32f4discovery }, .{ .name = "stm3240geval", .target = stm32.boards.stm3240geval }, .{ .name = "stm32f429idiscovery", .target = stm32.boards.stm32f429idiscovery }, + + // NXP LPC + // TODO: Add checksum postprocessing + .{ .name = "lpc176x5x", .target = lpc.chips.lpc176x5x }, + .{ .name = "mbed-lpc1768", .target = lpc.boards.mbed.lpc1768 }, + + // GigaDevice GD32 + .{ .name = "gd32vf103xb", .target = gd32.chips.gd32vf103xb }, + .{ .name = "gd32vf103x8", .target = gd32.chips.gd32vf103x8 }, + .{ .name = "sipeed-longan_nano", .target = gd32.boards.sipeed.longan_nano }, + + // Nordic Nrf5x + .{ .name = "nrf52832", .target = nrf5x.chips.nrf52832 }, + .{ .name = "nrf52840", .target = nrf5x.chips.nrf52840 }, + .{ .name = "nrf52840-dongle", .target = nrf5x.boards.nordic.nRF52840_Dongle }, // TODO: Add support for DFU files! + + // Espressif ESP + // .{ .name = "nrf52832", .target = nrf5x.chips.nrf52832 }, + // TODO: Add support for Espressif Update Binaries + + // Microchip ATmega + // TODO: Fix compiler bugs }; for (available_targets) |dest| { diff --git a/build.zig.zon b/build.zig.zon index e44e0ba..1180edb 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -14,5 +14,25 @@ .url = "https://github.com/ZigEmbeddedGroup/stmicro-stm32/archive/cb2893707efa6aa289fa72f02959ad5f2d9db2a1.tar.gz", .hash = "12208cab5f60ef97cac4165ad694f3ba0c7b28f279538c1539b74f7c152f34fe306d", }, + .lpc = .{ + .url = "https://github.com/ZigEmbeddedGroup/nxp-lpc/archive/be4280a8b55690e8446fd4c3186dcd6673118cd3.tar.gz", + .hash = "1220891bc5fa43b30cd024a628f8915f54691e5664d2a34e6653bf92722b222b7c7e", + }, + .gd32 = .{ + .url = "https://github.com/ZigEmbeddedGroup/gigadevice-gd32/archive/9324753cc3b8e7afe83fcda085bcfe76681a3be3.tar.gz", + .hash = "122043ff4dcbc342f25dbb936b0d9eaa701ac3509e2cbe6764be37b90d31c7a385d0", + }, + .nrf5x = .{ + .url = "https://github.com/ZigEmbeddedGroup/nordic-nrf5x/archive/0ab136860ccf7eb1d07969c3ef523f3cd898e2ff.tar.gz", + .hash = "1220980da06f9634dcff06afefa7aa111bd030018fea49f79e86657dab69621e1d08", + }, + .esp = .{ + .url = "https://github.com/ZigEmbeddedGroup/espressif-esp/archive/f7e47d07996565036501f55ed781a5f6e786b2f7.tar.gz", + .hash = "12209b0365f56df4ce83b1300da86bef605bd299e94b87f373571351f71fa2ccd461", + }, + .atmega = .{ + .url = "https://github.com/ZigEmbeddedGroup/microchip-atmega/archive/46dfd08ad13e0a9a84351cfd595b1e6e341d4839.tar.gz", + .hash = "1220b2df269bf997b77bebcebea63a8e39aea354a7075cf99878423e304394bc28eb", + }, }, } diff --git a/ezpkg.sh b/ezpkg.sh index 577c8b4..caafa03 100755 --- a/ezpkg.sh +++ b/ezpkg.sh @@ -5,5 +5,9 @@ exec ezpkg \ microzig.uf2=/home/felix/projects/zeg/uf2 \ microzig.regz=/home/felix/projects/zeg/regz \ rp2040=/home/felix/projects/zeg/device-support-package/rp2040 \ - stm32=/home/felix/projects/zeg/device-support-package/stmicro-stm32 - \ No newline at end of file + stm32=/home/felix/projects/zeg/device-support-package/stmicro-stm32 \ + lpc=/home/felix/projects/zeg/device-support-package/nxp-lpc \ + gd32=/home/felix/projects/zeg/device-support-package/gigadevice-gd32 \ + esp=/home/felix/projects/zeg/device-support-package/espressif-esp \ + nrf5x=/home/felix/projects/zeg/device-support-package/nordic-nrf5x \ + atmega=/home/felix/projects/zeg/device-support-package/microchip-atmega \ No newline at end of file From ca17420a81df7bec9382459970652e7dc79cfe26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20=22xq=22=20Quei=C3=9Fner?= Date: Thu, 21 Sep 2023 12:16:03 +0200 Subject: [PATCH 7/7] Adds more architectures --- build.zig | 15 +++++++++++---- build.zig.zon | 12 ++++++------ shell.nix | 1 + 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/build.zig b/build.zig index 3aeb293..4064772 100644 --- a/build.zig +++ b/build.zig @@ -4,6 +4,8 @@ const stm32 = @import("stm32"); const lpc = @import("lpc"); const gd32 = @import("gd32"); const nrf5x = @import("nrf5x"); +const esp = @import("esp"); +const atmega = @import("atmega"); pub fn build(b: *std.Build) void { const microzig = @import("microzig").init(b, "microzig"); @@ -33,7 +35,6 @@ pub fn build(b: *std.Build) void { .{ .name = "stm32f429idiscovery", .target = stm32.boards.stm32f429idiscovery }, // NXP LPC - // TODO: Add checksum postprocessing .{ .name = "lpc176x5x", .target = lpc.chips.lpc176x5x }, .{ .name = "mbed-lpc1768", .target = lpc.boards.mbed.lpc1768 }, @@ -47,12 +48,15 @@ pub fn build(b: *std.Build) void { .{ .name = "nrf52840", .target = nrf5x.chips.nrf52840 }, .{ .name = "nrf52840-dongle", .target = nrf5x.boards.nordic.nRF52840_Dongle }, // TODO: Add support for DFU files! - // Espressif ESP - // .{ .name = "nrf52832", .target = nrf5x.chips.nrf52832 }, - // TODO: Add support for Espressif Update Binaries + // RISC-V Espressif ESP + .{ .name = "esp32-c3", .target = esp.chips.esp32_c3 }, // TODO: Add support for Espressif Update Binaries // Microchip ATmega // TODO: Fix compiler bugs + // - https://github.com/ziglang/zig/issues/17219 + // .{ .name = "atmega328p", .target = atmega.chips.atmega328p }, + // .{ .name = "arduino-nano", .target = atmega.boards.arduino.nano }, + // .{ .name = "arduino-uno-rev3", .target = atmega.boards.arduino.uno_rev3 }, }; for (available_targets) |dest| { @@ -73,5 +77,8 @@ pub fn build(b: *std.Build) void { // // This will also install into `$prefix/firmware` instead of `$prefix/bin`. microzig.installFirmware(b, firmware, .{}); + + // For debugging, we also always install the firmware as an ELF file + microzig.installFirmware(b, firmware, .{ .format = .elf }); } } diff --git a/build.zig.zon b/build.zig.zon index 1180edb..7166259 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -15,8 +15,8 @@ .hash = "12208cab5f60ef97cac4165ad694f3ba0c7b28f279538c1539b74f7c152f34fe306d", }, .lpc = .{ - .url = "https://github.com/ZigEmbeddedGroup/nxp-lpc/archive/be4280a8b55690e8446fd4c3186dcd6673118cd3.tar.gz", - .hash = "1220891bc5fa43b30cd024a628f8915f54691e5664d2a34e6653bf92722b222b7c7e", + .url = "https://github.com/ZigEmbeddedGroup/nxp-lpc/archive/130a1316c0892415e7da958a5e9548ed87bba54d.tar.gz", + .hash = "1220165879f85a1d51656d35b3963a95f3585dc665fc7414f76aa6aad4e6635536cf", }, .gd32 = .{ .url = "https://github.com/ZigEmbeddedGroup/gigadevice-gd32/archive/9324753cc3b8e7afe83fcda085bcfe76681a3be3.tar.gz", @@ -27,12 +27,12 @@ .hash = "1220980da06f9634dcff06afefa7aa111bd030018fea49f79e86657dab69621e1d08", }, .esp = .{ - .url = "https://github.com/ZigEmbeddedGroup/espressif-esp/archive/f7e47d07996565036501f55ed781a5f6e786b2f7.tar.gz", - .hash = "12209b0365f56df4ce83b1300da86bef605bd299e94b87f373571351f71fa2ccd461", + .url = "https://github.com/ZigEmbeddedGroup/espressif-esp/archive/59b8ca028915c0d6224ec88dbf4db19afbb559c0.tar.gz", + .hash = "1220f6e5f22416fdc63442cd8869fcaa35f9abf30d878ea3d80073176677dc6f8a65", }, .atmega = .{ - .url = "https://github.com/ZigEmbeddedGroup/microchip-atmega/archive/46dfd08ad13e0a9a84351cfd595b1e6e341d4839.tar.gz", - .hash = "1220b2df269bf997b77bebcebea63a8e39aea354a7075cf99878423e304394bc28eb", + .url = "https://github.com/ZigEmbeddedGroup/microchip-atmega/archive/feefcb87a63c0aae31afb783d4e388e90c4d922f.tar.gz", + .hash = "1220048dc5d22729ee119a496f8b8ca3556838af1f3bd32ce6acd5f76480ec942965", }, }, } diff --git a/shell.nix b/shell.nix index 3c88ea0..b1724c4 100644 --- a/shell.nix +++ b/shell.nix @@ -3,6 +3,7 @@ pkgs.mkShell { nativeBuildInputs = [ pkgs.zig_0_11_0 pkgs.picotool + pkgs.llvmPackages_16.bintools ]; buildInputs = []; }