17 Commits

Author SHA1 Message Date
Michael Droogleever Fortuyn
cb48e8fbdd Merge branch 'rofrol-patch-1' 2020-04-27 18:54:57 +02:00
droogmic
492ef04d3d Merge pull request #24 from NOP0/master
Bumped micro-rust dependency to 0.8
2020-04-27 18:47:29 +02:00
droogmic
d8ee697999 Merge pull request #23 from rofrol/patch-6
we -> We
2020-04-27 18:47:20 +02:00
droogmic
3da68b5f1d Merge pull request #21 from rofrol/patch-5
Uninitialized _y has value -1
2020-04-27 18:47:09 +02:00
droogmic
69c27cf5f2 Merge pull request #20 from rofrol/patch-4
use #[entry] instead of entry!
2020-04-27 18:46:57 +02:00
droogmic
fe7a225b00 Merge pull request #19 from rofrol/patch-3
break main instead of break rustled::main
2020-04-27 18:46:46 +02:00
droogmic
e4e030c109 Merge pull request #17 from rofrol/patch-2
Missing extern crate panic_halt
2020-04-27 18:46:32 +02:00
droogmic
f278ec36b1 Use stable rust (#16)
* Stable rust in setup

* Version WIP

* Update panics

* fix1

* manual fixes

* autofix

* bump

* finish

* More stable fixes

* Stable nb block and editions
2020-04-27 18:45:47 +02:00
droogmic
6cc89a0423 Typos (#15)
* Typo: verify

* Typo: build

* Bump microbit

* Fix gdb command

* Fix gdbinit name

* Fix debugging binary name

* Add space

* Finish removing rustled
2020-04-27 18:45:12 +02:00
NOP0
b08613a7fd Bumped micro-rust dependency to 0.8 2020-01-05 21:29:32 +01:00
Roman Frołow
44c312271e we -> We 2019-12-30 15:14:19 +01:00
Roman Frołow
84783bca5e gdb-multiarch 2019-12-30 12:23:20 +01:00
Roman Frołow
7e1dd57395 Uninitialized _y has value -1 2019-12-30 12:19:08 +01:00
Roman Frołow
5810565cf6 use #[entry] instead of entry!
>[breaking-change] the entry!, pre_init! and exception! macros have been replaced with attributes: #[entry], #[pre_init] and #[exception], respectively.

9a4a260398/CHANGELOG.md (v060---2018-09-06)
2019-12-30 12:13:33 +01:00
Roman Frołow
bd34b10823 break main instead of break rustled::main
It didn't work for me with `rustled::`
2019-12-30 12:11:59 +01:00
Roman Frołow
f2dcd25d4e Missing extern crate panic_halt 2019-12-29 18:25:49 +01:00
Roman Frołow
a46be27bce Use gdb-multiarch instead of gdb-arm-none-eabi
https://askubuntu.com/questions/1031103/how-to-install-gdb-arm-none-eabi-on-ubuntu-18-04#comment1682182_1032469
2019-12-29 18:24:23 +01:00
7 changed files with 20 additions and 17 deletions

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

@@ -136,7 +136,7 @@ executing the binary usually has the operating system start by executing the C r
This in turn invokes the Rust runtime, as marked by the `start` language item,
which in turn invokes the main function.
Having enabled `no_std`, as we are targeting on a microcontroller,
Having enabled `no_std`, as we are targeting a microcontroller,
neither the crt0 nor the rust runtime are available,
so even implementing `start` would not help us.
We need to replace the operating system entry point.
@@ -149,6 +149,8 @@ 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

@@ -2,7 +2,7 @@
Flashing is the process of moving our program into the microcontroller's (persistent) memory. Once flashed, the microcontroller will execute the flashed program every time it is powered on.
In this case, our `rustled` program will be the only program in the microcontroller memory. By this I mean that there's nothing else running on the microcontroller: no OS, no daemon, nothing. `rustled` has full control over the device. This is what is meant by *bare-metal* programming.
In this case, our `microrust-start` program will be the only program in the microcontroller memory. By this I mean that there's nothing else running on the microcontroller: no OS, no daemon, nothing. `microrust-start` has full control over the device. This is what is meant by *bare-metal* programming.
<dl>
<dt>OS</dt>
@@ -71,8 +71,9 @@ available.
I mentioned that OpenOCD provides a GDB server so let's connect to that right now:
``` console
$ arm-none-eabi-gdb -q target/thumbv6m-none-eabi/debug/rustled
Reading symbols from target/thumbv6m-none-eabi/debug/rustled...done.
# 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)
```
@@ -157,9 +158,9 @@ set print asm-demangle on
# Load your program, breaks at entry
load
# (optional) Add breakpoint at function
break rustled::main
break main
# Continue with execution
continue
```
Now we can learn how to debug code on the micro:bit.
Now we can learn how to debug code on the micro:bit.

View File

@@ -6,7 +6,7 @@ Before we start, let's add some code to debug:
``` rust
// -- snip --
entry!(main);
#[entry]
fn main() -> ! {
let _y;
let x = 42;
@@ -28,14 +28,14 @@ At this time, we are not interested in that "pre-main" part so let's skip right
the `main` function. We'll do that using a breakpoint:
```
(gdb) break rustled::main
(gdb) break main
Breakpoint 1 at 0x8000218: file src/main.rs, line 8.
(gdb) continue
Continuing.
Note: automatically using hardware breakpoints for read-only addresses.
Breakpoint 1, rustled::main () at src/rustled/src/main.rs:13
Breakpoint 1, main () at src/microrust-start/src/main.rs:13
13 let x = 42;
```
@@ -87,15 +87,15 @@ $1 = 42
$2 = (i32 *) 0x10001fdc
(gdb) print _y
$3 = 134219052
$3 = -1
(gdb) print &_y
$4 = (i32 *) 0x10001fd8
```
As expected, `x` contains the value `42`.
`_y` however, contains the value `134219052` (?).
Because `_y` has not been initialized yet, it contains some garbage value.
`_y` however, contains the value `-1` (?).
Because `_y` has not been initialized yet, it contains `-1`.
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 = 134219052
_y = -1
```
OK. With another `step`, we'll be on top of the `loop {}` statement:

View File

@@ -2,5 +2,5 @@
In this chapter, we will discuss the basic I/O of embedded development in rust.
After this chapter,you should have all the neccesary basic knowledge to do embedded development in Rust,
After this chapter, you should have all the neccesary basic knowledge to do embedded development in Rust,
with anything remaining being solution specific.

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-arm-none-eabi \
gdb-multiarch \
minicom \
openocd
```

View File

@@ -18,7 +18,7 @@ Bus 002 Device 033: ID 0d28:0204 NXP ARM mbed
```
In my case, the micro:bit got connected to the bus #2 and got enumerated as the device #33.
This means the file `/dev/bus/usb/002/033` *is* the Fmicro:bit3.
This means the file `/dev/bus/usb/002/033` is the micro:bit.
Let's check its permissions:
``` shell