Skip to content

Firmware configuration file #4404

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

Closed
bitboy85 opened this issue Mar 14, 2021 · 6 comments · Fixed by #6247
Closed

Firmware configuration file #4404

bitboy85 opened this issue Mar 14, 2021 · 6 comments · Fixed by #6247
Milestone

Comments

@bitboy85
Copy link

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

@deshipu
Copy link

deshipu commented Mar 14, 2021

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

@jepler
Copy link

jepler commented Mar 15, 2021

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.

@jepler jepler added this to the Long term milestone Mar 15, 2021
@tannewt
Copy link
Member

tannewt commented Mar 16, 2021

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

@bitboy85
Copy link
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.

@tannewt
Copy link
Member

tannewt commented Mar 16, 2021

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.

@s-ol
Copy link

s-ol commented Apr 5, 2022

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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants