USB Serial Ubuntu 15.04 Blue pill

Rmk177
Thu Jan 28, 2016 8:26 pm
Good day!
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

RogerClark
Fri Jan 29, 2016 2:38 am
We need more information

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


Rmk177
Fri Jan 29, 2016 4:51 am
Hi!
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.


RogerClark
Fri Jan 29, 2016 5:11 am
I don’t have that board. I have a red coloured one which I think is very similar, but I did not need to remove or change any resistors

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


Rmk177
Fri Jan 29, 2016 8:35 am
Here is my sketch led blinked but
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
}


RogerClark
Fri Jan 29, 2016 8:48 am
What upload type did you select

Rmk177
Fri Jan 29, 2016 9:16 am
STM32duino_bootloader

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


Rmk177
Mon Feb 01, 2016 2:54 pm
Ok tested second time and generate CubeMX project and convert it to eclipse.
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

mrburnette
Mon Feb 01, 2016 2:59 pm
Rmk177 wrote:Ok tested second time and generate CubeMX project and convert it to eclipse.
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

Rmk177
Mon Feb 01, 2016 4:09 pm
Ok maybe someone can make .bin file for pc13 blue pill that use only usb serial and attach some sketch to it.
I simply write that flash with st-link and see results.

mrburnette
Mon Feb 01, 2016 5:44 pm
Rmk177 wrote:Ok maybe someone can make .bin file for pc13 blue pill that use only usb serial and attach some sketch to it.
I simply write that flash with st-link and see results.

Rmk177
Mon Feb 01, 2016 8:04 pm
Ok maybe I’ve done something wrong but if I made a sketch with blink PC13 and use usb serial PC13 blinked and usb serial don’t work – that means that I upload fine to board. So I uploaded using stlink method -> stlink-flash write blink.bin 0x8000000 so led blinked.
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

RogerClark
Mon Feb 01, 2016 8:16 pm
ok

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


fredbox
Mon Feb 01, 2016 8:44 pm
Try this –

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.


Rmk177
Tue Feb 02, 2016 4:45 am
Ok continue our saga :)

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.


RogerClark
Tue Feb 02, 2016 5:05 am
what format is the file you attached.

It seems to be a binary not a cpp


Rmk177
Tue Feb 02, 2016 6:37 am
Forum doesn’t allow to attach .bin files
Please rename it to .bin and flash it.

robarago
Thu Feb 18, 2016 12:13 am
Hi,

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


Slammer
Tue Mar 01, 2016 10:44 pm
I think the problem is related with gcc 4.9.3

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


RogerClark
Tue Mar 01, 2016 11:02 pm
Very interesting

Thankyou.


martinayotte
Tue Mar 01, 2016 11:51 pm
Interesting, indeed !

Slammer
Wed Mar 02, 2016 12:10 am
FYI

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).


RogerClark
Wed Mar 02, 2016 1:10 am
OK

Probably, the volatile stuff is something we should consider changing


martinayotte
Wed Mar 02, 2016 1:56 am
Yeark !
Fortunately, I’m always keep several previous versions of many cross-toolchains and use a symbolic link to switch between them if required …

Leave a Reply

Your email address will not be published. Required fields are marked *