8000 boards/apollo3: redboard_artemis_atp: Initial commit by alistair23 · Pull Request #3804 · tock/tock · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

boards/apollo3: redboard_artemis_atp: Initial commit #3804

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

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ members = [
"boards/particle_boron",
"boards/pico_explorer_base",
"boards/raspberry_pi_pico",
"boards/apollo3/redboard_artemis_atp",
"boards/apollo3/redboard_artemis_nano",
"boards/apollo3/lora_things_plus",
"boards/redboard_redv",
Expand Down
28 changes: 28 additions & 0 deletions boards/apollo3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,33 @@ Apollo3 Boards
This directory contains all of the Apollo3 boards supported by Tock

* ambiq - Generic tools for flashing binaries
* redboard_artemis_atp [SparkFun RedBoard Artemis ATP](https://www.sparkfun.com/products/15442)
* redboard_artemis_nano [SparkFun RedBoard Artemis Nano](https://www.sparkfun.com/products/15443)
* lora_things_plus [SparkFun LoRa Thing Plus - expLoRaBLE](https://www.sparkfun.com/products/17506)

## Hardware differences

All of the boards use the same SoC, so the Tock board files are overall very
similar and can actually be used interchangably for basic operations.

The main difference between them is what is broken out via the boards. For
example the Redboard Artemis ATP uses IOM4 for the Qwiic connector while
the Redboard Artemis Nano uses IOM2.

The GPIO breakouts are also a little different.

The LoRa Thing Plus also sets up the SX1262 radio, which the other boards
don't have.

## Configuration differences

The other difference is Tock configurations. The boards are configured
slightly differently to show a range of different options.

### I2C

The Redboard Artemis ATP doesn't setup a `MuxI2C`, like the other boards,
instead it creates a `I2CMasterSlaveDriver`.

A `I2CMasterSlaveDriver` can also be setup on the Redboard Artemis Nano
instead of a `MuxI2C` as it exposes the correct pins, but it isn't by default.
6 changes: 6 additions & 0 deletions boards/apollo3/redboard_artemis_atp/.cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Licensed under the Apache License, Version 2.0 or the MIT License.
# SPDX-License-Identifier: Apache-2.0 OR MIT
# Copyright Tock Contributors 2022.

[target.'cfg(target_arch = "arm")']
runner = "./run.sh"
19 changes: 19 additions & 0 deletions boards/apollo3/redboard_artemis_atp/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Licensed under the Apache License, Version 2.0 or the MIT License.
# SPDX-License-Identifier: Apache-2.0 OR MIT
# Copyright Tock Contributors 2022.

[package]
name = "redboard_artemis_atp"
version.workspace = true
authors.workspace = true
edition.workspace = true
build = "../../build.rs"

[dependencies]
components = { path = "../../components" }
cortexm4 = { path = "../../../arch/cortex-m4" }
kernel = { path = "../../../kernel" }
apollo3 = { path = "../../../chips/apollo3" }

capsules-core = { path = "../../../capsules/core" }
capsules-extra = { path = "../../../capsules/extra" }
37 changes: 37 additions & 0 deletions boards/apollo3/redboard_artemis_atp/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Licensed under the Apache License, Version 2.0 or the MIT License.
# SPDX-License-Identifier: Apache-2.0 OR MIT
# Copyright Tock Contributors 2022.

# Makefile for building the tock kernel for the RedBoard Artemis ATP platform
#
TARGET=thumbv7em-none-eabi
PLATFORM=redboard_artemis_atp

include ../../Makefile.common

ifndef PORT
PORT="/dev/ttyUSB0"
endif

# Default target for installing the kernel.
.PHONY: install
install: flash

.PHONY: flash
flash: $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/$(PLATFORM).bin
python ../ambiq/ambiq_bin2board.py --bin $< --load-address-blob 0x40000 -b 115200 -port $(PORT) -r 2 -v --magic-num 0xCB --version 0x0 --load-address-wired 0xc000 -i 6 --options 0x1

.PHONY: flash-debug
flash-debug: $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/debug/$(PLATFORM).bin
python ../ambiq/ambiq_bin2board.py --bin $< --load-address-blob 0x40000 -b 115200 -port $(PORT) -r 2 -v --magic-num 0xCB --version 0x0 --load-address-wired 0xc000 -i 6 --options 0x1

.PHONY: flash-app
flash-app:
python ../ambiq/ambiq_bin2board.py --bin $(APP) --load-address-blob 0x60000 -b 115200 -port $(PORT) -r 2 -v --magic-num 0xCB --version 0x0 --load-address-wired 0x40000 -i 6 --options 0x1

.PHONY: test
test:
mkdir -p $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/deps/
$(Q)cp layout.ld $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/deps/
$(Q)cp ../../kernel_layout.ld $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/
$(Q)RUSTFLAGS="$(RUSTC_FLAGS_TOCK)" OBJCOPY=${OBJCOPY} PORT=$(PORT) $(CARGO) test $(CARGO_FLAGS_TOCK_NO_BUILD_STD) $(NO_RUN) --bin $(PLATFORM) --release
84 changes: 84 additions & 0 deletions boards/apollo3/redboard_artemis_atp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
SparkFun RedBoard Artemis ATP
=============================

The RedBoard Artemis ATP is affectionately called 'All the Pins!' at SparkFun.
The Artemis module has 48 GPIO and this board breaks out absolutely every one
of them in a familiar Mega like form factor.

## Board features

- 17 GPIO - all interrupt capable
- 8 ADC channels with 14-bit precision
- 17 PWM channels
- 2 UARTs
- 4 I2C buses
- 2 SPI buses
- PDM Digital Microphone
- Qwiic Connector

For more details [visit the SparkFun
website](https://www.sparkfun.com/products/15442).

## Flashing the kernel

The kernel can be programmed using the Ambiq python scrips. `cd` into `boards/apollo3/sparkfun_redboard_artemis_atp`
directory and run:

```shell
$ make flash

(or)

$ make flash-debug # To flash the debug build
```

This will flash Tock onto the board via the /dev/ttyUSB0 port. If you would like to use a different port you can specify it from the `PORT` variable.

```bash
$ PORT=/dev/ttyUSB2 make flash
```

This will flash Tock over the SparkFun Variable Loader (SVL) using the Ambiq loader.
The SVL can always be re-flashed if you want to.

## I2C Master/Slave support

To use I2C master/slave support the pins need to manually be wired together. This
is because the IOS uses GPIO 0 and 1, while the IOM uses GPIO 40 and 39 (exposed)
via the Qwiic connector.

To do this use a [Qwiic connector breakout](https://www.sparkfun.com/products/14425).

The yellow cable of the connector should be connected to GPIO 0. This is the
SCL line, which can then be connected to other devices.

The blue cable of the connector should be connected to GPIO 1. This is the
SDA line, which can then be connected to other devices.

## Debugging the board

The RedBoard Artemis ATP exposes JTAG via the header in the middle of
the board. See the [SparkFun hookup guide](https://learn.sparkfun.com/tutorials/hookup-guide-for-the-sparkfun-redboard-artemis-atp) for a picture of this.

SparkFun sell accessories you can use to connecting to this. It appears
something like the J-Link BASE will work, but that hasn't been tested by Tock.

Instead, Tock has tested debugging with the [Black Magic Probe](https://black-magic.org/).
The Black Magic Probe (BMP) is an easy to use, mostly plug and play, JTAG/SWD debugger
for embedded microcontrollers.

In order to debug with the BMP, first connect the 2x5 SWD cable to the RedBoard
and the BMP. The ribbon on the RedBoard should face towards the USB
connection and on the BMP away from the USB connection.

Then power on both boards.

Fire up an ARM GDB instance and attach to the BMP with:

```
target extended-remote /dev/ttyACM0
monitor swdp_scan
attach 1
```

You can then use GDB to debug the RedBoard
14 changes: 14 additions & 0 deletions boards/apollo3/redboard_artemis_atp/layout.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* Licensed under the Apache License, Version 2.0 or the MIT License. */
/* SPDX-License-Identifier: Apache-2.0 OR MIT */
/* Copyright Tock Contributors 2023. */

MEMORY
{
rom (rx) : ORIGIN = 0x0000C000, LENGTH = 0x00030000
prog (rx) : ORIGIN = 0x00040000, LENGTH = 0x08000000 - 0x00030000
ram (rwx) : ORIGIN = 0x10000000, LENGTH = 0x60000
}

PAGE_SIZE = 8K;

INCLUDE ../../kernel_layout.ld
14 changes: 14 additions & 0 deletions boards/apollo3/redboard_artemis_atp/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

# Licensed under the Apache License, Version 2.0 or the MIT License.
# SPDX-License-Identifier: Apache-2.0 OR MIT
# Copyright Tock Contributors 2023.

set -ex

${OBJCOPY} --output-target=binary ${OBJCOPY_FLAGS} ${1} redboard-artemis-atp-tests.bin
python ../ambiq/ambiq_bin2board.py --bin redboard-artemis-atp-tests.bin --load-address-blob 0x40000 -b 115200 -port ${PORT} -r 2 -v --magic-num 0xCB --version 0x0 --load-address-wired 0xc000 -i 6 --options 0x1

# If we connect too quickly the UART doesn't work, so add a small delay
sleep 1
screen ${PORT} 115200
60 changes: 60 additions & 0 deletions boards/apollo3/redboard_artemis_atp/src/io.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Licensed under the Apache License, Version 2.0 or the MIT License.
// SPDX-License-Identifier: Apache-2.0 OR MIT
// Copyright Tock Contributors 2022.

use core::fmt::Write;
use core::panic::PanicInfo;

use crate::CHIP;
use crate::PROCESSES;
use crate::PROCESS_PRINTER;
use apollo3;
use kernel::debug;
use kernel::debug::IoWrite;
use kernel::hil::led;

/// Writer is used by kernel::debug to panic message to the serial port.
pub struct Writer {}

/// Global static for debug writer
pub static mut WRITER: Writer = Writer {};

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]) -> usize {
let uart = apollo3::uart::Uart::new_uart_0(); // Aliases memory for uart0. Okay bc we are panicking.
uart.transmit_sync(buf);
buf.len()
}
}

/// Panic handler.
#[no_mangle]
#[panic_handler]
pub unsafe fn panic_fmt(info: &PanicInfo) -> ! {
// just create a new pin reference here instead of using global
let led_pin = &mut apollo3::gpio::GpioPin::new(
kernel::utilities::StaticRef::new(
apollo3::gpio::GPIO_BASE_RAW as *const apollo3::gpio::GpioRegisters,
),
apollo3::gpio::Pin::Pin19,
);
let led = &mut led::LedLow::new(led_pin);
let writer = &mut WRITER;

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