Upload code issue on Linux-Ubuntu

Development environment specific, Arduino, Eclipse, VS2013, Em::Blocks etc
User avatar
MasterT
Posts: 33
Joined: Mon Apr 20, 2020 12:02 am

Upload code issue on Linux-Ubuntu

Post by MasterT »

Hi,
IDE 1.8.16 with latest stm32 boards 2.1.0 everything work flawlessly (serial & uploading - mass storage)
till I put laptop into hibernation. After waking up arduino serial monitor still responsive and comm link is o'k,
but uploading is dead. Connecting-reconnecting USB , restarting Nucleo - hot/ cold/ reset - nothing helps
till I logged out of OS and re-logging again. My troubleshooting skills tell me that mounting-unmounting usb drive "freezing" but I don't know what to do.
lsblk and sudo fdisk -l listed about 25 /dev/loop devices - is it o'k?

Does anyone have similar issue?
mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

Re: Upload code issue on Linux-Ubuntu

Post by mrburnette »

As a "rule of thumb", do not leave the ArduinoIDE open and your USB enumerated to an Arduino board. This goes also for Windows when using non-Microsoft com drivers. Bad things will happen sometimes and mess with your head.

The internet has numerous stories of such dark skies surrounding Linux and USB. Just unplug the USB before putting the notebook into hibernation.

Of course you can drop into the shell and force a re-enumeration of a stale port.

Ray
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Upload code issue on Linux-Ubuntu

Post by ag123 »

In Linux, I typically use dfu-util and install my bins manually from the command line.
For Nucleo, u'd probably need st-link or stm32cubeprogrammer
all these apps are likely there in your installed core.

The Linux command dmesg helps, you could use it to check what is happening. If the kernel USB device drivers is connecting ok.
It probably means, the IDE needs to be restarted at a minimum.

There are issues with linux devices restoring from hibernation, and normally i simply shutdown and reboot my pc to avoid those issues.
mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

Re: Upload code issue on Linux-Ubuntu

Post by mrburnette »

ag123 wrote: Sun Oct 24, 2021 8:02 am ...
There are issues with linux devices restoring from hibernation, and normally i simply shutdown and reboot my pc to avoid those issues.
Hibernation is voodoo and can be problematic on any OS.

I find it easier for me to just remember to unplug the USB from the Arduino device before the notebook goes into sleep. I do not permit hibernation on any of my development notebooks ... one Linux, one Windows. Hibernating PCs are like bears, waking one can have undesired consequences.
User avatar
MasterT
Posts: 33
Joined: Mon Apr 20, 2020 12:02 am

Re: Upload code issue on Linux-Ubuntu

Post by MasterT »

Updates:
1. doesn't matter serial monitor closed or not;
2. same apply to arduino IDE;
3. dmesg shows no difference:

[151249.020810] usb 1-4: new high-speed USB device number 24 using xhci_hcd
[151249.169512] usb 1-4: config 1 interface 2 altsetting 0 endpoint 0x84 has an invalid bInterval 255, changing to 11
[151249.170104] usb 1-4: New USB device found, idVendor=0483, idProduct=374e, bcdDevice= 1.00
[151249.170114] usb 1-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[151249.170119] usb 1-4: Product: ST-LINK/V3
[151249.170122] usb 1-4: Manufacturer: STMicroelectronics
[151249.170125] usb 1-4: SerialNumber: 003600193438511334XXXXXX
[151249.177708] usb-storage 1-4:1.1: USB Mass Storage device detected
[151249.178237] scsi host2: usb-storage 1-4:1.1
[151249.179142] cdc_acm 1-4:1.2: ttyACM0: USB ACM device
[151250.197442] scsi 2:0:0:0: Direct-Access STM Product 0.01 PQ: 0 ANSI: 2
[151250.198050] sd 2:0:0:0: Attached scsi generic sg0 type 0
[151250.198363] sd 2:0:0:0: [sda] 1096 512-byte logical blocks: (561 kB/548 KiB)
[151250.198524] sd 2:0:0:0: [sda] Write Protect is off
[151250.198530] sd 2:0:0:0: [sda] Mode Sense: 00 00 00 00
[151250.198673] sd 2:0:0:0: [sda] Asking for cache data failed
[151250.198682] sd 2:0:0:0: [sda] Assuming drive cache: write through
[151250.281658] sd 2:0:0:0: [sda] Attached SCSI removable disk

