DrMN wrote: Tue Dec 06, 2022 3:37 pm
@GonzoG Thank you, that is a big help.
I should probably be more careful with language. For the application, I plan to communicate with the pc by serial over usb. The data rate going back to the pc needs to be about 1MB/s, faster is better of course.
From your previous description, it seems like serial over usb can be via the already present usb connector or by wiring a usb connector to pins PA11/PA12. I vote for simplicity - almost always. So that would seem to point to using the onboard connector.
For flashing the application to the board, for the moment, I prefer to use the onboard usb connector.
Aside, I guessed that SWD means software debugging? That sounds useful, An ICE might be even better. Arduino famously does not support either. So, I am curious about how to use a debugger with the Nucleo. But, apart from DMA, what I am doing is simple enough for the holy and time-honoured print statement and "blink the led". So, setting it up might only be a distraction for the moment.
Thank you again.
I'm thinking you can actually get one of those boards, like the stm32f401/f411 "black pill" boards
e.g.
https://www.aliexpress.com/item/1005001456186625.html
https://stm32-base.org/boards/STM32F401 ... -Pill-V3.0
https://github.com/WeActStudio/WeActStu ... iSTM32F4x1
note that there are others making similar boards, but that the configuration (e.g. pinouts, buttons, etc) may be different
https://www.aliexpress.com/wholesale?ca ... =stm32f401
or a stm32f405 feather from Adafruit
https://www.adafruit.com/product/4382
or a Pyboard
https://store.micropython.org/product/PYBLITEv1.0
or a stm32F405 dev board from Olimex
https://www.olimex.com/Products/ARM/ST/STM32-H405/
STM32F405 is a 168 Mhz chip and has considerably more resources 1 M flash, 512k sram and is consequently more expensive
the 3rd party boards mostly have the usb connector directly connected at PA11/PA12 all done on board.
the stm32f4xx series has a DFU boot loader built in
https://learn.adafruit.com/adafruit-stm ... er-details
what it takes is to set boot0, press reset it it should be in usb (DFU) mode waiting for the upload.
of course, as you have the L432 Nucleo, you can also buy the usb breakout modules and connect PA11/PA12 accordingly along with the usb power lines. And I think you can try setting boot0, pressing reset to try uploads as well.
on stm32 the normal usb is full speed 12 Mbps, but that because usb (host/pc) multiplex the connections by polling every device for 1 ms each (round robin) the bandwidth is heavily shared by all the connected usb devices (including hubs (there are hidden ones)) e.g. your mouse, keyboard, etc.
in my tests on my own pc (running Linux) usb serial gives about 1.x Mbps maximum. Note that for USB, there are other protocol overheads as well.
--- the difficult way:
Accordingly, the stm32f405 can interface a USB high speed ULPI transceiver (480 Mbps), but that I've never tried it prior.
There are modules like such
https://www.aliexpress.com/wholesale?ca ... xt=usb3300
you would need to check the pin accessibility on the dev boards if you want to do that as well, preferably get a board where all the pins goes to the headers.
At those speeds, I'd think signal quality / signals etc is critical, any stray capacitance or impedance mismatch is effectively a short circuit or open circuit.
And I think usb high speeds actually use signals like 0.3v. Shielded cables are necessary as well to prevent signal degradation and possible interference.
---
another solution which I kind of thought about is to get a separate USB host adapter
https://www.aliexpress.com/wholesale?ca ... ss+adapter
they are quite cost-effective the idea is to reduce the multiplexing so that you can have as much of the 12 Mbps USB full speed as is possible.
but again I've never tried this prior.
Note that this may not help if, after all there are many ports on the hub internal to the host adapter, as it may still poll the 'empty' ports. But I'm not sure if this is indeed the case.
----
as i'm using Linux
I do use various 3rd party, open sourced utilities
https://github.com/stlink-org/stlink
^ this is for st-link, you have a st-link on your Nucleo board, so you can try it.
https://dfu-util.sourceforge.net/
^ open sourced dfu-util, this can work with ST chips with DFU boot loader, set boot0, press reset:
Code: Select all
dfu-util -a 0 -s 0x8000000 -RD sketch.bin
https://pypi.org/project/stm32loader/
^ this is for upload over serial, you need a separate usb-uart dongle to connect to PA9/PA10 for the flashing, again set boot0, press reset
The trouble with the open sourced utilities is that in Windows there may be different additional driver requirements, hence they may not work out of the box. But that stm32cubeprogrammer would have the driver issues accounted for as it is developed to work natively in Windows.
---
There is another thing which I don't understand fully is about the usb polling on the host/pc.
can this be controlled influenced by software?
e.g. that there are mouses which allows setting polling rates, but that normally HID uses interrupt requests, so I'm not too sure if it'd work with USB (CDC) serial.
A thing is we may not have access to the os driver layers that control polling even if it is software driven.
if it is hardware driven, e.g. by the host controller/adapter, it is likely we have even less control over it unless there is some registers we can set in the host controller/adapter to influence polling.
but that if these are possible, then we can 'optimize' the usb bandwidth e.g. to use as much of the 12 Mbps as is possible
it seemed some of the answers may be found in the host controllers specifications
https://www.intel.sg/content/www/xa/en/ ... ation.html
some interesting reading here as well
https://learn.microsoft.com/en-us/windo ... allocation
--
note that optimizing usb transfers on the device can be tricky as well, i've tried something like to read from ADC then transferring to usb sequently, e.g. read into a 2KB buffer then sending it. I'd think things like Serial.write(buffer, size) rather than Serial.print() or Serial.write() a single char at a time can improve throughput. But i did it sequentially. Other more 'difficult' things may involve double buffers and DMA. This would likely improve the throughput to usb as well.
--
oh and of course, another *cheap* and 'simple minded* way is to temporary disconnect other devices, e.g. mouse / keyboard to see if it could improve on all that usb multiplexing. There is a chance this works, because polling is all controlled by the host / os / apps etc.
-- swd / debug
Nucleo boards has st-link on board
https://www.st.com/resource/en/user_man ... ronics.pdf
https://www.st.com/resource/en/applicat ... ronics.pdf
so you can already do that if you want
and as usual, this is an 'advanced' topic, don't forget to review the wiki
https://github.com/stm32duino/wiki/wiki
there are some tips on how you can do that
https://github.com/stm32duino/wiki/wiki/How-to-debug