From 24411900e0867a1e72fef76d95bb19ae3ea71f4c Mon Sep 17 00:00:00 2001 From: Matt Knight Date: Thu, 19 Dec 2024 16:11:09 -0800 Subject: [PATCH] Get website ready for 0.13.1 release (#321) * get website ready for 0.13.1 release * fix commented line * remove output prefix --- website/assets/logo-text-brightmode.svg | 1 + website/assets/style.css | 135 ++++++++++++++++++++++++ website/build.zig | 1 - website/content/about.smd | 13 --- website/content/community.smd | 1 - website/content/index.smd | 110 +++++++++++++++++-- website/layouts/templates/base.shtml | 41 ++++--- 7 files changed, 264 insertions(+), 38 deletions(-) create mode 100644 website/assets/logo-text-brightmode.svg delete mode 100644 website/content/about.smd diff --git a/website/assets/logo-text-brightmode.svg b/website/assets/logo-text-brightmode.svg new file mode 100644 index 000000000..c048b67d2 --- /dev/null +++ b/website/assets/logo-text-brightmode.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/website/assets/style.css b/website/assets/style.css index e69de29bb..8906363d0 100644 --- a/website/assets/style.css +++ b/website/assets/style.css @@ -0,0 +1,135 @@ +body { +} + +.upper-header { + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: center; +} + +.navbar { + display: flex; + flex-direction: row; +} + +.navlink { + margin: 5px; +} + +.logo { + max-height: 30px; +} + +.container { + max-width: 900px; + margin: 0 auto; +} + +:root { + --srcery-black: #1C1B19; + --srcery-red: #EF2F27; + --srcery-green: #519F50; + --srcery-yellow: #FBB829; + --srcery-blue: #2C78BF; + --srcery-magenta: #E02C6D; + --srcery-cyan: #0AAEB3; + --srcery-white: #BAA67F; + + --srcery-black-bright: #918175; + --srcery-red-bright: #F75341; + --srcery-green-bright: #98BC37; + --srcery-yellow-bright: #FED06E; + --srcery-blue-bright: #68A8E4; + --srcery-magenta-bright: #FF5C8F; + --srcery-cyan-bright: #2BE4D0; + --srcery-white-bright: #FCE8C3; + + --srcery-orange: #FF5F00; + --srcery-orange-bright: #FF8700; + --srcery-black-hard: #121212; + --srcery-teal: #008080; + --srcery-xgray1: #262626; + --srcery-xgray2: #303030; + --srcery-xgray3: #3A3A3A; + --srcery-xgray4: #444444; + --srcery-xgray5: #4E4E4E; + --srcery-xgray6: #585858; + --srcery-xgray7: #626262; + --srcery-xgray8: #6C6C6C; + --srcery-xgray9: #767676; + --srcery-xgray10: #808080; + --srcery-xgray11: #8A8A8A; + --srcery-xgray12: #949494; +} + +pre { + background-color: var(--srcery-black); + color: var(--srcery-white-bright); + padding: 10px; + overflow-x: auto; +} + +code { + white-space: pre; + +} + +code .attribute { color: var(--srcery-white-bright) } +code .boolean { color: var(--srcery-magenta-bright) } +code .character { color: var(--srcery-magenta-bright) } +code .character-special { color: var(--srcery-blue) } +code .comment { color: var(--srcery-black-bright) } +code .conditional { color: var(--srcery-red) } +code .constant { color: var(--srcery-magenta-bright) } +code .constant-builtin { color: var(--srcery-orange) } +code .constant-macro { color: var(--srcery-cyan) } +code .constructor { color: var(--srcery-blue) } +code .debug { color: var(--srcery-black-bright) } +code .define { color: var(--srcery-cyan) } +code .error { color: var(--srcery-white) } +code .exception { color: var(--srcery-red) } +code .field { color: var(--srcery-cyan) } +code .float { color: var(--srcery-magenta-bright) } +code .function { color: var(--srcery-yellow) } +code .function-builtin { color: var(--srcery-orange) } +code .function-call { color: var(--srcery-yellow) } +code .function-macro { color: var(--srcery-orange) } +code .include { color: var(--srcery-cyan) } +code .keyword { color: var(--srcery-red) } +code .keyword-function { color: var(--srcery-red) } +code .keyword-return { color: var(--srcery-red) } +code .keyword-operator { color: var(--srcery-red) } +code .label { color: var(--srcery-red) } +code .literal { color: var(--srcery-red) } +code .macro { color: var(--srcery-orange) } +code .method { color: var(--srcery-yellow) } +code .namespace { color: var(--srcery-cyan) } +code .number { color: var(--srcery-magenta-bright) } +code .operator { color: var(--srcery-white-bright) } +code .parameter { color: var(--srcery-cyan) } +code .preproc { color: var(--srcery-cyan) } +code .property { color: var(--srcery-cyan) } +code .punctuation { color: var(--srcery-black-bright) } +code .punctuation-bracket { color: var(--srcery-black-bright) } +code .punctuation-delimiter { color: var(--srcery-black-bright) } +code .punctuation-special { color: var(--srcery-black-bright) } +code .repeat { color: var(--srcery-red) } +code .storageclass { color: var(--srcery-orange) } +code .string { color: var(--srcery-green-bright) } +code .string-escape { color: var(--srcery-blue) } +code .string-special { color: var(--srcery-blue) } +code .structure { color: var(--srcery-cyan) } +code .tag { color: var(--srcery-cyan) } +code .text-literal { color: var(--srcery-black-bright) } +code .text-reference { color: var(--srcery-cyan) } +code .text-title { color: var(--srcery-green) } /* TODO: bold */ +code .text-todo { color: var(--srcery-white) } /* TODO: bold */ +code .text-underline { color: var(--srcery-blue) } /* TODO: underline */ +code .text-uri { color: var(--srcery-blue) } /* TODO: underline */ +code .type { color: var(--srcery-blue-bright) } +code .type-builtin { color: var(--srcery-blue-bright) } +code .type-definition { color: var(--srcery-magenta) } +code .type-qualifier { color: var(--srcery-blue-bright) } +code .variable { color: var(--srcery-cyan) } +code .variable-builtin { color: var(--srcery-magenta-bright) } diff --git a/website/build.zig b/website/build.zig index e86ec6cf8..a66e48a43 100644 --- a/website/build.zig +++ b/website/build.zig @@ -8,6 +8,5 @@ pub fn build(b: *std.Build) void { .content_dir_path = "content", .layouts_dir_path = "layouts", .assets_dir_path = "assets", - .output_path_prefix = "www", }); } diff --git a/website/content/about.smd b/website/content/about.smd deleted file mode 100644 index d8685e13e..000000000 --- a/website/content/about.smd +++ /dev/null @@ -1,13 +0,0 @@ ---- -.title = "About", -.date = @date("2024-11-02T00:00:00"), -.author = "Matthew Knight", -.draft = false, -.layout = "index.shtml", -.description = "MicroZig: About", -.tags = [] ---- - -# About - -[MicroZig](https://github.com/ZigEmbeddedGroup/microzig) is the main project of the Zig Embedded Group. diff --git a/website/content/community.smd b/website/content/community.smd index 749c69a6e..dca9a7fca 100644 --- a/website/content/community.smd +++ b/website/content/community.smd @@ -11,4 +11,3 @@ # Community - [ZEG Discord](https://discord.gg/Hpps2zStQ5) -- MicroZig IRC: irc://irc.libera.chat/microzig diff --git a/website/content/index.smd b/website/content/index.smd index e5cadf5b8..74d3f6f66 100644 --- a/website/content/index.smd +++ b/website/content/index.smd @@ -8,15 +8,107 @@ .tags = [] --- -# MicroZig +# Getting Started -[Repository](https://github.com/ZigEmbeddedGroup/microzig) +This tutorial assumes that you're programming a [Raspberry Pi +Pico](https://www.raspberrypi.com/products/raspberry-pi-pico/). This hardware +is by far the best supported in MicroZig. It's a fairly alpha project based on +a fairly new and breaking language so your mileage may vary. That being said, +it does support other hardware, such as Microchip's `ATSAMD51J19` which was +used for the [2024 SYCL](https://sycl.it) Badge. -## Goals +## Let's Begin -- Provide documents on how to get started with embedded programming (for absolute newbies) -- Provide example snippets for common operations on certain architectures (LPC, STM32, AVR, ...) -- Provide example worked through embedded mini-projects -- Create register definition libraries -- Create a common interface/HAL over several architectures -- Create a performant common set of drivers for external platforms +Assuming you've initialized a zig project with `zig init`, or have set one up +yourself, you can add microzig as a dependency with the following command: + +```sh +zig fetch --save=microzig https://microzig.tech/downloads/microzig/0.13.1/microzig.tar.gz +``` + +Then in your `build.zig`: + +```zig +const std = @import("std"); +const microzig = @import("microzig"); + +const MicroBuild = microzig.MicroBuild(.{ + .rp2xxx = true, +}); + +pub fn build(b: *std.Build) void { + const mz_dep = b.dependency("microzig", .{}); + const mb = MicroBuild.init(b, mz_dep) orelse return; + + const firmware = mb.add_firmware(.{ + .name = "blinky", + .target = mb.ports.rp2xxx.boards.raspberrypi.pico, + .optimize = .ReleaseSmall, + .root_source_file = b.path("src/main.zig"), + }); + + // We call this twice to demonstrate that the default binary output for + // RP2040 is UF2, but we can also output other formats easily + mb.install_firmware(firmware, .{ }); + mb.install_firmware(firmware, .{ .format = .elf }); +} +``` + +and for your `src/main.zig`, let's start with a classic blinky program. Yes, +most of the main stdlib is available for use on an MCU with Zig: + +```zig +const std = @import("std"); +const microzig = @import("microzig"); +const rp2xxx = microzig.hal; +const time = rp2xxx.time; + +// Compile-time pin configuration +const pin_config = rp2xxx.pins.GlobalConfiguration{ + .GPIO25 = .{ + .name = "led", + .direction = .out, + }, +}; + +const pins = pin_config.pins(); + +pub fn main() !void { + pin_config.apply(); + + while (true) { + pins.led.toggle(); + time.sleep_ms(250); + } +} +``` + +Now if you run `zig build`, our extremely simple program will be installed under `zig-out`: + +``` +zig-out +└── firmware + ├── blinky.uf2 +    └── blinky.elf +``` + +And if we run the `file` command, often found on Linux and MacOS, on the ELF +file we'll see that it's targetting ARM!: + +``` +zig-out/firmware/blinky.elf: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, with debug_info, not stripped +``` + +## Programming the MCU + +To activate the UF2 bootloader, power must be applied to the pico while the +`BOOTSEL` button is held. This is best done by connecting a button from `RUN` +to ground, pressing both buttons, and releasing the `RUN` button first, then +`BOOTSEL`. The other option is to plug/unplug the USB cable which is awkward +and gets tiresome. + +Copy the uf2 file into the mounted drive. Execution should take place immediately. + +## Further Resources + +- [Zig Language Reference](https://ziglang.org/documentation/0.13.0/) diff --git a/website/layouts/templates/base.shtml b/website/layouts/templates/base.shtml index 6c121d04e..8891752c0 100644 --- a/website/layouts/templates/base.shtml +++ b/website/layouts/templates/base.shtml @@ -1,31 +1,44 @@ - <super> - - Zig Embedded Group + <super>MicroZig - + + - -
- +
+ +
+ +
+
+
-