8 Commits

Author SHA1 Message Date
Michael Droogleever Fortuyn
1587daf5d1 Finish removing rustled 2019-11-30 21:31:41 +01:00
Michael Droogleever Fortuyn
4d631b12aa Add space 2019-11-30 20:58:55 +01:00
Michael Droogleever Fortuyn
72532bcee1 Fix debugging binary name 2019-11-30 20:57:00 +01:00
Michael Droogleever Fortuyn
6ed3b08955 Fix gdbinit name 2019-11-30 20:55:37 +01:00
Michael Droogleever Fortuyn
254312a988 Fix gdb command 2019-11-30 20:48:44 +01:00
Michael Droogleever Fortuyn
4b6be8fb61 Bump microbit 2019-11-23 12:16:22 +01:00
Michael Droogleever Fortuyn
74c52e42b6 Typo: build 2019-11-23 12:07:10 +01:00
Michael Droogleever Fortuyn
74950c7a78 Typo: verify 2019-11-23 11:51:53 +01:00
18 changed files with 51 additions and 53 deletions

View File

@@ -2,5 +2,5 @@ target remote :3333
monitor arm semihosting enable
set print asm-demangle on
load
break main
#break main
continue

View File

@@ -3,7 +3,7 @@
> Create a time delay.
Another piece of information you will need is how to create a time delay before moving to the next row.
We want the time spent switching LED lines on and off to be much shorter than the time spent waiting with LEDs on.
we want the time spent switching LED lines on and off to be much shorter than the time spent waiting with LEDs on.
### For loop

View File

@@ -1,10 +1,9 @@
[package]
name = "display"
version = "0.2.0"
edition = "2018"
version = "0.1.0"
[dependencies]
cortex-m-rt="~0.6"
cortex-m-semihosting="~0.3"
panic-semihosting = "~0.5"
microbit="~0.8"
microbit="~0.6"

View File

