commaai / flash

https://flash.comma.ai
5 stars 19 forks source link

Transfer to QDL #33

Closed bongbui321 closed 6 months ago

bongbui321 commented 9 months ago

+++ Covered all the needed commands. Now test and integrate+++ https://bongbui321.github.io/flash/

TESTS

bongbui321 commented 8 months ago

I will be updating in this repo (https://github.com/bongbui321/op_qdl_eons) which is mainly used for testing of QDL.js library and eons flashing only without interfering with this repo. I will transfer working changes to this repo once I finish with everything.

bongbui321 commented 7 months ago

@adeebshihadeh Ready for review:

some notes:

  1. remaining TODOs are from before the PR
  2. Always throw Error when device disconnect. But if you unplug during download and unpack it would not throw, will throw when trying to flash (send or read data from device). I can make it throw right away but that would just add unnecessary complexity considering the nature the users should never unplug during flashing process, and when move to the flashing step, if the device is disconnected during or prior, the website will always indicate failure.
bongbui321 commented 7 months ago

You recently mentioned I'd have to flash with fastboot to recover an interrupted flash before using this again. Has that been fixed?

This only matters if it fails during setting other slot to active, and it would only mess up the meta data type within the header of the partitions. This is because when you change slot you swap the type of type a partition to its corresponding type b partition. Ex: call setactiveslot(): abl_a.type, abl_b.type = abl_b.type, abl_a.type. the device would still boot but the metadata type would be corrupted. The solution is to recognize that the header is corrupted, and fix it by patching the primary gpt header with the data in the secondary gpt header.

The original edl repo doesn't really have this feature to be done automatically, so will need to implement this ourselves

sorry not sure if I explain it clearly, happy to clarify if you have questions

Why does "Changing slot to b" take like 30s?

I have never experienced this, it usually takes 2-3s for me.

bongbui321 commented 7 months ago

This will always catch and be able to recover even if it crashes during the middle of flashing or setactiveslot.

bongbui321 commented 7 months ago

You recently mentioned I'd have to flash with fastboot to recover an interrupted flash before using this again. Has that been fixed?

Hmm, I was wrong, fastboot doesn't even fix this (tested), if the device disconnects at the middle of changing slot, most likely the guid type of the partitions will be incorrect (it is just metadata, and the device look at the attribute field of the partition to determine active slots). Though this would not affect the ability to boot up, I still prefer to preserve the correctness of the guid type metadata of the partitions

My fix is currently better since it uses backup gpt to recover that metadata if the device disconnects

bongbui321 commented 6 months ago

Can use this whenever you test. https://github.com/bongbui321/test_flash_op

adeebshihadeh commented 6 months ago

Nice work! Merged into a staging qdl branch for now.