energia / Energia

Fork of Arduino for the Texas Instruments LaunchPad's
http://energia.nu
Other
793 stars 673 forks source link

Linux: Problem with serial debug window #33

Closed pbrier closed 12 years ago

pbrier commented 12 years ago

There seems to be a problem using the serial debug window in linux. After you use it, Energia becomes slow (10 seconds response time when clicking some window or menu). Removing the USB connection makes it work OK again, but plugging in the launchpad makes it slow again.

May be a problem in serial port detection code.

Note: this problem occurs only after doing a download. If you do not do a download, it works OK. Could be buggy CDC implementation in the launchpad USB firmware.

RickKimball commented 12 years ago

I noticed this also. It definitively has something to do with the port detection. I commented out that code and the User Interface runs normally. I think it only gets slow if you mouse over the Tools menu item which in turn triggers serial port detection. Try keeping your mouse away from the Tools menu and see if it that is how your system reacts.

robertinant commented 12 years ago

Can you point me to the relevant file/line where this detection is done? This will save me some time digging.

RickKimball commented 12 years ago

[Edit: .. see my next comment, although I'll leave this so your question is answered]

+++ b/app/src/processing/app/Editor.java @@ -656,7 +656,7 @@ public class Editor extends JFrame implements RunnerListener { toolsMenu = new JMenu(_("Tools")); JMenu menu = toolsMenu;

JMenuItem item;

RickKimball commented 12 years ago

I just did a git pull and this problem seems to have fixed itself. I'm not experiencing slow serial port enumeration in linux any more.

RickKimball commented 12 years ago

Actually, I tried it again with the ASCII table example and it hung up on linux.

I think this has more to do with the common problem of the linux acm tty driver that is used for the launchpad serial. There is a problem with the driver that causes it to fail if your firmware outputs data without there being a host side program reading it.

The simple solution is to always wait for the user to type something before your send data or to put a 10 second pause in there so that when linux does its usb enumeration, there isn't any data being sent by the firmware.

Or use an external usb->serial device like an FTDI or similar.

RickKimball commented 12 years ago

I think I can confirm this as a driver problem with the Launchpad serial port. I undid my TX/RX pins on J3 and connected them to an FTDI breakout board. I can open and close the serial port without a problem. I used an unmodified version of the "ASCIITable" example program with an msp430g2553.

pbrier commented 12 years ago

Confirmed this also last night. Found some info on the web that suggested the same. Could make detection more robust by doing it in a seperate thread.

Also found some references that suggest that newer linux kernel fixes issue.

pbrier commented 12 years ago

Problem can be made more 'manageable' by leaving the serial debug open all the time (not closing it on a download). This way you reduce the risk of serial chars being received while the window is closed, and the serial port closed. Otherwise: the kernel is confused and issues this dmesg: [14297.267081] tty_port_close_start: tty->count = 1 port count = 0.

this post may be related: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1286088093

Is there a way to fix the USB driver of firmware in the TI controller?

RickKimball commented 12 years ago

I used the changes mentioned in this post http://e2e.ti.com/support/low_power_rf/f/156/p/53610/697952.aspx#697952 with good results on my ubuntu 11.04 with a 2.6 linux kernel. http://www.43oh.com/forum/viewtopic.php?f=38&t=2866

-rick

RickKimball commented 12 years ago

@pbrier did you try that patch?

pbrier commented 12 years ago

not yet

Rick Kimball
reply@reply.github.com
schreef:

@pbrier did you try that patch?


Reply to this email directly or view it on GitHub: https://github.com/energia/Energia/issues/33#issuecomment-6825899

pbrier commented 12 years ago

I tried it: DKMS build failed (see log below). But if I build manually and insmod the new driver: success! All works fine. Any pointers on the DKMS build problem?

Log:


Deleting module version: 0.1

completely from the DKMS tree.

Done.

Creating symlink /var/lib/dkms/cdcacm/0.1/source -> /usr/src/cdcacm-0.1

DKMS: add Completed.

Kernel preparation unnecessary for this kernel. Skipping...

Building module: cleaning build area....(bad exit status: 2) ....(bad exit status: 2)8-10-generic all KVERSION=2.6.38-10-generic

Error! Bad return status for module build on kernel: 2.6.38-10-generic (i686) Consult the make.log in the build directory /var/lib/dkms/cdcacm/0.1/build/ for more information. 0 0 ERROR: binary package for cdcacm: 0.1 not found

.ko for module cdcacm in the DKMS tree. You must run a dkms build for kernel 2.6.38-10-generic (i686) first. FATAL: Module cdcacm not found. ERROR: modinfo: could not open /var/lib/dkms/cdcacm/0.1/2.6.38-10-generic/i686/module/cdcacm.ko: No such file or directory

root@peebee-laptop:/usr/src/cdcacm-0.1# more /var/lib/dkms/cdcacm/0.1/build/make.log DKMS make.log for cdcacm-0.1 for kernel 2.6.38-10-generic (i686) Tue Jul 10 01:10:05 CEST 2012 /build M=/var/lib/dkms/cdcacm/0.1/build modules /build: No such file or directory. Stop. make: *\ [all] Error 2

RickKimball commented 12 years ago

To be honest, I installed it by hand too.

RickKimball commented 12 years ago

I'd like to close this. Using the patch seems to fix it for everyone who has tried.

robertinant commented 12 years ago

Can we post the procedure and the code in the Wiki please?

RickKimball commented 12 years ago

Wiki page posted:

https://github.com/energia/Energia/wiki/Linux-Serial-Communication