Skip to content

An experimental project about writing programs for RP2040 MCUs in Zig language

License

Notifications You must be signed in to change notification settings

ikubaku/rp2040_zig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rp2040_zig

An experimental project about writing programs for RP2040 MCUs in Zig language

Features

(Working in progress but the main objective) This program demonstrates how to write a baremetal application for RP2040 in Zig.

The application blinks a LED connected on GPIO25 (preinstalled on Raspberry Pi Pico boards).

To do list

  • ✓ Blink a LED on GPIO25

  • ✓ Generate a valid UF2 binary for Raspberry Pi Pico board

  • ❏ Refactor build scripts

  • ❏ Rewrite the GPIO APIs

  • ❏ Add more features to the HAL

  • ❏ Support more flash memories

Repository structure

build.zig

The build script.

build/uf2.zig

Logics to generate UF2 format binaries.

rp2040_ras/rp2040_ras.zig

src/hal/gpio.zig

The GPIO multiplexer peripheral access API implementation.

src/hal/sio.zig

The Software Input/Output (SIO) peripheral access API implementation.

src/linker.ld

The main linker script.

src/runtime.zig

The runtime initialization and the interrupt vector definitions.

src/main.zig

The application entry point.

src/ipl/*.zig

Second stage bootloader implementations for different flash memories.

Building

Prerequisites

  • Zig >= 0.9.0

Build script options

release-small-ipl: bool

Set the build mode for the second stage bootloader to ReleaseSmall.

You will need this option to be enabled because the size of the debug bootloader almost always exceed 252 bytes.

flash-kind: enum FlashKind

Select the flash memory type to be used in the target system.

Only W25Q080 and equivalent components are supported for now.

  • W25Q080: Use src/ipl/w25q080.zig for the second stage bootloader.

Steps

  1. Run zig build -Drelease-small-ipl

  2. Download the generated UF2 binary (located in Binary/{Debug,ReleaseSmall,…​}/rp2040_zig.uf2) to your board.

License

This program is licensed under The BSD 3-Clause License. See LICENSE for more information.

About

An experimental project about writing programs for RP2040 MCUs in Zig language

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages