Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish firmware on Linux Vendor Firmware Service #817

Open
t-8ch opened this issue Jan 20, 2021 · 29 comments
Open

Publish firmware on Linux Vendor Firmware Service #817

t-8ch opened this issue Jan 20, 2021 · 29 comments

Comments

@t-8ch
Copy link
Contributor

t-8ch commented Jan 20, 2021

The Linux Foundation operates a online repository of device firmware (the Linux Vendor Firmware Service, LVFS) at https://fwupd.org/ .
This repository is currently consumed by the fwupd tool on Linux which provides a easy one-click update-experience to update device firmware.

It would be great if IronOS could be uploaded there and be at least published as the default firmware for the Pinecil.
As fwupd already supports the USB DFU protocol that part should be reasonably straight forward.
Some context: https://twitter.com/dal000/status/1344630316015755265

The following open points I see:

  1. IronOS has one firmware build for each language. This does not seem to be supported in LVFS/fwupd currently, so it would need development there.
  2. fwupd uses its own DFU implementation, so it will also need a custom quirk implementation to handle the wrong blocksize reported by the Pinecil DFU implementation (as dfu-util is GPL2 and fwupd is LGPL-2.1+ I don't think their implementation can be used as-is)
  3. IronOS can be used as unofficial firmware for other soldering irons, is this something that can/should be supported by LVFS?
  4. LVFS does not have a specific icon for soldering icons!

@Ralim is this something you would want to have?
@hughsie As maintainer of fuwpd and LVFS what is your take on this?

Relevant issue for Pine64s official firmware updater: pine64/pine64_updater#1

@hughsie
Copy link

hughsie commented Jan 20, 2021

IronOS has one firmware build for each language

So there are a few different ways for USB devices you can get a "custom" GUID. The easiest is to have a different USB PID for each language; that makes everything happen correctly with no code changes, although kinda sucks from a build-time complexity problem. I have a USB VID you can use if you want so certainly don't spend the $2000 to just get a new VID assigned -- and it has 0xfff2 PIDs remaining :)

The other way is to somehow tell fwupd what language the device is in; maybe using the extended descriptor thing from Microsoft or just something custom we have to add code for. You could even stick it in the serial number string index or something. Basically; if the device can export the data we can add code to fwupd to consume it.

so it will also need a custom quirk implementation to handle the wrong blocksize

So desc.wTransferSize is wrong? I can easily add a quirk to set that -- what's the VID/PID of the bootloader and what should the wTransferSize be in reality?

IronOS can be used as unofficial firmware for other soldering irons

If it helps, the LVFS already supports "branches" -- e.g. on the BC57XX network cards there's an unofficial open source firmware and the nonfree broadcom one and you can "fwupdmgr swithc-branch" between them.

LVFS does not have a specific icon for soldering icons

Ha! Got any ideas? it needs to be freely re-distributable and in the hicolor theme.

More seriously, I think the bigger problem is that the firmware doesn't seem to have a runtime; that is when you plug in the soldering iron you don't see a USB device being added, you only see one when the device is in bootloader mode. This means that fwupd can't get the current firmware version without the user manually going into bootloader mode first, which kinda sucks as:

  • You don't get notified about new firmware
  • The bootloader VID/PID can't be modified so you don't know what hardware you have attached

@Ralim seems to be open to the idea of a runtime interface for monitoring, and it would be trivial to implement a DFU runtime with all the required bits so that fwupd can enumerate the hardware to get the language and current firmware version and also automatically push it into bootloader mode. I think that's the prerequisite before we start talking about icons :)

@t-8ch
Copy link
Contributor Author

t-8ch commented Jan 20, 2021

so it will also need a custom quirk implementation to handle the wrong blocksize

So desc.wTransferSize is wrong? I can easily add a quirk to set that -- what's the VID/PID of the bootloader and what should the wTransferSize be in reality?

I don't think it's wTransferSize that is wrong.
It's more the sector size and count that is misreported.
This is the GPL2 patch to dfu-util: https://sourceforge.net/p/dfu-util/dfu-util/ci/f2b7d4b1113ef6c3ada31a0654c9aefebcdb1de5/
The bootloader has idVendor=28e9, idProduct=0189 .

@hughsie
Copy link

hughsie commented Jan 20, 2021

Ahh, it's a strange beast indeed. I've started the process with hughsie/libgusb#43

@hughsie
Copy link

hughsie commented Jan 20, 2021

100% untested incomplete WIP branch: wip/hughsie/GD32VF103 -- I've ordered a Sipeed Longan Nano dev board and can finish off the branch when it arrives.

@hughsie
Copy link

hughsie commented Jan 27, 2021

Seems to work for me: fwupd/fwupd#2815 -- there's the slight issue that fwupd doesn't know how to flash an Intel Hex file to the DFU device, but I can work on that too.

@Ralim
Copy link
Owner

Ralim commented Jan 28, 2021

@hughsie We do also pack the bin file in all releases so hex support shouldnt be required for now.

@hughsie
Copy link

hughsie commented Jan 28, 2021

Ahh, I missed that. The bin file might need fwupd work as I'm assuming the base offset is 0 rather than 0x8000000 or whatever the chip has. Got a link handy? Also, did you ponder a runtime USB interface?

@Ralim
Copy link
Owner

Ralim commented Jan 28, 2021

Ah yes the bin files are setup to be flashed at the start of flash which is indeed 0x8000000.

As an example, any pinecil.zip from the actions tab will work or this release https://github.com/Ralim/IronOS/releases/download/v2.14.1/Pinecil.zip

Heh, yeah have been thinking about adding a usb mode. At the least even just all of the descriptors would be useful for this.

Just haven't sat down to code it yet sadly 😅

@dal00
Copy link

dal00 commented Feb 17, 2021

I see support is now merged in the latest fwupd-release now! That is great! Does that mean it is nearing completion? Or is there still outstanding work to be done on the Pinecil side of things?
I mean the usb mode might not be required for initial support? That would only make it a nicer user experience?

@alvinhochun
Copy link
Contributor

I mean the usb mode might not be required for initial support? That would only make it a nicer user experience?

Without a USB mode, how would fwupd identify the Pinecil? I don't think we can just use the GD32 DFU VID/PID pair. The Pinecil is not the only thing that uses the GD32VF103 MCU and we wouldn't want to accidentally flash IronOS to some other devices.

@hughsie
Copy link

hughsie commented Feb 17, 2021

how would fwupd identify the Pinecil

We need a USB runtime interface, even if it's just the interface with some revision number and a VID PID. fwupd is smart enough to know that Pinecil -> generic DFU bootloader = "Pinecil in bootloader mode", although without the runtime with unique VIDPID you're correct in that we can't do anything correctly.

@hughsie
Copy link

hughsie commented Feb 26, 2021

Just haven't sat down to code it yet sadly

I tried to flash the UK Pinecil firmware to the GD32VF103 I have in the Sipeed Longan Nano but that seems to have 0x08000000/128*001Kg i.e. 32kb of flash and only ~60% of the flash fits. Does the Pinecil have more flash than this or have I got my sums wrong? The Nano has a ChipID of 0603 if that helps.

@t-8ch
Copy link
Contributor Author

t-8ch commented Feb 26, 2021

@hughsie
The Pinecil should have 128KB of flash ( https://wiki.pine64.org/index.php/Pinecil ).
If you tell me how to retrieve the ChipID I can check it for the Pinecil.

@hughsie
Copy link

hughsie commented Feb 26, 2021

If you tell me how to retrieve the ChipID I can check it for the Pinecil

Install libgusb fwupd from git master (or the F33 packages from https://people.freedesktop.org/~hughsient/fedora/ -- both fwupd and libgusb) and then sudo fwupdtool get-devices --plugins dfu --verbose with the Pinecil in bootloader mode. If that all sounds like too much hard work I'm pretty sure the pinecil has about twice the flash I have on my devboard.

@t-8ch
Copy link
Contributor Author

t-8ch commented Feb 27, 2021

ChipID seems for the Pinecil seems to be 0603, too.

Full log
23:56:55:0729 FuEngine             using plugins: dfu
23:56:55:0758 FuPluginDfu          DFU version 0x0000 invalid, v1.1 assumed
23:56:55:0758 FuPluginDfu          using DFU transfer size 0x0040 bytes
23:56:55:0758 FuPluginDfu          unable to guess initial device state from interface 0
23:56:55:0758 FuPluginDfu          STM-DFU support
23:56:55:0758 FuPluginDfu          using DFU transfer size 0x0800 bytes
23:56:55:0758 FuPluginDfu          unable to guess initial device state from interface 0
23:56:55:0758 FuDevice             using 23ec719b6aabc2d2dac5176c232f0da7a21881b0 for usb:01:00:04
23:56:55:0868 FuPluginDfu          chip ID set to: 0603
23:56:55:0868 FuPluginDfu          using GD32 sector size of 0x8000
23:56:55:0869 FuPluginDfu          using GD32 sector size of 0x8000
23:56:55:0870 FuPlugin             emit added from dfu: 23ec719b6aabc2d2dac5176c232f0da7a21881b0
23:56:55:0871 FuDeviceList         ::added 23ec719b6aabc2d2dac5176c232f0da7a21881b0
23:56:55:0871 FuMain               ADDED:
FuDfuDevice:
GD32 0x418 DFU Bootloade?
  DeviceId:             23ec719b6aabc2d2dac5176c232f0da7a21881b0
  Guid:                 f3005d4e-2e30-503a-bc93-fcb79ce65f34 <- USB\VID_28E9&PID_0189&REV_1000
  Guid:                 f40ef7cf-e4f6-5708-b274-13edfb04646e <- USB\VID_28E9&PID_0189
  Serial:               3TBJ
  Plugin:               dfu
  Protocol:             com.st.dfuse
  Flags:                updatable|registered|add-counterpart-guids
  Vendor:               GDMicroelectronics
  VendorId:             USB:0x28E9
  Version:              10.0
  VersionFormat:        bcd
  Icon:                 drive-harddisk-usb
  Created:              2021-02-26
  PhysicalId:           usb:01:00:04
  CustomFlags:          gd32
  PossiblePlugin:       dfu
  InternalFlags:        replug-match-guid
  State:                appIDLE
  Status:               OK
  DoneUploadOrDownload: false
  ClaimedInterface:     false
  ChipId:               0603
  Version:              0x11a
  ForceVersion:         0x0
  RuntimePid:           0x189
  RuntimeVid:           0x28e9
  RuntimeRelease:       0x1000
  TransferSize:         0x800
  IfaceNumber:          0x0
  DnloadTimeout:        0x0
  TimeoutMs:            0x5dc
    AltSetting:         0x0
    AltIdx:             0x4
    AltName:            @Internal Flash  /0x08000000/512*002Kg
      Idx00:            Zone:0, Sec#:0, Addr:0x08000000, Size:0x8000, Caps:0x7 [REW]
    AltSetting:         0x1
    AltIdx:             0x5
    AltName:            @Option Bytes  /0x1FFFF800/01*016 g
      Idx00:            Zone:0, Sec#:0, Addr:0x08000000, Size:0x8000, Caps:0x7 [REW]

23:56:55:0901 FuEngine             Emitting PropertyChanged('Status'='idle')
Loading…                 [***************************************]
WARNING: This package has not been validated, it may not work properly.
23:56:55:0903 FuMain               GD32 0x418 DFU Bootloade?
  DeviceId:             23ec719b6aabc2d2dac5176c232f0da7a21881b0
  Guid:                 f3005d4e-2e30-503a-bc93-fcb79ce65f34 <- USB\VID_28E9&PID_0189&REV_1000
  Guid:                 f40ef7cf-e4f6-5708-b274-13edfb04646e <- USB\VID_28E9&PID_0189
  Serial:               3TBJ
  Plugin:               dfu
  Protocol:             com.st.dfuse
  Flags:                updatable|registered|add-counterpart-guids
  Vendor:               GDMicroelectronics
  VendorId:             USB:0x28E9
  Version:              10.0
  VersionFormat:        bcd
  Icon:                 drive-harddisk-usb
  Created:              2021-02-26

@hughsie
Copy link

hughsie commented Feb 27, 2021

@t-8ch does fwupd/fwupd#2952 fix things? I'm away from my lab today so I can actually test until Monday.

@Ralim
Copy link
Owner

Ralim commented Feb 27, 2021

Ah you are correct in the different flash sizes; though the fitness can be flashed to either as it fits; just that I'm not certain what would happen when it tries to save settings as these are located at the end of flash

@t-8ch
Copy link
Contributor Author

t-8ch commented Feb 27, 2021

@hughsie Now it looks different, but still 0603.

Full log
12:34:16:0270 FuEngine             Emitting PropertyChanged('Status'='loading')
Loading…                 [-                                      ]12:34:16:0270 FuEngine             using plugins: dfu
12:34:16:0347 FuPluginDfu          DFU version 0x0000 invalid, v1.1 assumed
12:34:16:0347 FuPluginDfu          using DFU transfer size 0x0040 bytes
12:34:16:0347 FuPluginDfu          quirking device into DFU mode
12:34:16:0347 FuPluginDfu          STM-DFU support
12:34:16:0347 FuPluginDfu          using DFU transfer size 0x0800 bytes
12:34:16:0347 FuPluginDfu          quirking device into DFU mode
12:34:16:0347 FuDevice             using 23ec719b6aabc2d2dac5176c232f0da7a21881b0 for usb:01:00:04
12:34:16:0458 FuPluginDfu          chip ID set to: 0603
12:34:16:0459 FuPlugin             emit added from dfu: 23ec719b6aabc2d2dac5176c232f0da7a21881b0
12:34:16:0460 FuDeviceList         ::added 23ec719b6aabc2d2dac5176c232f0da7a21881b0
12:34:16:0461 FuMain               ADDED:
FuDfuDevice:
GD32 0x418 DFU Bootloade?
  DeviceId:             23ec719b6aabc2d2dac5176c232f0da7a21881b0
  Guid:                 f3005d4e-2e30-503a-bc93-fcb79ce65f34 <- USB\VID_28E9&PID_0189&REV_1000
  Guid:                 f40ef7cf-e4f6-5708-b274-13edfb04646e <- USB\VID_28E9&PID_0189
  Serial:               3TBJ
  Plugin:               dfu
  Protocol:             com.st.dfuse
  Flags:                updatable|registered|is-bootloader|add-counterpart-guids
  Vendor:               GDMicroelectronics
  VendorId:             USB:0x28E9
  Version:              10.0
  VersionFormat:        bcd
  Icon:                 drive-harddisk-usb
  Created:              2021-02-27
  PhysicalId:           usb:01:00:04
  CustomFlags:          gd32,force-dfu-mode
  PossiblePlugin:       dfu
  InternalFlags:        replug-match-guid
  State:                dfuIDLE
  Status:               OK
  DoneUploadOrDownload: false
  ClaimedInterface:     false
  ChipId:               0603
  Version:              0x11a
  ForceVersion:         0x0
  RuntimePid:           0xffff
  RuntimeVid:           0xffff
  RuntimeRelease:       0xffff
  TransferSize:         0x800
  IfaceNumber:          0x0
  DnloadTimeout:        0x0
  TimeoutMs:            0x5dc
    AltSetting:         0x0
    AltIdx:             0x4
    AltName:            @Internal Flash  /0x8000000/128*1Kg
    AltNameForDisplay:  Internal Flash
      Idx00:            Zone:0, Sec#:0, Addr:0x08000000, Size:0x0400, Caps:0x7 [REW]
      Idx01:            Zone:0, Sec#:0, Addr:0x08000400, Size:0x0400, Caps:0x7 [REW]
      Idx02:            Zone:0, Sec#:0, Addr:0x08000800, Size:0x0400, Caps:0x7 [REW]
      Idx03:            Zone:0, Sec#:0, Addr:0x08000c00, Size:0x0400, Caps:0x7 [REW]
      Idx04:            Zone:0, Sec#:0, Addr:0x08001000, Size:0x0400, Caps:0x7 [REW]
      Idx05:            Zone:0, Sec#:0, Addr:0x08001400, Size:0x0400, Caps:0x7 [REW]
      Idx06:            Zone:0, Sec#:0, Addr:0x08001800, Size:0x0400, Caps:0x7 [REW]
      Idx07:            Zone:0, Sec#:0, Addr:0x08001c00, Size:0x0400, Caps:0x7 [REW]
      Idx08:            Zone:0, Sec#:0, Addr:0x08002000, Size:0x0400, Caps:0x7 [REW]
      Idx09:            Zone:0, Sec#:0, Addr:0x08002400, Size:0x0400, Caps:0x7 [REW]
      Idx0a:            Zone:0, Sec#:0, Addr:0x08002800, Size:0x0400, Caps:0x7 [REW]
      Idx0b:            Zone:0, Sec#:0, Addr:0x08002c00, Size:0x0400, Caps:0x7 [REW]
      Idx0c:            Zone:0, Sec#:0, Addr:0x08003000, Size:0x0400, Caps:0x7 [REW]
      Idx0d:            Zone:0, Sec#:0, Addr:0x08003400, Size:0x0400, Caps:0x7 [REW]
      Idx0e:            Zone:0, Sec#:0, Addr:0x08003800, Size:0x0400, Caps:0x7 [REW]
      Idx0f:            Zone:0, Sec#:0, Addr:0x08003c00, Size:0x0400, Caps:0x7 [REW]
      Idx10:            Zone:0, Sec#:0, Addr:0x08004000, Size:0x0400, Caps:0x7 [REW]
      Idx11:            Zone:0, Sec#:0, Addr:0x08004400, Size:0x0400, Caps:0x7 [REW]
      Idx12:            Zone:0, Sec#:0, Addr:0x08004800, Size:0x0400, Caps:0x7 [REW]
      Idx13:            Zone:0, Sec#:0, Addr:0x08004c00, Size:0x0400, Caps:0x7 [REW]
      Idx14:            Zone:0, Sec#:0, Addr:0x08005000, Size:0x0400, Caps:0x7 [REW]
      Idx15:            Zone:0, Sec#:0, Addr:0x08005400, Size:0x0400, Caps:0x7 [REW]
      Idx16:            Zone:0, Sec#:0, Addr:0x08005800, Size:0x0400, Caps:0x7 [REW]
      Idx17:            Zone:0, Sec#:0, Addr:0x08005c00, Size:0x0400, Caps:0x7 [REW]
      Idx18:            Zone:0, Sec#:0, Addr:0x08006000, Size:0x0400, Caps:0x7 [REW]
      Idx19:            Zone:0, Sec#:0, Addr:0x08006400, Size:0x0400, Caps:0x7 [REW]
      Idx1a:            Zone:0, Sec#:0, Addr:0x08006800, Size:0x0400, Caps:0x7 [REW]
      Idx1b:            Zone:0, Sec#:0, Addr:0x08006c00, Size:0x0400, Caps:0x7 [REW]
      Idx1c:            Zone:0, Sec#:0, Addr:0x08007000, Size:0x0400, Caps:0x7 [REW]
      Idx1d:            Zone:0, Sec#:0, Addr:0x08007400, Size:0x0400, Caps:0x7 [REW]
      Idx1e:            Zone:0, Sec#:0, Addr:0x08007800, Size:0x0400, Caps:0x7 [REW]
      Idx1f:            Zone:0, Sec#:0, Addr:0x08007c00, Size:0x0400, Caps:0x7 [REW]
      Idx20:            Zone:0, Sec#:0, Addr:0x08008000, Size:0x0400, Caps:0x7 [REW]
      Idx21:            Zone:0, Sec#:0, Addr:0x08008400, Size:0x0400, Caps:0x7 [REW]
      Idx22:            Zone:0, Sec#:0, Addr:0x08008800, Size:0x0400, Caps:0x7 [REW]
      Idx23:            Zone:0, Sec#:0, Addr:0x08008c00, Size:0x0400, Caps:0x7 [REW]
      Idx24:            Zone:0, Sec#:0, Addr:0x08009000, Size:0x0400, Caps:0x7 [REW]
      Idx25:            Zone:0, Sec#:0, Addr:0x08009400, Size:0x0400, Caps:0x7 [REW]
      Idx26:            Zone:0, Sec#:0, Addr:0x08009800, Size:0x0400, Caps:0x7 [REW]
      Idx27:            Zone:0, Sec#:0, Addr:0x08009c00, Size:0x0400, Caps:0x7 [REW]
      Idx28:            Zone:0, Sec#:0, Addr:0x0800a000, Size:0x0400, Caps:0x7 [REW]
      Idx29:            Zone:0, Sec#:0, Addr:0x0800a400, Size:0x0400, Caps:0x7 [REW]
      Idx2a:            Zone:0, Sec#:0, Addr:0x0800a800, Size:0x0400, Caps:0x7 [REW]
      Idx2b:            Zone:0, Sec#:0, Addr:0x0800ac00, Size:0x0400, Caps:0x7 [REW]
      Idx2c:            Zone:0, Sec#:0, Addr:0x0800b000, Size:0x0400, Caps:0x7 [REW]
      Idx2d:            Zone:0, Sec#:0, Addr:0x0800b400, Size:0x0400, Caps:0x7 [REW]
      Idx2e:            Zone:0, Sec#:0, Addr:0x0800b800, Size:0x0400, Caps:0x7 [REW]
      Idx2f:            Zone:0, Sec#:0, Addr:0x0800bc00, Size:0x0400, Caps:0x7 [REW]
      Idx30:            Zone:0, Sec#:0, Addr:0x0800c000, Size:0x0400, Caps:0x7 [REW]
      Idx31:            Zone:0, Sec#:0, Addr:0x0800c400, Size:0x0400, Caps:0x7 [REW]
      Idx32:            Zone:0, Sec#:0, Addr:0x0800c800, Size:0x0400, Caps:0x7 [REW]
      Idx33:            Zone:0, Sec#:0, Addr:0x0800cc00, Size:0x0400, Caps:0x7 [REW]
      Idx34:            Zone:0, Sec#:0, Addr:0x0800d000, Size:0x0400, Caps:0x7 [REW]
      Idx35:            Zone:0, Sec#:0, Addr:0x0800d400, Size:0x0400, Caps:0x7 [REW]
      Idx36:            Zone:0, Sec#:0, Addr:0x0800d800, Size:0x0400, Caps:0x7 [REW]
      Idx37:            Zone:0, Sec#:0, Addr:0x0800dc00, Size:0x0400, Caps:0x7 [REW]
      Idx38:            Zone:0, Sec#:0, Addr:0x0800e000, Size:0x0400, Caps:0x7 [REW]
      Idx39:            Zone:0, Sec#:0, Addr:0x0800e400, Size:0x0400, Caps:0x7 [REW]
      Idx3a:            Zone:0, Sec#:0, Addr:0x0800e800, Size:0x0400, Caps:0x7 [REW]
      Idx3b:            Zone:0, Sec#:0, Addr:0x0800ec00, Size:0x0400, Caps:0x7 [REW]
      Idx3c:            Zone:0, Sec#:0, Addr:0x0800f000, Size:0x0400, Caps:0x7 [REW]
      Idx3d:            Zone:0, Sec#:0, Addr:0x0800f400, Size:0x0400, Caps:0x7 [REW]
      Idx3e:            Zone:0, Sec#:0, Addr:0x0800f800, Size:0x0400, Caps:0x7 [REW]
      Idx3f:            Zone:0, Sec#:0, Addr:0x0800fc00, Size:0x0400, Caps:0x7 [REW]
      Idx40:            Zone:0, Sec#:0, Addr:0x08010000, Size:0x0400, Caps:0x7 [REW]
      Idx41:            Zone:0, Sec#:0, Addr:0x08010400, Size:0x0400, Caps:0x7 [REW]
      Idx42:            Zone:0, Sec#:0, Addr:0x08010800, Size:0x0400, Caps:0x7 [REW]
      Idx43:            Zone:0, Sec#:0, Addr:0x08010c00, Size:0x0400, Caps:0x7 [REW]
      Idx44:            Zone:0, Sec#:0, Addr:0x08011000, Size:0x0400, Caps:0x7 [REW]
      Idx45:            Zone:0, Sec#:0, Addr:0x08011400, Size:0x0400, Caps:0x7 [REW]
      Idx46:            Zone:0, Sec#:0, Addr:0x08011800, Size:0x0400, Caps:0x7 [REW]
      Idx47:            Zone:0, Sec#:0, Addr:0x08011c00, Size:0x0400, Caps:0x7 [REW]
      Idx48:            Zone:0, Sec#:0, Addr:0x08012000, Size:0x0400, Caps:0x7 [REW]
      Idx49:            Zone:0, Sec#:0, Addr:0x08012400, Size:0x0400, Caps:0x7 [REW]
      Idx4a:            Zone:0, Sec#:0, Addr:0x08012800, Size:0x0400, Caps:0x7 [REW]
      Idx4b:            Zone:0, Sec#:0, Addr:0x08012c00, Size:0x0400, Caps:0x7 [REW]
      Idx4c:            Zone:0, Sec#:0, Addr:0x08013000, Size:0x0400, Caps:0x7 [REW]
      Idx4d:            Zone:0, Sec#:0, Addr:0x08013400, Size:0x0400, Caps:0x7 [REW]
      Idx4e:            Zone:0, Sec#:0, Addr:0x08013800, Size:0x0400, Caps:0x7 [REW]
      Idx4f:            Zone:0, Sec#:0, Addr:0x08013c00, Size:0x0400, Caps:0x7 [REW]
      Idx50:            Zone:0, Sec#:0, Addr:0x08014000, Size:0x0400, Caps:0x7 [REW]
      Idx51:            Zone:0, Sec#:0, Addr:0x08014400, Size:0x0400, Caps:0x7 [REW]
      Idx52:            Zone:0, Sec#:0, Addr:0x08014800, Size:0x0400, Caps:0x7 [REW]
      Idx53:            Zone:0, Sec#:0, Addr:0x08014c00, Size:0x0400, Caps:0x7 [REW]
      Idx54:            Zone:0, Sec#:0, Addr:0x08015000, Size:0x0400, Caps:0x7 [REW]
      Idx55:            Zone:0, Sec#:0, Addr:0x08015400, Size:0x0400, Caps:0x7 [REW]
      Idx56:            Zone:0, Sec#:0, Addr:0x08015800, Size:0x0400, Caps:0x7 [REW]
      Idx57:            Zone:0, Sec#:0, Addr:0x08015c00, Size:0x0400, Caps:0x7 [REW]
      Idx58:            Zone:0, Sec#:0, Addr:0x08016000, Size:0x0400, Caps:0x7 [REW]
      Idx59:            Zone:0, Sec#:0, Addr:0x08016400, Size:0x0400, Caps:0x7 [REW]
      Idx5a:            Zone:0, Sec#:0, Addr:0x08016800, Size:0x0400, Caps:0x7 [REW]
      Idx5b:            Zone:0, Sec#:0, Addr:0x08016c00, Size:0x0400, Caps:0x7 [REW]
      Idx5c:            Zone:0, Sec#:0, Addr:0x08017000, Size:0x0400, Caps:0x7 [REW]
      Idx5d:            Zone:0, Sec#:0, Addr:0x08017400, Size:0x0400, Caps:0x7 [REW]
      Idx5e:            Zone:0, Sec#:0, Addr:0x08017800, Size:0x0400, Caps:0x7 [REW]
      Idx5f:            Zone:0, Sec#:0, Addr:0x08017c00, Size:0x0400, Caps:0x7 [REW]
      Idx60:            Zone:0, Sec#:0, Addr:0x08018000, Size:0x0400, Caps:0x7 [REW]
      Idx61:            Zone:0, Sec#:0, Addr:0x08018400, Size:0x0400, Caps:0x7 [REW]
      Idx62:            Zone:0, Sec#:0, Addr:0x08018800, Size:0x0400, Caps:0x7 [REW]
      Idx63:            Zone:0, Sec#:0, Addr:0x08018c00, Size:0x0400, Caps:0x7 [REW]
      Idx64:            Zone:0, Sec#:0, Addr:0x08019000, Size:0x0400, Caps:0x7 [REW]
      Idx65:            Zone:0, Sec#:0, Addr:0x08019400, Size:0x0400, Caps:0x7 [REW]
      Idx66:            Zone:0, Sec#:0, Addr:0x08019800, Size:0x0400, Caps:0x7 [REW]
      Idx67:            Zone:0, Sec#:0, Addr:0x08019c00, Size:0x0400, Caps:0x7 [REW]
      Idx68:            Zone:0, Sec#:0, Addr:0x0801a000, Size:0x0400, Caps:0x7 [REW]
      Idx69:            Zone:0, Sec#:0, Addr:0x0801a400, Size:0x0400, Caps:0x7 [REW]
      Idx6a:            Zone:0, Sec#:0, Addr:0x0801a800, Size:0x0400, Caps:0x7 [REW]
      Idx6b:            Zone:0, Sec#:0, Addr:0x0801ac00, Size:0x0400, Caps:0x7 [REW]
      Idx6c:            Zone:0, Sec#:0, Addr:0x0801b000, Size:0x0400, Caps:0x7 [REW]
      Idx6d:            Zone:0, Sec#:0, Addr:0x0801b400, Size:0x0400, Caps:0x7 [REW]
      Idx6e:            Zone:0, Sec#:0, Addr:0x0801b800, Size:0x0400, Caps:0x7 [REW]
      Idx6f:            Zone:0, Sec#:0, Addr:0x0801bc00, Size:0x0400, Caps:0x7 [REW]
      Idx70:            Zone:0, Sec#:0, Addr:0x0801c000, Size:0x0400, Caps:0x7 [REW]
      Idx71:            Zone:0, Sec#:0, Addr:0x0801c400, Size:0x0400, Caps:0x7 [REW]
      Idx72:            Zone:0, Sec#:0, Addr:0x0801c800, Size:0x0400, Caps:0x7 [REW]
      Idx73:            Zone:0, Sec#:0, Addr:0x0801cc00, Size:0x0400, Caps:0x7 [REW]
      Idx74:            Zone:0, Sec#:0, Addr:0x0801d000, Size:0x0400, Caps:0x7 [REW]
      Idx75:            Zone:0, Sec#:0, Addr:0x0801d400, Size:0x0400, Caps:0x7 [REW]
      Idx76:            Zone:0, Sec#:0, Addr:0x0801d800, Size:0x0400, Caps:0x7 [REW]
      Idx77:            Zone:0, Sec#:0, Addr:0x0801dc00, Size:0x0400, Caps:0x7 [REW]
      Idx78:            Zone:0, Sec#:0, Addr:0x0801e000, Size:0x0400, Caps:0x7 [REW]
      Idx79:            Zone:0, Sec#:0, Addr:0x0801e400, Size:0x0400, Caps:0x7 [REW]
      Idx7a:            Zone:0, Sec#:0, Addr:0x0801e800, Size:0x0400, Caps:0x7 [REW]
      Idx7b:            Zone:0, Sec#:0, Addr:0x0801ec00, Size:0x0400, Caps:0x7 [REW]
      Idx7c:            Zone:0, Sec#:0, Addr:0x0801f000, Size:0x0400, Caps:0x7 [REW]
      Idx7d:            Zone:0, Sec#:0, Addr:0x0801f400, Size:0x0400, Caps:0x7 [REW]
      Idx7e:            Zone:0, Sec#:0, Addr:0x0801f800, Size:0x0400, Caps:0x7 [REW]
      Idx7f:            Zone:0, Sec#:0, Addr:0x0801fc00, Size:0x0400, Caps:0x7 [REW]
    AltSetting:         0x1
    AltIdx:             0x5
    AltName:            @Option Bytes  /0x1FFFF800/01*016 g
    AltNameForDisplay:  Option Bytes
      Idx00:            Zone:0, Sec#:0, Addr:0x1ffff800, Size:0x0010, Caps:0x7 [REW]

12:34:16:0491 FuEngine             Emitting PropertyChanged('Status'='idle')
Loading…                 [***************************************]
WARNING: This package has not been validated, it may not work properly.
12:34:16:0493 FuMain               GD32 0x418 DFU Bootloade?
  DeviceId:             23ec719b6aabc2d2dac5176c232f0da7a21881b0
  Guid:                 f3005d4e-2e30-503a-bc93-fcb79ce65f34 <- USB\VID_28E9&PID_0189&REV_1000
  Guid:                 f40ef7cf-e4f6-5708-b274-13edfb04646e <- USB\VID_28E9&PID_0189
  Serial:               3TBJ
  Plugin:               dfu
  Protocol:             com.st.dfuse
  Flags:                updatable|registered|is-bootloader|add-counterpart-guids
  Vendor:               GDMicroelectronics
  VendorId:             USB:0x28E9
  Version:              10.0
  VersionFormat:        bcd
  Icon:                 drive-harddisk-usb
  Created:              2021-02-27

@hughsie
Copy link

hughsie commented Mar 1, 2021

Now it looks different, but still 0603

Ya, as it should; I misunderstood the original quirk purpose. I've fixed up the branch and just flashed successfully Pinecil_UK.bin to the development board. It did not, however, magically turn into a soldering iron.

Once @Ralim adds a DFU runtime (or rather, any USB runtime really, but a DFU runtime would make things "just work") I think we could actually upload firmware to the LVFS.

@t-8ch
Copy link
Contributor Author

t-8ch commented Mar 1, 2021

@Ralim
I'd like to to take a shot at this (at least for the Pinecil).
The gigadevice firmware library has code to implement the necessary DFU runtime descriptors beginning from version 1.1.0.
Do you think there are any problems updating to the latest version of the firmware?

@Ralim
Copy link
Owner

Ralim commented Mar 3, 2021

@t-8ch
You should be totally fine to update to the latest gigadevice library, though we dont require their DFU at runtime as we can use the rom version; so probably just need to setup the barebones USB to enumerate with a descriptor.

Sorta thinking could just implement a CDC or something while at it but unsure what is most useful long term as well.

Totally open to ideas here :)

@hughsie
Copy link

hughsie commented Mar 3, 2021

setup the barebones USB to enumerate with a descriptor

Certainly if you implement a DFU runtime interface then it's easy for fwupd to put the device into bootloader mode without asking the user to reinsert without pressing a button -- i.e. it goes from "urgh" to "just works".

Would there be a different USB PID for each language? Or perhaps a different USB REV? Either works for fwupd, we just need to know the language from the descriptor so we can download (from the LVFS) and then write the correct .bin file to the device.

@alvinhochun
Copy link
Contributor

I don't like the idea of using different PIDs for different languages. That means assigning a new PID every time a new language is added and having to keep a mapping between PID and language. Wouldn't it be more flexible to provide some mechanism (e.g. HID reports but I don't know what's the best way) for the host software to query the current version and language?

I think once such feature is added, it may also be utilized by the official Pinecil firmware updater tool to make the manual update process more user-friendly.

CC @gamelaster

@gamelaster
Copy link
Collaborator

@alvinhochun as I said, if there will be higher demand of Linux version, it's not problem to create it. Although, I'm bit worried about packaging, since it's best to ship the app with custom dfu-util. I will think about this and try to port it over Linux.

@alvinhochun
Copy link
Contributor

@alvinhochun as I said, if there will be higher demand of Linux version, it's not problem to create it. Although, I'm bit worried about packaging, since it's best to ship the app with custom dfu-util. I will think about this and try to port it over Linux.

No, I was mainly referring to the use on Windows and macOS. While this issue is mostly focused on LVFS, the addition of a runtime interface may also allow the updater to automatically detect firmware version and flash the updated firmware without requiring the user to manually enter DFU mode by holding the "-" button.

@hughsie
Copy link

hughsie commented Mar 3, 2021

e.g. HID reports

If different PIDs are not going to fly (to me a product in a different language is a different thing, but that's juts me...) then you could use a different REV for the languages. e.g. REV=0 for en, 1=fr, 2=de etc. If you did either REV or PID then there are no code changes required. If you do want a custom HID interface with some sort of command set to:

  • get the language
  • switch the device to bootloader DFU mode

then it would also be quite simple to support, something like https://github.com/fwupd/fwupd/blob/master/plugins/system76-launch/fu-system76-launch-device.c would be fine.

The other thing to consider is just adding the language in a string descriptor. e.g. in the serial, product, or a custom index. Then fwupd (or the windows updater) can just read that without claiming any interface.

@Ralim
Copy link
Owner

Ralim commented Mar 3, 2021

My vote for language would to put its name in a string in the descriptor as that also removes the requirement to have a number <-> name lookup and instead we can just place it into the USB descriptions somewhere.

@hughsie
Copy link

hughsie commented Mar 3, 2021

instead we can just place it into the USB descriptions somewhere

Works for me; it would be a few lines in fwupd to parse that and add an extra GUID.

@gamelaster
Copy link
Collaborator

No, I was mainly referring to the use on Windows and macOS. While this issue is mostly focused on LVFS, the addition of a runtime interface may also allow the updater to automatically detect firmware version and flash the updated firmware without requiring the user to manually enter DFU mode by holding the "-" button.

Ah sorry, yeah, this is interesting idea and if this whole feature will be implemented into IronOS and LVFS, I guess it can be implemented into the app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants