Discussion:
[libopencm3-devel] USB: stm32/st_usbfs_v1 vs st_usbfs_v2 (stm32f103)
Warren Gay
2017-03-14 14:14:41 UTC
Permalink
Earlier I posted to the list about my attempt to use the f107 usb driver on
the stm32f103c8t6 MCU, which turned out to be inappropriate (no OTG support
for f103).

I later discovered an example using the st_usbfs_v1 driver. Using that, I
was able to get a modified USB CDC demo going, and later even under
FreeRTOS as well. The name of this driver (with "fs" in it) originally
caused me to doubt that I could use it for this purpose. But it seems to
work just fine as a polled driver. Within FreeRTOS, you just have to run
everything USB driver related from one thread.

My present question for the list:

*What is the difference between st_usbfs_v1.c and st_usbfs_v2.c? *

Based upon a diff and comments, it would appear that v2 was created to deal
with limitations of the Cortex-M0 unaligned copies (bytewise copies vs
words). Is that entirely it? I just want to verify that the v1 driver is my
best choice for the f103 (without forced alignment enabled).

Thanks, Warren
Angelo Di Chello
2017-03-14 14:39:54 UTC
Permalink
Hi Warren,

I don't know all the details about your development and the study you are
doing, I have read something fast, and I may say something that is obvious
to you, but that costed me a bit of time... so, what I'd like to tell you
is to take care about how the different arm architectures treat the
unaligned accesses to memory (LDR, STR ).

While architecture v7 does NOT give an hard fault for unaligned accesses if
there is no UNALIGN_TRAP bit active in the CCR register, v6m (and I guess
v6) will always give a core generated hard fault.

This means that if you have a message stored in your memory and you think
you may, as an example, access the payload of the message with 32-bit word
alignment, you should take care that your payload is really 32-bit word
aligned in the case of cortex M0 and M0+ or access it with byte alignment,
while for M3 and M4 that should not really matter if the trap bit is 0
(usually it's default to 0, but it's up to the chip designer to set this...
so better check it out).

Hope this helps,
Angelo.
Post by Warren Gay
Earlier I posted to the list about my attempt to use the f107 usb driver
on the stm32f103c8t6 MCU, which turned out to be inappropriate (no OTG
support for f103).
I later discovered an example using the st_usbfs_v1 driver. Using that, I
was able to get a modified USB CDC demo going, and later even under
FreeRTOS as well. The name of this driver (with "fs" in it) originally
caused me to doubt that I could use it for this purpose. But it seems to
work just fine as a polled driver. Within FreeRTOS, you just have to run
everything USB driver related from one thread.
*What is the difference between st_usbfs_v1.c and st_usbfs_v2.c? *
Based upon a diff and comments, it would appear that v2 was created to
deal with limitations of the Cortex-M0 unaligned copies (bytewise copies vs
words). Is that entirely it? I just want to verify that the v1 driver is my
best choice for the f103 (without forced alignment enabled).
Thanks, Warren
------------------------------------------------------------
------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
libopencm3-devel mailing list
https://lists.sourceforge.net/lists/listinfo/libopencm3-devel
Karl Palsson
2017-03-14 14:54:33 UTC
Permalink
Post by Warren Gay
*What is the difference between st_usbfs_v1.c and
st_usbfs_v2.c? *
Based upon a diff and comments, it would appear that v2 was
created to deal with limitations of the Cortex-M0 unaligned
copies (bytewise copies vs words). Is that entirely it? I just
want to verify that the v1 driver is my best choice for the
f103 (without forced alignment enabled).
Not best, only. st_usbfs_v1 is for ST's USB Full Speed peripheral
implementation version 1. ST has a very similar, but different
version in some other devices. They also have a completely
different USB implementation they licensed from Mentor (the
classic "dwc_otg" core) as found on all the devices that support
USB-OTG: (including f107) Even this peripheral has versions and
differences.

Cheers,
Karl P

Loading...