STM32F103C8T6 USB CDC

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderators: barthess, RoccoMarco

Tuxford
Posts: 3
Joined: Fri Nov 06, 2020 3:28 pm
Has thanked: 1 time

STM32F103C8T6 USB CDC

Postby Tuxford » Fri Nov 06, 2020 3:38 pm

I have STM32F103C8T6 eval board "Blue Pill". Then I took RT-STM32F103-MAPLEMINI example, change ld for this MCU and ran this example. But when I try to connect by gtkterm it gives next error: "Control signals read: Inappropriate ioctl for device". Also I have tried to connect with simple PySerial example and it gives about same message.
What else has to be implemented for being ready to receive some date over USB.
In Linux it is available with the name /dev/ttyACM0

Thank You,

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

Re: STM32F103C8T6 USB CDC

Postby Giovanni » Fri Nov 06, 2020 3:45 pm

Hi,

When porting from one board to another you need to create new "board files" or GPIO/clock settings will likely not be compatible, that can create any kind of errors.

Look at board files under /os/hal/boards.

Giovanni

electronic_eel
Posts: 45
Joined: Sat Mar 19, 2016 8:07 pm
Been thanked: 9 times

Re: STM32F103C8T6 USB CDC

Postby electronic_eel » Sat Nov 07, 2020 6:52 pm

Tuxford wrote:I have STM32F103C8T6 eval board "Blue Pill".

I don't know if you are aware of this, but recently a lot of the boards sold as "Blue Pill" do not contain true STM32F103 from ST anymore, but MCUs that are more or less compatible from other manufacturers. Sometimes they carry their true chip marking, sometimes the marking is faked to read ST.

These MCUs often are able to run basic programs designed for the STM32F103 just fine, but once you use more advanced peripherals like DMA, there are differences that let the programs fail. This could be the issue you are seeing.

Here is some more information about this issue, photo comparison and a program designed to detect the fakes:
https://www.blaatschaap.be/tag/32f103/
https://github.com/keirf/Greaseweazle/wiki/STM32-Fakes

rreignier
Posts: 23
Joined: Sat Apr 15, 2017 11:49 pm
Has thanked: 7 times
Been thanked: 4 times

Re: STM32F103C8T6 USB CDC

Postby rreignier » Mon Nov 09, 2020 2:28 pm

The board definition STM32F103C8_MINIMAL already in ChibiOS sources should work for a Blue-Pill with a real STM32.

Tuxford
Posts: 3
Joined: Fri Nov 06, 2020 3:28 pm
Has thanked: 1 time

Re: STM32F103C8T6 USB CDC

Postby Tuxford » Mon Nov 09, 2020 3:14 pm

@electronic_eel
I know about it. Other case is CS32F103C8T6 instead of STM32F103C8T6. This is not my case. The problem is related to insufficient knowledge of ChibiOS.

So.. I took wrong board.c. I took minimal board config:

Code: Select all

#include "hal.h"

#if HAL_USE_PAL || defined(__DOXYGEN__)
const PALConfig pal_default_config = {
    {VAL_GPIOAODR, VAL_GPIOACRL, VAL_GPIOACRH},
    {VAL_GPIOBODR, VAL_GPIOBCRL, VAL_GPIOBCRH},
    {VAL_GPIOCODR, VAL_GPIOCCRL, VAL_GPIOCCRH},
    {0, 0, 0},
    {0, 0, 0},
};
#endif

void __early_init(void)
{
    stm32_clock_init();
}

void boardInit(void)
{}

Device started well. Then I tried to handle data receiving.

Code: Select all

static const USBEndpointConfig ep1config = {
  USB_EP_MODE_TYPE_BULK,
  NULL,
  sduDataTransmitted,
  onDataReceived,
  0x0040,
  0x0040,
  &ep1instate,
  &ep1outstate,
  2,
  NULL
};

But breakpoint doesn't hit in onDataReceived. Is there some doc how to implement data handling via USB CDC?

Tuxford
Posts: 3
Joined: Fri Nov 06, 2020 3:28 pm
Has thanked: 1 time

Re: STM32F103C8T6 USB CDC

Postby Tuxford » Fri Nov 20, 2020 9:15 pm

Problem occurred because thread try to write when usb device isn't ready yet.

And other thing. On STM32F103 Smart v.2. USD doesn't work at all.


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 5 guests