-
Notifications
You must be signed in to change notification settings - Fork 164
FreeRTOS microzig module #871
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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
Keep FreeRTOS naming conventions
| .hash = "ssd1306_font_8x8-0.0.0-oGb_cERcAAA6NJzWDOMepgnY6r4blNEHjpkldDaRAui5", | ||
| }, | ||
| .net = .{ .path = "../../../modules/network/" }, | ||
| .freertos = .{ .path = "../../../modules/freertos/" }, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this is new module created be me and sits next to lwip or fundation-libc. This module pulls freertos source code as dependency and provide glue code to produce zig wrapper around it.
|
|
||
| pub fn xTaskCreate( | ||
| task_function: c.TaskFunction_t, | ||
| name: [*:0]const u8, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is debatable, at this point task name have probably no other purpose than some debug/informational one so it is used internaly by FreeRTOS only, so there is no point to do extra allocation
| } | ||
|
|
||
| /// | ||
| /// Some ugly glue code to implement required functions from FreeRTOS and Pico SDK |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is debatable and in future can change. This code require some access to hal and some parts can be duplicated/implemented with what wi have in microzig right now and some other part probably no, especially those that require accessing some shared resource that have to be done by one API (microzig API). I will put comment about that in this place.
- more context in comments
There was a problem hiding this 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
| @@ -0,0 +1,99 @@ | |||
| const std = @import("std"); | |||
|
|
|||
| const FreeRTOSPort = enum { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Rename FreeRTOSPort to Free_RTOS_Port, it should be more in line with our style guidelines. This automation is not perfect so take it with a grain of salt.
| pub const MINIMAL_STACK_SIZE: usize = c.configMINIMAL_STACK_SIZE; | ||
| pub const MAX_PRIORITIES: usize = c.configMAX_PRIORITIES; | ||
|
|
||
| pub fn vTaskStartScheduler() noreturn { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change to v_task_start_scheduler, in MicroZig we use snake case for function names.
| unreachable; | ||
| } | ||
|
|
||
| pub fn vTaskDelay(ticks: c.TickType_t) void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change to v_task_delay, in MicroZig we use snake case for function names.
| c.vTaskDelay(ticks); | ||
| } | ||
|
|
||
| pub fn xTaskCreate( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change to x_task_create, in MicroZig we use snake case for function names.
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.