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

Implement picotool reboot #128

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ usb-device = "0.2.9"
heapless = "0.7.16"
usbd-serial = "0.1.1"
usbd-hid = "0.6.1"
# Can't use right now, depends on embedded-hal 1.0.0
# usbd-picotool-reset = "0.3.0"
usbd-picotool-reset = { git = "https://github.com/JohnAZoidberg/usbd-picotool-reset", branch = "rp-2040-hal-0.8" }
fugit = "0.3.7"
# LED Matrix
is31fl3741 = "0.3.0"
Expand Down
1 change: 1 addition & 0 deletions fwupd/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.cab
3 changes: 3 additions & 0 deletions fwupd/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
qtpy.cab: firmware.metainfo.xml
cp ../target/thumbv6m-none-eabi/release/qtpy.uf2 .
gcab -c -v $@ qtpy.uf2 firmware.metainfo.xml
43 changes: 43 additions & 0 deletions fwupd/firmware.metainfo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="firmware">
<id>work.frame.inputmodule.qtpy</id>
<name>Framework QT Py</name>
<summary>Firmware for the Framework QT Py</summary>
<description>
<p>
Updating the firmware on your Framework QT Py improves performance and
adds new features.
</p>
</description>
<provides>
<!-- 32ac:0012 -->
<firmware type="flashed">5a5b58d0-9cb4-5f8b-a449-e7b7c820b0cb</firmware>
</provides>
<url type="homepage">https://github.com/FrameworkComputer/inputmodule-rs</url>
<metadata_license>CC0-1.0</metadata_license>
<project_license>proprietary</project_license>
<categories>
<category>X-Device</category>
</categories>
<releases>
<release urgency="normal" version="0.20" date="2024-11-17" install_duration="40">
<checksum filename="qtpy.uf2" target="content"/>
<description>
New firmware!
</description>
</release>
</releases>
<requires>{{ min_ver }}
<id compare="ge" version="1.9.2">org.freedesktop.fwupd</id>
</requires>
<custom>
<!--<value key="LVFS::VersionFormat">{{ version_format }}</value>-->
<value key="LVFS::UpdateProtocol">com.microsoft.uf2</value>
</custom>
<!--
<keywords>
<keyword>{{ keyword }}</keyword>
<keyword>{{ id }}</keyword>
</keywords>
-->
</component>
1 change: 1 addition & 0 deletions qtpy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ usb-device.workspace = true
heapless.workspace = true
usbd-serial.workspace = true
usbd-hid.workspace = true
usbd-picotool-reset.workspace = true
fugit.workspace = true

# C1 Minimal
Expand Down
13 changes: 11 additions & 2 deletions qtpy/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ use bsp::hal::{
};

// USB Device support
use usb_device::{class_prelude::*, prelude::*};
use usb_device::{class_prelude::*, prelude::*, descriptor::lang_id};

// USB Communications Class Device support
use usbd_serial::{SerialPort, USB_CLASS_CDC};

use usbd_picotool_reset::PicoToolReset;

// Used to demonstrate writing formatted strings
// use core::fmt::Write;
// use heapless::String;
Expand Down Expand Up @@ -95,10 +97,16 @@ fn main() -> ! {
&mut pac.RESETS,
));

let mut picotool: PicoToolReset<_> = PicoToolReset::new(&usb_bus);

// Set up the USB Communications Class Device driver
let mut serial = SerialPort::new(&usb_bus);

let mut usb_dev = UsbDeviceBuilder::new(&usb_bus, UsbVidPid(FRAMEWORK_VID, COMMUNITY_PID))
//.strings(&[StringDescriptors::new(lang_id::ENGLISH_US)
// .manufacturer("Adafruit")
// .product("QT PY - Framework 16 Inputmodule FW")])
//.expect("Failed to set strings")
.manufacturer("Adafruit")
.product("QT PY - Framework 16 Inputmodule FW")
.max_power(500)
Expand Down Expand Up @@ -141,7 +149,8 @@ fn main() -> ! {
}

// Check for new data
if usb_dev.poll(&mut [&mut serial]) {
// usb_dev.poll(&mut [&mut picotool, &mut serial]);
if usb_dev.poll(&mut [&mut picotool, &mut serial]) {
let mut buf = [0u8; 64];
match serial.read(&mut buf) {
Err(_e) => {
Expand Down
2 changes: 2 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[toolchain]
# Needed for embeded-hal 1.0.0
# channel = "1.75.0"
channel = "1.74.0"
targets = ["thumbv6m-none-eabi"]
components = ["clippy", "rustfmt"]
Loading