Problems with shell on STM32F405 Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
angainor
Posts: 7
Joined: Mon Dec 20, 2021 6:43 pm
Been thanked: 1 time

Problems with shell on STM32F405  Topic is solved

Postby angainor » Mon Dec 20, 2021 6:56 pm

Hi,

Forgive me if this is not the right forum to ask, I'm new here. I have a problem with the simplest test like the one in demos/STM32/RT-STM32F429-DISCOVERY. I have an OpenPilot Revolution board, which runs an STM32F405. I have created a custom board.(c/h) setup, which initializes my USB correctly, or at least I think so. I have also set up my LED PINs. The test runs just fine up to and including stable_19.1.x. However, versions above that one have issues. Here is a small table, which summarizes what works where:

Code: Select all

                 led            ttyACM0     shell
---------------------------------------------------
stable_19.1.x    blinks         yes         yes
stable_20.3.x    blinks once    yes         no
stable_21.6.x    blinks once    yes         no
stable_21.11.x   blinks         no          no


As shown above, with version 19.1 I can connect to my board using ttyACM0 on Linux, I obtain a shell, I can run tests and generally use the whole shell functionality. In versions 20.3 and 21.6 however the shell doesn't work. When the board starts I can see one blink of the LED, then it's silent. I see that the device has registered as ttyACM0 by looking at dmesg, but when I connect the console I get no input/output. Version 21.11 is different in that the LEDs keep blinking (so the blinker thread is active), but the USB device does not register in Linux (no info in dmesg) and I don't have the console.

I think that the USB is initialized correctly: all works fine in 19, and the USB device registers in Linux in versions 20.3 and 21.6. It looks like something is wrong with the shellThread in those two cases. Version 21.11 is a total mystery.

Could anyone shed some light on that?

Thanks!

Marcin

User avatar
Giovanni
Site Admin
Posts: 14026
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 989 times
Been thanked: 833 times
Contact:

Re: Problems with shell on STM32F405

Postby Giovanni » Mon Dec 20, 2021 8:12 pm

Hi,

The only idea I have is to make sure to use configuration files taken from the version you are using. It looks like some kind of GPIO initialization issue.

Giovanni

angainor
Posts: 7
Joined: Mon Dec 20, 2021 6:43 pm
Been thanked: 1 time

Re: Problems with shell on STM32F405

Postby angainor » Mon Dec 20, 2021 9:21 pm

Thanks, Giovanni. This is also what I suspect, but I'm not able to pin the problem. All looks ok. LEDs always work, it's just the USB and serial driver that seem to fail in the newest version (USB device is not recognized by Linux). And USB seems to work in 20.3.x and 21.6.x, but the shell thread is stuck - I guess on read/write.

I'll have to look more. In case you might find something obviously wrong, this is how I set up my USB device in board.h:

Code: Select all

VAL_GPIOA_MODER
                                     PIN_MODE_ALTERNATE(GPIOA_PIN11_USB_DM) |  \
                                     PIN_MODE_ALTERNATE(GPIOA_PIN12_USB_DP) |  \

VAL_GPIOA_OTYPER
                                     PIN_OTYPE_PUSHPULL(GPIOA_PIN11_USB_DM) |  \
                                     PIN_OTYPE_PUSHPULL(GPIOA_PIN12_USB_DP) |  \
                                     
VAL_GPIOA_OSPEEDR
                                     PIN_OSPEED_HIGH(GPIOA_PIN11_USB_DM) | \
                                     PIN_OSPEED_HIGH(GPIOA_PIN12_USB_DP) | \

VAL_GPIOA_PUPDR
                                     PIN_PUPDR_FLOATING(GPIOA_PIN11_USB_DM) | \
                                     PIN_PUPDR_FLOATING(GPIOA_PIN12_USB_DP) | \

VAL_GPIOA_ODR
                                     PIN_ODR_HIGH(GPIOA_PIN11_USB_DM) | \
                                     PIN_ODR_HIGH(GPIOA_PIN12_USB_DP) | \