The only indication is "click" sound, after re-loging if I hear sound - everything o'k.
Closing arduino IDE, put into hibernate - wake up - no sound. Nucleo restarts after plugin USB - even its powered up over V-in. Serial works as usual, but uploading generates an error in the console window -- like time out or something.
There is one more strange things, left panel shows NOD_G474RE icon - even no USB, arduino IDE or serial running. "Files - nautilus" shows no any disk / removable media attached (/media/user/ folder is empty as well).
If I do right click context menu over icon I see "eject" single option - but pressing does nothing , icon is still there and context menu shows again on right click hovering.
mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

Re: Upload code issue on Linux-Ubuntu

Post by mrburnette »

The only indication is "click" sound, after re-loging if I hear sound - everything o'k.
I do not even know how to respond to this ... I do not have a Nucleo board here, but Maple F103, Espressif ESP8366 & ESP32 & ESPCAM all work OK as does real Arduino Mega2560 and UNO. I will not bother guessing; perhaps a super-Linux geek has the answer. Generally, audio "clicking" would indicate that the audio driver stack was being reset while the audio IC was "hot" ... I have witnessed Windows doing such things when Device Manager was forced to remove and reinstall a driver.

Weird.

Good luck. While I understand the frustration, be thankful that you are not hearing-challenged.

Ray
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Upload code issue on Linux-Ubuntu

Post by ag123 »

The Nucleo has an ST-link built-in, try to program with that instead of mass storage mode. on the command line that is.
Chances are that it would work. A trouble is it isn't easy for the kernel to keep state across hibernate for mass storage, often the state data is incorrect. i.e. folders that is 'open' prior should be considered closed and disconnected across a hibernate. This won't be easy for an os to detect, and the app needs to detect the hibernate and resume condition as well. I don't think apps are written to take care of such events, most of them are stateless.
User avatar
MasterT
Posts: 33
Joined: Mon Apr 20, 2020 12:02 am

Re: Upload code issue on Linux-Ubuntu

Post by MasterT »

I mean "click" sound - is system wide associated audio signal , acknowledge indicator from OS about "enumeration" USB successful. Similar to power cord connection - OS beeps to confirm its get a power and switching charging battery mode.
User avatar
MasterT
Posts: 33
Joined: Mon Apr 20, 2020 12:02 am

Re: Upload code issue on Linux-Ubuntu

Post by MasterT »

ag123 wrote: Sun Oct 24, 2021 6:01 pm The Nucleo has an ST-link built-in, try to program with that instead of mass storage mode. on the command line that is.
Chances are that it would work. A trouble is it isn't easy for the kernel to keep state across hibernate for mass storage, often the state data is incorrect. i.e. folders that is 'open' prior should be considered closed and disconnected across a hibernate. This won't be easy for an os to detect, and the app needs to detect the hibernate and resume condition as well. I don't think apps are written to take care of such events, most of them are stateless.
I tried stmCubeprogrammer, install software fromm ST official web site. But it's has no right to write over serial and I have no idea how to create udev-rules for this beast. Likely udev is not only problem, overall it would creates more troubles than common "mass storage" programming mode.
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Upload code issue on Linux-Ubuntu

Post by ag123 »

try https://github.com/stlink-org/stlink
it may work, no guarantees though. st-link may not need a udev, i'm not sure though.
udev is more commonly needed for serial, mass storage etc where you have a kernel device driver to connect.
for serial (i.e. CDC) it is already there.
Post Reply

Return to “IDE's”