Add nix-shell for Rust with OpenOCD & ITM; tcp example IP can be changed

* The user can now run a Nix shell to run the examples, OpenOCD and `itmdump` with Shell script binaries; use `run-help` for the list of these binaries.
* This includes a `itmdump` v0.3.1 binary re-compiled with patches for Rust >=1.41.0.
This commit is contained in:
Harry Ho 2020-06-24 14:14:58 +08:00
parent 66f89e8085
commit d399ebc3df
8 changed files with 16034 additions and 52 deletions

149
README.md
View File

@ -1,13 +1,8 @@
# ENC424J600 Driver # ENC424J600 Driver
## Examples ## Examples
<!---
TODO: Remove the installation/env setup steps in the following how-to;
only keep example-specific steps.
-->
### Endless Pinging - `tx_stm32f407` ### Endless Pinging - `tx_stm32f407`
This program demonstrates the Ethernet TX capability on an STM32F407 board connected to an ENC424J600 module via SPI. Once loaded and initialised, a specific ping packet is sent (broadcasted) every 100ms. Such a packet has the following properties: This program demonstrates the Ethernet TX capability on an STM32F407 board connected to an ENC424J600 module via SPI. Once loaded and initialised, a specific ping packet is sent (broadcasted) every 100ms. Such a packet has the following properties:
@ -18,37 +13,43 @@ This program demonstrates the Ethernet TX capability on an STM32F407 board conne
* Source IP Address: 192.168.1.100 * Source IP Address: 192.168.1.100
* Frame Length in Bytes: 64 * Frame Length in Bytes: 64
Note that this program uses ITM for logging output. This program assumes that **GPIO PA1** is connected to SPISEL of the Ethernet module. The program output is logged via ITM.
#### How-to #### How-to
1. Prepare the Rust and Cargo environment for building and running the program on STM32F4xx Cortex-M platforms. 1. On a console window, run OpenOCD and debug the example program:
```sh
2. Install [`itm`](https://docs.rs/itm/) on Cargo: $ nix-shell
[nix-shell]$ run-openocd-f4x
[nix-shell]$ tx_stm32f407
``` ```
cargo install itm
```
If necessary, add your installation location (`~/.cargo/bin` by default) to `$PATH`.
3. Connect your STM32F407 device to the computer. Without changing any code, you may use an STLink V2 debugger. 2. On a separate console window, run [`itmdump`](https://docs.rs/itm/) to observe the output:
```sh
4. Run OpenOCD with the appropriate configuration files (e.g. `interface/stlink-v2.cfg`, `target/stm32f4x.cfg`). $ nix-shell
[nix-shell]$ run-itmdump-follow
5. With OpenOCD running, build and run this program:
``` ```
cargo run --release --example=tx_stm32f407 --features=stm32f407
```
Use appropriate GDB commands such as `c` for continuing.
6. On a separate console window, monitor and observe the ITM output, which is located at the same directory as you started OpenOCD: #### Expected Output
(Note: the MAC address is an example only.)
``` ```
itmdump -f itm.log -F Eth TX Pinging on STM32-F407 via NIC100/ENC424J600
Ethernet initialised.
MAC Address = 04-91-62-3e-fc-1e
Promiscuous Mode ON
Sending packet (len=64): dest=ff-ff-ff-ff-ff-ff src=08-60-6e-44-42-95 data=08060001 08000604 ...
Packet sent
Sending packet (len=64): dest=ff-ff-ff-ff-ff-ff src=08-60-6e-44-42-95 data=08060001 08000604 ...
Packet sent
...
``` ```
### TCP Echoing & Greeting - `tcp_stm32f407` ### TCP Echoing & Greeting - `tcp_stm32f407`
This program demonstrates the TCP connectivity using **smoltcp** on an STM32F407 board connected to an ENC424J600 module via SPI. Once loaded and initialised, two TCP sockets will be opened on the IP address 192.168.1.75/24. These sockets are: This program demonstrates the TCP connectivity using **smoltcp** on an STM32F407 board connected to an ENC424J600 module via SPI. Once loaded and initialised, two TCP sockets will be opened on a specific IPv4 address. These sockets are:
1. **Echoing port - 1234** 1. **Echoing port - 1234**
* This socket receives raw data on all incoming TCP packets on the said port and prints them back on the output. * This socket receives raw data on all incoming TCP packets on the said port and prints them back on the output.
@ -57,35 +58,85 @@ This program demonstrates the TCP connectivity using **smoltcp** on an STM32F407
* This socket waits for a single incoming TCP packet on the said port, and sends a TCP packet holding a text of greeting on the port. * This socket waits for a single incoming TCP packet on the said port, and sends a TCP packet holding a text of greeting on the port.
* Note that once a greeting is sent, the port is closed immediately. Further packets received by the controller are dropped until the initiator closes the port. * Note that once a greeting is sent, the port is closed immediately. Further packets received by the controller are dropped until the initiator closes the port.
Note that this program uses ITM for logging output. This program assumes that **GPIO PA1** is connected to SPISEL of the Ethernet module. The program output is logged via ITM.
#### How-to #### How-to
1. Prepare the Rust and Cargo environment for building and running the program on STM32F4xx Cortex-M platforms. 1. On a console window, run OpenOCD and debug the example program. Choose your own IPv4 address and prefix length:
```sh
2. Install [`itm`](https://docs.rs/itm/) on Cargo: $ nix-shell
``` [nix-shell]$ run-openocd-f4x
cargo install itm [nix-shell]$ tcp_stm32f407 <ip> <prefix>
```
If necessary, add your installation location (`~/.cargo/bin` by default) to `$PATH`.
3. Connect your STM32F407 device to the computer. Without changing any code, you may use an STLink V2 debugger.
4. Run OpenOCD with the appropriate configuration files (e.g. `interface/stlink-v2.cfg`, `target/stm32f4x.cfg`).
5. With OpenOCD running, build and run this program:
```
cargo run --release --example=tcp_stm32f407 --features=stm32f407,smoltcp-phy-all
```
Use appropriate GDB commands such as `c` for continuing.
6. On a separate console window, monitor and observe the ITM output, which is located at the same directory as you started OpenOCD:
```
itmdump -f itm.log -F
``` ```
7. To test the TCP ports, you may use the Netcat utility (`nc`): 2. On a separate console window, run [`itmdump`](https://docs.rs/itm/) to observe the output:
```sh
$ nix-shell
[nix-shell]$ run-itmdump-follow
``` ```
nc 192.168.1.75 <port-number>
3. To test the TCP ports, open another console window and use utilities like NetCat (`nc`):
```sh
$ nc <ip> <port-number>
``` ```
Multiple instances of Netcat can run to use all the ports simultaneously. Use Ctrl+C to close the port manually. Multiple instances of Netcat can run to use all the ports simultaneously. Use Ctrl+C to close the port manually (especially for the greeting port).
#### Expected Output
(Note: the IP address, MAC address and timestamps shown below are examples only.)
ITM output at the initial state:
```
Eth TCP Server on STM32-F407 via NIC100/ENC424J600
Ethernet initialised.
Timer initialised.
MAC Address = 04-91-62-3e-fc-1e
TCP sockets will listen at 192.168.1.77/24
[0.0s] Listening to port 1234 for echoing, auto-closing in 10s
[0.0s] Listening to port 4321 for greeting, please open the port
```
The user opens port 1234 and sends two packets with the following commands:
```sh
$ nc 192.168.1.77 1234
Hello World!
Bye World!
```
The following is appended to the ITM output:
```
[12.950s] Received packet: Ok("Hello world!\n")
[19.0s] Received packet: Ok("Bye world!\n")
```
The user then opens port 4321 with the following command, and immediately receives the following message on their console:
```sh
$ nc 192.168.1.77 4321
Welcome to the server demo for STM32-F407!
```
The following is appended to the ITM output:
```
[24.200s] Greeting sent, socket closed
```
After 10 seconds of the user not sending any more packets on port 1234, the following is appended to the ITM output; meanwhile, port 1234 is closed by `nc` for the user:
```
[29.0s] Listening to port 1234 for echoing, auto-closing in 10s
```
The user can now re-open port 1234 again.
For port 4321, without closing the port by exiting `nc`, the user keeps sending any packets with the utility. Since the Ethernet controller has already closed the port, these new packets are dropped and the following error messages are appended to the ITM output:
```
[35.950s] Poll error: Dropped
[36.150s] Poll error: Dropped
...
```
The user then closes port 4321 by exiting `nc`, and the following message is appended to the ITM output:
```
[40.200s] Listening to port 4321 for greeting, please open the port
```
The user can now re-open port 4321 again.

View File

@ -1,6 +1,8 @@
#![no_std] #![no_std]
#![no_main] #![no_main]
use core::env;
extern crate panic_itm; extern crate panic_itm;
use cortex_m::iprintln; use cortex_m::iprintln;
@ -88,6 +90,29 @@ fn main() -> ! {
iprintln!(stim0, iprintln!(stim0,
"Eth TCP Server on STM32-F407 via NIC100/ENC424J600"); "Eth TCP Server on STM32-F407 via NIC100/ENC424J600");
// Get IP address from args
let arg_ip_raw = env!("ENC424J600_TCP_IP");
let mut arg_ip_str = arg_ip_raw.split('.');
let mut arg_ip: [u8; 4] = [0; 4];
for i in 0..4 {
match arg_ip_str.next() {
Some(x) => {
match x.parse() {
Ok(x_) => { arg_ip[i] = x_ },
Err(_) => { panic!("IPv4 address invalid!") }
}
},
None => { panic!("IPv4 address invalid!") }
}
}
// Get IP prefix length from args
let arg_ip_pref_raw = env!("ENC424J600_TCP_PREF");
let mut arg_ip_pref: u8 = 0;
match arg_ip_pref_raw.parse() {
Ok(x) => { arg_ip_pref = x },
Err(_) => { panic!("IP prefix length invalid!") }
}
// NIC100 / ENC424J600 Set-up // NIC100 / ENC424J600 Set-up
let spi1 = dp.SPI1; let spi1 = dp.SPI1;
let gpioa = dp.GPIOA.split(); let gpioa = dp.GPIOA.split();
@ -139,7 +164,8 @@ fn main() -> ! {
let device = smoltcp_phy::SmoltcpDevice::new(&mut spi_eth); let device = smoltcp_phy::SmoltcpDevice::new(&mut spi_eth);
let mut neighbor_cache_entries = [None; 16]; let mut neighbor_cache_entries = [None; 16];
let mut neighbor_cache = NeighborCache::new(&mut neighbor_cache_entries[..]); let mut neighbor_cache = NeighborCache::new(&mut neighbor_cache_entries[..]);
let ip_addr = IpCidr::new(IpAddress::v4(192, 168, 1, 75), 24); let ip_addr = IpCidr::new(IpAddress::v4(
arg_ip[0], arg_ip[1], arg_ip[2], arg_ip[3]), arg_ip_pref);
let mut ip_addrs = [ip_addr]; let mut ip_addrs = [ip_addr];
let mut iface = EthernetInterfaceBuilder::new(device) let mut iface = EthernetInterfaceBuilder::new(device)
.ethernet_addr(EthernetAddress(eth_mac_addr)) .ethernet_addr(EthernetAddress(eth_mac_addr))
@ -191,7 +217,6 @@ fn main() -> ! {
iprintln!(stim0, iprintln!(stim0,
"[{}] Listening to port 1234 for echoing, auto-closing in 10s", instant); "[{}] Listening to port 1234 for echoing, auto-closing in 10s", instant);
socket.listen(1234).unwrap(); socket.listen(1234).unwrap();
//socket.set_keep_alive(Some(Duration::from_millis(1000)));
socket.set_timeout(Some(Duration::from_millis(10000))); socket.set_timeout(Some(Duration::from_millis(10000)));
} }
if socket.can_recv() { if socket.can_recv() {

15080
nix/channel-rust-nightly.toml Normal file

File diff suppressed because it is too large Load Diff

703
nix/itm-cargo-lock.patch Normal file
View File

@ -0,0 +1,703 @@
diff --git a/Cargo.lock b/Cargo.lock
index d18dbe7..c19483d 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1,441 +1,450 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
[[package]]
-name = "aho-corasick"
-version = "0.6.4"
+name = "addr2line"
+version = "0.12.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "602d785912f476e480434627e8732e6766b760c045bbf897d9dfaa9f4fbd399c"
dependencies = [
- "memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "gimli",
]
[[package]]
-name = "ansi_term"
-version = "0.10.2"
+name = "adler32"
+version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "567b077b825e468cc974f0020d4082ee6e03132512f207ef1a02fd5d00d1f32d"
[[package]]
-name = "atty"
-version = "0.2.3"
+name = "aho-corasick"
+version = "0.6.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "81ce3d38065e618af2d7b77e10c5ad9a069859b4be3c2250f674af3840d9c8a5"
dependencies = [
- "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)",
- "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "memchr",
]
[[package]]
-name = "backtrace"
-version = "0.3.4"
+name = "ansi_term"
+version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
dependencies = [
- "backtrace-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
- "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "dbghelp-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-demangle 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi",
]
[[package]]
-name = "backtrace-sys"
-version = "0.1.16"
+name = "atty"
+version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
- "cc 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)",
+ "hermit-abi",
+ "libc",
+ "winapi",
]
[[package]]
-name = "bitflags"
-version = "0.7.0"
+name = "autocfg"
+version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
[[package]]
-name = "bitflags"
-version = "1.0.1"
+name = "backtrace"
+version = "0.3.49"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "05100821de9e028f12ae3d189176b41ee198341eb8f369956407fea2f5cc666c"
+dependencies = [
+ "addr2line",
+ "cfg-if",
+ "libc",
+ "miniz_oxide",
+ "object",
+ "rustc-demangle",
+]
[[package]]
-name = "cc"
-version = "1.0.3"
+name = "bitflags"
+version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
[[package]]
name = "cfg-if"
-version = "0.1.2"
+version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]]
name = "chrono"
-version = "0.4.0"
+version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "80094f509cf8b5ae86a4966a39b3ff66cd7e2a3e594accec3743ff3fabeab5b2"
dependencies = [
- "num 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
- "time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
+ "num-integer",
+ "num-traits",
+ "time",
]
[[package]]
name = "clap"
-version = "2.29.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "ansi_term 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "atty 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "dbghelp-sys"
-version = "0.2.0"
+version = "2.33.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bdfa80d47f954d53a35a64987ca1422f495b8d6483c0fe9f7117b36c2a792129"
dependencies = [
- "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "ansi_term",
+ "atty",
+ "bitflags",
+ "strsim",
+ "textwrap",
+ "unicode-width",
+ "vec_map",
]
[[package]]
name = "env_logger"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3ddf21e73e016298f5cb37d6ef8e8da8e39f91f9ec8b0df44b7deb16a9f8cd5b"
dependencies = [
- "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "log 0.3.9",
+ "regex",
]
[[package]]
name = "failure"
-version = "0.1.1"
+version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86"
dependencies = [
- "backtrace 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "backtrace",
+ "failure_derive",
]
[[package]]
name = "failure_derive"
-version = "0.1.1"
+version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4"
dependencies = [
- "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)",
- "synstructure 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "proc-macro2",
+ "quote",
+ "syn",
+ "synstructure",
]
[[package]]
-name = "fuchsia-zircon"
-version = "0.2.1"
+name = "fuchsia-cprng"
+version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "fuchsia-zircon-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
-]
+checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
[[package]]
-name = "fuchsia-zircon-sys"
-version = "0.2.0"
+name = "gimli"
+version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
-]
+checksum = "bcc8e0c9bce37868955864dbecd2b1ab2bdf967e6f28066d65aaac620444b65c"
[[package]]
-name = "itm"
-version = "0.3.0"
+name = "hermit-abi"
+version = "0.1.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b9586eedd4ce6b3c498bc3b4dd92fc9f11166aa908a914071953768066c67909"
dependencies = [
- "chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "clap 2.29.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc",
]
[[package]]
-name = "kernel32-sys"
-version = "0.2.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
+name = "itm"
+version = "0.3.1"
dependencies = [
- "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "chrono",
+ "clap",
+ "env_logger",
+ "failure",
+ "failure_derive",
+ "log 0.3.9",
+ "tempdir",
]
[[package]]
name = "lazy_static"
-version = "1.0.0"
+version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
-version = "0.2.34"
+version = "0.2.71"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9457b06509d27052635f90d6466700c65095fdf75409b3fbdd903e988b886f49"
[[package]]
name = "log"
-version = "0.3.8"
+version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b"
+dependencies = [
+ "log 0.4.8",
+]
[[package]]
-name = "memchr"
-version = "2.0.1"
+name = "log"
+version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
dependencies = [
- "libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cfg-if",
]
[[package]]
-name = "num"
-version = "0.1.41"
+name = "memchr"
+version = "2.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400"
+
+[[package]]
+name = "miniz_oxide"
+version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "791daaae1ed6889560f8c4359194f56648355540573244a5448a83ba1ecc7435"
dependencies = [
- "num-integer 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
- "num-iter 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
- "num-traits 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
+ "adler32",
]
[[package]]
name = "num-integer"
-version = "0.1.35"
+version = "0.1.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8d59457e662d541ba17869cf51cf177c0b5f0cbf476c66bdc90bf1edac4f875b"
dependencies = [
- "num-traits 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
+ "autocfg",
+ "num-traits",
]
[[package]]
-name = "num-iter"
-version = "0.1.34"
+name = "num-traits"
+version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611"
dependencies = [
- "num-integer 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
- "num-traits 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
+ "autocfg",
]
[[package]]
-name = "num-traits"
-version = "0.1.41"
+name = "object"
+version = "0.20.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5"
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "beae6331a816b1f65d04c45b078fd8e6c93e8071771f41b8163255bbd8d7c8fa"
+dependencies = [
+ "unicode-xid",
+]
[[package]]
name = "quote"
-version = "0.3.15"
+version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
+dependencies = [
+ "proc-macro2",
+]
[[package]]
name = "rand"
-version = "0.3.18"
+version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293"
dependencies = [
- "fuchsia-zircon 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)",
+ "fuchsia-cprng",
+ "libc",
+ "rand_core 0.3.1",
+ "rdrand",
+ "winapi",
]
[[package]]
-name = "redox_syscall"
-version = "0.1.32"
+name = "rand_core"
+version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
+dependencies = [
+ "rand_core 0.4.2",
+]
[[package]]
-name = "redox_termios"
-version = "0.1.1"
+name = "rand_core"
+version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
+
+[[package]]
+name = "rdrand"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
dependencies = [
- "redox_syscall 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand_core 0.3.1",
]
[[package]]
name = "regex"
-version = "0.2.3"
+version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9329abc99e39129fcceabd24cf5d85b4671ef7c29c50e972bc5afe32438ec384"
dependencies = [
- "aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "thread_local 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "aho-corasick",
+ "memchr",
+ "regex-syntax",
+ "thread_local",
+ "utf8-ranges",
]
[[package]]
name = "regex-syntax"
-version = "0.4.1"
+version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7d707a4fa2637f2dca2ef9fd02225ec7661fe01a53623c1e6515b6916511f7a7"
+dependencies = [
+ "ucd-util",
+]
[[package]]
-name = "rustc-demangle"
-version = "0.1.5"
+name = "remove_dir_all"
+version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
+dependencies = [
+ "winapi",
+]
[[package]]
-name = "strsim"
-version = "0.6.0"
+name = "rustc-demangle"
+version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783"
[[package]]
-name = "syn"
-version = "0.11.11"
+name = "strsim"
+version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
- "synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
-]
+checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
[[package]]
-name = "synom"
-version = "0.11.3"
+name = "syn"
+version = "1.0.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e8d5d96e8cbb005d6959f119f773bfaebb5684296108fb32600c00cde305b2cd"
dependencies = [
- "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "proc-macro2",
+ "quote",
+ "unicode-xid",
]
[[package]]
name = "synstructure"
-version = "0.6.1"
+version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701"
dependencies = [
- "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)",
+ "proc-macro2",
+ "quote",
+ "syn",
+ "unicode-xid",
]
[[package]]
name = "tempdir"
-version = "0.3.5"
+version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8"
dependencies = [
- "rand 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "termion"
-version = "1.5.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)",
- "redox_syscall 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
- "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand",
+ "remove_dir_all",
]
[[package]]
name = "textwrap"
-version = "0.9.0"
+version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
dependencies = [
- "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "unicode-width",
]
[[package]]
name = "thread_local"
-version = "0.3.5"
+version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"
dependencies = [
- "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lazy_static",
]
[[package]]
name = "time"
-version = "0.1.38"
+version = "0.1.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438"
dependencies = [
- "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)",
- "redox_syscall 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc",
+ "winapi",
]
[[package]]
-name = "unicode-width"
-version = "0.1.4"
+name = "ucd-util"
+version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c85f514e095d348c279b1e5cd76795082cf15bd59b93207832abe0b1d8fed236"
[[package]]
-name = "unicode-xid"
-version = "0.0.4"
+name = "unicode-width"
+version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479"
[[package]]
-name = "unreachable"
-version = "1.0.0"
+name = "unicode-xid"
+version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
-]
+checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
[[package]]
name = "utf8-ranges"
-version = "1.0.0"
+version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b4ae116fef2b7fea257ed6440d3cfcff7f190865f170cdad00bb6465bf18ecba"
[[package]]
name = "vec_map"
-version = "0.8.0"
+version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
[[package]]
-name = "void"
-version = "1.0.2"
+name = "winapi"
+version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6"
+dependencies = [
+ "winapi-i686-pc-windows-gnu",
+ "winapi-x86_64-pc-windows-gnu",
+]
[[package]]
-name = "winapi"
-version = "0.2.8"
+name = "winapi-i686-pc-windows-gnu"
+version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
-name = "winapi-build"
-version = "0.1.1"
+name = "winapi-x86_64-pc-windows-gnu"
+version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[metadata]
-"checksum aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d6531d44de723825aa81398a6415283229725a00fa30713812ab9323faa82fc4"
-"checksum ansi_term 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6b3568b48b7cefa6b8ce125f9bb4989e52fbcc29ebea88df04cc7c5f12f70455"
-"checksum atty 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "21e50800ec991574876040fff8ee46b136a53e985286fbe6a3bdfe6421b78860"
-"checksum backtrace 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8709cc7ec06f6f0ae6c2c7e12f6ed41540781f72b488d83734978295ceae182e"
-"checksum backtrace-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "44585761d6161b0f57afc49482ab6bd067e4edef48c12a152c237eb0203f7661"
-"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d"
-"checksum bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b3c30d3802dfb7281680d6285f2ccdaa8c2d8fee41f93805dba5c4cf50dc23cf"
-"checksum cc 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a9b13a57efd6b30ecd6598ebdb302cca617930b5470647570468a65d12ef9719"
-"checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de"
-"checksum chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7c20ebe0b2b08b0aeddba49c609fe7957ba2e33449882cb186a180bc60682fa9"
-"checksum clap 2.29.0 (registry+https://github.com/rust-lang/crates.io-index)" = "110d43e343eb29f4f51c1db31beb879d546db27998577e5715270a54bcf41d3f"
-"checksum dbghelp-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "97590ba53bcb8ac28279161ca943a924d1fd4a8fb3fa63302591647c4fc5b850"
-"checksum env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3ddf21e73e016298f5cb37d6ef8e8da8e39f91f9ec8b0df44b7deb16a9f8cd5b"
-"checksum failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "934799b6c1de475a012a02dab0ace1ace43789ee4b99bcfbf1a2e3e8ced5de82"
-"checksum failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c7cdda555bb90c9bb67a3b670a0f42de8e73f5981524123ad8578aafec8ddb8b"
-"checksum fuchsia-zircon 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f6c0581a4e363262e52b87f59ee2afe3415361c6ec35e665924eb08afe8ff159"
-"checksum fuchsia-zircon-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "43f3795b4bae048dc6123a6b972cadde2e676f9ded08aef6bb77f5f157684a82"
-"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
-"checksum lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c8f31047daa365f19be14b47c29df4f7c3b581832407daabe6ae77397619237d"
-"checksum libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)" = "36fbc8a8929c632868295d0178dd8f63fc423fd7537ad0738372bd010b3ac9b0"
-"checksum log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "880f77541efa6e5cc74e76910c9884d9859683118839d6a1dc3b11e63512565b"
-"checksum memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "796fba70e76612589ed2ce7f45282f5af869e0fdd7cc6199fa1aa1f1d591ba9d"
-"checksum num 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "cc4083e14b542ea3eb9b5f33ff48bd373a92d78687e74f4cc0a30caeb754f0ca"
-"checksum num-integer 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)" = "d1452e8b06e448a07f0e6ebb0bb1d92b8890eea63288c0b627331d53514d0fba"
-"checksum num-iter 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)" = "7485fcc84f85b4ecd0ea527b14189281cf27d60e583ae65ebc9c088b13dffe01"
-"checksum num-traits 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "cacfcab5eb48250ee7d0c7896b51a2c5eec99c1feea5f32025635f5ae4b00070"
-"checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a"
-"checksum rand 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)" = "6475140dfd8655aeb72e1fd4b7a1cc1c202be65d71669476e392fe62532b9edd"
-"checksum redox_syscall 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "ab105df655884ede59d45b7070c8a65002d921461ee813a024558ca16030eea0"
-"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76"
-"checksum regex 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ac6ab4e9218ade5b423358bbd2567d1617418403c7a512603630181813316322"
-"checksum regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad890a5eef7953f55427c50575c680c42841653abd2b028b68cd223d157f62db"
-"checksum rustc-demangle 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "aee45432acc62f7b9a108cc054142dac51f979e69e71ddce7d6fc7adf29e817e"
-"checksum strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d15c810519a91cf877e7e36e63fe068815c678181439f2f29e2562147c3694"
-"checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad"
-"checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6"
-"checksum synstructure 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a761d12e6d8dcb4dcf952a7a89b475e3a9d69e4a69307e01a470977642914bd"
-"checksum tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "87974a6f5c1dfb344d733055601650059a3363de2a6104819293baff662132d6"
-"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096"
-"checksum textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c0b59b6b4b44d867f1370ef1bd91bfb262bf07bf0ae65c202ea2fbc16153b693"
-"checksum thread_local 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "279ef31c19ededf577bfd12dfae728040a21f635b06a24cd670ff510edd38963"
-"checksum time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)" = "d5d788d3aa77bc0ef3e9621256885555368b47bd495c13dd2e7413c89f845520"
-"checksum unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3a113775714a22dcb774d8ea3655c53a32debae63a063acc00a91cc586245f"
-"checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc"
-"checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56"
-"checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122"
-"checksum vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "887b5b631c2ad01628bbbaa7dd4c869f80d3186688f8d0b6f58774fbe324988c"
-"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
-"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
-"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
+checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
diff --git a/src/bin/itmdump.rs b/src/bin/itmdump.rs
index 455623a..a002c83 100644
--- a/src/bin/itmdump.rs
+++ b/src/bin/itmdump.rs
@@ -128,13 +128,13 @@ fn run() -> Result<(), failure::Error> {
// Unreachable.
}
-fn open_read(matches: &ArgMatches) -> Result<Box<io::Read + 'static>, io::Error> {
+fn open_read(matches: &ArgMatches) -> Result<Box<dyn io::Read + 'static>, io::Error> {
let path = matches.value_of("file");
Ok(match path {
Some(path) => {
let f = File::open(path)?;
- Box::new(f) as Box<io::Read + 'static>
+ Box::new(f) as Box<dyn io::Read + 'static>
}
- None => Box::new(io::stdin()) as Box<io::Read + 'static>,
+ None => Box::new(io::stdin()) as Box<dyn io::Read + 'static>,
})
}

21
nix/itm.nix Normal file
View File

@ -0,0 +1,21 @@
{ stdenv, fetchFromGitHub, rustPlatform, pkgconfig }:
rustPlatform.buildRustPackage rec {
version = "0.3.1";
pname = "itm";
src = fetchFromGitHub {
owner = "rust-embedded";
repo = "itm";
rev = "v${version}";
sha256 = "15pa0ydm19vz8p3wairpx3vqzc55rp4lgki143ybgw44sgf8hraj";
};
cargoPatches = [ ./itm-cargo-lock.patch ];
cargoSha256 = "0xzpyafmkp2wvw2332kb1sm2m3lgg6qy6fskcq431d713ilvrkmg";
nativeBuildInputs = [ pkgconfig ];
doCheck = false;
}

24
nix/rustPlatform.nix Normal file
View File

@ -0,0 +1,24 @@
{ recurseIntoAttrs, stdenv, lib,
makeRustPlatform, defaultCrateOverrides,
fetchurl, patchelf,
rustManifest ? ./channel-rust-nightly.toml
}:
let
targets = [
"thumbv7em-none-eabihf" # For ARM Cortex-M4 or M7 w/ FPU support
];
rustChannel =
lib.rustLib.fromManifestFile rustManifest {
inherit stdenv fetchurl patchelf;
};
rust =
rustChannel.rust.override {
inherit targets;
};
in
makeRustPlatform {
rustc = rust;
cargo = rust;
}

