Compare commits
No commits in common. "4cf8f67bf9866710942df363ab3b2b526233c70e" and "2d0a54eccc9379f557718548b55a8eb9731c9d52" have entirely different histories.
4cf8f67bf9
...
2d0a54eccc
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,2 @@
|
|||
/target
|
||||
/*/output.log
|
||||
*.bin
|
73
Cargo.lock
generated
73
Cargo.lock
generated
|
@ -320,42 +320,6 @@ dependencies = [
|
|||
"powerfmt",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dfu-core"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c3fb34e94bedc8bbd76dfc9f6774896fadbbedac6108fa8a3c46a0125bde188"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"displaydoc",
|
||||
"log",
|
||||
"pretty-hex",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dfu-libusb"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4e20ae81db46fd54fede9e71d06c06a382926212831cfd2f758b888e00a321d1"
|
||||
dependencies = [
|
||||
"dfu-core",
|
||||
"libusb1-sys",
|
||||
"rusb",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "displaydoc"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.72",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "document-features"
|
||||
version = "0.2.10"
|
||||
|
@ -777,18 +741,6 @@ dependencies = [
|
|||
"pkg-config",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libusb1-sys"
|
||||
version = "0.6.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "17f6bace2f39082e9787c851afce469e7b2fe0f1cc64bbc68ca96653b63d8f17"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
"pkg-config",
|
||||
"vcpkg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "litrs"
|
||||
version = "0.4.1"
|
||||
|
@ -1113,12 +1065,6 @@ version = "0.2.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
|
||||
|
||||
[[package]]
|
||||
name = "pretty-hex"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c6fa0831dd7cc608c38a5e323422a0077678fa5744aa2be4ad91c4ece8eec8d5"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-error"
|
||||
version = "1.0.4"
|
||||
|
@ -1211,15 +1157,12 @@ version = "0.1.0"
|
|||
dependencies = [
|
||||
"anyhow",
|
||||
"axum",
|
||||
"dfu-libusb",
|
||||
"fern",
|
||||
"humantime",
|
||||
"libusb1-sys",
|
||||
"log",
|
||||
"nom",
|
||||
"postcard",
|
||||
"radomctl-protocol",
|
||||
"rusb",
|
||||
"serde_json",
|
||||
"serialport",
|
||||
"tokio",
|
||||
|
@ -1313,16 +1256,6 @@ dependencies = [
|
|||
"rtic-common",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rusb"
|
||||
version = "0.9.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "45fff149b6033f25e825cbb7b2c625a11ee8e6dac09264d49beb125e39aa97bf"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"libusb1-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-demangle"
|
||||
version = "0.1.24"
|
||||
|
@ -1888,12 +1821,6 @@ version = "0.1.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77439c1b53d2303b20d9459b1ade71a83c716e3f9c34f3228c00e6f185d6c002"
|
||||
|
||||
[[package]]
|
||||
name = "vcpkg"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.5"
|
||||
|
|
|
@ -19,6 +19,3 @@ tracing = "0.1.40"
|
|||
tracing-subscriber = "0.3.18"
|
||||
radomctl-protocol = { path = "../protocol" }
|
||||
postcard = {version = "1.0.10", features = ["use-std"]}
|
||||
dfu-libusb = "0.3.0"
|
||||
libusb1-sys = "0.6"
|
||||
rusb = "0.9"
|
||||
|
|
|
@ -1,16 +1,10 @@
|
|||
use std::{
|
||||
io::{self, Seek},
|
||||
thread,
|
||||
time::{self, Duration},
|
||||
};
|
||||
use std::time::Duration;
|
||||
|
||||
use anyhow::Context;
|
||||
use dfu_libusb::{Dfu, DfuLibusb};
|
||||
use postcard::{from_bytes_cobs, to_stdvec_cobs};
|
||||
use radomctl_protocol::*;
|
||||
use radomctld::logger::setup_logger;
|
||||
|
||||
pub fn main() -> anyhow::Result<()> {
|
||||
pub fn main() -> () {
|
||||
let mut port = serialport::new("/dev/ttyACM0", 115_200)
|
||||
.timeout(Duration::from_millis(10))
|
||||
.open()
|
||||
|
@ -19,28 +13,4 @@ pub fn main() -> anyhow::Result<()> {
|
|||
let host_msg = HostMessage::TriggerDFUBootloader;
|
||||
let msg_bytes = to_stdvec_cobs(&host_msg).unwrap();
|
||||
port.write_all(&msg_bytes).unwrap();
|
||||
drop(port);
|
||||
|
||||
let context = rusb::Context::new()?;
|
||||
let mut file = std::fs::File::open("../../firmware/radomctl-firmware.bin")
|
||||
.context("firmware file not found")?;
|
||||
|
||||
thread::sleep(time::Duration::from_millis(1000));
|
||||
|
||||
let file_size =
|
||||
u32::try_from(file.seek(io::SeekFrom::End(0))?).context("the firmware file is too big")?;
|
||||
file.seek(io::SeekFrom::Start(0))?;
|
||||
|
||||
let vid = 0x0483;
|
||||
let pid = 0xdf11;
|
||||
let intf = 0;
|
||||
let alt = 0;
|
||||
let mut device: Dfu<rusb::Context> =
|
||||
DfuLibusb::open(&context, vid, pid, intf, alt).context("could not open device")?;
|
||||
|
||||
device
|
||||
.download(file, file_size)
|
||||
.context("could not write firmware to the device")?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
cargo build --release && \
|
||||
arm-none-eabi-objcopy -O binary ../target/thumbv7em-none-eabihf/release/radomctl-firmware radomctl-firmware.bin && \
|
||||
dfu-util --alt 0 -s 0x08000000:leave -D radomctl-firmware.bin
|
|
@ -133,22 +133,11 @@ mod app {
|
|||
|
||||
let usb_serial = usbd_serial::SerialPort::new(unsafe { USB_BUS.as_ref().unwrap() });
|
||||
|
||||
let serial = unsafe {
|
||||
let u_id0 = 0x1FFF_7A10 as *const u32;
|
||||
let u_id2 = 0x1FFF_7A18 as *const u32;
|
||||
|
||||
defmt::debug!("UID0: {:x}", u_id0.read());
|
||||
defmt::debug!("UID2: {:x}", u_id2.read());
|
||||
|
||||
// See https://community.st.com/t5/stm32-mcus-products/usb-bootloader-serial-number/td-p/432148
|
||||
(u_id0.read() as u64 + u_id2.read() as u64) << 16
|
||||
| (u_id2.read() as u64 & 0xFF00) >> 8
|
||||
| (u_id2.read() as u64 & 0x00FF) << 8
|
||||
};
|
||||
let uid = signature::Uid::get();
|
||||
|
||||
static mut SERIAL: String<16> = String::new();
|
||||
unsafe {
|
||||
write!(SERIAL, "{:X}", serial).unwrap();
|
||||
write!(SERIAL, "{}{:x}{:x}", uid.lot_num(), uid.x(), uid.y()).unwrap();
|
||||
}
|
||||
|
||||
let usb_dev = unsafe {
|
||||
|
|
Loading…
Reference in a new issue