Skip to content

Commit 27dd767

Browse files
authored
Update website (ZigEmbeddedGroup#510)
1 parent f186140 commit 27dd767

File tree

17 files changed

+412
-180
lines changed

17 files changed

+412
-180
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,10 @@ jobs:
189189
build-website:
190190
name: Build Website
191191
continue-on-error: true
192-
runs-on: ubuntu-latest
192+
runs-on: ${{ matrix.os }}
193+
strategy:
194+
matrix:
195+
os: [ubuntu-latest, windows-latest]
193196
steps:
194197
- name: Checkout
195198
uses: actions/checkout@v4

README.md

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
# ![MicroZig Logo](design/logo-text-auto.svg)
22

3-
[![Chat](https://img.shields.io/discord/824493524413710336.svg?logo=discord)](https://discord.gg/ShUWykk38X)
4-
[![Downloads](https://img.shields.io/badge/Zig_Package-Download-blue)](https://downloads.microzig.tech/)
5-
[![Continuous Integration](https://github.com/ZigEmbeddedGroup/microzig/actions/workflows/build.yml/badge.svg)](https://github.com/ZigEmbeddedGroup/microzig/actions/workflows/build.yml)
6-
73
> **NOTE:** This is in development; breaks in the API are bound to happen.
84
95
## What version of Zig to use
@@ -12,56 +8,4 @@ Zig 0.14.0
128

139
## Getting Started With MicroZig
1410

15-
### I Want To Use MicroZig
16-
17-
**IMPORTANT:** You may not have to clone the whole repository to get started.
18-
19-
MicroZig uses a monorepo architecture, but provides a lot of different packages. If you just want to get started, head over to [downloads.microzig.tech](https://downloads.microzig.tech/) and download an example for the chip family you desire. MicroZig's version listed here match the zig versions assoicated with them, so version 12.0 match zig 12.0. If you don't see the zig version here you will have to clone the repo to get started.
20-
21-
We support several chip families like the [RP2 family by RaspberryPi Foundation](https://www.raspberrypi.com/products/rp2040/), [STM32 by STMicroelectronics](https://www.st.com/content/st_com/en.html), and many others.
22-
23-
Unpack the example, and run `zig build` in the resulting example folder gives you `zig-out/firmware` which contains the resulting files.
24-
25-
Right now, you gotta figure out how to flash the MCU yourself, but as people say: Google is your friend. But you can also ask for help [on our Discord server](https://discord.gg/ShUWykk38X).
26-
27-
### I Want To Contribute To MicroZig
28-
29-
Please see the [project page](https://github.com/orgs/ZigEmbeddedGroup/projects/1/views/1), it’s used as a place to brainstorm and organize work in ZEG. There will be issues marked as good first issue or drafts for larger ideas that need scoping/breaking ground on.
30-
31-
More words on contribution and development on MicroZig are [further down below](#developing).
32-
33-
## Introduction
34-
35-
This repo contains the infrastructure for getting started in an embedded Zig project; it "gets you to main()". Specifically, it offers:
36-
37-
* a single easy-to-use builder function that:
38-
* generates your linker script
39-
* sets up packages and startup code
40-
* generalized interfaces for common devices, such as UART.
41-
* device drivers for interacting with external hardware
42-
* an uncomplicated method to define xref:interrupts[interrupts]
43-
44-
## Design
45-
46-
For MicroZig internals please see the [Design Document](docs/design.md).
47-
48-
## Repository structure
49-
50-
* `build/` contains the build components of MicroZig.
51-
* `core/` contains the shared components of MicroZig.
52-
* `port/` contains all official board support package.
53-
* `examples/` contains examples that can be used with the board support packages.
54-
* `tools/` contains tooling to work *on* MicroZig itself, so deployment, testing, ...
55-
* `design/` contains images and logos
56-
57-
## Versioning Scheme
58-
59-
MicroZig versions are tightly locked with Zig versions.
60-
61-
The general scheme is `${zig_version}-${commit}-${count}`, so the MicroZig versions will look really similar to
62-
Zigs versions, but with our own commit abbreviations and counters.
63-
64-
As MicroZig sticks to tagged Zig releases, `${zig_version}` will show to which Zig version the MicroZig build is compatible.
65-
66-
Consider the version `0.11.0-abcdef-123` means that this MicroZig version has a commit starting with `abcdef`, which was the 123rd commit of the version that is compatible with Zig 0.11.0.
67-
11+
Go to [microzig.tech](https://microzig.tech)!

website/assets/style.css

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
body {
2+
font-family: "Noto Sans", sans-serif;
3+
}
4+
5+
a {
6+
color: var(--srcery-blue);
7+
text-decoration: none;
8+
}
9+
10+
a:hover {
11+
text-decoration: underline;
212
}
313

414
.upper-header {
@@ -70,9 +80,23 @@ pre {
7080
overflow-x: auto;
7181
}
7282

73-
code {
74-
white-space: pre;
83+
pre code {
84+
white-space: pre;
85+
font-family: "Sometype Mono", monospace;
86+
padding: 0px;
87+
color: var(--srcery-white-bright);
88+
background-color: var(--srcery-black);
89+
}
7590

91+
code {
92+
background-color: var(--srcery-black);
93+
padding-right: 3px;
94+
padding-left: 3px;
95+
padding-top: 2px;
96+
padding-bottom: 2px;
97+
color: var(--srcery-yellow);
98+
white-space: pre;
99+
font-family: "Sometype Mono", monospace;
76100
}
77101

78102
code .attribute { color: var(--srcery-white-bright) }

website/build.zig

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
const std = @import("std");
22
const zine = @import("zine");
33

4-
pub fn build(b: *std.Build) void {
5-
zine.website(b, .{
6-
.title = "Zig Embedded Group",
7-
.host_url = "https://ZigEmbeddedGroup/github.io/microzig",
8-
.content_dir_path = "content",
9-
.layouts_dir_path = "layouts",
10-
.assets_dir_path = "assets",
11-
});
4+
pub fn build(b: *std.Build) !void {
5+
b.getInstallStep().dependOn(&zine.website(b, .{}).step);
6+
7+
const serve = b.step("serve", "Start the Zine dev server");
8+
const run_zine = zine.serve(b, .{});
9+
serve.dependOn(&run_zine.step);
1210
}

website/build.zig.zon

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,19 @@
22
.name = .microzig_website,
33
.fingerprint = 0xc756ec109b390767,
44
.version = "0.2.0",
5-
.paths = .{"."},
5+
.paths = .{
6+
"README.md",
7+
"build.zig",
8+
"build.zig.zon",
9+
"zine.ziggy",
10+
"content",
11+
"assets",
12+
"layouts",
13+
},
614
.dependencies = .{
715
.zine = .{
8-
.url = "git+https://github.com/kristoff-it/zine.git#92ef5f930a65773eb7730f714830a70c9dfebf73",
9-
.hash = "zine-0.0.0-ou6nID_kBQDh3bzW8TpyF5-jtomG90qD3VLTRLb_KB3G",
16+
.url = "git+https://github.com/kristoff-it/zine#aa43d44c2d271cb309549e8d7eab0a7fe6bb06f2",
17+
.hash = "zine-0.9.0-ou6nINpTFgA_E5pd1H6CXmBMdL_oNVAeD1ca3DzJoXzX",
1018
},
1119
},
1220
}

website/content/devlog.smd

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
.title = "Devlog",
3+
.date = @date("2021-07-06T00:00:00"),
4+
.author = "ZEG contributors",
5+
.layout = "devlog.shtml",
6+
.alternatives = [{
7+
.name = "rss",
8+
.layout = "devlog.xml",
9+
.output = "devlog/rss.xml",
10+
}],
11+
.draft = false,
12+
---
13+
14+
[]($section.id('about'))
15+
## About
16+
17+
This is a non-exhaustive, curated list of changes meant to help users quickly
18+
see what has improved since they last checked.
19+
20+
You can [subscribe to this page via RSS]($link.alternative('rss')).
21+
22+
## Changes
23+
24+
[]($section.id('start').data('date','2025-04-28'))
25+
26+
### Devlog Begins!
27+
28+
The MicroZig devlog is now set up for contributors to showcase their work. When
29+
adding your work, add to the top of the list.

website/content/docs.smd

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
.title = "Documentation",
3+
.date = @date("2024-11-02T00:00:00"),
4+
.author = "Matthew Knight",
5+
.draft = false,
6+
.layout = "index.shtml",
7+
.description = "MicroZig: Documentation",
8+
.tags = []
9+
---
10+
11+
# Documentation
12+
13+
- [Getting Started](docs/getting-started)
14+
- [Contributing Guidelines](docs/contributing)
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
.title = "Contributing Guide",
3+
.date = @date("2024-11-02T00:00:00"),
4+
.author = "Matthew Knight",
5+
.draft = false,
6+
.layout = "index.shtml",
7+
.description = "MicroZig: Contributing",
8+
.tags = []
9+
---
10+
11+
# Contributing Guide
12+
13+
## Coding Style
14+
15+
In MicroZig we break from the suggested coding style by the ZSF:
16+
17+
- Use `snake_case` for functions and methods.
18+
- When there is an acronym in a type name, we keep the acronym uppercase, and
19+
separate it from other components in the name with underscores. Some examples:
20+
- `GpioMask -> GPIO_Mask`
21+
- `DigitalIo -> Digital_IO`
22+
- `HttpsOverCan -> HTTPS_Over_CAN`
23+
24+
Like any naming convention, it is broken when appropriate. In the future we
25+
will have linters suggest naming changes when you make a PR, but they will
26+
never be mandatory.
27+
28+
## Monorepo
29+
30+
MicroZig is developed as a monorepo. In the past we had it split into a number
31+
of small repos, but we found it difficult to maintain all those separate
32+
components. The monorepo has shown a significant improvement in development
33+
velocity and confidence in changes.
34+
35+
### Packaging
36+
37+
MicroZig does not force users to download the entire codebase if they use a
38+
released version. This is done through a small project called
39+
[boxzer](https://github.com/mattnite/boxzer), which creates a separate tarball
40+
for each package in MicroZig. With the use of lazy dependencies in the Zig
41+
build system, a user will download the `esp` package for their hardware, but
42+
nothing related to `stm32`. This will enable us to support a lot of hardware
43+
without MicroZig users needing to download gigabytes everytime they run their
44+
CI.
45+
46+
## Naming Sub-packages
47+
48+
We try to keep package names identical to their path in the project, with
49+
underscores replacing path separators. Package names in Zig are limted to 32
50+
bytes, so the earlier components are often shortened. We also try to keep `mz`
51+
the first component in the name to denote the package as being part of
52+
MicroZig. For example the `examples/stmicro/stm32` package has the name
53+
`mz_ex_stmicro_stm32` as we've hit the name length limit
54+
55+
If a package is under `modules`, then the package has a single name for itself,
56+
such as `foundationlibc`.
57+
58+
## Versioning and Release Process
59+
60+
MicroZig follows semantic versioning, and while all packages have their own
61+
version, they are released as a single group.
62+
63+
- **Major**: Micro MicroZig will have a 0 for the major version until Zig reaches 1.0.
64+
- **Minor**: We always depend on a stable release of Zig, and the minor version of
65+
MicroZig will always match the minor version of the compiler we depend on.
66+
Patch versions of the compiler are not reflected in this scheme.
67+
- **Patch**: The patch number is incremented once every time we release, note that
68+
since MicroZig is 0.x, semantic versioning allows for breaks even between
69+
patch versions.
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
---
2+
.title = "Getting Started",
3+
.date = @date("2024-11-02T00:00:00"),
4+
.author = "Matthew Knight",
5+
.draft = false,
6+
.layout = "index.shtml",
7+
.description = "MicroZig: Getting Started",
8+
.tags = []
9+
---
10+
11+
# Getting Started
12+
13+
## Blinky on the Raspberry Pi Pico
14+
15+
This tutorial assumes that you're programming a [Raspberry Pi
16+
Pico](https://www.raspberrypi.com/products/raspberry-pi-pico/). This hardware
17+
is by far the best supported in MicroZig. It's a fairly alpha project based on
18+
a fairly new and breaking language so your mileage may vary. That being said,
19+
it does support other hardware, such as Microchip's `ATSAMD51J19` which was
20+
used for the [2024 SYCL](https://sycl.it)
21+
[Badge](https://github.com/ZigEmbeddedGroup/sycl-badge/blob/main/docs/introduction/).
22+
23+
## Let's Begin
24+
25+
Assuming you've initialized a zig project with `zig init`, or have set one up
26+
yourself, you can add microzig as a dependency with the following command:
27+
28+
```sh
29+
zig fetch --save=microzig https://microzig.tech/downloads/microzig/0.13.2/microzig.tar.gz
30+
```
31+
32+
Then in your `build.zig`:
33+
34+
```zig
35+
const std = @import("std");
36+
const microzig = @import("microzig");
37+
38+
const MicroBuild = microzig.MicroBuild(.{
39+
.rp2xxx = true,
40+
});
41+
42+
pub fn build(b: *std.Build) void {
43+
const mz_dep = b.dependency("microzig", .{});
44+
const mb = MicroBuild.init(b, mz_dep) orelse return;
45+
46+
const firmware = mb.add_firmware(.{
47+
.name = "blinky",
48+
.target = mb.ports.rp2xxx.boards.raspberrypi.pico,
49+
.optimize = .ReleaseSmall,
50+
.root_source_file = b.path("src/main.zig"),
51+
});
52+
53+
// We call this twice to demonstrate that the default binary output for
54+
// RP2040 is UF2, but we can also output other formats easily
55+
mb.install_firmware(firmware, .{ });
56+
mb.install_firmware(firmware, .{ .format = .elf });
57+
}
58+
```
59+
60+
and for your `src/main.zig`, let's start with a classic blinky program. Yes,
61+
most of the main stdlib is available for use on an MCU with Zig:
62+
63+
```zig
64+
const std = @import("std");
65+
const microzig = @import("microzig");
66+
const rp2xxx = microzig.hal;
67+
const time = rp2xxx.time;
68+
69+
// Compile-time pin configuration
70+
const pin_config = rp2xxx.pins.GlobalConfiguration{
71+
.GPIO25 = .{
72+
.name = "led",
73+
.direction = .out,
74+
},
75+
};
76+
77+
const pins = pin_config.pins();
78+
79+
pub fn main() !void {
80+
pin_config.apply();
81+
82+
while (true) {
83+
pins.led.toggle();
84+
time.sleep_ms(250);
85+
}
86+
}
87+
```
88+
89+
Now if you run `zig build`, our extremely simple program will be installed under `zig-out`:
90+
91+
```
92+
zig-out
93+
└── firmware
94+
├── blinky.uf2
95+
   └── blinky.elf
96+
```
97+
98+
And if we run the `file` command, often found on Linux and MacOS, on the ELF
99+
file we'll see that it's targetting ARM!:
100+
101+
```
102+
zig-out/firmware/blinky.elf: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, with debug_info, not stripped
103+
```
104+
105+
## Programming the MCU
106+
107+
To activate the UF2 bootloader, power must be applied to the pico while the
108+
`BOOTSEL` button is held. This is best done by connecting a button from `RUN`
109+
to ground, pressing both buttons, and releasing the `RUN` button first, then
110+
`BOOTSEL`. The other option is to plug/unplug the USB cable which is awkward
111+
and gets tiresome.
112+
113+
Copy the uf2 file into the mounted drive. Execution should take place immediately.
114+
115+
## Further Resources
116+
117+
- [Zig Language Reference](https://ziglang.org/documentation/0.14.0/)

0 commit comments

Comments
 (0)