From fe9bafc828fbb924a7aaaf53579e698a31eff47a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20=22xq=22=20Quei=C3=9Fner?= Date: Fri, 23 Feb 2024 11:50:37 +0100 Subject: [PATCH] Refactors website to use zine-ssg.io --- .envrc | 2 + .gitignore | 1 + .gitmodules | 3 - WIP.md | 41 +++-- build.zig | 42 ++--- build.zig.zon | 11 ++ {website => content}/articles/.keep | 0 content/getting-started.md | 11 ++ content/index.md | 11 ++ .../tutorials/01-embedded-basics.md | 11 ++ .../tutorials/02-embedded-programming.md | 18 ++- .../img => content/tutorials}/memory-map.png | Bin deps/koino | 1 - flake.lock | 146 ++++++++++++++++++ flake.nix | 52 +++++++ .../getting-started.html | 6 +- website/index.htm => layouts/index.html | 8 +- layouts/templates/base.html | 28 ++++ layouts/tutorial.html | 17 ++ {src => legacy-ssg}/main.zig | 0 {website => static}/favicon.ico | Bin {website => static}/img/articles.svg | 0 {website => static}/img/atom.svg | 0 {website => static}/img/battery.svg | 0 {website => static}/img/chat-discord.svg | 0 {website => static}/img/chat-irc.svg | 0 {website => static}/img/code.svg | 0 {website => static}/img/community.svg | 0 {website => static}/img/ember.svg | 0 {website => static}/img/goals.svg | 0 {website => static}/img/members.svg | 0 {website => static}/img/pager.svg | 0 {website => static}/img/read-more.svg | 0 {website => static}/img/teacher.svg | 0 {src => static}/style.css | 2 +- 35 files changed, 348 insertions(+), 63 deletions(-) create mode 100644 .envrc create mode 100644 build.zig.zon rename {website => content}/articles/.keep (100%) create mode 100644 content/getting-started.md create mode 100644 content/index.md rename {website => content}/tutorials/01-embedded-basics.md (87%) rename {website => content}/tutorials/02-embedded-programming.md (97%) rename {website/img => content/tutorials}/memory-map.png (100%) delete mode 160000 deps/koino create mode 100644 flake.lock create mode 100644 flake.nix rename website/getting-started.htm => layouts/getting-started.html (95%) rename website/index.htm => layouts/index.html (98%) create mode 100644 layouts/templates/base.html create mode 100644 layouts/tutorial.html rename {src => legacy-ssg}/main.zig (100%) rename {website => static}/favicon.ico (100%) rename {website => static}/img/articles.svg (100%) rename {website => static}/img/atom.svg (100%) rename {website => static}/img/battery.svg (100%) rename {website => static}/img/chat-discord.svg (100%) rename {website => static}/img/chat-irc.svg (100%) rename {website => static}/img/code.svg (100%) rename {website => static}/img/community.svg (100%) rename {website => static}/img/ember.svg (100%) rename {website => static}/img/goals.svg (100%) rename {website => static}/img/members.svg (100%) rename {website => static}/img/pager.svg (100%) rename {website => static}/img/read-more.svg (100%) rename {website => static}/img/teacher.svg (100%) rename {src => static}/style.css (99%) diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..4cc700c --- /dev/null +++ b/.envrc @@ -0,0 +1,2 @@ +# use_nix +use_flake diff --git a/.gitignore b/.gitignore index f2d5b30..06606ca 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ zig-cache/ render/ zig-out/ +.direnv/ diff --git a/.gitmodules b/.gitmodules index 9aade95..e69de29 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "deps/koino"] - path = deps/koino - url = https://github.com/MasterQ32/koino diff --git a/WIP.md b/WIP.md index e9a8dc9..1f26e46 100644 --- a/WIP.md +++ b/WIP.md @@ -5,34 +5,33 @@ These have either incomplete content on the website or a branch where they are being written. - Tutorials - - 01-embedded-basics - - 02-embedded-programming + - 01-embedded-basics + - 02-embedded-programming - Articles - - NONE + - NONE ## TODO Things that should be written eventually. - Tutorials - - Getting started with: - - Arduino/AVR - - LPC1768 - - NRF52 - - Hardware: nRF52840 Dongle - - https://www.nordicsemi.com/Software-and-tools/Development-Kits/nRF52840-Dongle/GetStarted - - https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Connect-for-desktop - - https://infocenter.nordicsemi.com/index.jsp?topic=%2Fug_nc_programmer%2FUG%2Fnrf_connect_programmer%2Fncp_programming_dongle.html - - Raspberry Pi Pico - - STM32 - - What device to chose? - - Introduction to HAL 9001 + - Getting started with: + - Arduino/AVR + - LPC1768 + - NRF52 + - Hardware: nRF52840 Dongle + - https://www.nordicsemi.com/Software-and-tools/Development-Kits/nRF52840-Dongle/GetStarted + - https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Connect-for-desktop + - https://infocenter.nordicsemi.com/index.jsp?topic=%2Fug_nc_programmer%2FUG%2Fnrf_connect_programmer%2Fncp_programming_dongle.html + - Raspberry Pi Pico + - STM32 + - What device to chose? + - Introduction to HAL 9001 - Articles - - `async`/`await` on embedded platforms - - Creating your own JTAG debugger - - Black Magic Probe - - https://paramaggarwal.medium.com/converting-an-stm32f103-board-to-a-black-magic-probe-c013cf2cc38c - - zCOM, a network stack for embedded devices + - Creating your own JTAG debugger + - Black Magic Probe + - https://paramaggarwal.medium.com/converting-an-stm32f103-board-to-a-black-magic-probe-c013cf2cc38c + - zCOM, a network stack for embedded devices ## Ideas @@ -40,4 +39,4 @@ Ideas for things to write that would be great to do eventually or projects to wr - Tutorials - Articles - - Make your own keyboard with zig (and replace qmk) + - Make your own keyboard with zig (and replace qmk) diff --git a/build.zig b/build.zig index 4b2f483..f1d8096 100644 --- a/build.zig +++ b/build.zig @@ -1,33 +1,15 @@ const std = @import("std"); - -const pkgs = struct { - const koino = std.build.Pkg{ - .name = "koino", - .source = .{ .path = "./deps/koino/src/koino.zig" }, - .dependencies = &[_]std.build.Pkg{ - std.build.Pkg{ .name = "libpcre", .source = .{ .path = "deps/koino/vendor/libpcre/src/main.zig" } }, - std.build.Pkg{ .name = "htmlentities", .source = .{ .path = "deps/koino/vendor/htmlentities/src/main.zig" } }, - std.build.Pkg{ .name = "clap", .source = .{ .path = "deps/koino/vendor/zig-clap/clap.zig" } }, - std.build.Pkg{ .name = "zunicode", .source = .{ .path = "deps/koino/vendor/zunicode/src/zunicode.zig" } }, +const zine = @import("zine"); + +pub fn build(b: *std.Build) !void { + // zine.scriptyReferenceDocs(b, "content/documentation/scripty/index.md"); + try zine.addWebsite(b, .{ + .layouts_dir_path = "layouts", + .content_dir_path = "content", + .static_dir_path = "static", + .site = .{ + .base_url = "https://microzig.tech", + .title = "Zig Embedded Group", }, - }; -}; - -const linkPcre = @import("deps/koino/vendor/libpcre/build.zig").linkPcre; - -pub fn build(b: *std.build.Builder) !void { - const target = b.standardTargetOptions(.{}); - const mode = b.standardReleaseOptions(); - - const render_website = b.addExecutable("zeg-website", "src/main.zig"); - render_website.setTarget(target); - render_website.setBuildMode(mode); - try linkPcre(render_website); - render_website.addPackage(pkgs.koino); - render_website.install(); - - const gen_cmd = render_website.run(); - - const gen_step = b.step("gen", "Generates the website"); - gen_step.dependOn(&gen_cmd.step); + }); } diff --git a/build.zig.zon b/build.zig.zon new file mode 100644 index 0000000..4ec7868 --- /dev/null +++ b/build.zig.zon @@ -0,0 +1,11 @@ +.{ + .name = "microzig.tech", + .version = "0.2.0", + .paths = .{"."}, + .dependencies = .{ + .zine = .{ + .url = "https://github.com/kristoff-it/zine/archive/03f80646b83cadb2e693ff5d97445d3e16c8e222.tar.gz", + .hash = "1220e3e4938edf652776349c45b3bb58774d540a050034488ff8dab7dbe410cc2977", + }, + }, +} diff --git a/website/articles/.keep b/content/articles/.keep similarity index 100% rename from website/articles/.keep rename to content/articles/.keep diff --git a/content/getting-started.md b/content/getting-started.md new file mode 100644 index 0000000..d9edbd1 --- /dev/null +++ b/content/getting-started.md @@ -0,0 +1,11 @@ +--- +{ + "title": "Home", + "date": "2020-07-06T00:00:00", + "author": "Felix Queißner", + "draft": false, + "layout": "getting-started.html", + "tags": [] +} +--- +Dummy, full text is implemented in the HTML file for now. diff --git a/content/index.md b/content/index.md new file mode 100644 index 0000000..af1d6e7 --- /dev/null +++ b/content/index.md @@ -0,0 +1,11 @@ +--- +{ + "title": "Home", + "date": "2020-07-06T00:00:00", + "author": "Felix Queißner", + "draft": false, + "layout": "index.html", + "tags": [] +} +--- +Dummy, full text is implemented in the HTML file for now. diff --git a/website/tutorials/01-embedded-basics.md b/content/tutorials/01-embedded-basics.md similarity index 87% rename from website/tutorials/01-embedded-basics.md rename to content/tutorials/01-embedded-basics.md index 1ff6a3f..e1a246a 100644 --- a/website/tutorials/01-embedded-basics.md +++ b/content/tutorials/01-embedded-basics.md @@ -1,3 +1,13 @@ +--- +{ + "title": "Embedded Basics", + "date": "2020-07-06T00:00:00", + "author": "Felix Queißner", + "draft": false, + "layout": "tutorial.html", + "tags": [] +} +--- # Embedded Basics In this tutorial, you'll learn the absolute basics of the embedded world. If @@ -21,6 +31,7 @@ Wikipedia does a good job defining embedded systems with this opener: So at the end of the day, if you are adding any sort of computation to some object who's main purpose is not being a computer, it's an embedded system. Some examples of Embedded systems: + - cars - industrial control systems - mars rovers diff --git a/website/tutorials/02-embedded-programming.md b/content/tutorials/02-embedded-programming.md similarity index 97% rename from website/tutorials/02-embedded-programming.md rename to content/tutorials/02-embedded-programming.md index 1c67a02..86e04e1 100644 --- a/website/tutorials/02-embedded-programming.md +++ b/content/tutorials/02-embedded-programming.md @@ -1,3 +1,13 @@ +--- +{ + "title": "Embedded Basics", + "date": "2020-07-06T00:00:00", + "author": "Felix Queißner", + "draft": false, + "layout": "tutorial.html", + "tags": [] +} +--- # Embedded Programming In this tutorial, you'll learn the ways of the embedded programmer and how to master your MCU. @@ -39,9 +49,9 @@ And last, but not least: You need a [text editor of your choice](https://en.wiki So to get an embedded program up and running, we first need to check out the *memory map* in the datasheet. These usually look like this: -![Memory Map of LPC1768](../img/memory-map.png) +![Memory Map of LPC1768](memory-map.png) -Here you can see that the memory contains continuous flash memory (*On-chip [non-volatile memory](https://en.wikipedia.org/wiki/Non-volatile_memory)*), two sections of SRAM (*On-chip [SRAM](https://en.wikipedia.org/wiki/Static_random-access_memory)*), some *Boot ROM*, and peripherials. +Here you can see that the memory contains continuous flash memory (*On-chip [non-volatile memory](https://en.wikipedia.org/wiki/Non-volatile_memory)*), two sections of SRAM (*On-chip [SRAM](https://en.wikipedia.org/wiki/Static_random-access_memory)*), some *Boot ROM*, and peripherials. This memory map tells us how to design the [linker script](https://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_chapter/ld_3.html#SEC6) and how to lay out our sections (`.text`, `.data`, …). As sections are quite complex topic for themselves, they [will be explained later](#text-data-and-other-curious-sections). For now, we only need to know that `.text` is all of our code (this is where our functions live), `.rodata` is pre-initialized immutable data, `.data` is the pre-initialized mutable data and `.bss` is zero-initialized mutable data. @@ -127,7 +137,7 @@ extern fn _start() callconv(.Naked) noreturn { std.mem.copy(u8, dst_ptr[0..length], src_ptr[0..length]); // call your program enty point here: - … + // … } ``` @@ -138,4 +148,4 @@ As you might have noticed, we have a function called `_start`. This is our progr But you might wonder: How is this entry point called? This is very SOC-dependent and is explained in the respective tutorials for each SOC. The same is true for setting up the [stack pointer](https://en.wikipedia.org/wiki/Call_stack) which is required for calling functions and storing temporary variables. -## MORE COMING SOON \ No newline at end of file +## MORE COMING SOON diff --git a/website/img/memory-map.png b/content/tutorials/memory-map.png similarity index 100% rename from website/img/memory-map.png rename to content/tutorials/memory-map.png diff --git a/deps/koino b/deps/koino deleted file mode 160000 index 5ea268b..0000000 --- a/deps/koino +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 5ea268b50116f2f06bfa9b83f24324ec8c211be1 diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..276e5a4 --- /dev/null +++ b/flake.lock @@ -0,0 +1,146 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1708682153, + "narHash": "sha256-5sMDOig3rOe5/2yrhiVjQZnVranorjKHVkzQGmZNNLY=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "33a498b7b1e3af01cb9f99bed64c96c1b4acaa70", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "release-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1702350026, + "narHash": "sha256-A+GNZFZdfl4JdDphYKBJ5Ef1HOiFsP18vQe9mqjmUis=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9463103069725474698139ab10f17a9d125da859", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "zig": "zig" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "zig": { + "inputs": { + "flake-compat": "flake-compat_2", + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1708647717, + "narHash": "sha256-iA+MJG6isCog6KIq9uyyTmBMacJCwIuecBbkZol8XiE=", + "owner": "mitchellh", + "repo": "zig-overlay", + "rev": "433ed3117af772faad68a50dcf0199bf273f8721", + "type": "github" + }, + "original": { + "owner": "mitchellh", + "repo": "zig-overlay", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..c8c8b64 --- /dev/null +++ b/flake.nix @@ -0,0 +1,52 @@ +{ + description = "microzig website environment"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/release-23.11"; + flake-utils.url = "github:numtide/flake-utils"; + + # required for latest zig + zig.url = "github:mitchellh/zig-overlay"; + + # Used for shell.nix + flake-compat = { + url = github:edolstra/flake-compat; + flake = false; + }; + }; + + outputs = + { self + , nixpkgs + , flake-utils + , ... + } @ inputs: + let + overlays = [ + (final: prev: { zigpkgs = inputs.zig.packages.${prev.system}; }) + ]; + + # Our supported systems are the same supported systems as the Zig binaries + systems = builtins.attrNames inputs.zig.packages; + in + flake-utils.lib.eachSystem systems ( + system: + let + pkgs = import nixpkgs { inherit overlays system; }; + in + rec { + devShells.default = pkgs.mkShell { + nativeBuildInputs = [ pkgs.zigpkgs.master ]; + + buildInputs = [ pkgs.bashInteractive ]; + + shellHook = '' + export SHELL=${pkgs.bashInteractive}/bin/bash + ''; + }; + + # For compatibility with older versions of the `nix` binary + devShell = self.devShells.${system}.default; + } + ); +} diff --git a/website/getting-started.htm b/layouts/getting-started.html similarity index 95% rename from website/getting-started.htm rename to layouts/getting-started.html index f934f0f..646f607 100644 --- a/website/getting-started.htm +++ b/layouts/getting-started.html @@ -1,4 +1,8 @@ -
+ + + + +