From b4ba69bad2577ed84f3edf628c4062297430e820 Mon Sep 17 00:00:00 2001 From: bunnie Date: Mon, 8 Sep 2025 10:32:28 +0800 Subject: [PATCH] ux improvements on update actually use only the two buttons listed for initiating updates --- loader/src/platform/cramium/update.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/loader/src/platform/cramium/update.rs b/loader/src/platform/cramium/update.rs index 27fc3a1c3..9a25bd859 100644 --- a/loader/src/platform/cramium/update.rs +++ b/loader/src/platform/cramium/update.rs @@ -28,7 +28,8 @@ const TEXT_MIDLINE: isize = 51; // Empirically measured PORTSC when the port is unplugged. This might be a brittle way // to detect if the device is unplugged. -const DISCONNECT_STATE: u32 = 0x40b; +const DISCONNECT_STATE: u32 = 0x40b; // 01_0_0000_0_1_01_1 +const DISCONNECT_STATE_HS: u32 = 0xc6b; // 11_0_0011_0_1_01_1 // loader is not updateable here because we're XIP. But we can update these other images: const SWAP_NAME: &'static str = "SWAP.IMG"; @@ -127,9 +128,11 @@ pub fn process_update(perclk: u32) { for kp in kps { if kp != KeyPress::None { crate::println!("Got key: {:?}", kp); - key_pressed = true; } - if kp == KeyPress::Down { + if kp == KeyPress::Up { + key_pressed = true; + } else if kp == KeyPress::Down { + key_pressed = true; do_update = true; } } @@ -193,9 +196,11 @@ pub fn process_update(perclk: u32) { let new_portsc = usb.portsc_val(); // alternately, break out of the loop when USB is disconnected if new_portsc != portsc { - crate::println!("PP: {:x}", portsc); portsc = new_portsc; - if portsc == DISCONNECT_STATE && new_usb_state == UsbDeviceState::Configured { + crate::println!("PP: {:x}", portsc); + if (portsc == DISCONNECT_STATE || portsc == DISCONNECT_STATE_HS) + && new_usb_state == UsbDeviceState::Configured + { break; } } @@ -289,7 +294,7 @@ pub fn process_update(perclk: u32) { return; } crate::println!("Kernel image is good!"); - + sh1107.clear(); let mut rram = cramium_hal::rram::Reram::new(); // concatenate this with e.g. .min(0x2000) to shorten the run, if needed @@ -315,7 +320,6 @@ pub fn process_update(perclk: u32) { .enumerate() { rram.write_slice(KERNEL_BASE_ADDR + i * BLOCKLEN_BYTES, &byte_chunk); - crate::println!("{:x}: {:x?}", i * BLOCKLEN_BYTES, &byte_chunk[..4]); progress_bar(&mut sh1107, i * BLOCKLEN_BYTES * 100 / total_len); } progress_bar(&mut sh1107, 100);