@@ -4,7 +4,9 @@ const microzig = @import("microzig/build-internals");
44const Self = @This ();
55
66chips : struct {
7+ nrf51822 : * const microzig.Target ,
78 nrf52832 : * const microzig.Target ,
9+ nrf52833 : * const microzig.Target ,
810 nrf52840 : * const microzig.Target ,
911},
1012
@@ -14,6 +16,10 @@ boards: struct {
1416 nrf52840_mdk : * const microzig.Target ,
1517 pca10040 : * const microzig.Target ,
1618 },
19+ bbc : struct {
20+ microbit_v1 : * const microzig.Target ,
21+ microbit_v2 : * const microzig.Target ,
22+ },
1723},
1824
1925pub fn init (dep : * std.Build.Dependency ) Self {
@@ -25,6 +31,30 @@ pub fn init(dep: *std.Build.Dependency) Self {
2531 .root_source_file = b .path ("src/hal.zig" ),
2632 };
2733
34+ const chip_nrf51822 : microzig.Target = .{
35+ .dep = dep ,
36+ .preferred_binary_format = .elf ,
37+ .zig_target = .{
38+ .cpu_arch = .thumb ,
39+ .cpu_model = .{ .explicit = & std .Target .arm .cpu .cortex_m0 },
40+ .os_tag = .freestanding ,
41+ .abi = .eabi ,
42+ },
43+ .chip = .{
44+ .name = "nrf51" ,
45+ .url = "https://www.nordicsemi.com/products/nrf51822" ,
46+ .register_definition = .{
47+ .svd = nrfx .path ("mdk/nrf51.svd" ),
48+ },
49+ .memory_regions = &.{
50+ .{ .tag = .flash , .offset = 0x00000000 , .length = 128 * 1024 , .access = .rx },
51+ .{ .tag = .ram , .offset = 0x20000000 , .length = 16 * 1024 , .access = .rwx },
52+ },
53+ .patches = @import ("patches/nrf51.zig" ).patches ,
54+ },
55+ .hal = .{ .root_source_file = b .path ("src/hal.zig" ) },
56+ };
57+
2858 const chip_nrf52832 : microzig.Target = .{
2959 .dep = dep ,
3060 .preferred_binary_format = .elf ,
@@ -38,14 +68,37 @@ pub fn init(dep: *std.Build.Dependency) Self {
3868 .name = "nrf52" ,
3969 .url = "https://www.nordicsemi.com/products/nrf52832" ,
4070 .register_definition = .{
41- // TODO: does this determine the name of the chips/x.zig?
4271 .svd = nrfx .path ("mdk/nrf52.svd" ),
4372 },
4473 .memory_regions = &.{
4574 .{ .tag = .flash , .offset = 0x00000000 , .length = 0x80000 , .access = .rx },
46- .{ .tag = .ram , .offset = 0x20000000 , .length = 0x10000 , .access = .rw },
75+ .{ .tag = .ram , .offset = 0x20000000 , .length = 0x10000 , .access = .rwx },
4776 },
48- .patches = @import ("patches/nrf52832.zig" ).patches ,
77+ .patches = @import ("patches/nrf528xx.zig" ).patches ,
78+ },
79+ .hal = .{ .root_source_file = b .path ("src/hal.zig" ) },
80+ };
81+
82+ const chip_nrf52833 : microzig.Target = .{
83+ .dep = dep ,
84+ .preferred_binary_format = .elf ,
85+ .zig_target = .{
86+ .cpu_arch = .thumb ,
87+ .cpu_model = .{ .explicit = & std .Target .arm .cpu .cortex_m4 },
88+ .os_tag = .freestanding ,
89+ .abi = .eabi ,
90+ },
91+ .chip = .{
92+ .name = "nrf52833" ,
93+ .url = "https://www.nordicsemi.com/products/nrf52833" ,
94+ .register_definition = .{
95+ .svd = nrfx .path ("mdk/nrf52833.svd" ),
96+ },
97+ .memory_regions = &.{
98+ .{ .tag = .flash , .offset = 0x00000000 , .length = 512 * 1024 , .access = .rx },
99+ .{ .tag = .ram , .offset = 0x20000000 , .length = 128 * 1024 , .access = .rwx },
100+ },
101+ .patches = @import ("patches/nrf528xx.zig" ).patches ,
49102 },
50103 .hal = .{ .root_source_file = b .path ("src/hal.zig" ) },
51104 };
@@ -76,14 +129,16 @@ pub fn init(dep: *std.Build.Dependency) Self {
76129 // CODE_RAM
77130 .{ .name = "code_ram" , .offset = 0x800000 , .length = 0x40000 , .access = .x },
78131 },
79- .patches = @import ("patches/nrf52840 .zig" ).patches ,
132+ .patches = @import ("patches/nrf528xx .zig" ).patches ,
80133 },
81134 .hal = hal ,
82135 };
83136
84137 return .{
85138 .chips = .{
139+ .nrf51822 = chip_nrf51822 .derive (.{}),
86140 .nrf52832 = chip_nrf52832 .derive (.{}),
141+ .nrf52833 = chip_nrf52833 .derive (.{}),
87142 .nrf52840 = chip_nrf52840 .derive (.{}),
88143 },
89144 .boards = .{
@@ -110,6 +165,24 @@ pub fn init(dep: *std.Build.Dependency) Self {
110165 },
111166 }),
112167 },
168+ .bbc = .{
169+ .microbit_v1 = chip_nrf51822 .derive (.{
170+ .preferred_binary_format = .hex ,
171+ .board = .{
172+ .name = "micro:bit v1" ,
173+ .url = "https://tech.microbit.org/hardware/1-5-revision" ,
174+ .root_source_file = b .path ("src/boards/microbit.zig" ),
175+ },
176+ }),
177+ .microbit_v2 = chip_nrf52833 .derive (.{
178+ .preferred_binary_format = .hex ,
179+ .board = .{
180+ .name = "micro:bit v2" ,
181+ .url = "https://tech.microbit.org/hardware/2-2-revision" ,
182+ .root_source_file = b .path ("src/boards/microbit.zig" ),
183+ },
184+ }),
185+ },
113186 },
114187 };
115188}
0 commit comments