Skip to content

Commit

Permalink
Merge #358
Browse files Browse the repository at this point in the history
358: Add microbit_v2 layout r=jrvanwhy a=alexandruradovici

The PR adds the microbit_v2 memory layout and modifies `flash.sh` to (hopefully) work with both versions of libtock.

It also adds the`microbit_v2` board to the Makefile, even tough Makefile uses libtock1.

Co-authored-by: Alexandru Radovici <[email protected]>
  • Loading branch information
bors[bot] and alexandruradovici authored Jan 18, 2022
2 parents 6f8b512 + 253e4a8 commit 4c7ecb6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ usage:
@echo "libtock-rs currently includes support for the following platforms:"
@echo " - hail"
@echo " - nrf52840"
@echo " - microbit_v2"
@echo " - nucleo_f429zi"
@echo " - nucleo_f446re"
@echo " - opentitan"
Expand Down Expand Up @@ -153,6 +154,14 @@ hail:
flash-hail:
PLATFORM=hail cargo run $(release) --target=thumbv7em-none-eabi --example $(EXAMPLE) $(features)

.PHONY: microbit_v2
microbit_v2:
PLATFORM=microbit_v2 cargo build $(release) --target=thumbv7em-none-eabi --examples $(features)

.PHONY: flash-microbit_v2
flash-microbit_v2:
PLATFORM=microbit_v2 cargo run $(release) --target=thumbv7em-none-eabi --example $(EXAMPLE) $(features)

.PHONY: nucleo_f429zi
nucleo_f429zi:
PLATFORM=nucleo_f429zi cargo build $(release) --target=thumbv7em-none-eabi --examples $(features)
Expand Down
9 changes: 9 additions & 0 deletions runtime/layouts/microbit_v2.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* Layout for the micro:bit v2 board, used by the examples in this repository. */

MEMORY {
FLASH (X) : ORIGIN = 0x00040000, LENGTH = 256K
RAM (W) : ORIGIN = 0x20004000, LENGTH = 112K
}

TBF_HEADER_SIZE = 0x48;
INCLUDE libtock_layout.ld
17 changes: 16 additions & 1 deletion tools/flash.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
#!/usr/bin/env bash

TBF_HEADER=64
KERNEL_VERSION=""

if [ ! -z $LIBTOCK_PLATFORM ]; then
# we are using libtock2
PLATFORM=$LIBTOCK_PLATFORM
TBF_HEADER=72
KERNEL_VERSION="--kernel-major 2 --kernel-minor 0"
fi

set -eux

artifact="$(basename $1)"
Expand All @@ -20,6 +30,11 @@ case "${PLATFORM}" in
binary_name=cortex-m4.elf
tockload=n
;;
"microbit_v2")
tockloader_flags="--bundle-apps"
binary_name=cortex-m4.elf
tockload=y
;;
"nucleo_f429zi"|"nucleo_f446re")
tockloader_flags=""
binary_name=cortex-m4.elf
Expand Down Expand Up @@ -70,7 +85,7 @@ cp "$1" "${elf_file_name}"

STACK_SIZE=$(nm --print-size --size-sort --radix=d "${elf_file_name}" | grep STACK_MEMORY | cut -d " " -f 2)

elf2tab -n "${artifact}" -o "${tab_file_name}" "${elf_file_name}" --stack ${STACK_SIZE} --app-heap $APP_HEAP_SIZE --kernel-heap $KERNEL_HEAP_SIZE --protected-region-size=64
elf2tab -n "${artifact}" -o "${tab_file_name}" "${elf_file_name}" --stack ${STACK_SIZE} --app-heap $APP_HEAP_SIZE --kernel-heap $KERNEL_HEAP_SIZE --protected-region-size=$TBF_HEADER $KERNEL_VERSION

if [ $tockload == "n" ]; then
echo "Skipping flashing for platform \"${PLATFORM}\""
Expand Down

0 comments on commit 4c7ecb6

Please sign in to comment.