Coder Social home page Coder Social logo

zigembeddedgroup / microzig Goto Github PK

View Code? Open in Web Editor NEW
1.1K 27.0 81.0 12.04 MB

Unified abstraction layer and HAL for several microcontrollers

License: zlib License

Zig 79.91% Shell 0.02% RobotFramework 0.04% Assembly 3.89% C 14.64% Nix 0.35% HTML 0.85% CSS 0.30%
ziglang zig-package zig embedded hal

microzig's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

microzig's Issues

USB driver: serialization improvements

Currently, USB descriptors have a Serialize function that returns an array of bytes. The byte order is handled manually for every integer greater than u8. Instead, Serialize should accept something like the BufferWriter proposed in #201 (probably with an additional field that indicates buffer endianness) with writeInt function that utilizes std.mem.writeInt that would accept buffer endianness. With such implementation we would not have to handle byte order manualy in each serialize implementation.

Something like:

pub fn serialize(self: *@This(), bw: *BufferWriter) !void {
        try bw.writeInt(u8, 8);
        try bw.writeInt(u8, @intFromEnum(self.descriptor_type));
        try bw.writeInt(u16, self.report_length);  // u16, BufferWritter will take care of proper byte order
        ...
 }

AVR: Support C backend

Right now, the AVR support is degraded. With using avr-gcc, we can make it work quite well though.

This requires updating the AVR code to use a different logic in the start code, and just implement a extern fn main() c_int, that jumps into the microzig code and is happy about .bss, .data being already set up.

As-is, we cannot implement the whole startup logic ourselves via C backend, as some features are still missing.

Compile error on Raspberry Pi

Building a microzig project on a Raspberry Pi 2 fails with this error:

