raspy135 / Qun-mk2

Manual and presets for Qun mk2 synthesizer
69 stars 3 forks source link

Padding added to firmware uploaded with web interface, breaks update process #26

Closed nrichards closed 6 months ago

nrichards commented 6 months ago

Various numbers of bytes of padding is added to firmware files (qunmk2.bin) on SD card when uploaded through the web interface, unpredictably.

Browser header identification data is appended during the Chrome web interface file upload process, per the "WebKit" string in the second experiment, below.

Noticed this behavior first when updating to 5.00.

Impact

I am unable to reliably flash firmware through the web interface. Device refuses to install padded firmware files.

Workaround

Details

  1. Downloaded 5.02 firmware from https://github.com/raspy135/Qun-mk2/blob/063d7bf4b44e84ea3bdb053debb7a5c92c01e55d/firmware/qunmk2.bin
  2. Uploaded to Qun (5.01, modded) through web interface
    1. Used Firefox web browser 124.0.2 on macOS Sonoma 14.2.1 with uBlock Origin ad-blocking extension.
    2. Second experiment (data below) used Chrome browser.
  3. Attempted to update firmware three times using normal base-board REC + RST button sequence, and failed in two ways:
    1. proceeded through firmware update wizard, and showed firmware update success on screen, and upon reboot showed incorrect (5.01) version.
    2. could not trigger firmware update wizard using base-board button sequence

Copied firmware from Qun SD card and examined

NOTE: qunmk2\(8\).bin is my freshly downloaded file, direct from the internet. qunmk2_from_QUNMK2.bin is copied from the SD card.

(From Firefox)

nick@Nicholass-MacBook-Pro Downloads % ll qunmk2\(8\).bin
-rw-r--r--@ 1 nick  staff  935840 Apr  6 10:25 qunmk2(8).bin
nick@Nicholass-MacBook-Pro Downloads % ll qunmk2_from_QUNMK2.bin
-rwx------@ 1 nick  staff  935904 Apr  6 10:30 qunmk2_from_QUNMK2.bin*

Calculate filesize differences

Compared contents of firmware files

Files are the same, until the end of the SD card. Left file is ORIGINAL. Middle (second .. Chrome), and right-hand (first .. Firefox) side shows padding added to end of uploaded firmware file, undesirably. Notice "WebKit" string in the Chrome web browser uploaded file.

image

Questions

raspy135 commented 6 months ago

Padding might be related how the code finds the header, but padding at the end should be fine, qunmk2.bin is just an expanded bin file. How much is the likelihood of the issue? Issue (i) can happen only when firmware was not written, this case you should not see "Firmware uploaded" message on Qun's screen. Issue (ii) is almost impossible, firmware updater is located different address of flash, if it's broken, it;s bricked.

nrichards commented 6 months ago

I believe the issue should be closed. I just need to press harder.

More:

I believe it is my hardware: the actual REC button (needed to trigger firmware update during reboot) might need to be pressed harder than I have previously pressed. The issue started when I received a new, modded board, recently. I am used to pressing gently. I am able to reliably flash, now, when I press hard.

Padding might be related how the code finds the header, but padding at the end should be fine, qunmk2.bin is just an expanded bin file.

Yes. I just successfully updated firmware (to 5.04 from 5.02). I confirmed the BIN file has padding at the end of the file. Since it was successful, I agree the padding is not a problem.

Thank you for thinking this through with me.