Skip to content

Commit

Permalink
Merge #1911
Browse files Browse the repository at this point in the history
1911: New Platform: Msp432 r=bradjc a=lebakassemmerl

### New Platform Support for the MSP-EXP432P401R Eval-Board

This pull-request adds support for MSP432P401R chip from Texas Instruments.
The implementation is currently very, very basic, only the GPIO-module is properly implemented in order to create a panic-handler which blinks an LED and to be able to test a simple user-space application. 

If this PR will be accepted, the next step would be to implement the UART and timer modules for supporting debug-output and delays in userspace.

## Adding a Platform to Tock Repository

- [x] The hardware must be widely available. Generally that means the hardware platform can be purchased online.
- The port of Tock to the platform must include at least:
   - [x] Console support so that debug!() and printf() work.
   - [x] Timer support.
   - [x] GPIO support with interrupt functionality.
- [x] The contributor must be willing to maintain the platform, at least initially, and help test the platform for future releases.


Co-authored-by: hotschi <hotschi@gmx.at>
  • Loading branch information
bors[bot] and lebakassemmerl committed Jul 24, 2020
2 parents 2ce7b7b + 578d70d commit 8bb0709
Show file tree
Hide file tree
Showing 25 changed files with 4,775 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@
"monitor speed auto",
"b reset_handler"
]
},
{
"name": "MSP432 Cortex Debug",
"type": "cortex-debug",
"servertype": "openocd",
"request": "launch",
"executable": "${workspaceRoot}/target/thumbv7em-none-eabi/debug/msp-exp432p401r.elf",
"cwd": "${workspaceRoot}",
"svdFile": "${workspaceRoot}/boards/msp_exp432p401r/msp432.svd",
"runToMain": true,
"configFiles": [
"${workspaceRoot}/boards/msp_exp432p401r/openocd.cfg",
]
}
]
}
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ members = [
"boards/hail",
"boards/hifive1",
"boards/imix",
"boards/msp_exp432p401r",
"boards/nordic/nrf52840dk",
"boards/nordic/nrf52840_dongle",
"boards/nordic/nrf52dk",
Expand All @@ -26,6 +27,7 @@ members = [
"chips/e310x",
"chips/earlgrey",
"chips/lowrisc",
"chips/msp432",
"chips/nrf52",
"chips/nrf52832",
"chips/nrf52840",
Expand Down
13 changes: 13 additions & 0 deletions boards/msp_exp432p401r/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "msp-exp432p401r"
version = "0.1.0"
authors = ["Tock Project Developers <tock-dev@googlegroups.com>"]
build = "build.rs"
edition = "2018"

[dependencies]
components = { path = "../components" }
cortexm4 = { path = "../../arch/cortex-m4" }
capsules = { path = "../../capsules" }
kernel = { path = "../../kernel" }
msp432 = { path = "../../chips/msp432" }
23 changes: 23 additions & 0 deletions boards/msp_exp432p401r/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Makefile for building the tock kernel for the MSP-EXP432P401 launchpad
#
TARGET=thumbv7em-none-eabi
PLATFORM=msp-exp432p401r

include ../Makefile.common

OPENOCD=openocd
OPENOCD_OPTIONS=-f openocd.cfg
APP_START_ADDR=0x20000
APP?=

.PHONY: flash-debug
flash-debug: $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/debug/$(PLATFORM).elf
$(OPENOCD) $(OPENOCD_OPTIONS) -c "init; reset halt; flash write_image erase $<; verify_image $<; reset; shutdown"

.PHONY: flash
flash: $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/$(PLATFORM).elf
$(OPENOCD) $(OPENOCD_OPTIONS) -c "init; reset halt; flash write_image erase $<; verify_image $<; reset; shutdown"

.PHONY: flash-app
flash-app:
$(OPENOCD) $(OPENOCD_OPTIONS) -c "init; reset halt; flash write_image erase $(APP) $(APP_START_ADDR) bin; verify_image_checksum $(APP) $(APP_START_ADDR) bin; reset; shutdown"
33 changes: 33 additions & 0 deletions boards/msp_exp432p401r/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
MSP432 Evaluation kit MSP432P401R MCU
=====================================

For more details [visit the Evaluation kit website](https://www.ti.com/tool/MSP-EXP432P401R).

## Flashing the kernel

The kernel can be programmed using OpenOCD. `cd` into `boards/msp_exp432p401r`
directory and run:

```bash
$ make flash

(or)

$ make flash-debug
```

**Note:** Make sure to use the latest git-openOCD-version as there is currently no support for the
XDS110 debug-probe in the pre-built binaries!

## Flashing an app

Apps are also flashed via openOCD. Make sure, your app is was compiled and converted into the TBF
(Tock Binary Format) format. Then `cd` into the `boards/msp_exp432p401r`directory and run:

```bash
$ make flash-app APP=<path_to_tbf_file>

(e.g.)

$ make flash-app APP=../../../libtock-c/examples/c_hello/build/cortex-m4/cortex-m4.tbf
```
5 changes: 5 additions & 0 deletions boards/msp_exp432p401r/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fn main() {
println!("cargo:rerun-if-changed=layout.ld");
println!("cargo:rerun-if-changed=chip_layout.ld");
println!("cargo:rerun-if-changed=../kernel_layout.ld");
}
9 changes: 9 additions & 0 deletions boards/msp_exp432p401r/chip_layout.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* Memory Space Definitions, 256K flash, 64K ram */
MEMORY
{
rom (rx) : ORIGIN = 0x00000000, LENGTH = 128K
prog (rx) : ORIGIN = 0x00020000, LENGTH = 128K
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K
}

MPU_MIN_ALIGN = 4K;
2 changes: 2 additions & 0 deletions boards/msp_exp432p401r/layout.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
INCLUDE ./chip_layout.ld
INCLUDE ../kernel_layout.ld
6 changes: 6 additions & 0 deletions boards/msp_exp432p401r/openocd.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
adapter driver xds110
adapter speed 2500
source [find board/ti_msp432_launchpad.cfg]

init;
reset halt;
57 changes: 57 additions & 0 deletions boards/msp_exp432p401r/src/io.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
use crate::CHIP;
use crate::PROCESSES;

use core::fmt::Write;
use core::panic::PanicInfo;
use kernel::debug;
use kernel::debug::IoWrite;
use kernel::hil::led;
use msp432::gpio::PinNr;

/// Uart is used by kernel::debug to panic message to the serial port.
pub struct Uart {
initialized: bool,
}

/// Global static for debug writer
pub static mut UART: Uart = Uart { initialized: false };

impl Uart {
/// Indicate that UART has already been initialized.
pub fn set_initialized(&mut self) {
self.initialized = true;
}
}

impl Write for Uart {
fn write_str(&mut self, s: &str) -> ::core::fmt::Result {
self.write(s.as_bytes());
Ok(())
}
}

impl IoWrite for Uart {
fn write(&mut self, buf: &[u8]) {
unsafe {
msp432::uart::UART0.transmit_sync(buf);
}
}
}

/// Panic handler
#[no_mangle]
#[panic_handler]
pub unsafe extern "C" fn panic_fmt(info: &PanicInfo) -> ! {
const LED1_PIN: PinNr = PinNr::P01_0;
let led = &mut led::LedHigh::new(&mut msp432::gpio::PINS[LED1_PIN as usize]);
let writer = &mut UART;

debug::panic(
&mut [led],
writer,
info,
&cortexm4::support::nop,
&PROCESSES,
&CHIP,
)
}

0 comments on commit 8bb0709

Please sign in to comment.