dektronics / printalyzer-densitometer

Reflection and Transmission Densitometer for Photographic Darkroom Use
19 stars 4 forks source link

Provide a way for end-users to update device firmware #4

Closed dkonigsberg closed 2 years ago

dkonigsberg commented 3 years ago

While it is the hope that a "launch" version of the device will effectively have finalized firmware, the possibility for future updates to fix bugs and add features will always remain.

Its probably not reasonable to expect average end-users to use an ST-Link with a Tag-Connect cable to install firmware updates on the device. Therefore, another option should be provided.

The biggest issue right now is that the current firmware build (which is not feature-complete, but is close) already uses up most of the available flash on the STM32L052 microcontroller. Furthermore, the built-in bootloader options on this MCU are really not suitable for handling end-user firmware updates.

The solutions to this problem can be broken up into two categories:

Options for a tiny cram-able bootloader include these projects:

dkonigsberg commented 3 years ago

As of recent updates, there is now a very basic way of doing this:

  1. Hold down boot selector button with device powered off
  2. Plug in device to a computer
  3. Device shows up as a USB DFU device (with both LED sets on, for some reason)
  4. $ dfu-util -a 0 --dfuse-address 0x08000000 -D densitometer.bin
  5. Power-cycle the device

A more polished version is going to need a few additions, that may or may not end up as separate issues:

dkonigsberg commented 2 years ago

There are now two ways to update on-device firmware, so I think its time to close this issue:

  1. The DFU method, as mentioned above. This is great for programming from a bare-metal state, and/or fixing a bricked device. It might be a little too involved for ordinary updates.
  2. An embedded UF2 bootloader, triggered by holding down a button combination on power-up. This is very easy for an ordinary end-user to use to install updates. It may still have room for improvement, but in its current state it gets the job done.
pixelwaster commented 2 years ago

You might want to check out the nanoVNA, The update process is very easy and they use a similar processor. Basically select the file, select the device, and update.

Very interesting project. Looking forward to seeing how this goes almost more than the densitometer itself.

dkonigsberg commented 2 years ago

You might want to check out the nanoVNA, The update process is very easy and they use a similar processor. Basically select the file, select the device, and update.

NanoVNA uses DFU. There are a few utilities that can be used to do a DFU update, some easier to get going than others, but none really intended for normal end users. A polished DFU update process would require writing my own wrapper, and then dealing with OS-specific device issues.

The advantage of UF2 is that it requires no special software. Just boot into UF2 mode, the device shows up as a USB mass storage device, drag-and-drop the file to it, and you're done.