I try to enable usb serial on my blue pill with 10k pc13 led
I have notebook MSI GE62 i7 haswell with ubuntu 15.04 with USB3.0 ports
My goal have only USB serial without DFU mode but no luck.
So I resolder 10k to 1.5k and reflash with stlink bootloader wi pc13 suffix.
When I reconnect usb I have DFU mode but fail to create USB serial. also USB autoreset doesn’t work.
If I manually reset all works fine and I can donload sketches.
So I tried to compile libopencm3-examples https://github.com/libopencm3/libopencm3-examples
so I choose https://github.com/libopencm3/libopencm … usb_cdcacm
and flash it with openocd. and I magically have ttyACM0 port. and it works even with 10k resistor.
Also I tried create with CubeMX USB CDC https://github.com/rogerclarkmelbourne/ … uino_STM32
But also I can’t create USB CDC.
here is my dmesg
[ 1830.130974] usb 1-1: new full-speed USB device number 4 using xhci_hcd
[ 1830.243005] usb 1-1: device descriptor read/64, error -71
[ 1830.459167] usb 1-1: device descriptor read/64, error -71
[ 1830.675250] usb 1-1: new full-speed USB device number 5 using xhci_hcd
[ 1830.787284] usb 1-1: device descriptor read/64, error -71
[ 1831.003470] usb 1-1: device descriptor read/64, error -71
[ 1831.219575] usb 1-1: new full-speed USB device number 6 using xhci_hcd
[ 1831.219751] usb 1-1: Device not responding to setup address.
[ 1831.423756] usb 1-1: Device not responding to setup address.
[ 1831.627796] usb 1-1: device not accepting address 6, error -71
[ 1831.739880] usb 1-1: new full-speed USB device number 7 using xhci_hcd
[ 1831.740051] usb 1-1: Device not responding to setup address.
[ 1831.944150] usb 1-1: Device not responding to setup address.
[ 1832.148138] usb 1-1: device not accepting address 7, error -71
[ 1832.148204] usb usb1-port1: unable to enumerate USB device
Please send a link to your board
Where are you soldering this resistor.
10k is far to high for a led or for USB signalling
For the USB you need 1.5k and it needs to be soldered between PA12 and the 3.3V positive (however most generic boards already have this resistor) The only board I know that does not have it is the GD32
here is my http://ru.aliexpress.com/item/mini-Stm3 … 85935.html
So I remove R10 resistor and solder 1.5k from PA12 to 3.3v.
Also PA12 to D+ have 22Oms.
It’s too strange that libopencm3-example usb_cdc works fine without replacing resistor and your DFU works perfectly too, but not Serial.
Re:Serial
Serial code is only inside the sketch, not the bootloader.
So you need to upload a sketch with the correct board selected (Generic STM32F103C) and upload via bootloader
Then after the sketch runs, there should be Serial
dmesg says that can’t enumerate USB
I tried also with Serial1 – the same result.
Also when board in DFU mode it can’t reset USB after upload flash.
void setup() {
// initialize digital pin 13 as an output.
pinMode(PC13, OUTPUT);
Serial.begin(115200);
}
void loop() {
Serial.println("11111");
digitalWrite(PC13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(PC13, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
Board is genericSTM32F103C.
Arduino_STM32 from today git
Also I tried to use HALMX from your repo
Also doesn’t work
Also I tried to upload from STLink and add -DSERIAL_USB to STLink upload profile.
P.S. I use gcc-4.9.3 to compile sketches and adruino 1.6.4.
###################### Generic STM32F103C ########################################
genericSTM32F103C.name=Generic STM32F103C series
genericSTM32F103C.build.variant=generic_stm32f103c
genericSTM32F103C.build.vect=VECT_TAB_ADDR=0x8000000
genericSTM32F103C.build.core=maple
genericSTM32F103C.build.board=GENERIC_STM32F103C
genericSTM32F103C.upload.use_1200bps_touch=false
genericSTM32F103C.upload.file_type=bin
genericSTM32F103C.upload.auto_reset=true
## STM32F103C8 -------------------------
genericSTM32F103C.menu.device_variant.STM32F103C8=STM32F103C8 (20k RAM. 64k Flash)
genericSTM32F103C.menu.device_variant.STM32F103C8.build.cpu_flags=-DMCU_STM32F103C8
genericSTM32F103C.menu.device_variant.STM32F103C8.build.ldscript=ld/jtag_c8.ld
genericSTM32F103C.menu.device_variant.STM32F103C8.upload.maximum_size=65536
genericSTM32F103C.menu.device_variant.STM32F103C8.upload.ram.maximum_size=20480
genericSTM32F103C.menu.device_variant.STM32F103C8.upload.flash.maximum_size=65536
## STM32F103CB -------------------------
genericSTM32F103C.menu.device_variant.STM32F103CB=STM32F103CB (20k RAM. 128k Flash)
genericSTM32F103C.menu.device_variant.STM32F103CB.build.cpu_flags=-DMCU_STM32F103CB
genericSTM32F103C.menu.device_variant.STM32F103CB.build.ldscript=ld/jtag.ld
genericSTM32F103C.menu.device_variant.STM32F103CB.upload.maximum_size=131072
genericSTM32F103C.menu.device_variant.STM32F103CB.upload.ram.maximum_size=20480
genericSTM32F103C.menu.device_variant.STM32F103CB.upload.flash.maximum_size=131072
#---------------------------- UPLOAD METHODS ---------------------------
genericSTM32F103C.menu.upload_method.DFUUploadMethod=STM32duino bootloader
genericSTM32F103C.menu.upload_method.DFUUploadMethod.upload.protocol=maple_dfu
genericSTM32F103C.menu.upload_method.DFUUploadMethod.upload.tool=maple_upload
genericSTM32F103C.menu.upload_method.DFUUploadMethod.build.upload_flags=-DSERIAL_USB -DGENERIC_BOOTLOADER
genericSTM32F103C.menu.upload_method.DFUUploadMethod.build.vect=VECT_TAB_ADDR=0x8002000
genericSTM32F103C.menu.upload_method.DFUUploadMethod.build.ldscript=ld/bootloader_20.ld
genericSTM32F103C.menu.upload_method.DFUUploadMethod.upload.usbID=1EAF:0003
genericSTM32F103C.menu.upload_method.DFUUploadMethod.upload.altID=2
genericSTM32F103C.menu.upload_method.serialMethod=Serial
genericSTM32F103C.menu.upload_method.serialMethod.upload.protocol=maple_serial
genericSTM32F103C.menu.upload_method.serialMethod.upload.tool=serial_upload
genericSTM32F103C.menu.upload_method.STLinkMethod=STLink
genericSTM32F103C.menu.upload_method.STLinkMethod.upload.protocol=STLink
genericSTM32F103C.menu.upload_method.STLinkMethod.upload.tool=stlink_upload
genericSTM32F103C.menu.upload_method.STLinkMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DSERIAL_USB
genericSTM32F103C.menu.upload_method.BMPMethod=BMP (Black Magic Probe)
genericSTM32F103C.menu.upload_method.BMPMethod.upload.protocol=gdb_bmp
genericSTM32F103C.menu.upload_method.BMPMethod.upload.tool=bmp_upload
genericSTM32F103C.menu.upload_method.BMPMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG
And I have virtual com port and there is no need to remove 10k resistor, all work fine.
But I can’t make it work in arduino IDE.
Also I tested it on stm32f103vet6 – it has 4.7k resistor to 5V – also works in eclipse but doesn’t work in arduino 1.6.4
And I have virtual com port and there is no need to remove 10k resistor, all work fine.
But I can’t make it work in arduino IDE.
Also I tested it on stm32f103vet6 – it has 4.7k resistor to 5V – also works in eclipse but doesn’t work in arduino 1.6.4
I simply write that flash with st-link and see results.
I simply write that flash with st-link and see results.
So I ask you about favor – please compile your sketch to .bin in your arduino IDE and post it here. Also please attach .ino file
Thanx in advance
Bye
as you are using the stlink upload method, it will compile the USB serial code into the sketch, and after the sketch runs, you should see the Maple Serial device
If the USB reset hardware is not working on your board, try unplugging the usb and reconnecting after you have uploaded.
If the usb serial device still does not appear, its likely you have a fault on your board. The USB connector on the Red and Blue Pill boards is very weak, and its quite likely you have a broken USB data connection.
If so, you may be able to resolder it, and then glue the USB connector down with hot glue etc
Flash the board with the generic pc13 bootloader.
Connect the board using USB and look at the output of dmesg. You should the the board enumerate.
Upload a blink sketch using the IDE with the upload method as the bootloader. This should work and the board should start blinking as long as you set the LED pin to PC13.
Unplug/replug the USB connector and check dmesg. You should have two devices, the board and a serial port enumerated as /dev/ttyACM0. I have two blue pill boards and neither one enumerates the serial port without help.
Assuming that you don’t yet have a serial port, touch a 1k resistor from PA12 to ground. Check dmesg again. You should see the serial port enumerate.
After it enumerates, you should be able to upload another sketch from the IDE.
FIRST:Please guys! Post here THE sketch that 100% work for you and bin file . It’s very simple for you to prove your words that usb serial works.
SECOND:I’ve managed to work cdc_acm under libopencm3 and under CubeMX.
For me today it’s too complicated move from arduino to eclipse beacause of w5100 and mpu-9250 so I’d like to stay with arduino IDE, that’s why I write theese words.
Unplug/replug the USB connector and check dmesg. You should have two devices, the board and a serial port enumerated as /dev/ttyACM0. I have two blue pill boards and neither one enumerates the serial port without help.
If the usb serial device still does not appear, its likely you have a fault on your board. The USB connector on the Red and Blue Pill boards is very weak, and its quite likely you have a broken USB data connection.
Ok if you have stlink please flash attached .bin and you magically have ttyACM0 without resolder resistor or touching 1k to ground. Rename it to .bin This sipmly works.
That means that something is missing in arduino code.
It seems to be a binary not a cpp
Please rename it to .bin and flash it.
I’ve tested the cdcacm.bin file and it works OK in my blue pill.
Once connected thru USB, the ttyACM0 is enumerated and works.
I’ve been unable, up to now, to use USB DFU mode, i.e. STM32duino bootloader.
Also tried the usb_dfu example from libopencm3 and it didn’t worked, but the usb_cdcacm works OK.
With STM32duino bootloader and the usb_dfu example the bad behaviour it’s similar:
feb 18 01:03:07 kernel: usb 4-1.2: new full-speed USB device number 80 using ehci-pci
feb 18 01:03:07 kernel: usb 4-1.2: device descriptor read/64, error 18
feb 18 01:03:08 kernel: usb 4-1.2: device descriptor read/64, error 18
feb 18 01:03:08 kernel: usb 4-1.2: new full-speed USB device number 81 using ehci-pci
feb 18 01:03:08 kernel: usb 4-1.2: device descriptor read/64, error 18
feb 18 01:03:08 kernel: usb 4-1.2: device descriptor read/64, error 18
feb 18 01:03:08 kernel: usb 4-1.2: new full-speed USB device number 82 using ehci-pci
feb 18 01:03:09 kernel: usb 4-1.2: device not accepting address 82, error -32
...
feb 18 01:03:10 kernel: usb 4-1-port2: unable to enumerate USB device
I am building my stm32 projects with eclipse and when I am using the default arduino compiler gcc 4.8.3 the project executes correctly end the USB is enumerated as usual.
The same project with absolute the same settings with gcc 4.9.3 (as provided by ubuntu/debian repository) executes correctly but the USB enumeration fails and no ttyACM0 is created. Some regression of gcc here…..
As a test try to disable -Os in your flags.
I think that this is related to the problem
http://stackoverflow.com/questions/2719 … ith-gcc-os
Thankyou.
look this : https://github.com/cleanflight/cleanflight/issues/763
The same problem with gcc 4.9.3
They solved the problem with some volatile declarations in USB registers.
https://github.com/nzmichaelh/cleanflig … 1531d532a0
https://github.com/nzmichaelh/cleanflig … 4c5524a395
Seems that gcc 4.9.3 is more aggresive with optimizations
I confirm that USB with gcc 4.9.3 without -Os CFlag works correctly (but with double size).
Probably, the volatile stuff is something we should consider changing
Fortunately, I’m always keep several previous versions of many cross-toolchains and use a symbolic link to switch between them if required …

![[Pending Enhancement] RTC values resetting](https://sparklogic.ru/wp-content/uploads/2019/11/nucleo-l476rg-zestaw-startowy-z-mikrokontrolerem-z-rodziny-stm32-stm32l476-90x90.jpg)