USB reset issue in the Bootloader and libmaple core

Information on the latest releases
User avatar
fra
Posts: 2
Joined: Fri Feb 26, 2016 8:59 pm

Re: USB reset issue in the Bootloader and libmaple core

Postby fra » Thu Dec 01, 2016 9:48 pm

Hi guys, I may have found a workaround on this.
Two symptoms:
1) after a sketch upload I have to wait 15-20 seconds before I can open the USB Serial, otherwise I get the error message

Code: Select all

Error opening serial port '/dev/ttyACM0'. (Port busy)

2) In between two uploads I have to push the reset button (see http://www.stm32duino.com/viewtopic.php?t=475)

I have a Maple-Mini Baite clone
I am using Ubuntu 16.04 LTS (probably the bug is on their side as the same board works fine with Windows)

I noticed that the reset code was hanging exactly in the same way as the IDE when switching back to Serial USB.

Code: Select all

upload_reset /dev/ttyACM0 750

I also noticed that running dmesg after each reset command I could find the following error:

Code: Select all

cdc_acm 2-3:1.0: failed to set dtr/rts


Looking into this article https://bugs.launchpad.net/ubuntu/+source/modemmanager/+bug/1473246 I found that the symptoms would be due to a bug of the Ubuntu ModemManager that recognizes the board as a modem.
As suggested the workaround is to blacklist the device adding the following snippet into the corresponding rule:

Code: Select all

ENV{ID_MM_DEVICE_IGNORE}="1"


So in my case the file called "45-maple.rules" would look like this:

Code: Select all

ATTRS{idProduct}=="1001", ATTRS{idVendor}=="0110", MODE="664", GROUP="plugdev"
ATTRS{idProduct}=="1002", ATTRS{idVendor}=="0110", MODE="664", GROUP="plugdev"
ATTRS{idProduct}=="0003", ATTRS{idVendor}=="1eaf", MODE="664", GROUP="plugdev" SYMLINK+="maple", ENV{ID_MM_DEVICE_IGNORE}="1"
ATTRS{idProduct}=="0004", ATTRS{idVendor}=="1eaf", MODE="664", GROUP="plugdev" SYMLINK+="maple", ENV{ID_MM_DEVICE_IGNORE}="1"


Rerun the install.sh and the two symptoms above disappear...

Hope this helps.

User avatar
RogerClark
Posts: 5588
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: USB reset issue in the Bootloader and libmaple core

Postby RogerClark » Thu Dec 01, 2016 10:38 pm

fra wrote:Hi guys, I may have found a workaround on this.
Two symptoms:
1) after a sketch upload I have to wait 15-20 seconds before I can open the USB Serial, otherwise I get the error message

Code: Select all

Error opening serial port '/dev/ttyACM0'. (Port busy)

2) In between two uploads I have to push the reset button (see http://www.stm32duino.com/viewtopic.php?t=475)

I have a Maple-Mini Baite clone
I am using Ubuntu 16.04 LTS (probably the bug is on their side as the same board works fine with Windows)

I noticed that the reset code was hanging exactly in the same way as the IDE when switching back to Serial USB.

Code: Select all

upload_reset /dev/ttyACM0 750

I also noticed that running dmesg after each reset command I could find the following error:

Code: Select all

cdc_acm 2-3:1.0: failed to set dtr/rts


Looking into this article https://bugs.launchpad.net/ubuntu/+source/modemmanager/+bug/1473246 I found that the symptoms would be due to a bug of the Ubuntu ModemManager that recognizes the board as a modem.
As suggested the workaround is to blacklist the device adding the following snippet into the corresponding rule:

Code: Select all

ENV{ID_MM_DEVICE_IGNORE}="1"


So in my case the file called "45-maple.rules" would look like this:

Code: Select all

ATTRS{idProduct}=="1001", ATTRS{idVendor}=="0110", MODE="664", GROUP="plugdev"
ATTRS{idProduct}=="1002", ATTRS{idVendor}=="0110", MODE="664", GROUP="plugdev"
ATTRS{idProduct}=="0003", ATTRS{idVendor}=="1eaf", MODE="664", GROUP="plugdev" SYMLINK+="maple", ENV{ID_MM_DEVICE_IGNORE}="1"
ATTRS{idProduct}=="0004", ATTRS{idVendor}=="1eaf", MODE="664", GROUP="plugdev" SYMLINK+="maple", ENV{ID_MM_DEVICE_IGNORE}="1"


Rerun the install.sh and the two symptoms above disappear...

Hope this helps.



Very interesting.

If some other linux users can test this on their installations (e.g. Linux mint etc), I would be happy to update the repo with this change.

BTW. Windows users have similar issues, because the IDE doesnt seem to close the serial terminal before upload, and if you leave it open, then you get a load of Java errors in the iDE when the Serial USB re-appears (and you still can't use the terminal without resetting the board)

User avatar
ahull
Posts: 1468
Joined: Mon Apr 27, 2015 11:04 pm
Location: Sunny Scotland
Contact:

Re: USB reset issue in the Bootloader and libmaple core

Postby ahull » Thu Dec 01, 2016 11:26 pm

:D I just flashed the tiny-o-scope code I was working on earlier to my test board. Five uploads one after the other, no problems... usb serial worked every time too... so far so good.
- Andy Hull -

User avatar
RogerClark
Posts: 5588
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: USB reset issue in the Bootloader and libmaple core

Postby RogerClark » Thu Dec 01, 2016 11:32 pm

Thanks guys

I've updated the repo

User avatar
SukkoPera
Posts: 22
Joined: Tue Jun 07, 2016 11:02 pm
Location: Turin, Italy
Contact:

Re: USB reset issue in the Bootloader and libmaple core

Postby SukkoPera » Wed Apr 19, 2017 9:37 am

Sorry for the delay. I've just come to the same conclusion, i.e.: the cr*ppy ModemManager interferes with my ttyACM* ports :evil:.

The udev rules change seems to fix the issue, at least partly: if I upload while the serial monitor is open, the upload succeeds, but then I get the usual "Port busy" error. Anyway now I can just close and reopen the serial monitor and it will connect as expected. So, well done! ;)

Just one minor thing: you only applied the changes to the 45-maple.rules file under the linux directory. You should replicate the changes under the linux64 directory as well. There's also another copy of that file under STM32F1/system/support/scripts/45-maple.rules so that should be fixed as well, or maybe removed altogether?

Bingo600
Posts: 9
Joined: Thu Mar 16, 2017 5:25 pm

Re: USB reset issue in the Bootloader and libmaple core

Postby Bingo600 » Wed Apr 19, 2017 5:16 pm

Maybe try this one , modem-mgr blacklist

viewtopic.php?f=22&t=1892#p25160

/Bingo


Return to “Builds and Announcements”

Who is online

Users browsing this forum: No registered users and 1 guest