Skip to content

Conversation

@arkadiuszwojcik
Copy link
Contributor

@arkadiuszwojcik arkadiuszwojcik commented Jan 19, 2026

This PR introduces FreeRTOS module for MicroZig and for now exposes RP2040 port only. Version for RP2350 will come later. I reconstruted miniaml version of PicoSDK headers neccesery for compilation so this code don't have to relay on full PicoSDK.

Right now module expose only few basic wrappers around FreeRTOS API, more will be added gradually.

Edit:
There are few ugly fragments in glue code (see hello_task.zig example), maybe somone will help me with that.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Lint Results

Found 4 issues on changed lines in 2 files:

  • modules/freertos/build.zig: 1 issue
  • modules/freertos/src/root.zig: 3 issues

@arkadiuszwojcik arkadiuszwojcik marked this pull request as draft January 19, 2026 16:38
@arkadiuszwojcik arkadiuszwojcik marked this pull request as ready for review January 19, 2026 16:40
@mattnite mattnite dismissed github-actions[bot]’s stale review January 19, 2026 20:04

Keep FreeRTOS naming conventions

Comment on lines +17 to +18
//.overwrite_hal_interrupts = true,
//.interrupts = .{ .PendSV = .{ .naked = freertos.isr_pendsv }, .SysTick = .{ .c = freertos.isr_systick }, .SVCall = .{ .c = freertos.isr_svcall } },
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will have to clean this up.

const cs = microzig.interrupt.enter_critical_section();
defer cs.leave();

// very ugly code but good for now
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put a TODO to cleanup please

}

export fn multicore_reset_core1() callconv(.c) void {
// TODO
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more descriptive TODO please

firmware.app_mod.addImport("net", net_mod);
}

// Import freertos module for some examples
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please mention that it's a hack that uses the example name to determine.

We could just add a field to Example and default it to false, that would be cleaner.

.hash = "ssd1306_font_8x8-0.0.0-oGb_cERcAAA6NJzWDOMepgnY6r4blNEHjpkldDaRAui5",
},
.net = .{ .path = "../../../modules/network/" },
.freertos = .{ .path = "../../../modules/freertos/" },
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where did you pull this from? I think it would be nice to be able to have a hash on this.

Did you have to make any modifications?

// Used when PICO_NO_RAM_VECTOR_TABLE is 1 (but don't work - VTOR is not set to 0x10000100 during boot)
// pub const microzig_options = microzig.Options{
// .overwrite_hal_interrupts = true,
// .interrupts = .{ .PendSV = .{ .naked = freertos.isr_pendsv }, .SysTick = .{ .c = freertos.isr_systick }, .SVCall = .{ .c = freertos.isr_svcall } },
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please multiline this


freertos_lib.addCMacro("LIB_PICO_MULTICORE", "0");

// Had problems when this was enabled. Microzig but also Pico SDK? dont set VTOR to 0x10000100 for RP2040 at boot even when ram_vector_table is set to false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrap long lines

Comment on lines +20 to +25
"build.zig",
"build.zig.zon",
"src",
// For example...
//"LICENSE",
//"README.md",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please clean this up! you'll need picosdk and config.


pub fn xTaskCreate(
task_function: c.TaskFunction_t,
name: [*:0]const u8,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder whether we should make this a normal string, maybe provide a helper to convert it (though that might require alloc + copy to fit the null byte?). Similarly, should we provide nicer types for the handle?

}

///
/// Some ugly glue code to implement required functions from FreeRTOS and Pico SDK
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not tuck this into freertos root.zig?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants