Skip to content

Firmware configuration file #4404

Closed

Description

@bitboy85

To customize the board i think a firmware configuration file could come handy.
The file should stay in the botsel part of the storage and should allow some basic configuration of the device.
The configuration should be applied on each firmware update so the configuration will always be the same even if the defaults in the firmware itself changes.

It could look like this
`
[GENERAL]
FileSystem="FS Label"

[USB]
USB_VID = 0x239A
USB_PID = 0x804C
USB_PRODUCT = "PyRuler"
USB_MANUFACTURER = "Adafruit Industries LLC"

[ENDPOINTS]
0=CDC
1=Storage
2=Keyboard
3=BootKeyboard
4=Gamepad
5=MIDI
`

Reference:
#4191
#1136
https://learn.adafruit.com/welcome-to-circuitpython/the-circuitpy-drive
https://learn.adafruit.com/how-to-add-a-new-board-to-circuitpython/customizing-the-board-files

Activity

  1. deshipu commented on Mar 14, 2021

    @deshipu

    Maybe it would be best to keep this information in the bootloader? https://github.com/Microsoft/uf2/blob/master/cf2.md

  2. jepler commented on Mar 15, 2021

    @jepler

    See also #1015 about making USB descriptors configurable. I think we favored the idea of doing it in Python code from boot.py over having a "configuration file" in another language.

    Note that the filesystem label is set just once when the storage is initially formatted (or re-formatted via storage.erase_filesystem()) rather than each time the device is plugged in.

  3. added this to the Long term milestone on Mar 15, 2021
  4. tannewt commented on Mar 16, 2021

    @tannewt
    Member

    Why do you want this? boot.py is meant to store settings too.

  5. bitboy85 commented on Mar 16, 2021

    @bitboy85
    Author

    If it is possible to edit those settings within boot.py i'm fine with it. I thought, the configuration needs to be available at the time circuit python is installed/updated.
    The idea behind the bot-sel storge was that this configuration cannot be accidentally deleted and it would be easier to deploy because you just need to copy the configuration an the firmwarefile to the same directory.

  6. tannewt commented on Mar 16, 2021

    @tannewt
    Member

    The UF2 file is copied to a fake drive so no other files can be copied with it. boot.py runs before USB starts, so it can change what the USB device is configured as.

  7. s-ol commented on Apr 5, 2022

    @s-ol

    Configuring this in boot.py definitely makes sense. As far as I can tell, what is missing is just a python API for setting/overriding USB_VID, USB_PID, USB_PRODUCT, USB_MANUFACTURER; probably in the supervisor module.

    It's interesting that usb_build_device_descriptor already has parameters for setting USB_VID and USB_PID at runtime, but it is only ever called once (and with static arguments).

    These values could be non-const variables that can be updated (in RAM only) with something like e.g.:

    import supervisor
    supervisor.set_usb_device_descriptor(
      vid: Optional[int] = 0xdead,
      pid: Optional[int] = 0xbeef,
      manufacturer: Optional[str] = "ACME Inc.",
      product: Optional[str] = "Foobar",
    )
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions