Page 1 of 1
STM32F103C8T6 USB CDC
Posted: Fri Nov 06, 2020 3:38 pm
by Tuxford
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,
Re: STM32F103C8T6 USB CDC
Posted: Fri Nov 06, 2020 3:45 pm
by Giovanni
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
Re: STM32F103C8T6 USB CDC
Posted: Sat Nov 07, 2020 6:52 pm
by electronic_eel
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
Re: STM32F103C8T6 USB CDC
Posted: Mon Nov 09, 2020 2:28 pm
by rreignier
The board definition STM32F103C8_MINIMAL already in ChibiOS sources should work for a Blue-Pill with a real STM32.
Re: STM32F103C8T6 USB CDC
Posted: Mon Nov 09, 2020 3:14 pm
by Tuxford
@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?
Re: STM32F103C8T6 USB CDC
Posted: Fri Nov 20, 2020 9:15 pm
by Tuxford
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.