Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions modules/freertos/build.zig
Original file line number Diff line number Diff line change
@@ -1,26 +1,46 @@
const std = @import("std");

const FreeRTOSPort = enum {
const FreeRTOS_Port = enum {
RP2040,
RP2350_ARM,
RP2350_RISCV,
};

const FreeRTOS_Config = struct {
// Scheduler related
configUSE_IDLE_HOOK: bool = false,
configUSE_TICK_HOOK: bool = false,
};

pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});

// Configurable options
const port_name = b.option(
FreeRTOSPort,
FreeRTOS_Port,
"port_name",
"FreeRTOS port to use",
) orelse .RP2040;

const cfg_idle_hook = b.option(bool, "idle_hook", "Enable FreeRTOS idle hook") orelse false;
const cfg_tick_hook = b.option(bool, "tick_hook", "Enable FreeRTOS tick hook") orelse false;

if (port_name != .RP2040 and port_name != .RP2350_ARM) {
@panic("Right now only RP2040 and RP2350_ARM ports are supported");
}

// In future this config might be validated against port-specific capabilities
const config = FreeRTOS_Config{
.configUSE_IDLE_HOOK = cfg_idle_hook,
.configUSE_TICK_HOOK = cfg_tick_hook,
};

const config_header = b.addConfigHeader(.{
.style = .{ .cmake = b.path("config/FreeRTOSConfig.h.cmake") },
.include_path = "FreeRTOSConfig.h",
}, config);

const foundationlibc_dep = b.dependency("foundationlibc", .{
.target = target,
.optimize = optimize,
Expand All @@ -34,6 +54,8 @@ pub fn build(b: *std.Build) void {

// Link libc
freertos_lib.linkLibrary(foundationlibc_dep.artifact("foundation"));
// Add generated configuration header
freertos_lib.addConfigHeader(config_header);

const freertos_kernel_dep = b.dependency("freertos_kernel", .{});
const freertos_kernel_community_dep = b.dependency("freertos_kernel_community", .{});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@
/* Scheduler Related */
#define configUSE_PREEMPTION 1
#define configUSE_TICKLESS_IDLE 0
#define configUSE_IDLE_HOOK 0
#define configUSE_TICK_HOOK 0
// FIXME: must be without indent to work, please fix (add indent) after Zig 0.16 release: https://codeberg.org/ziglang/zig/issues/31164
#cmakedefine01 configUSE_IDLE_HOOK
#cmakedefine01 configUSE_TICK_HOOK
#define configTICK_RATE_HZ ( ( TickType_t ) 1000 )
#define configMAX_PRIORITIES 32
#define configMINIMAL_STACK_SIZE ( uint32_t ) 256
Expand Down Expand Up @@ -118,7 +119,7 @@
#define configSUPPORT_PICO_SYNC_INTEROP 0
#define configSUPPORT_PICO_TIME_INTEROP 0

/* RP2350 required */
/* Dependent on processor */
#define configENABLE_FPU 1
#define configENABLE_MPU 0
#define configENABLE_TRUSTZONE 0
Expand Down
146 changes: 0 additions & 146 deletions modules/freertos/config/RP2040/FreeRTOSConfig.h

This file was deleted.

Loading