I am trying to input data to a pico from a USB barcode reader (in either HID or virtual com mode).
OTG is not required , USB would be a dedicated input.
Happy to dig deeper and get a logic analyser on the case but USB low level signalling is a new world for me. Searching the forums :
So my questions here are:
and any suggestions on investigations I could do to move this forward appreciated.
Thanks in Advance
I'm afraid nothing has progressed on USB Host. While possible with the hardware (although I think most implementations add some kind of USB switch device?) there'd be a lot of software work required in Espruino, and that hasn't been done.
So I think your main options would be:
Sorry to not have better news!
Thanks for the confirmation and the clear options. I’ve been doing some more googling and checked out the libraries and stm32 reference docs. I think it’s possible but I have to say it looks incredible complex.
On a general point this https://youtu.be/4FOkJLp_PUw
is a great youtube tutorial with stm32 that shows the logic analyser techniques (and effort ) it might take to debug such a development.
I’ll investigate a bit more , Signed up to Udemy course on interfaces in embedded c, for stm32 !!! but no promises.
Out of interest , and maybe mid term answer to my problem, have you decided if, the new Espruino Wi-fi Board might support USB host ! Or use hardware that could. ? If one was going to invest time in this maybe it be better spent that way.
Thanks again for considered response.
And Happy new year.
I'm pretty sure the new Wifi won't support USB Host I'm afraid - it'll be using the nRF52840 which supports device only :(
But that’s good to know in any event.
PICO it is then.
Will let the forum know how I get on, in the c driver, usb host , stm library world !
Quick status, having spent some time on this, Im going to make a serious attempt at adding a USB host functionality option on the Pico build for host HID support.
Approach maybe with a with a new E.USBSetHost, function that can be used in conjunction with the existing E.USBSetHID to set the mode between: USB device Virtual com (default) , USB Device with HID or USB Host for HID. ie set to host on next USB insert of the board.
Will add discussion on an approach for comment after more learning on my part.
status So far:
Working thru Udemy course embedded driver development for STM32.
Learnt how to successfully build Espruino and flash to Pico on Ubunto box
Currently getting to grips with the current Pico USB build: Looking at the STM libraries currently employed, working back from STM32_USB.make, using STM Library docs. , understanding how E.USBSetHID is implemented.
Found great basic USB tutorial.
Trying to get hold of a STM32F407G DISC BOARD for the development as it has debug capability and USB wired up to STF32F4.... But struggling on availability, just spoke to Anglia Live sales rep to complete questionnaire on my 'project' to justify having stock allocated to me !
So told her this was a project to enhance the Espruino project , hope that is enough.
If ok , will raise an issue for an enhancement 'Provide USB Host functionality on Pico' on Github to formalise the work, in case it helps with supply issue of the dev board. And then can have discussion there on the approach .
Just heard the discovery board has been dispatched :)
From the GitHub commits and changes of the STM drivers in Espruino (targetlibs/stm32usb/Src/) back in 2015 , it looks like GWilliams was very busy and there were a ton of changes to the STM libraries to get USB working in Espruino. SO .... clearly changing existing functionality to use more recent STM libraries is not agood idea ! So approach has to be that any Host functionality is all incremental and sits beside existing device virtual com and HID. However that also makes sense, looking at the current STM host libraries in
... they would be a parallel set to the existing device libraries on the stack. See Attached pic.
complicated ....... still early days. update in a couple of weeks.
Realised that given my requirement is to input to pico from usb barcode readers that are usually capable of output in virtual com mode, then may only need host CDC capability on the pico and not need host HID also. So will start with host CDC .
Initially , looks like CDC is an easier implementation and needing fewer library files.
Interested in others view , if you only had one usb class of input. HID or virtual com ?
I think probably CDC - with that you can pretty much just open up the right endpoint (which you could hard-code rather than trying to read the descriptors on the fly) and then you should usually receive serial data on it. I don't think there's much other setup required (but I guess it depends on the device)
Thanks Gordon, CDC it is.
Quick status ... still putting in lots of hours on this. Steep learning curve for me. Achieved so far,
P.s any advice always appreciated.
A little wire wrapping going on in the mean time. :)
Looks great! Hope it goes well!
Yes, building with the new ST APIs is a bit of a pain. You may find some clues in the targets/stm32l4 code, but also I seem to recall that on the whole you could split things up enough that mostly the USB could use the new HAL and everything else could use the old HAL
Don't worry about formatting, just type in the text and we'll take care of making sense of it. We will auto-convert links, and if you put asterisks around words we will make them bold.
For a full reference visit the Markdown syntax.
© Espruino, powered by microcosm.
Report a problem