Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.
/ uf2 Public archive

USB Flashing Format (UF2) for your build.zig

Notifications You must be signed in to change notification settings

ZigEmbeddedGroup/uf2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Archived

This repository has been moved into the monorepo

uf2

USB Flashing Format (UF2) for your build.zig

This package is for assembling uf2 files from ELF binaries. This format is used for flashing a microcontroller over a mass storage interface, such as the Pi Pico.

See https://github.com/microsoft/uf2#file-containers for how we're going to embed file source into the format.

For use in a build.zig:

const uf2 = @import("uf2");

pub fn build(b: *Build) void {
    // ...
    const uf2_dep = b.dependency("uf2", .{});

    const uf2_file = uf2.from_elf(uf2_dep, exe, .{ .family_id = .RP2040 });
    _ = b.addInstallFile(uf2_file, "bin/test.uf2");
}

Manually Executing elf2uf2

pub fn build(b: *Build) void {
    // ...

    const uf2_dep = b.dependency("uf2", .{});

    const elf2uf2_run = b.addRunArtifact(uf2_dep.artifact("elf2uf2"));

    // family id
    elf2uf2_run.addArgs(&.{"--family-id", "RP2040"});

    // elf file
    elf2uf2_run.addArg("--elf-path");
    elf2uf2_run.addArtifactArg(exe);

    // output file
    const uf2_file = elf2uf2_run.addPrefixedOutputFileArg("--output-path", "test.uf2");
    _ = b.addInstallFile(uf2_file, "bin/test.uf2");
}

About

USB Flashing Format (UF2) for your build.zig

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages