Skip to content

Commit

Permalink
sensors mission - temperature, motion orientation
Browse files Browse the repository at this point in the history
* sensors mission - temperature, motion orientation
  • Loading branch information
markfirmware authored Feb 25, 2020
1 parent 0333d18 commit 27e89b2
Show file tree
Hide file tree
Showing 22 changed files with 1,479 additions and 2,428 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
REPO=$(basename $GITHUB_REPOSITORY)
RELEASE_TAG=$(grep '^const release_tag =' mission00*.zig | sed 's/";//' | sed 's/^.*"//')
RELEASE_TAG=$(grep '^const release_tag =' mission0_*.zig | sed 's/";//' | sed 's/^.*"//')
RELEASE_ASSET=$REPO-$RELEASE_TAG.zip
pushd release
echo $RELEASE_TAG > RELEASE.md
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ See also [zig-bare-metal-raspberry-pi](https://github.com/markfirmware/zig-bare-

The goal is to replace the [ble buttons broadcaster](https://github.com/markfirmware/microbit-samples/blob/master/source/examples/blebuttonsbroadcaster/main.cpp) with zig on bare metal. This broadcaster is processed by [ultibo-ble-observer](https://github.com/markfirmware/ultibo-ble-observer/releases). Although it has no encryption, no privacy and no authentication, it is still useful for controlling a model railroad in a home or club setting, or at a demo.

* [microbit](https://tech.microbit.org/)

* [microbit](https://tech.microbit.org)
* [runtime - not used in this bare-metal project](https://lancaster-university.github.io/microbit-docs/#)
* [led matrix display driver](https://github.com/lancaster-university/microbit-dal/blob/master/source/drivers/MicroBitDisplay.cpp)
* [nrf51822](https://infocenter.nordicsemi.com/pdf/nRF51822_PS_v3.1.pdf)
* [reference](https://infocenter.nordicsemi.com/pdf/nRF51_RM_v3.0.pdf)
* gpio p56
* radio p81
* [reference](https://infocenter.nordicsemi.com/pdf/nRF51_RM_v3.0.1.pdf)
* [arm cortex-m0](https://developer.arm.com/ip-products/processors/cortex-m/cortex-m0)
* [cortex m0 user's guide](https://static.docs.arm.com/dui0497/a/DUI0497A_cortex_m0_r0p0_generic_ug.pdf?_ga=2.60319917.1865497363.1577386349-160760379.1577386349)
* [armv6m](https://static.docs.arm.com/ddi0419/e/DDI0419E_armv6m_arm.pdf?_ga=2.152616249.101383920.1573135559-619929151.1573135559)
* [pin assignments (sheet 5)](https://github.com/bbcmicrobit/hardware/blob/master/SCH_BBC-Microbit_V1.3B.pdf)
* [edge connector and pins](https://tech.microbit.org/hardware/edgeconnector)
* [pin assignments (sheet 5 of schematic)](https://github.com/bbcmicrobit/hardware/blob/master/SCH_BBC-Microbit_V1.3B.pdf)
8 changes: 6 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
set -e

ARCH=thumbv6m
SOURCE=$(ls mission00*.zig)
SOURCE=$(ls mission0*.zig)

echo zig version $(zig version)
zig fmt *.zig
touch symbols.txt
zig build
llvm-objdump-6.0 --source zig-cache/bin/main > main.asm
grep '^00000000.*:$' main.asm | sed 's/^00000000//' > symbols.txt
zig build

#llvm-objdump -x --source main > asm.$ARCH
Expand All @@ -14,4 +18,4 @@ zig build
#grep 'q[0-9].*#' asm.$ARCH | egrep -v '#(-|)(16|32|48|64|80|96|112|128)'
#set -e

ls -lt main.hex zig-cache/bin/main.img
ls -l main.hex zig-cache/bin/main.img symbols.txt
31 changes: 23 additions & 8 deletions build.zig
Original file line number Diff line number Diff line change
@@ -1,24 +1,39 @@
pub fn build(b: *Builder) void {
const arch = builtin.Arch{ .thumb = builtin.Arch.Arm32.v6m };
const environ = builtin.Abi.none;
pub fn build(b: *std.build.Builder) !void {
const exec_name = "main";
const mode = b.standardReleaseOptions();
const os = builtin.Os.freestanding;
const main = b.option([]const u8, "main", "main file") orelse "mission0_mission_selector.zig";
const want_display = b.option(bool, "display", "graphics display for qemu") orelse false;

const exe = b.addExecutable(exec_name, "mission00_mission_selector.zig");
const exe = b.addExecutable(exec_name, main);
exe.install();
exe.installRaw("main.img");
exe.setBuildMode(mode);
exe.setLinkerScriptPath("linker.ld");
exe.setTarget(arch, os, environ);
exe.setTheTarget(try std.Target.parse(.{
.arch_os_abi = "thumb-freestanding-none",
}));

const run_makehex = b.addSystemCommand(&[_][]const u8{
"zig", "run", "makehex.zig",
});
run_makehex.step.dependOn(&exe.step);

const qemu = b.step("qemu", "run in qemu");
const run_qemu = b.addSystemCommand(&[_][]const u8{
"qemu-system-arm",
"-kernel",
"zig-cache/bin/main.img",
"-M",
"microbit",
"-serial",
"stdio",
"-display",
if (want_display) "gtk" else "xnone",
});
qemu.dependOn(&run_qemu.step);
run_qemu.step.dependOn(&exe.step);

b.default_step.dependOn(&run_makehex.step);
}

const Builder = std.build.Builder;
const builtin = @import("builtin");
const std = @import("std");
Loading

0 comments on commit 27e89b2

Please sign in to comment.