Add library for reset interface #2629
No reviewers
Labels
No labels
bazel
bluetooth
board settings
boot_stage2
bug
build
c++
can't reproduce
clang
clib-interface
cmsis
code cleanliness
code size
compiler version issues
cyw43_driver
debug
discussion
documentation
duplicate
dynamic_clock
elf2uf2
enhancement
errata
filesystem
flash layout
floating point
FreeRTOS
hardware_adc
hardware_claim
hardware_clocks
hardware_dma
hardware_exception
hardware_flash
hardware_gpio
hardware_i2c
hardware_irq
hardware_pio
hardware_pwm
hardware_rcp
hardware_rtc
hardware_spi
hardware_sync
hardware_uart
hardware_vreg
hardware_watchdog
hardware_xosc
help wanted
host
IAR
installation
invalid
linker scripts
lto
lwip
mbedtls
missing API
needs reporter detail
networking
newlib
newlib-multicore
non-c
non-cmake
non-gcc
openocd
orphan PR
OS integration
pico_async_context
pico_base
pico_binary_info
pico_flash
picolibc
pico_lwip
pico_malloc
pico_multicore
pico_printf
pico_runtime
pico_stdio
pico_stdio_usb
pico_sync
pico_time
pico_util
pioasm
port
question
review
review2
rtos interop
runtime init
static library
svd
test
tinyusb
vscode
wifi integration
wontfix
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-raspberrypi/pico-sdk!2629
Loading…
Reference in a new issue
No description provided.
Delete branch "reset-lib"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This separates the stdio_usb reset interface out into a separate library, which can be used by applications which use TinyUSB directly.
No change in behaviour when using the typical stdio_usb (eg in the hello_usb example).
Keeps the
PICO_STDIO_USB_prefix on the config defines to maintain compatibility, and also maintains compatibility with picotool.Instructions to use this are added to the header file.
See implementation in debugprobe and the dev_multi_cdc example
i would be tempted to move this into a separate header under pico_usb_reset_interface_headers, that can be included if desired
not sure
resetdis a sufficient/good prefix for the public APInote also, on this and the below, this is peculiar to TinyUSB - as we think about CherryUSB etc, we (i haven't looked in detail) should consider what if any of this is exposed (and whether we should expose them again in a separate header - e.g. one for TinyUSB one for CherryUSB)
I will rename them to
pico_usb_reset_interface_...Note that these functions are not supposed to be exposed as a public API - the only thing that should be used publicly is the
_resetd_driverstruct, I will try to refactor it so that's the caseHave made a separate
usb_reset_interface_device.hfile which should be included instead ofusb_reset_interface.hI made a separate TinyUSB header, and made it so this should be compatible with the CherryUSB PR (as that only uses the
usb_reset_interface.hheader)I couldn't refactor the functions out of the header, because I think the
pico_usb_reset_interface_driverhas to be defined in the header asstatic constin order for the debugprobe inclusion to compile, and therefore the functions must be in the header toonote
pico_/hardware_is not included in function names; e.g.dma_fooPerhaps this is slightly more readable?
Maybe? 🤷♂️
Does this new
pico_usb_reset_interfacegroup need adding todocs/index.h?Any reason this has stalled? I'd quite like to use this, so my project can handle reset to reconfigure in a new mode.
I've been using this PR in a project for a while now, which isn't great, but it has been working.
Looks like this PR has conflicts which need resolving? @will-v-pi
I've rebased it onto develop to resolve those - this PR is awaiting review by @kilograham
oops - sorry i seem to have ignored this!
I can rename the new library to
pico_usb_reset_interface_device, as the header name you actually include to use it is alreadyusb_reset_interface_device.h. That will make it the longest library name, but it's only slightly longer thanpico_bootsel_via_double_resetso it's probably fine. I can also move the new headers out ofcommonand into that library.Actually, maybe just
pico_usb_resetis fine for the library name, given it also includes the resetting via baud rate"default=1 when using pico_usb_reset_interface, 0 otherwise"
😕
Search&replace typo?
@ -0,0 +111,4 @@if (request->wValue & (1u << 8)) {active_low = request->wValue & (1u << 7);gpio = request->wValue >> 9u;}It might be worth swapping around two of these lines, so that the code better matches the comment?
ok, so there was maybe a bit of a miscommunication on the renaming, but i have looked at it again anyway.
I am cool with leaving it called
pico_usb_reset_interfacesince thats really what it is - the original headers can remain.even though they are long, we should probably keep PICO_USB_RESET_INTERFACE_ in the names to be consistent (i could handle contraction to IFC i guess)
It's kinda ugly, but the real headers really belong in rp2_common, so i'd actually put them with the code in rp2_common, but add them to the pico_usb_reset_interface_headers, and #include them from the original one guarded by a
#if LIB_PICO_USB_RESET_INTERFACESorry, I was occupied with other stuff - I think the rename to
pico_usb_resetmakes all of this cleaner so I will do that, as it allows for a separate pico_usb_reset_headers library so everything can be in rp2_common without any hacks in the existing header@ -0,0 +1,126 @@/*https://github.com/raspberrypi/pico-sdk/pull/2971/files mentions that the activity led active_low setting is ignored on RP2040. Is the same true here? (And if so, should it be mentioned?)
@ -0,0 +1,126 @@/*For readability purposes, I wonder if it might make sense to move all these
PICO_USB_RESET_BOOTSEL_settings belowPICO_USB_RESET_SUPPORT_RESET_TO_BOOTSEL? (Since if the latter is set to 0, I guess none of the former settings are applicable?)@ -0,0 +57,4 @@.reset = usb_reset_interface_reset,.open = usb_reset_interface_open,.control_xfer_cb = usb_reset_interface_control_xfer_cb,.xfer_cb = usb_reset_interface_xfer_cb,To match the renaming done in a recent commit, would it also make sense to rename these functions to
usb_reset_initetc.? Or does theusb_reset_interface_naming still make sense here? 🤷@ -0,0 +57,4 @@.reset = usb_reset_interface_reset,.open = usb_reset_interface_open,.control_xfer_cb = usb_reset_interface_control_xfer_cb,.xfer_cb = usb_reset_interface_xfer_cb,I think it still makes sense here, as these functions are specific to the USB interface that handles the reset
@ -0,0 +111,4 @@if (request->wValue & (1u << 8)) {active_low = request->wValue & (1u << 7);gpio = request->wValue >> 9u;}I've swapped them, and replaced
0x100etc with(1u << 8)to make that clearer as well@ -0,0 +28,4 @@U16_TO_U8S_LE(0x0080), U16_TO_U8S_LE(MS_OS_20_FEATURE_REG_PROPERTY), \U16_TO_U8S_LE(0x0001), U16_TO_U8S_LE(0x0028), /* wPropertyDataType, wPropertyNameLength and PropertyName "DeviceInterfaceGUID" in UTF-16 */ \'D', 0x00, 'e', 0x00, 'v', 0x00, 'i', 0x00, 'c', 0x00, 'e', 0x00, 'I', 0x00, 'n', 0x00, 't', 0x00, 'e', 0x00, \'r', 0x00, 'f', 0x00, 'a', 0x00, 'c', 0x00, 'e', 0x00, 'G', 0x00, 'U', 0x00, 'I', 0x00, 'D', 0x00, 0x00, 0x00, \Not directly-related to this PR (so feel free to ignore this suggestion), but maybe this could be reformatted to:
as this would then match the formatting of the
{bc7398c1-...UTF-16 string below?