Skip to content

Commit

Permalink
Merge pull request #21 from WyliodrinEmbeddedIoT/microbit_v2
Browse files Browse the repository at this point in the history
Microbit v2 serial bootloader
  • Loading branch information
bradjc authored Feb 3, 2021
2 parents 7ba196d + b005893 commit 0d3504d
Show file tree
Hide file tree
Showing 9 changed files with 596 additions and 5 deletions.
162 changes: 162 additions & 0 deletions boards/microbit_v2-bootloader/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions boards/microbit_v2-bootloader/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[package]
name = "microbit_v2-bootloader"
version = "0.1.0"
authors = ["Tock Project Developers <[email protected]>"]
build = "build.rs"
edition = "2018"

[dependencies]
cortexm4 = { git = "https://github.com/tock/tock", branch = "master" }
capsules = { git = "https://github.com/tock/tock", branch = "master" }
kernel = { git = "https://github.com/tock/tock", branch = "master" }
nrf52 = { git = "https://github.com/tock/tock", branch = "master" }
nrf52833 = { git = "https://github.com/tock/tock", branch = "master" }
components = { git = "https://github.com/tock/tock", branch = "master" }

# For Development
# cortexm4 = { path = "../../../tock/arch/cortex-m4" }
# capsules = { path = "../../../tock/capsules" }
# kernel = { path = "../../../tock/kernel" }
# nrf52 = { path = "../../../tock/chips/nrf52" }
# nrf52833 = { path = "../../../tock/chips/nrf52833" }
# components = { path = "../../../tock/boards/components" }

bootloader = { path = "../../bootloader" }
bootloader_nrf52 = { path = "../../chips/bootloader_nrf52" }
bootloader_cortexm = { path = "../../arch/bootloader_cortexm" }


[build-dependencies]
bootloader_attributes = { path = "../../tools/bootloader_attributes" }

[profile.dev]
panic = "abort"
lto = false
opt-level = "z"
debug = true

[profile.release]
panic = "abort"
lto = true
opt-level = "z"
debug = true
22 changes: 22 additions & 0 deletions boards/microbit_v2-bootloader/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Makefile for building the Tock bootloader for nRF52 platforms using CDC-ACM
# over USB.

TOCK_ARCH=cortex-m4
TARGET=thumbv7em-none-eabi
PLATFORM=microbit_v2-bootloader

include ../Common.mk

TOCKLOADER=tockloader

OPENOCD=openocd
OPENOCD_OPTIONS=-f openocd.cfg

# Upload the kernel over JTAG
.PHONY: flash
flash: $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/$(PLATFORM).bin
$(OPENOCD) $(OPENOCD_OPTIONS) -c "program $<; verify_image $<; reset; shutdown;"

.PHONY: flash
flash-debug: $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/debug/$(PLATFORM).bin
$(OPENOCD) $(OPENOCD_OPTIONS) -c "program $<; verify_image $<; reset; shutdown;"
28 changes: 28 additions & 0 deletions boards/microbit_v2-bootloader/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
BBC:MicroBit v2 Tock Bootloader
===================

This is the implementation of the Tock bootloader for the BBC:MicroBit v2
board. The bootloader runs using the Debugger UART.

Compiling
---------

To compile the bootloader, simply run the `make` command.

```
make
```

Flashing
--------

OpenOCD is needed to flash the bootloader. Running `make flash` will compile it and flash it.

```
make flash
```

Entering
--------

Entering the bootloader is done by holding Button A during reset.
12 changes: 12 additions & 0 deletions boards/microbit_v2-bootloader/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
extern crate bootloader_attributes;

fn main() {
println!("cargo:rerun-if-changed=layout.ld");
println!("cargo:rerun-if-changed=../kernel_layout.ld");

let mut f = bootloader_attributes::get_file();
bootloader_attributes::write_flags(&mut f, "1.1.1", 0x8000);
bootloader_attributes::write_attribute(&mut f, "board", "microbit_v2");
bootloader_attributes::write_attribute(&mut f, "arch", "cortex-m4");
bootloader_attributes::write_attribute(&mut f, "appaddr", "0x40000");
}
11 changes: 11 additions & 0 deletions boards/microbit_v2-bootloader/layout.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
MEMORY
{
rom (rx) : ORIGIN = 0x00000000, LENGTH = 32K
prog (rx) : ORIGIN = 0x00008000, LENGTH = 480K
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 128K
}

MPU_MIN_ALIGN = 8K;
PAGE_SIZE = 4K;

INCLUDE ../kernel_layout.ld
11 changes: 11 additions & 0 deletions boards/microbit_v2-bootloader/openocd.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
source [find interface/cmsis-dap.cfg]
transport select swd
source [find target/nrf52.cfg]

set WORKAREASIZE 0x40000

$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $WORKAREASIZE -work-area-backup 0

flash bank $_CHIPNAME.flash nrf51 0x00000000 0 1 1 $_TARGETNAME
flash bank $_CHIPNAME.uicr nrf51 0x10001000 0 1 1 $_TARGETNAME

Loading

0 comments on commit 0d3504d

Please sign in to comment.