Ralim / IronOS-dfu

Minimal USB-DFU for Miniware products with OLED driver support
GNU General Public License v3.0
35 stars 8 forks source link

Support of Sequre S99 #28

Closed jonasius closed 4 months ago

jonasius commented 4 months ago

Hi there, I just got a Sequre S99, which seems to be very similar to the S60P in terms of hardware. As @Ralim mentioned in a discussion here, we need to find out the starting address for the bootloader. I have a firmware upgrade file which I can analyze.

Ralim commented 4 months ago

Hello 👋🏼 Thanks for moving over here; just helps keep things more organised and easier to find later.

Is the update file a .hex file?

If so, if you open it in a text editor the first few lines gives the offset.

For example image

The first line sets the start of the address to 0x0800 (last 4 digits ignoring the very last 2 which are a checksum) Then the next line gives the lower half of the address as the 3rd-6th digits (0x4000 in this example).

We then merge those to know the runtime code runs at 0x08004000 in this example. If you dump the first few lines here I can open a PR to get a draft build for that address for you to test with?

jonasius commented 4 months ago

Hey, perfect. Yes, .hex File.

Thanks for the explanation. Good to know in general! If i got it right the offset should be 0x08004C00. VSCode Plugin helps for better visual overview ;-)

:020000040800F2
:104C000050160020014D000895B10008C99A00080F
:104C100091B100083959000805C9000800000000DA

I can open a PR to get a draft build for that address for you to test with?

Would love to test it. Then I flash the runtime.hex from the draft build and backup the bootloader with the dfu-util?!

Ralim commented 4 months ago

Alrighty,

Very first test version is building here (Actions tab)

So if you grab the file "S99" at the bottom of that page, inside you will have runtime and bootloader files.

Noting that we dont know if buttons are wired up the same, or if OLED is wired up the same. So if no display or buttons dont work, lmk and dont go further. Also please read all the steps and notes before going beyond.

Order of steps to do:

  1. Flash the update you have first, to check the update works && flashing works
  2. Flash the runtime.hex file
  3. Power up iron normally (not holding buttons) connected to a pc
  4. Should show to a screen showing IronOS-DFU
  5. On your PC you should be able to use sudo dfu-util -d 28e9:0189 -U backup.bin -s 0x08000000:0x4C00 to dump the bootloader
  6. This should make the file backup.bin
  7. Use a hexeditor (https://hexed.it/ is online and good) to look at the file.
  8. Compare to below image, it should have a similar "pattern" at the start of the file if its valid (This is the vector table)
  9. Done with runtime, have a backup bootloader (so fairly safe for future troubles)
  10. If you can MD5 the file + document the version if it has one, would be neat (i'll add it to the table)

Start of file appearance image


Now that you have the bootloader backed up; you can try flashing the bootloader file (to replace theirs) if you want to. You do NOT need to for IronOS. This is mostly provided for people who find dfu easier than the virtual flash drive. Please note, historically Sequre has set the lock bits for the start of flash. This means when you try to flash this, it will instead trigger a full flash erase (wiping all bootloaders). So you will likely need to use a SWD programmer to then flash either their bootloader or this one back onto it (with the bits now cleared, so should be safe for future).

I will repeat, please read that paragraph again before flashing the bootloader.dfu file 🙇🏼 . I hold no warranty over this, of course I will do everything I can to help if anything goes wrong, but please understand the risk first 😁 It can be hard to solder SWD wires if this is your only soldering iron 😉 .

IF you do flash the bootloader file, plug it in while holding the bootloader button;either it will boot and you get a blank screen and nothing on USB. Then likely you hit ^. If you get no screen but USB then the OLED I2C or reset pins might be pinned out differently. Best solution here is multimeter to buzz them out. If you get a screen fantastic. Depending on what screen you get we will know if the button is mapped correctly or not 🤣

jonasius commented 4 months ago

Thanks for your detailed instructions!

I was able to flash the runtime and bootloader, got an backup of the initial bootloader. Needed to restore it because at some point it would not let me into the dfu-mode. But I already had SWD connected and I was able to reflash it.

Afterwards I tried again with:

  1. Flash original Firmware via USB-Drive (both buttons pressed at startup) and reboot afterwards
  2. Flash runtime.hex via USB-Drive (both buttons pressed at startup)
  3. Restart without any keys pressed, runtime started
  4. Flash bootloader.dfu via dfu-util -D bootloader.dfu
  5. Restart & IronOS Bootloader is working

Version of the initial bootloader as shown in the Display was V12.00, MD5 of the binary with original bootloader and IronOS runtime is MD5 (backup.bin) = ca373fe47f4d3f736479e671c481fd6e

I duplicated the settings from the S60P besides the bootloader offsets. I was able to build and flash the Firmware for S99. I have some problems with entering the right PD mode. But I think we should discuss this in the IronOS repo.

Ralim commented 4 months ago

Going to close this as done, and then continue discussion over in IronOS. Great to see this worked for you.