Skip to content
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

added receive functionality to the cc26x0 uart #2

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
42e568f
working RX (using console app)
Apr 26, 2018
ee65277
ran make formatall
Apr 26, 2018
ff28980
added receive functionality to the cc26x0 uart
Apr 27, 2018
f337df4
ran make formatall
Apr 27, 2018
bce1788
added statically allocated DMA control table section
Apr 29, 2018
a0ae70e
started setting up DMA- added statically allocated arrays for DMA con…
Apr 29, 2018
d2da82f
working aligned DMA CTRL Table without using custom linker
Apr 30, 2018
49021c4
Merge branch 'launchpad-uart-rx' into cc26x0-uart-rx
Apr 30, 2018
7ce18c7
cleaned up a few comments, working aligned DMA control table without …
Apr 30, 2018
1d978a2
working configuration (right now using a private static array inside …
May 1, 2018
6d1a4e3
tried to implement register changes
May 7, 2018
d5cd118
Merge branch 'launchpad-uart-rx' into cc26x0-uart-rx
May 7, 2018
72a1d75
static block initialization, nothing fancy
May 8, 2018
8ba03bd
Merge branch 'launchpad-uart-rx' into cc26x0-uart-rx
May 8, 2018
a58c54d
successfully builds
May 8, 2018
8d0d23f
removed copy clone derive from core, still builds
May 8, 2018
aa229b2
ram overflow...
May 20, 2018
8c4ba6b
Merge branch 'launchpad-uart-rx' into cc26x0-uart-rx
May 20, 2018
dfadaf3
ready for testing
May 20, 2018
30ac41d
working TX
May 22, 2018
1d45bf0
added the buffer vector to the right spot
May 22, 2018
523fbaf
working transmit/receive (finally)
May 23, 2018
469b0d1
changed main.rs to be compatible with sensortag pinouts (forgot to wo…
May 23, 2018
cb97e27
made requested changes
May 24, 2018
252d7dd
merged updated master
May 29, 2018
202d8e9
UART tx works but not rx. maybe it's not waking up from sleep?
May 29, 2018
603cbc9
Merge branch 'launchpad-uart-rx' into cc26x0-uart-rx
May 29, 2018
91e1975
changing sleep settings
May 29, 2018
836b78a
removed extraneous comments
May 29, 2018
51ad227
added launchpad board definition
May 29, 2018
7eeede2
added code for io.rs
May 30, 2018
78f9e75
merged in latest master updates
May 30, 2018
e2af3c0
addressed compiler warnings
May 30, 2018
1a5081b
removed commented code
Jun 1, 2018
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
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "tock"]
path = tock
url = https://github.com/helena-project/tock
url = https://github.com/tock/tock
53 changes: 53 additions & 0 deletions boards/launchxl/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions boards/launchxl/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[package]
name = "launchxl"
version = "0.1.0"
authors = ["Tock Project Developers <tock-dev@googlegroups.com>"]
build = "build.rs"

[profile.dev]
panic = "abort"
lto = true
opt-level = "z"
debug = true

[profile.release]
panic = "abort"
lto = true
opt-level = "z"
debug = true

[dependencies]
cortexm3 = { path = "../../tock/arch/cortex-m3" }
capsules = { path = "../../tock/capsules" }
kernel = { path = "../../tock/kernel" }
cc26xx = { path = "../../tock/chips/cc26xx" }

cc26x0 = { path = "../../chips/cc26x0" }
15 changes: 15 additions & 0 deletions boards/launchxl/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Makefile for building the tock kernel for the launchxl development kit

TOCK_ARCH=cortex-m3
TOCK_BOARD=launchxl
TARGET=thumbv7m-none-eabi
PLATFORM=launchxl

PROG_BASE=0x10000

include ../../tock/boards/Makefile.common

flash: target/$(TARGET)/release/launchxl
$(call check_defined, UNIFLASH_CLI_BASE, See launchxl README for details)
@echo "Flashing target/$(TARGET)/release/launchxl"
@$(UNIFLASH_CLI_BASE)/ccs_base/DebugServer/bin/DSLite flash -c jtag/cc2650.ccxml -e -f target/$(TARGET)/release/launchxl
26 changes: 26 additions & 0 deletions boards/launchxl/Makefile-app
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Makefile for loading applications for the launchpad

$(call check_defined, TOCK_USERLAND_BASE_DIR)
$(call check_defined, BUILDDIR)
$(call check_defined, PACKAGE_NAME)

TOCK_ARCH = cortex-m3
BOARD_BUILDDIR = $(BUILDDIR)/$(TOCK_ARCH)

PROG_BASE=0x10000

# Relative working directory, get the directory of *this*
# specific makefile
RWD=$(TOCK_USERLAND_BASE_DIR)/../../boards/launchxl

$(BOARD_BUILDDIR)/$(TOCK_ARCH).tbf: $(BOARD_BUILDDIR/$(TOCK_ARCH).elf

# Upload programs to launchpad
.PHONY: flash
flash: $(BOARD_BUILDDIR)/$(TOCK_ARCH).tbf $(BUILDDIR)/$(PACKAGE_NAME).tab
$(call check_defined, UNIFLASH_CLI_BASE, See launchxl README for details)
@$(UNIFLASH_CLI_BASE)/ccs_base/DebugServer/bin/DSLite flash -c $(RWD)/jtag/cc2650.ccxml -e -f $<,$(PROG_BASE)

.PHONY: program
program: $(BOARD_BUILDDIR)/$(TOCK_ARCH).bin $(BUILDDIR)/$(PACKAGE_NAME).tab
$(error Cannot program launchpad over USB. Use \'make flash\' and JTAG)
76 changes: 76 additions & 0 deletions boards/launchxl/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
## Platform specific instructions
The [Launchpad CC2650STK](http://www.ti.com/tool/launchxl-cc2650) is a platform based on the CC2650 MCU by
Texas Instrument, an SoC running on an ARM Cortex-M3.

The technical reference manual for the cc2650 can be found
[here](http://www.ti.com/lit/ug/swcu117h/swcu117h.pdf),
and it shares many properties with other MCUs in the same family (cc26xx).

### Flashing
Download and use [uniflash](http://processors.wiki.ti.com/index.php/Category:CCS_UniFlash) to flash. Follow the guide
[here](http://processors.wiki.ti.com/index.php/UniFlash_v4_Quick_Guide#Standalone_Command_line_tool) in order to generate
a standalone command line tool to ease the flashing process.

The standalone CLI has been extracted, set an environment variable named `UNIFLASH_CLI_BASE` in your shell profile:

```bash
$> echo export UNIFLASH_CLI_BASE="<path to extracted uniflash CLI>" >> ~/.bash_profile
$> source ~/.bash_profile
```

Now you're able to use the Makefile target `flash` in order to load the kernel onto the SensorTag board.

```bash
$> make flash # make and flash the kernel
```

### Apps
To compile and get apps to the board, you need to navigate to their directory in tock/userland/...

```bash
$> cd tock/userland/examples/blink
$> make
```

#### Flashing
You can issue the flash command by pointing the variable `TOCK_BOARD` to the correct
directory.

```bash
$> make TOCK_BOARD=../../boards/launchxl flash
```

### Debugging
You need to use openocd together with gdb in order to debug the launchxl board using JTAG. However, you'll need to build OpenOCD with extra applied patches until the next version has been released.

Clone the repository and apply the patches:

```bash
$> git clone https://git.code.sf.net/p/openocd/code openocd
$> cd openocd
$> git pull http://openocd.zylin.com/openocd refs/changes/22/4322/2
$> git pull http://openocd.zylin.com/openocd refs/changes/58/4358/1
```

Once cloned and the patches has been applied, read the readme in order to build and install openocd.

Once flashed, launch openocd with the configuration specified at jtag/openocd.cfg:

```bash
$> openocd -f jtag/openocd.cfg
```

And then launch gdb

```bash
$> arm-none-eabi-gdb -x jtag/gdbinit
```

and it will automatically connect to the board.

*Note: it is possible to debug using OpenOCD without the applied patches, but it is painfully slow.
Just install a later version than 0.10 of OpenOCD, and uncomment the necessary parts in jtag/openocd.cfg (see file), then
follow the instructions above.*

### Panic/Crash
When the board panics or crashes, the RED led will be blinking frequently.
7 changes: 7 additions & 0 deletions boards/launchxl/Xargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[dependencies.core]

[dependencies.compiler_builtins]
features = ["mem"]
git = "https://github.com/rust-lang-nursery/compiler-builtins"
stage = 1
rev = "67e0908d7f2fd86423ec32fc4d904952fe96e7a9"
5 changes: 5 additions & 0 deletions boards/launchxl/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");
}
15 changes: 15 additions & 0 deletions boards/launchxl/jtag/cc2650.ccxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<configurations XML_version="1.2" id="configurations_0">
<configuration XML_version="1.2" id="Texas Instruments XDS110 USB Debug Probe_0">
<instance XML_version="1.2" desc="Texas Instruments XDS110 USB Debug Probe_0" href="connections/TIXDS110_Connection.xml" id="Texas Instruments XDS110 USB Debug Probe_0" xml="TIXDS110_Connection.xml" xmlpath="connections"/>
<connection XML_version="1.2" id="Texas Instruments XDS110 USB Debug Probe_0">
<instance XML_version="1.2" href="drivers/tixds510icepick_c.xml" id="drivers" xml="tixds510icepick_c.xml" xmlpath="drivers"/>
<instance XML_version="1.2" href="drivers/tixds510cs_dap.xml" id="drivers" xml="tixds510cs_dap.xml" xmlpath="drivers"/>
<instance XML_version="1.2" href="drivers/tixds510cortexM.xml" id="drivers" xml="tixds510cortexM.xml" xmlpath="drivers"/>
<platform XML_version="1.2" id="platform_0">
<instance XML_version="1.2" desc="CC2650F128_0" href="devices/cc2650f128.xml" id="CC2650F128_0" xml="cc2650f128.xml" xmlpath="devices"/>
</platform>
</connection>
</configuration>
</configurations>

14 changes: 14 additions & 0 deletions boards/launchxl/jtag/gdbinit
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# GDB Init for openocd

set remotetimeout 20000

# Connect to openocd at port 3333
target remote localhost:3333

file target/thumbv7m-none-eabi/release/launchxl

monitor reset halt

# Setup GDB for faster downloads
set remote memory-write-packet-size 1024
set remote memory-write-packet-size fixed
11 changes: 11 additions & 0 deletions boards/launchxl/jtag/openocd.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Uncomment to debug with OpenOCD w/o patches
#source [find interface/cmsis-dap.cfg]

## Comment to debug with OpenOCD w/o patches
source [find interface/xds110.cfg]

transport select jtag
# gdb_memory_map enable
gdb_flash_program enable
source [find target/cc26xx.cfg]
adapter_khz 5000
42 changes: 42 additions & 0 deletions boards/launchxl/layout.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* This is the generic linker script for Tock. For most developers, it should
* be sufficient to define {ROM/PROG/RAM}_{ORIGIN/LENGTH} (6 variables, the
* start and length for each) and MPU_MIN_ALIGN (the minimum alignment
* granularity supported by the MPU).
*
* --------------------------------------------------------------------------
*
* If you wish to create your own linker script from scratch, you must define
* the following symbols:
*
* `_etext`, `_srelocate`, `_erelocate`
* The `_etext` symbol marks the end of data stored in flash that should
* stay in flash. `_srelocate` and `_erelocate` mark the address range in
* SRAM that mutable program data is copied to.
*
* Tock will copy `_erelocate` - `_srelocate` bytes of data from the
* `_etext` pointer to the `_srelocate` pointer.
*
* `_szero`, `_ezero`
*
* The `_szero` and `_ezero` symbols define the range of the BSS, SRAM that
* Tock will zero on boot.
*
* `_sapps`
*
* The `_sapps` symbol marks the beginning of application memory in flash.
*/

ROM_ORIGIN = 0x00000000;
ROM_LENGTH = 0x00010000;
PROG_ORIGIN = 0x00010000;
PROG_LENGTH = 0x0000F000;
CCFG_ORIGIN = 0x0001FFA8;
CCFG_LENGTH = 0x00000058;
RAM_ORIGIN = 0x20000000;
RAM_LENGTH = 20K;

MPU_MIN_ALIGN = 4;

INCLUDE ../../tock/boards/kernel_layout.ld

90 changes: 90 additions & 0 deletions boards/launchxl/src/io.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
use core::fmt::{write, Arguments, Write};
use kernel::hil::uart::{self, UART};
use kernel::hil::gpio::Pin;
use cc26xx;
use cc26x0;

pub struct Writer {
initialized: bool,
}

pub static mut WRITER: Writer = Writer { initialized: false };

impl Write for Writer {
fn write_str(&mut self, s: &str) -> ::core::fmt::Result {
let uart = unsafe { &mut cc26x0::uart::UART0 };
if !self.initialized {
self.initialized = true;
uart.init(uart::UARTParams {
baud_rate: 115200,
stop_bits: uart::StopBits::One,
parity: uart::Parity::None,
hw_flow_control: false,
});
}

for c in s.bytes() {
uart.send_byte(c);
while !uart.tx_ready() {}
}
Ok(())
}
}

#[macro_export]
macro_rules! print {
($($arg:tt)*) => (
{
use core::fmt::write;
let writer = &mut $crate::io::WRITER;
let _ = write(writer, format_args!($($arg)*));
}
);
}

#[macro_export]
macro_rules! println {
($fmt:expr) => (print!(concat!($fmt, "\n")));
($fmt:expr, $($arg:tt)*) => (print!(concat!($fmt, "\n"), $($arg)*));
}

#[cfg(not(test))]
#[lang = "panic_fmt"]
#[no_mangle]
pub unsafe extern "C" fn rust_begin_unwind(
_args: Arguments,
_file: &'static str,
_line: usize,
) -> ! {
let writer = &mut WRITER;
let _ = writer.write_fmt(format_args!(
"\r\nKernel panic at {}:{}:\r\n\t\"",
_file, _line
));
let _ = write(writer, _args);
let _ = writer.write_str("\"\r\n");

let led0 = &cc26xx::gpio::PORT[10]; // Red led
let led1 = &cc26xx::gpio::PORT[15]; // Green led

led0.make_output();
led1.make_output();
loop {
for _ in 0..1000000 {
led0.clear();
led1.clear();
}
for _ in 0..100000 {
led0.set();
led1.set();
}
for _ in 0..1000000 {
led0.clear();
led1.clear();
}
for _ in 0..500000 {
led0.set();
led1.set();
}
}
}
Loading