View File

@ -3,6 +3,7 @@ target remote :3333
# print demangled symbols by default # print demangled symbols by default
set print asm-demangle on set print asm-demangle on
!rm itm.log
monitor tpiu config internal itm.log uart off 168000000 monitor tpiu config internal itm.log uart off 168000000
monitor itm port 0 on monitor itm port 0 on

77
shell.nix Normal file
View File

@ -0,0 +1,77 @@
{ rustChannel ? "nightly" }:
let
mozillaOverlay = import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz);
pkgs = import <nixpkgs> { overlays = [ mozillaOverlay ]; };
in
with pkgs;
let
rustPlatform = callPackage ./nix/rustPlatform.nix {};
# Note: This itm binary is built with a modified version its v0.3.1 source code,
# so as to meet the requirements of newer Rust compiler.
itm = callPackage ./nix/itm.nix { inherit rustPlatform; };
runHelp = writeShellScriptBin "run-help" ''
echo "[Common Tools]"
echo " run-openocd-f4x"
echo " - Run OpenOCD in background for STM32F4XX boards."
echo " run-itmdump-follow"
echo " - Run itmdump in following mode."
echo " run-help"
echo " - Display this help message."
echo ""
echo "[Examples]"
echo " tx_stm32f407"
echo " - Run tx_stm32f407 example."
echo " tcp_stm32f407 <ip> <pref>"
echo " - Run tcp_stm32f407 example with the IPv4"
echo " address <ip> \(dot-separated\) and prefix length <pref>."
echo ""
'';
runOpenOcdF4x = writeShellScriptBin "run-openocd-f4x" ''
openocd \
-f ${openocd}/share/openocd/scripts/interface/stlink-v2.cfg \
-f ${openocd}/share/openocd/scripts/target/stm32f4x.cfg \
-c init &
sleep 1
'';
runItmDumpFollow = writeShellScriptBin "run-itmdump-follow" ''
itmdump -f itm.log -F
'';
# Examples
exTxStm32f407 = writeShellScriptBin "tx_stm32f407" ''
cargo run --release --example=tx_stm32f407 --features=stm32f407
'';
exTcpStm32f407 = writeShellScriptBin "tcp_stm32f407" ''
if [[ $1 = "" ]] || [[ $2 = "" ]]
then
echo "Arguments <ip> or <pref> are missing."
exit
fi
touch ./examples/tcp_stm32f407.rs
export ENC424J600_TCP_IP=$1
export ENC424J600_TCP_PREF=$2
cargo run --release --example=tcp_stm32f407 --features=stm32f407,smoltcp-phy-all
'';
in
stdenv.mkDerivation {
name = "enc424j600-stm32-env";
buildInputs = with rustPlatform.rust; [
rustc cargo pkgs.gdb pkgs.openocd itm
runHelp runOpenOcdF4x runItmDumpFollow
exTxStm32f407 exTcpStm32f407
];
# Set Environment Variables
RUST_BACKTRACE = 1;
shellHook = ''
echo "Welcome to the nix-shell for running STM32 examples!"
echo ""
run-help
'';
}