feat(cherryusb): add cherryusb library #2212
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!2212
Loading…
Reference in a new issue
No description provided.
Delete branch "CherryUSB/master"
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?
Support usb device and host with cherryusb. Also host hub supports.
Stupid question 1: Why does this modify the linker files in
src/rp2_common/pico_crt0/rp2040/but not those insrc/rp2_common/pico_crt0/rp2350/?Stupid question 2: Can this be used as a complete replacement for TinyUSB? (or would that require a much larger refactoring of the SDK's existing USB code?)
1, my mistake, fixed
2, Our transfer api only has write & read and no need loop, it is easy to refactor.
Could you list or point out which usb code? I can help to match with cherryusb.
I did a
git grep -i tinyusband it looks like apart from thesrc/rp2_common/tinyusb/directory, tinyusb is only used insrc/rp2_common/pico_stdio_usb/(so perhaps not as much refactoring as I previously thought).done
Please stick to existing code-formatting conventions, rather than moving braces to a new line.
More stupid questions from me:
pico_stdio_usbto support (only) cherryusb and removed support for tinyusb? However I think we'd prefer if the user could choose to either use the tinyusb stack OR the cherryusb stack. However I'm not sure how difficult that'd be, so it might something that @kilograham would need to provide guidance with.Sorry, you told me refactor stdio_usb before, so i misunderstood to only support one.
Ahhh, apologies for the confusion!
EDIT (to clarify): The Raspberry Pi Pico SDK places a big emphasis on backwards-compatibility, and obviously unconditionally replacing tinyusb with cherryusb would break backwards-compatibility of the SDK for existing projects. So to stay backwards-compatible with all existing projects,
pico_stdio_usbshould continue to use tinyusb by default, but it might be nice if the user could optionally switch to use cherryusb forpico_stdio_usb, if they wanted to use the cherryusb stack instead of the tinyusb stack for new projects. (I'm assuming it wouldn't make sense to use both the tinyusb stack and the cherryusb stack in the same project!)Yes, i agree, i have changed.
@ -0,0 +1,153 @@/*The
tools/extract_configs.pyscript will get upset if the samePICO_CONFIG:entry appears in multiple different files.Note, i had a little play with this:
On RP2350
memcpy/memsetis not safe for unaligned or non word size copies involving USB memory.I did this
Which got the one example running, however I don't know which
memcpymight be misaligned (I was assuming none for now) or non word sizesHi, from cherryusb v1.5.0, we use our own memcpy instead, i will update submodule in this pr.
Just wanted to drop in my two cents since I doubt very many people have tried CherryUSB on Pi Pico. Ultimately, I failed to make it work since I don't have the RAM, but here's what I learned.
I use TinyUSB in host mode and support 5 hubs, 16 HID devices, 8 MSC devices, and XInput as a vendor protocol. Of course, we all know that TinyUSB on the rp2 is still unstable, so that's why I tried CherryUSB.
Modifying the linker script is unnecessary. This appears to be in there to support a kind of module registration by leveraging the linker. Pico SDK has a mechanism for forcing code into flash and giving it a unique name. While I'm not a fan of extending program logic into the linker, using the tools we already have seems better than complicating an already complicated linker script for a single library that should leverage the existing linker script with a macro that can be changed per platform.
The memory usage is crazy large. The math is (5 hubs * (16 hid + 8 msc)) since you need to allocate memory for every potential port usage on every hub. 8-port hubs are very common and some devices, like keyboards, can have hubs built in. Keyboards and mice often report as composite keyboard+mouse so we need 2 HID per port. Even though I only need to support (5 hubs + 16 HID + 8 MSC) = 29 which TinyUSB happily does, I have to allocate for (5 hubs * (16 hid + 8 msc)) = 120.
And finally is the requirement of an OS. There's no poll option. I have a 20k loc project that uses usb, bluetooth, and wifi just fine without an OS. I can add an OS but I don't have to like it.
You can change CONFIG_USBHOST_MAX_INTF_ALTSETTINGS to 1 for the less memory. And i don't think rp2 can support too many usb devices because of hardware endpoints limitation, also in cherryusb, we support dynamic endpoint(in urb) to reuse hardware endpoints.
Last, in cherryusb, we record all usb device's descriptors, we can easily read them and select one of them, so they are important, and some usb devices have many identical interfaces but different ep settings, and users need to choose one of them,this named INTF_ALTSETTING, usually for usb audio and video.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.