Skip to content

Commit

Permalink
Merge pull request #24 from WyliodrinEmbeddedIoT/clue_nrf52840
Browse files Browse the repository at this point in the history
Enable bootloader for Adafruit CLUE nRF52840
  • Loading branch information
bradjc authored Aug 20, 2021
2 parents a2f0841 + 65ae43b commit aedb2fb
Show file tree
Hide file tree
Showing 6 changed files with 516 additions and 0 deletions.
44 changes: 44 additions & 0 deletions boards/clue_nrf52840-bootloader/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[package]
name = "clue_nrf52840-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" }
# nrf52840 = { git = "https://github.com/tock/tock", branch = "master" }
# components = { git = "https://github.com/tock/tock", branch = "master" }
# nrf52_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" }
nrf52840 = { path = "../../../tock/chips/nrf52840" }
components = { path = "../../../tock/boards/components" }
nrf52_components = { path = "../../../tock/boards/nordic/nrf52_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
27 changes: 27 additions & 0 deletions boards/clue_nrf52840-bootloader/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Makefile for building the Tock bootloader for nRF52 platforms using CDC-ACM
# over USB.

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

include ../Common.mk

TOCKLOADER=tockloader

# Where in the flash to load the kernel with `tockloader`
KERNEL_ADDRESS=0x26000

ifdef PORT
TOCKLOADER_GENERAL_FLAGS += --port $(PORT)
endif

# Upload the kernel over JTAG
.PHONY: flash
flash: $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/$(PLATFORM).bin
$(TOCKLOADER) $(TOCKLOADER_GENERAL_FLAGS) flash --address $(KERNEL_ADDRESS) --board nrf52dk --jlink $<

# Upload the kernel over JTAG using OpenOCD
.PHONY: flash-openocd
flash-openocd: $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/$(PLATFORM).bin
$(TOCKLOADER) $(TOCKLOADER_GENERAL_FLAGS) flash --address $(KERNEL_ADDRESS) --board nrf52dk --openocd $<
24 changes: 24 additions & 0 deletions boards/clue_nrf52840-bootloader/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Adafruit CLUE - nRF52840 Express with Bluetooth LE Tock Bootloader
===================

This is the implementation of the Tock bootloader for the Adafruit CLUE - nRF52840 Express with Bluetooth LE
board. The bootloader runs using the CDC-ACM over USB stack.

Compiling
---------

Here are the steps:

```
make
cp ../../target/thumbv7em-none-eabi/release/clue_nrf52840-bootloader.bin ./clue_nrf52840-bootloader.bin
```

Converting to UF2
-----------

Install [uf2conf](https://github.com/microsoft/uf2/blob/master/utils/uf2conv.py)

```
uf2conv clue_nrf52840-bootloader.bin -f 0xADA52840 --base 0x26000 --output clue_nrf52840-bootloader.uf2
```
12 changes: 12 additions & 0 deletions boards/clue_nrf52840-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.0", 0x36000);
bootloader_attributes::write_attribute(&mut f, "board", "clue_nrf52840");
bootloader_attributes::write_attribute(&mut f, "arch", "cortex-m4");
bootloader_attributes::write_attribute(&mut f, "appaddr", "0x80000");
}
11 changes: 11 additions & 0 deletions boards/clue_nrf52840-bootloader/layout.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
MEMORY
{
rom (rx) : ORIGIN = 0x00026000, LENGTH = 64K
prog (rx) : ORIGIN = 0x00036000, LENGTH = 808K
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 128K
}

MPU_MIN_ALIGN = 8K;
PAGE_SIZE = 4K;

INCLUDE ../kernel_layout.ld
Loading

0 comments on commit aedb2fb

Please sign in to comment.