example interfacing a STM32F4 with libusb

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
Mathias
Posts: 43
Joined: Thu Jun 28, 2012 6:19 pm

Re: example interfacing a STM32F4 with libusb

Post by Mathias »

Giovanni wrote:There are three new configuration option that should be considered when using this driver.

Do you mean "txpending", "thd_ptr" and "thd_wait" ? Those are the only new options I found and as far as I can tell I don't have to fiddle with them at all.
Without changing anything, the new driver works like a charm, many thanks for improving it, much appreciated!

@Kjell I'm still trying to use the asynchronous libUSB api, but I don't have much free time to do so. If you get something working, I'd be happy to test your code.
*edit* I have an asynchronous version ready, but it uses ~20x more CPU power, because its braindead implemented. I'll push it when its fixed.
Mathias
Posts: 43
Joined: Thu Jun 28, 2012 6:19 pm

Re: example interfacing a STM32F4 with libusb

Post by Mathias »

So I added the asynchronous libUSB example. I'm not sure if its elegant or something, from the example point of view it looks quite weired, because there is still a main while loop that processes all the events, but thats how libUSB works. It can't create a callback out of nowhere. For a real application this event handler has to be moved to somewhere sane.

From my point of view I'm done working on this example. The speed is up to what USB FS can do and I even have an example doing something remotely useful. Maybe this thread should be moved back to the code samples forum? Or split into a dev and an example thread?
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: example interfacing a STM32F4 with libusb

Post by Giovanni »

The thread can stay here, I have no time to do all the splitting, probably we need a dedicated global moderator.

About your example, IMHO examples are best kept simple, I suggest to focus it on code readability and freeze it (then you could open another topic in the other forum with all the info and the package).

Giovanni
kab
Posts: 70
Joined: Sun Sep 16, 2012 6:18 pm

Re: example interfacing a STM32F4 with libusb

Post by kab »

with latest trunk i try to compile:

Code: Select all

d:\chibios.git\testhal\STM32F4xx\USB_CDC>make
Compiling ../../../test/test.c
In file included from ../../../os/hal/include/hal.h:35:0,
                 from ../../../test/test.c:30:
../../../os/hal/platforms/STM32F4xx/hal_lld.h:967:2: error: #error "STM32_PLLCLKIN outside acceptable range (STM32_PLLIN_MIN...STM32_PLLIN_MAX)"
../../../os/hal/platforms/STM32F4xx/hal_lld.h:1187:2: error: #error "STM32_PLLI2SVCO outside acceptable range (STM32_PLLVCO_MIN...STM32_PLLVCO_MAX)"
In file included from ../../../os/hal/include/usb.h:314:0,
                 from ../../../os/hal/include/hal.h:60,
                 from ../../../test/test.c:30:
../../../os/hal/platforms/STM32/OTGv1/usb_lld.h:182:2: error: #error "the USB OTG driver requires a 48MHz clock"
make.EXE: *** [build/obj/test.o] Error 1


Only one difference - i change board from Olimex to STM32 F4 Discovery...
User avatar
Badger
Posts: 346
Joined: Mon Apr 18, 2011 6:07 pm

Re: example interfacing a STM32F4 with libusb

Post by Badger »

Have you updated your halconf.h? they have changed and now have USB options
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: example interfacing a STM32F4 with libusb

Post by Giovanni »

Correct, and not all STM32 halconf.h are equal, make sure to use the right one for your device.

Giovanni
kab
Posts: 70
Joined: Sun Sep 16, 2012 6:18 pm

Re: example interfacing a STM32F4 with libusb

Post by kab »

once again, i take fresh copy from git and try to compile test.
only once thing is modified - i change board include in Makefile to:

Code: Select all

include $(CHIBIOS)/boards/ST_STM32F4_DISCOVERY/board.mk


nothing else was changed in sources from git. i try to use another halconf.h (from \chibios.git\testhal\STM32F4xx\UART\ and enable USB in it) and got same error.
kab
Posts: 70
Joined: Sun Sep 16, 2012 6:18 pm

Re: example interfacing a STM32F4 with libusb

Post by kab »

i've try again, get fresh copy from git, run make in \chibios.git\testhal\STM32F4xx\USB_CDC\ - all fine, all compiled.

now change
include $(CHIBIOS)/boards/OLIMEX_STM32_E407/board.mk
to
include $(CHIBIOS)/boards/ST_STM32F4_DISCOVERY/board.mk

in Makefile.

try to compile - got same error as above. this test should work with STM F4 Discovery? or some modifications required?
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: example interfacing a STM32F4 with libusb

Post by Giovanni »

Are you using an F1 device or an F4 device? USB is different among the two.

Giovanni
kab
Posts: 70
Joined: Sun Sep 16, 2012 6:18 pm

Re: example interfacing a STM32F4 with libusb

Post by kab »

i try to compile both (at least one) ))

i have a lot of boards and try to build STM32 F4 Discovery and custom F103RET6 (problem described in another thread).
Post Reply