@@ -69,10 +69,10 @@ impl Display {
/// Clear display
pub fn clear(&mut self) {
for row in &mut self.rows {
row.set_low().unwrap();
row.set_low();
}
for col in &mut self.cols {
col.set_high().unwrap();
col.set_high();
}
}
@@ -97,18 +97,18 @@ impl Display {
let loops = duration_ms / (self.rows.len() as u32 * self.delay_ms);
for _ in 0..loops {
for (row_line, led_matrix_row) in self.rows.iter_mut().zip(led_matrix.iter()) {
row_line.set_high().unwrap();
row_line.set_high();
for (col_line, led_matrix_val) in self.cols.iter_mut().zip(led_matrix_row.iter()) {
// We are keeping it simple, and not adding brightness
if *led_matrix_val > 0 {
col_line.set_low().unwrap();
col_line.set_low();
}
}
delay.delay_ms(self.delay_ms);
for col_line in &mut self.cols {
col_line.set_high().unwrap();
col_line.set_high();
}
row_line.set_low().unwrap();
row_line.set_low();
}
}
}
@@ -120,15 +120,15 @@ fn main() -> ! {
writeln!(stdout, "Start").unwrap();
if let Some(p) = microbit::Peripherals::take() {
// Split GPIO
let gpio = p.GPIO.split();
let mut gpio = p.GPIO.split();
// Configure RX and TX pins accordingly
let tx = gpio.pin24.into_push_pull_output().downgrade();
let rx = gpio.pin25.into_floating_input().downgrade();
// Configure serial communication
let (mut tx, _) = serial::Serial::uart0(p.UART0, tx, rx, BAUD115200).split();
writeln!(tx, "").unwrap();
writeln!(tx, "Init").unwrap();
writeln!(tx, "");
writeln!(tx, "Init");
// Create delay provider
let mut delay = Delay::new(p.TIMER0);
@@ -179,10 +179,10 @@ fn main() -> ! {
[0, 1, 1, 1, 0],
];
writeln!(tx, "Starting!").unwrap();
writeln!(tx, "Starting!");
loop {
writeln!(tx, "I <3 Rust on the micro:bit!").unwrap();
writeln!(tx, "I <3 Rust on the micro:bit!");
leds.display(&mut delay, letter_I, 1000);
leds.display(&mut delay, heart, 1000);
leds.display(&mut delay, letter_U, 1000);

View File

@@ -149,8 +149,6 @@ Note, you would also need to disable [name mangling][nm]:
#![no_std]
#![no_main]
extern crate panic_halt;
#[no_mangle]
pub extern "C" fn _start() -> ! {
loop {}

View File

@@ -71,7 +71,6 @@ available.
I mentioned that OpenOCD provides a GDB server so let's connect to that right now:
``` console
# On Ubuntu use `gdb-mutliarch -q target/thumbv6m-none-eabi/debug//microrust-start`
$ arm-none-eabi-gdb -q target/thumbv6m-none-eabi/debug/microrust-start
Reading symbols from target/thumbv6m-none-eabi/debug/microrust-start...done.
(gdb)

View File

@@ -6,7 +6,7 @@ Before we start, let's add some code to debug:
``` rust
// -- snip --
#[entry]
entry!(main);
fn main() -> ! {
let _y;
let x = 42;
@@ -87,15 +87,15 @@ $1 = 42
$2 = (i32 *) 0x10001fdc
(gdb) print _y
$3 = -1
$3 = 134219052
(gdb) print &_y
$4 = (i32 *) 0x10001fd8
```
As expected, `x` contains the value `42`.
`_y` however, contains the value `-1` (?).
Because `_y` has not been initialized yet, it contains `-1`.
`_y` however, contains the value `134219052` (?).
Because `_y` has not been initialized yet, it contains some garbage value.
The command `print &x` prints the address of the variable `x`.
The interesting bit here is that GDB output shows the type of the reference:
@@ -108,7 +108,7 @@ Instead of printing the local variables one by one, you can also use the `info l
```
(gdb) info locals
x = 42
_y = -1
_y = 134219052
```
OK. With another `step`, we'll be on top of the `loop {}` statement:

View File

@@ -1,7 +1,6 @@
[package]
name = "start"
version = "0.3.0"
edition = "2018"
version = "0.2.0"
[dependencies]
panic-halt = "~0.2"

View File

@@ -1,10 +1,9 @@
[package]
name = "hello"
version = "0.3.0"
edition = "2018"
version = "0.2.0"
[dependencies]
microbit="~0.8"
microbit="~0.6"
cortex-m-rt="~0.6"
cortex-m-semihosting="~0.3"
panic-semihosting = "~0.5"

View File

@@ -20,20 +20,20 @@ fn main() -> ! {
writeln!(stdout, "Start").unwrap();
if let Some(p) = microbit::Peripherals::take() {
// Split GPIO
let gpio = p.GPIO.split();
let mut gpio = p.GPIO.split();
// Configure RX and TX pins accordingly
let tx = gpio.pin24.into_push_pull_output().downgrade();
let rx = gpio.pin25.into_floating_input().downgrade();
// Configure serial communication
let (mut tx, _) = serial::Serial::uart0(p.UART0, tx, rx, BAUD115200).split();
write!(tx, "serial - start\r\n").unwrap();
write!(tx, "serial - start\r\n");
// Get row and column for display
let mut led = gpio.pin13.into_push_pull_output();
let _ = gpio.pin4.into_push_pull_output();
// Set row high (column starts low)
led.set_high().unwrap();
led.set_high();
// Write string with newline and carriage return
write!(tx, "serial - LED on\r\n").unwrap();
write!(tx, "serial - LED on\r\n");
}
panic!("End");
}

View File

@@ -1,11 +1,10 @@
[package]
name = "micro"
version = "0.2.0"
edition = "2018"
name = "microbit"
version = "0.1.0"
[dependencies]
cortex-m-rt="~0.6"
cortex-m-semihosting="~0.3"
panic-halt = "~0.2"
panic-abort = "~0.3"
panic-semihosting = "~0.5"
microbit="~0.8"
microbit="~0.6"

View File

@@ -1,7 +1,7 @@
#![no_std]
#![no_main]
extern crate panic_halt;
extern crate panic_abort;
extern crate cortex_m_rt as rt;
extern crate microbit;
@@ -16,7 +16,7 @@ use microbit::hal::serial::BAUD115200;
fn main() -> ! {
if let Some(p) = microbit::Peripherals::take() {
// Split GPIO
let gpio = p.GPIO.split();
let mut gpio = p.GPIO.split();
// Configure RX and TX pins accordingly
let tx = gpio.pin24.into_push_pull_output().downgrade();
let rx = gpio.pin25.into_floating_input().downgrade();

View File

@@ -1,7 +1,7 @@
#![no_std]
#![no_main]
extern crate panic_halt;
extern crate panic_abort;
extern crate cortex_m_rt as rt;
extern crate microbit;

View File

@@ -5,7 +5,7 @@
extern crate microbit;
extern crate cortex_m_rt as rt;
extern crate cortex_m_semihosting as sh;
extern crate panic_halt;
extern crate panic_abort;
use core::fmt::Write;
use rt::entry;

View File

@@ -1,11 +1,10 @@
[package]
name = "serial"
version = "0.2.0"
edition = "2018"
version = "0.1.0"
[dependencies]
heapless="~0.5"
heapless="~0.3"
cortex-m-rt="~0.6"
cortex-m-semihosting="~0.3"
panic-semihosting = "~0.5"
microbit="~0.8"
microbit="~0.6"

View File

@@ -13,7 +13,7 @@ use sh::hio;
use microbit::hal::prelude::*;
use microbit::hal::serial;
use microbit::hal::serial::BAUD115200;
use microbit::block;
use microbit::nb::block;
#[entry]
fn main() -> ! {
@@ -21,16 +21,16 @@ fn main() -> ! {
writeln!(stdout, "Start").unwrap();
if let Some(p) = microbit::Peripherals::take() {
// Split GPIO
let gpio = p.GPIO.split();
let mut gpio = p.GPIO.split();
// Configure RX and TX pins accordingly
let tx = gpio.pin24.into_push_pull_output().downgrade();
let rx = gpio.pin25.into_floating_input().downgrade();
// Configure serial communication
let (mut tx, mut rx) = serial::Serial::uart0(p.UART0, tx, rx, BAUD115200).split();
writeln!(tx, "Start").unwrap();
writeln!(tx, "Start");
loop {
let val = block!(rx.read()).unwrap();
block!(tx.write(val)).unwrap();
block!(tx.write(val));
}
}
panic!("End");

View File

@@ -9,7 +9,7 @@ Here are the installation commands for a few Linux distributions.
``` shell
$ sudo apt-get install \
gcc-arm-none-eabi \
gdb-multiarch \
gdb-arm-none-eabi \
minicom \
openocd
```

View File

@@ -38,12 +38,18 @@ Next, follow OS-agnostic installation instructions for a few of the tools:
Install rustup by following the instructions at [https://rustup.rs](https://rustup.rs).
**NOTE** Make sure you have a recent version, but only `1.39.0` is validated.
Then, install or switch to the nightly channel.
``` shell
$ rustup default nightly
```
**NOTE** Make sure you have a nightly newer than `nightly-2018-10-12`.
`rustc -V` should return a date newer than the one shown below:
``` shell
$ rustc -V
rustc 1.39.0 (4560ea788 2019-11-04)
rustc 1.31.0-nightly (2c2e2c57d 2018-10-12)
```
### OS specific instructions