initial commit

main
Clyne 3 months ago
commit f529a3b0f8
Signed by: clyne
GPG Key ID: 3267C8EBF3F9AFC7

3
.gitignore vendored

@ -0,0 +1,3 @@
*.sw*
.zig-cache/
zig-out/

@ -0,0 +1,23 @@
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.resolveTargetQuery(.{
.cpu_arch = .thumb,
.os_tag = .freestanding,
.abi = .none
});
const optimize = .Debug; // .ReleaseSmall
const exe = b.addExecutable(.{
.name = "stm32",
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.linkage = .static,
});
exe.addAssemblyFile(b.path("src/bootstrap.s"));
exe.setLinkerScriptPath(b.path("link.ld"));
b.installArtifact(exe);
}

@ -0,0 +1,44 @@
ENTRY(_start)
/* description of memory regions */
MEMORY {
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 96K
}
/* description of ELF sections */
SECTIONS {
.text : {
. = ALIGN(8);
*(.isr_vector)
*(.text)
*(.text*)
} > FLASH
/* read-only data sections */
.rodata : {
. = ALIGN(8);
*(.rodata)
*(.rodata*)
} > FLASH
/* initialized data */
_sidata = LOADADDR(.data);
.data : {
. = ALIGN(8);
_sdata = .;
*(.data)
. = ALIGN(8);
_edata = .;
} > RAM AT > FLASH
/* uninitialized data */
.bss : {
. = ALIGN(8);
_sbss = .;
*(.bss)
. = ALIGN(8);
_ebss = .;
} > RAM
}

@ -0,0 +1,38 @@
.cpu cortex-m4
.thumb
.extern _start
.extern fault_handler
.section .text
fault1:
mov r0, 1
b fault_handler
fault2:
mov r0, 2
b fault_handler
fault3:
mov r0, 3
b fault_handler
fault4:
mov r0, 4
b fault_handler
fault5:
mov r0, 5
b fault_handler
.section .bss
.skip 128
stack_top:
.section .isr_vector
.word stack_top
.word _start
.word fault1
.word fault2
.word fault3
.word fault4
.word fault5
.skip 4 * 91

@ -0,0 +1,13 @@
//! By convention, main.zig is where your main function lives in the case that
//! you are building an executable. If you are making a library, the convention
//! is to delete this file and start with root.zig instead.
//const std = @import("std");
export fn _start() callconv(.C) noreturn {
while (true) {}
}
export fn fault_handler() callconv(.C) void {
while (true) {}
}
Loading…
Cancel
Save