/home/pi/.cache/zig/p/1220af58bdaa721b8189f3a7adfda660517dd354463463388e96d69fe4ceccf80b92/build.zig:161:55: error: expected type 'usize', found 'u64'
                .elf, .bin, .hex, .dfu, .esp => |val| {
                                                      ^
/home/pi/.cache/zig/p/1220af58bdaa721b8189f3a7adfda660517dd354463463388e96d69fe4ceccf80b92/build.zig:161:55: note: unsigned 32-bit int cannot represent all possible unsigned 64-bit values

What could be the reason for this? Maybe because the Pi's CPU is 32 bit, and u64 is hardcoded somewhere?

No output files generated

If I clone the repository and run zig build, zig-out folder isn't generated. Only zig-cache is. Tried with this compiler zig-linux-x86_64-0.11.0-dev.2317+46b2f1f70.

I would expect for test programs to compile.

Improve customization of linker scripts

Right now in raspberrypi-rp2040 we've had to hardcode the linker script to allow a boot2 section, time_critical section, and have all of sram executable so that some of it may be executed by the processor. Linker scripts can be pretty complex, but maybe we can reduce the feature to only what's typically required in embedded systems. If users are already at the point where they need very specific features or linker script layouts then it's already easy enough for them to write their own.

ESP support tracking

This issue tracks the support status for ESP32 series Espressif SoCs and will be updated with new tasks continously:

  • Add GPIO driver - in progress
  • Add UART driver
  • Add support for the ESP32-C6
  • Interrupt support
  • Add support for digital addressable RGB LEDs found on many devboards (WS2811 compatible)
  • Add support for the ESP-IDF Application Image Format
  • Enable caches

Add documentation to the website

A documentation page for this repo would be very helpful for new embedded programmers who want to get into embedded development with Zig. I would be very willing to aid in a project for making a static site on github of all the documentation, maybe in a javadocs style of documentation. Would this be a feature that people would want? Would there be other people willing to aid in this project?

Various issues

I am having troubles getting examples building with the monorepo. Reporting my issues as requested.

  1. No mention of need to install requirements.
  2. bundle.py uses pathspec with the negate kwarg in match_tree, but requirements.txt doesn't pin a version. This used 0.11.0 on my machine, but negate shows up in 0.12.0
  3. bundle.py uses the --hard-deference option from tar, which is not a valid option for OSX tar. I suggest using tarlib. I got around this, however, by installing gnutar with brew and symlinking it to tar on my PATH.
  4. No .zon files with the build.zig files for the example. I don't know how to write these to have it point to the server.

[Tracking issue] Platform support/wishlist

Currently, the number of supported platforms is rather minimal. If the owners are alright with it, I'd like to designate this issue as a tracking issue for boards/chips which are not yet implemented in here with the aim of getting a good selection supported.

To start off the list, here's a few chips I have come across:

  • ATMega644/A (chip)
  • ATTiny25/45/85 (chip)

`add_include_path()` does not work

Versions

  • Zig 0.12.0
  • MicroZig 0.12.0

Issue

I am having trouble importing a C library.

I want to import pico-sdk to use the CYW43 driver on a Raspberry Pi Pico W. I found a method firmware.add_include_path() for specifying an include path, which is likely to work like exe.addIncludePath(), but it does not work.

build.zig

const MicroZig = @import("microzig/build");
const rp2040 = @import("microzig/bsp/raspberrypi/rp2040");

pub fn build(b: *std.Build) void {
    const mz = MicroZig.init(b, .{});
    const optimize = b.standardOptimizeOption(.{});

    const firmware = mz.add_firmware(b, .{
        .name = "main",
        .target = rp2040.boards.raspberrypi.pico,
        .optimize = optimize,
        .root_source_file = .{ .path = "src/main.zig" },
    });

    firmware.add_include_path(.{ .path = "pico-sdk/src/common/pico_base/include" });
    firmware.add_include_path(.{ .path = "pico-sdk/src/common/pico_stdlib/include" });
    firmware.add_include_path(.{ .path = "pico-sdk/src/rp2_common/pico_cyw43_arch/include" });

    mz.install_firmware(b, firmware, .{});
    mz.install_firmware(b, firmware, .{ .format = .elf });
}

build.zig.zon

.{
    .name = "project",
    .version = "0.1.0",
    .dependencies = .{
        .@"microzig/build" = .{
            .url = "https://downloads.microzig.tech/microzig-0.12.0/build-0.0.0.tar.gz",
            .hash = "1220362d63876dd7ad88d0ee55ab24c2eb7fc49b0441703111d98d7b78bf315ebf70",
        },
        .@"microzig/bsp/raspberrypi/rp2040" = .{
            .url = "https://downloads.microzig.tech/microzig-0.12.0/bsp/raspberrypi/rp2040-0.0.0.tar.gz",
            .hash = "1220a7f44ffad57f0c59bfc4ae68632c274c5762795854dbe04dacbb086bb05856fa",
        },
    },
    .paths = .{
        "LICENSE",
        "README.md",
        "build.zig",
        "build.zig.zon",
        "src",
        "scripts",
    },
    .minimum_zig_version = "0.12.0",
}

src/main.zig

const std = @import("std");
const microzig = @import("microzig");

const c = @cImport({
    @cInclude("pico/cyw43_arch.h");
});

pub fn main() !void {
    c.cyw43_arch_init();
}

pico-sdk is located in /home/***/path/to/project as a git submodule.

result:

$ zig build -Doptimize=ReleaseSmall
install
└─ install generated to main.uf2
   └─ run elf2uf2 (main.uf2)
      └─ zig build-exe main ReleaseSmall thumb-freestanding-eabi 2 errors
src/main.zig:4:11: error: C import failed
const c = @cImport({
          ^~~~~~~~
src/main.zig:4:11: note: libc headers not available; compilation does not link against libc
referenced by:
    main: src/main.zig:12:5
    microzig_main: /home/***/.cache/zig/p/1220d6f088f42b4d34f832990e0cbcf790b4538a7e5a7a720c13bf07a4b1241089c8/src/start.zig:126:18
    remaining reference traces hidden; use '-freference-trace' to see all reference traces
/home/***/path/to/project/zig-cache/o/2757200903cccd5f17dd400c1960e67d/cimport.h:1:10: error: 'pico/cyw43_arch.h' file not found
#include <pico/cyw43_arch.h>
         ^
error: the following command failed with 2 compilation errors:
/home/***/.zig/zig-linux-x86_64-0.12.0/zig build-exe -OReleaseSmall -target thumb-freestanding-eabi -mcpu cortex_m0plus -I /home/***/path/to/project/pico-sdk/src/common/pico_stdlib/include -I /home/***/path/to/project/pico-sdk/src/rp2_common/pico_cyw43_arch/include --dep app --dep microzig -Mroot=/home/***/.cache/zig/p/1220d6f088f42b4d34f832990e0cbcf790b4538a7e5a7a720c13bf07a4b1241089c8/src/start.zig --dep microzig -Mapp=/home/***/path/to/project/src/main.zig --dep config --dep chip --dep cpu --dep hal --dep board -Mmicrozig=/home/***/.cache/zig/p/1220d6f088f42b4d34f832990e0cbcf790b4538a7e5a7a720c13bf07a4b1241089c8/src/microzig.zig -Mconfig=/home/***/path/to/project/zig-cache/c/cb74838774d212d46a4b6ad47bca5bcc/options.zig --dep microzig -Mchip=/home/***/path/to/project/zig-cache/o/01a9a7f0711c6fac54cec6ec4ab59da3/chip.zig --dep microzig -Mcpu=/home/***/.cache/zig/p/1220d6f088f42b4d34f832990e0cbcf790b4538a7e5a7a720c13bf07a4b1241089c8/src/cpus/cortex-m.zig --dep microzig -Mhal=/home/***/.cache/zig/p/1220a7f44ffad57f0c59bfc4ae68632c274c5762795854dbe04dacbb086bb05856fa/src/hal.zig --dep microzig --dep bootloader -Mboard=/home/***/.cache/zig/p/1220a7f44ffad57f0c59bfc4ae68632c274c5762795854dbe04dacbb086bb05856fa/src/boards/raspberry_pi_pico.zig -Mbootloader=/home/***/path/to/project/zig-cache/o/e9a2f6a4c63be6395f5681702ab50778/w25q080.bin --cache-dir /home/***/path/to/project/zig-cache --global-cache-dir /home/***/.cache/zig --name main -static -fcompiler-rt --script /home/***/.cache/zig/p/1220a7f44ffad57f0c59bfc4ae68632c274c5762795854dbe04dacbb086bb05856fa/rp2040.ld --listen=- 
Build Summary: 8/13 steps succeeded; 1 failed (disable with --summary none)
install transitive failure
├─ install generated to main.uf2 transitive failure
│  └─ run elf2uf2 (main.uf2) transitive failure
│     └─ zig build-exe main ReleaseSmall thumb-freestanding-eabi 2 errors
└─ install generated to main.elf transitive failure
   └─ zig build-exe main ReleaseSmall thumb-freestanding-eabi (+6 more reused dependencies)
error: the following build command failed with exit code 1:
/home/***/path/to/project/zig-cache/o/c9cafd921ac2f4c0d5c2c804c98770b0/build /home/***/.zig/zig-linux-x86_64-0.12.0/zig /home/***/path/to/project /home/***/path/to/project/zig-cache /home/***/.cache/zig --seed 0x321ad4c6 -Z5ce5c6b4c9fc2a23 -Doptimize=ReleaseSmall

It seems correct include paths are specified (-I) in the zig build-exe command.

Alternatively, using an absolute path works, but #includes in the C files cannot be resolved.

src/main.zig

const c = @cImport({
    @cInclude("/home/***/path/to/project/pico-sdk/src/rp2_common/pico_cyw43_arch/include/pico/cyw43_arch.h");
});

result:

/home/***/path/to/project/pico-sdk/src/rp2_common/pico_cyw43_arch/include/pico/cyw43_arch.h:10:10: error: 'pico.h' file not found
#include "pico.h"
         ^

Getting Started

How do I get started ? The instructions on setting up a new project seem out of date.
I would like to develop for raspberry pi pico.

RP2040 Interrupt Support

Very roughly, the HAL needs to support 4 things:

  • Registering callbacks in the vector table
  • Enabling interrupts
  • Masking event-types
  • Acknowledging the interrupt

ATmega328P SRAM memory map

Hi all I'm new to the project as studying the source code to get a better handle on how MicroZig works

I have a question regarding the .memory_regions specified in

.{ .offset = 0x000000, .length = 32 * 1024, .kind = .flash },
.{ .offset = 0x800100, .length = 2048, .kind = .ram },

To help me get a better understanding I have pulled the ATmega328P.atdf directly in conjunction to the hardware reference manual

Based on this the memory address starts at 0x000000 with the following block sizes

Sector Size Offset
prog 0x8000 0x00000
signatures 0x0003 0x08000
fuses 0x0003 0x08003
lockbits 0x0001 0x08006
data.ram 0x0100 0x08007

I'm not sure how to get to the ram offset 0x800100 as set here:

.memory_regions = &.{
    .{ .offset = 0x000000, .length = 32 * 1024, .kind = .flash },
    .{ .offset = 0x800100, .length = 2048, .kind = .ram },
},

My end-game here is to add support for AVR8 - tinyAVR - specifically the Attiny85

Support for ATmega32U4

I've been working on a Keyboard for a while based on the ATmega32U4 and would love to someday have the firmware written in Zig.
@MasterQ32
I have:

  • Double checked all the addresses from the 328p matched the 32u4 datasheet
  • bumped the ram from 2kb -> 2.5kb
  • Changed the USART0 -> USART1 per the json
  • Added ATmega32u4.json and patched the COMM_SCK_RATE_3BIT enum, because it was missing a size field
  • Add the Adafruit itsy bitsy 32u4 board
    https://github.com/biom4st3r/microzig

I cannot test until the dependencies are updated to latest zig which removed LazyPath.path

STM32F4XX does not support SysTick register

I think this may be a bug in regz, not microzig, or maybe whatever svd file that was used to generate the register definitions. afaik All Cortex devices have the same definition of this register. I coppied a samd one and it worked without issue

Bug: USB packet split issue for 3 or more packets

This is a self-reported bug for my recent code change in the USB driver that introduced chunked data (packet split). The current implementation allows for max of 2 packets of response data, which is enforced by the TMP buffer size of 128 bytes (2 * 64). This is probably enough for all command response cases. However, there is a bug that could manifest if the buffer size is extended in the future to support 3 or more packets.

Short version:
Bug is one liner, we should use try_peek instead of try_read when sending next chunk of data

Long version:
I reproduced this bug in this branch where last commit is solution, and previous commit is bug introduction. To enforce 3 packets in USB hand shake I extended buffor size and put a lot of redundant data. In first case (without fix) bug is reproduced and Windows generates error on USB hand shake. After fix everything is OK, device is detected correctly. We should use try_peek that returns data to consume and don't advance buffor read cursor, because we do that manualy after we receive confirmation that chunk/packet of data was sent.

I'm sorry for that mistake. I will create PR shortly.

CC: @r4gus

Usb.init_clk() freezes depending on timing

I have been struggling to run USB device code, e.g. the HID demo, on any rp2040 board because the program always freezes in the call to rp2040.usb.Usb.init_clk(). However, @arkadiuszwojcik helped me debug tonight and found that it is possible to get it to work with a timing hack.

Steps to reproduce

Modify the example usb_hid.zig around the clock initialization:

    ...
    std.log.debug("one", .{});
    // First we initialize the USB clock
    rp2040.usb.Usb.init_clk();
    std.log.debug("two", .{});
    ...

Run zig build -Doptimize=ReleaseSmall.

When flashing a Raspberry Pi Pico H or similar board, UART prints one but not two, and the LED never blinks.

Modify bsp/raspberrypi/rp2040/src/hal/resets.zig such that the empty while loop has at least one NOP instruction:

pub fn reset(mask: Mask) void {
    ...
    while ((RESETS.RESET_DONE.raw & raw_mask) != raw_mask) {
        asm volatile (
            \\ nop
        );
    }
}

...and suddenly, the LED blinks and we see two in the log. It also suffices to add some log lines inside reset() to change the timing of operations, although it may not be as consistent.

With -Doptimize=Debug, there is no issue with or without the asm block. With ReleaseSmall, it is as described above. With ReleaseFast and ReleaseSafe, I still get freezing even with the asm block.

Other notes

As a reference point, the stock pico-examples/usb/device/dev_hid_composite example from Raspberry Pi / TinyUSB works out of the box for me.

The above findings are true both on main (bb88889) and based on #211.

Add "hal" packages to microzig

Similar to how an app can have it's own packages, create another option to the build function that adds a "hal" package. This is a package that only depends on microzig and would be used to write drivers for chips with similar peripherals, Eg. an nrf52 hal.

An application would be able to access the hal via microzig.hal, and with it's access to other microzig namespaces it would be able to do conditional compilation for different chips if the need arose.

documentation not clear and failre when using example

I'm attempting to use microzig, and I'm also very new to zig and the instructions in README.adoc assume that you have a lot of knowledge about zig and how microzig works.

I attempted to use the sample and despite inferring how to make it work, even with modifications, it fails to compile.

run: zig init-exe

undocumented commands (implied via the vague statement: add the hardware support package as a submodule, this is also the "simple way" as zig init-exe doesn't do a git init, so can't do some git submodule command to add it):

mkdir deps
cd deps
git clone --recursive https://github.com/ZigEmbeddedGroup/microchip-atmega
cd ..

replace build.zig (undocumented what file, and need to replace hardware_support_package with microchip-atmega and replace root_source_file with source_file) w/:

const std = @import("std");
const atmega = @import("deps/microchip-atmega/build.zig");

// the hardware support package should have microzig as a dependency
const microzig = @import("deps/microchip-atmega/deps/microzig/build.zig");

pub fn build(b: *std.build.Builder) !void {
    const optimize = b.standardOptimizeOption(.{});
    var exe = microzig.addEmbeddedExecutable( b, .{
        .name = "my-executable",
        .source_file = .{
            .path = "src/main.zig",
        },
        .backing = .{
            .board = atmega.boards.arduino_nano,

            // instead of a board, you can use the raw chip as well
            // .chip = atmega.chips.atmega328p,
        },
        .optimize = optimize,
    });
    exe.install();
}

replace src/main.zig with the next block (undocumented what file to put it in).

run zig build and see the following failure:

$ zig build
zig build-exe my-executable Debug avr-freestanding-eabi: error: the following command terminated unexpectedly:
[xxx]/github/zig/build/zig2 build-exe /private/tmp/mcre/deps/microchip-atmega/deps/microzig/src/start.zig -fno-strip --cache-dir /private/tmp/mcre/zig-cache --global-cache-dir [xxx]/.cache/zig --name my-executable -fno-compiler-rt -fsingle-threaded -target avr-freestanding-eabi -mcpu avr5 --script /private/tmp/mcre/zig-cache/microzig/bad2341405a5fe8c06f6286f91ea1100/ATmega328P_AVR5.ld --mod microzig:config,chip,cpu,hal,board:/private/tmp/mcre/deps/microchip-atmega/deps/microzig/src/microzig.zig --mod chip:microzig:/private/tmp/mcre/deps/microchip-atmega/src/chips/ATmega328P.zig --mod board:microzig:/private/tmp/mcre/deps/microchip-atmega/src/boards/arduino_nano.zig --mod hal:microzig:/private/tmp/mcre/deps/microchip-atmega/src/hals/ATmega328P.zig --mod app:microzig:/private/tmp/mcre/src/main.zig --mod cpu:microzig:/private/tmp/mcre/deps/microchip-atmega/deps/microzig/src/modules/cpus/avr5.zig --mod config::/private/tmp/mcre/zig-cache/microzig/config-6df6165a62f30831cad66fa94379f8d3.zig --deps app,microzig --enable-cache --listen=- 
Build Summary: 1/4 steps succeeded; 1 failed (disable with -fno-summary)
install transitive failure
└─ install my-executable transitive failure
   └─ zig build-exe my-executable Debug avr-freestanding-eabi failure
      └─ linkerscript success
error: the following build command failed with exit code 1:
/private/tmp/mcre/zig-cache/o/b840765e239219fa1562b810d024cd97/build [xxx]/github/zig/build/zig2 /private/tmp/mcre /private/tmp/mcre/zig-cache [xxx]/.cache/zig

environment: MacOS Ventura 13.2

zig version: 0.11.0-dev.2249+dcdb87836

I'm unsure what to do now to make the necessary executable.

Suggestions re: STM32 from a Rust Embedded dev

Hey! Chiming in as someone doing embedded Rust things:

Just wanted to share particularly with respect to STM32 chips, which have an insane number of variants, SVD files that are often wrong, and a lot of challenging details, it might be worth looking at https://github.com/embassy-rs/stm32-data, which https://embassy.rs uses for the unified stm32 HAL. It is typically more actively patched and maintained for correctness than the upstream STM32 SVD data sources.

In general, SVD files often require patching and continued maintenance, https://github.com/embassy-rs/chiptool might be a good inspiration, which uses YAML files to apply patches and groupings, rather than hand-editing SVD files.

Feel free to close, or let me know if y'all would like to share notes on anything. Excited to see what you all build!

(edited title to make it more clear this is just my opinion, not like an "offical embedded rust position")

Implement compiler_rt for AVR

This work requires upstreaming to https://github.com/ziglang/zig

As a repro compile this program with the following build command:

export fn foo(a: i32, b: i32) i32 {
    return a * b;
}
zig build-exe -target avr-freestanding -mcpu=avr5 test.zig -O ReleaseSmall

and you'll see the following output:

LLVM ERROR: Not supported instr: <MCInst 312 <MCOperand Reg:1> <MCOperand Imm:15> <MCOperand Reg:53>>

note: doing this in a basic program that is being built by the microzig build function, it does not bundle compiler_rt, so you'll see a missing definition:

ld.lld: error: undefined symbol: __mulsi3

Add Support for SparkFun RED-V RISCV Board

I am currently revisiting computer architecture and design for my personal project of building an operating system. In an attempt to tap into my dormant knowledge of the hardware-software concepts, I would like to contribute and add support for the SparkFun RED-V board. It has a RISC-V chip from SiFive, FE310.

dimIndex does not get parsed correctly in .svd files

While updating the ESP32-C3 .svd file, I noticed that register groups that had dimIndex fields added were suddenly missing in chip.zig and were replaced with reserved fields.

To reproduce, replace the ESP32-C3 .svd file with one found in the esp-pacs repo, or patch it and use the patched version and re-build and check the GPIO.PINn registers.

HAL Design

I created a Google Doc which contains some overview of what features different MCUs have.

Those who want to join can send me a message with their email on discord, i'll invite you.

Some words on the future path:

  1. Figure out what features we require for several chips
  2. Determine which subset of those features we want to have in a shared HAL
  3. Design the API for those features
  4. Implement them in the boards, use common driver abstractions

error: struct 'chip.devices.RP2040.peripherals' has no member named 'NVIC'

I'm trying to play around with the synth project from the 2023 sycl conference and I'm getting a build error when trying to use the latest microzig version. I've made some changes to the build script to try get it working, but I'm hitting an error now that seems to me to be related to microzig.

(I ran into a hash issue using the vanilla project deps which is why I'm trying to use the latest microzig).

% /c/src/zig/zig-windows-x86_64-0.12.0/zig.exe build
install
└─ install generated to uart_monitor.elf
   └─ zig build-exe uart_monitor Debug thumb-freestanding-eabi 2 errors
C:\Users\jtebokkel\AppData\Local\zig\p\1220a74a829bcd0e0cb6b5918646e20c68c2c47be9401e6f873a445453d4d8102027\src\start.zig:70:81: error: expected type 'start.Options', found 'type'
pub const microzig_options: Options = if (@hasDecl(app, "microzig_options")) app.microzig_options else .{};
                                                                             ~~~^~~~~~~~~~~~~~~~~
C:\Users\jtebokkel\AppData\Local\zig\p\1220a74a829bcd0e0cb6b5918646e20c68c2c47be9401e6f873a445453d4d8102027\src\start.zig:46:21: note: struct declared here
pub const Options = struct {
                    ^~~~~~
referenced by:
    vector_table: C:\Users\jtebokkel\AppData\Local\zig\p\1220a74a829bcd0e0cb6b5918646e20c68c2c47be9401e6f873a445453d4d8102027\src\cpus\cortex_m.zig:151:50
    remaining reference traces hidden; use '-freference-trace' to see all reference traces
C:\Users\jtebokkel\AppData\Local\zig\p\1220a557b7c940ea0193e8e4f516c6dab6d16dd41e528486889f356a2388930aae42\src\hal\irq.zig:2:39: error: struct 'chip.devices.RP2040.peripherals' has no member named 'NVIC'
const NVIC = microzig.chip.peripherals.NVIC;
             ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
zig-cache\o\ce1fd5a7bdf3a724fe567c58a510dd57\chip.zig:66:33: note: struct declared here
        pub const peripherals = struct {
                                ^~~~~~
error: the following command failed with 2 compilation errors:
C:\src\zig\zig-windows-x86_64-0.12.0\zig.exe build-exe -fno-strip -ODebug -target thumb-freestanding-eabi -mcpu cortex_m0plus --dep app --dep microzig -Mroot=C:\Users\jtebokkel\AppData\Local\zig\p\1220a74a829bcd0e0cb6b5918646e20c68c2c47be9401e6f873a445453d4d8102027\src\start.zig --dep microzig --dep workshop -Mapp=C:\src\synth-workshop\demos\01_uart\monitor.zig --dep config --dep chip --dep cpu --dep hal --dep board -Mmicrozig=C:\Users\jtebokkel\AppData\Local\zig\p\1220a74a829bcd0e0cb6b5918646e20c68c2c47be9401e6f873a445453d4d8102027\src\microzig.zig --dep microzig -Mworkshop=C:\src\synth-workshop\src\workshop.zig -Mconfig=C:\src\synth-workshop\zig-cache\c\cb74838774d212d46a4b6ad47bca5bcc\options.zig --dep microzig -Mchip=C:\src\synth-workshop\zig-cache\o\ce1fd5a7bdf3a724fe567c58a510dd57\chip.zig --dep microzig -Mcpu=C:\Users\jtebokkel\AppData\Local\zig\p\1220a74a829bcd0e0cb6b5918646e20c68c2c47be9401e6f873a445453d4d8102027\src\cpus\cortex_m.zig --dep microzig -Mhal=C:\Users\jtebokkel\AppData\Local\zig\p\1220a557b7c940ea0193e8e4f516c6dab6d16dd41e528486889f356a2388930aae42\src\hal.zig --dep microzig --dep bootloader -Mboard=C:\Users\jtebokkel\AppData\Local\zig\p\1220a557b7c940ea0193e8e4f516c6dab6d16dd41e528486889f356a2388930aae42\src\boards\raspberry_pi_pico.zig -Mbootloader=C:\src\synth-workshop\zig-cache\o\730f41bc6b5f93cab44fdd7241cc9338\w25q080.bin --cache-dir C:\src\synth-workshop\zig-cache --global-cache-dir C:\Users\jtebokkel\AppData\Local\zig --name uart_monitor -static -fcompiler-rt --script C:\Users\jtebokkel\AppData\Local\zig\p\1220a557b7c940ea0193e8e4f516c6dab6d16dd41e528486889f356a2388930aae42\rp2040.ld --listen=-
Build Summary: 80/85 steps succeeded; 1 failed (disable with --summary none)
install transitive failure
├─ install generated to uart_monitor.uf2 transitive failure
│  └─ run elf2uf2 (uart_monitor.uf2) transitive failure
│     └─ zig build-exe uart_monitor Debug thumb-freestanding-eabi 2 errors
└─ install generated to uart_monitor.elf transitive failure
   └─ zig build-exe uart_monitor Debug thumb-freestanding-eabi (+9 more reused dependencies)
error: the following build command failed with exit code 1:
C:\src\synth-workshop\zig-cache\o\76617bd811a3831f1b1ec2d766d7f552\build.exe C:\src\zig\zig-windows-x86_64-0.12.0\zig.exe C:\src\synth-workshop C:\src\synth-workshop\zig-cache C:\Users\jtebokkel\AppData\Local\zig --seed 0x37e3cbaa -Z7c6f518096f843be

Support serial over USB (CEC ADC)

I'd like to have a log.zig logFn that I could use to emit debug logs over USB, rather than UART.

Currently Microzig has support for acting as a USB HID device. I believe emitting debug logs over USB would require support for acting as a "serial device", which uses USB CDC/ADC.

Please help: with format a string with numbers or allocator instance in microzig.

Hello!
Thank you for your work on that project.

I start to use it in development. I want to write some simple apps to understand if it works.

I want to be able to format a string with numbers.

I need help with the allocator issue. I need help finding a way to use the standard library functions that require an allocator instance.

Example:

  const allocator = os.heap.page_allocator;

   const string1 = try std.fmt.allocPrint(allocator, "{d}", .{count()});
   defer allocator.free(string1);
   microzig.hal.uart.write(0, string1);

Gives me the error:

 error: root struct of file 'start' has no member named 'os'
 root.os.heap.page_allocator

Is there a way to get the allocator in the Microzig? or ESP32C2 environment? Can I resolve those issues without the allocator usage?
Thank you in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.