-
Notifications
You must be signed in to change notification settings - Fork 289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revamp deploy.py #78
Merged
Merged
Revamp deploy.py #78
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e63482a
Revamp deploy.py
jmichelp 9c13d73
Fix pylint
jmichelp e87e78a
Minor changes (review round 1)
jmichelp 550098d
Remove duplicate patch
jmichelp b22832e
Rely on Makefile to build Tock OS
jmichelp 4a3ccb4
Allow flashing only the kernel without any app.
jmichelp 7c5c7b9
Ensure we have something to do.
jmichelp 0e1c764
Address review round #2
jmichelp 49182c5
Add new python dependency
jmichelp dfe901e
Adding missing intelhex python library
jmichelp 93bc8da
Fix missing directory
jmichelp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[package] | ||
name = "nrf52840_dongle_dfu" | ||
version = "0.1.0" | ||
authors = ["Tock Project Developers <tock-dev@googlegroups.com>"] | ||
build = "build.rs" | ||
edition = "2018" | ||
|
||
[profile.dev] | ||
panic = "abort" | ||
lto = false | ||
opt-level = "z" | ||
debug = true | ||
|
||
[profile.release] | ||
panic = "abort" | ||
lto = true | ||
opt-level = "z" | ||
debug = true | ||
|
||
[[bin]] | ||
path = "../../third_party/tock/boards/nordic/nrf52840_dongle/src/main.rs" | ||
name = "nrf52840_dongle_dfu" | ||
|
||
[dependencies] | ||
components = { path = "../../third_party/tock/boards/components" } | ||
cortexm4 = { path = "../../third_party/tock/arch/cortex-m4" } | ||
capsules = { path = "../../third_party/tock/capsules" } | ||
kernel = { path = "../../third_party/tock/kernel" } | ||
nrf52840 = { path = "../../third_party/tock/chips/nrf52840" } | ||
nrf52dk_base = { path = "../../third_party/tock/boards/nordic/nrf52dk_base" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Makefile for building the tock kernel for the nRF development kit | ||
|
||
TOCK_ARCH=cortex-m4 | ||
TARGET=thumbv7em-none-eabi | ||
PLATFORM=nrf52840_dongle_dfu | ||
|
||
include ../../third_party/tock/boards/Makefile.common | ||
|
||
TOCKLOADER=tockloader | ||
|
||
# Where in the nrf52 flash to load the kernel with `tockloader` | ||
KERNEL_ADDRESS=0x01000 | ||
|
||
# Upload programs over uart with tockloader | ||
ifdef PORT | ||
TOCKLOADER_GENERAL_FLAGS += --port $(PORT) | ||
endif | ||
|
||
TOCKLOADER_JTAG_FLAGS = --jlink --arch $(TOCK_ARCH) --board $(PLATFORM) --page-size 4096 --jlink-device nrf52840_xxaa | ||
|
||
# Upload the kernel over JTAG | ||
.PHONY: flash | ||
flash: target/$(TARGET)/release/$(PLATFORM).bin | ||
$(TOCKLOADER) $(TOCKLOADER_GENERAL_FLAGS) flash --address $(KERNEL_ADDRESS) $(TOCKLOADER_JTAG_FLAGS) $< | ||
|
||
# Upload the kernel over serial/bootloader | ||
.PHONY: program | ||
program: target/$(TARGET)/release/$(PLATFORM).hex | ||
$(error Cannot program nRF52 Dongle over USB. Use \`make flash\` and JTAG) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
fn main() { | ||
println!("cargo:rerun-if-changed=layout.ld"); | ||
println!("cargo:rerun-if-changed=../../third_party/tock/boards/kernel_layout.ld"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
MEMORY | ||
{ | ||
rom (rx) : ORIGIN = 0x00001000, LENGTH = 188K | ||
prog (rx) : ORIGIN = 0x00030000, LENGTH = 832K | ||
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 256K | ||
} | ||
|
||
MPU_MIN_ALIGN = 8K; | ||
|
||
INCLUDE ../../third_party/tock/boards/kernel_layout.ld |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[package] | ||
name = "nrf52840_mdk_dfu" | ||
version = "0.1.0" | ||
authors = ["Yihui Xiong <yihui.xiong@hotmail.com>"] | ||
build = "build.rs" | ||
edition = "2018" | ||
|
||
[profile.dev] | ||
panic = "abort" | ||
lto = false | ||
opt-level = "z" | ||
debug = true | ||
|
||
[profile.release] | ||
panic = "abort" | ||
lto = true | ||
opt-level = "z" | ||
debug = true | ||
|
||
[dependencies] | ||
components = { path = "../../third_party/tock/boards/components" } | ||
cortexm4 = { path = "../../third_party/tock/arch/cortex-m4" } | ||
capsules = { path = "../../third_party/tock/capsules" } | ||
kernel = { path = "../../third_party/tock/kernel" } | ||
nrf52840 = { path = "../../third_party/tock/chips/nrf52840" } | ||
nrf52dk_base = { path = "../../third_party/tock/boards/nordic/nrf52dk_base" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Makefile for building the tock kernel for the nRF development kit | ||
|
||
TOCK_ARCH=cortex-m4 | ||
TARGET=thumbv7em-none-eabi | ||
PLATFORM=nrf52840_mdk_dfu | ||
|
||
include ../../third_party/tock/boards/Makefile.common | ||
|
||
TOCKLOADER=tockloader | ||
|
||
# Where in the nrf52 flash to load the kernel with `tockloader` | ||
KERNEL_ADDRESS=0x01000 | ||
|
||
# Upload programs over uart with tockloader | ||
ifdef PORT | ||
TOCKLOADER_GENERAL_FLAGS += --port $(PORT) | ||
endif | ||
|
||
TOCKLOADER_JTAG_FLAGS = --jlink --arch $(TOCK_ARCH) --board $(PLATFORM) --page-size 4096 --jlink-device nrf52840_xxaa | ||
|
||
# Upload the kernel over JTAG | ||
.PHONY: flash | ||
flash: target/$(TARGET)/release/$(PLATFORM).bin | ||
$(TOCKLOADER) $(TOCKLOADER_GENERAL_FLAGS) flash --address $(KERNEL_ADDRESS) $(TOCKLOADER_JTAG_FLAGS) $< | ||
|
||
# Upload the kernel over serial/bootloader | ||
.PHONY: program | ||
program: target/$(TARGET)/release/$(PLATFORM).hex | ||
$(error Cannot program nRF52 Dongle over USB. Use \`make flash\` and JTAG) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
fn main() { | ||
println!("cargo:rerun-if-changed=layout.ld"); | ||
println!("cargo:rerun-if-changed=../../third_party/tock/boards/kernel_layout.ld"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
MEMORY | ||
{ | ||
rom (rx) : ORIGIN = 0x00001000, LENGTH = 188K | ||
prog (rx) : ORIGIN = 0x00030000, LENGTH = 832K | ||
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 256K | ||
} | ||
|
||
MPU_MIN_ALIGN = 8K; | ||
|
||
INCLUDE ../../third_party/tock/boards/kernel_layout.ld |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
use core::fmt::Write; | ||
gendx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
use core::panic::PanicInfo; | ||
use cortexm4; | ||
use kernel::debug; | ||
use kernel::debug::IoWrite; | ||
use kernel::hil::led; | ||
use kernel::hil::uart::{self, Configure}; | ||
use nrf52840::gpio::Pin; | ||
|
||
use crate::CHIP; | ||
use crate::PROCESSES; | ||
|
||
struct Writer { | ||
initialized: bool, | ||
} | ||
|
||
static mut WRITER: Writer = Writer { initialized: false }; | ||
|
||
impl Write for Writer { | ||
fn write_str(&mut self, s: &str) -> ::core::fmt::Result { | ||
self.write(s.as_bytes()); | ||
Ok(()) | ||
} | ||
} | ||
|
||
impl IoWrite for Writer { | ||
fn write(&mut self, buf: &[u8]) { | ||
let uart = unsafe { &mut nrf52840::uart::UARTE0 }; | ||
if !self.initialized { | ||
self.initialized = true; | ||
uart.configure(uart::Parameters { | ||
baud_rate: 115200, | ||
stop_bits: uart::StopBits::One, | ||
parity: uart::Parity::None, | ||
hw_flow_control: false, | ||
width: uart::Width::Eight, | ||
}); | ||
} | ||
for &c in buf { | ||
unsafe { | ||
uart.send_byte(c); | ||
} | ||
while !uart.tx_ready() {} | ||
} | ||
} | ||
} | ||
|
||
#[cfg(not(test))] | ||
#[no_mangle] | ||
#[panic_handler] | ||
/// Panic handler | ||
pub unsafe extern "C" fn panic_fmt(pi: &PanicInfo) -> ! { | ||
// The nRF52840 Dongle LEDs (see back of board) | ||
const LED1_PIN: Pin = Pin::P0_23; | ||
let led = &mut led::LedLow::new(&mut nrf52840::gpio::PORT[LED1_PIN]); | ||
let writer = &mut WRITER; | ||
debug::panic( | ||
&mut [led], | ||
writer, | ||
pi, | ||
&cortexm4::support::nop, | ||
&PROCESSES, | ||
&CHIP, | ||
) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to mention the DFU-based boards in this README? And the DFU limitations regarding re-flashing Tock?