AnnePro2-Tools icon indicating copy to clipboard operation
AnnePro2-Tools copied to clipboard

AnnePro2 C18 ISO: AnnePro2-Tools hangs in write_ap_flag

Open Johns-Q opened this issue 1 year ago • 0 comments

I have a AnnePro 2 Version C18 ISO layout keyboard.

When i flash with my for ISO patched AnnePro-Tools, it flashs the keyboard, but hangs.

After a little search in the discord channel, it found it is in the function 'write_ap_flag'.

I tried this fix:

@@ -111,8 +119,21 @@ pub fn flash_firmware<R: std::io::Read>(
 }
 
 pub fn write_ap_flag(handle: &HidDevice, flag: u8) -> HidResult<()> {
-    let buffer: Vec<u8> = vec![L2Command::FW as u8, KeyCommand::IapWriteApFlag as u8, flag];
-    write_to_target(handle, AP2Target::McuMain, &buffer)?;
+    //let buffer: Vec<u8> = vec![L2Command::FW as u8, KeyCommand::IapWriteApFlag as u8, flag];
+    //write_to_target(handle, AP2Target::McuMain, &buffer)?;
+    let buffer: Vec<u8> = vec![
+        //                            len                     target,what,flag
+        0x00, 0x7b, 0x10, 0x31, 0x10, 0x03, 0x00, 0x00, 0x7d, 0x02, 0x50, 0x02,
+    ];
+
+    // directly use write because we shouldn't pad this command to 64 bytes
+    let lol = handle.write(&buffer);
+
+    if lol.is_err() {
+        let err = handle.check_error();
+        println!("err: {:?}", err);
+    }
+
     Ok(())
 }

I copied it from 'boot_device', I don't know if this is correct, but now it flashes without hangup.

Johns

Johns-Q avatar Aug 12 '22 14:08 Johns-Q