#tinyusb
1 messages Β· Page 4 of 1
] heap info
Heap dump (using miniheap):
base 0xc411c284, len 0x9d7c
free list:
base 0xc411c588, end 0xc411c59c, len 0x14
base 0xc411c74c, end 0xc411e418, len 0x1ccc
base 0xc4125688, end 0xc4126000, len 0x978
delayed free list:
node 0xc411c5a8
node 0xc4123588
] novm
not enough arguments
usage:
novm info
novm alloc <numberofpages> [arena bitmap]
novm free <address> [numberofpages]
] novm info
name 'main', 1037027 pages, each 4k (4148108k in all)
range: 0xc411d000-0xc1400000
loading GD#24, disk offset 5632
tuh_msc_read_block(0xc411c518, 0xc4120220, 526347, 1)
406.446168 [DWC2:hcd_edpt_xfer:418]: HOST0 -> 2.02 0xc401d87c/31 opep:0xc411c4d0 type:2 pid:0
407.592887 [DWC2:hcd_edpt_xfer:411]: HOST0 <- 2.81 0xc4120220/512 opep:0xc411c488 type:2 pid:2
dumping channel 0: IN init
HCCHAR0: 0x988a00
mps:512 ep:1 dir1 type:2 mc:1 addr:2
HCSPLT0: 0x0
HCINT0: 0x0
HCINTMSK0: 0x7ff
HCTSIZ0: 0x40080200
size:512 packets:1 pid:2 ping:0
HCDMA0: 0xc4120220
enabling...
unhandled VPU Exception: Bad L2 alias
dumping channel 0: xfer comp
HCCHAR0: 0x988a00
mps:512 ep:1 dir1 type:2 mc:1 addr:2
HCSPLT0: 0x0
HCINT0: 0x0
HCINTMSK0: 0x7ff
HCTSIZ0: 0x80000000
size:0 packets:0 pid:0 ping:1
HCDMA0: 0x00000200
407.939082 [DWC2:dwc_check_interrupt:657]: bytes 0, buflen 512, packets: 1, old next_pid: 2
407.947150 [DWC2:dwc_check_interrupt:658]: hcd_event_xfer_complete(2, 0x81, 512, success, true)
407.955571 [DWC2:dwc_irq:746]: irq time: 267783
Fatal VPU Exception: Undefined instruction
pc: 0x0000000c lr: 0x00000000
stack 0xc411e4c8, stack_size 8448, stack_used 1660
stack end: c41205c8
the buffer was ~936 bytes from the top of the shell's stack, which fits with expectations
yeah this makes sense. Actualy I think we should skip this entirely for rp2040. LTO is global option, and it should only be set by top level application cmakelists.txt. It is ok for other ports since it only applies to examples within tinyusb. But I don't really want to force this on user application at all.
hmm, I pushed some update to your branch, but look like github doesn't pick that up.
I skip the LTO option entirely for rp2040 since this should be decision by application top level cmake file. @kilograham let me know you are with the changes.
Example implementation of the discussion #2201.
- Invoke unmounted state when there is a configuration reset
I think the natural size of the CPU architecture, the variable type, is better for performance. The natural size means 'int' and 'unsigned'. Unless there is a reason the type may keep 'unsigned'.
When variable type is narrow than CPU architecture, compiler generates sign extension instructions to keep variable type size.
In this function, it is clear that 'total_len' is always less than or equal to 65535, so there is no need for it to be 'uint16_t'. Because 'total_len' is clipped by max p...
You hinted me about using uint_least16_t & uint_least8_t for narrow variable types.
@robust walrus so ive now run into a rather confusing problem
reading MSD works fine
if i link my ext2/4 driver in, it begins loading group descriptors
0-23 load fine
24 causes all **** to break loose
when the IN packet for that block is executed, an unknown cpu exception fires
if i attempt to return from that, the normal transfer-complete irq fires
but a cpu exception in the middle of an irq hander prologue, corrupts the state, and it returns to the wrong addr
adding sleeps to every in/out does nothing
reducing the vpu clock does nothing
I haven't seen anything like that before
i can currently think of ~3 plans of attack
1: figure out exactly what is causing the Bad L2 alias exception
2: examine the stack and figure out why i cant return from that
3: just checksum all of .text and .rodata and see if dma is somehow corrupting my code
you got any ideas from that?
not really, you are in deeper weeds than I am
one issue, is that i dont have an MMU, and i havent configured the MPU
so anything can just trash my code
unhandled VPU Exception: Bad L2 alias
VPU registers:
r0: 0x00000039 r1: 0x00000065 r2: 0x7e201018 r3: 0xc401bed0
r4: 0xc4012394 r5: 0x00000000 r6: 0x00000065 r7: 0xc4018c4f
r8: 0x00000007 r9: 0x40000000 r10: 0x80988a00 r11: 0x00080000
r12: 0x00000200 r13: 0x00000800 r14: 0xc4120420 r15: 0x0000ffff
pc: 0xc40012a0 lr: 0xc4000a9a sr: 0x20000000
0xc401ccd0 9c 12 00 c4 00 00 00 00 00 00 00 00 00 00 00 00 |................|
0xc401cce0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
0xc401ccf0 00 00 00 00 ff ff 00 00 20 04 12 c4 00 08 00 00 |........ .......|
0xc401cd00 00 02 00 00 00 00 08 00 00 8a 98 80 00 00 00 40 |...............@|
0xc401cd10 07 00 00 00 4f 8c 01 c4 65 00 00 00 00 00 00 00 |....O...e.......|
0xc401cd20 94 23 01 c4 d0 be 01 c4 18 10 20 7e 65 00 00 00 |.#........ ~e...|
0xc401cd30 39 00 00 00 9a 0a 00 c4 00 00 00 20 a0 12 00 c4 |9.......... ....|
from 0xc401ccd8 to 0xc401cd33, you can see r23 to r0, in reverse order
after r0, is the state of lr at the instant it entered the exception handler
9a 0a 00 c4, as the printf showed, that is a return statement at the end of platform_dputc()
00 00 00 20 a0 12 00 c4
from memory, i believe the hardware will push the PC and status reg to the stack, upon any interrupt
so, it was 1 opcode into fleh_irq (the raw irq entry-point) when this exception fired
0xc401cd40 00 00 00 00 86 1d 00 c4 00 00 00 00 00 00 00 00 |................|
but there is an extra 32bit word there.., then an addr into .text, timer0_irq(), a c function
0xc401cd50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
0xc401cd60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
0xc401cd70 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
0xc401cd80 00 00 00 00 00 00 00 00 00 00 00 00 44 9e 00 c4 |............D...|
and a lot more nulls
followed by the c entry-point for the usb irq
this stack doesnt look right, and i can see why it later returned to an invalid addr
This would be very useful. Working on a gamepad at the moment and this would help a ton with reducing latency at lower interval inputs.
i also remembered another benefit of this trick
ipxe always compiles every driver, to prevent code-rot
and then at link time, it can select what the user actually wanted, so you can still get small binaries, but lesser used code still gets syntax/type-checked by the compiler
but yeah, you would need to at least inject the linker script into the linker args, i believe it can take multiple linker scripts
] bio dump usb2_0 269489664 512
tuh_msc_read_block(0xc411c718, 0xc41204e0, 526347, 1)
Queue EP 02 with 31 bytes ...
240.417172 [DWC2:hcd_edpt_xfer:418]: HOST0 -> 2.02 0xc401da7c/31 opep:0xc411c6d0 type:2 pid:2
241.545910 [DWC2:hcd_edpt_xfer:411]: HOST0 <- 2.81 0xc41204e0/512 opep:0xc411c688 type:2 pid:0
241.837717 [DWC2:dwc_check_interrupt:658]: hcd_event_xfer_complete(2, 0x81, 512, success, true)
242.869957 [DWC2:hcd_edpt_xfer:411]: HOST0 <- 2.81 0xc401da9c/13 opep:0xc411c688 type:2 pid:2
tuh_msc_read_block(0xc411c718, 0xc41204e0, 526347, 1)
244.090481 [DWC2:hcd_edpt_xfer:418]: HOST0 -> 2.02 0xc401da7c/31 opep:0xc411c6d0 type:2 pid:0
245.246201 [DWC2:hcd_edpt_xfer:411]: HOST0 <- 2.81 0xc41204e0/512 opep:0xc411c688 type:2 pid:0
246.570247 [DWC2:hcd_edpt_xfer:411]: HOST0 <- 2.81 0xc401da9c/13 opep:0xc411c688 type:2 pid:2
digging some more, i can see that my bio dump only supports 256 byte blocks
so, to dump a 512 byte sector, it has to do 2 reads
and its not the block# that is lethal, that is the same block that fails
0x10101600: 08 00 08 00 14 00 08 00 08 10 08 00 00 80 e0 1f |................
0x10101610: 00 00 03 00 00 00 00 00 00 00 00 00 e0 1f 7f 84 |................
0x10101620: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................
0x10101630: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................
0x10101640: 09 00 08 00 15 00 08 00 06 12 08 00 41 7e e0 1f |............A~..
0x10101650: 00 00 03 00 00 00 00 00 00 00 00 00 e0 1f e3 46 |...............F
0x10101660: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................
0x10101670: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................
0x10101680: 0a 00 08 00 16 00 08 00 04 14 08 00 00 80 e0 1f |................
0x10101690: 00 00 03 00 00 00 00 00 00 00 00 00 e0 1f de 60 |...............`
0x101016a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................
0x101016b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................
0x101016c0: 0b 00 08 00 17 00 08 00 02 16 08 00 41 6d e0 1f |............Am..
0x101016d0: 00 00 01 00 00 00 00 00 e3 f3 00 00 e0 1f 88 80 |................
0x101016e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................
0x101016f0: 00 00 00 00 00 00 00 00 3a d5 00 00 00 00 00 00 |........:.......
[root@amd-nixos:~]# hexdump -C /dev/sdc --skip 269489664 --length 512
10101600 08 00 08 00 14 00 08 00 08 10 08 00 00 80 e0 1f |................|
10101610 00 00 03 00 00 00 00 00 00 00 00 00 e0 1f 7f 84 |................|
10101620 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
10101640 09 00 08 00 15 00 08 00 06 12 08 00 41 7e e0 1f |............A~..|
10101650 00 00 03 00 00 00 00 00 00 00 00 00 e0 1f e3 46 |...............F|
10101660 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
10101680 0a 00 08 00 16 00 08 00 04 14 08 00 00 80 e0 1f |................|
10101690 00 00 03 00 00 00 00 00 00 00 00 00 e0 1f de 60 |...............`|
101016a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
101016c0 0b 00 08 00 17 00 08 00 02 16 08 00 41 6d e0 1f |............Am..|
101016d0 00 00 01 00 00 00 00 00 e3 f3 00 00 e0 1f 88 80 |................|
101016e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
101016f0 00 00 00 00 00 00 00 00 3a d5 00 00 00 00 00 00 |........:.......|
and the data its returning, does look valid
@robust walrus aha, if i just hexdump the same block ~25 times, it crashes!
that roughly lines up with an ext4 superblock, and 24 group descriptors!
@kkitayam great anatomy, indeed using native size has smaller code size, though I am worried that unsinged on smaller such as 8-bit mcu can cause issue (not sure if rusb2 has any 8-bit mcu maybe H8). However, as @HiFiPhile suggested uint_least16_t seems to be the best of both worlds. If you agree we could do that.
PS: would it be ok if we do that in follow-up PR since I plan to refactor common code from dcd/hcd (pipe write/read etc..) anyway and that would be good chance to update overall...
@cleverca22 multiple linker script could work with gcc, but proriearty compiler such as IAR or ARMCC may not (not sure though). It is a great approach if we are working on a specific project/mcu and could dictate all compiler/linker progress. I wouldn't want to touch linker in the some platform such as esp-idf. Anyway, I still perfer to solve this with C than linker.
thank you for your PR and patient. Changing qdef name is actually not what I mean. Although the name is a bit odd _usbd_qdef. It is still useful since user would know which variable to look at, let just keep that. I also update to only include the name if needed and does quite a bit of reformat. Will merge will ci is complete
@visual breach ive hit a rather crazy bug in the dwc hw
if i read ~27 packets from a usb device
the hw takes the 32bit int, 12 bytes into the last usb packet
and overwrites the dma write-pointer
then writes that packet to an essentially random location in ram, lol
how crazy does that sound?
It sounds like a security vulnerability.
it also fired a VPU exception, that i havent been able to return from correctly
so its also a DoS
i'm not sure what it could be, because it fires with such regularity
i'm writing an HCD for tinyusb, on the rpi
and the usb controller is malfunctioning, when using the mass-storage driver in tinyusb
59.183018 [DWC2:dwc_check_interrupt:706]: bytes 0, buflen -1006507332, packets: -1006507332, old next_pid: 1
59.192647 [DWC2:dwc_check_interrupt:707]: hcd_event_xfer_complete(2, 0x81, 0, success, true)
ASSERT FAILED at (lk/kernel/timer.c:151): timer->magic == TIMER_MAGIC
what what have i done??, time to debug it more!
unhandled packet status on rx fifo
channel: 4
byte count: 1558
PID: 0
packet status: 10
wait, what
0x0f0e0d00 8a aa ab 8b aa aa 22 aa aa aa aa aa 00 01 02 03 |......".........|
0x0f0e0d10 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 |................|
a sample, where the entire sector (0 to 255, repeated twice), got written to address 0f0e0b0c, which is just 0c 0d 0e 0f but interpreted as LE
i should get to bed
Here are a couple hardware project for HITL. Thanks @esden for the pointers! https://github.com/probe-rs/hive https://github.com/esden/redcuttle
thanks Scott, it looks very neat, but probably overkilled I guess. I would prefer to just stick the dev board in, most of them has on-board debugger anyway for flashing. It is of course just me :D
superb! Thank you very much for your PR and patient. I was super busy with other works. I have pulled and tested, added makefile so that we could build with other mcus without the huge list of skip.txt. Also update descriptor to build with nrf52 and a couple of file renaming to reduce confusion as tud_cdc.c look like it comes from the stack. Overally it is great, I haven't tested it on other mcus though, but should work (else we could fix later).
Related area
Port
Hardware specification
STM32H5
Is your feature request related to a problem?
Is support for STM32H5 planned in future? Couldn't find any discussion in regards and would like to use TinyUSB in a project using that MCU
Describe the solution you'd like
Support for STM32H5, at least in device mode
I have checked existing issues, dicussion and documentation
- [X] I confirm I have checked existing issues, dicussion and documentation.
Thank you for your reply.
I am agree that @HiFiPhile and your suggestion. uint_least16_t will be good solution.
This would be very useful. Working on a gamepad at the moment and this would help a ton with reducing latency at lower interval inputs.
I would assume the GP2040-CE firmware would also benefit as well. Pretty sure the GP2040-CE is also one of the fastest on the market already since it uses the 2 cores of the RP2040 which is cool.
perfect, thank you everyone for joining to make this PR possible. I am glad we finally merge it. Any issues could be addressed later with follow-up PRs.
@robust walrus just noticed a possible hint
the tx fifo, can hold ~32 packets of 512 bytes
its failing at ~27 plus enumeration....
Although the name is a bit odd _usbd_qdef...
Clear variable names and comments ease development, debug, and maintenance,
and are the mark of a great programmer ;-) ;-)
Thanks @hathach !!
Best Regards, Dave
Apologies I won't be able to look at this for some weeks...
@robust walrus i dumped the raw rx and tx fifo's
after the failure, i can see a 512 byte sector, crossing the border from rx fifo to tx fifo!
please don't ping unless you have a question about tinyusb. I'm not following the details of your debugging. You are in areas I'm unfamiliar with
(I'll still follow along with your updates. just don't want to get interrupted)
setting them to the current value doesnt work
but if i shrink the rx fifo, it seems to stop crashing...
that seems to be working
unsure if data is being lost when it overflows into "free space" and wraps wrongly
but its no longer crashing
was able to read 1024 sectors without issue!
left it reading 102400 sectors
its up to 10.2k
] fs mount /root ext2 usb2_0p1
] ls /root
F 1431655893 .
error -2 opening file '/root'
D 16384 lost+found
D 4096 lk
] ls /root/lk
D 4096 .
F 1431655893 ..
D 4096 .git
D 4096 .github
F 120 .gitignore
F 1132 LICENSE
F 1344 README.md
D 4096 app
D 4096 arch
D 4096 dev
D 4096 docs
F 12442 engine.mk
D 4096 external
D 4096 kernel
D 4096 lib
F 590 lk_inc.mk.example
D 4096 make
F 1113 makefile
D 4096 platform
D 4096 project
D 4096 scripts
D 4096 target
D 4096 tools
D 4096 top
]
woooo!!!
the problem, was that despite the rx fifo being right up against the tx fifo (0 byte gap, the default), it seems that is invalid, and it causes the fifo to overflow into its neighbor
i just shrank the rx fifo some, and no more problems
Describe the PR
- Mostly BSP related, non-stack code
- rename hw/bsp/board.h to hw/bsp/board_api.h
- add board_get_unique_id() to get unique ID for usb serial number. Partly implement #1970 , related #2194
- This function is implemented on rp2040 and various stm32
- if not implemented default to 0123456789abcdef
- Update all examples'descriptors to use unique ID
#2204 implement unique ID for several families including: rp2040 and various stm32 (including l4 and f7)
all is good, thank you for the fix and your detailed exaplanation
all is good, thank you for the PR
all looks good, thank you for your PR. I take the chance to also update cmake for all f4 board. As well as fix building and other house keeping work.
update: and PR building pico-examples will be added soon (after this one). CI will only build 2 usb example in the pico-examples repo dev_hid_composite and host_cdc_msc_hid (currently disabled due to usb host api changes). let me know if this is sufficient enough.
- name: Build pico-examples
if: matrix.family == 'rp2040'
env:
PICO_SDK...
filled in the missing code for queues to block
removed various sleeps, it can now enumerate a usb disk in ~3.2 seconds from init
wired up the msd disconnect event, and fixed interrupt endpoints
I've connected the boards.
3 debuggers are flashed to Jlink:
| SN | Board | Device |
|---|---|---|
| 770935966 | STM32F746DISCO | STM32F746NG |
| 774470029 | NUCLEO-L412KB | STM32L412KB |
| 727600775 | OM13092 | LPC54608J512 |
Both STM32L4 & STM32F7 works, while only HS port works on OM13092. (added missing -DBOARD_TUD_RHPORT=$(PORT))
Tried changing 54628 to 54608 in board.mk and I don't spot any USB related difference...
unfortunately the "fix" is too hacky. The changes for hcd_rusb2 look good, maybe split this to an seperate PR so that it can be merged.
this is a hack, we cannnot clear the event queue like this though. E.g rusb2 with 2 ports can be configured as BOTH host, but they still share the same event queue. Clearing the queue is not an option even there is no hub support. This is mostly caused by physical connection bouncing, We will analyze the rootcause and fix it properly though, just need a bit of time.
thank you :+1: , just saw them show up in the lsusb (ssh shell). I will try to update ci test script later on. Since you are often working with audio, maybe we should spend more time to write some script to capture the mic input and compare with knowngood etc... but that can always wait :)
Describe the PR
Host Library:
The unplugging process of the USB device might lead to an infinite loop. It is easy to run into this situation if unplugging occurs during the enumeration process. Also, it happens when unplugging while the host and the USB device are doing something.
The issue is really big. As the stack enters an infinite loop when this is happening.
Additional context
I am testing with the RA4M2 family, with no OS. I know this fix is not meant if you are hosting a hub...
Since you are often working with audio, maybe we should spend more time to write some script to capture the mic input and compare with knowngood etc... but that can always wait :)
It would be nice but compare audio is a little tricky due to PC resampling etc., I'll try to figure something out.
look good, hw test failed is due to the new addition of new hardware. We have to specific jlink serial so that It connect to correct board. GIve me some time to fix this. Once done, this will be merged. Thank you
Seriously @hathach:
Steve McConnell "Code Complete" (first edition, not 2nd).
Chapter 9 "The Power of Data Names"
Naming data checklist, page 212-213.
I found it extremely helpful!
A really excellent book on programming (and there aren't that many)...
https://www.amazon.com/Complete-Microsoft-Programming-Steve-McConnell/dp/1556154844
Best Regards, Dave
Describe the PR
HITL farm know has more boards with jlink #2194, use correct usb serial for L412 board
] init
hcd_event_handler()
HCD_EVENT_DEVICE_ATTACH
] reset
] open
17.585567 [DWC2:hcd_edpt_open:390]: dev 0 EP00 opened root port: 0 hub_addr: 0 hub_port: 0 speed: 2(HS) opep: 0xc4116db4
] setup
hcd_event_handler()
HCD_EVENT_XFER_COMPLETE
ep_addr: 00
result: 0
len: 8
(result 0 is success)
] data_in
hcd_event_handler()
HCD_EVENT_XFER_COMPLETE
ep_addr: 80
result: 0
len: 8
0xc4018600 12 01 00 02 09 00 02 40 00 00 00 00 00 00 00 00 |.......@........|
] setup
] data_in
hcd_event_handler()
HCD_EVENT_XFER_COMPLETE
ep_addr: 80
result: 0
len: 8
0xc4018600 12 01 00 02 09 00 02 40 00 00 00 00 00 00 00 00 |.......@........|
] setup
] setup
] data_in
0xc4018600 12 01 00 02 09 00 02 40 00 00 00 00 00 00 00 00 |.......@........|
https://gist.github.com/cleverca22/287f9116c92bfef576c8652f04d4da3d
by replacing tinyusb with this, i can manually drive the HCD, and do "invalid" things for testing
ive confirmed that the hub in the lan9514, is perfectly happy to respond to SETUP requests, even if a previous control-in was not completed fully
my next step, was to test that with a tinyusb device, but my zero is giving me trouble...
] init
HCD_EVENT_DEVICE_ATTACH
] reset
20.297209 [DWC2:dwc_check_interrupt:671]: port enabled at HS
] open
25.373273 [DWC2:hcd_edpt_open:390]: dev 0 EP00 opened root port: 0 hub_addr: 0 hub_port: 0 speed: 2(HS) opep: 0xc01014cc
] setup
] data_in
0x8001d7c0 12 01 00 02 00 00 00 40 00 00 00 00 00 00 00 00 |.......@........|
(diff usb device, no hub involved, pi0)
and i can confirm the same thing, setup setup in, and setup in setup in all give the expected result, even with the ack missing, or controls not reading the in
but i can break the rp2040 boot rom, by just doing setup setup in
i think its tinyusb based
Hi I want to implement the same of having CTS flow control with pre existing RTS. Have you got it to work if yes can u share them please.
Describe the PR
Because Windows command prompt has no tr command, it occurs a warning.
Additional context
I found some way in stack overflow.
https://stackoverflow.com/questions/664601/in-gnu-make-how-do-i-convert-a-variable-to-lower-case
For portability, I guess the simple way is better.
Describe the PR
Add HITL testing script for newly added boards #2194
I'm not familiar with Github, @hathach could you take a look for CI integration ?
Additional context
Actually it catched something !
My lpcxpresso54608 (even modified 54628 to 54608 in board.mk) failed with cdc_msc test, msc block doesn't show up :
[242341.797154] usb 4-1.7: new high-speed USB device number 89 using xhci_hcd
[242341.901761] usb 4-1.7: New USB device found, idVendor=cafe, idProduct=...
- There should be only necessary things placed in an interrupt. Everything else should be done in the main loop.
- Data response should be done in an asynchronous manner.
- The USB driver only guarantee bandwidth (for isochronous transfers) and uniform timings (for interrupt transfers).
Meaning a HID device can be polled at any time as long as the rate is constant while it's unclear when that actually happens between two SOFs packages. So the SOF interrupt should be only used to save the...
LGTM - not sure if it is better to just have the job fail if there are any issues (e.g. the host API changing is a valid reason for failure), though we could add a second job for that - perhaps i'll add that on our end
@HiFiPhile yeah, I notice MSC is not showed up on your VM. I thought it is due your VM not enable auto mount block device, I remembered we could find it /dev/sda. I guess we have to manual mount ? I will check out the PR later.
LGTM - not sure if it is better to just have the job fail if there are any issues (e.g. the host API changing is a valid reason for failure), though we could add a second job for that - perhaps i'll add that on our end
maybe you could update the pico-examples on dev branch, and we can use dev branch here. otheriwse a failed ci will prevent any merge on this repo. We could fix and enable it in follow up PR. Thank you.
Describe the PR
Build pico-examples usb in the CI to prevent changes in this repo break pico-examples #2151
Note: due to host API changes, currently only usb/device/dev_hid_composite is built, usb/host/host_cdc_msc_hid is commented out.
PS: let me know if you need to set up an hook when there is pushed to tinyusb for running ci on pico-examples.
I thought it is due your VM not enable auto mount block device
It's true. I set udev alias, it will show up with something like /dev/blkUSB_57323020.02
thank you, this is a bit lengthy is portable.
Describe the PR
- Add tuh_rhport_reset_bus() for reset downstream port.
- Add tuh_rhport_is_active() to check if rhport is running as host
- EHCI improve bus reset, fix send_setup() not carried out if halted previously
- seperate bus reset delay and contact debouncing delay in enumeration
- fix host msc get maxlun not using aligned section memory
@tannewt
I thought it is due your VM not enable auto mount block device
It's true. I set udev alias, it will show up with something like
/dev/blkUSB_57323020.02
we should actually read the contents of README.TXT to verify that it works. Give me a bit of time. I will add manual mount to this PR when possible.
should be BLINK_NOT_MOUNTED
it is not reachable, since cfg_num is check before process_set_config() is called.
https://github.com/hathach/tinyusb/blob/master/src/device/usbd.c#L714
This check should be moved there.
thank you for you PR. changes look good, though there is 2 changes we should make
- correct typo for BLINK_NOT_MOUNTED
- move the umount callback to the correct place (right now it is not reachable)
we should actually read the contents of README.TXT to verify that it works.
Currently I read the content directly from block device.
https://github.com/hathach/tinyusb/blob/87150b77702d93527e2998c62371ef2d7d2b9860/test/hitl/hitl_test.py#L109-L115
I was too lazy to do mounting rightly to take care permissions and when multiples devices running msc_cdc example.
Now it read README.TXT from mounted device.
The problem with the Wooting is addressed now, it was related to a bug.
So together with the the PR #2202 these changes should help making the USB handling overall more reliable which likely addresses issues for some edge cases.
@robust walrus i suspect this is why you had trouble a few fridays ago
the tinyusb device stack gets confused by a double setup
and the pio-host stack misses an ack, causing a double setup
yup totally. I think thach just fixed it
maybe not. thinking #2211 above
yeah, thats more host stuff
and also a fix i mentioned elsewhere:
fix host msc get maxlun not using aligned section memory
ive also gotten MSD and ext4 stable enough that i can stream raw uncompressed video from usb to the screen
have a look at this
Does anyone have any resources on using the rp2040 as a host using its own built in USB port that's already attached? I want to use a USB keyboard to type in a program, but I want to just be able to plug a usb in without cutting up the wire. Also preferably in Arduino lol
like maybe modifying the Feather Host library to just use the usb thats built in
the existing host examples should work
here is one of the official examples: https://github.com/raspberrypi/pico-examples/tree/master/usb/host/host_cdc_msc_hid
yeahhh I have seen that, but I was looking for an arduino version
maybe I could just swap host and device in this
https://github.com/newts/Pico-PIO-USB/blob/main/examples/host_hid_to_device_cdc/host_hid_to_device_cdc.c
10.935417 [DWC2:hcd_edpt_open:415]: dev 0 EP00 opened root port: 0 hub_addr: 5 hub_port: 2 speed: 0(FS) opep: 0xc411a2e8
ok, so something in tinyusb is aware that its a full-speed device behind the hub
that came from asking tinyusb via hcd_devtree_get_info()
yep, as expected, thats a reply from the hub
perfect now, thank you for your PR
Now it read README.TXT from mounted device.
thank you perfect, I will check this out soon enough. Though one thing pop up in my mind. I think at the end of the CI. We should flash board_test example. This will disable the usb on the tested board. Making testing the next board easier, at least it will more forgiving in our test script.
Operating System
Others
Board
rpi2
Firmware
custom https://github.com/librerpi/lk-overlay/tree/master/platform/bcm28xx/dwc2 + https://github.com/librerpi/lk-overlay/tree/master/lib/tinyusb
#define CFG_TUH_HUB 1
#define CFG_TUH_DEVICE_MAX (3*CFG_TUH_HUB + 1)
What happened ?
a second hub connected to port 2 prevents enumeration from discovering devices on ports 3-5
if the MSD is on port 2, and hub on port 3, the MSD is enumerated,...
I understand what you're saying, but for that to happen a SOF callback here I think would exactly help facilitate that. For the user to implement this RTOS functionality if required and not be TinyUSBs responsibility.
Unless you mean this should be extended to all device types.
As far as I know it's not guaranteed that interrupt transfers are always scheduled directly after the SOF, even if that is typically done this way. I'm not aware that the USB specification specifies when withing a frame interrupts transfers should take places as long as the timing is ok.
Imagine a lot of devices with a lot of interrupt interfaces. The more there are the longer it takes to handle all and the last one can be scheduled very late compared to the first one.
Even your linked ...
lpc54 has an issue with receiving 31 bytes for msc command and sending 13 for msc status. Somehow when the transfer is complete, it is only 30 bytes (1 residue) and 12 bytes. Seem like the interrupt triggered a bit early or something. I have spent something troubleshoot, but not quite sure what is wrong. We probably need to skip the lpc54 for now, lpc55 has no issue with this though, strange.
We probably need to skip the lpc54 for now
Yes we can fix it later.
- I think a general SOF callback can be helpful for any application. It's likely needed for any realtime implementation. As the other callbacks these drivers callbacks are handled also by the
tud_task()in the main loop. So that can't be used as a time reference for any time critical stuff because you don't know the time between the SOF interrupt triggered by the MCU and when this callback is actually executed. Of course for non-critical stuff it should be fine and better as nothing. - I d...
@Rocky04 I don't understand where you are trying to get, please be concise, and avoid massive information dumps and rambling like you are doing, it's hard to parse to parse without the context of what you're thinking, also try to reach a conclusion, ideally something actionable, right now you're just wasting everyone's time.
I think you're suggesting that the SOF interrupts not reliable, and you're right, that's a given some architectures don't even implement it... but I fail to realize wh...
@perigoso Here, as simple as I can write it for you...
- Add a general SOF callback. It makes absolutely no sense to implement that in a HID specific way.
- It would help making the delay more consistent but likely add latency. Please check out how Motion Sync works on a modern mouse.
- Your statement is contrary. This PR is all about adding a HID specific callback and not about a general one.
- I aware of the USB specification, how a typically implementation for a USB device works an...
@HiFiPhile everything looks great and the python test script is way better than my shell script and easier to work with. Though I think we may have to modify it a bit to work better with ci. I will try to wrap this up tomorrow.
- Added support for a simple general callback when a new frame or micro frame started
Can be used to synchronize the scanning to the polling on HID devices. Not useful for time critical things because the time which has passed between the interrupt and the execution is unknown.
Proper example implementation for the PR #2180.
@Xelus22
The function hidd_sof_isr() as configured in the class driver is called in dcd_event_handler() and so executed when the SOF interrupt is handled. That's why the name is "isr". Due to this there would not pass much time between the interrupt and the execution. But that approach isn't good because only very important stuff should be done in an ISR and as less as possible execution time should be spend there in general.
The added code from you in the tud_task_ext() function on...
I was looking around for lpc54 issue and found there are 17 USB issues in errata sheet, that's a lot...
Maybe it's related:
* USB.1: In USB high-speed device mode, the NBytes field does not decrement after BULK OUT transfer
Introduction:
The LPC546xx. device family includes a USB high-speed interface (USB1) that can
operate in device mode at high-speed. The NBytes value represents the number of bytes
that can be received in the buffer.
* Problem:
If the buffer length is less th...
I'm unsure if the device port should be part of the callback or not. I started the PR with it but removed it for now.
A function executed directly in a synchron manner isn't a callback. Meaning don't put a "_cb" in an "_isr" because these names refer to different things.
In this function only code should be placed which needs to be executed inside the interrupt service routine right after when the start of frame occurred.
Here the callback should be executed but instead the ISR function is executed a second time.
As a callback it should be invoked in the ISR due to the SOF event and called here: https://github.com/hathach/tinyusb/blob/cfe8ca3fa51061bbe7e519b72236f9aabae13e59/src/device/usbd.c#L599
The assigned ISR function at this place gets called here: https://github.com/hathach/tinyusb/blob/cfe8ca3fa51061bbe7e519b72236f9aabae13e59/src/device/usbd.c#L1132
Here, as simple as I can summaries it, just for you...
This is better, you should make extra effort from the start.
A general SOF callback should be added. It makes absolutely no sense to implement that in a HID specific way.
I agree, I made the same suggestion.
It would help making the delay more consistent but likely add latency. Please check out how Motion Sync works on a modern mouse.
This is precisely what I noted as being an implementation detail.
Your statemen...
This is a callback because it's a configurable function defined by the user, not because of how it is called
@perigoso
Upf, details matter... An implementation is always about the details. This is a PR, so side effects and specifics need to be taken into account. The underlying goal for the desired feature of this PR was all about input delays on USB. So with the provided info I was basically questioning the purpose of the PR as is, even I referred to a use case which would be implementation specific.
I can understand that there is likely a language barrier and that maybe not all things are e...
There are naming conventions for a reason. So people who read a function name have an expectation what the function does. Messing around with that only causes issues.
Just have a look at the other TinyUSB callbacks, like tud_mount_cb(). The event for it is invoked (but the function isn't executed) in the ISR. It's later called in the main loop from tud_task(). But audiod_sof_isr() on the other hand is executed in the ISR. So the "_cb" functions are executed in the main loop and the "...
You're the one repling like you're on twitter, this isn't personal
It's the way how it used here in this repro. Feel free to prove me wrong by pointing to a function referred as callback in its name which isn't called indirectly in the main loop. Would be appreciated...
Please calm down friends, it's just a hobbits project we are not NASA :)
It happens sometime we have different working style / understanding of a problem, not means others is wrong.
Related area
extending class driver
Hardware specification
N/A
Is your feature request related to a problem?
Currently, a project needs to select the number of class descriptors at compile time. In most use cases, this is great as it is well known the exact number of each type of USB device an MCU wants to be. But what about cases where this isn't known? In my case, I'd like to make prebuilt binaries of this library for multiple architectures. These binaries can be linked in...
I will also like to add that I'd be interested in working on this, when I get free time. π
yeah, thank for the info, I should have checked errata. As tested, I also saw it in the bulk in as well (12 instead 13 bytes for msc status) which is more severe as there is no walkaround.
A quick look around, and there is tons of errata, tx data corruption 3.22 is also severe
I could add wal...
But what about cases where this isn't known? In my case, I'd like to make prebuilt binaries of this library for multiple architectures. These binaries can be linked into any kind of application. The number of interfaces won't be known at the compile time of the binary.
can you elaborate with examples, I don't see why we need to make any changes for this.
@HiFiPhile why would you limit the serial number to 8 characters, wouldn't be simpler to use it as it is ?
For some historical reason my udev script cut serial number to 8 characters.
In fact udev rule is not even needed, cdc can be accessed by /dev/serial/by-id/usb-TinyUSB_TinyUSB_Device_41003B000E504E5457323020-if00
yeah, I figure that out as well. I have already made the changes, just want double check if you first. The id is also shorten in blk device, if it only impact serial, then we are probably safe to remove the cut ?
def get_serial_dev(id, product, ifnum):
# get usb serial by id
return f'/dev/serial/by-id/usb-TinyUSB_{product}_{id}-if{ifnum:02d}'
def get_disk_dev(id, lun):
# get usb disk by id
return f'/dev/disk/by-id/usb-TinyUSB_Mass_Storage_{id}-0:{lun}'
...
The id is also shorten in blk device, if it only impact serial, then we are probably safe to remove the cut ?
Yes you are right.
since I am in the middle of this, let me try to do this as well. At worst, we could revert if I messed up :)
Sure. Please correct me if there is already a way to support remotely allocated storage for this project or if this isn't necessary to support multiple USB ports at runtime. To clarify my goal, I would like to build a prebuilt binary version of this library for the set of processors I plan to deploy to. A small example of those would be Cortex-M0+, Cortex-M3 and Cortex-M4 processors. Having these singular prebuilt binaries means that I can link them to any application that wants to support US...
I pushed my changes which include:
- add lpc54608 board, similar to 54628
- work-around for lpc54 mcu, msc disk appears but the mcu is too troublesome, it still reset randomly, and failed with hid_boot_interfaces, probably due to USB.15 (TX corruption) and/or other usb errata. So I decide it is better to not include lpc54 into the test farm since it will be a headache in the future.
- update hitl_test script and json to simplify the json configuration. by default, all tests will be run. js...
this is where the script is run, CI compile with IAR using cmake build in previous step. We could pick up the elf. This will conveniently test IAR for us as well. (normally I only test with gcc)
everything seems to work well now, except for the lpc54 which has horrible usb hs implementation. The MSC still use the 8 byte ID ( didn't manage time to update that). But it is all good for the merge. We can update thing later with follow-up PRs. @HiFiPhile let me know if you are ok with my changes, and/or want to make more changes.
before I forgot here is the lpc54 setting, should we want to re-add it later (couldn't find way to comment out in json)
{
"name": "lpcxpresso54608",
"uid": "0123456789ABCDEF",
"debugger": "jlink",
"debugger_sn": "727600775",
"cpu": "LPC54608J512",
"tests_skip": [
"cdc_msc"
]
}
Perfect it's good for me, maybe also let it run for GCC build.
Perfect it's good for me, maybe also let it run for GCC build.
yeah, that is possible as well, though I think we are good enough for now. Since we do generally test with gcc when developement. IAR is much rarer, so I am glad it is covered by HIL. Thank you very much for work and VM/board farm for doing actual test.
I was looking through the code today and I think the cdc_dual_ports is a great example. In the tusb_config.h, CFG_TUD_CDC is set to 2, which sets the size of https://github.com/hathach/tinyusb/blob/92457ec99f1690b772ef9fa6b348256701c7fcf7/src/class/cdc/cdc_device.c#L86. Now if I wanted to make prebuilt binaries for Cortex M3 processors to support multiple applications, I would need to make a prebuilt bina...
Get 3DEXPERIENCE SOLIDWORKS for Makers (20% Off $99USD/year!)Β at https://lmg.gg/3DSW or learn more at https://lmg.gg/f03c8
Save 10% and Free Shipping at Ridge by using offer code LINUS at https://www.ridge.com/LINUS
How many USB devices can be plugged into a PC at one time? It's a reasonable question, but the answer is more complicated than yo...
it hurts, when youve been reading usb specs for weeks
and then linus claims usb includes the full route in the address of usb packets
facepalm
and now he is confused as to why 250 ENDPOINTS are working, when the address limit is 127
though he is now starting to explain some more about endpoints
I've added a LPCXpresso4367 to replace 54608, it passes all tests with EA4357 BSP. I think it's good to have chipidea_hs tested.
PS1:
Can we modify Make to build both FS & HS option for stm32f746 ? Since HS use external phy I think it worth to test both.
PS2:
Potential null pointer dereference building host example for ea4357.
/home/tusb/tinyusb/src/portable/ehci/ehci.c: In function 'hcd_edpt_xfer.constprop':
/home/tusb/tinyusb/src/portable/ehci/ehci.c:459:5: error: potential n...
Hmm, I guess you are right and it can cause issues for some very rare things. Like timing related stings in a communication mesh. For example when different SPI secondaries need to be accessed in a very specific order.
@robust walrus after a few more days work, i now have tinyusb dwc2 working on both VPU and aarch64
its able to load a Image file from ext4 on usb, and execute linux
and linux is then able to mount the rootfs, and begin booting (but the systemd starts being a pita)
ive also talked to somebody else about xhci, and found a potential issue with tinyusb/xhci support
the xhci controller will automatically assign an address and issue the SetAddress control transfer for you, skipping a few steps in tinyusb's state machine
so that state machine would need special states for xhci
Describe the PR
removed obsolete tud_network_link_state_cb()
Additional context
That's host support on dwc2 right? Have you made a PR?
Nice work!
yep, dwc host support
no PR yet, and i'm heavily relying on LK primitives (events, timers) in the HCD
so it wouldnt work outside of my kernel
part of the problem, is that interrupt endpoints are 100% manual
so when an interrupt endpoint NAK's, i have to schedule a timer to try again later
and the existing OSAL lacks timer support
though, i could modify it, to just have a big queue of things, and retry on the next SOF IRQ
i'm also using malloc in many places in the HCD
and from what ive seen, tinyusb seems to be anti-malloc
and i'm still missing split transaction support, so no LS/FS devices
yup, anti malloc
that's best for circuitpython and micropython because their main heap gets torn down and recreated every VM
so i would need to kind of re-design the entire HCD, to suit tinyusb's expectations
but i at least have a working example now, and a far better understanding of the hw
π
i also discovered a nasty bug, in the MSD support
xhci would be so cool to support π
host support is all very new so I'm not surprised
tinyusb does not support 2 concurrent reads, and has zero protections to stop you from trying that
due to the lack of malloc, it uses a static buffer for state
and a second read, just overwrites the buffer, and then when 2 replies come in, it goes nuts π
i discovered that, when implementing bad-apple
i opened 2 files, in 2 different threads, bad-apple.bin (the video), and bad-apple.wav
haha, uh oh!
had to wrap the MSD functions in a mutex to make it functional
but i did also notice another thing
every scsi command, has a 32bit tag
i think the intent, is that the usb drive can send replies out of order
and you use the tag to send the reply to the right client
so, if tinyusb just staticly allocates say 4 buffers per drive
then it can support 4 concurrent reads at once
and still route the replies back to the right thread
but currently, tinyusb hard-codes that 32bit tag, to TUSB
π
and when i went to actually use the usb heavily, my old friend corrupt packets returned!
there is a config bug, where tcp packets get silently corrupted
as best as i can tell, the usb NIC (smsc95xx) validates the tcp checksums for you
then sends packets over usb (which has its own checksums)
and linux trusts that the smsc95xx and usb are doing their job, and doesnt check checksums
*REG32(USB_GVBUSDRV) = (*REG32(USB_GVBUSDRV) & 0xFFF0FFFF) | 0xD0000;
if this line of code is missing from the firmware, then something in that whole chain messes up
and tcp packets get corrupted without any warning signs
you wont notice until ssh/https get upset
i had disabled that, because it was breaking my HCD, back before i had proper reset logic
@hathach If you require a C only solution, then macros like these should do the trick.
In file usbh_classdriver.h
/*
To define your own USB Host driver(s), invoke this macro one or more times in the definition of the
CFG_TUH_EXTERNAL_DRIVERS macro in your local tuh_config.h file
*/
#define TUH_MAKE_EXTERNAL_DRIVER(ex_name, ex_init, ex_open, ex_set_config, ex_xfer_cb, close) \
{ \
DRIVER_NAME(ex_name) \
.init = ex_init, \
.open = ex_open...
[ 12.847507] FIQ FSM acceleration enabled for :
[ 12.847507] Non-periodic Split Transactions
[ 12.847507] Periodic Split Transactions
[ 12.847507] High-Speed Isochronous Endpoints
[ 12.847507] Interrupt/Control Split Transaction hack enabled
noticed this in the dmesg while booting linux
and now that i know usb more, i can make sense of this
thanks @rppicomidi , we will probably go with the same approach used by custom device class driver with callback for consitency. Also back then we once considered a smilar approach like your suggestion, but espressif team insist on dynamic drivers to only load them once enabled, which I think kind of making sense. I forgot the detail, but you could go through the long discussion in following issues
ah thanks, I also have LPCXpresso43s67, I can help adding bsp and testing this out.
Can we modify Make to build both FS & HS option for stm32f746 ? Since HS use external phy I think it worth to test both.
Yeah, sure, I would love to, we will need
- add addtional json field for compile argument e.g
PORT=0(may need to duplicate f476 in json) - update test scrip to build to build with extra compile argument and run test on f746
You don't have to do this, give me a bit of time, I...
CFG_TUD_HID is maximum HID interfaces tinyusb can support, it does not dictact number of HID in use. That is dictacted by configuration descriptors. What is your max HID for all cases, just define CFG_TUD_HID to that number. If it isn't terribly high number, it won't cost much of sram.
late response as usual, seems like there is a bit of heated dicussion in this issue, I hope we are still cool and don't take that personal.
Hi hathach, ive added in the SOF callback to the HID driver specifically for fast mouse response and minimum latency.
I've put it here since I would like to use tinyUSB to follow the current fastest open-source mouse firmware on the market in terms of click latency (after razer)
https://github.com/zaunkoenig-firmware/m2k-firmware/blob/main/mo...
@hathach
Why was is renamed, what was the issue with the existing code?
Because that function pointer is executed within the ISR and not like a callback in the main loop I would think it helps to understand the code better if that suffix is used.
@hathach
What's missing and should be re-added? The linked PR is merged? Do you mean the function to dynamically set the SOF ISR function?
@hathach What's missing and should be re-added? The linked PR is merged. Do you mean the function to dynamically set the SOF ISR function?
If that is supposed to be controlled by the individual implementation why is there one already present just for audio?
I just removed that in one of follow-up PR along with other managing code, forgot which one. Yeah, we can re-add that generic code to enable SOF
void tud_sof_isr_set(tud_sof_isr_t sof_isr);
Though, maybe we sho...
Describe the PR
Update lpc43 to support adding it to HIL test board farm
- Add lpc43s67 board
- Also add add board_get_unique_id() for lpc43
#2217 add lpc43s67 since it is what I got. I guess it is probably run fine with your non-s board. If it is not the case we can change the jlink device to non-s verion. Also add uuid support lpc43. Let me know if those are now working with your hil setup there :)
I can confirm it works well, here is the config diff if you want to include in the pr.
I would prefer to have both, a SOF callback which is executed by tud_task() in the main loop and one separated from this in the ISR. For the first there is already a PR #2213.
Describe the PR
In dcd_synopsys.c, the FIFO is not flushed after configuration. This causes some problems when I'm porting TinyUSB to my GD32F470 board. Since I don't have a STM32 board at hand, I'm not sure if it's necessary on STM32 boards.
Describe the PR
Adds a MIN() check for the bufsize on cdc reads and writes. This is to avoid a loop where the 'bufsize' passed to 'tud_cdc_write()' or 'tud_cdc_read()' is '65536' (or a multiple) causing nothing to be written/read.
Additional context
Casting values to uint16_t greater than UINT16_MAX just truncates the upper bits, which means if bufsize ends up being 65536 (or a multiple) it results in the uint16_t cast giving a value of 0, causing no read/write to o...
CFG_TUD_HIDis maximum HID interfaces tinyusb can support, it does not dictact number of HID in use. That is dictacted by configuration descriptors. What is your max HID for all cases, just define CFG_TUD_HID to that number. If it isn't terribly high number, it won't cost much of sram.
I'm building a library that others will consume that uses this project, therefore I cannot know what circumstances a user of the library will find themselves in and thus I cannot define a hardcoded value...
- Opens the driver SOF which is executed in the ISR to be changed by the vendor if the CFG_TUD_VENDOR configuration is used as a device driver
The issue right now with setting the function pointer for a driver specific SOF callback (here used in a common sense), which is executed within the ISR, is that this would need to know to which driver it should be applied in the case multiple configurations are used. The driver name is only present on a debug level so that can't be used.
Because of this I think it would be better to let it as is so that the SOF ISR is purely driver related. Meaning if that behavior should be changed or co...
The TU_ATTR_WEAK symbol isn't working for me, possible that .sof = tud_vendor_sof_isr would be enough.
I would prefer to have both, a more general SOF callback which is weak and executed by tud_task() and so within the main loop and one separated from this in the ISR for driver specific things. For the first there is already a PR https://github.com/hathach/tinyusb/pull/2213.
I used to think of deferred SOF, but from last work with audio feedback. I am not quite sure if we still need that. what is point of SOF where is not invoked in the start of frame, other transferred is probably comple...
I'm not really sure what you mean...
For me there are two places, executed a bit later in the main loop via a general callback and or directly when the MCU handles the SOF interrupt via a specific driver callback. I also don't get why you mentioning tud_sof_enable() because controlling if the MCU should react to a SOF package or not is independent what the application should do when this occur and can be handled.
I also think a vendor defined driver should have full control and I don'...
oh, I can see your point now. This will require all the changes across all drivers, but there is a few gotchas
- internal buffer also has other resitriction on endpoint alignment and address range depending on mcus.
- The internal interface typedef struct won't be made public, therefore the set interface is probably just supply buffer + size and get the number of inteface it got in return. Maybe we can have an get size function. But that would be needed for every class driver.
- The set...
sof_isr in usbd driver is only available for driver that can be managed by usbd, e.g audio with feedback enpoint is enabled, sof is enabled, and disable along with the interface. I don't see the point to add sof_isr for vendor. Vendor manage SOF in application and should use the generic tud_sof_enable()
How is a vendor driver not managed by usbd? I don't get it. If that is the case it makes absolutely no sense for me that there is a CFG_TUD_VENDOR driver.
not all thing we thought might be needed will be added though. Only thing that we are sure people will use. I don't see the point to calculate start of SOF ISR with SOF_CB. When you need SOF_ISR, you need it because you have to do something on-time, otherwise something else will break.
SOF interrupt is not always enabled since it interrupt 1 every 1ms which hurt performance and ampere. When will vendor eanble sof, and when will it disable sof interrupt ? Read my above explanation for audio sof for feedback endpoint.
look good, would you mind changing TU_MIN() to tu_min16() i.e
uint32_t num_read = tu_fifo_read_n(&p_cdc->rx_ff, buffer,
tu_min16(bufsize, UINT16_MAX));
look good, would you mind changing TU_MIN() to tu_min16() i.e
uint32_t num_read = tu_fifo_read_n(&p_cdc->rx_ff, buffer, tu_min16(bufsize, UINT16_MAX));
I think that would result in the same issue right? Since arg is type uint16_t would just cast bufsize and do the same thing
I think that would result in the same issue right? Since arg is type
uint16_twould just castbufsizeand do the same thing
Ah you are right, my bad :)
thank you, we can use tu_min32, but i guess it is not really matter in this case.
Awesome! With your blessing, I'll start work on this. Thank you for considering this feature.
I can confirm it works well, here is the config diff if you want to include in the pr.
Thank you, I update PR to add IAR build support for lpc43 (via cmake) and added your json entry. Everything works perfect now.
Again, yes the control of that is missing. The code I use so far is much older and rely on a symbol (USE_SOF) where it's always on or off. Indeed a dynamic control of that is the preferred way and for this reason I'm currently adding it to the PR #2213.
It also doesn't matter if it hurts performance when it's needed. Of course it should be off when it's not currently needed. What's the preferred way if an implementation wants to have it's own audio driver with endpoint control? I would i...
Awesome! With your blessing, I'll start work on this. Thank you for considering this feature.
please start with HID only as draft PR, before applies to other drivers, just to make sure you don't have to change too many places. Also if possible be sure to test it on your lib with actual hardware as well.
I'm still irritated why you think a vendor driver isn't controlled by usbd.
English is not my first language, and I don't like to read and type much text. vendor sof is not auto managed by usdb, application turn it on and off by itself and stay permanently after that. Audio sof is only enabled when needed in run time by usbd.
@hathach That method works too. Does your schedule permit you to work on this now? If not, I can work on a pull request.
@hathach That method works too. Does your schedule permit you to work on this now? If not, I can work on a pull request.
yes please, if possible, you could check the usbd implemenation for reference. I always have issue to catch up with PR. I still want to review and merge your midi host, but kept pushing by other works.
English is not my first langue either...
At first I thought I know how a vendor defined device should look like. Due to your feedback I'm not sure anymore. :worried:
I was expecting that each device should have at least one standard class from TinyUSB defined in the tusb_config.h config file. So if no predefined class matches the use case the vendor class should be used instead. But if this isn't the case I don't get why there is a vendor class to begin with if that should not be us...
- webusb example use vendor class
- if there is any double, just check the code.
Ok, thank you.... β€οΈ That helped to understand how you want it to be used.
we should only add sof_isr that can be auto managed (on/off when neede) to class driver e.g audio with feedback enpoint is enabled, sof is enabled, and disable along with the interface. Since HID does not need it function, we can add an generic sof cb in isr for this purpose for app to turn it on and off when it wants. You don't need to make any changes for this PR. I remembered added that sometime ago (then reverted), I could try to re-add it when possible. Thank you for brining up this PR a...
Describe the PR
EHCI: clear qhd halted bit if not caused by STALL protocol to allow for next transfer
@hathach OK. Working on it. Will try to have a solution soon. If it works, I can withdraw my midihost pull request and just maintain the midihost driver out of tree.
I found docs that say you can get pcap data from an ip socket but can't figure out how
tio can do serial -> ip
will circuitpython acitvate the pio-usb host stuff automatically, or do i need to enable something at build time?
is it as simple as just connecting the usb cable to the right pins?
I think its on in the build but you'll need to init it from python
port = usb_host.Port(dp, dm) iirc
ah, manually specify pins, perfect
so i can wire it up the same as the sniffer-lite, and just punch the pin#'s into the repl
probably. I think they need to be consecutive pins but that's probably true for the sniffer too
yeah, so the only issue is if its D+, D-
or D-,D+
I think pio-usb handles both..
dp then dm
actual api to use it: https://docs.circuitpython.org/en/latest/shared-bindings/usb/core/index.html
ive also commited all of my little-kernel/dwc2 stuff to github
and i can now boot linux on my pi3, even when building from a completely clean clone
in the current configuration, i only bring dwc2 online once, in aarch64, to load the linux kernel from usb
and then linux takes over, and finds the rootfs
up next, is confirming that stage1 can still do things, and make it fully self-contained on usb
Describe the PR
This pull request implements a fix to issue #2188. To add an application host driver, implement the callback usbh_app_driver_get_cb().
Additional context
This implementation should be consistent with the usbd_app_driver_get_cb() method implemented for application defined USB device drivers.
@hathach The pull request should be consistent with what was done for the USB device driver side.
Describe the PR
This allows USB host functionality to call HID_REQ_CONTROL_GET_REPORT on the TUSB_DIR_IN direction, and read the report buffer in the callback function.
This extends the functionality of the hid_host.h/.c files and gives the host a way to call the HID get report features.
Additional context
I'm one of the main developers of https://gp2040-ce.info/ and we extensively use the TinyUSB library to handle USB calls. I wanted to try to keep our TUSB host code as hid_h...
>>> port = usb_host.Port(microcontroller.pin.GPIO10,microcontroller.pin.GPIO11)
nothing seems to be happening
[Tue Aug 15 02:15:30 2023] usb 1-11.1.2: New USB device found, idVendor=0930, idProduct=6544, bcdDevice= 1.00
[Tue Aug 15 02:15:30 2023] usb 1-11.1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[Tue Aug 15 02:15:30 2023] usb 1-11.1.2: Product: USB Flash Memory
[Tue Aug 15 02:15:30 2023] usb 1-11.1.2: Manufacturer:
[Tue Aug 15 02:15:30 2023] usb 1-11.1.2: SerialNumber: 001D92DC4AF9C8C153B703E7
vs
>>> dev.idVendor
2352
>>> dev.idProduct
25924
>>> dev.serial_number
'001D92DC4AF9C8C153B703E7'
i think that just worked?
vid/pid do match
>>> dev = usb.core.find()
>>> dev.idVendor
1267
>>> dev.idProduct
420
>>> dev.serial_number
i typed those commands, from my usb keyboard, plugged into pins 10/11
everything ive tried works, when tannewt gets back tomorrow, you can tell me what you did to break it, and how to access MSD, and i can poke at it more
thank you everything look great, I have go through the changes. and also add a few changes and rename as well to be consistent with usbd.
thanks, this remind me to double check usbd, for reason why I write it a bit compliated there. Seem like I was trying to give clue to compiler to optimize out when driver callback is not available. Though, think again now, it only for link time optimization (LTO), and does not seem to save much code as well. This is much cleaner code. thanks
@hathach @abakosh Sup. I also ran into this problem, but on RP2040. Do I understand correctly that this hack will help me solve this problem on RP2040, if I don't use the hub? Do you see any pitfalls with this?
all is good, thank you very much for your PR. After this is merged, if posible, please keep the midihost pr open, I really want to merge that one, but haven't got time just yet due to crzay work previously. Will try to wrap it up soon enough.
closed by #2222, thank you @rppicomidi for your work. If posible, please keep the midihost pr open, I really want to merge that one, but haven't got time just yet due to crzay work previously. Will try to wrap it up soon enough. You can actual use external for developement since external has more priority than built-in, and we could sync once after a while or so. That would allow to more peoeple to work on the driver.
sof must be explicitly enable/disable with additional API
Here is the MSD example: https://github.com/adafruit/Adafruit_CircuitPython_USB_Host_Mass_Storage/blob/main/examples/usb_host_mass_storage_simpletest.py
The crash I was seeing was done by connecting a second CP device to the first
ah, we are in luck then, i also have a sparkfun pro micro rp2040
so i can just build for the other board, and connect them together
if its anything like what i saw during the livestream, the pio-usb is sending a double setup due to a missed ack
and the TUD stack gets upset by that, while a real usb device doesnt
with https://github.com/librerpi/lk-overlay/tree/master/lib/tinyusb/manual i can manually do a double-setup on a pi-zero connected to circuitpython, and stress just the device end
but i need some sleep first
As @hathach said, it is hacky, not a clean way. However, for me, it works perfectly. The pitful will be if the port is supporting a hub or if the rp2040 usb supports two ports as well that you are using as a host. In a single port full speed host for mass storage, this hack will work like a charm π, please let me know if it works for you
Related area
Run complex (hub/multidevice) setups connected to the BL616 host
Hardware specification
BouffaloLabs BL616
Is your feature request related to a problem?
I recently stumbled upon the BouffaloLabs BL616 which is a cheap Risc-V microcontroller coming with WiFi and Bluetooth and some other interesting peripherals incl. a EHCI controller. The BL616 seems to target the same audience as the ESP32 and is roughly comparable.
This BouffaloLab SDK comes with cherryUSB ...
@abakosh It seems it's working great in my case. I came across this today and came to almost the same solution as you. As far as I understand, the RP2040 has one port, so everything should be fine.
The mcu looks interesting, unfortunately I have no plan to support this anytime soon yet.
Thanks for the fast reply, anyway.
I might give it a try myself. I still don't fully understand how these devices with just the EHCI controllers work with low and full speed. But as I have received data from a keyboard it's definitely possible.
I read that TinyUSB has support for H7-MCUs, so H5 shouldn't be a technical issue.
Does anyone have this working on the H7 yet? Maybe there is a code example that could be ported to H5?
Thank you @rppicomidi and @hathach, this worked perfectly! I was able to pretty easily wrap my xinput_host into an external app_driver using the usb_midi_host repo as an example. ππ
I will clean things up and update my tusb_xinput repo. But now all I can think about is mapping MIDI keyboards to be video game controllers. π
From what I have seen in the datasheet, it looks like the USB peripheral from the H5 might be the same as that in the G0 family (at least register names seem to match) but I haven't looked in the details yet
At this point, this pull request is obsolete. Merged pull request #1434 implemented RP2040 bulk endpoints more cleanly. Some of the other changes I made are either already in TinyUSB from other pull requests or have been implemented in TinyUSB in an equally functional way. Pull request #1627 fixed several bugs in this pull request. Finally, I have used the code from #1627 to create this application host driver; the driver also implements BULK IN ...
Operating System
Windows 11
Board
f1c100s
Firmware
hid generic inout and vendor
What happened ?
I am using F1C100s as the chip for my project. When I use the "hid inout" interface alone or use the vendor interface, which means the USB device has only one interface, everything works perfectly. However, once I set up "hid inout" as interface 1 and vendor as interface 2, tinyusb doesn't respond to the TUSB_DESC_BOS request. I noticed that at this point, CONFIG_TOTAL_LEN ha...
I can confirm this issue on the RetroFlag SNES controller and various 8Bitdo controllers that all seem to exhibit the same boot behavior of cycling through different modes.
I first noticed this issue in the 8BitDo Wireless Adapter 2's latest firmware updates. Then more recently the 8BitDo Ultimate C wired controller and the 8BitDo NEOGEO controller both crash TinyUSB.
When I turn on full logs I can see it hits a *** PANIC *** error stating Invalid speed right before it l...
For example, my VM software (Parallels) detecting the various device modes after plugging in the 8BItdo Wireless Adapter 2.
https://github.com/hathach/tinyusb/assets/2039258/ab33a305-1cc7-4c0d-a7c8-91a466fb06ad
Describe the PR
This is a rewrite of the original NCM device driver. You can check tests concerning functionality and performance here.
Additional context
Buggyness of the current driver can be easily verified with for MSS in 100 200 400 800 1200 1450 1500; do iperf -c 192.168.14.1 -e -i 1 -M $MSS -l 8192 -P 1; sleep 2; done.
I'm using the driver in my own [project](h...
@hathach
Can you please explain why the buffer was renamed? Now the naming is wrong. The buffer represents the transfer buffer and so is independent of the transaction size (the size of the endpoint and so wMaxPacketSize). If the transaction buffer is smaller than the transfer buffer the transfer is split by the host driver into multiple transactions for the HID class.
Meaning the proper name should be transfer_in_buf and transfer_out_buf while the define can be `CFG_TUD_HID_TRANSFE...
+1
This would be great to get merged, as we are seeing the same issue, and this change appears to resolve it.
Hmmm, does anybody read this?
I want to make a proposal: the ncm_device driver seems to be very buggy, e.g. it operates on incoming frames while the previous one is still processed, also it does no ZLP insertion where it should insert one. These bugs are the cause for the above described hickups.
I have implemented a simple version of the driver, which allows only one ethernet frame on reception/transmission.
This would put the focus on reliability, not so much on perfo...
Hello rgrr,
Thanks for finding out these bugs I'll test this on my device and let you know.
Hmmm, does anybody read this?
I want to make a proposal: the ncm_device driver seems to be very buggy, e.g. it operates on incoming frames while the previous one is still processed, also it does no ZLP insertion where it should insert one. These bugs are the cause for the above described hickups.
I have implemented a simple version of the driver, which allows only one ethernet frame on reception/transmission.
This would put the focus on reliability, not so much on perfo...
Note, that there is a pull request #2227 about this. I have done a complete rewrite in the meantime.
rgrr,
Kudos for writing a very clear concise documentation.
I was able to see that the NCM bandwidth increased by a factor or 2 :smile: .
However I observed that as the segment size kept increasing the bandwidth was decreasing.
For segment size > 800 my iperf application crashed.
Currently trying to understand and analyze your changes in the driver.
...
However I observed that as the segment size kept increasing the bandwidth was decreasing. For segment size > 800 my iperf application crashed.
...
Do you have some kind of available test application? What is the exact iperf command line?
Yup I am using standard lwip webserver example from TinyUSB and iperf application from lwip-contrib/examples/lwiperf
I am executing following command.
for MSS in 100 200 400 800 1200 1450 1500; do iperf -c 192.168.7.1 -e -i 1 -M $MSS -l 8192 -P 1; sleep 2; done
Here are the logs that I am getting.
Iperf logs
WARNING: attempt to set TCP maximum segment size to 100, but got 536
------------------------------------------------------------
Client connecting to 192....
ooopssss... and the example is running with ECM/RNDIS?
"request blocked" is not bad, but the "VALIDATION FAILED" messages are fatal. Possible reasons that come to my mind:
- bad glue code (but if ECM/RNDIS are working this should not be the case)
- memory alignment problem of the buffer (when I'm counting correctly, the ncm_interface buffers could land at an 16bit boundary if the struct is packed)
- buffer is not valid (but why?)
What I also do not understand is "WARNING: attempt ...
It is possible, that I have created a dependency of the driver with my glue code to TinyUSB. The suspicious part looks like:
static void context_tinyusb_linkoutput(void *param)
/**
* Put \a xmt_buff into TinyUSB.
*
* Context: TinyUSB
*/
{
if ( !tud_network_can_xmit(xmt_buff_len)) {
//printf("context_tinyusb_linkoutput: sleep\n");
vTaskDelay(pdMS_TO_TICKS(5));
taskDISABLE_INTERRUPTS();
usbd_defer_func(context_tinyusb_linkoutput, NU...
Ok, first check shows, that with the lwip-webserver example it is running as well. Little bit slow, but anyway.
You can find the sources here: https://github.com/rgrr/tinyusb/tree/feature/standard-webserver/examples/device/net_lwip_webserver
Operating System
RaspberryPi OS
Board
Rasberry pi pico
Firmware
any
What happened ?
Function "get_new_address" in "usbh.c" is bugged and delivers wrong address.
It tests for a usb host device that is not connected, and then returns that device address + 1.
It looks like the idea is to not return a 0 which later is tested as illegal address.
However, the next time a call is made to "get_new_address", the same unconnected device is found and the same device address + 1...
Operating System
Linux
Board
RPi Pico
Firmware
examples/device/usbtmc
What happened ?
When issuing read() to provoke timeout the device becomes unusable. It does not respond to new commands anymore; needs to be power cycled.
How to reproduce ?
Issue read() without prior write(). The command will timeout. Trying to do a clear() with result in endless messages from host to device without positive result ; i.e. any new command results in timeout. See log files for st...
For applications that need HID report protocol instead of HID boot protocol, changing the default with tuh_hid_set_default_protocol() is simpler than changing for the devices one by one.
rgrr,
I confirmed that , lwip-webserver is also running fine on my platform.
"WARNING: attempt to set TCP maximum segment size to 100, but got 536". That also indicates that something is really wrong.
I suspect that this definitely indicates some problem. Also it works for smaller segment sizes but as I increase the segment size the bandwidth decreases and later point driver just crashes.
:(
I need to thoroughly understand the code changes that you made and what problems i...
Describe the PR
A clear and concise description of what this PR solve.
Additional context
If applicable, add any other context about the PR and/or screenshots here.
thank you very much for your PR. I have rename the option from OPT_MCU_KINETIS_K64 to simply OPT_MCU_KINETIS_K since it seems to be the name of family of those m4f.
I have tried to add kinetis_k to bsp with teensy_35 board to test with this PR. Unfortunately teensy 3.5 is not able to blink led with board_test example. It is probably due to clock config. I push the changes anyway, will try to find an k64f board later to test with. Menanwhile please be patient.
Operating System
Windows 11
Board
DevEBox STM32F407
Firmware
Created very basic test project with STM32CubeIDE and followed https://github.com/hathach/tinyusb/discussions/633 with current master branch. Used https://github.com/hathach/tinyusb/tree/master/examples/device/cdc_dual_ports as template.
Relevant/modified lines in tusb_config.h are:
#define CFG_TUSB_MCU OPT_MCU_STM32F4
#define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE | OPT_MODE_FULL_SPEED)
#define CFG...
STM32F407 doesn't support cdc_dual_ports example, as it has too few endpoints:
:( I need to thoroughly understand the code changes that you made and the specific problems it is fixing in the original ncm driver. After this only I will be able to better deduce what is causing this problem. Is it the TinyUSB ? or class driver ? Or my device specific dcd.c implementation.
Please consider ncm_device as a rewrite. I have dropped more or less the original and started fresh but used the original as a template for some things.
Problem with the original ncm_device was, ...
I get this error, even with current git HEAD. For some devices (including hub) consistently each time the device is disconnected, for other occasionally, but still often. And the PANIC makes whole device inoperableΒ β a library should behave much more robust, even in unexpected conditions.
Operating System
Linux
Board
Raspberry Pi Pico
Firmware
examples/host/cdc_msc_hid
What happened ?
When hub is connected device seems stuck in a loop instead of detecting the hub connected. When disconnecting the hub it panics with 'Invalid speed'. The same hub works correctly with Linux PC, a different hub works with the same Pico.
How to reproduce ?
- compile the example with:
make BOARD=raspberry_pi_pico all LOG=2 - flash it to the Rasbperry Pi Pico
3....
I think the problem here is the different semantics of weak functions in Keil and in the GCC.
I solved the problem by removing TA_ATTR_WEAK from:
void dcd_edpt0_status_complete(uint8_t rhport, tusb_control_request_t const * request);
In usbd_control.c I added an empty, yet weak declaration:
TU_ATTR_WEAK void dcd_edpt0_status_complete(uint8_t rhport, tusb_control_request_t const * request)
{
(void)rhport;
(void)request;
}
In "usbd_control_xfer_cb" I removed the check for the...
The Keil compiler seems to have different semantics and the defined function was never called.
The same is probably true for the other weak functions. I can change those too.
Describe the PR
A clear and concise description of what this PR solve.
Additional context
If applicable, add any other context about the PR and/or screenshots here.
I tried to use this. One sticking point was that setting CFG_TUD_LOG_LEVEL failed to find corresponding macros for the given level. It may be better to pick a specific number to disable them.
"failed to find corresponding macros" I don't quite understand the issue, can you elaborate a bit. What is your setting for CFG_TUD_LOG_LEVEL and CFG_TUSB_LOG.
Thank you for the Pr. Do you check with official doc from keil for this behavior for declared weak function ?
Yes and I have tried this in the code, with Keil and with STM32CubeIDE GCC (since I needed this in my project right now)...
Am 30. August 2023 05:06:15 MESZ schrieb Ha Thach @.***>:
@hathach commented on this pull request.
Thank you for the Pr. Do you check with official doc from keil for this behavior for declared weak function ?
--
Reply to this email directly or view it on GitHub:
https://github.com/hathach/tinyusb/pull/2239#pullrequestreview-1601789495
You are receiv...
can you provide link to keil's official doc for the behavior ?
can you please provide link to keil's official doc for the behavior ?
As usual, the documentation is a bit cryptic:
Also on the same topic:
https://stackoverflow.com/questions/51656838/attribute-weak-and-static-libraries
In my understanding the problem is the difference of the weak declaration vs. the weak de...
won't fix since I don't have device in question. PR is welcome
I would need at least some guide how to debug this and what could be the problem. I hoped someone can see what is wrong by looking at the logs β they are completely incomprehensible to me right now.
Thank you for pointing that out. I would not have believed that a STM32F4 would reach its limits so quickly...
I've been following this thread, interested to know if I can setup TinyUSB for an STM32H7xx MCU for 192 and 384KHz audio streaming and VCom port? Any info on this would be appreciated, thanks, Sorry if this is the wrong thread.
Please don't hijack other issue, which generate meaningless notification for participant. Post it as your own issue/discussion.
Operating System
Windows 10
Board
PCA10056 (nRF52840 Nordic DK)
Firmware
Firmware provides a USB-CDC and puts the received data onto BLE.
The host software opens the COM port, does some communication and closed the COM port. This in a loop.
What happened ?
The communication on device side hangs after a while (depending on luck after 5x the above loop or 200x). It seems that especially the disconnect causes the hangup condition.
Used compiler is clang. Several v...
Right now I am progressing further with the project and I now realize the scope of the problem is bigger. My first thought was, the function above is the only one that is really needed for an implementation. But now I have come to realize TU_ATTR_WEAK functions are all over the place (well, at least several of them).
So, the right thing to do would be to change the semantics of all the callbacks and provide a default implementation for any callbacks that are optional. The return value of t...
hothach sorry I saw that this was an STM MCU limitation, so didn't think it so out of line to ask about the STM32H7 series.
I will search for a thread related to that instead. Have a nice day!
I have taken a reference of glue logic from
https://github.com/rgrr/yapicoprobe/blob/feature/minor-cleanup/src/net/net_glue.c
Implemented the same.
As I increased the TinyUSB buffer size, the test case work for all segment size. :smiley:
iperf command used:
for LEN in 40000 16000 1400 1024 800 200 80 22 8 2 1; do for MSS in 90 93 100 150 200 255 256 300 400 500 511 512 600 700 800 900 1000 1100 1200 1300 1400 1450 1459 1460 1500; do iperf -c 192.168.14.1 -e -i 1 -l $LE...
Actually I have no idea what the bottleneck could be. Have you checked the wireshark log if you see the expected? Perhaps your iperf behaves not as you want.
Your iperf output:
Client connecting to 192.168.7.1, TCP port 5001 with pid 1792756
Write buffer size: 100 Byte
TCP window size: 40.0 KByte (default)
Mine (2.1.9):
Client connecting to 192.168.14.1, TCP port 5001 with pid 18915 (1 flows)
Write buffer size: 40000 Byte
MSS req size 600 bytes (per TCP_MAXSEG)
...
Your link is pointed to armclang (which is different from keil armcc). From keil doc, look like it should work well with current code https://developer.arm.com/documentation/dui0375/g/Compiler-specific-Features/--weak
__weak
This keyword instructs the compiler to export symbols weakly.
The __weak keyword can be applied to function and variable declarations, and to function definitions.
Usage
Functions and variable declarations
For declarations, this storage class specifies an...
Actually I have no idea what the bottleneck could be. Have you checked the wireshark log if you see the expected? Perhaps your iperf behaves not as you want.
Tried with iperf 2.1.9 same result
- According to analysis, this version of ncm driver is definitely much better than previous version.
Can you explain what is the expectation with glue code logic ? So that if possible we can think in that direction.
Also with little clean up https://github.com/hathach/tinyusb/pull/2227 ...
Can we us the debug macros defined in tusb_debug.h ?
Can we add these config is tud_config.h in lwip_webserver example ?
can we make comment format consistent with tinyUSB ?
Expectations with glue logic: there should be an official call to put an event into the TinyUSB event queue so that one get into the context of TinyUSB. lwIP API offers tcpip_try_callback() or tcpip_callback(). Currently one has to use usbd_defer_func() which is actually TinyUSB private and also does just block USB interrupts.
Clean up: will follow soon.
Currently I cannot see any further improvement. Perhaps wider use of the net_device will open some new wishes/issues.
One point for improvement could be to change the webserver example to use NCM by default.
This would improve compatibility over the several OSes, because NCM is supported by Linux, MacOS (AFAIK), Win11 (AFAIK) and Win10 (with minor driver installation).
With ECM or RNDIS I had no luck under Win10, at least on my machine.
not sure about this: what are the TinyUSB comment conventions?
One more thing (out of topic): how about adding iperf to the webserver example to get a reference example for performance measurements?
Out of curiosity: have you ever compared with ECM/RNDIS? And have you done a bidirectional test with e.g.
for MSS in 100 800 1450; do iperf -c 192.168.14.1 -e -i 1 -M $MSS -l 8192 -r; sleep 2; done?
((to me) surprisingly server-to-client does not work for small packets)
Describe the PR
Select ECM for small devices, select NCM + iperf for bigger devices.
This covers more modules during build time and also allows simple performance measurements with an example.
Additional context
This is for the net_lwip_webserver
What about in the case of using TinyUSB as a host device reading a HID keyboard? Appears the built-in support is for hid keyboard boot mode which reports only 6 keys. From what I understand there is a command that must be sent to a keyboard from a host device to enable full NKRO mode. Is this correct and are there any known examples?
This would improve compatibility over the several OSes, because NCM is supported by Linux, MacOS (AFAIK), Win11 (AFAIK) and Win10 (with minor driver installation).
As far as I know RNDIS is windows standard offering and Linux also supports RNDIS by default. Where as in NCM extra driver installation is required. Thus it is okay to keep RNDIS as default.
: how about adding iperf to the webserver example to get a reference example for performance measurements?
lwip Iperf will be ...
Hello all,
This issue has been mentioned in the tiny usb official example (examples/host/bare_api/src/main.c) and it can be easily reproduced.
Is there any workaround to detect multiple devices connected to a hub then connect the hub to the tinyusb host?
Thank you in advance for your feedback
Best regards,
Moctar
yes, that is a valid point: RNDIS is correctly detected by Win10. But there are some drawbacks: RNDIS changes somehow routing of my Linux desktop (Debian) and also RNDIS works only under Win10 if it is the only class of the USB device. So actually not a generic solution.
Nevertheless as an example RNDIS should do it.
But: those examples aren't just examples. To my understanding they are also some kind of compilation test. So if all examples go for RNDIS, the NCM device will not be c...
@Keval-Joshi-TI : "funny" thing, if you limit in lwiperf_tcp_client_send_more() (in lwiperf.c) the txlen_max to 700 (instead of TCP_MSS) then iperf -c 192.168.14.1 -e -i 1 -M 100 -l 8192 -r succeeds.
Don't know yet, if this indicates a bug in lwiperf, lwIP, TinyUSB or the device driver (but ECM shows the same behavior).
Comparing ECM / NCM shows that NCM is factor 4 better in direction device -> host.
PS: actual problem is, that tcp_output() does not create a lwiperf_tcp_client_sen...
Hardy: I am stuck at more basic problem.
Even with your suggested change int the lwip example DEV-> HOST transfer is not happening in my case :(
------------------------------------------------------------
Client connecting to 192.168.7.1, TCP port 5001 with pid 3025046 (1 flows)
Write buffer size: 8192 Byte
MSS req size 100 bytes (per TCP_MAXSEG)
TOS set to 0x0 (Nagle on)
TCP window size: 16.0 KByte (default)
------------------------------------------------------------...
Hardy : I am stuck at more basic problem.
Even with your suggested change int the lwip example DEV-> HOST transfer is not happening in my case :(
------------------------------------------------------------
Client connecting to 192.168.7.1, TCP port 5001 with pid 3025046 (1 flows)
Write buffer size: 8192 Byte
MSS req size 100 bytes (per TCP_MAXSEG)
TOS set to 0x0 (Nagle on)
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
...
Perhaps our lwIP configuration is different. Essential parts of mine:
#define TCP_MSS (1500 - 20 - 20) // MTU minus header sizes (best value til now)
#define TCP_SND_BUF (8 * TCP_MSS) // good tuning
#define TCP_SND_QUEUELEN 16
#define TCP_SNDQUEUELOWAT (TCP_SND_QUEUELEN / 2)
#define MEMP_NUM_TCP_SEG 32
#define MEM_SIZE ...
Describe the PR
I added support for the NUCLEO-U575ZI-Q (https://www.st.com/en/evaluation-tools/nucleo-u575zi-q.html) from ST to the stm32u5 bsp.
Fix the fact that MSD status msg sometimes goes in the payload of data read from disk
This fixes: https://github.com/arduino/ArduinoCore-renesas/issues/84
The problem: when issuing a reading command on MSD class, sometimes data read form disk (QSPI flash device) are corrupted with status message (the one that should "end" the transmission of data read from disk, i.e. "USBS..."). According to our analysis this is due to the fact given that MSC_STAGE_STATUS case is executed always "after" t...
I guess that the following place is good to wait for the HW pipe FIFO to be empty. At the last packet of an IN transaction, it will wait for the HW pipe to be empty.
if data are still present in the hw pipe fifo while the status message is sent by the function, the status message overwrites part of the data present in the hw pipe fifo.
For efficient handling ...
gosh... sometimes it is more complicated... I have to correct myself: the above loop does not work, the one with the usbd_defer_func() is the correct one. And this is also true for ECM/RNDIS: they do fine with the defer loop but not with the simple loop from above. I will investigate this further if there is time, but I guess the simple loop blocks TinyUSB while it actually wants something to do. The problems appears for ECM immediately, for NCM (because of better buffering) for very smal...
Describe the PR
add cmake support for samd21 and samd51
@rgrr :
Concerning lwiperf: the problem with the sender operations lies within the condition of the do-while-loop in lwiperf_tcp_client_send_more(). The condition txlen >= (TCP_MSS / 2) is too limiting, because for -M 100 the call to tcp_write() does not succeed and thus there is no data in the buffer which stops transmission.
Replacing the above condition with txlen != 0 solves this and lwiperf sends data correctly.
Even with above mentioned change rx is not working in my case.
...
@rgrr :
NCM driver worked for me for all segment sizes.
When lwip_task priority == tud_task priority it works well and as expected.
I am trying to get iperf -r working on my platform.
My device is a Raspi Pico (RP2040), i.e. dual-core Cortex-M0. TinyUSB has higher priority than lwIP. I will test, if it matters which process has higher priority (both processes are limited to one core).
lwiperf: I inserted several printf() for debugging. They pointed very fast to the loop in lwiperf_tcp_client_send_more().
What is your current glue code? Especially if you are using TinyUSB I would use mine ;-)
Just since I'm also using the NCM device and didn't experience any problem with my RP2040-based project up to now: @rgrr: You are using an RTOS? I'm going bare-metal. In case you want to do measurements using my setup (you just need to enable iperf but you know how to do that ;): https://github.com/OpenLightingProject/rp2040-dmxsun
Related area
Please add 16 or 12 bit Analog Trigger Resolution
Hardware specification
rp2040
Is your feature request related to a problem?
I was using the arduino leonardo with Joystick library for my project, which had 16 bit res. support. Now i shifted to the RP2040 platform, i miss that 16 bit resolution support. The arduino-pico core and Pico SDK all use 8 bit internally, which are all derived from you.
Describe the solution you'd like
instead of uint8_t use uint16...
@kripton : does it mean that you are using the new NCM device?
It did not do any tests with your project although I like your work. I stopped when "make" asked for npm :-/
Nevertheless your glue code points me into the direction why the simple loop from above did not work: the call to tud_task() was missing.
Corrected version looks like this:
static void context_tinyusb_linkoutput(void *param)
/**
* Put \a xmt_buff into TinyUSB.
*
* Context: TinyUSB
*/
{
whil...
@kripton : does it mean that you are using the new NCM device?
No, i'm using the original, first version and I did notnface any problems with it.
It did not do any tests with your project although I like your work. I stopped when "make" asked for npm :-/
True, dmxsun is compiling a React web app, Sorry, I know it causes additional effort.
Nevertheless your glue code points me into the direction why the simple loop from above did not work: the call to tud_task() was missing....
@kripton : does it mean that you are using the new NCM device?
No, i'm using the original, first version and I did notnface any problems with it.
You will stumble into problems if the transmitted packets are coming fast and in different sizes. My initial application was SystemView.
Nevertheless your glue code points me into the direction why the simple loop from above did not work: the call to tud_task() was missing.
So does it solve your problems with the origina...
@Keval-Joshi-TI
@rgrr :
NCM driver worked for me for all segment sizes.
When lwip_task priority == tud_task priority it works well and as expected.
Made some tests with priority: for my device tud_task priority > lwip_task priority is mandatory. Otherwise especially target->host transfer collapses.
@HiFiPhile do you have an example code on how to calculate feedback on fifo count work ? I will try to find a way to fit it as well or give some option to do so.
Full code is in https://github.com/HiFiPhile/i2s_bridge, UAC related code is in
audio_callbacks.c1. I defined a feedback min/max of 0.1%, in USB HS spec clock deviation is 0.05% so 0.1% should be good if same type of oscillator is used for MCLK. https://github.com/HiFiPhile/i2s_bridge/blob/1d6a24fdd...
@Protoxy22 just sent you a invite:)
@Protoxy22 just sent you a invite:)
Thank you !
I made the changes you suggested and tested them on our device. Now the wait function is static in the RA file dcd_rusb2.c and used in the point you mentioned in the comment. The MSD result untouched in this way and all the changes are only for renesas.
In case you prefer some changes to this to better fit the overall architecture please let me know and I will test them on our device. Thanks.
@rgrr:
Thanks for conforming this.
Iperf Rx is finally functional for me
On my Linux machine due to some firewall issue iperf -r was not working
I am getting good results with the changes you suggested in lwiperf_tcp_client_send_more()
i.e ( txlen != 0 ).
renesas: add support for renesas micro with different number of USB hw pipes
not all renesas micro have the same number of pipes as expected by the find_pipe function.
For example see RA4M1 micro which only have 2 bulk pipes and 2 interrupt pipes.
For this reason some defines were introduced so that the actual number and positions of USB HW pipes can be defined at build time for different kind of processor.
If you prefer a different approach please let me know. I will try to impleme...
Because of TU_ASSERT returns bool value, this function's return type should be bool.
Please find the build error message.
https://github.com/hathach/tinyusb/actions/runs/6119698047/job/16610133014?pr=2245#step:10:45
Thank you for changing and testing.
Gotcha. I pushed a quick change introducing bool as return value. Thank
Related area
Report descriptor for gamepad
Hardware specification
esp32s3
Is your feature request related to a problem?
Hello I want to provide haptics to my gamepad and I did not find how to do that. How can I configure that ?
It is good to implement some macro for that like below.
#define TUD_HID_REPORT_DESC_GAMEPAD(...)
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ) ,
HID_USAGE ( HID_USAGE_DESKTOP_GAMEPAD ) ,
HID_COLLECT...
Describe the PR
Add support for host controller driver for Analog MAX3421e SPI
How can we dynamically initialize this? In CP, we'll want the code but not the data structures until we know we need it. Maybe a struct with all needed buffers/data and function pointers to the SPI API?
For now, you need to enable the host driver with CFG_TUH_MAX3421=1, this will also include driver internal data https://github.com/hathach/tinyusb/blob/master/src/portable/analog/max3421/hcd_max3421.c#L205. If you want to supply the internal data when needed we probably need some kind of malloc-like callback (malloc when init host stack, free when de-init). It will probably need its own PR since there is a few request for more dyanmic memory for class drivers (since not all enabled driveres...
superb! thank you @maidnl for the fix and @kkitayam for suggestion and reviewing.
Describe the PR
This PR adds Lighting and Illumination usage page and descriptor template for HID class.
Additional context
The descriptor in hid_device.h was taken from the lighting and illumination page, and all definitions in hid.h are taken from there as well. Adding this functionality allows TinyUSB devices that have lighting capabilities to be controlled by the host machine. In Windows, ...
Addressing some drawbacks of the HID class driver implementation.
- Fixing that the
tud_hid_set_report_cbcallback would always inform about an invalid result state if a dedicated OUT endpoint is used. In the case the optional OUT endpoint is used outgoing transfers are then handled byhidd_xfer_cband not byhidd_control_xfer_cbanymore. Then the HID examples wouldn't work anymore because the result state wouldn't be right. - Only invoke
tud_hid_report_complete_cband `tud_hid_se...
sorry, I was busy with other works, will pull out datasheet and check this out soon enough. Thank you for your patient.
Device can notify the host about network connection status by CDC NetworkConnection.
In the current scheme, the host does not re-initiate the DHCP process even if WiFi is connected to a different router. We used it to solve the problem that WiFi devices would connect to different routers.
Operating System
Linux
Board
raspberry pico (rp2040)
Firmware
any tinyusb firmware as long as it uses the usbd.c default handling of TUSB_REQ_SET_INTERFACE and doesn't override that in a driver specific control endpoint handler call-back.
What happened ?
It is my understanding that after any configuration event (to which SET INTERFACE belongs), the endpoints belonging to that interface re-start from DATA0.
See USB Spec 9.1.1.5: _configuing a device or changing an alt...
FYI: I tried to add related code, but I couldn't even find any dcd_* API from the low-level drivers to the generic usbd.c which would be used to reset the DATA toggle state.
The below diff illustrates how one can get notifications from the rp2040 usb device peripheral about those data toggle errors (the commented-out panic was from the hcd which interestingly does enable those error interrupts, while the dcd doesn't):
diff --git a/src/portable/raspberrypi/rp2040/dcd_rp2040.c b/src/p...
One way of looking at the problem is the fact that the default usbd code blindly acknowledges all SET_INTERFACE requests. The USB spec chapter 9 explicitly states that for interfaces with only one altsetting the device may simply stall rather than acknowledging the request. This way the data toggling state on the host/bus presumably shouldn't change.
However, this wouldn't be a true fix for any application that actually uses multiple different altsettings (like vendor specific drivers).
...
see below for a control_xfer_cb of a custom driver which overrides the usbd.c default handling (returning true in the SETUP stage) and then later returns false in the ACK/Status stage. This way the host sees the SET_INTERFACE failing, and will not change the data toggling.
static bool cardemd_control_xfer_cb(uint8_t __unused rhport, uint8_t __unused stage, tusb_control_request_t const *request)
{
switch (request->bmRequestType_bit.type) {
case TUSB_REQ_TYPE...
This is a ShanWan (PS3) wireless controller, it configures EP 0x81 & 0x02 as 32 bytes longs, but by my calculations the HID report is 35 bytes long and I suspect those extra 3 bytes make the Pico's USB device hold the EP inactive...
Normally, it crashes the Pico on these assert &| panic lines (which I've disabled for this dump, because I don't want my Pico to crash if a user plugs in such a device, and in the logging...
@timonsku I wrote a USB MIDI host application driver for TinyUSB in the usb_midi_host project. You might find that helpful. I have only tested it on the RP2040 on a Raspberry Pi Pico board and a Pico W board.
@raveslave I wrote a USB MIDI host application driver for TinyUSB in the usb_midi_host project. You might find that helpful. I have tested it on the RP2040 on a Raspberry Pi Pico board and a Pico W board.
Operating System
Windows 11
Board
BlackPill F411
Firmware
audio_4_channel_mic example (unmodified and modified, see below)
What happened ?
I successfully integrated the audio_4_channel_mic example in a new STM32CubeIDE project and used "plot_audio_samples.py" to test it. When I looked at the plot, I saw that the value 1 remains constant for two samples (see marking in the screenshot below). According to the source code, the value 1 should only be displayed for one sampl...
Out of curiosity: have you checked my NCM PR (#2227)? It should perform better and more bugfree than the original NCM device.
@raveslave I wrote a USB MIDI host application driver for TinyUSB in the usb_midi_host project. You might find that helpful. I have tested it on the RP2040 on a Raspberry Pi Pico board and a Pico W board.
thanks!!
I just checked 4m1 group hw manual, it has the same pipe numbering as other i.e
- pipe 1,2: ISO + Bulk
- pipe 3,4,5 bulk only
- pipe 6-9 interrupt
So I guess this PR isn't needed ? Btw, I think we should rename PIPE_1ST_BULK since it isn't correct (first bulk is 1 though). But we could do that later on.
I am so sorry, I wrote the wrong micro.
The micro with less PIPES is RA2A1 (not RA4M1). Really sorry, my mistake!
I think this PR is necessary.
Thank you.
Describe the PR
Add cmake support for stm32u5
yeah, you are right, we should reset DATA toggle when received SET_INTERFACE request, it should be done by either usbd or class driver and an additional dcd_edpt_reset_toggle() should be addded. Could you explain a bit on your configuration descriptor/driver, and how you setup/test, it would be helpful if you have an ready to build/test example/repo so that I could work on and verify the fix.
Thanks for confirming the bug.
I'm currently in the process of implementing a rp2040 based device that exposes the same protocol as the Osmocom SIMtrace2 device. The libusb based host software for this always first issues a SET INTERFACE to the desired target altsetting (see the library utility function in https://gitea.osmocom.org/osmocom/libosmocore/src/commit/d5c6651a...
Describe the PR
Currently interleaved copy in UAC2 is bugged, resulting samples become scrambled if encoding/decoding is enabled.
#2256, maybe #1722
Additional context
audio_4_channel_mic example use identical sample for all channels, makes the problems less obvious.
Thank you so much, @HiFiPhile . I can confirm, that #2259 fixes the problem.
Regards, Klaus
I've started to look at how I can get both the native USB host and the Pico PIO USB host up and running at the same time on the RP2040. My use case is as a HID controller for keyboard + mouse on a retro ITX motherboard I'm making (https://www.vogons.org/viewtopic.php?t=93480). I find it quite challenging however, because of how mutually exclusive the two solutions are set up to be for the RP2040 specifically, and generally how TinyUSB doesn't yet support two host controllers. In also not that...
@eivindbohler Why do you need two host controllers? A hub would allow you to connect multiple devices to one host port.
@tannewt Because not having to rely on a hub is arguably the better solution. I mean, if this can be done in software then why not?
As for hubs, I assume most external ones would probably work just fine - but the fewer external dependencies the better. I could also use an internal hub chip I guess. The problem with that is that it would break being able to reprogram the rp2040 over the native USB port (using the BOOTSEL button/signal).
At a high level - both the rp2040 and the TinyUSB l...
Sorry I missed this. I set CFG_TUD_LOG_LEVEL to 10 and it failed to find macros, such as TU_LOG10 for it. I think the STRCAT here is to blame: https://github.com/hathach/tinyusb/blob/master/src/common/tusb_debug.h#L65-L97
Operating System
Windows 10
Board
No board used till now
Firmware
tinyusb-master\examples\host\cdc_msc_hid\src
What happened ?
Aim is to build the above project.
I'm using esp-idf 5.1 CMD. Tried to do idf.py set-target esp32s3 but getting a Cmake error. How to fix this error.
Error :
You must set a FAMILY variable for the build (e.g. rp2040, eps32s2,
esp32s3). You can do this via -DFAMILY=xxx on the cmake command line
How to reproduce ?
- Open esp-i...
Describe the PR
With this PR it is also possible to compile the dcd_nrf5x with old Nordic SDKs. The current version of the driver uses API calls to nrf_clock with two parameters while the old SDK only uses one parameter for the call.
For correct behavior the NVIC calls also has to be directed thru the softdevice.
Additional context
ah yeah, you are right, that is my bad, please try to change CFG_TUD_LOG_LEVEL=3 only now, which the log is able to expanded to. I will try to fix this later on :)
@hathach, what's your take on this? Do you feel it makes the most sense to try to get the Pico PIO host working "alongside" and as decoupled from the native host as possible, or put in place a more general support for multiple host controllers? I'd imagine the latter being more elegant and potentially useful for other boards as well, but I'm sure harder to achieve.
native usb controller + pio-usb host can coexist, treated as mixed host controllers. There are more MCUs with mixed controll...
Added support for USB2 HS peripheral (with integrated HS PHY) on STM32U59x & STM32U5Ax chips.
Describe the PR
The latest additions to the STM32U5 family have an OTG_HS peripheral (replacing the OTG_FS peripheral).
This requires modifications to the dwc2_stm32.h to reflect the lack of OTG_FS defines and set up the HS defines correctly.
I tried to keep this looking/feeling similar to the OPT_MCU_STM32H7 case above it.
Additional context
In my tusb_config.h (for device only) I ...
Operating System
Linux
Board
Custom STM32G491 board
Firmware
size_t CustomWriter::flush()
{
size_t num = tud_cdc_n_write(0, txBuf, numBytes);
tud_cdc_n_write_flush(0);
numBytes = 0;
return num;
}
size_t CustomWriter::writeBuffer(const uint8_t *buffer, size_t length)
{
...
// Copy as many bytes as will fit into the buffer and transmit
uint16_t remainingBytes = 64 - numBytes;
memcpy(&txBuf[numBytes], modBuffer, remaining...
Describe the PR
Update project IAR template files.
Describe the PR
- Change signature of hcd_int_handler from (uint8_t rhport) to (uint8_t rhport, bool in_isr)
- for backward-compatible tuh_int_handler() is update to take optional arugment
- tuh_int_handler(rhport) --> hcd_int_handler(rhport, true)
- tuh_int_handler(rhport, in_isr) --> hcd_int_handler(rhport, in_isr)
Describe the PR
- Add max3421 support for esp32s2/s3 along with examples
- TBD
Describe the PR
Add support for the aforementioned discovery kit.
See https://www.st.com/en/evaluation-tools/stm32h750b-dk.html#overview for more details about it.
Additional context
Initial support and tested a couple of example projects.
This is my first contribution to the project so please be patient.
Thanks
Hello! I am also trying bring up usbfs (and usbd) IP on ch32.
Why stall is not supported on USBFS? In the datasheet I can see:
R8_UEPn_TX_CTRL
MASK_UEP_T_RES -> 11: Response STALL or error
Could you explain me a bit?
Did you know that this was done already?
Hey folks. I'm using both the Adafruit TinyUSB library, and vanilla version for projects. Getting stuck into an ESP32-S3 board and having some issues with the Adafruit TinyUSB library inside PlatformIO. I've scoured the forums and GH but no dice.
I'd like to use the Adafruit version as it incorperates a little more nicely with the MIDI library and various transports. I've played with the USB mode, different include options as well as the include file trick mentioned on the PIO forums, but still won't compile. The particular error is: "TUP_DCD_ENDPOINT_MAX is not defined for this MCU, default to 8". I also can't see 'OPT_MCU_ESP32S3' defined anywhere. It seems to indeed be an issue with the library linking order or clashign with the IDF TinyUSB.
From a few forum threads it indicates that a fix has been merged, but even on the latest version, the behaviour is the same.
Operating System
Others
Board
raspberry pi pico W
Firmware
using pico-sdk 1.5.1
What happened ?
I'm writing firmware for the pico which talks to pre-existing software on a usb host (read: I cannot change or easily inspect the host software/stack).
The host regularly sends HID output reports to the pico. At the same time, it also sends SET_ and GET_ FEATURE_REPORT reports. What I observe is that occasionally while I am processing a SET_FEATURE, the underlying buffer g...
@hathach How can we get some traction on this?
Hello, I am chiming in here since I worked on this effort for a project and got a link to this issue from a colleague. I'll start the process to push my implementation of the port of TinyUSB to upstream Zephyr.
One way to add a generic TinyUSB port would be the device_next driver API: it would give some generic api->ep_enqueue() method supported by all drivers, to use as an alternative to Zephyr own stack.
https://github.com/zephyrproject-rtos/zephyr/blob/main/drivers/usb/udc/udc_common.c#L568
Not sure about how Host mode works.
On a side note: Kudos for your work and thank you for the talk! It helps for going down the same route, in particular for the debugging methods.
Hey @hathach! Any news on this issue?
Thanks :)
Related area
USB488 / USBTMC
Hardware specification
all
Is your feature request related to a problem?
n/a
Describe the solution you'd like
Adding support to asynchronously trigger sending a status byte on the interrupt endpoint, to indicate a USB488 SRQ condition, that occurs in the usbtmc application level.
I have checked existing issues, dicussion and documentation
- [X] I confirm I have checked existing issues, dicussion and documentation.
no, I still haven't got time for this yet. Though It is on my TODO list when I get back to work on dwc2 driver
@me-no-dev does this need further review? Looks like it's missing your approval
poke @hathach
Describe the PR
- change tuh_max3421_spi_xfer_api() signature
- esp32 comment out uart, increase max3421 spi speed to 26mhz
Operating System
Linux
Board
ST STM32F439-Nucleo
Firmware
examples/device/cdc_msc_freertos
What happened ?
Following output from make BOARD=stm323f439nucleo all
WORKAROUND: Disable maybe-uninitialized as an error by adding to Makefile:
CFLAGS_GCC += -Wno-error=maybe-uninitialized
How to reproduce ?
git clone https://github.com/hathach/tinyusb- `cd tinyusb/examp...
Note: The example appears to run correctly on an STM32F429-Nucleo board, with the described workaround.
CH32F20x MCU family support
Added support of CH32F2 MCUs
Current code already support WCH CH32V3 chip, this MCU have the same USB HS core as CH32F20x therefore I just moved portable/wch/ch32v307/dcd_usbhs.c file to common folder(portable/wch/dcd_ch32_usbhs.c) and add libs for CH32F2xx
This my first Pull Request to tinyusb, please let me know If I missed something
@robust walrus https://forums.raspberrypi.com/viewtopic.php?p=2141907#p2141907
somebody doing pcie and xhci on the pi400, with the goal of using the keyboard, may have some code we can borrow
pi5 also complicates matters, by having 2 xhci controllers, each driving half the usb-a ports
so you would need a more complex xhci driver, that can manage multiple controllers at once
only if you want pi5 support from the get go
pi400 would be very cool
you should let them know that tinyusb does run bare metal on the pi
just not with pcie or xhci support
@robust walrus i also had an idea before, not sure i mentioned it, on how to deal with multiple controllers and different hcd's
what if the normal set of hcd functions, re-route the call to the right hcd, based on the root port number
so root port 0 goes to the dwc hcd
root port 1 goes to the 1st xhci
and root port 2 goes to 2nd xhci
then a single tinyusb host stack could drive multiple controllers
by adding a state pointer, and mapping the root ports over, i think it could easily expand to handle multiple controllers
i'll try to pop one open tonight
Hello! I am chiming in here since I worked on this effort for a project and got a link to this issue from a colleague. I'll start the process to push my implementation of the port of TinyUSB to upstream Zephyr.
Thank you kindly for your work. You're awesome. Can't wait to finally be rid of that god-awful zephyr usb stack.
audio_4_channel_mic has been updated to output different waveforms each channel.
Describe the PR
Two improvements in this PR for the BTH class:
- Force the user to specify CFG_TUD_BTH_ISO_ALT_COUNT
- Allow BTH class to work in historically compatibility mode where the
bRequestis always0xe0. See Bluetooth Core v5.3, Vol. 4, Part B, Section 2.2
@PanRe Thanks for your quick return :)
I'll try to optimize IN transfer data flow in a following PR.
For TYPE-I format the allowed sample in each packet is n<sub>avg</sub>+-1, for example 48kHz with a FS device gives 47~49 samples per packet.
<img width="664" alt="image" src="https://github.com/hathach/tinyusb/assets/4375114/e6fa43b8-7c04-44fe-9a5c-494aea124e0d">
Currently it always try to send all the data in FIFO. If we take example of a 48 sample length I2S buffer, who wri...
Interesting idea, but isn't that what you already implemented in one of your projects? I remember you mentioned something like that for the feedback value calculation?
Nevertheless, I like the idea. However, it introduces a lag and some users might not want that. I know, it is hard to get it working without some kind of buffering. How about defining a minimum buffer fill level? The higher it is, the more robust it gets. For users which don't want a buffering, they can set the fill level to z...
Interesting idea, but isn't that what you already implemented in one of your projects? I remember you mentioned something like that for the feedback value calculation?
It was for OUT transfer, in that case user code has the responsibility to calculate feedback correctly. For IN transfer the feedback is implicite, simply determined by how much data is sent.
After thinking current code only support fixed sample rate, it's necessary to calculate n<sub>avg</sub> based on sample rate to le...
Describe the PR
Currently UAC IN transfer always try to send all the data in FIFO, which comes with 2 issues:
- Recorded audio could have glitch depending on I2S clock variation.
- Multi-rate (eg. 44.1k & 48k) doesn't work as the packet size is different.
For TYPE-I format the allowed sample in each packet is navg+-1, for example 48kHz with a FS device gives 47~49 samples per packet.
This PR makes IN transfer size honor the constraint and resolve above 2 issues, by select ...
Great, thank you for your PR. Pull and tested on my u575 nucleo board, I also make some changes to add cmake support for the board. Will merge when ci passed.
Describe the PR
fixes SET_REPORT data corruption.
Additional context
fixes #2273
awesome, great work as usual :+1: :+1:
Operating System
Others
Board
Portenta C33 (Renesas)
Firmware
What happened ?
An assert didn't catch out-of-bounds indexing of a multi-dimensional array, which caused memory corruption.
The problem occurs when get_new_address() returns address 5, and that number ends up at this line as dev_addr:
_hcd.ep[dev_addr - 1][dir_in][epn - 1] = num;
in hcd_edpt_open() in hcd_rusb2.c(). It becomes 4 and is then used to index the ep array. There's an assert that checks...
@PanRe PR is up, looking for class users' feedback.
Nice work!! Thanks a lot!
Could you explain a bit how the blackout works please?
Could you explain a bit how the blackout works please?
Well that's something need to be proven :) There are some reasons why I added it:
- At startup as the FIFO is being filled, short packets will be sent until FIFO half filled, on my Windows machine I observed there are 1 or 2 samples missed when there are too many short packets (maybe it tries to correct clock drift, who knows), while capture shows packets are ok.
<img width="400" alt="image" src="https://github.com/hathach/tinyus...
I see, sounds a bit like black magic stuff :)
From my side, I don't have any problems with merging your PR as it is already more robust than the current version. But I am curious, have you already conducted a long term test? Maybe for an hour? Or do you know if Linux works without issues? Lots of time consuming questions I know ;)
In any case, very nice work as usual!!
From what I have seen in the datasheet, it looks like the USB peripheral from the H5 might be the same as that in the G0 family (at least register names seem to match) but I haven't looked in the details yet
I have tried replacing G0 with H5 HAL just for a test and also changed:
- manually edited dcd_stm32_fsdev_pvt_st.h to point to stm32h5xx
- changed USB_UCPD1_2_IRQn to USB_DRD_FS_IRQn in dcd_stm32_fsdev.c
- defined "STM32G0" to omit the "USB->BTABLE"
Just by doing these change...
Here are logs in log level 3:
and at the end:
I haven't done long test only 5s recording, it's too hard to inspect data when there are too much. I've done a quick test on Archlinux which works but I don't remember it was with STM32G0 or LPC55, I'm going to test more, at least both FS & HS later.
I can confirm this patch fixes operation on Keil
I think this also affects other weak callbacks, eg. tud_cdc_line_state_cb or tud_cdc_rx_cb don't work either in Keil if not modified in a similar way as this PR does
Related area
HOST
Hardware specification
CH32V307
Is your feature request related to a problem?
The status table is unclear about HOST mode on CH32V307 (there is no status). I want to run the video capture example, which is host mode, on ch32v307, if the status could be confirmed it would be nice.
Describe the solution you'd like
video capture example working on ch32v307
I have checked existing issues, dicussion and documentation
- [X] I confirm I have checked e...
Operating System
Linux
Board
STM32H7 Custom
Firmware
Custom.
Quite simple firmware using a currently days-old pull of tinyusb trunk.
Using the tinyusb provided dcd_synopsys.c
#define CFG_TUSB_MCU OPT_MCU_STM32H7
#define CFG_TUSB_OS OPT_OS_FREERTOS
#define BOARD_DEVICE_RHPORT_SPEED OPT_MODE_FULL_SPEED
#define BOARD_DEVICE_RHPORT_NUM 0
#define CFG_TUSB_RHPORT1_MODE (OPT_MODE_DEVICE | BOARD_DEVICE_RHPORT_SPEED)
define CFG_TUD_ENDPOINT0_SIZE 64
#defi...
This is a show-stopper for my device development.
If this is expected behavior, is there a known workaround?
Hi @MWP
It's an intended behavior, For a stream like CDC, when an multiple bytes of endpoints size (64 bytes) is transfer e.g 256 byte, TinyUSB currently expect an zero-length data (ZLP packet) to end otherwise it will assume host is sending more data.
Ok.
So is there a commonly used work-around for this on the TinyUSB side?
Something like a transfer time-out?
I'm not too familiar with the inner workings of TinyUSB, so i would very much appreciate some advice or a starting-point on a solution.
Thanks.
superb !! Thank you very much @mabembedded for your effort :+1: . Eveen though I really want to, but unfortunately, I was a bit busy at the moment to follow up with Zephyr. I will try to catch up with you guys later.
Describe the PR
Update audio_4_channel_mic example and descriptor, to let HS device use 125us interval.
Klemen, would you mind creating a patch file that captures the changes you made to get the code to compile and run as far as you've described? I have been trying to get just to the point of being able to compile and keep getting stuck. Also could I see your tusb_config.h? Or are you using the one straight from the example?
Deleted previous comment; managed to make the same changes Klemen describes to get to a buildable codebase. I'll report back as things develop...
If it's your host program you need to send a ZLP packet et the end to finish the transfer. For the moment there is no transfer timeout implemented.
Update: my changes work, the issue described above is due to #1018 as I use Keil (most callbacks don't work out of the box here it seems)
Hi! I am really sorry to bother you on this topic again.
I would like to ask you if can reconsider the possibility to merge this PR.
As I wrote in my previous comment I initially mentioned the wrong renesas microcontroller (again I'm sorry for that):
the renesas microcontroller with less pipes is RA2A1 (he really is :-).
I think this PR is required to make possible the use of this renesas microcontroller and I hope you can reconsider it and merge it. This will allow us (Arduino) to swi...
Please can this get merged
update s3 devkitm with max3421 pin following metro s3, check max3421 version to make sure it is valid
I think I reached the same "built and run" state as Klemen, but nothing happens when I connect the USB cable to the host PC (Windows 10). The tud_descriptor_device_cb callback is not hit. In my case it's a Nucleo board (still H563 chip) that has a Type-C connector for that port. Klemen, does your board use Type-C?
I've started a new discussion here in case I'm pulling this one too far off its original path.
Describe the PR
Allows easy usage of TinyUSB in PlatformIO (see https://platformio.org/).
Describe the PR
Currently, only devices with product IDs 0xEA60 and 0xEA70 are recognized by the cp210x driver. I've had some success with one of the other ids from this list.
Optimally, it would be better if this is managed internally, but by allowing customization of the list at compile-time this may be more easily tweaked and experimented with in the meantime.
Additional context
Related area
new port support
Hardware specification
STM32F429-Disco
Is your feature request related to a problem?
I'm trying to port TinyUSB for the STM32F429 Discovery development board.
Such board uses the rhport = 1 (USB_OTG_HS).
The pins are different from the current port for the STM32F4 family.
__HAL_RCC_GPIOB_CLK_ENABLE();
/**USB_OTG_HS GPIO Configuration
PB13 ------> USB_OTG_HS_VBUS
PB14 ------> USB_OTG_HS_DM
PB15 ------> USB_OTG_HS_D...
I manage to get USB to start the enumerate process, but i'm getting this error:
[ 8578.520458] usb 3-4: new full-speed USB device number 46 using xhci_hcd
[ 8578.520627] usb 3-4: Device not responding to setup address.
[ 8578.728658] usb 3-4: Device not responding to setup address.
[ 8578.936488] usb 3-4: device not accepting address 46, error -71
[ 8578.936690] usb usb3-port4: unable to enumerate USB device
[ 8828.424773] usb 3-4: new full-speed USB device number 49 using xhci_hcd
[ 8...
STM32F429 doesn't have internal UTMI phy, so even if the port support high speed you are limited to full speed.
STM32F429 doesn't have internal UTMI phy, so even if the port support high speed you are limited to full speed.
Yes, I know that. You can note in the linux dmesg info "new full speed device". I'm using the HS port configured to full speed.
#define BOARD_TUD_RHPORT 1
#define CFG_TUSB_RHPORT1_MODE OPT_MODE_DEVICE
#define BOARD_TUD_MAX_SPEED OPT_MODE_FULL_SPEED
// Enable Device stack
#define CFG_TUD_ENABLED 1
#define TUD_OPT_RHPORT 1
// Default is max sp...
The exact same code is working in the STM32F4-Discovery kit, but such kit uses the FS por. The port problem seems to be when using the HS port with the internal PHY with full speed. It just do not enumerate.
Describe the PR
- Add support for stm32u5a5 (highspeed with built-in femtoPHY). Tested with stm32u5a5 nucleo
- Also update u5 cmsis and hal driver
- dwc2 driver flush all tx fifo and rx fifo in dcd_init()
- reformat dwc2 related files
- add dwc2_info.py and dwc2_info.md which store dwc2's ghwcfg1,2,3,4 configuration for all ports for comparison and study purpose
Sorry, was busy with other works. Will check this out as soon as I could
Describe the PR
When OTG_HS configured to work on internal phy FS mode.
Also fix a F7 GPIO alternate mapping.
I got it. The problem was in the clock. Everything is working now. Congrats for the project. It is great. :)
I got it. The problem was in the clock. Everything is working now. Congrats for the project. It is great. :)
These are intended to allow bare metal platforms with one-shot scheduling capabilities to schedule the TinyUSB task handlers whenever they know there is work for them to do.
I've been experimenting with this approach for MicroPython, where we don't usually have an RTOS but we do have scheduling capability. Selectively scheduling tusb_task_ext() to run when we know there are events in the queue reduces latency for processing, while also avoiding the overhead of polling tusb_task_ext() w...
Describe the PR
- update docs
- add adafruit & its logo as sponsors in readme
Describe the PR
remove legacy driver st/synopsys
Any luck on this issue? Also need 16 bit resolution :(.
look good, please fix the missing end of file per ci recommendation.
Describe the PR
only call tuh_max3421_spi_cs_api() in SPI start/end transfer since Arduino port use this to call begin/endTransaction()
Describe the PR
add unique id for u5, also allow to build with OPT_OS_CUSTOM
Should be fixed. Thanks for the headsup!
Related area
CDC device class, probably others
Hardware specification
RP2040
Is your feature request related to a problem?
Unless I have missed something or not done something correctly, it seems that a call to tud_cdc_n_write_flush() can block if the host is not pulling data. I haven't tried yet, but I'm guessing that it's a more general issue that happens with the vendor device class as well, and possibly others.
Not completely sure how to deal with it gracefully. It's d...
Describe the PR
Fix a race condition where device is removed while enumerating (repeatedly sometimes when plugging in) which cause following symptons
[1:] USBH Defer Attach until current enumeration complete
[1:] USBH Defer Attach until current enumeration complete
[1:] USBH Defer Attach until current enumeration complete
[1:] USBH Defer Attach until current enumeration complete
[1:] USBH Defer Attach until current enumeration complete
Any luck on this issue? Also need 16 bit resolution :(.
Hi, sorry for the late reply. My implementation was like this:
16BitTest.ino
Hope this helps.
Seems #2310 has fixed one of the possible failures here, possibly replaced with more "invalid speed" panics. Otherwise seems the same.
Hi,
I've found dhserver and dnserver gives a linkage error when you try to use on a C++ project, so the solution that I've found is to
add extern c to the affected headers.
Describe the PR
This adds bsp for ST nucleo-g491re board.
Additional context
This is mostly copy of nucleo-f474 only differences being:
- PLL configured to 170MHz (not affecting USB which runs on HSI48)
- Linker script freshly generated from STM32CubeIDE (smaller RAM)
Finally back to this... setting CFG_TUD_CDC_EP_BUFSIZE=64 is indeed a workaround for the problem.
It may have some negative speed consequences, but they shouldn't be a problem for my application.
Thankyou HiFiPhile!
I think it is no hurt to add an function to change the default behavior eventhough it is not a norm. That make tinyusb more flexible. e.g
tud_cdc_wait_for_zlp(bool)
Describe the PR
Typo fix in UAC examples.
@RobertDaleSmith this kind of race is hard to troubleshoot without actual hardware. If you can send an hardware in question to me, I will try to take a look. However, there is no guarantee on the ETA at all, and I do live in Vietnam. If you are OK with that, please drop me an email, I will send you the shipping info.
Any hints on where to look for someone with the hardware and too much free time?
@RobertDaleSmith this kind of race is hard to troubleshoot without actual hardware. If you can send an hardware in question to me, I will try to take a look. However, there is no guarantee on the ETA at all, and I do live in Vietnam. If you are OK with that, please drop me an email, I will send you the shipping info.
I got you. And no rush. I appreciate you even offering.
robert [at] robert dale smith [dot] com
I just checked the manual for RA2A1, it indeed only support 5 pipes, oddly enough pipe0 then 4-7 (1-3 seems to be not usable). RA2A1 (and other similar mcus) should be detected e.g BSP_MCU_GROUP_RA2A1 and addressed by tinyusb without the need of using external MACRO as suggested change.
I don't have RA2A1 hardware on hand, but I can try to add an bsp for it, and then make some adjumst to pipe allocation for it later on.
Describe the PR
- add ra2a1 ek
- also make some other changes
Describe the PR
- update imxrt bsp to make use of mcux pinconfig tool
- add metro m7 1011 sd with ETM TRACE enabled, not yet got trace data out
- add imxrt1170 bsp, led + button works, but usb (device) is not working yet. Maybe something missing.
- other clion setting
Operating System
Linux
Board
Raspberry Pi PICO (RP2040)
Firmware
https://github.com/byteit101/test-tinyusb-pico
What happened ?
panic/assert/exit calls sometimes, but not always, on writes (I think?).
I have confirmed it on Debian 10, Linux pollux 5.10.0-21-amd64 #1 SMP Debian 5.10.162-1 (2023-01-21) x86_64 GNU/Linux
I haven't seen it on a "blank" flash (no filesystem)
I have confirmed it with G++ 8.3 and G++ 12.2 (the latter requires uncommenting `target_lin...
Operating System
Linux
Board
Raspberry Pi Pico
Firmware
0.15.0
What happened ?
When using tuh_hid_set_report to set leds, like this sample:
leds = KEYBOARD_LED_NUMLOCK;
tuh_hid_set_report(deviceadress, deviceinstance, 0, HID_REPORT_TYPE_OUTPUT, &leds, sizeof(leds));
It causes erratic behavior with two different keyboards.
I implemented a short program to toggle the leds while pressing a button. It initially seems to work.
But after some toggles, seemi...
My issue seem to be exactly the same as this one:
https://github.com/hathach/tinyusb/pull/2024
This looks to be already merged and what I can see is that I am already running the latest version of tinyUSB?
Am I missing something else?
Describe the PR
Add dwc2 info of F429, which is the same as F407
Describe the PR
Finally I had time to integrate my feedback work into UAC2 class :)
Compared to other methods the only thing needed is add a callback to set sample rate, all calculations are done inside the class.
void tud_audio_feedback_params_cb(uint8_t func_id, uint8_t alt_itf, audio_feedback_params_t* feedback_param)
{
// Set feedback methode to fifo counting
feedback_param->method = AUDIO_FEEDBACK_METHOD_FIFO_COUNT;
feedback_param->sample_freq = current_sample_...
Operating System
Linux
Board
All
Firmware
n/a
What happened ?
There's a few places where the word "conding" has been used, which I assume is a typo for "coding"?
Obviously for backwards-compatibility the existing misnamed constants need to be kept, but I wonder if it'd be possible to use some #defines or something to also add correctly-spelt versions of the constants?
How to reproduce ?
...
Test welcomed @Protoxy22 @Lurcy38 @kf6gpe @PanRe
Wow great work, I will have time to test this next week-end on an STM32H743 Eval Board with USB HS
Thank you
Describe the PR
- add tuh_max3421_reg_read(), tuh_max3421_reg_read() for application usage
- update example to work with featherwing max3421, set max3421 GPIO0 for vbus
- tested with feather nrf52840, m0, m4
Describe the PR
Add endpoint buffer allocation support.
Describe the PR
fix #2330 , an macro with previous typo words are added for backward-compatible. Maybe removed in the future release.
fixed, thank you for spotting the issue. I made quite a bit of typos in early days.
Describe the PR
- Correct clock source with xtal in CLOCK_EnableUsbhs0/1PhyPllClock(). This get usb working with rt1170 evkb
Describe the PR
H7 running on full-speed phy need to disable ULPI clock in sleep mode. Otherwise, USB won't work when mcu executing WFI/WFE instruction i.e tick-less RTOS.
Note: there may be other family that is affected by this, but only H7 is tested so far
- also update clock setting for h743nucleo to run at 400mhz
- update dwc2 info to extract dwc2 specs...
Operating System
Linux
Board
ek_tm4c123gxl
Firmware
Attempting to build the examples:
What happened ?
Linking fails due to an overlapping linker section.
arm-none-eabi/bin/ld: section .ARM.exidx LMA [000053f8,000053ff] overlaps section .data LMA [000053f8,0000746f]
I can't see anything obviously wrong with ./hw/mcu/ti/tm4c123xx/CMSIS/5.7.0/Device/ARM/ARMCM4/Source/GCC/gcc_arm.ld but I also can't see that it's being used...
How to reproduce ?
cd exam...
following patch "fixes" it, but unsure if that's where you want things done:
$ git diff
diff --git a/hw/bsp/tm4c123/boards/ek_tm4c123gxl/tm4c123.ld b/hw/bsp/tm4c123/boards/ek_tm4c123gxl/tm4c123.ld
index 351857bd6..f70f253bd 100644
--- a/hw/bsp/tm4c123/boards/ek_tm4c123gxl/tm4c123.ld
+++ b/hw/bsp/tm4c123/boards/ek_tm4c123gxl/tm4c123.ld
@@ -24,6 +24,7 @@ SECTIONS
*(.fini)
*(.rodata)
*(.rodata.*)
+ *(.ARM.exidx*)
. = ALIGN(4) ;
...
I've hit the same issue with an STM32U575. I had similar behavior to what was described in https://github.com/hathach/tinyusb/issues/1935 but https://github.com/hathach/tinyusb/pull/1928/ allowed me to advance one step forward to this current bug (with the default settings of 96 kHz 24-bit). Do you have any updates on this issue ?
Describe the PR
- Move build file from tools/ to examples/build_system
- remove the need of SKIP_NANOLIB, LDFLAGS should be explicit set for each board/family
LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
- rename tools/build_family.py to build_make.py
- Added
LDFLAGS += -Wl,--no-warn-rwx-segmentfor GCC >= 12.0 for make/cmake
@gabChouin Unfortunately not. I gave up eventually and wrote my own UAC (1.0 only) driver.
Could you take a looks the version of dwc2 IP used in F401 ?
Basically these registers : https://github.com/hathach/tinyusb/blob/d6b8b3515df4bb83b6038bd60260771e65af8de7/src/portable/synopsys/dwc2/dwc2_info.py#L6C4-L6C4
I'll see if it's reproducible on my F429 board.
Could you try #2333 ?
While I didn't hit breakpoint, sometimes after re-plug it NAK all OUT transfers (which will cause host to re-enumerate like in your log)
we should refactor this to share code with dcd_edpt_open(), since it is quite a duplication. I can do it if you don't mind testing again :)
thank you very much, this is a great idea and I really like it. Though I would like to tweak it to use weak callback function to be consistent with the rest of API. e.g
void tud_event_hook_cb(const void* event, bool in_isr) _weak
void tuh_event_hook_cb(const void* event, bool in_isr) _weak
The reasson to change to void* is dcd_event_t/hcd_event_t type are not public (not included with tusb.h).
Let me know if this suggestion make sense to you.
look ok, but for configurable settings, this should be rename to follow the convention to CFG_TUH_CDC_CP210X_PID_LIST. I could make the change if you are not familar with the codebase. Also please let me know which PID you succesfully test with, so that it can also be added to default list (which is list of tested devices).
hihi @kasjer do you have time to help reviewing this. Thank you.
thank you for the PR, it looks great, I just rebase and update the PR to match latest change. The board should use both startup and linker for h750, would you mind updating and testing it again. Thank you
startup and linker should be changed to h750 instead of h745. I was about to change that but I realize that H750 mcu only has 128KB of flash, it proabably means to be used with qspi flash. Though if all examples can fit into 128KB, we are all good.
perfect, thank you very much. I resolve an readme conflict and fix a minor pre-commit format (end of file). Will merge when ci is all passed.
I was able to make it work with PID = 0x800A. I've not tested all the edge cases so I'm not 100% sure if everything works, but it seems to. And to be honest, I'm too unfamiliar with the protocol and the standard to be able to confidently do so either. Receiving and sending serial bytes works.
You are of course right with the naming convention. The reason I did it this way was so that the change was as unintrusive as possible and to not encourage the use of other PIDs that may or may not ...
for user configurable macros, it must be renamed to CFG_TUH_CDC_CP210X_PID_LIST. you also need to move the default value #ifndef from cp210x.h to tusb_option.h right after the CFG_TUH_CDC_CP210X. If you are not confident, also the 0x800A seems not very popular serial device (from your list is SPORTident), we can skip adding it to the default. Thanks.
also the 0x800A seems not very popular serial device
My thoughts too.
I'll follow your suggestions and update the PR :+1:
Looks good.
Verified not to break existing code with CFG_TUD_BTH_ISO_ALT_COUNT requirement.
Historical compatibility looks good (not tested though)
thank you for your PR there is a couple of problems
- 1.x version check is not correct.
- please explain the sd_nvic usage with old sdk, when sd is running (eanbled) and not.
do we really need it this, USB isn't restricted peripheral by SoftDevice ? If it is required to use sd_nvic_EnableIRQ() when sd is enabled, we should use this instead
#ifdef SOFTDEVICE_PRESENT
if ( is_sd_enabled() ) sd_nvic_EnableIRQ(USBD_IRQn)
They concurrently developed both 1.x and 2.x together since it is breaking changes. 1.9 is actually released after 2.0. It is supprising that nordicsemi didn't include NRFX_VERSION in their codebase.
This check make version v2.0 to v2.4 not compilable with tinyusb which is not correct. The correct check must ensure:
- all v2.x compile as it is
- additionally some of 1.x can be compiled, not all since there is a slash of MDK version.
From what I found MDK version for releases are
`...
That's great, thanks! Would you like me to update the PR to change the hooks?
Probably the "event" parameter can be removed from the hook. I added them on a whim as they're "free" with a macro, but I can't think of a use case so it can probably be removed.
I guess passing through "in_isr" is still potentially useful, though.
That's great, thanks! Would you like me to update the PR to change the hooks?
Yeah, please do it when you have the time.
Probably the "event" parameter can be removed from the hook. I added it on a whim as they're "free" with a macro, but I can't think of a use case so it can probably be removed.
I guess passing through "in_isr" is still potentially useful, though.
Yeah, you are right, application does not have any usage with internal data. Maybe we can change it to have r...
thank you @kasjer for reviewing, I will make some tweak before merging this.
maybe renamed CFG_TUD_BTH_HISTORICAL_COMPATIBLE to make it clearer.
this check does not do much since CFG_TUD_BTH_ISO_ALT_COUNT is default to 0 here https://github.com/hathach/tinyusb/blob/master/src/device/usbd.h#L774
we should move this to tusb_opt.h and only force it when CFG_TUD_BTH is enabled.
thank you for your PR. I made some tweaks
- rename to CFG_TUD_BTH_HISTORICAL_COMPATIBLE
- move CFG_TUD_BTH_ISO_ALT_COUNT to tusb_option.h and mandatory for BTH driver
will merge when ci passed
actually, since I am working on PRs, I could do it just now, if you haven't started thge update yet.
For dcd_edpt_close_all(), shouldn't it stop pending transfer and flush FIFO, just like dcd_edpt_close() does ?
https://github.com/hathach/tinyusb/blob/f1898fef8c605843e1a783bf758949247caae90e/src/portable/synopsys/dwc2/dcd_dwc2.c#L632
I haven't, so feel free if you have time. Thanks!
Describe the PR
supercede #2234, want to make some changes to PR, but that PR is not writable.
all is good now, thank you very much for the PR
Same issue with host/cdc_msc_hid_freertos It's a freertos "error" (There's a configAssert guarding the potentially uninitialized variable) but I don't think we should have -Werror for third party chunks..
Operating System
Linux
Board
dk-tm4c129x (msp432e4 equivalent)
Firmware
examples/host/cdc_msc_hid
What happened ?
assert failure... (see reproduction steps
How to reproduce ?
- Flash
- Run
- Plug in cp210x dongle
- watch that it mounts correctly as expected
- unplug dongle
- watch assert on log
Debug Log as txt file (LOG/CFG_TUSB_DEBUG=2)
Screenshots
No response
...
I'm afraid I don't have any other supported host capable boards right now, but i'll try and dig one up to compare against.
Describe the PR
- Bump up version macro in tusb_option.h, json, yml
- update docs: readme, changelog etc..
Operating System
Linux
Board
dk-tm4c129x (msp432e4 equivalent)
Firmware
examples/host/cdc_msc_hid
What happened ?
I'm not entirely sure from https://github.com/hathach/tinyusb/pull/1213 whether hubs are meant to be supported or not yet?
If I have the hub attached when the test app starts, it attempts to enumerate, but then asserts.
If I don't have the hub attached, let it boot, and then plug it in, it is simply not detected.
How to reproduce ?
build exa...
Related area
USB wifi dongle
Hardware specification
rp2040
Is your feature request related to a problem?
I have built a project to use Pi Pico W as a usb wifi dongle over RDNIS https://github.com/sidd-kishan/pico-webserver using the lwip example but I need a way to set wifi creds dynamically with cdc port
Describe the solution you'd like
There should be an example to demonstrate RDNIS to run with a cdc port.
I have checked existing issues, dicussion and documentat...
You can compare cdc_uac2 and uac2_headset example to learn how composite device works, especially usb_descriptors.c and tusb_config.h
It's impossible to maintain composite device examples of all combinations.
Hi, I am curious if there is any progress on working on both ports at the same time? I have really interesting case where I need host on fs, and device on hs
this PR made TU_LOG and other prints consistent using \r\n instead \n only
CFG_TUH_LOG_LEVEL is not treated in right way, if CFG_TUSB_DEBUG and CFG_TUH_LOG_LEVEL are 1
@hathach Updated now.
Not sure if there would be value in allowing external definition of FTDI PIDs too, but that should probably be its own PR.
I'm actually not absolutely sure if this is required. This is more a defensive approach. If one guarantees, that "NVIC_EnableIRQ(USBD_IRQn)" works for all Nordic SDK, I'll remove those #ifdefs immedately. Same is true, if you accept the PR only if this construct is removed of course ;-)
is_sd_enabled() is not available in all Nordic SDKs. Before using another #ifdef I prefer a "generic" approach which works for all Nordic SDKs.
I've changed the code so that the old API is correctly detected. But, I put priority on detection of the old API in case of conflicts, because TMO most people now keep the versions current because handling of the Connect SDK is different.
Upgrading to nrfx 1.9.0 is not that easy, because the nrfx is part of the Nordic SDK.
I believe I have the same issue on RP2040. Don't have exact steps to reproduce, as I couldn't find an exact pattern when it happens. Here's an example of the problem when I was plugging and unplugging the Rasbperry Pi Pico from a Pixel 8 phone (flushed with uac2_headset example):
_exit(int status) (c:\Program Files\Raspberry Pi\Pico SDK v1.5.1\pico-sdk\src\rp2_common\pico_runtime\runtime.c:187)
panic(const char * fmt) (c:\Program Files\Raspberry Pi\Pico SDK v1.5.1\pico-sdk\src\rp2_co...
@rpascalsdl
It's not the same issue. This one is specific to dwc2 IP, rp2040 use a different USB controller.
I have the exact same problem
What platform should I choose as a reference "known good" host platform? From the supported boards table, it looks like either imxrt10xx or renesas? Any preference?
@HiFiPhile thanks. I removed the comment. Will try to create an issue when I have better repro steps.
Describe the PR
This pull request introduces a CodeQL workflow to enhance the security analysis of this repository. CodeQL analysis results will be uploaded to Code Scanning under the Security tab. The workflow file also allows certain CodeQL queries to be filtered out that may result in false positives. Errors from the analysis may be dismissed for multiple reasons, e.g. false positive, won't fix, etc.
fail_on_error.py is a script that forces the entire workflow to fail should th...
Operating System
Windows 11
Board
Raspberry Pi Pico
Firmware
/tree/examples/device/uac2_headset
What happened ?
Actually, there is no problem with direct connection. However, when the computer stops making sound, it close the EP after a certain period of time. When I play the sound again, I get the error "hw_data_offset(next_buffer_ptr) <= USB_DPRAM_MAX". I can create this by simply pressing and waiting on the button used for windows to test audio devices.
How to r...
Describe the PR
A clear and concise description of what this PR solve.
Additional context
If applicable, add any other context about the PR and/or screenshots here.
Describe the PR
fix: memory leak: buf
Currently contributing with a sample linker script that may suit our needs in https://github.com/STMicroelectronics/cmsis_device_h7/pull/8
Currently contributing with a sample linker script that may suit our needs in STMicroelectronics/cmsis_device_h7#8
we don't need to wait for this, it would take forever for ST to merge this. Instead you could just copy the linker to the board folder like this board https://github.com/hathach/tinyusb/tree/master/hw/bsp/stm32h7/boards/daisyseed
Describe the PR
Update hil test for rp2040 on self-hosted PI4
perfect, thank you for your hard works
Describe the PR
test run locally well, changes needed for self-hosted pi4 since it does not compile, and only download artifacts from gh ci.
superb!! Thank you, I was always wanting to add these static code analysis to action ci. This is a great feature to have. Though, due to sync issue, it failed current ci. Would you mind edit this PR to allow maintainer to edit so that I could help you to fix it or add me with write permission on your fork. If you are busy, I could just merge this as it is and make follow up PR later on.
@hathach Thanks for your response; I've added you to the fork.
Describe the PR
Sometimes it may be handy to know to which port a device is connected to, e.g. when dealing with identical devices.
This change allows the port number of a device to be retrieved.
Additional context
Supports root hub and external hub ports.
This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests wi...
perfect, thank you for the great PR. I have update it to latest code, and make some tweak to the codeql.yml. We will continue to tweak and improve codeql scanning in the future with follow-up PRs as well.
I have updated the markdown files.
I don't see any changes at all
thank you, PR look good, though there is some slight changes requests
since it is common for host and device, it should be
#if CFG_TUSB_DEBUG >= CFG_TUH_LOG_LEVEL || CFG_TUSB_DEBUG >= CFG_TUD_LOG_LEVEL
since it is common for host and device, it should be
#if CFG_TUSB_DEBUG >= CFG_TUH_LOG_LEVEL || CFG_TUSB_DEBUG >= CFG_TUD_LOG_LEVEL
This is interesting. I'm curious where can I find audio_debug.py. Any ideas? Thanks a lot!
This is interesting. I'm curious where can I find audio_debug.py. Any ideas? Thanks a lot!
Just in the PR examples/device/uac2_speaker_fb/src/audio_debug.py
This is interesting. I'm curious where can I find audio_debug.py. Any ideas? Thanks a lot!
Just in the PR examples/device/uac2_speaker_fb/src/audio_debug.py
Ah, so not in main yet. Ok, thanks!
@hathach Sorry I didn't reply earlier, that looks great thank you!
great :) , I will be very happy to test this implementation in my app, but i cannot reach the branch rx_fb , how to do ?
@Lurcy38 it's under my user space
https://github.com/HiFiPhile/tinyusb/tree/rx_fb
Or you can download PR by adding .patch
https://github.com/hathach/tinyusb/pull/2328.patch
I'm currently traveling without a notebook. I'll change it in a week
Short-circuiting operator applied to flag
Operand to short-circuiting operator looks like a flag (2 = 2 ^ 1), may be typo for bitwise operator.
I'm currently traveling without a notebook. I'll change it in a week
Take your time, I am om vacation next week as well
Operating System
Linux
Board
mkrzero
Firmware
I set up this repository containing my complete project:
https://github.com/nerdyscout/tinyusb_gettingstarted
What happened ?
Hi,
currently I am trying to get started with TinyUSB, but seems like I'm doing something stupid wrong and can not figure out what to do.... so I would like to ask for some help. Following this page I checked out ...
hi @Yveaux
I am trying to setup TinyUSB with platformio in this project but get 'undefined references' and can not figure out why. maybe you could help?
Hey @nerdyscout,
You should include the TinyUSB library as an external library instead of copying the files in your project.
The TinyUSB config file does need to be part of your project and CFG_TUSB_CONFIG_FILE must point at it; I placed it in include/tusb_config.h.
I use the TinyUSB library on an RPI Pico with Arduino, and the platformio.ini looks something like:
[env:pico]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
board = pico
framework = arduino
...
Anything I can do to fix this?
<img width="686" alt="image" src="https://github.com/hathach/tinyusb/assets/7716005/369b0fa1-61f0-480a-bd7a-33601c8b283c">
Describe the PR
Added support for the USB OTG/FS driver found in the CH32V20x microcontrollers, heavily inspired by the CH32V307 driver. Note there is an older incomplete PR https://github.com/hathach/tinyusb/pull/1995 for the same IP in the CH32V307.
Additional context
Driver does appear to be working well, I'm currently using it to implement a basic RPC using bulk transfers in [dragonlock2/miscboards/wch/rvice_adc](https://github.com/dragonlock2/miscboards/tree/main/wch/rvice_a...
I've reached the same "build and run" state as Klemen on the Nucleo-H563ZI. No USB enumeration. It is a type C. Might be the same board Lotharyx used.
Operating System
Linux
Board
rp2040
Firmware
Any example.
https://github.com/angmolin/tinyusb/tree/bugfix/gcc%2B12-strict-overflow-warning
What happened ?
When you try to compile tinyusb examples with gcc >= 12 it annoyingly triggers -Wstrict-overflow:
tinyusb/src/class/audio/audio_device.c:1568:23: error: assuming pointer wraparound does not occur when comparing P +- C1 with P +- C2 [-Werror=strict-overflow]
1568 | while (p_desc < p_desc_end)
...
Describe the PR
A clear and concise description of what this PR solve.
This PR solves a problem with strict-overflow when compiling the tinyusb examples with gcc >=12. Here is the output:
tinyusb/src/class/audio/audio_device.c:1568:23: error: assuming pointer wraparound does not occur when comparing P +- C1 with P +- C2 [-Werror=strict-overflow]
1568 | while (p_desc < p_desc_end)
| ~~~~~~~^~~~~~~~~~~~
compilation terminated due to -Wfatal-errors.
...
Thanks for the pr, could you add a comment?
Hello, I've just added a comment to the PR to explain why I changed the condition. Thank you for feedback.
@hathach Updated now.
Not sure if there would be value in allowing external definition of FTDI PIDs too, but that should probably be its own PR.
yeah, if you happen to work with FTDI, please submit PR as well if possible.
check out my below request changes.
unless there is a good reason (with explanation), for case where mdk conflicts, nrfx v2 should be used. If it is due to sdk tighted version, please list the sdk + mdk here.
please remove these since they are not tested.
Describe the PR
update hil_test.py and workflow to get esp32s3 board in the loop test
Describe the PR
Allow configuration of PIDs to consider applicable for FTDI serial.
Additional context
This brings the FTDI configuration in-line with the previously modified CP210X configuration options (#2296).
Describe the PR
reduce epstool baudarte cp210x seems to struggle with 1.5MB caussing usb bus error.
Describe the PR
- add nrf52840 to hard in the loop pool
- reset usb bus on pi4 each time, since it seems to have issue with multiple usb device connected somehow !!!
Describe the PR
Add Support stm32h5 for stm32h573i based on stm32_fsdev stm32g0
Board supported : STM32H573I-DK
Implementation Tested on Windows with IAR and GCC toolchain ( via cubeide) and working properly
Additional context
Tested only with audio examples, but sould be ok for other examples
cmake patched : but not tested Linux build : not tested
Added a temporary workaround in make file to support H5 HAL repo ( ARMCC_VERSION=0)
i can send some boards if you need it, send me the adresse via the private email
regards
Operating System
MacOS
Board
custom
Firmware
stm32f723disco
What happened ?
I'm running the stm32f723disco example on a custom board. (Actual chip: STM32F730I8K6.)
USB comms work reliably when connected to an Intel Mac.
USB comms are flaky when connected to an ARM Mac, in which case the USB_OTG_DIEPINT_TOC / DIEPINT_TOC interrupt is occurring on EP0. This causes TinyUSB to loop in handle_epin_irq() (because it never clears the DIEPINT_TOC interrupt). Howev...
Nice PR ! I'm trying to push a commit to fix CI & typo but I got permission denied, could you give maintainers write permission or simply apply the patch ?
done: you should have the access
Describe the PR
- add samd51 (itsybitsy_m4) to hardware test loop
- also move CFG_TUH_LOG_LEVEL/CFG_TUD_LOG_LEVEL to tusb_option.h
- add bossac flasher and rpi_gpio reset for hil test
Describe the PR
- Resolve jlink script error
- Make
size.exeoptional - Generate linker map
- Fix typos
- Update doc
Operating System
Linux
Board
Raspberry Pi Pico
Firmware
1.5.1
What happened ?
Keyboard caps lock control wont work.(Control STALLED, xferred_bytes = 0)
Seem to isolated to this keyboard, out of three that i have available.
Reads keystrokes without issues to debug log.
How to reproduce ?
Plug keyboard in, try to switch on capslock LED with:
tuh_hid_set_report(deviceadress, deviceadress, 0, HID_REPORT_TYPE_OUTPUT, &leds, sizeof(leds));
Keyboard Lenovo SK-8827
...
does IAR has 1 config per folder within the build dir. Normally clion has 1 build dir per config. If possible, change it to {TARGET}_$<CONFIG>.jlink would be better.
Yes each binary has it's own folder.
$ ls
audio_4_channel_mic_Debug.jlink build.ninja build-RelWithDebInfo.ninja CMakeFiles/ RelWithDebInfo/
audio_4_channel_mic_Release.jlink build-Debug.ninja cmake_install.cmake Debug/ tinyusb/
audio_4_channel_mic_RelWithDebInfo.jlink build-Release.ninja CMakeCache.txt Release/
I see, for clion, I typically use one build dir per config. I think maybe we can use
$<TARGET_FILE_DIR:${TARGET}> instead of of ${CMAKE_CURRENT_BINARY_DIR} for the flash target
$ ls
audio_test.elf audio_test.elf.map audio_test.jlink CMakeFiles cmake_install.cmake tinyusb
``
need to change as well, though please try the new $<TARGET_FILE_DIR:${TARGET}>
Describe the PR
reset pi4 usb bus before checkout/download, so that we could skip delay
It gives something like this:
.
βββ build.ninja
βββ build-Debug.ninja
βββ build-Release.ninja
βββ build-RelWithDebInfo.ninja
βββ cmake_install.cmake
βββ CMakeCache.txt
βββ CMakeFiles
β βββ...
βββ Debug
βΒ Β βββ audio_4_channel_mic.elf
βΒ Β βββ audio_4_channel_mic.elf.map
βΒ Β βββ audio_4_channel_mic.jlink
βΒ Β βββ libboard_stm32f439nucleo.a
βββ Release
βΒ Β βββ audio_4_channel_mic.elf
βΒ Β βββ audio_4_channel_mic.elf.map
βΒ Β βββ audio_4_channel_mic.jlink
βΒ Β βββ libboard_s...
perfect, it is what we want the .jlink file in the same folder of the elf for both IAR Workbecnh and clion. Not sure if IAR can execute the -jlink target, if it does, it should be able to flash your board with correct elf
Done.
Currently CMake support is pretty primitive, it defaults to Ninja multi config generator and there is no option for pre/post build actions. And I had multiple crashes modifying CMake file.
I'm going to give them some feedbacks.
I confirmed that this issue occurs on the stock STM32F723E-DISCO board running the stock stm32f723disco example.
It looks like the STLINK-V3MINI boards have a STM32F723 too, so do all STLink V3 devices have flaky USB when connected to ARM Macs? I'd expect lots of complaints if that were the case, but I haven't seen any...
Also, this issue disappears when the device is attached to the ARM Mac through a USB-C hub (instead of attached directly to the ARM Mac.)
thank you for your PR. I have push some update to
- correct some cmake build
- rename board to stm32h573i_dk (dash does not play well with some build system)
- add h5 to cmake ci build
- add h567nucleo since I have this board. Though usb isn't showed up yet. Probably due to clock setup (just copied from your dk just now), will fix in later push.
I don't have mac Mx machine to test with, for the record, are you using OTG HS or FS on F723 ? also which stock exampmle specifcialy e.g cdc_msc ?
This issue occurs when using the OTG HS peripheral on the STM32F7. Interestingly the issue disappears when configuring the OTG HS peripheral to operate in full-speed mode with this change:
diff --git a/src/portable/synopsys/dwc2/dcd_dwc2.c b/src/portable/synopsys/dwc2/dcd_dwc2.c
static void phy_hs_init(dwc2_regs_t* dwc2) {
...
- dcfg |= DCFG_DSPD_HS << DCFG_DSPD_Pos;
+ dcfg |= DCFG_DSPD_FS_HSPHY << DCFG_DSPD_Pos; // Tell HS peripheral to operate in FS mode
This issue app...
Here's the program I'm using to reproduce the issue on an ARM Mac:
https://github.com/davekeck/ST-USB-Issue-Repro/blob/master/ST-USB-Issue-Repro.mm
It simply issues GET_STATUS control transfers in a loop. The issue reproduces after less than 100 control transfers (ie typically takes less than a second).
Confirmed that the stock STLINK-V3MINIE also has this issue. It has the STM32F723 and uses the OTG HS peripheral.
Plug STLINK-V3MINIE into an ARM Mac and run the ST-USB-Issue-Repro.mm program, and this problem occurs.
I just got my protocol analyzer set up about 3 seconds ago, but here are the working (Intel) vs failing (ARM) GET_STATUS traces:
<img width="1665" alt="Intel-Vs-ARM" src="https://github.com/hathach/tinyusb/assets/791944/884257a6-5fb0-4e38-a27d-2bb264550f4a">
I'll dig into that but if anyone has thoughts, let me know...
Good news: setting USB_HS_PHYC_TUNE to 0 fixes this issue, so that's a strong indicator that this issue is in the analog domain:
+++ b/src/portable/synopsys/dwc2/dwc2_stm32.h
@@ -197,7 +197,7 @@ static inline void dwc2_phy_init(dwc2_regs_t* dwc2, uint8_t hs_phy_type) {
// Control the tuning interface of the High Speed PHY
// Use magic value (USB_HS_PHYC_TUNE_VALUE) from ST driver for F7
- USB_HS_PHYC->USB_HS_PHYC_TUNE |= 0x00000F13U;
+ USB_HS_PHYC->USB_H...
The root cause appears to be that we're or'ing the USB_HS_PHYC_TUNE register with the magic value, instead of setting USB_HS_PHYC_TUNE to the magic value. This causes the default value of the LFSCAPEN bit (bit 2) to be retained, where LFSCAPEN is described by the reference manual as:
LFSCAPEN: Enables the Low Full Speed feedback capacitor.
This capacitor is presumably messing up our analog signals, which makes sense because it appears to be intended for low/full-speed mode, ...
Fix issue #2374 by assigning USB_HS_PHYC_TUNE to the magic value, instead of performing a bitwise-or.
Previously, the bitwise-or causes the default value of the LFSCAPEN bit (bit 2) to be retained, where LFSCAPEN is described by the reference manual as:
LFSCAPEN: Enables the Low Full Speed feedback capacitor.
This capacitor interferes with the D+/D- signals (which makes sense because it appears to be intended for low/full-speed mode, but we're in high-speed mode), which break...
This PR was premature, see comments in issue #2374.
Upon further testing, the assign-to-magic-value-instead-of-oring solution (which has the effect of clearing the LFSCAPEN bit) only fixes USB comms when the device is connected to the USB ports on the left side of my ARM Mac. USB comms are still flaky when the device is connected to the USB port on the right side. π€―
I'm guessing the signal integrity of the D+/D- signals isn't great with the USB_HS_PHYC_TUNE magic value of 0xF13.
β¦BLE_MJPG to CFG_EXAMPLE_VIDEO_DISABLE_MJPEG
Describe the PR
A clear and concise description of what this PR solve.
Additional context
If applicable, add any other context about the PR and/or screenshots here.
I took a look at the D+ / D- signals with a 800 MHz diffprobe. My scope only goes to 200 MHz, so I'm comparing the signals between a good device (a USB HS Kingston thumbdrive) versus the STLINK-V3MINIE.
The STLINK-V3MINIE looks a lot noisier by comparison:
thank you for your PR, everything is working well now. The usb issue previously is due to h563 need 8Mhz clock out put from st-link onboard, while I tried to use my jlink. Will probably try to get it running without stlink later on.
thank you for your detail feedback, it is indeed confusing with these phy analog magic timing. I don't have anything to add or test, though please keep update the information. Maybe other could help.
Describe the PR
update lib/freertos kernel to latest v11.0
I think this also affects other weak callbacks, eg. tud_cdc_line_state_cb or tud_cdc_rx_cb don't work either in Keil if not modified in a similar way as this PR does
Yes true. Didn't want to change stuff that I don't use and thus can't test. But should be straight forward.,
Describe the PR
When ISO endpoint handling was introduced two lines that clear stall and data toggle bit were left unchanged and they were effective for ISO endpoint as well.
This is incorrect behavior since EPSTALL and DTOGGLE registers have only 3 bits for address.
Leaving code that clears toggle bit results in endpoint 0 toggle bit being reset when iso endpoint (8) is opened.
Now code that clears stall and toggle bit is applied to non-iso endpoint only as it was done before iso h...
look good, thank you for the fix
which gcc version you are using ?
Thank you for debug video_capture example. It looks good for me regarding video_capture example. But, I can't confirm patches for bluepill board because I don't have the board.
If you want to merge video_capture part quickly, please separate this PR into two PRs: one for the video_capture part and the other for the bluepill part. Then, I will merge the PR for video_capture part immediately.
arm-none-eabi-gcc (Arm GNU Toolchain 12.3.Rel1 (Build arm-12.35)) 12.3.1 20230626
Additional info: this issue doesn't appear to occur on M1 Macs. So as of now:
- Broken: M3 Macs
- Working: M1, Intel Macs
- Untested: M2 Macs
I filed FB13481335 with Apple regarding this issue, but it's still unclear whether the problem is on the host side or device side (or both).
A report of a similar issue (USB-C device works with M1 Mac, broken with M3 Mac):
https://forums.macrumors.com/threads/usb-c-problems-on-new-m3-max-macbook-pros.2410302/
Operating System
Windows 10
Board
Custom board with nRF52840
Firmware
Any bluefruit example
What happened ?
when the board is connected to USB charger with wall adapter the program will stuck at line 1044 ( while ( !(USBD_EVENTCAUSE_READY_Msk & NRF_USBD->EVENTCAUSE) ) { }) in the file dcd_nrf5x.c
How to reproduce ?
Should happen in any board powered by USB with wall adapter where is no enumerated
Debug Log as txt file (LOG/CFG_TUSB_DEBUG=2)
no log available...
ah thanks, my pc (and ci) is currently running with gcc 11. I will try to update and test this soon enough.
- improved debug print of hex values TU_LOG1_HEX, added "0x" before hex value print (src/common/tusb_debug.h)
- added macros for int, hex, mem and buf debug prints in src/host/usbh_pvt.h
- added pid and vid print in src/host/usbh.c
- clean up debug prints in src/host/usbh.c
Describe the PR
allow rp2040 to use max3421e as host controller
- fix warnings build hcd max3421 with rp2040
- add tinyusb_host_max3421 target for rp2040 cmake, -DMAX3421_HOST=1 will enable this
- add max3421 driver implementation for rp2040 family
- update tusb_config for host to allow easy enable host selection for
rp2040: native(default)/pio-usb/max3421e
this is the initial version to support the CH34x CDC device.
the CH34x is as popular as FTDI or CH34x.
this version supports only RX and TX and the line_coding settings.
modem control handling will follow...
Old implementations have some issues:
- EP0 OUT request just copied data from the buffer without any checking
- TOG bit set not correctly for OUT xfers
- Long packets(more then ep size) xfer incorrectly
Fixed this issue #1891 also other examples now work stable
What's the status of this PR? is it going to be merged?
Unfortunately, I still havent got time to look at this. Will do whenever possible
It's nearly 50 lines and a year ago :)
Hope you get time to check it out.
By the way, can we use the same device for absolute and relative in the same descriptor or it has to be 2 different devices?
Operating System
Windows 10
Board
imxRT1024
Firmware
This appears to be a generic problem for FreeRTOS (or any RTOS) applications...
Custom FreeRTOS application, using tinyUSB host mode with a USB stick attached.
Per tinyUSB examples, my FreeRTOS application has a task dedicated to processing USB events as follows:
void usb_host_task(void*) {
tuh_init(BOARD_TUH_RHPORT); // Initialize device stack on configured roothub port.
while (1) {
tuh_task(); // bloc...
Update as I've had a chance to further test this...
Oddly, plugging in a USB stick with application does work with a new faster USB stick (SanDisk Extreme PRO 128GB), but fails with older USB sticks. Looks like a timing error or maybe another race condition. I'll report more when I've had time to further debug...
Allow a CDC-ACM device to send a line state notification to the host (DCD/DSR/RING etc).
It has been tested using statserial command on Linux host side to verify UART-like line status.
It looks like that the notification endpoint size must be at least 10 bytes in order to hold the entire notification packet (which means this won't work for USB low speed devices).
Operating System
Linux
Board
RP2040 Pico
Firmware
Latest github branch (commit 86c416d4c0fb38432460b3e11b08b9de76941bf5 (HEAD, tag: 0.15.0))
What happened ?
Hi!
First please allow me to thank you for making and maintaining this library, it's incredible!
The issue is a small one - I've noticed tusb_inited() does:
bool tusb_inited(void)
{
bool ret = false;
#if CFG_TUD_ENABLED
ret = ret || tud_inited();
#endif
#if CFG_TUH_ENABLED
ret = ret |...
I'm commenting as an observer who's delved into the relevant parts of the USB specs for a while.
endpoint size must be at least 10 bytes in order to hold the entire notification packet (which means this won't work for USB low speed devices).
I'm pretty sure that low-speed USB devices aren't allowed to have bulk endpoints, which rules out typical CDC ACM implementations, so this concern probably doesn't apply.
Describe the PR
I'm using the clang compiler which for our purposes the compiler attributes match GCC from what I can read.
Although TU_ATTR_WEAK had to be changed to __attribute__ ((weak_import)) or I was getting lld: error: duplicate symbol errors on all the TU_ATTR_WEAK functions.