mirror of
https://github.com/im-tomu/fomu-workshop.git
synced 2024-09-20 03:10:12 +00:00
zig: updates for 0.9.0 (#610)
This commit is contained in:
parent
3af9a2424a
commit
24fd943692
6
.github/workflows/test.yml
vendored
6
.github/workflows/test.yml
vendored
@ -45,8 +45,8 @@ jobs:
|
|||||||
- name: Install (Ubuntu)
|
- name: Install (Ubuntu)
|
||||||
if: matrix.os == 'ubuntu'
|
if: matrix.os == 'ubuntu'
|
||||||
run: |
|
run: |
|
||||||
curl -L https://ziglang.org/download/0.8.0/zig-linux-x86_64-0.8.0.tar.xz | tar -xJf -
|
curl -L https://ziglang.org/download/0.9.0/zig-linux-x86_64-0.9.0.tar.xz | tar -xJf -
|
||||||
echo "$(pwd)/zig-linux-x86_64-0.8.0" >> $GITHUB_PATH
|
echo "$(pwd)/zig-linux-x86_64-0.9.0" >> $GITHUB_PATH
|
||||||
|
|
||||||
- name: Install (Mac OS)
|
- name: Install (Mac OS)
|
||||||
if: matrix.os == 'macos'
|
if: matrix.os == 'macos'
|
||||||
@ -55,7 +55,7 @@ jobs:
|
|||||||
- name: Install (Windows)
|
- name: Install (Windows)
|
||||||
if: matrix.os == 'windows'
|
if: matrix.os == 'windows'
|
||||||
run: |
|
run: |
|
||||||
choco install zig --version 0.8.0
|
choco install zig --version 0.9.0
|
||||||
ln -s $(which python) /usr/bin/python3
|
ln -s $(which python) /usr/bin/python3
|
||||||
|
|
||||||
- run: python ./get-toolchain.py
|
- run: python ./get-toolchain.py
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
# riscv-zig-blink
|
# riscv-zig-blink
|
||||||
|
|
||||||
Written against zig 0.8.0
|
Written against zig 0.9.0
|
||||||
|
|
||||||
You can obtain the zig compiler via https://ziglang.org/download/
|
You can obtain the zig compiler via https://ziglang.org/download/
|
||||||
e.g. a linux user might run:
|
e.g. a linux user might run:
|
||||||
```
|
```
|
||||||
curl -L https://ziglang.org/download/0.8.0/zig-linux-x86_64-0.8.0.tar.xz | tar -xJf -
|
curl -L https://ziglang.org/download/0.9.0/zig-linux-x86_64-0.9.0.tar.xz | tar -xJf -
|
||||||
alias zig=./zig-linux-x86_64-0.8.0/zig
|
alias zig=./zig-linux-x86_64-0.9.0/zig
|
||||||
```
|
```
|
||||||
|
|
||||||
Run `zig build --help` from this directory for usage and options.
|
Run `zig build --help` from this directory for usage and options.
|
||||||
|
@ -14,7 +14,7 @@ pub fn build(b: *Builder) void {
|
|||||||
.explicit = &std.Target.riscv.cpu.generic_rv32,
|
.explicit = &std.Target.riscv.cpu.generic_rv32,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
elf.setLinkerScriptPath("ld/linker.ld");
|
elf.setLinkerScriptPath(.{ .path = "ld/linker.ld" });
|
||||||
elf.setBuildMode(mode);
|
elf.setBuildMode(mode);
|
||||||
// The ELF file contains debug symbols and can be passed to gdb for remote debugging
|
// The ELF file contains debug symbols and can be passed to gdb for remote debugging
|
||||||
if (b.option(bool, "emit-elf", "Should an ELF file be emitted in the current directory?") orelse false) {
|
if (b.option(bool, "emit-elf", "Should an ELF file be emitted in the current directory?") orelse false) {
|
||||||
|
@ -17,6 +17,7 @@ comptime {
|
|||||||
/// Panic function that sets LED to red and flashing + prints the panic message over messible
|
/// Panic function that sets LED to red and flashing + prints the panic message over messible
|
||||||
pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {
|
pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {
|
||||||
@setCold(true);
|
@setCold(true);
|
||||||
|
_ = stack_trace;
|
||||||
|
|
||||||
// Put LED into non-raw flashing mode
|
// Put LED into non-raw flashing mode
|
||||||
RGB.CTRL.* = .{
|
RGB.CTRL.* = .{
|
||||||
@ -49,6 +50,7 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noretur
|
|||||||
|
|
||||||
const WriteError = error{};
|
const WriteError = error{};
|
||||||
fn messibleWrite(self: void, bytes: []const u8) WriteError!usize {
|
fn messibleWrite(self: void, bytes: []const u8) WriteError!usize {
|
||||||
|
_ = self;
|
||||||
while (true) {
|
while (true) {
|
||||||
const bytes_written = MESSIBLE.write(bytes);
|
const bytes_written = MESSIBLE.write(bytes);
|
||||||
if (bytes_written != 0) return bytes_written;
|
if (bytes_written != 0) return bytes_written;
|
||||||
@ -58,6 +60,7 @@ pub const messibleWriter = std.io.Writer(void, WriteError, messibleWrite){ .cont
|
|||||||
|
|
||||||
const ReadError = error{};
|
const ReadError = error{};
|
||||||
fn messibleRead(self: void, buffer: []u8) ReadError!usize {
|
fn messibleRead(self: void, buffer: []u8) ReadError!usize {
|
||||||
|
_ = self;
|
||||||
while (true) {
|
while (true) {
|
||||||
const bytes_read = MESSIBLE.read(buffer);
|
const bytes_read = MESSIBLE.read(buffer);
|
||||||
if (bytes_read != 0) return bytes_read;
|
if (bytes_read != 0) return bytes_read;
|
||||||
|
@ -14,7 +14,7 @@ pub const RGB = struct {
|
|||||||
/// Writing to this register has no immediate effect – data isn’t written until the DAT register is written.
|
/// Writing to this register has no immediate effect – data isn’t written until the DAT register is written.
|
||||||
pub const ADDR = @intToPtr(*volatile u4, base + 0x4);
|
pub const ADDR = @intToPtr(*volatile u4, base + 0x4);
|
||||||
|
|
||||||
pub const Register = enum {
|
pub const Register = enum(u4) {
|
||||||
PWRR = 1,
|
PWRR = 1,
|
||||||
PWRG = 2,
|
PWRG = 2,
|
||||||
PWRB = 3,
|
PWRB = 3,
|
||||||
|
Loading…
Reference in New Issue
Block a user