AbhayaKumar 1 Posted May 3, 2014 Share Posted May 3, 2014 Hello, I need some guidance on Programming MSP-EXP430G2 Launchpad using Energia on Linux OS. This is the first time I am using energia. The main objective for using energia is to be able to program/debug MSP-EXP430G2 Launchpad in Linux environment (as CCS 6.0 does not support MSP-EXP430G2 Launchpad on linux) Guidance needed for: Kindly guide me on how can I get things working in usermode. Specially, I would like to be able to 1. pass any argument while my code is running in the device (equivalent to scanf/getc/getchar in C programming). 2. Print information while my code is running in the device (equivalent to printf/putc/putchar in C programming). System Information: Launchpad: MS-EXP430G2 Rev 1.5 $ uname -aLinux Home 3.2.0-60-generic #91-Ubuntu SMP Wed Feb 19 03:54:44 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux $ lsusb Bus 002 Device 008: ID 0451:f432 Texas Instruments, Inc. eZ430 Development Tool $ dmesg [ 2652.200025] usb 2-9: new full-speed USB device number 9 using ohci_hcd[ 2652.445202] cdc_acm 2-9:1.0: This device cannot do calls on its own. It is not a modem.[ 2652.445207] cdc_acm 2-9:1.0: No union descriptor, testing for castrated device[ 2652.445231] cdc_acm 2-9:1.0: ttyACM0: USB ACM device[ 2662.504177] generic-usb 0003:0451:F432.0005: usb_submit_urb(ctrl) failed[ 2662.504188] generic-usb 0003:0451:F432.0005: timeout initializing reports[ 2662.504371] generic-usb 0003:0451:F432.0005: hiddev0,hidraw3: USB HID v1.01 Device [Texas Instruments Texas Instruments MSP-FET430UIF] on usb-0000:00:02.0-9/input1 $ more /etc/udev/rules.d/46-TI_launchpad.rules#MSP 430 Launchpad#Bus 002 Device 005: ID 0451:f432 Texas Instruments, Inc. eZ430 Development ToolSUBSYSTEMS=="usb", ATTRS{idVendor}=="0451", ATTRS{idProduct}=="f430", MODE="0660", GROUP="plugdev"SUBSYSTEMS=="usb", ATTRS{idVendor}=="0451", ATTRS{idProduct}=="f432", MODE="0660", GROUP="plugdev" $ ls -al /dev/ttyACM0crw-rw---- 1 root dialout 166, 0 May 3 10:14 /dev/ttyACM0 $ sudo service udev restartudev stop/waitingudev start/running, process 7856 $ ls -al /dev/ttyACM0crw-rw---- 1 root dialout 166, 0 May 3 10:14 /dev/ttyACM0 $ groupsadm tty cdrom sudo dip plugdev lpadmin sambashare home $ /opt/energia-0101E0012/energia IDE comes-up in usermode as well as sudo mode Current Status: In sudo mode Tools->Serial Port is active ans shows /dev/ttyACM0 selected Blink example can be loaded succesfully with following log:- Binary sketch size: 2,623 bytes (of a 16,384 byte maximum)Trying to open interface 1 on 009rf2500: warning: can't detach kernel driver: No data availableDevice: MSP430G2553/G2403Erasing...Programming...Done, 2624 bytes totalIn Usermode Tools->Serial Port is Greyed out Blink example can be loaded succesfully with following log:- Binary sketch size: 2,623 bytes (of a 16,384 byte maximum)Trying to open interface 1 on 009Device: MSP430G2553/G2403Erasing...Programming...Done, 2624 bytes total Current Issues: In sudo mode Serial Monitor window shows up without any error Following code does not show any output in Serial Monitor window or in status window of energia. void setup () { // initialize serial communications at 9600 bps: Serial.begin(9600); // Initialize the digital pin as output. // Pin 2:14 leds have connected: pinMode (14, OUTPUT); pinMode (2, OUTPUT); }void loop () { digitalWrite (14, HIGH); // Led on delay (600); // Wait 1 sec. digitalWrite (14, LOW); // LED off delay (1000); // Wait 1 second. digitalWrite (2, HIGH); // Led on delay (300); // Wait 1 second digitalWrite (2, LOW); // LED off delay (1000); // Wait 1 sec. Serial.print("Hi Abhaya"); Serial.println(300);} In Usermode Gives following error when Serial Monitor is invokedprocessing.app.SerialNotFoundException: Serial port '/dev/ttyACM0' not found. Did you select the right one from the Tools > Serial Port menu? at processing.app.Serial.<init>(Serial.java:165) at processing.app.Serial.<init>(Serial.java:92) at processing.app.SerialMonitor.openSerialPort(SerialMonitor.java:209) at processing.app.Editor.handleSerial(Editor.java:2630) at processing.app.Editor$20.actionPerformed(Editor.java:777) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259) at javax.swing.AbstractButton.doClick(AbstractButton.java:376) at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:833) at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:877) at java.awt.Component.processMouseEvent(Component.java:6505) at javax.swing.JComponent.processMouseEvent(JComponent.java:3311) at java.awt.Component.processEvent(Component.java:6270) at java.awt.Container.processEvent(Container.java:2229) at java.awt.Component.dispatchEventImpl(Component.java:4861) at java.awt.Container.dispatchEventImpl(Container.java:2287) at java.awt.Component.dispatchEvent(Component.java:4687) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422) at java.awt.Container.dispatchEventImpl(Container.java:2273) at java.awt.Window.dispatchEventImpl(Window.java:2719) at java.awt.Component.dispatchEvent(Component.java:4687) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735) at java.awt.EventQueue.access$200(EventQueue.java:103) at java.awt.EventQueue$3.run(EventQueue.java:694) at java.awt.EventQueue$3.run(EventQueue.java:692) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87) at java.awt.EventQueue$4.run(EventQueue.java:708) at java.awt.EventQueue$4.run(EventQueue.java:706) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.awt.EventQueue.dispatchEvent(EventQueue.java:705) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138) at java.awt.EventDispatchThread.run(EventDispatchThread.java:91) Quote Link to post Share on other sites
bi0tech 4 Posted May 3, 2014 Share Posted May 3, 2014 $ groupsadm tty cdrom sudo dip plugdev lpadmin sambashare home I believe your problem is there. If the serial device is owned by dialout you need to be a member. sudo usermod -a -G dialout username Although I believe the udev rule should move the usb device as well as the tty to plugdev ownership. Did you disconnect/reconnect the device since you restarted udev? Permissions for usermode aside, serial communication on the 430 and serial comm in linux is a bit touchy (read as buggy). I haven't spent a lot of time with it yet but I find toggling the line speed of the ttyACM* device on the host side kickstarts throughput. (After starting the serial monitor toggle it to 4800 for a second and then back to 9600, or leave one terminal open to 'cat < /dev/ttyACM0' and use 'stty -F /dev/ttyACM0 raw <speed>' in a second terminal.) Quote Link to post Share on other sites
AbhayaKumar 1 Posted May 4, 2014 Author Share Posted May 4, 2014 Thanks for your suggestions. After adding myself to dialout group, in usermode, I can select Serial Port-> /dev/ttyACM0. (Ofcourse, I still don't understand why udev rule is not working). So-far I have tried the following:- 1. After reboot, /dev/ttyACM0 is part of dialout group 2. After sudo service udev restart, /dev/ttyACM0 is part of dialout group 3. After disconnect/connect MSP-EXP430 Launchpad, /dev/ttyACM0 is part of dialout group Now, my biggest concern is not being able to interact with program (i.e. ley's say print status of resisters and take input parameters). My program contain:- 1. In setup function Serial.begin(9600); 2. In loop function Serial.print("Hi Abhaya"); Serial.println(300); With above, is my expectation to see "Hi Abhaya300" (running in infinite loop) throughout Serial Monitor window correct? After uploading the code, when I open Serial Monitor window, I see a blank page and bottom drop down lists have following values:- No line ending 9600 baud Manually when I change drop down list to "4800 baud", Serial Monitor window is still blank (no output of print statement). Manually when I change drop down list to "9600 baud", Serial Monitor window is still blank (no output of print statement). Is there any other workaround to communicate with program running on launchpad (just 2 LEDs and one reset switch is not enough)? Quote Link to post Share on other sites
bi0tech 4 Posted May 4, 2014 Share Posted May 4, 2014 The only other thing I could think of for no output would be the chip configuration. You didn't mention which msp430 this is using. Make sure you have the correct chip variant selected and the jumpers oriented acc'd to the info below. Check here: http://energia.nu/Guide_MSP430LaunchPad.html A bit more info: http://energia.nu/Serial.html Quote Link to post Share on other sites
BRey 22 Posted May 4, 2014 Share Posted May 4, 2014 The Launchpad ACM device just isn't implemented well. As your note shows, the FET works very reliably, but the Comm port comes and goes... The problem gets worse if you connect and reconnect Launchpads (working with RF stuff, I often need to reprogram multiple nodes). I have pulled the TX/RX jumpers on the Launchpads and wired USB-TTL serial modules directly to P1.1 & P1.2. A couple of bucks per module yields much less frustration! My primary workstation is Linux Mint 16, but the Launchpad serial port performs just as poorly on Windows often requiring a reboot for Putty to be able to open it. B Quote Link to post Share on other sites
AbhayaKumar 1 Posted May 5, 2014 Author Share Posted May 5, 2014 Thanks for your suggestions. I have MSP430G2553 installed in my MSP-ESP430G2 Launchpad (Rev 1.5) board. As per http://energia.nu/Gu...0LaunchPad.html I changed the jumper settings from || || || || || (SW UART) to == == || || || (HW UART). This also confirms with description in Quick Start Guide shipped with the Launchpad. Below is what I observed. On same machine, when I booted into Windows 7 (Dual boot), with SW UART settings, I do not get any output. But in HW UART setting, I do get stuff printed in Serial Monitor. Hence, looks like if I am not able to fix things in my Linux (ubuntu 12.04), I'll be forced to work in windows 7 :-((. Coming to Linux OS, below is what I observed:- I observed a clear difference in dmesg output with SW/HW UART settings HW UART $ dmesg |tail[ 813.124012] usb 2-9: new full-speed USB device number 9 using ohci_hcd[ 813.369112] cdc_acm 2-9:1.0: This device cannot do calls on its own. It is not a modem.[ 813.369117] cdc_acm 2-9:1.0: No union descriptor, testing for castrated device[ 813.369140] cdc_acm 2-9:1.0: ttyACM0: USB ACM deviceHW UART - Launchpad disconnect $ dmesg |tail[ 833.388089] generic-usb: probe of 0003:0451:F432.0005 failed with error -110[ 876.793044] usb 2-9: USB disconnect, device number 9SW UART $ dmesg |tail[ 962.372013] usb 2-9: new full-speed USB device number 10 using ohci_hcd[ 962.617126] cdc_acm 2-9:1.0: This device cannot do calls on its own. It is not a modem.[ 962.617132] cdc_acm 2-9:1.0: No union descriptor, testing for castrated device[ 962.617154] cdc_acm 2-9:1.0: ttyACM0: USB ACM device[ 972.676088] generic-usb 0003:0451:F432.0006: usb_submit_urb(ctrl) failed[ 972.676097] generic-usb 0003:0451:F432.0006: timeout initializing reports[ 972.676259] generic-usb 0003:0451:F432.0006: hiddev0,hidraw3: USB HID v1.01 Device [Texas Instruments Texas Instruments MSP-FET430UIF] on usb-0000:00:02.0-9/input1SW UART - Launchpad disconnect $ dmesg |tail[ 1047.172647] usb 2-9: USB disconnect, device number 10 With HW UART setting, when I invoke /opt/energia-0101E0012/energia (in sudo mode as well as in usermode), 1. energia window takes lot of time. 2. The Tools menu also becomes very slow. 3. Tools->Serial Monitor-> /dev/ttyACM0 is not listed (even though ls -al /dev/ttyACM0 output is same as descriped in my 1st post). 4. I am able to load my program into Launchpad (as LEDs behave the way I expect based on my program). 5. When I start Serial Monitor (in usermode as well as sudo mode), the energia window throws following message (even though ls -al /dev/ttyACM0 output is same as descriped in my 1st post after energia throws this message). processing.app.SerialNotFoundException: Serial port '/dev/ttyACM0' not found. Did you select the right one from the Tools > Serial Port menu? at processing.app.Serial.<init>(Serial.java:165) at processing.app.Serial.<init>(Serial.java:92) at processing.app.SerialMonitor.openSerialPort(SerialMonitor.java:209) at processing.app.Editor.handleSerial(Editor.java:2630) at processing.app.EditorToolbar.mousePressed(EditorToolbar.java:367) at java.awt.Component.processMouseEvent(Component.java:6502) at javax.swing.JComponent.processMouseEvent(JComponent.java:3311) at java.awt.Component.processEvent(Component.java:6270) at java.awt.Container.processEvent(Container.java:2229) at java.awt.Component.dispatchEventImpl(Component.java:4861) at java.awt.Container.dispatchEventImpl(Container.java:2287) at java.awt.Component.dispatchEvent(Component.java:4687) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4489) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422) at java.awt.Container.dispatchEventImpl(Container.java:2273) at java.awt.Window.dispatchEventImpl(Window.java:2719) at java.awt.Component.dispatchEvent(Component.java:4687) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735) at java.awt.EventQueue.access$200(EventQueue.java:103) at java.awt.EventQueue$3.run(EventQueue.java:694) at java.awt.EventQueue$3.run(EventQueue.java:692) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87) at java.awt.EventQueue$4.run(EventQueue.java:708) at java.awt.EventQueue$4.run(EventQueue.java:706) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.awt.EventQueue.dispatchEvent(EventQueue.java:705) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138) at java.awt.EventDispatchThread.run(EventDispatchThread.java:91) Quote Link to post Share on other sites
bi0tech 4 Posted May 6, 2014 Share Posted May 6, 2014 I figured I'd have to deal with this sooner or later myself so I hooked up my launchpad and tested a kernel module patch I'd seen around a few places. In very brief testing it does seem that it eliminates the extended hang when serial data is passed to ttyACM* before there is a reciever on the host. The patch to cdc-acm I used was for arch and has been since abandoned but it's easy enough to use/modify: Grab the tarball here: https://aur.archlinux.org/packages.php?ID=63769 The only file you need from it is the cdc-acm.patch, extract it somewhere like /usr/src/cdcacm-msp430 Grab the source for your kernel version. (either from vendor site or kernel.org) Pull the cdc-acm.c & cdc-acm.h files from the kernel source into /usr/src/cdcacm-msp430 sudo apt-get install kernel-headers build-essential (or similar for non-deb distros) cd /usr/src/cdcacm-msp430/ Rename the cdc-acm.c to cdc-acm.c.orig Either use the patch file (/usr/src/cdcacm-msp430/patch < cdc-acm.patch) or manually edit the changes from the .patch into cdc-acm.c.orig Save the result file as cdcacm.c Save the below text into /usr/src/cdcacm-msp430/Makefile make sudo cp /usr/src/cdcacm-msp430/cdcacm.ko /lib/modules/`uname -r`/kernel/drivers/usb/class/ echo "blacklist cdc-acm" > blacklist-MSP430.conf sudo cp blacklist-MSP430.conf /etc/modprobe.d/ sudo depmod -a reboot (or manually unload the old "cdc-acm" and insmod the new "cdcacm") generic kernel module Makefile: obj-m := cdcacm.o KVERSION := $(shell uname -r) all: $(MAKE) --debug=v -C /lib/modules/$(KVERSION)/build M=$(PWD) modules clean: $(MAKE) --debug=v -C /lib/modules/$(KVERSION)/build M=$(PWD) clean You can also go the dkms route but I had issues with it (and I'm not overly fond of it). Using dkms you won't need to rebuild when switching kernels (in theory). To revert back to cdc-acm: sudo rm /etc/modprobe.d/blacklist-MSP430.conf sudo rm /lib/modules/`uname -r`/kernel/drivers/usb/class/cdcacm.ko sudo depmod -a reboot energia 1 Quote Link to post Share on other sites
AbhayaKumar 1 Posted May 6, 2014 Author Share Posted May 6, 2014 Thanks for all the support. I could successfully see the messages printed by my code on Serial Monitor window of eneergia running on my ubuntu 12.04 64-Bit machine. So far it seems to be working fine in user as well as sudo mode. Since I am a beginner, I may have taken some redundant steps and for sake of subsequent readers, it would be good if somebody can fine tune the same. Below are the list of steps taken by me:- 1. Since I have a 64-Bit machine, I choose 64bit version of shared library for /opt/energia-0101E0012/lib/librxtxSerial.so This was done as suggested in http://www.itopen.it/2013/03/01/msp430-energia-on-linux Now sure why this should be required for a well written code. 2. Changed the udev rule as suggested in http://www.itopen.it/2013/03/01/msp430-energia-on-linux/ (basically Mode and group) more /etc/udev/rules.d/46-TI_launchpad.rules#MSP 430 Launchpad#Bus 002 Device 005: ID 0451:f432 Texas Instruments, Inc. eZ430 Development ToolSUBSYSTEMS=="usb",ATTRS{idVendor}=="0451",ATTRS{idProduct}=="f430",MODE="666",GROUP="dialout"SUBSYSTEMS=="usb",ATTRS{idVendor}=="0451",ATTRS{idProduct}=="f432",MODE="666",GROUP="dialout" Now sure why GROUP for /dev/ttyACM0 is stuck to dialout. 3. Changed cdcacm module as suggested by bi0tech in his last suggestion. The kernel source for 3.2.0.60-generic has changed and patch should be updated, as I had to manually search patterns and then edit the code. Thus, not sure whether I did the edits correctly. energia 1 Quote Link to post Share on other sites
bi0tech 4 Posted May 7, 2014 Share Posted May 7, 2014 as CCS 6.0 does not support MSP-EXP430G2 Launchpad on linux One last note I'll throw in this thread since it already has other info. CCSv6 does actually work with the MSP430 under Linux, I'm not sure I'd go as far as saying 'supported' though. For debugging you have to configure it for external program use of mspdebug as a relay for msp430-gdb, but it functions in terms of compilation (briefly tested TI compiler with 430ware libs and Energia project imports using GCC), flashing, and debugging with those external tools. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.