Problems using USB on STM32F413 Topic is solved

Use this forum for requesting small changes in ChibiOS. Large changes should be discussed in the development forum. This forum is NOT for support.
A319
Posts: 48
Joined: Thu Feb 05, 2015 9:52 am
Has thanked: 2 times
Been thanked: 3 times

Problems using USB on STM32F413

Post by A319 »

Hi,

I'm trying to get USB running on my own device (my Pecan Project). I had a predecessor Pecan Pico 8b and I got it working on this device using a STM32F429.

The sucessor Pecan Pico 9a doesn't use a STM32F413 instead. That chip has only the OTG1 and no OTG2. So I moved everything to the PA port. Unfortunately there is no STm32F413 yet available for ChibiOS, so I'm using the alternative STM32F412 model which works also fine (with some exceptions).

Since this is my own design I checked all pins and especially the design. I did this by wiggling PA11 (D-) and PA12 (D+) by software and measure this on a cut USB cable. The voltage level is at around 2.90V which is a little bit low. Tough I think it should still work. But at the moment I feed 3.3V externally to rule out such an error.

I also see my computer looking for a device on my oscilloscope having a signal level of 3.7V but the STM32F413 doesn't respond. It would have a lower voltage level on the oscilloscope. But I cannot see any.

I saw the datasheet telling: "The USB OTG full-speed controller requires a dedicated 48 MHz clock, which is generated by a PLL connected to the HSE oscillator" (Datasheet STM32F413xG/H [DocID029162 Rev 4], Chapter 3.33, Page 40).
While I cannot bring the HSE currently to work, I use the HSI. I think that is possible since I have used USB with the HSI on the STM32F429 before (or might there be an issue).

Currently I can't bring the HSE to work. The MCU stops working when enabling it (using STM32_HSE_ENABLED), even if the MCU supposed to use the HSI.

The Code which I use is available on Github if somebody wants to check something: https://github.com/DL7AD/pecanpico9/tre ... r/software

USB is started in the main.c
https://github.com/DL7AD/pecanpico9/blo ... are/main.c

In the usbcfg.c I have changed everthing to USBD1
https://github.com/DL7AD/pecanpico9/blo ... e/usbcfg.c

Best Regards
Sven
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Problems using USB on STM32F413

Post by Giovanni »

Hi,

The F413 is not supported yet, differences with other devices have not been analyzed yet, hard to tell what your problem could be.

Giovanni
A319
Posts: 48
Joined: Thu Feb 05, 2015 9:52 am
Has thanked: 2 times
Been thanked: 3 times

Re: Problems using USB on STM32F413

Post by A319 »

That could be a problem. But so far I know, nothing has changed between the STMF412 and STMF413. I couldn't see any difference in the Reference Manual.

By the way. I've got the HSE working. It has been a hardware problem. But it didn't affect the USB problem unfortunately.

Sven
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Problems using USB on STM32F413

Post by Giovanni »

Note that both F412 and F413 are different from the other F4s and require a new clock tree.

Giovanni
User avatar
RoccoMarco
Posts: 655
Joined: Wed Apr 24, 2013 4:11 pm
Has thanked: 83 times
Been thanked: 67 times

Re: Problems using USB on STM32F413

Post by RoccoMarco »

Hi, F412 and F413 are still unsupported since there are some small differences in clock tree. I will add support soon.
A319
Posts: 48
Joined: Thu Feb 05, 2015 9:52 am
Has thanked: 2 times
Been thanked: 3 times

Re: Problems using USB on STM32F413

Post by A319 »

Hi,

Thanks Rocco. I thought F412 is already supported... Because I can see the Nucleo144-F412ZG in the repository.

Best Regards
Sven
User avatar
FXCoder
Posts: 403
Joined: Sun Jun 12, 2016 4:10 am
Has thanked: 188 times
Been thanked: 134 times

Re: Problems using USB on STM32F413

Post by FXCoder »

Hi Rocco and Giovanni,
I've been adding STM32F413 to RT.

Made updates to:
os/common/ext/CMSIS/ST/STM32F4xx/stm32f4xx.h
os/hal/ports/STM32/STM32F4xx/hal_lld.h
os/hal/ports/STM32/STM32F4xx/stm32_rcc.h
os/hal/ports/STM32/STM32F4xx/stm32_registry.h

Added:
os/common/ext/CMSIS/ST/STM32F4xx/stm32f413xx.h

So far have added the extra timers (inc LPTIM1), uart, spi, i2c, i2cfmp (not sure if this should be added as I2C4 with a define for supports FMP), etc. but not made any driver changes.
Thus I've got only the basics of what will really be needed in order to make a F413 specific implementation but it's a start.
At least a demo project of NUCLEO-F413ZH (a clone of the F412 demo project with changes, new board config) will compile.
I thought as the next step to load this to the NUCLEO-F413ZH board to see if the basics work.
Unfortunately openocd in Chibistudio doesn't recognise the F413.
So next adventure is to get the latest patched openocd with F413 support (http://openocd.zylin.com/#/c/4045/).
Before I mess about with installing MSYS2 and building openocd I wondered if you had the patched openocd already?

Thanks,

Bob
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Problems using USB on STM32F413

Post by Giovanni »

Hi,

The latest OpenOCD we compiled is here under tools: https://svn.code.sf.net/p/chibios/svn/b ... udio_trunk

Giovanni
User avatar
FXCoder
Posts: 403
Joined: Sun Jun 12, 2016 4:10 am
Has thanked: 188 times
Been thanked: 134 times

Re: Problems using USB on STM32F413

Post by FXCoder »

Thanks Giovanni.
The openocd in the SVN reports version as: Open On-Chip Debugger 0.10.0-dev-00107-ge4848fe (2015-11-13-11:49)
F413 support was initially added in March 2017 and was still getting patch updates as recently as June 13.
Your repo version of openocd (derived from MSYS2) is not that recent.
So I may have to setup to build openocd from scratch or perhaps wait for Freddie Chopin to release a binary.
Depends on time availability.

Meanwhile I've flashed the NUCLEO demo code (same functionality as F412 demo) using ST-LINK Utility V4 and updated firmware on the Nucleo ST-LINK to V2.J28.M18.
The demo code loads and runs the Chibios test suite so at least the basics are working.

Regarding earlier posts in this thread I'm not sure which differences exist that need a revised clock chain setup.
For sure I2CFMP uses different clock selection that needs to be catered for.
Not sure if that was it or there are more/different changes required?
If you can let me know what you saw as needing work I'll review the RM, etc. and see if I can implement required changes.

Thanks,

Bob
User avatar
RoccoMarco
Posts: 655
Joined: Wed Apr 24, 2013 4:11 pm
Has thanked: 83 times
Been thanked: 67 times

Re: Problems using USB on STM32F413

Post by RoccoMarco »

Hi,
have you checkout the right subfolder?
https://svn.code.sf.net/p/chibios/svn/b ... s/openocd/

My version reports
Open On-Chip Debugger 0.10.0+dev-00146-g1025be363 (2017-06-11-20:37)

Let me know where the problem is.
Post Reply