VAL_GPIOA_AFRH
                                     PIN_AFIO_AF(GPIOA_PIN11_USB_DM, 0xA) | \
                                     PIN_AFIO_AF(GPIOA_PIN12_USB_DP, 0xA) | \


The only thing is that I do not set up GPIOA_PIN10 as OTG_FS_ID - it's used as USART1_RX on this board.

Thanks again!

Marcin

User avatar
Giovanni
Site Admin
Posts: 14026
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 989 times
Been thanked: 833 times
Contact:

Re: Problems with shell on STM32F405

Postby Giovanni » Mon Dec 20, 2021 9:26 pm

Hi,

About USB, check clock settings carefully, you need a perfect 48MHz clock for USB.

Giovanni

angainor
Posts: 7
Joined: Mon Dec 20, 2021 6:43 pm
Been thanked: 1 time

Re: Problems with shell on STM32F405

Postby angainor » Tue Dec 21, 2021 12:13 am

I think this is also correct. From board.h:

Code: Select all

#define STM32_HSECLK                8000000U


and in mcuconf.h

Code: Select all

#define STM32_HSI_ENABLED                   TRUE
#define STM32_LSI_ENABLED                   TRUE
#define STM32_HSE_ENABLED                   TRUE
#define STM32_LSE_ENABLED                   FALSE
#define STM32_CLOCK48_REQUIRED              TRUE
#define STM32_SW                            STM32_SW_PLL
#define STM32_PLLSRC                        STM32_PLLSRC_HSE
#define STM32_PLLM_VALUE                    8
#define STM32_PLLN_VALUE                    336
#define STM32_PLLP_VALUE                    2
#define STM32_PLLQ_VALUE                    7


So it seems that PLLQ gives ((8MHz/PLLM)*PLLN)/PLLQ=48MHz. heh..

angainor
Posts: 7
Joined: Mon Dec 20, 2021 6:43 pm
Been thanked: 1 time

Re: Problems with shell on STM32F405

Postby angainor » Thu Dec 23, 2021 8:06 am

Hi, Giovanni,

I have found a difference between 21.11.x and the other earlier versions in how USB is set up. In all earlier versions file

Code: Select all

os/hal/ports/STM32/STM32F4xx/stm32_registry.h


in the section for my MCU (STM32F40_41xxx) contains

Code: Select all

#define STM32_OTG_STEPPING                  1


while in version 21.11.x I find

Code: Select all

#define STM32_OTG_STEPPING                  2


I do not have my board with me now, so I cannot test, but could this be the reason why in 21.11.x the USB device is not registered? Is it possible that this change is incorrect and should be reverted to previous version?

Thanks!

Marcin

User avatar
Giovanni
Site Admin
Posts: 14026
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 989 times
Been thanked: 833 times
Contact:

Re: Problems with shell on STM32F405

Postby Giovanni » Thu Dec 23, 2021 9:23 am

Hi,

It is possible, please let me know how it goes and I will handle it as a bug. I don't have F4 boards right now and until 3 of January (left those at office).

Giovanni

angainor
Posts: 7
Joined: Mon Dec 20, 2021 6:43 pm
Been thanked: 1 time

Re: Problems with shell on STM32F405

Postby angainor » Wed Dec 29, 2021 2:17 pm

Hi, Giovanni,

I have tested my board with STM32_OTG_STEPPING=1 and it works fine. I get a shell, tests pass. With STM32_OTG_STEPPING=2 USB serial device does not work. I guess it's a bug?

Marcin

User avatar
Giovanni
Site Admin
Posts: 14026
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 989 times
Been thanked: 833 times
Contact:

Re: Problems with shell on STM32F405

Postby Giovanni » Wed Dec 29, 2021 2:59 pm

Hi,

Moving this to bug reports, will be fixed in next release.

Giovanni

User avatar
Giovanni
Site Admin
Posts: 14026
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 989 times
Been thanked: 833 times
Contact:

Re: Problems with shell on STM32F405

Postby Giovanni » Sat Jan 22, 2022 8:28 am

Hi,

Fixed as bug #1214.

Giovanni


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 3 guests