https://wiki.gumstix.com/api.php?action=feedcontributions&user=Alxx&feedformat=atomGumstix User Wiki - User contributions [en]2024-03-28T22:47:47ZUser contributionsMediaWiki 1.25.3https://wiki.gumstix.com/index.php?title=ADC_overo_2.6.38-&diff=5698ADC overo 2.6.38-2011-11-09T01:04:40Z<p>Alxx: </p>
<hr />
<div>For overo's running kernel 2.6.38 and earlier<br />
<br />
Use /dev/twl4030 to access the adc's<br />
<br />
See Scott Ellis' page<br />
<br />
http://www.jumpnowtek.com/index.php?option=com_content&view=article&id=79&Itemid=91<br />
<br />
<br />
<br />
The source code uses the ‘twl4030’ as a name - which is also an older chip from TI. The TPS65950 on the OMAP board is pin-compatible and uses the same/similar ADC module so the older code works nicely (no need to reinvent the wheel).<br />
<br />
You can support the ‘twl4030’ in Linux is via a kernel module, which is the way you can access it directly via /dev/twl4030. The TPS65950 talks to the OMAP chip via I2C bus.<br />
<br />
Save both files in the same directory then build<br />
<br />
twl4030-madc.h<br />
<br />
<br />
/* <br />
* include/linux/i2c/twl4030-madc.h <br />
* <br />
* TWL4030 MADC module driver header <br />
* <br />
* Copyright (C) 2008 Nokia Corporation <br />
* Mikko Ylinen <mikko.k.ylinen@...> <br />
* <br />
* This program is free software; you can redistribute it and/or <br />
* modify it under the terms of the GNU General Public License <br />
* version 2 as published by the Free Software Foundation. <br />
* <br />
* This program is distributed in the hope that it will be useful, but <br />
* WITHOUT ANY WARRANTY; without even the implied warranty of <br />
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU <br />
* General Public License for more details. <br />
* <br />
* You should have received a copy of the GNU General Public License <br />
* along with this program; if not, write to the Free Software <br />
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA <br />
* 02110-1301 USA <br />
* <br />
*/ <br />
#ifndef _TWL4030_MADC_H <br />
#define _TWL4030_MADC_H <br />
struct twl4030_madc_conversion_method { <br />
u8 sel; <br />
u8 avg; <br />
u8 rbase; <br />
u8 ctrl; <br />
}; <br />
#define TWL4030_MADC_MAX_CHANNELS 16 <br />
struct twl4030_madc_request { <br />
u16 channels; <br />
u16 do_avg; <br />
u16 method; <br />
u16 type; <br />
int active; <br />
int result_pending; <br />
int rbuf[TWL4030_MADC_MAX_CHANNELS]; <br />
void (*func_cb)(int len, int channels, int *buf); <br />
}; <br />
enum conversion_methods { <br />
TWL4030_MADC_RT, <br />
TWL4030_MADC_SW1, <br />
TWL4030_MADC_SW2, <br />
TWL4030_MADC_NUM_METHODS <br />
}; <br />
enum sample_type { <br />
TWL4030_MADC_WAIT, <br />
TWL4030_MADC_IRQ_ONESHOT, <br />
TWL4030_MADC_IRQ_REARM <br />
}; <br />
#define TWL4030_MADC_CTRL1 0x00 <br />
#define TWL4030_MADC_CTRL2 0x01 <br />
#define TWL4030_MADC_RTSELECT_LSB 0x02 <br />
#define TWL4030_MADC_SW1SELECT_LSB 0x06 <br />
#define TWL4030_MADC_SW2SELECT_LSB 0x0A <br />
#define TWL4030_MADC_RTAVERAGE_LSB 0x04 <br />
#define TWL4030_MADC_SW1AVERAGE_LSB 0x08 <br />
#define TWL4030_MADC_SW2AVERAGE_LSB 0x0C <br />
#define TWL4030_MADC_CTRL_SW1 0x12 <br />
#define TWL4030_MADC_CTRL_SW2 0x13 <br />
#define TWL4030_MADC_RTCH0_LSB 0x17 <br />
#define TWL4030_MADC_GPCH0_LSB 0x37 <br />
#define TWL4030_MADC_MADCON (1<<0) /* MADC power on */ <br />
#define TWL4030_MADC_BUSY (1<<0) /* MADC busy */ <br />
#define TWL4030_MADC_EOC_SW (1<<1) /* MADC conversion completion */ <br />
#define TWL4030_MADC_SW_START (1<<5) /* MADC SWx start conversion */ <br />
#define TWL4030_MADC_ADCIN0 (1<<0) <br />
#define TWL4030_MADC_ADCIN1 (1<<1) <br />
#define TWL4030_MADC_ADCIN2 (1<<2) <br />
#define TWL4030_MADC_ADCIN3 (1<<3) <br />
#define TWL4030_MADC_ADCIN4 (1<<4) <br />
#define TWL4030_MADC_ADCIN5 (1<<5) <br />
#define TWL4030_MADC_ADCIN6 (1<<6) <br />
#define TWL4030_MADC_ADCIN7 (1<<7) <br />
#define TWL4030_MADC_ADCIN8 (1<<8) <br />
#define TWL4030_MADC_ADCIN9 (1<<9) <br />
#define TWL4030_MADC_ADCIN10 (1<<10) <br />
#define TWL4030_MADC_ADCIN11 (1<<11) <br />
#define TWL4030_MADC_ADCIN12 (1<<12) <br />
#define TWL4030_MADC_ADCIN13 (1<<13) <br />
#define TWL4030_MADC_ADCIN14 (1<<14) <br />
#define TWL4030_MADC_ADCIN15 (1<<15) <br />
/* Fixed channels */ <br />
#define TWL4030_MADC_BTEMP TWL4030_MADC_ADCIN1 <br />
#define TWL4030_MADC_VBUS TWL4030_MADC_ADCIN8 <br />
#define TWL4030_MADC_VBKB TWL4030_MADC_ADCIN9 <br />
#define TWL4030_MADC_ICHG TWL4030_MADC_ADCIN10 <br />
#define TWL4030_MADC_VCHG TWL4030_MADC_ADCIN11 <br />
#define TWL4030_MADC_VBAT TWL4030_MADC_ADCIN12 <br />
/* BCI related - XXX To be moved elsewhere */ <br />
#define TWL4030_BCI_BCICTL1 0x23 <br />
#define TWL4030_BCI_MESBAT (1<<1) <br />
#define TWL4030_BCI_TYPEN (1<<4) <br />
#define TWL4030_BCI_ITHEN (1<<3) <br />
#define TWL4030_MADC_IOC_MAGIC '`' <br />
#define TWL4030_MADC_IOCX_ADC_RAW_READ _IO(TWL4030_MADC_IOC_MAGIC, 0) <br />
struct twl4030_madc_user_parms { <br />
int channel; <br />
int average; <br />
int status; <br />
u16 result; <br />
}; <br />
int twl4030_madc_conversion(struct twl4030_madc_request *conv); <br />
#endif<br />
<br />
'''Main program'''<br />
<br />
/* Test code for the MADC function<br />
*<br />
* Hugo Vincent, May 2009<br />
*/<br />
#include <sys/ioctl.h><br />
#include <sys/types.h><br />
#include <sys/stat.h><br />
#include <fcntl.h><br />
#include <stdio.h><br />
#include <stdint.h><br />
#include <string.h><br />
#include <stdlib.h><br />
#include <unistd.h><br />
#include <errno.h><br />
#include <time.h><br />
typedef uint8_t u8;<br />
typedef uint16_t u16;<br />
#include "twl4030-madc.h"<br />
/* Note: (very weird) the madc driver seems to crash if you've got driver debugging<br />
* turned on in your defconfig... */<br />
/* Channel numbering:<br />
* ADC0-1 : to do with battery charging, not relevant on Overo<br />
* ADC2-7 : general purpose, input range = 0 - 2.5V.<br />
* On Overo, ADC2 seems to read as ~0.4 and ADC7 as ~1.4V (?).<br />
* ADC8 : USB OTG port bus voltage.<br />
* ADC9-11 : more battery charging stuff, not relevant.<br />
* ADC12 : main battery voltage.<br />
* This will be the system 3.3V rail in our case<br />
* ADC13-15: reserved or not relevant.<br />
*/<br />
struct adc_channel {<br />
int number;<br />
char name[16];<br />
float input_range;<br />
};<br />
struct adc_channel channels[] = {<br />
{<br />
.number = 2,<br />
.name = "ADCIN2",<br />
.input_range = 2.5,<br />
},<br />
{<br />
.number = 3,<br />
.name = "ADCIN3",<br />
.input_range = 2.5,<br />
},<br />
{<br />
.number = 4,<br />
.name = "ADCIN4",<br />
.input_range = 2.5,<br />
},<br />
{<br />
.number = 5,<br />
.name = "ADCIN5",<br />
.input_range = 2.5,<br />
},<br />
{<br />
.number = 6,<br />
.name = "ADCIN6",<br />
.input_range = 2.5,<br />
},<br />
{<br />
.number = 7,<br />
.name = "ADCIN7",<br />
.input_range = 2.5,<br />
},<br />
{<br />
.number = 8,<br />
.name = "VBUS_USB_OTG",<br />
.input_range = 7.0,<br />
},<br />
{<br />
.number = 12,<br />
.name = "VBATT/3.3V_RAIL",<br />
.input_range = 6.0,<br />
},<br />
};<br />
int main(int argc, char **argv)<br />
{<br />
int d = open("/dev/twl4030-madc", O_RDWR | O_NONBLOCK);<br />
if (d == -1)<br />
{<br />
printf("could not open device /dev/twl4030-madc \n");<br />
EXIT_FAILURE;<br />
}<br />
struct twl4030_madc_user_parms *par;<br />
par = malloc(sizeof(struct twl4030_madc_user_parms));<br />
for (j = 0; j < (sizeof(channels)/sizeof(struct adc_channel)); j++)<br />
{<br />
memset(par, 0, sizeof(struct twl4030_madc_user_parms));<br />
par->channel = channels[j].number;<br />
int ret = ioctl(d, TWL4030_MADC_IOCX_ADC_RAW_READ, par);<br />
float result = ((unsigned int)par->result) / 1024.f;/* 10 bit ADC -> 1024 */<br />
if (ret == 0 && par->status != -1)<br />
{<br />
printf("%s (channel %d): %f\n", channels[j].name, channels[j].number,result * channels[j].input_range); <br />
}<br />
else<br />
{<br />
if (par->status == -1)<br />
printf("Channel %d (%s) timed out!\n", j, channels[j].name);<br />
printf("ERROR\n");<br />
exit(1);<br />
}<br />
} <br />
return 0;<br />
}<br />
<br />
<br />
compile it<br />
<br />
gcc –o madc madc.c<br />
<br />
root@overo:~# ./madc<br />
ADCIN2 (channel 2): 0.673828<br />
ADCIN3 (channel 3): 0.087891<br />
ADCIN4 (channel 4): 0.612793<br />
ADCIN5 (channel 5): 0.090332<br />
ADCIN6 (channel 6): 0.341797<br />
ADCIN7 (channel 7): 1.374512<br />
VBUS_USB_OTG (channel 8): 5.154297<br />
VBATT/3.3V_RAIL (channel 12): 3.275391<br />
root@overo:~#<br />
<br />
when using the ADCs you may/will need to scale values.<br />
To connect up circuits running at higher than 2.5V you will need to use a voltage divider (resistors)<br />
<br />
Vincent, H. (2009) ADC Code Example – Help with Overo ADC. http://old.nabble.com/Re%3A-Help-with-Overo-ADC-td24174607.html <br />
<br />
TI TPS65950 Integrated Power Management/Audio Codec Data Manual http://focus.ti.com/lit/ds/symlink/tps65950.pdf<br />
<br />
TI TPS65950 OMAP Power Management and System Companion Device Version G Technical Reference Manual http://focus.ti.com/lit/ug/swcu050g/swcu050g.pdf</div>Alxxhttps://wiki.gumstix.com/index.php?title=ADC_overo_2.6.39%2B&diff=5667ADC overo 2.6.39+2011-09-21T07:11:19Z<p>Alxx: /* Python */</p>
<hr />
<div>==Using the ADC's==<br />
From posts in the mailing list by Steve Sakoman and others<br />
<br />
In linux-omap3-2.6.39 and 3.0 and above<br />
<br />
The madc driver is now upstream and in the process it moved to the hwmon subsystem.<br />
It is now even easier to access using the /sys/class interface:<br />
<br />
root@omap3-multi:~# ls /sys/class/hwmon/hwmon1/device/<br />
curr10_input in11_input in3_input in7_input power<br />
driver in12_input in4_input in8_input subsystem<br />
hwmon in15_input in5_input in9_input temp1_input<br />
in0_input in2_input in6_input modalias uevent<br />
<br />
<br />
root@omap3-multi:~# cat /sys/class/hwmon/hwmon1/device/temp1_input<br />
56<br />
<br />
root@omap3-multi:~# cat /sys/class/hwmon/hwmon1/device/curr10_input<br />
-750<br />
<br />
==ADC's via a system call==<br />
a quick and very nasty way to access them is by a system call<br />
===C===<br />
system("cat /sys/class/hwmon/hwmon1/device/in7_input");<br />
<br />
===Python===<br />
<br />
os.system("cat /sys/class/hwmon/hwmon1/device/in7_input")<br />
<br />
=== Python ===<br />
import os<br />
import sys<br />
import subprocess<br />
cmd1 = "cat /sys/class/hwmon/hwmon1/device/in7_input"<br />
process = subprocess.Popen(cmd1, stdout=subprocess.PIPE , shell=True)<br />
os.waitpid(process.pid, 0)[1]<br />
udata = process.stdout.read().strip()<br />
print udata <br />
<br />
'''In console (in interactive mode)'''<br />
<br />
python<br />
Python 2.6.6 (r266:84292, Sep 1 2011, 13:08:10)<br />
[GCC 4.3.3] on linux2<br />
>>> import os<br />
>>> import sys<br />
>>> import subprocess<br />
>>> cmd1 = "cat /sys/class/hwmon/hwmon1/device/in7_input"<br />
>>> process = subprocess.Popen(cmd1, stdout=subprocess.PIPE , shell=True)<br />
>>> os.waitpid(process.pid, 0)[1]<br />
0<br />
>>> udata = process.stdout.read().strip()<br />
>>> print udata<br />
1388<br />
>>><br />
<br />
==Using sysfs from c and fopen and fread==<br />
A much useful way to access the adc's is using fopen and fread.<br />
<br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include <string.h><br />
FILE *fp;<br />
int main(void)<br />
{<br />
char read_value[4];<br />
char adcVal2[6];<br />
if (( fp = fopen("/sys/class/hwmon/hwmon1/device/in2_input", "r")) == NULL)<br />
{<br />
printf("Can not open hwmon1 \n");<br />
exit(1);<br />
}<br />
rewind(fp);<br />
fread(&read_value, sizeof(char), 1 , fp);<br />
strcpy(adcVal2 , read_value);<br />
fclose(fp);<br />
printf("\nADC 2 value = %s \n",adcVal2);<br />
return 0;<br />
}<br />
<br />
==Building your own kernel ==<br />
<br />
When building your own kernel Make sure your defconfig has CONFIG_TWL4030_MADC and CONFIG_SENSORS_TWL4030_MADC<br />
and make sure your rootfs has the module.<br />
<br />
Link to kernel docs for Kernel driver twl4030-madc<br />
http://www.sakoman.com/cgi-bin/gitweb.cgi?p=linux-omap-2.6.git;a=blob;f=Documentation/hwmon/twl4030-madc-hwmon;h=ef7984317cecb29eca6ef23a30c21d920e66ef31;hb=refs/heads/omap-2.6.39-pm</div>Alxxhttps://wiki.gumstix.com/index.php?title=ADC_overo_2.6.39%2B&diff=5666ADC overo 2.6.39+2011-09-21T07:10:12Z<p>Alxx: /* Using the ADC's */ fix formatting</p>
<hr />
<div>==Using the ADC's==<br />
From posts in the mailing list by Steve Sakoman and others<br />
<br />
In linux-omap3-2.6.39 and 3.0 and above<br />
<br />
The madc driver is now upstream and in the process it moved to the hwmon subsystem.<br />
It is now even easier to access using the /sys/class interface:<br />
<br />
root@omap3-multi:~# ls /sys/class/hwmon/hwmon1/device/<br />
curr10_input in11_input in3_input in7_input power<br />
driver in12_input in4_input in8_input subsystem<br />
hwmon in15_input in5_input in9_input temp1_input<br />
in0_input in2_input in6_input modalias uevent<br />
<br />
<br />
root@omap3-multi:~# cat /sys/class/hwmon/hwmon1/device/temp1_input<br />
56<br />
<br />
root@omap3-multi:~# cat /sys/class/hwmon/hwmon1/device/curr10_input<br />
-750<br />
<br />
==ADC's via a system call==<br />
a quick and very nasty way to access them is by a system call<br />
===C===<br />
system("cat /sys/class/hwmon/hwmon1/device/in7_input");<br />
<br />
===Python===<br />
<br />
os.system("cat /sys/class/hwmon/hwmon1/device/in7_input")<br />
<br />
=== Python ===<br />
import os<br />
<br />
import sys<br />
<br />
import subprocess<br />
<br />
cmd1 = "cat /sys/class/hwmon/hwmon1/device/in7_input"<br />
<br />
process = subprocess.Popen(cmd1, stdout=subprocess.PIPE , shell=True)<br />
<br />
os.waitpid(process.pid, 0)[1]<br />
<br />
udata = process.stdout.read().strip()<br />
<br />
print udata <br />
<br />
'''In console (in interactive mode)'''<br />
<br />
python<br />
<br />
Python 2.6.6 (r266:84292, Sep 1 2011, 13:08:10)<br />
<br />
[GCC 4.3.3] on linux2<br />
<br />
>>> import os<br />
<br />
>>> import sys<br />
<br />
>>> import subprocess<br />
<br />
>>> cmd1 = "cat /sys/class/hwmon/hwmon1/device/in7_input"<br />
<br />
>>> process = subprocess.Popen(cmd1, stdout=subprocess.PIPE , shell=True)<br />
<br />
>>> os.waitpid(process.pid, 0)[1]<br />
<br />
0<br />
<br />
>>> udata = process.stdout.read().strip()<br />
<br />
>>> print udata<br />
<br />
1388<br />
<br />
>>> <br />
<br />
==Using sysfs from c and fopen and fread==<br />
A much useful way to access the adc's is using fopen and fread.<br />
<br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include <string.h><br />
FILE *fp;<br />
int main(void)<br />
{<br />
char read_value[4];<br />
char adcVal2[6];<br />
if (( fp = fopen("/sys/class/hwmon/hwmon1/device/in2_input", "r")) == NULL)<br />
{<br />
printf("Can not open hwmon1 \n");<br />
exit(1);<br />
}<br />
rewind(fp);<br />
fread(&read_value, sizeof(char), 1 , fp);<br />
strcpy(adcVal2 , read_value);<br />
fclose(fp);<br />
printf("\nADC 2 value = %s \n",adcVal2);<br />
return 0;<br />
}<br />
<br />
==Building your own kernel ==<br />
<br />
When building your own kernel Make sure your defconfig has CONFIG_TWL4030_MADC and CONFIG_SENSORS_TWL4030_MADC<br />
and make sure your rootfs has the module.<br />
<br />
Link to kernel docs for Kernel driver twl4030-madc<br />
http://www.sakoman.com/cgi-bin/gitweb.cgi?p=linux-omap-2.6.git;a=blob;f=Documentation/hwmon/twl4030-madc-hwmon;h=ef7984317cecb29eca6ef23a30c21d920e66ef31;hb=refs/heads/omap-2.6.39-pm</div>Alxxhttps://wiki.gumstix.com/index.php?title=ADC_overo_2.6.38-&diff=5665ADC overo 2.6.38-2011-09-21T07:08:46Z<p>Alxx: formatting fixed</p>
<hr />
<div>For overo's running kernel 2.6.38 and earlier<br />
<br />
Use /dev/twl4030 to access the adc's<br />
<br />
See Scott Ellis' page<br />
<br />
http://www.jumpnowtek.com/index.php?option=com_content&view=article&id=79&Itemid=91<br />
<br />
<br />
<br />
The source code uses the ‘twl4030’ as a name - which is also an older chip from TI. The TPS65950 on the OMAP board is pin-compatible and uses the same/similar ADC module so the older code works nicely (no need to reinvent the wheel).<br />
<br />
You can support the ‘twl4030’ in Linux is via a kernel module, which is the way you can access it directly via /dev/twl4030. The TPS65950 talks to the OMAP chip via I2C bus.<br />
<br />
Save both files in the same directory then build<br />
<br />
twl4030-madc.h<br />
<br />
<br />
/* <br />
* include/linux/i2c/twl4030-madc.h <br />
* <br />
* TWL4030 MADC module driver header <br />
* <br />
* Copyright (C) 2008 Nokia Corporation <br />
* Mikko Ylinen <mikko.k.ylinen@...> <br />
* <br />
* This program is free software; you can redistribute it and/or <br />
* modify it under the terms of the GNU General Public License <br />
* version 2 as published by the Free Software Foundation. <br />
* <br />
* This program is distributed in the hope that it will be useful, but <br />
* WITHOUT ANY WARRANTY; without even the implied warranty of <br />
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU <br />
* General Public License for more details. <br />
* <br />
* You should have received a copy of the GNU General Public License <br />
* along with this program; if not, write to the Free Software <br />
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA <br />
* 02110-1301 USA <br />
* <br />
*/ <br />
#ifndef _TWL4030_MADC_H <br />
#define _TWL4030_MADC_H <br />
struct twl4030_madc_conversion_method { <br />
u8 sel; <br />
u8 avg; <br />
u8 rbase; <br />
u8 ctrl; <br />
}; <br />
#define TWL4030_MADC_MAX_CHANNELS 16 <br />
struct twl4030_madc_request { <br />
u16 channels; <br />
u16 do_avg; <br />
u16 method; <br />
u16 type; <br />
int active; <br />
int result_pending; <br />
int rbuf[TWL4030_MADC_MAX_CHANNELS]; <br />
void (*func_cb)(int len, int channels, int *buf); <br />
}; <br />
enum conversion_methods { <br />
TWL4030_MADC_RT, <br />
TWL4030_MADC_SW1, <br />
TWL4030_MADC_SW2, <br />
TWL4030_MADC_NUM_METHODS <br />
}; <br />
enum sample_type { <br />
TWL4030_MADC_WAIT, <br />
TWL4030_MADC_IRQ_ONESHOT, <br />
TWL4030_MADC_IRQ_REARM <br />
}; <br />
#define TWL4030_MADC_CTRL1 0x00 <br />
#define TWL4030_MADC_CTRL2 0x01 <br />
#define TWL4030_MADC_RTSELECT_LSB 0x02 <br />
#define TWL4030_MADC_SW1SELECT_LSB 0x06 <br />
#define TWL4030_MADC_SW2SELECT_LSB 0x0A <br />
#define TWL4030_MADC_RTAVERAGE_LSB 0x04 <br />
#define TWL4030_MADC_SW1AVERAGE_LSB 0x08 <br />
#define TWL4030_MADC_SW2AVERAGE_LSB 0x0C <br />
#define TWL4030_MADC_CTRL_SW1 0x12 <br />
#define TWL4030_MADC_CTRL_SW2 0x13 <br />
#define TWL4030_MADC_RTCH0_LSB 0x17 <br />
#define TWL4030_MADC_GPCH0_LSB 0x37 <br />
#define TWL4030_MADC_MADCON (1<<0) /* MADC power on */ <br />
#define TWL4030_MADC_BUSY (1<<0) /* MADC busy */ <br />
#define TWL4030_MADC_EOC_SW (1<<1) /* MADC conversion completion */ <br />
#define TWL4030_MADC_SW_START (1<<5) /* MADC SWx start conversion */ <br />
#define TWL4030_MADC_ADCIN0 (1<<0) <br />
#define TWL4030_MADC_ADCIN1 (1<<1) <br />
#define TWL4030_MADC_ADCIN2 (1<<2) <br />
#define TWL4030_MADC_ADCIN3 (1<<3) <br />
#define TWL4030_MADC_ADCIN4 (1<<4) <br />
#define TWL4030_MADC_ADCIN5 (1<<5) <br />
#define TWL4030_MADC_ADCIN6 (1<<6) <br />
#define TWL4030_MADC_ADCIN7 (1<<7) <br />
#define TWL4030_MADC_ADCIN8 (1<<8) <br />
#define TWL4030_MADC_ADCIN9 (1<<9) <br />
#define TWL4030_MADC_ADCIN10 (1<<10) <br />
#define TWL4030_MADC_ADCIN11 (1<<11) <br />
#define TWL4030_MADC_ADCIN12 (1<<12) <br />
#define TWL4030_MADC_ADCIN13 (1<<13) <br />
#define TWL4030_MADC_ADCIN14 (1<<14) <br />
#define TWL4030_MADC_ADCIN15 (1<<15) <br />
/* Fixed channels */ <br />
#define TWL4030_MADC_BTEMP TWL4030_MADC_ADCIN1 <br />
#define TWL4030_MADC_VBUS TWL4030_MADC_ADCIN8 <br />
#define TWL4030_MADC_VBKB TWL4030_MADC_ADCIN9 <br />
#define TWL4030_MADC_ICHG TWL4030_MADC_ADCIN10 <br />
#define TWL4030_MADC_VCHG TWL4030_MADC_ADCIN11 <br />
#define TWL4030_MADC_VBAT TWL4030_MADC_ADCIN12 <br />
/* BCI related - XXX To be moved elsewhere */ <br />
#define TWL4030_BCI_BCICTL1 0x23 <br />
#define TWL4030_BCI_MESBAT (1<<1) <br />
#define TWL4030_BCI_TYPEN (1<<4) <br />
#define TWL4030_BCI_ITHEN (1<<3) <br />
#define TWL4030_MADC_IOC_MAGIC '`' <br />
#define TWL4030_MADC_IOCX_ADC_RAW_READ _IO(TWL4030_MADC_IOC_MAGIC, 0) <br />
struct twl4030_madc_user_parms { <br />
int channel; <br />
int average; <br />
int status; <br />
u16 result; <br />
}; <br />
int twl4030_madc_conversion(struct twl4030_madc_request *conv); <br />
#endif<br />
<br />
'''Main program'''<br />
<br />
/* Test code for the MADC function<br />
*<br />
* Hugo Vincent, May 2009<br />
*/<br />
#include <sys/ioctl.h><br />
#include <sys/types.h><br />
#include <sys/stat.h><br />
#include <fcntl.h><br />
#include <stdio.h><br />
#include <stdint.h><br />
#include <string.h><br />
#include <stdlib.h><br />
#include <unistd.h><br />
#include <errno.h><br />
#include <time.h><br />
typedef uint8_t u8;<br />
typedef uint16_t u16;<br />
#include "twl4030-madc.h"<br />
/* Note: (very weird) the madc driver seems to crash if you've got driver debugging<br />
* turned on in your defconfig... */<br />
/* Channel numbering:<br />
* ADC0-1 : to do with battery charging, not relevant on Overo<br />
* ADC2-7 : general purpose, input range = 0 - 2.5V.<br />
* On Overo, ADC2 seems to read as ~0.4 and ADC7 as ~1.4V (?).<br />
* ADC8 : USB OTG port bus voltage.<br />
* ADC9-11 : more battery charging stuff, not relevant.<br />
* ADC12 : main battery voltage.<br />
* This will be the system 3.3V rail in our case<br />
* ADC13-15: reserved or not relevant.<br />
*/<br />
struct adc_channel {<br />
int number;<br />
char name[16];<br />
float input_range;<br />
};<br />
struct adc_channel channels[] = {<br />
{<br />
.number = 2,<br />
.name = "ADCIN2",<br />
.input_range = 2.5,<br />
},<br />
{<br />
.number = 3,<br />
.name = "ADCIN3",<br />
.input_range = 2.5,<br />
},<br />
{<br />
.number = 4,<br />
.name = "ADCIN4",<br />
.input_range = 2.5,<br />
},<br />
{<br />
.number = 5,<br />
.name = "ADCIN5",<br />
.input_range = 2.5,<br />
},<br />
{<br />
.number = 6,<br />
.name = "ADCIN6",<br />
.input_range = 2.5,<br />
},<br />
{<br />
.number = 7,<br />
.name = "ADCIN7",<br />
.input_range = 2.5,<br />
},<br />
{<br />
.number = 8,<br />
.name = "VBUS_USB_OTG",<br />
.input_range = 7.0,<br />
},<br />
{<br />
.number = 12,<br />
.name = "VBATT/3.3V_RAIL",<br />
.input_range = 6.0,<br />
},<br />
};<br />
int main(int argc, char **argv)<br />
{<br />
int d = open("/dev/twl4030-madc", O_RDWR | O_NONBLOCK);<br />
if (d == -1)<br />
{<br />
printf("could not open device /dev/twl4030-madc \n");<br />
EXIT_FAILURE;<br />
}<br />
struct twl4030_madc_user_parms *par;<br />
par = malloc(sizeof(struct twl4030_madc_user_parms));<br />
for (j = 0; j < (sizeof(channels)/sizeof(struct adc_channel)); j++)<br />
{<br />
memset(par, 0, sizeof(struct twl4030_madc_user_parms));<br />
par->channel = channels[j].number;<br />
int ret = ioctl(d, TWL4030_MADC_IOCX_ADC_RAW_READ, par);<br />
float result = ((unsigned int)par->result) / 1024.f;/* 10 bit ADC -> 1024 */<br />
if (ret == 0 && par->status != -1)<br />
{<br />
printf("%s (channel %d): %f\n", channels[j].name, channels[j].number,result * channels[j].input_range); <br />
}<br />
else<br />
{<br />
if (par->status == -1)<br />
printf("Channel %d (%s) timed out!\n", j, channels[j].name);<br />
printf("ERROR\n");<br />
exit(1);<br />
}<br />
} <br />
return 0;<br />
}<br />
<br />
<br />
compile it<br />
<br />
gcc –o madc madc.c<br />
<br />
root@overo:~# ./madc<br />
ADCIN2 (channel 2): 0.673828<br />
ADCIN3 (channel 3): 0.087891<br />
ADCIN4 (channel 4): 0.612793<br />
ADCIN5 (channel 5): 0.090332<br />
ADCIN6 (channel 6): 0.341797<br />
ADCIN7 (channel 7): 1.374512<br />
VBUS_USB_OTG (channel 8): 5.154297<br />
VBATT/3.3V_RAIL (channel 12): 3.275391<br />
root@overo:~#<br />
<br />
when using the ADCs you may/will need to scale values.<br />
<br />
Vincent, H. (2009) ADC Code Example – Help with Overo ADC. http://old.nabble.com/Re%3A-Help-with-Overo-ADC-td24174607.html <br />
<br />
TI TPS65950 Integrated Power Management/Audio Codec Data Manual http://focus.ti.com/lit/ds/symlink/tps65950.pdf<br />
<br />
TI TPS65950 OMAP Power Management and System Companion Device Version G Technical Reference Manual http://focus.ti.com/lit/ug/swcu050g/swcu050g.pdf</div>Alxxhttps://wiki.gumstix.com/index.php?title=ADC_overo_2.6.39%2B&diff=5664ADC overo 2.6.39+2011-09-21T06:54:23Z<p>Alxx: /* Using sysfs from c and fopen and fread */</p>
<hr />
<div>==Using the ADC's==<br />
From posts in the mailing list by Steve Sakoman and others<br />
<br />
In linux-omap3-2.6.39 and 3.0 and above<br />
<br />
The madc driver is now upstream and in the process it moved to the hwmon subsystem.<br />
It is now even easier to access using the /sys/class interface:<br />
<br />
root@omap3-multi:~# ls /sys/class/hwmon/hwmon1/device/<br />
<br />
curr10_input in11_input in3_input in7_input power<br />
<br />
driver in12_input in4_input in8_input subsystem<br />
<br />
hwmon in15_input in5_input in9_input temp1_input<br />
<br />
in0_input in2_input in6_input modalias uevent<br />
<br />
root@omap3-multi:~# cat /sys/class/hwmon/hwmon1/device/temp1_input<br />
<br />
56<br />
<br />
root@omap3-multi:~# cat /sys/class/hwmon/hwmon1/device/curr10_input<br />
<br />
-750<br />
<br />
==ADC's via a system call==<br />
a quick and very nasty way to access them is by a system call<br />
===C===<br />
system("cat /sys/class/hwmon/hwmon1/device/in7_input");<br />
<br />
===Python===<br />
<br />
os.system("cat /sys/class/hwmon/hwmon1/device/in7_input")<br />
<br />
=== Python ===<br />
import os<br />
<br />
import sys<br />
<br />
import subprocess<br />
<br />
cmd1 = "cat /sys/class/hwmon/hwmon1/device/in7_input"<br />
<br />
process = subprocess.Popen(cmd1, stdout=subprocess.PIPE , shell=True)<br />
<br />
os.waitpid(process.pid, 0)[1]<br />
<br />
udata = process.stdout.read().strip()<br />
<br />
print udata <br />
<br />
'''In console (in interactive mode)'''<br />
<br />
python<br />
<br />
Python 2.6.6 (r266:84292, Sep 1 2011, 13:08:10)<br />
<br />
[GCC 4.3.3] on linux2<br />
<br />
>>> import os<br />
<br />
>>> import sys<br />
<br />
>>> import subprocess<br />
<br />
>>> cmd1 = "cat /sys/class/hwmon/hwmon1/device/in7_input"<br />
<br />
>>> process = subprocess.Popen(cmd1, stdout=subprocess.PIPE , shell=True)<br />
<br />
>>> os.waitpid(process.pid, 0)[1]<br />
<br />
0<br />
<br />
>>> udata = process.stdout.read().strip()<br />
<br />
>>> print udata<br />
<br />
1388<br />
<br />
>>> <br />
<br />
==Using sysfs from c and fopen and fread==<br />
A much useful way to access the adc's is using fopen and fread.<br />
<br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include <string.h><br />
FILE *fp;<br />
int main(void)<br />
{<br />
char read_value[4];<br />
char adcVal2[6];<br />
if (( fp = fopen("/sys/class/hwmon/hwmon1/device/in2_input", "r")) == NULL)<br />
{<br />
printf("Can not open hwmon1 \n");<br />
exit(1);<br />
}<br />
rewind(fp);<br />
fread(&read_value, sizeof(char), 1 , fp);<br />
strcpy(adcVal2 , read_value);<br />
fclose(fp);<br />
printf("\nADC 2 value = %s \n",adcVal2);<br />
return 0;<br />
}<br />
<br />
==Building your own kernel ==<br />
<br />
When building your own kernel Make sure your defconfig has CONFIG_TWL4030_MADC and CONFIG_SENSORS_TWL4030_MADC<br />
and make sure your rootfs has the module.<br />
<br />
Link to kernel docs for Kernel driver twl4030-madc<br />
http://www.sakoman.com/cgi-bin/gitweb.cgi?p=linux-omap-2.6.git;a=blob;f=Documentation/hwmon/twl4030-madc-hwmon;h=ef7984317cecb29eca6ef23a30c21d920e66ef31;hb=refs/heads/omap-2.6.39-pm</div>Alxxhttps://wiki.gumstix.com/index.php?title=ADC_overo_2.6.39%2B&diff=5663ADC overo 2.6.39+2011-09-21T06:54:02Z<p>Alxx: /* Using sysfs from c and fopen and fread */ code formating</p>
<hr />
<div>==Using the ADC's==<br />
From posts in the mailing list by Steve Sakoman and others<br />
<br />
In linux-omap3-2.6.39 and 3.0 and above<br />
<br />
The madc driver is now upstream and in the process it moved to the hwmon subsystem.<br />
It is now even easier to access using the /sys/class interface:<br />
<br />
root@omap3-multi:~# ls /sys/class/hwmon/hwmon1/device/<br />
<br />
curr10_input in11_input in3_input in7_input power<br />
<br />
driver in12_input in4_input in8_input subsystem<br />
<br />
hwmon in15_input in5_input in9_input temp1_input<br />
<br />
in0_input in2_input in6_input modalias uevent<br />
<br />
root@omap3-multi:~# cat /sys/class/hwmon/hwmon1/device/temp1_input<br />
<br />
56<br />
<br />
root@omap3-multi:~# cat /sys/class/hwmon/hwmon1/device/curr10_input<br />
<br />
-750<br />
<br />
==ADC's via a system call==<br />
a quick and very nasty way to access them is by a system call<br />
===C===<br />
system("cat /sys/class/hwmon/hwmon1/device/in7_input");<br />
<br />
===Python===<br />
<br />
os.system("cat /sys/class/hwmon/hwmon1/device/in7_input")<br />
<br />
=== Python ===<br />
import os<br />
<br />
import sys<br />
<br />
import subprocess<br />
<br />
cmd1 = "cat /sys/class/hwmon/hwmon1/device/in7_input"<br />
<br />
process = subprocess.Popen(cmd1, stdout=subprocess.PIPE , shell=True)<br />
<br />
os.waitpid(process.pid, 0)[1]<br />
<br />
udata = process.stdout.read().strip()<br />
<br />
print udata <br />
<br />
'''In console (in interactive mode)'''<br />
<br />
python<br />
<br />
Python 2.6.6 (r266:84292, Sep 1 2011, 13:08:10)<br />
<br />
[GCC 4.3.3] on linux2<br />
<br />
>>> import os<br />
<br />
>>> import sys<br />
<br />
>>> import subprocess<br />
<br />
>>> cmd1 = "cat /sys/class/hwmon/hwmon1/device/in7_input"<br />
<br />
>>> process = subprocess.Popen(cmd1, stdout=subprocess.PIPE , shell=True)<br />
<br />
>>> os.waitpid(process.pid, 0)[1]<br />
<br />
0<br />
<br />
>>> udata = process.stdout.read().strip()<br />
<br />
>>> print udata<br />
<br />
1388<br />
<br />
>>> <br />
<br />
==Using sysfs from c and fopen and fread==<br />
A much useful way to access the adc's is using fopen and fread.<br />
<br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include <sys/types.h><br />
#include <sys/stat.h><br />
#include <unistd.h><br />
#include <fcntl.h><br />
#include <sys/mman.h><br />
#include <time.h><br />
#include <string.h><br />
FILE *fp;<br />
int main(void)<br />
{<br />
char read_value[4];<br />
char adcVal2[6];<br />
if (( fp = fopen("/sys/class/hwmon/hwmon1/device/in2_input", "r")) == NULL)<br />
{<br />
printf("Can not open hwmon1 \n");<br />
exit(1);<br />
}<br />
rewind(fp);<br />
fread(&read_value, sizeof(char), 1 , fp);<br />
strcpy(adcVal2 , read_value);<br />
fclose(fp);<br />
printf("\nADC 2 value = %s \n",adcVal2);<br />
return 0;<br />
}<br />
<br />
==Building your own kernel ==<br />
<br />
When building your own kernel Make sure your defconfig has CONFIG_TWL4030_MADC and CONFIG_SENSORS_TWL4030_MADC<br />
and make sure your rootfs has the module.<br />
<br />
Link to kernel docs for Kernel driver twl4030-madc<br />
http://www.sakoman.com/cgi-bin/gitweb.cgi?p=linux-omap-2.6.git;a=blob;f=Documentation/hwmon/twl4030-madc-hwmon;h=ef7984317cecb29eca6ef23a30c21d920e66ef31;hb=refs/heads/omap-2.6.39-pm</div>Alxxhttps://wiki.gumstix.com/index.php?title=ADC_overo_2.6.39%2B&diff=5662ADC overo 2.6.39+2011-09-21T06:46:30Z<p>Alxx: /* Using sysfs from c and fopen and fread */</p>
<hr />
<div>==Using the ADC's==<br />
From posts in the mailing list by Steve Sakoman and others<br />
<br />
In linux-omap3-2.6.39 and 3.0 and above<br />
<br />
The madc driver is now upstream and in the process it moved to the hwmon subsystem.<br />
It is now even easier to access using the /sys/class interface:<br />
<br />
root@omap3-multi:~# ls /sys/class/hwmon/hwmon1/device/<br />
<br />
curr10_input in11_input in3_input in7_input power<br />
<br />
driver in12_input in4_input in8_input subsystem<br />
<br />
hwmon in15_input in5_input in9_input temp1_input<br />
<br />
in0_input in2_input in6_input modalias uevent<br />
<br />
root@omap3-multi:~# cat /sys/class/hwmon/hwmon1/device/temp1_input<br />
<br />
56<br />
<br />
root@omap3-multi:~# cat /sys/class/hwmon/hwmon1/device/curr10_input<br />
<br />
-750<br />
<br />
==ADC's via a system call==<br />
a quick and very nasty way to access them is by a system call<br />
===C===<br />
system("cat /sys/class/hwmon/hwmon1/device/in7_input");<br />
<br />
===Python===<br />
<br />
os.system("cat /sys/class/hwmon/hwmon1/device/in7_input")<br />
<br />
=== Python ===<br />
import os<br />
<br />
import sys<br />
<br />
import subprocess<br />
<br />
cmd1 = "cat /sys/class/hwmon/hwmon1/device/in7_input"<br />
<br />
process = subprocess.Popen(cmd1, stdout=subprocess.PIPE , shell=True)<br />
<br />
os.waitpid(process.pid, 0)[1]<br />
<br />
udata = process.stdout.read().strip()<br />
<br />
print udata <br />
<br />
'''In console (in interactive mode)'''<br />
<br />
python<br />
<br />
Python 2.6.6 (r266:84292, Sep 1 2011, 13:08:10)<br />
<br />
[GCC 4.3.3] on linux2<br />
<br />
>>> import os<br />
<br />
>>> import sys<br />
<br />
>>> import subprocess<br />
<br />
>>> cmd1 = "cat /sys/class/hwmon/hwmon1/device/in7_input"<br />
<br />
>>> process = subprocess.Popen(cmd1, stdout=subprocess.PIPE , shell=True)<br />
<br />
>>> os.waitpid(process.pid, 0)[1]<br />
<br />
0<br />
<br />
>>> udata = process.stdout.read().strip()<br />
<br />
>>> print udata<br />
<br />
1388<br />
<br />
>>> <br />
<br />
==Using sysfs from c and fopen and fread==<br />
A much useful way to access the adc's is using fopen and fread.<br />
<br />
<nowiki><br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include <sys/types.h><br />
#include <sys/stat.h><br />
#include <unistd.h><br />
#include <fcntl.h><br />
#include <sys/mman.h><br />
#include <time.h><br />
#include <string.h><br />
<br />
FILE *fp;<br />
<br />
int main(void)<br />
{<br />
char read_value[4];<br />
char adcVal2[6];<br />
if (( fp = fopen("/sys/class/hwmon/hwmon1/device/in2_input", "r")) == NULL)<br />
{<br />
printf("Can not open hwmon1 \n");<br />
exit(1);<br />
}<br />
rewind(fp);<br />
<br />
fread(&read_value, sizeof(char), 1 , fp);<br />
strcpy(adcVal2 , read_value);<br />
<br />
fclose(fp);<br />
printf("\nADC 2 value = %s \n",adcVal2);<br />
return 0;<br />
}<br />
</nowiki><br />
<br />
==Building your own kernel ==<br />
<br />
When building your own kernel Make sure your defconfig has CONFIG_TWL4030_MADC and CONFIG_SENSORS_TWL4030_MADC<br />
and make sure your rootfs has the module.<br />
<br />
Link to kernel docs for Kernel driver twl4030-madc<br />
http://www.sakoman.com/cgi-bin/gitweb.cgi?p=linux-omap-2.6.git;a=blob;f=Documentation/hwmon/twl4030-madc-hwmon;h=ef7984317cecb29eca6ef23a30c21d920e66ef31;hb=refs/heads/omap-2.6.39-pm</div>Alxxhttps://wiki.gumstix.com/index.php?title=ADC_overo_2.6.39%2B&diff=5661ADC overo 2.6.39+2011-09-21T06:45:58Z<p>Alxx: /* Using sysfs in c and fopen and fread */</p>
<hr />
<div>==Using the ADC's==<br />
From posts in the mailing list by Steve Sakoman and others<br />
<br />
In linux-omap3-2.6.39 and 3.0 and above<br />
<br />
The madc driver is now upstream and in the process it moved to the hwmon subsystem.<br />
It is now even easier to access using the /sys/class interface:<br />
<br />
root@omap3-multi:~# ls /sys/class/hwmon/hwmon1/device/<br />
<br />
curr10_input in11_input in3_input in7_input power<br />
<br />
driver in12_input in4_input in8_input subsystem<br />
<br />
hwmon in15_input in5_input in9_input temp1_input<br />
<br />
in0_input in2_input in6_input modalias uevent<br />
<br />
root@omap3-multi:~# cat /sys/class/hwmon/hwmon1/device/temp1_input<br />
<br />
56<br />
<br />
root@omap3-multi:~# cat /sys/class/hwmon/hwmon1/device/curr10_input<br />
<br />
-750<br />
<br />
==ADC's via a system call==<br />
a quick and very nasty way to access them is by a system call<br />
===C===<br />
system("cat /sys/class/hwmon/hwmon1/device/in7_input");<br />
<br />
===Python===<br />
<br />
os.system("cat /sys/class/hwmon/hwmon1/device/in7_input")<br />
<br />
=== Python ===<br />
import os<br />
<br />
import sys<br />
<br />
import subprocess<br />
<br />
cmd1 = "cat /sys/class/hwmon/hwmon1/device/in7_input"<br />
<br />
process = subprocess.Popen(cmd1, stdout=subprocess.PIPE , shell=True)<br />
<br />
os.waitpid(process.pid, 0)[1]<br />
<br />
udata = process.stdout.read().strip()<br />
<br />
print udata <br />
<br />
'''In console (in interactive mode)'''<br />
<br />
python<br />
<br />
Python 2.6.6 (r266:84292, Sep 1 2011, 13:08:10)<br />
<br />
[GCC 4.3.3] on linux2<br />
<br />
>>> import os<br />
<br />
>>> import sys<br />
<br />
>>> import subprocess<br />
<br />
>>> cmd1 = "cat /sys/class/hwmon/hwmon1/device/in7_input"<br />
<br />
>>> process = subprocess.Popen(cmd1, stdout=subprocess.PIPE , shell=True)<br />
<br />
>>> os.waitpid(process.pid, 0)[1]<br />
<br />
0<br />
<br />
>>> udata = process.stdout.read().strip()<br />
<br />
>>> print udata<br />
<br />
1388<br />
<br />
>>> <br />
<br />
==Using sysfs from c and fopen and fread==<br />
A much useful way to access the adc's is using fopen and fread.<br />
<nowiki><br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include <sys/types.h><br />
#include <sys/stat.h><br />
#include <unistd.h><br />
#include <fcntl.h><br />
#include <sys/mman.h><br />
#include <time.h><br />
#include <string.h><br />
<br />
FILE *fp;<br />
<br />
int main(void)<br />
{<br />
char read_value[4];<br />
char adcVal2[6];<br />
if (( fp = fopen("/sys/class/hwmon/hwmon1/device/in2_input", "r")) == NULL)<br />
{<br />
printf("Can not open hwmon1 \n");<br />
exit(1);<br />
}<br />
rewind(fp);<br />
<br />
fread(&read_value, sizeof(char), 1 , fp);<br />
strcpy(adcVal2 , read_value);<br />
<br />
fclose(fp);<br />
printf("\nADC 2 value = %s \n",adcVal2);<br />
return 0;<br />
}<br />
</nowiki><br />
<br />
==Building your own kernel ==<br />
<br />
When building your own kernel Make sure your defconfig has CONFIG_TWL4030_MADC and CONFIG_SENSORS_TWL4030_MADC<br />
and make sure your rootfs has the module.<br />
<br />
Link to kernel docs for Kernel driver twl4030-madc<br />
http://www.sakoman.com/cgi-bin/gitweb.cgi?p=linux-omap-2.6.git;a=blob;f=Documentation/hwmon/twl4030-madc-hwmon;h=ef7984317cecb29eca6ef23a30c21d920e66ef31;hb=refs/heads/omap-2.6.39-pm</div>Alxxhttps://wiki.gumstix.com/index.php?title=ADC_overo_2.6.39%2B&diff=5660ADC overo 2.6.39+2011-09-21T06:44:17Z<p>Alxx: added brief example on reading adc's in c via fopen and fread</p>
<hr />
<div>==Using the ADC's==<br />
From posts in the mailing list by Steve Sakoman and others<br />
<br />
In linux-omap3-2.6.39 and 3.0 and above<br />
<br />
The madc driver is now upstream and in the process it moved to the hwmon subsystem.<br />
It is now even easier to access using the /sys/class interface:<br />
<br />
root@omap3-multi:~# ls /sys/class/hwmon/hwmon1/device/<br />
<br />
curr10_input in11_input in3_input in7_input power<br />
<br />
driver in12_input in4_input in8_input subsystem<br />
<br />
hwmon in15_input in5_input in9_input temp1_input<br />
<br />
in0_input in2_input in6_input modalias uevent<br />
<br />
root@omap3-multi:~# cat /sys/class/hwmon/hwmon1/device/temp1_input<br />
<br />
56<br />
<br />
root@omap3-multi:~# cat /sys/class/hwmon/hwmon1/device/curr10_input<br />
<br />
-750<br />
<br />
==ADC's via a system call==<br />
a quick and very nasty way to access them is by a system call<br />
===C===<br />
system("cat /sys/class/hwmon/hwmon1/device/in7_input");<br />
<br />
===Python===<br />
<br />
os.system("cat /sys/class/hwmon/hwmon1/device/in7_input")<br />
<br />
=== Python ===<br />
import os<br />
<br />
import sys<br />
<br />
import subprocess<br />
<br />
cmd1 = "cat /sys/class/hwmon/hwmon1/device/in7_input"<br />
<br />
process = subprocess.Popen(cmd1, stdout=subprocess.PIPE , shell=True)<br />
<br />
os.waitpid(process.pid, 0)[1]<br />
<br />
udata = process.stdout.read().strip()<br />
<br />
print udata <br />
<br />
'''In console (in interactive mode)'''<br />
<br />
python<br />
<br />
Python 2.6.6 (r266:84292, Sep 1 2011, 13:08:10)<br />
<br />
[GCC 4.3.3] on linux2<br />
<br />
>>> import os<br />
<br />
>>> import sys<br />
<br />
>>> import subprocess<br />
<br />
>>> cmd1 = "cat /sys/class/hwmon/hwmon1/device/in7_input"<br />
<br />
>>> process = subprocess.Popen(cmd1, stdout=subprocess.PIPE , shell=True)<br />
<br />
>>> os.waitpid(process.pid, 0)[1]<br />
<br />
0<br />
<br />
>>> udata = process.stdout.read().strip()<br />
<br />
>>> print udata<br />
<br />
1388<br />
<br />
>>> <br />
<br />
==Using sysfs in c and fopen and fread==<br />
<nowiki><br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include <sys/types.h><br />
#include <sys/stat.h><br />
#include <unistd.h><br />
#include <fcntl.h><br />
#include <sys/mman.h><br />
#include <time.h><br />
#include <string.h><br />
<br />
FILE *fp;<br />
<br />
int main(void)<br />
{<br />
<br />
<br />
char read_value[4];<br />
<br />
char adcVal2[6];<br />
<br />
if (( fp = fopen("/sys/class/hwmon/hwmon1/device/in2_input", "r")) == NULL)<br />
{<br />
printf("Can not open hwmon1 \n");<br />
exit(1);<br />
}<br />
<br />
rewind(fp);<br />
<br />
fread(&read_value, sizeof(char), 1 , fp);<br />
strcpy(adcVal2 , read_value);<br />
<br />
fclose(fp);<br />
printf("\nADC 2 value = %s \n",adcVal2);<br />
<br />
<br />
<br />
return 0;<br />
}</nowiki><br />
<br />
==Building your own kernel ==<br />
<br />
When building your own kernel Make sure your defconfig has CONFIG_TWL4030_MADC and CONFIG_SENSORS_TWL4030_MADC<br />
and make sure your rootfs has the module.<br />
<br />
Link to kernel docs for Kernel driver twl4030-madc<br />
http://www.sakoman.com/cgi-bin/gitweb.cgi?p=linux-omap-2.6.git;a=blob;f=Documentation/hwmon/twl4030-madc-hwmon;h=ef7984317cecb29eca6ef23a30c21d920e66ef31;hb=refs/heads/omap-2.6.39-pm</div>Alxxhttps://wiki.gumstix.com/index.php?title=ADC_overo_2.6.39%2B&diff=5659ADC overo 2.6.39+2011-09-19T08:12:14Z<p>Alxx: /* Using the ADC's */</p>
<hr />
<div>==Using the ADC's==<br />
From posts in the mailing list by Steve Sakoman and others<br />
<br />
In linux-omap3-2.6.39 and 3.0 and above<br />
<br />
The madc driver is now upstream and in the process it moved to the hwmon subsystem.<br />
It is now even easier to access using the /sys/class interface:<br />
<br />
root@omap3-multi:~# ls /sys/class/hwmon/hwmon1/device/<br />
<br />
curr10_input in11_input in3_input in7_input power<br />
<br />
driver in12_input in4_input in8_input subsystem<br />
<br />
hwmon in15_input in5_input in9_input temp1_input<br />
<br />
in0_input in2_input in6_input modalias uevent<br />
<br />
root@omap3-multi:~# cat /sys/class/hwmon/hwmon1/device/temp1_input<br />
<br />
56<br />
<br />
root@omap3-multi:~# cat /sys/class/hwmon/hwmon1/device/curr10_input<br />
<br />
-750<br />
<br />
==ADC's via a system call==<br />
a quick and very nasty way to access them is by a system call<br />
===C===<br />
system("cat /sys/class/hwmon/hwmon1/device/in7_input");<br />
<br />
===Python===<br />
<br />
os.system("cat /sys/class/hwmon/hwmon1/device/in7_input")<br />
<br />
=== Python ===<br />
import os<br />
<br />
import sys<br />
<br />
import subprocess<br />
<br />
cmd1 = "cat /sys/class/hwmon/hwmon1/device/in7_input"<br />
<br />
process = subprocess.Popen(cmd1, stdout=subprocess.PIPE , shell=True)<br />
<br />
os.waitpid(process.pid, 0)[1]<br />
<br />
udata = process.stdout.read().strip()<br />
<br />
print udata <br />
<br />
'''In console (in interactive mode)'''<br />
<br />
python<br />
<br />
Python 2.6.6 (r266:84292, Sep 1 2011, 13:08:10)<br />
<br />
[GCC 4.3.3] on linux2<br />
<br />
>>> import os<br />
<br />
>>> import sys<br />
<br />
>>> import subprocess<br />
<br />
>>> cmd1 = "cat /sys/class/hwmon/hwmon1/device/in7_input"<br />
<br />
>>> process = subprocess.Popen(cmd1, stdout=subprocess.PIPE , shell=True)<br />
<br />
>>> os.waitpid(process.pid, 0)[1]<br />
<br />
0<br />
<br />
>>> udata = process.stdout.read().strip()<br />
<br />
>>> print udata<br />
<br />
1388<br />
<br />
>>> <br />
<br />
==<br />
<br />
==Building your own kernel ==<br />
<br />
When building your own kernel Make sure your defconfig has CONFIG_TWL4030_MADC and CONFIG_SENSORS_TWL4030_MADC<br />
and make sure your rootfs has the module.<br />
<br />
Link to kernel docs for Kernel driver twl4030-madc<br />
http://www.sakoman.com/cgi-bin/gitweb.cgi?p=linux-omap-2.6.git;a=blob;f=Documentation/hwmon/twl4030-madc-hwmon;h=ef7984317cecb29eca6ef23a30c21d920e66ef31;hb=refs/heads/omap-2.6.39-pm</div>Alxxhttps://wiki.gumstix.com/index.php?title=ADC_overo_2.6.38-&diff=5658ADC overo 2.6.38-2011-09-19T08:04:36Z<p>Alxx: </p>
<hr />
<div>For overo's running kernel 2.6.38 and earlier<br />
<br />
Use /dev/twl4030 to access the adc's<br />
<br />
See Scott Ellis' page<br />
<br />
http://www.jumpnowtek.com/index.php?option=com_content&view=article&id=79&Itemid=91<br />
<br />
<br />
<br />
The source code uses the ‘twl4030’ as a name - which is also an older chip from TI. The TPS65950 on the OMAP board is pin-compatible and uses the same/similar ADC module so the older code works nicely (no need to reinvent the wheel).<br />
<br />
You can support the ‘twl4030’ in Linux is via a kernel module, which is the way you can access it directly via /dev/twl4030. The TPS65950 talks to the OMAP chip via I2C bus.<br />
<br />
Save both files in the same directory then build<br />
<br />
twl4030-madc.h<br />
<br />
<nowiki><br />
/* <br />
* include/linux/i2c/twl4030-madc.h <br />
* <br />
* TWL4030 MADC module driver header <br />
* <br />
* Copyright (C) 2008 Nokia Corporation <br />
* Mikko Ylinen <mikko.k.ylinen@...> <br />
* <br />
* This program is free software; you can redistribute it and/or <br />
* modify it under the terms of the GNU General Public License <br />
* version 2 as published by the Free Software Foundation. <br />
* <br />
* This program is distributed in the hope that it will be useful, but <br />
* WITHOUT ANY WARRANTY; without even the implied warranty of <br />
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU <br />
* General Public License for more details. <br />
* <br />
* You should have received a copy of the GNU General Public License <br />
* along with this program; if not, write to the Free Software <br />
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA <br />
* 02110-1301 USA <br />
* <br />
*/ <br />
#ifndef _TWL4030_MADC_H <br />
#define _TWL4030_MADC_H <br />
<br />
struct twl4030_madc_conversion_method { <br />
u8 sel; <br />
u8 avg; <br />
u8 rbase; <br />
u8 ctrl; <br />
}; <br />
<br />
#define TWL4030_MADC_MAX_CHANNELS 16 <br />
<br />
struct twl4030_madc_request { <br />
u16 channels; <br />
u16 do_avg; <br />
u16 method; <br />
u16 type; <br />
int active; <br />
int result_pending; <br />
int rbuf[TWL4030_MADC_MAX_CHANNELS]; <br />
void (*func_cb)(int len, int channels, int *buf); <br />
}; <br />
<br />
enum conversion_methods { <br />
TWL4030_MADC_RT, <br />
TWL4030_MADC_SW1, <br />
TWL4030_MADC_SW2, <br />
TWL4030_MADC_NUM_METHODS <br />
}; <br />
<br />
enum sample_type { <br />
TWL4030_MADC_WAIT, <br />
TWL4030_MADC_IRQ_ONESHOT, <br />
TWL4030_MADC_IRQ_REARM <br />
}; <br />
<br />
#define TWL4030_MADC_CTRL1 0x00 <br />
#define TWL4030_MADC_CTRL2 0x01 <br />
<br />
#define TWL4030_MADC_RTSELECT_LSB 0x02 <br />
#define TWL4030_MADC_SW1SELECT_LSB 0x06 <br />
#define TWL4030_MADC_SW2SELECT_LSB 0x0A <br />
<br />
#define TWL4030_MADC_RTAVERAGE_LSB 0x04 <br />
#define TWL4030_MADC_SW1AVERAGE_LSB 0x08 <br />
#define TWL4030_MADC_SW2AVERAGE_LSB 0x0C <br />
<br />
#define TWL4030_MADC_CTRL_SW1 0x12 <br />
#define TWL4030_MADC_CTRL_SW2 0x13 <br />
<br />
#define TWL4030_MADC_RTCH0_LSB 0x17 <br />
#define TWL4030_MADC_GPCH0_LSB 0x37 <br />
<br />
#define TWL4030_MADC_MADCON (1<<0) /* MADC power on */ <br />
#define TWL4030_MADC_BUSY (1<<0) /* MADC busy */ <br />
#define TWL4030_MADC_EOC_SW (1<<1) /* MADC conversion completion */ <br />
#define TWL4030_MADC_SW_START (1<<5) /* MADC SWx start conversion */ <br />
<br />
#define TWL4030_MADC_ADCIN0 (1<<0) <br />
#define TWL4030_MADC_ADCIN1 (1<<1) <br />
#define TWL4030_MADC_ADCIN2 (1<<2) <br />
#define TWL4030_MADC_ADCIN3 (1<<3) <br />
#define TWL4030_MADC_ADCIN4 (1<<4) <br />
#define TWL4030_MADC_ADCIN5 (1<<5) <br />
#define TWL4030_MADC_ADCIN6 (1<<6) <br />
#define TWL4030_MADC_ADCIN7 (1<<7) <br />
#define TWL4030_MADC_ADCIN8 (1<<8) <br />
#define TWL4030_MADC_ADCIN9 (1<<9) <br />
#define TWL4030_MADC_ADCIN10 (1<<10) <br />
#define TWL4030_MADC_ADCIN11 (1<<11) <br />
#define TWL4030_MADC_ADCIN12 (1<<12) <br />
#define TWL4030_MADC_ADCIN13 (1<<13) <br />
#define TWL4030_MADC_ADCIN14 (1<<14) <br />
#define TWL4030_MADC_ADCIN15 (1<<15) <br />
<br />
/* Fixed channels */ <br />
#define TWL4030_MADC_BTEMP TWL4030_MADC_ADCIN1 <br />
#define TWL4030_MADC_VBUS TWL4030_MADC_ADCIN8 <br />
#define TWL4030_MADC_VBKB TWL4030_MADC_ADCIN9 <br />
#define TWL4030_MADC_ICHG TWL4030_MADC_ADCIN10 <br />
#define TWL4030_MADC_VCHG TWL4030_MADC_ADCIN11 <br />
#define TWL4030_MADC_VBAT TWL4030_MADC_ADCIN12 <br />
<br />
/* BCI related - XXX To be moved elsewhere */ <br />
#define TWL4030_BCI_BCICTL1 0x23 <br />
#define TWL4030_BCI_MESBAT (1<<1) <br />
#define TWL4030_BCI_TYPEN (1<<4) <br />
#define TWL4030_BCI_ITHEN (1<<3) <br />
<br />
#define TWL4030_MADC_IOC_MAGIC '`' <br />
#define TWL4030_MADC_IOCX_ADC_RAW_READ _IO(TWL4030_MADC_IOC_MAGIC, 0) <br />
<br />
struct twl4030_madc_user_parms { <br />
int channel; <br />
int average; <br />
int status; <br />
u16 result; <br />
}; <br />
<br />
int twl4030_madc_conversion(struct twl4030_madc_request *conv); <br />
<br />
#endif<br />
</nowiki><br />
<br />
'''Main program'''<br />
<br />
<nowiki><br />
<br />
/* Test code for the MADC function<br />
*<br />
* Hugo Vincent, May 2009<br />
*/<br />
<br />
#include <sys/ioctl.h><br />
#include <sys/types.h><br />
#include <sys/stat.h><br />
#include <fcntl.h><br />
#include <stdio.h><br />
#include <stdint.h><br />
#include <string.h><br />
#include <stdlib.h><br />
#include <unistd.h><br />
#include <errno.h><br />
#include <time.h><br />
typedef uint8_t u8;<br />
typedef uint16_t u16;<br />
#include "twl4030-madc.h"<br />
<br />
/* Note: (very weird) the madc driver seems to crash if you've got driver debugging<br />
* turned on in your defconfig... */<br />
<br />
/* Channel numbering:<br />
* ADC0-1 : to do with battery charging, not relevant on Overo<br />
* ADC2-7 : general purpose, input range = 0 - 2.5V.<br />
* On Overo, ADC2 seems to read as ~0.4 and ADC7 as ~1.4V (?).<br />
* ADC8 : USB OTG port bus voltage.<br />
* ADC9-11 : more battery charging stuff, not relevant.<br />
* ADC12 : main battery voltage.<br />
* This will be the system 3.3V rail in our case<br />
* ADC13-15: reserved or not relevant.<br />
*/<br />
<br />
struct adc_channel {<br />
int number;<br />
char name[16];<br />
float input_range;<br />
};<br />
struct adc_channel channels[] = {<br />
{<br />
.number = 2,<br />
.name = "ADCIN2",<br />
.input_range = 2.5,<br />
},<br />
{<br />
.number = 3,<br />
.name = "ADCIN3",<br />
.input_range = 2.5,<br />
},<br />
{<br />
.number = 4,<br />
.name = "ADCIN4",<br />
.input_range = 2.5,<br />
},<br />
{<br />
.number = 5,<br />
.name = "ADCIN5",<br />
.input_range = 2.5,<br />
},<br />
{<br />
.number = 6,<br />
.name = "ADCIN6",<br />
.input_range = 2.5,<br />
},<br />
{<br />
.number = 7,<br />
.name = "ADCIN7",<br />
.input_range = 2.5,<br />
},<br />
{<br />
.number = 8,<br />
.name = "VBUS_USB_OTG",<br />
.input_range = 7.0,<br />
},<br />
{<br />
.number = 12,<br />
.name = "VBATT/3.3V_RAIL",<br />
.input_range = 6.0,<br />
},<br />
};<br />
<br />
int main(int argc, char **argv)<br />
{<br />
int d = open("/dev/twl4030-madc", O_RDWR | O_NONBLOCK);<br />
if (d == -1)<br />
{<br />
printf("could not open device /dev/twl4030-madc \n");<br />
EXIT_FAILURE;<br />
}<br />
<br />
struct twl4030_madc_user_parms *par;<br />
par = malloc(sizeof(struct twl4030_madc_user_parms));<br />
<br />
for (j = 0; j < (sizeof(channels)/sizeof(struct adc_channel)); j++)<br />
{<br />
memset(par, 0, sizeof(struct twl4030_madc_user_parms));<br />
par->channel = channels[j].number;<br />
int ret = ioctl(d, TWL4030_MADC_IOCX_ADC_RAW_READ, par);<br />
float result = ((unsigned int)par->result) / 1024.f; // 10 bit ADC -> 1024<br />
<br />
if (ret == 0 && par->status != -1)<br />
{<br />
printf("%s (channel %d): %f\n", channels[j].name, channels[j].number,result * channels[j].input_range);<br />
}<br />
else<br />
{<br />
if (par->status == -1)<br />
printf("Channel %d (%s) timed out!\n", j, channels[j].name);<br />
printf("ERROR\n");<br />
exit(1);<br />
}<br />
}<br />
<br />
return 0;<br />
}<br />
</nowiki><br />
<br />
<br />
<br />
compile it<br />
<br />
gcc –o madc madc.c<br />
<br />
<br />
root@overo:~# ./madc<br />
<br />
ADCIN2 (channel 2): 0.673828<br />
<br />
ADCIN3 (channel 3): 0.087891<br />
<br />
ADCIN4 (channel 4): 0.612793<br />
<br />
ADCIN5 (channel 5): 0.090332<br />
<br />
ADCIN6 (channel 6): 0.341797<br />
<br />
ADCIN7 (channel 7): 1.374512<br />
<br />
VBUS_USB_OTG (channel 8): 5.154297<br />
<br />
VBATT/3.3V_RAIL (channel 12): 3.275391<br />
<br />
root@overo:~#<br />
<br />
when using the ADCs you may/will need to scale values.<br />
<br />
Vincent, H. (2009) ADC Code Example – Help with Overo ADC. http://old.nabble.com/Re%3A-Help-with-Overo-ADC-td24174607.html <br />
<br />
TI TPS65950 Integrated Power Management/Audio Codec Data Manual http://focus.ti.com/lit/ds/symlink/tps65950.pdf<br />
<br />
TI TPS65950 OMAP Power Management and System Companion Device Version G Technical Reference Manual http://focus.ti.com/lit/ug/swcu050g/swcu050g.pdf</div>Alxxhttps://wiki.gumstix.com/index.php?title=ADC_overo_2.6.38-&diff=5657ADC overo 2.6.38-2011-09-19T07:55:56Z<p>Alxx: just to point people in the right direction</p>
<hr />
<div><br />
Use /dev/twl4030<br />
<br />
See Scott Ellis' page<br />
<br />
http://www.jumpnowtek.com/index.php?option=com_content&view=article&id=79&Itemid=91</div>Alxxhttps://wiki.gumstix.com/index.php?title=Talk:ADC_overo_2.6.39%2B&diff=5656Talk:ADC overo 2.6.39+2011-09-19T07:54:14Z<p>Alxx: Created page with "Just quickly whipped this up from posts in the mailing list. It needs tidying up. When I get some spare time(maybe november) ,I'll add some more code"</p>
<hr />
<div>Just quickly whipped this up from posts in the mailing list.<br />
<br />
It needs tidying up.<br />
When I get some spare time(maybe november) ,I'll add some more code</div>Alxxhttps://wiki.gumstix.com/index.php?title=ADC_overo_2.6.39%2B&diff=5655ADC overo 2.6.39+2011-09-19T07:52:39Z<p>Alxx: /* Using the ADC's */</p>
<hr />
<div>==Using the ADC's==<br />
From posts in the mailing list by Steve Sakoman and others<br />
<br />
In linux-omap3-2.6.39<br />
<br />
The madc driver is now upstream and in the process it moved to the hwmon subsystem.<br />
It is now even easier to access using the /sys/class interface:<br />
<br />
root@omap3-multi:~# ls /sys/class/hwmon/hwmon1/device/<br />
<br />
curr10_input in11_input in3_input in7_input power<br />
<br />
driver in12_input in4_input in8_input subsystem<br />
<br />
hwmon in15_input in5_input in9_input temp1_input<br />
<br />
in0_input in2_input in6_input modalias uevent<br />
<br />
root@omap3-multi:~# cat /sys/class/hwmon/hwmon1/device/temp1_input<br />
<br />
56<br />
<br />
root@omap3-multi:~# cat /sys/class/hwmon/hwmon1/device/curr10_input<br />
<br />
-750<br />
<br />
==ADC's via a system call==<br />
a quick and very nasty way to access them is by a system call<br />
===C===<br />
system("cat /sys/class/hwmon/hwmon1/device/in7_input");<br />
<br />
===Python===<br />
<br />
os.system("cat /sys/class/hwmon/hwmon1/device/in7_input")<br />
<br />
=== Python ===<br />
import os<br />
<br />
import sys<br />
<br />
import subprocess<br />
<br />
cmd1 = "cat /sys/class/hwmon/hwmon1/device/in7_input"<br />
<br />
process = subprocess.Popen(cmd1, stdout=subprocess.PIPE , shell=True)<br />
<br />
os.waitpid(process.pid, 0)[1]<br />
<br />
udata = process.stdout.read().strip()<br />
<br />
print udata <br />
<br />
'''In console (in interactive mode)'''<br />
<br />
python<br />
<br />
Python 2.6.6 (r266:84292, Sep 1 2011, 13:08:10)<br />
<br />
[GCC 4.3.3] on linux2<br />
<br />
>>> import os<br />
<br />
>>> import sys<br />
<br />
>>> import subprocess<br />
<br />
>>> cmd1 = "cat /sys/class/hwmon/hwmon1/device/in7_input"<br />
<br />
>>> process = subprocess.Popen(cmd1, stdout=subprocess.PIPE , shell=True)<br />
<br />
>>> os.waitpid(process.pid, 0)[1]<br />
<br />
0<br />
<br />
>>> udata = process.stdout.read().strip()<br />
<br />
>>> print udata<br />
<br />
1388<br />
<br />
>>> <br />
<br />
==<br />
<br />
==Building your own kernel ==<br />
<br />
When building your own kernel Make sure your defconfig has CONFIG_TWL4030_MADC and CONFIG_SENSORS_TWL4030_MADC<br />
and make sure your rootfs has the module.<br />
<br />
Link to kernel docs for Kernel driver twl4030-madc<br />
http://www.sakoman.com/cgi-bin/gitweb.cgi?p=linux-omap-2.6.git;a=blob;f=Documentation/hwmon/twl4030-madc-hwmon;h=ef7984317cecb29eca6ef23a30c21d920e66ef31;hb=refs/heads/omap-2.6.39-pm</div>Alxxhttps://wiki.gumstix.com/index.php?title=ADC_overo_2.6.39%2B&diff=5654ADC overo 2.6.39+2011-09-19T07:50:33Z<p>Alxx: /* ADC's via sysfs in code */</p>
<hr />
<div>==Using the ADC's==<br />
From posts in the mailing list by Steve Sakoman and others<br />
<br />
The madc driver is now upstream and in the process it moved to the hwmon subsystem.<br />
It is now even easier to access using the /sys/class interface:<br />
<br />
root@omap3-multi:~# ls /sys/class/hwmon/hwmon1/device/<br />
<br />
curr10_input in11_input in3_input in7_input power<br />
<br />
driver in12_input in4_input in8_input subsystem<br />
<br />
hwmon in15_input in5_input in9_input temp1_input<br />
<br />
in0_input in2_input in6_input modalias uevent<br />
<br />
root@omap3-multi:~# cat /sys/class/hwmon/hwmon1/device/temp1_input<br />
<br />
56<br />
<br />
root@omap3-multi:~# cat /sys/class/hwmon/hwmon1/device/curr10_input<br />
<br />
-750<br />
<br />
==ADC's via a system call==<br />
a quick and very nasty way to access them is by a system call<br />
===C===<br />
system("cat /sys/class/hwmon/hwmon1/device/in7_input");<br />
<br />
===Python===<br />
<br />
os.system("cat /sys/class/hwmon/hwmon1/device/in7_input")<br />
<br />
=== Python ===<br />
import os<br />
<br />
import sys<br />
<br />
import subprocess<br />
<br />
cmd1 = "cat /sys/class/hwmon/hwmon1/device/in7_input"<br />
<br />
process = subprocess.Popen(cmd1, stdout=subprocess.PIPE , shell=True)<br />
<br />
os.waitpid(process.pid, 0)[1]<br />
<br />
udata = process.stdout.read().strip()<br />
<br />
print udata <br />
<br />
'''In console (in interactive mode)'''<br />
<br />
python<br />
<br />
Python 2.6.6 (r266:84292, Sep 1 2011, 13:08:10)<br />
<br />
[GCC 4.3.3] on linux2<br />
<br />
>>> import os<br />
<br />
>>> import sys<br />
<br />
>>> import subprocess<br />
<br />
>>> cmd1 = "cat /sys/class/hwmon/hwmon1/device/in7_input"<br />
<br />
>>> process = subprocess.Popen(cmd1, stdout=subprocess.PIPE , shell=True)<br />
<br />
>>> os.waitpid(process.pid, 0)[1]<br />
<br />
0<br />
<br />
>>> udata = process.stdout.read().strip()<br />
<br />
>>> print udata<br />
<br />
1388<br />
<br />
>>> <br />
<br />
==<br />
<br />
==Building your own kernel ==<br />
<br />
When building your own kernel Make sure your defconfig has CONFIG_TWL4030_MADC and CONFIG_SENSORS_TWL4030_MADC<br />
and make sure your rootfs has the module.<br />
<br />
Link to kernel docs for Kernel driver twl4030-madc<br />
http://www.sakoman.com/cgi-bin/gitweb.cgi?p=linux-omap-2.6.git;a=blob;f=Documentation/hwmon/twl4030-madc-hwmon;h=ef7984317cecb29eca6ef23a30c21d920e66ef31;hb=refs/heads/omap-2.6.39-pm</div>Alxxhttps://wiki.gumstix.com/index.php?title=Category:How_to_-_adc&diff=5653Category:How to - adc2011-09-19T07:49:15Z<p>Alxx: Created page with "== overo == 1. Using the ADC's on overo kernel 2.6.39 and newer ADC_overo_2.6.39+ 2. Using the ADC's on overo kernel 2.6.38 and ealier ADC_overo_2.6.38-"</p>
<hr />
<div>== overo ==<br />
<br />
1. Using the ADC's on overo kernel 2.6.39 and newer [[ADC_overo_2.6.39+]]<br />
<br />
2. Using the ADC's on overo kernel 2.6.38 and ealier [[ADC_overo_2.6.38-]]</div>Alxxhttps://wiki.gumstix.com/index.php?title=ADC_overo_2.6.39%2B&diff=5652ADC overo 2.6.39+2011-09-19T07:48:37Z<p>Alxx: /* Using the ADC's */</p>
<hr />
<div>==Using the ADC's==<br />
From posts in the mailing list by Steve Sakoman and others<br />
<br />
The madc driver is now upstream and in the process it moved to the hwmon subsystem.<br />
It is now even easier to access using the /sys/class interface:<br />
<br />
root@omap3-multi:~# ls /sys/class/hwmon/hwmon1/device/<br />
<br />
curr10_input in11_input in3_input in7_input power<br />
<br />
driver in12_input in4_input in8_input subsystem<br />
<br />
hwmon in15_input in5_input in9_input temp1_input<br />
<br />
in0_input in2_input in6_input modalias uevent<br />
<br />
root@omap3-multi:~# cat /sys/class/hwmon/hwmon1/device/temp1_input<br />
<br />
56<br />
<br />
root@omap3-multi:~# cat /sys/class/hwmon/hwmon1/device/curr10_input<br />
<br />
-750<br />
<br />
==ADC's via a system call==<br />
a quick and very nasty way to access them is by a system call<br />
===C===<br />
system("cat /sys/class/hwmon/hwmon1/device/in7_input");<br />
<br />
===Python===<br />
<br />
os.system("cat /sys/class/hwmon/hwmon1/device/in7_input")<br />
<br />
==ADC's via sysfs in code==<br />
<br />
=== Python ===<br />
import os<br />
<br />
import sys<br />
<br />
import subprocess<br />
<br />
cmd1 = "cat /sys/class/hwmon/hwmon1/device/in7_input"<br />
<br />
process = subprocess.Popen(cmd1, stdout=subprocess.PIPE , shell=True)<br />
<br />
os.waitpid(process.pid, 0)[1]<br />
<br />
udata = process.stdout.read().strip()<br />
<br />
print udata <br />
<br />
'''In console (in interactive mode)'''<br />
<br />
python<br />
<br />
Python 2.6.6 (r266:84292, Sep 1 2011, 13:08:10)<br />
<br />
[GCC 4.3.3] on linux2<br />
<br />
>>> import os<br />
<br />
>>> import sys<br />
<br />
>>> import subprocess<br />
<br />
>>> cmd1 = "cat /sys/class/hwmon/hwmon1/device/in7_input"<br />
<br />
>>> process = subprocess.Popen(cmd1, stdout=subprocess.PIPE , shell=True)<br />
<br />
>>> os.waitpid(process.pid, 0)[1]<br />
<br />
0<br />
<br />
>>> udata = process.stdout.read().strip()<br />
<br />
>>> print udata<br />
<br />
1388<br />
<br />
>>> <br />
<br />
==<br />
<br />
<br />
==Building your own kernel ==<br />
<br />
When building your own kernel Make sure your defconfig has CONFIG_TWL4030_MADC and CONFIG_SENSORS_TWL4030_MADC<br />
and make sure your rootfs has the module.<br />
<br />
Link to kernel docs for Kernel driver twl4030-madc<br />
http://www.sakoman.com/cgi-bin/gitweb.cgi?p=linux-omap-2.6.git;a=blob;f=Documentation/hwmon/twl4030-madc-hwmon;h=ef7984317cecb29eca6ef23a30c21d920e66ef31;hb=refs/heads/omap-2.6.39-pm</div>Alxxhttps://wiki.gumstix.com/index.php?title=ADC_overo_2.6.39%2B&diff=5651ADC overo 2.6.39+2011-09-19T07:47:40Z<p>Alxx: /* Python */</p>
<hr />
<div>==Using the ADC's==<br />
From posts in the mailing list by Steve Sakoman and others<br />
<br />
The madc driver is now upstream and in the process it moved to the hwmon subsystem.<br />
It is now even easier to access using the /sys/class interface:<br />
<br />
root@omap3-multi:~# ls /sys/class/hwmon/hwmon1/device/<br />
<br />
curr10_input in11_input in3_input in7_input power<br />
driver in12_input in4_input in8_input subsystem<br />
hwmon in15_input in5_input in9_input temp1_input<br />
in0_input in2_input in6_input modalias uevent<br />
root@omap3-multi:~# cat /sys/class/hwmon/hwmon1/device/temp1_input<br />
56<br />
root@omap3-multi:~# cat /sys/class/hwmon/hwmon1/device/curr10_input<br />
-750<br />
<br />
==ADC's via a system call==<br />
a quick and very nasty way to access them is by a system call<br />
===C===<br />
system("cat /sys/class/hwmon/hwmon1/device/in7_input");<br />
<br />
===Python===<br />
<br />
os.system("cat /sys/class/hwmon/hwmon1/device/in7_input")<br />
<br />
==ADC's via sysfs in code==<br />
<br />
=== Python ===<br />
import os<br />
<br />
import sys<br />
<br />
import subprocess<br />
<br />
cmd1 = "cat /sys/class/hwmon/hwmon1/device/in7_input"<br />
<br />
process = subprocess.Popen(cmd1, stdout=subprocess.PIPE , shell=True)<br />
<br />
os.waitpid(process.pid, 0)[1]<br />
<br />
udata = process.stdout.read().strip()<br />
<br />
print udata <br />
<br />
'''In console (in interactive mode)'''<br />
<br />
python<br />
<br />
Python 2.6.6 (r266:84292, Sep 1 2011, 13:08:10)<br />
<br />
[GCC 4.3.3] on linux2<br />
<br />
>>> import os<br />
<br />
>>> import sys<br />
<br />
>>> import subprocess<br />
<br />
>>> cmd1 = "cat /sys/class/hwmon/hwmon1/device/in7_input"<br />
<br />
>>> process = subprocess.Popen(cmd1, stdout=subprocess.PIPE , shell=True)<br />
<br />
>>> os.waitpid(process.pid, 0)[1]<br />
<br />
0<br />
<br />
>>> udata = process.stdout.read().strip()<br />
<br />
>>> print udata<br />
<br />
1388<br />
<br />
>>> <br />
<br />
==<br />
<br />
<br />
==Building your own kernel ==<br />
<br />
When building your own kernel Make sure your defconfig has CONFIG_TWL4030_MADC and CONFIG_SENSORS_TWL4030_MADC<br />
and make sure your rootfs has the module.<br />
<br />
Link to kernel docs for Kernel driver twl4030-madc<br />
http://www.sakoman.com/cgi-bin/gitweb.cgi?p=linux-omap-2.6.git;a=blob;f=Documentation/hwmon/twl4030-madc-hwmon;h=ef7984317cecb29eca6ef23a30c21d920e66ef31;hb=refs/heads/omap-2.6.39-pm</div>Alxxhttps://wiki.gumstix.com/index.php?title=ADC_overo_2.6.39%2B&diff=5650ADC overo 2.6.39+2011-09-19T07:47:19Z<p>Alxx: /* Python */</p>
<hr />
<div>==Using the ADC's==<br />
From posts in the mailing list by Steve Sakoman and others<br />
<br />
The madc driver is now upstream and in the process it moved to the hwmon subsystem.<br />
It is now even easier to access using the /sys/class interface:<br />
<br />
root@omap3-multi:~# ls /sys/class/hwmon/hwmon1/device/<br />
<br />
curr10_input in11_input in3_input in7_input power<br />
driver in12_input in4_input in8_input subsystem<br />
hwmon in15_input in5_input in9_input temp1_input<br />
in0_input in2_input in6_input modalias uevent<br />
root@omap3-multi:~# cat /sys/class/hwmon/hwmon1/device/temp1_input<br />
56<br />
root@omap3-multi:~# cat /sys/class/hwmon/hwmon1/device/curr10_input<br />
-750<br />
<br />
==ADC's via a system call==<br />
a quick and very nasty way to access them is by a system call<br />
===C===<br />
system("cat /sys/class/hwmon/hwmon1/device/in7_input");<br />
<br />
===Python===<br />
<br />
os.system("cat /sys/class/hwmon/hwmon1/device/in7_input");<br />
<br />
==ADC's via sysfs in code==<br />
<br />
=== Python ===<br />
import os<br />
<br />
import sys<br />
<br />
import subprocess<br />
<br />
cmd1 = "cat /sys/class/hwmon/hwmon1/device/in7_input"<br />
<br />
process = subprocess.Popen(cmd1, stdout=subprocess.PIPE , shell=True)<br />
<br />
os.waitpid(process.pid, 0)[1]<br />
<br />
udata = process.stdout.read().strip()<br />
<br />
print udata <br />
<br />
'''In console (in interactive mode)'''<br />
<br />
python<br />
<br />
Python 2.6.6 (r266:84292, Sep 1 2011, 13:08:10)<br />
<br />
[GCC 4.3.3] on linux2<br />
<br />
>>> import os<br />
<br />
>>> import sys<br />
<br />
>>> import subprocess<br />
<br />
>>> cmd1 = "cat /sys/class/hwmon/hwmon1/device/in7_input"<br />
<br />
>>> process = subprocess.Popen(cmd1, stdout=subprocess.PIPE , shell=True)<br />
<br />
>>> os.waitpid(process.pid, 0)[1]<br />
<br />
0<br />
<br />
>>> udata = process.stdout.read().strip()<br />
<br />
>>> print udata<br />
<br />
1388<br />
<br />
>>> <br />
<br />
==<br />
<br />
<br />
==Building your own kernel ==<br />
<br />
When building your own kernel Make sure your defconfig has CONFIG_TWL4030_MADC and CONFIG_SENSORS_TWL4030_MADC<br />
and make sure your rootfs has the module.<br />
<br />
Link to kernel docs for Kernel driver twl4030-madc<br />
http://www.sakoman.com/cgi-bin/gitweb.cgi?p=linux-omap-2.6.git;a=blob;f=Documentation/hwmon/twl4030-madc-hwmon;h=ef7984317cecb29eca6ef23a30c21d920e66ef31;hb=refs/heads/omap-2.6.39-pm</div>Alxxhttps://wiki.gumstix.com/index.php?title=ADC_overo_2.6.39%2B&diff=5649ADC overo 2.6.39+2011-09-19T07:46:26Z<p>Alxx: Created page with "==Using the ADC's== From posts in the mailing list by Steve Sakoman and others The madc driver is now upstream and in the process it moved to the hwmon subsystem. It is now even..."</p>
<hr />
<div>==Using the ADC's==<br />
From posts in the mailing list by Steve Sakoman and others<br />
<br />
The madc driver is now upstream and in the process it moved to the hwmon subsystem.<br />
It is now even easier to access using the /sys/class interface:<br />
<br />
root@omap3-multi:~# ls /sys/class/hwmon/hwmon1/device/<br />
<br />
curr10_input in11_input in3_input in7_input power<br />
driver in12_input in4_input in8_input subsystem<br />
hwmon in15_input in5_input in9_input temp1_input<br />
in0_input in2_input in6_input modalias uevent<br />
root@omap3-multi:~# cat /sys/class/hwmon/hwmon1/device/temp1_input<br />
56<br />
root@omap3-multi:~# cat /sys/class/hwmon/hwmon1/device/curr10_input<br />
-750<br />
<br />
==ADC's via a system call==<br />
a quick and very nasty way to access them is by a system call<br />
===C===<br />
system("cat /sys/class/hwmon/hwmon1/device/in7_input");<br />
<br />
===Python===<br />
system("cat /sys/class/hwmon/hwmon1/device/in7_input");<br />
<br />
<br />
==ADC's via sysfs in code==<br />
<br />
=== Python ===<br />
import os<br />
<br />
import sys<br />
<br />
import subprocess<br />
<br />
cmd1 = "cat /sys/class/hwmon/hwmon1/device/in7_input"<br />
<br />
process = subprocess.Popen(cmd1, stdout=subprocess.PIPE , shell=True)<br />
<br />
os.waitpid(process.pid, 0)[1]<br />
<br />
udata = process.stdout.read().strip()<br />
<br />
print udata <br />
<br />
'''In console (in interactive mode)'''<br />
<br />
python<br />
<br />
Python 2.6.6 (r266:84292, Sep 1 2011, 13:08:10)<br />
<br />
[GCC 4.3.3] on linux2<br />
<br />
>>> import os<br />
<br />
>>> import sys<br />
<br />
>>> import subprocess<br />
<br />
>>> cmd1 = "cat /sys/class/hwmon/hwmon1/device/in7_input"<br />
<br />
>>> process = subprocess.Popen(cmd1, stdout=subprocess.PIPE , shell=True)<br />
<br />
>>> os.waitpid(process.pid, 0)[1]<br />
<br />
0<br />
<br />
>>> udata = process.stdout.read().strip()<br />
<br />
>>> print udata<br />
<br />
1388<br />
<br />
>>> <br />
<br />
==<br />
<br />
<br />
==Building your own kernel ==<br />
<br />
When building your own kernel Make sure your defconfig has CONFIG_TWL4030_MADC and CONFIG_SENSORS_TWL4030_MADC<br />
and make sure your rootfs has the module.<br />
<br />
Link to kernel docs for Kernel driver twl4030-madc<br />
http://www.sakoman.com/cgi-bin/gitweb.cgi?p=linux-omap-2.6.git;a=blob;f=Documentation/hwmon/twl4030-madc-hwmon;h=ef7984317cecb29eca6ef23a30c21d920e66ef31;hb=refs/heads/omap-2.6.39-pm</div>Alxxhttps://wiki.gumstix.com/index.php?title=Main_Page&diff=5648Main Page2011-09-19T07:24:37Z<p>Alxx: adding entry for ADC (on overo)</p>
<hr />
<div><big>''Welcome to the Gumstix User Wiki''</big> <br />
<br />
This site is provided so that users of the Gumstix OpenEmbedded build system can share their knowledge, showcase their Gumstix-based projects, and pass on links to other sources of information and materials. This information is entirely user generated and supported. Please contribute your know-how to help your fellow developers.<br />
<br />
'''Customer additions and edits are encouraged, but please read the help page before you make any major edits.'''<br />
''Note: you will need to create a new user account if you would like to contribute or edit content on this site.''<br />
<br />
Go to the [http://gumstix.org Gumstix Developer's website] for official Gumstix supported documentation on OpenEmbedded and other information of interest to developers:<br />
<br />
{|<br />
| valign="top" |<br />
{|cellpadding="2" cellspacing="5" style="vertical-align:top;background-color:#f5fffa;border:1px solid #bcc"<br />
! style="margin:0;background:#cef2e0;font-size:120%;font-weight:bold;border:1px solid #a3b0bf;text-align:left;color:#000;padding:0.2em 0.4em;" | [[:Category:How-tos |User how to's - Focus]]<br />
! style="margin:0;background:#cef2e0;font-size:120%;font-weight:bold;border:1px solid #a3b0bf;text-align:left;color:#000;padding:0.2em 0.4em;" | [[:Category:How-tos |User how to's]]<br />
! style="margin:0;background:#cef2e0;font-size:120%;font-weight:bold;border:1px solid #a3b0bf;text-align:left;color:#000;padding:0.2em 0.4em;" | [[:Category:How-tos |User how to's]]<br />
! style="margin:0;background:#cef2e0;font-size:120%;font-weight:bold;border:1px solid #a3b0bf;text-align:left;color:#000;padding:0.2em 0.4em;" | [[:Category:How-tos |User how to's]]<br />
! style="margin:0;background:#cef2e0;font-size:120%;font-weight:bold;border:1px solid #a3b0bf;text-align:left;color:#000;padding:0.2em 0.4em;" | [[:Category:How-tos |User how to's]]<br />
<br />
|-<br />
| valign="top" |<br />
* [[:Category:how to - Android|Android]]<br />
* [[:Category:how to - eclipse|Eclipse]]<br />
* [[:Category:How_to_-_Migrate_to_Gumstix|Migrate to Gumstix]]<br />
* [[Linaro]]<br />
* [[:Category:how to - Ubuntu|Ubuntu]]<br />
| valign="top" |<br />
* [[:Category:how to - audio|Audio]]<br />
* [[:Category:how to - adc|ADC]]<br />
* [[AutoLogin|Automatic Logins]]<br />
* [[:Category:how to - batteries|Batteries]]<br />
* [[:Category:how to - bluetooth|Bluetooth]]<br />
* [[:Category:Connect_hardware|Connect Hardware]]<br />
* [[Caspa_camera_boards|Caspa camera boards]]<br />
* [[:Category:how to - displays|Displays]]<br />
* [[:Category:how to - DSP|DSP]]<br />
* [[:Category:how_to_-_ethernet|Ethernet]]<br />
* [[:Category:how_to_-_expansion_boards|Expansion Boards]]<br />
* [[:Category:how to - fedora|Fedora]]<br />
* [[:Category:how to - Fast Boot|Fast Boot]]<br />
* [[:Category:how to - Fortran|Fortran]]<br />
* [[Gaining Console Connection via Terminal]]<br />
* [[:Category:how to - git|Git]]<br />
<br />
| valign="top" |<br />
* [[1-wire|1-wire]]<br />
* [[GPIO|GPIO]]<br />
* [[GPS|GPS]]<br />
* [[:Category:how to - gui|GUI]]<br />
* [[:Category:how to - general|General]]<br />
* [[:Category:how to - Build helloworld|HelloWorld]]<br />
* [[HelloWorld|HelloWorld in Python, C, C++]]<br />
* [[HelloWorld in Java|HelloWorld in Java]]<br />
* [[:Category:how to - i2c|I2C]]<br />
* [[:Category:how to - IMU|IMU]]<br />
* [[:Category:how to - JAVA|JAVA]]<br />
* [[Kernel Reconfiguration|Kernel Reconfiguration]]<br />
* [[:Category:how to - Known Issues|Known Issues]]<br />
* [[:Category:how to - LCD|LCD]]<br />
* [[:Category:how to - Low Power|Low Power]]<br />
| valign="top" |<br />
* [[:Category:how to - linux|Linux]]<br />
* [[AudioIn | Use a microphone]]<br />
* [[MicroSd |MicroSD Duplication]]<br />
* [[:Category:how to - Network_Boot|Network Boot]]<br />
* [[:Category:how to - OpenEmbedded|OpenEmbedded]]<br />
* [[:Category:how to - player|Player]]<br />
* [[:Category:How to - PWM|PWM]]<br />
* [[:Category:How_to_-_qemu|Qemu]]<br />
* [[:Category:How_to_-_Qt|Qt]]<br />
* [[:Category:how to - robotics|Robotics]]<br />
* [[ROS|ROS]]<br />
* [[RoboVero|RoboVero]]<br />
* [[:Category:how to - security|Security]]<br />
* [[:Category:SPI|SPI]]<br />
| valign="top" |<br />
* [[:Category:SUSE|SUSE]]<br />
* [[Remote Debugging with GDB|Remote Debugging with GDB]]<br />
* [[U-Boot|UBoot]]<br />
* [[:Category:how to - usb|USB]]<br />
* [[Verdex Git Repository]]<br />
* [[VerdexPro U-Boot Flashing Fix]]<br />
* [[:Category:how to - virtual machine|Virtual Machine]]<br />
* [[:Category:how to - webcams|Webcams]]<br />
* [[:Category:how to - wifi|Wifi]]<br />
<br />
|}<br />
<br />
<br />
{|<br />
| valign="top" |<br />
{|cellpadding="2" cellspacing="5" style="vertical-align:top;background-color:#f5fffa;border:1px solid #bcc"<br />
! style="margin:0;background:#cef2e0;font-size:120%;font-weight:bold;border:1px solid #a3b0bf;text-align:left;color:#000;padding:0.2em 0.4em;" | [[:Category:projects|User projects]]<br />
! style="margin:0;background:#cef2e0;font-size:120%;font-weight:bold;border:1px solid #a3b0bf;text-align:left;color:#000;padding:0.2em 0.4em;" | [[:Category:User_pics_videos|User Pics & Videos]]<br />
! style="margin:0;background:#cef2e0;font-size:120%;font-weight:bold;border:1px solid #a3b0bf;text-align:left;color:#000;padding:0.2em 0.4em;" | [[:Category:resources|Resources]]<br />
! style="margin:0;background:#cef2e0;font-size:120%;font-weight:bold;border:1px solid #a3b0bf;text-align:left;color:#000;padding:0.2em 0.4em;" | [[:Category:faqs|Questions and Answers]]<br />
<br />
|-<br />
| valign="top" |<br />
* [[:Category:projects - audio|Audio]]<br />
* [[:Category:projects - competitions|Competitions]]<br />
* [[:Category:projects - displays|Displays]]<br />
* [[:Category:projects - pdas|PDA's]]<br />
* [[:Category:Projects_-Research_and_Education|Research & Education]]<br />
* [[:Category:projects - monitoring and control|Monitoring and Control]]<br />
* [[:Category:projects - robotics|Robotics & UAV's]]<br />
| valign="top" |<br />
* [http://www.youtube.com/results?uploaded=m&search_query=gumstix&search_type=videos&suggested_categories=28&uni=3&search_sort=video_date_uploaded Gumstix on Youtube]<br />
* [http://www.flickr.com/search/?q=gumstix&s=rec Gumstix in Flickr]<br />
* [http://www.cs.umd.edu/alandaluz/nchen/ebook/dualdisp-chi.mov Dual Display device at UMD]<br />
| valign="top" |<br />
* [[Windows CE solution|Solutions for Windows CE]]<br />
* [[Qt solution|Solutions for Qt]]<br />
* [[Manufacturer's specifications|Specifications for Processors & Components]]<br />
* [[Software information]]<br />
* [[Supported hardware]]<br />
* [[Third Party Boards]]<br />
| valign="top" |<br />
Gumstix Community Mailing List (no cost)<br />
* [https://lists.sourceforge.net/lists/listinfo/gumstix-users Sign-up]<br />
* [http://old.nabble.com/Gumstix-f22543.html Archives]<br />
|}<br />
<br />
<br />
<br />
<br />
For information and support for the legacy gumstix buildroot build system:<br />
[http://docwiki.gumstix.com/Main_Page docwiki.gumstix.com]<br />
.</div>Alxxhttps://wiki.gumstix.com/index.php?title=Category:How_to_-_Fortran&diff=5614Category:How to - Fortran2011-07-14T05:37:28Z<p>Alxx: </p>
<hr />
<div>GCC contains gfortran as part of it(usually) but the library does not get pulled in.<br />
or you can install gfortran separately.<br />
<br />
To ensure its installed <br />
<br />
opkg update<br />
opkg install gfortran<br />
opkg install gfortran-symlinks<br />
opkg install libgfortran<br />
opkg install libgfortran-dev<br />
<br />
(or add the packages to your image recipe)<br />
<br />
Then write a program to test its installed<br />
<br />
vim hello.f90<br />
<br />
! hello.f90<br />
program hello<br />
implicit none<br />
print*, " "<br />
print*, "Hello World!"<br />
print*, " "<br />
end<br />
<br />
To compile<br />
<br />
user@overo:~# gfortran -o hellof hello.f90<br />
<br />
<br />
to run<br />
user@overo:~# ./hellof <br />
<br />
Hello Fortran World!<br />
<br />
user@overo:~#<br />
<br />
program to do a system call<br />
<br />
vim utime.f90<br />
<br />
<br />
! utime.f90<br />
! program to do a system call to uptime<br />
program utime<br />
implicit none<br />
character(6) :: command<br />
command = 'uptime'<br />
print*, " "<br />
call system(command)<br />
print*, " "<br />
end<br />
<br />
user@overo:~# gfortran -o utime utime.f90<br />
user@overo:~# ./utime<br />
<br />
11:06:43 up 7 days, 23:03, 2 users, load average: 0.00, 0.00, 0.00<br />
<br />
user@overo:~#</div>Alxxhttps://wiki.gumstix.com/index.php?title=Category:How_to_-_Fortran&diff=5613Category:How to - Fortran2011-07-14T05:36:22Z<p>Alxx: add an example of a system call in fortran</p>
<hr />
<div>GCC contains gfortran as part of it(usually) but the library does not get pulled in.<br />
or you can install gfortran separately.<br />
<br />
To ensure its installed (or include the packages in your image recipe)<br />
<br />
opkg update<br />
opkg install gfortran<br />
opkg install gfortran-symlinks<br />
opkg install libgfortran<br />
opkg install libgfortran-dev<br />
<br />
(or include the packages in your image recipe)<br />
<br />
Then write a program to test its installed<br />
<br />
vim hello.f90<br />
<br />
! hello.f90<br />
program hello<br />
implicit none<br />
print*, " "<br />
print*, "Hello World!"<br />
print*, " "<br />
end<br />
<br />
To compile<br />
<br />
user@overo:~# gfortran -o hellof hello.f90<br />
<br />
<br />
to run<br />
user@overo:~# ./hellof <br />
<br />
Hello Fortran World!<br />
<br />
user@overo:~#<br />
<br />
program to do a system call<br />
<br />
vim utime.f90<br />
<br />
<br />
! utime.f90<br />
! program to do a system call to uptime<br />
program utime<br />
implicit none<br />
character(6) :: command<br />
command = 'uptime'<br />
print*, " "<br />
call system(command)<br />
print*, " "<br />
end<br />
<br />
user@overo:~# gfortran -o utime utime.f90<br />
user@overo:~# ./utime<br />
<br />
11:06:43 up 7 days, 23:03, 2 users, load average: 0.00, 0.00, 0.00<br />
<br />
user@overo:~#</div>Alxxhttps://wiki.gumstix.com/index.php?title=Category:How_to_-_Fortran&diff=5612Category:How to - Fortran2011-07-14T05:29:31Z<p>Alxx: Created page with "GCC contains gfortran as part of it(usually) but the library does not get pulled in. or you can install gfortran separately. To ensure its installed (or include the packages in ..."</p>
<hr />
<div>GCC contains gfortran as part of it(usually) but the library does not get pulled in.<br />
or you can install gfortran separately.<br />
<br />
To ensure its installed (or include the packages in your image recipe)<br />
<br />
opkg update<br />
opkg install gfortran<br />
opkg install gfortran-symlinks<br />
opkg install libgfortran<br />
opkg install libgfortran-dev<br />
<br />
Then<br />
<br />
vim hello.f90<br />
<br />
! hello.f90<br />
program hello<br />
implicit none<br />
print*, " "<br />
print*, "Hello World!"<br />
print*, " "<br />
end<br />
<br />
To compile<br />
<br />
user@overo:~# gfortran -o hellof hello.f90<br />
<br />
<br />
to run<br />
user@overo:~# ./hellof <br />
<br />
Hello Fortran World!<br />
<br />
user@overo:~#</div>Alxxhttps://wiki.gumstix.com/index.php?title=Main_Page&diff=5611Main Page2011-07-14T05:11:01Z<p>Alxx: add Fortran</p>
<hr />
<div><big>''Welcome to the Gumstix User Wiki''</big> <br />
<br />
This site is provided so that users of the Gumstix OpenEmbedded build system can share their knowledge, showcase their Gumstix-based projects, and pass on links to other sources of information and materials. This information is entirely user generated and supported. Please contribute your know-how to help your fellow developers.<br />
<br />
'''Customer additions and edits are encouraged, but please read the help page before you make any major edits.'''<br />
''Note: you will need to create a new user account if you would like to contribute or edit content on this site.''<br />
<br />
Go to the [http://gumstix.org Gumstix Developer's website] for official Gumstix supported documentation on OpenEmbedded and other information of interest to developers:<br />
<br />
{|<br />
| valign="top" |<br />
{|cellpadding="2" cellspacing="5" style="vertical-align:top;background-color:#f5fffa;border:1px solid #bcc"<br />
! style="margin:0;background:#cef2e0;font-size:120%;font-weight:bold;border:1px solid #a3b0bf;text-align:left;color:#000;padding:0.2em 0.4em;" | [[:Category:How-tos |User how to's - Focus]]<br />
! style="margin:0;background:#cef2e0;font-size:120%;font-weight:bold;border:1px solid #a3b0bf;text-align:left;color:#000;padding:0.2em 0.4em;" | [[:Category:How-tos |User how to's]]<br />
! style="margin:0;background:#cef2e0;font-size:120%;font-weight:bold;border:1px solid #a3b0bf;text-align:left;color:#000;padding:0.2em 0.4em;" | [[:Category:How-tos |User how to's]]<br />
! style="margin:0;background:#cef2e0;font-size:120%;font-weight:bold;border:1px solid #a3b0bf;text-align:left;color:#000;padding:0.2em 0.4em;" | [[:Category:How-tos |User how to's]]<br />
! style="margin:0;background:#cef2e0;font-size:120%;font-weight:bold;border:1px solid #a3b0bf;text-align:left;color:#000;padding:0.2em 0.4em;" | [[:Category:How-tos |User how to's]]<br />
<br />
|-<br />
| valign="top" |<br />
* [[:Category:how to - Android|Android]]<br />
* [[:Category:how to - eclipse|Eclipse]]<br />
* [[:Category:How_to_-_Migrate_to_Gumstix|Migrate to Gumstix]]<br />
* [[Linaro]]<br />
* [[:Category:how to - Ubuntu|Ubuntu]]<br />
| valign="top" |<br />
* [[:Category:how to - audio|Audio]]<br />
* [[AutoLogin|Automatic Logins]]<br />
* [[:Category:how to - batteries|Batteries]]<br />
* [[:Category:how to - bluetooth|Bluetooth]]<br />
* [[:Category:Connect_hardware|Connect Hardware]]<br />
* [[Caspa_camera_boards|Caspa camera boards]]<br />
* [[:Category:how to - displays|Displays]]<br />
* [[:Category:how to - DSP|DSP]]<br />
* [[:Category:how_to_-_ethernet|Ethernet]]<br />
* [[:Category:how_to_-_expansion_boards|Expansion Boards]]<br />
* [[:Category:how to - fedora|Fedora]]<br />
* [[:Category:how to - Fast Boot|Fast Boot]]<br />
* [[:Category:how to - Fortran|Fortran]]<br />
* [[Gaining Console Connection via Terminal]]<br />
* [[:Category:how to - git|Git]]<br />
<br />
| valign="top" |<br />
* [[GPIO|GPIO]]<br />
* [[GPS|GPS]]<br />
* [[:Category:how to - gui|GUI]]<br />
* [[:Category:how to - general|General]]<br />
* [[:Category:how to - Build helloworld|HelloWorld]]<br />
* [[HelloWorld|HelloWorld in Python, C, C++]]<br />
* [[HelloWorld in Java|HelloWorld in Java]]<br />
* [[:Category:how to - i2c|I2C]]<br />
* [[:Category:how to - IMU|IMU]]<br />
* [[:Category:how to - JAVA|JAVA]]<br />
* [[Kernel Reconfiguration|Kernel Reconfiguration]]<br />
* [[:Category:how to - Known Issues|Known Issues]]<br />
* [[:Category:how to - LCD|LCD]]<br />
* [[:Category:how to - Low Power|Low Power]]<br />
| valign="top" |<br />
* [[:Category:how to - linux|Linux]]<br />
* [[AudioIn | Use a microphone]]<br />
* [[MicroSd |MicroSD Duplication]]<br />
* [[:Category:how to - Network_Boot|Network Boot]]<br />
* [[:Category:how to - OpenEmbedded|OpenEmbedded]]<br />
* [[:Category:how to - player|Player]]<br />
* [[:Category:How to - PWM|PWM]]<br />
* [[:Category:How_to_-_qemu|Qemu]]<br />
* [[:Category:How_to_-_Qt|Qt]]<br />
* [[:Category:how to - robotics|Robotics]]<br />
* [[RoboVero|RoboVero]]<br />
* [[:Category:how to - security|Security]]<br />
* [[:Category:SPI|SPI]]<br />
| valign="top" |<br />
* [[:Category:SUSE|SUSE]]<br />
* [[Remote Debugging with GDB|Remote Debugging with GDB]]<br />
* [[U-Boot|UBoot]]<br />
* [[:Category:how to - usb|USB]]<br />
* [[Verdex Git Repository]]<br />
* [[VerdexPro U-Boot Flashing Fix]]<br />
* [[:Category:how to - virtual machine|Virtual Machine]]<br />
* [[:Category:how to - webcams|Webcams]]<br />
* [[:Category:how to - wifi|Wifi]]<br />
<br />
|}<br />
<br />
<br />
{|<br />
| valign="top" |<br />
{|cellpadding="2" cellspacing="5" style="vertical-align:top;background-color:#f5fffa;border:1px solid #bcc"<br />
! style="margin:0;background:#cef2e0;font-size:120%;font-weight:bold;border:1px solid #a3b0bf;text-align:left;color:#000;padding:0.2em 0.4em;" | [[:Category:projects|User projects]]<br />
! style="margin:0;background:#cef2e0;font-size:120%;font-weight:bold;border:1px solid #a3b0bf;text-align:left;color:#000;padding:0.2em 0.4em;" | [[:Category:User_pics_videos|User Pics & Videos]]<br />
! style="margin:0;background:#cef2e0;font-size:120%;font-weight:bold;border:1px solid #a3b0bf;text-align:left;color:#000;padding:0.2em 0.4em;" | [[:Category:resources|Resources]]<br />
! style="margin:0;background:#cef2e0;font-size:120%;font-weight:bold;border:1px solid #a3b0bf;text-align:left;color:#000;padding:0.2em 0.4em;" | [[:Category:faqs|Questions and Answers]]<br />
<br />
|-<br />
| valign="top" |<br />
* [[:Category:projects - audio|Audio]]<br />
* [[:Category:projects - competitions|Competitions]]<br />
* [[:Category:projects - displays|Displays]]<br />
* [[:Category:projects - pdas|PDA's]]<br />
* [[:Category:Projects_-Research_and_Education|Research & Education]]<br />
* [[:Category:projects - monitoring and control|Monitoring and Control]]<br />
* [[:Category:projects - robotics|Robotics & UAV's]]<br />
| valign="top" |<br />
* [http://www.youtube.com/results?uploaded=m&search_query=gumstix&search_type=videos&suggested_categories=28&uni=3&search_sort=video_date_uploaded Gumstix on Youtube]<br />
* [http://www.flickr.com/search/?q=gumstix&s=rec Gumstix in Flickr]<br />
* [http://www.cs.umd.edu/alandaluz/nchen/ebook/dualdisp-chi.mov Dual Display device at UMD]<br />
| valign="top" |<br />
* [[Windows CE solution|Solutions for Windows CE]]<br />
* [[Qt solution|Solutions for Qt]]<br />
* [[Manufacturer's specifications|Specifications for Processors & Components]]<br />
* [[Software information]]<br />
* [[Supported hardware]]<br />
* [[Third Party Boards]]<br />
| valign="top" |<br />
Gumstix Community Mailing List (no cost)<br />
* [https://lists.sourceforge.net/lists/listinfo/gumstix-users Sign-up]<br />
* [http://old.nabble.com/Gumstix-f22543.html Archives]<br />
|}<br />
<br />
<br />
<br />
<br />
For information and support for the legacy gumstix buildroot build system:<br />
[http://docwiki.gumstix.com/Main_Page docwiki.gumstix.com]<br />
.</div>Alxxhttps://wiki.gumstix.com/index.php?title=Onboard_Java_Compiler&diff=5373Onboard Java Compiler2011-04-10T12:09:52Z<p>Alxx: /* Compile HelloWorld */</p>
<hr />
<div>To install a java vm , a compiler and runtime library.<br />
<br />
<br />
== Pre-requisites == <br />
<br />
Need to have these packages installed<br />
<br />
task-native-sdk<br />
<br />
opkg install task-native-sdk<br />
<br />
== Installation ==<br />
As root or using sudo on a running gumstix with internet access.<br />
<br />
If you don't have internet access on your gumstix, you can download the packages and copy them to the gumstix via usb drive.<br />
May take a few goes to get all the dependencies. <br />
<br />
first add angstrom repo<br />
echo 'src/gz angstrom-base http://www.angstrom-distribution.org/feeds/unstable/ipk/glibc/armv7a/base'<br />
> /etc/opkg/angstrom-base.conf<br />
<br />
===Install class path===<br />
opkg install classpath<br />
opkg install classpath-dev <br />
<br />
If you need the graphical classes<br />
opkg install classpath-gtk<br />
<br />
If you are using graphical classes/gui remember to export the display<br />
export DISPLAY=:0.0<br />
<br />
===Install cacao vm===<br />
opkg install cacao<br />
<br />
===Install jikes java compiler===<br />
opkg install jikes<br />
<br />
== Install phoneme jvm ==<br />
If you need a java vm with debuging or remote debugging support or wish to use the phoneme jvm<br />
wget http://bugcommunity.com/downloads/files/phoneme-advanced-personal-debug_mr2-r1_armv6.ipk<br />
opkg install -force-depends phoneme-advanced-personal-debug_mr2-r1_armv6.ipk<br />
<br />
<br />
Once you have installed it add cvm to your path or create a symbolic link<br />
cvm is in /usr/lib/jvm/phoneme-advanced-personal-debug/bin <br />
<br />
sudo ln -s /usr/lib/jvm/phoneme-advanced-personal-debug/bin/cvm /usr/bin/cvm<br />
<br />
== Set the classpath for Jikes ==<br />
<br />
Set the bootclass path so jikes can find the classes<br />
export BOOTCLASSPATH=/usr/share/cacao/vm.zip:/usr/share/classpath/glibj.zip<br />
<br />
== Testing the install ==<br />
Once everything is installed and you are ready to run.<br />
<br />
=== Check the versions ===<br />
Check the versions and that the jvm's run.<br />
<br />
First cacao<br />
alxx@omap1:~$ java -version<br />
java version "1.5.0"<br />
CACAO version 0.99.4<br />
Copyright (C) 1996-2005, 2006, 2007, 2008<br />
CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO<br />
This is free software; see the source for copying conditions. There is NO<br />
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.<br />
<br />
alxx@omap1:~$ java -fullversion<br />
java full version "cacao-1.5.0"<br />
or<br />
alxx@omap1:~$ cacao -fullversion<br />
java full version "cacao-1.5.0"<br />
alxx@omap1:~$ <br />
<br />
Then phoneme<br />
alxx@omap1:~$ java-cdc -version<br />
Product: phoneME Advanced (phoneme_advanced_mr2-b97)<br />
Profile: Personal Profile Specification 1.1<br />
JVM: CVM phoneme_advanced_mr2-b97 (mixed mode)<br />
alxx@omap1:~$ <br />
or<br />
alxx@omap1:~$ cvm -version<br />
Product: phoneME Advanced (phoneme_advanced_mr2-b97)<br />
Profile: Personal Profile Specification 1.1<br />
JVM: CVM phoneme_advanced_mr2-b97 (mixed mode)<br />
alxx@omap1:~$<br />
<br />
=== Compile HelloWorld ===<br />
<br />
Then with the standard java hello world<br />
vim Hello.java<br />
<br />
/* Hello.java */<br />
public class Hello<br />
{<br />
public static void main(String[] args)<br />
{<br />
System.out.println("Hello world!");<br />
}<br />
}<br />
<br />
Save then compile<br />
alxx@omap1:~$ jikes Hello.java<br />
alxx@omap1:~$ ls<br />
Hello.class Hello.java<br />
<br />
=== Run it using cacao ===<br />
alxx@omap1:~$ java Hello<br />
Hello world!<br />
alxx@omap1:~$<br />
or<br />
alxx@omap1:~$ cacao Hello<br />
Hello world!<br />
alxx@omap1:~$<br />
<br />
<br />
=== Run it using phoneme ===<br />
alxx@omap1:~$ java-cdc Hello<br />
Hello world!<br />
alxx@omap1:~$<br />
or<br />
alxx@omap1:~$ cvm Hello<br />
Hello world!<br />
alxx@omap1:~$<br />
<br />
Test phoneme using its provided testclasses.zip<br />
alxx@omap1:~$cvm -cp /usr/lib/jvm/phoneme-advanced-personal-debug/testclasses.zip HelloWorld<br />
Hello world.<br />
alxx@omap1:~$<br />
<br />
<br />
phoneme with some extra files can be used to run javascript , jython and servlets<br />
see http://www.nslu2-linux.org/wiki/HowTo/UseJavaOnTheSlug</div>Alxxhttps://wiki.gumstix.com/index.php?title=Onboard_Java_Compiler&diff=5372Onboard Java Compiler2011-04-10T12:03:20Z<p>Alxx: /* Installation */</p>
<hr />
<div>To install a java vm , a compiler and runtime library.<br />
<br />
<br />
== Pre-requisites == <br />
<br />
Need to have these packages installed<br />
<br />
task-native-sdk<br />
<br />
opkg install task-native-sdk<br />
<br />
== Installation ==<br />
As root or using sudo on a running gumstix with internet access.<br />
<br />
If you don't have internet access on your gumstix, you can download the packages and copy them to the gumstix via usb drive.<br />
May take a few goes to get all the dependencies. <br />
<br />
first add angstrom repo<br />
echo 'src/gz angstrom-base http://www.angstrom-distribution.org/feeds/unstable/ipk/glibc/armv7a/base'<br />
> /etc/opkg/angstrom-base.conf<br />
<br />
===Install class path===<br />
opkg install classpath<br />
opkg install classpath-dev <br />
<br />
If you need the graphical classes<br />
opkg install classpath-gtk<br />
<br />
If you are using graphical classes/gui remember to export the display<br />
export DISPLAY=:0.0<br />
<br />
===Install cacao vm===<br />
opkg install cacao<br />
<br />
===Install jikes java compiler===<br />
opkg install jikes<br />
<br />
== Install phoneme jvm ==<br />
If you need a java vm with debuging or remote debugging support or wish to use the phoneme jvm<br />
wget http://bugcommunity.com/downloads/files/phoneme-advanced-personal-debug_mr2-r1_armv6.ipk<br />
opkg install -force-depends phoneme-advanced-personal-debug_mr2-r1_armv6.ipk<br />
<br />
<br />
Once you have installed it add cvm to your path or create a symbolic link<br />
cvm is in /usr/lib/jvm/phoneme-advanced-personal-debug/bin <br />
<br />
sudo ln -s /usr/lib/jvm/phoneme-advanced-personal-debug/bin/cvm /usr/bin/cvm<br />
<br />
== Set the classpath for Jikes ==<br />
<br />
Set the bootclass path so jikes can find the classes<br />
export BOOTCLASSPATH=/usr/share/cacao/vm.zip:/usr/share/classpath/glibj.zip<br />
<br />
== Testing the install ==<br />
Once everything is installed and you are ready to run.<br />
<br />
=== Check the versions ===<br />
Check the versions and that the jvm's run.<br />
<br />
First cacao<br />
alxx@omap1:~$ java -version<br />
java version "1.5.0"<br />
CACAO version 0.99.4<br />
Copyright (C) 1996-2005, 2006, 2007, 2008<br />
CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO<br />
This is free software; see the source for copying conditions. There is NO<br />
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.<br />
<br />
alxx@omap1:~$ java -fullversion<br />
java full version "cacao-1.5.0"<br />
or<br />
alxx@omap1:~$ cacao -fullversion<br />
java full version "cacao-1.5.0"<br />
alxx@omap1:~$ <br />
<br />
Then phoneme<br />
alxx@omap1:~$ java-cdc -version<br />
Product: phoneME Advanced (phoneme_advanced_mr2-b97)<br />
Profile: Personal Profile Specification 1.1<br />
JVM: CVM phoneme_advanced_mr2-b97 (mixed mode)<br />
alxx@omap1:~$ <br />
or<br />
alxx@omap1:~$ cvm -version<br />
Product: phoneME Advanced (phoneme_advanced_mr2-b97)<br />
Profile: Personal Profile Specification 1.1<br />
JVM: CVM phoneme_advanced_mr2-b97 (mixed mode)<br />
alxx@omap1:~$<br />
<br />
=== Compile HelloWorld ===<br />
<br />
Then with the standard java hello world<br />
vim Hello.java<br />
/* Hello.java */<br />
<br />
public class Hello<br />
{<br />
public static void main(String[] args)<br />
{<br />
System.out.println("Hello world!");<br />
}<br />
}<br />
<br />
Save then compile<br />
alxx@omap1:~$ jikes Hello.java<br />
alxx@omap1:~$ ls<br />
Hello.class Hello.java<br />
<br />
=== Run it using cacao ===<br />
alxx@omap1:~$ java Hello<br />
Hello world!<br />
alxx@omap1:~$<br />
or<br />
alxx@omap1:~$ cacao Hello<br />
Hello world!<br />
alxx@omap1:~$<br />
<br />
<br />
=== Run it using phoneme ===<br />
alxx@omap1:~$ java-cdc Hello<br />
Hello world!<br />
alxx@omap1:~$<br />
or<br />
alxx@omap1:~$ cvm Hello<br />
Hello world!<br />
alxx@omap1:~$<br />
<br />
Test phoneme using its provided testclasses.zip<br />
alxx@omap1:~$cvm -cp /usr/lib/jvm/phoneme-advanced-personal-debug/testclasses.zip HelloWorld<br />
Hello world.<br />
alxx@omap1:~$<br />
<br />
<br />
phoneme with some extra files can be used to run javascript , jython and servlets<br />
see http://www.nslu2-linux.org/wiki/HowTo/UseJavaOnTheSlug</div>Alxxhttps://wiki.gumstix.com/index.php?title=Category:How_to_-_JAVA&diff=5371Category:How to - JAVA2011-04-10T12:01:29Z<p>Alxx: </p>
<hr />
<div>1. [http://code.google.com/p/netbeams/wiki/GumstixOESystem This link] has instructions for installing classpath and JamVM.<br />
The instructions are based on outdated version numbers. Just substitute the current OE versions.<br />
<br />
2. A Gumstix customer has successfully built both Cacoa and JamVM on the Overo board using the instructions [http://wiki.openembedded.net/index.php/Java here].<br />
<br />
3. Onboard java compiler [[Onboard_Java_Compiler]]</div>Alxxhttps://wiki.gumstix.com/index.php?title=Onboard_Java_Compiler&diff=5370Onboard Java Compiler2011-04-10T11:57:10Z<p>Alxx: /* Run the program */</p>
<hr />
<div>To install a java vm , a compiler and runtime library.<br />
<br />
<br />
== Pre-requisites == <br />
<br />
Need to have these packages installed<br />
<br />
task-native-sdk<br />
<br />
opkg install task-native-sdk<br />
<br />
== Installation ==<br />
As root on a running gumstix with internet access.<br />
<br />
If you don't have internet access on your gumstix, you can download the packages and copy them to the gumstix via usb drive.<br />
May take a few goes to get all the dependencies. <br />
<br />
first add angstrom repo<br />
echo 'src/gz angstrom-base http://www.angstrom-distribution.org/feeds/unstable/ipk/glibc/armv7a/base'<br />
> /etc/opkg/angstrom-base.conf<br />
<br />
Install class path<br />
opkg install classpath<br />
opkg install classpath-dev <br />
<br />
If you need the graphical classes<br />
opkg install classpath-gtk<br />
<br />
If you are using graphical classes/gui remember to export the display<br />
export DISPLAY=:0.0<br />
<br />
Install cacao vm<br />
opkg install cacao<br />
<br />
Install jikes java compiler<br />
opkg install jikes<br />
<br />
== Install phoneme jvm ==<br />
If you need a java vm with debuging or remote debugging support or wish to use the phoneme jvm<br />
wget http://bugcommunity.com/downloads/files/phoneme-advanced-personal-debug_mr2-r1_armv6.ipk<br />
opkg install -force-depends phoneme-advanced-personal-debug_mr2-r1_armv6.ipk<br />
<br />
<br />
Once you have installed it add cvm to your path or create a symbolic link<br />
cvm is in /usr/lib/jvm/phoneme-advanced-personal-debug/bin <br />
<br />
sudo ln -s /usr/lib/jvm/phoneme-advanced-personal-debug/bin/cvm /usr/bin/cvm<br />
<br />
== Set the classpath for Jikes ==<br />
<br />
Set the bootclass path so jikes can find the classes<br />
export BOOTCLASSPATH=/usr/share/cacao/vm.zip:/usr/share/classpath/glibj.zip<br />
<br />
== Testing the install ==<br />
Once everything is installed and you are ready to run.<br />
<br />
=== Check the versions ===<br />
Check the versions and that the jvm's run.<br />
<br />
First cacao<br />
alxx@omap1:~$ java -version<br />
java version "1.5.0"<br />
CACAO version 0.99.4<br />
Copyright (C) 1996-2005, 2006, 2007, 2008<br />
CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO<br />
This is free software; see the source for copying conditions. There is NO<br />
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.<br />
<br />
alxx@omap1:~$ java -fullversion<br />
java full version "cacao-1.5.0"<br />
or<br />
alxx@omap1:~$ cacao -fullversion<br />
java full version "cacao-1.5.0"<br />
alxx@omap1:~$ <br />
<br />
Then phoneme<br />
alxx@omap1:~$ java-cdc -version<br />
Product: phoneME Advanced (phoneme_advanced_mr2-b97)<br />
Profile: Personal Profile Specification 1.1<br />
JVM: CVM phoneme_advanced_mr2-b97 (mixed mode)<br />
alxx@omap1:~$ <br />
or<br />
alxx@omap1:~$ cvm -version<br />
Product: phoneME Advanced (phoneme_advanced_mr2-b97)<br />
Profile: Personal Profile Specification 1.1<br />
JVM: CVM phoneme_advanced_mr2-b97 (mixed mode)<br />
alxx@omap1:~$<br />
<br />
=== Compile HelloWorld ===<br />
<br />
Then with the standard java hello world<br />
vim Hello.java<br />
/* Hello.java */<br />
<br />
public class Hello<br />
{<br />
public static void main(String[] args)<br />
{<br />
System.out.println("Hello world!");<br />
}<br />
}<br />
<br />
Save then compile<br />
alxx@omap1:~$ jikes Hello.java<br />
alxx@omap1:~$ ls<br />
Hello.class Hello.java<br />
<br />
=== Run it using cacao ===<br />
alxx@omap1:~$ java Hello<br />
Hello world!<br />
alxx@omap1:~$<br />
or<br />
alxx@omap1:~$ cacao Hello<br />
Hello world!<br />
alxx@omap1:~$<br />
<br />
<br />
=== Run it using phoneme ===<br />
alxx@omap1:~$ java-cdc Hello<br />
Hello world!<br />
alxx@omap1:~$<br />
or<br />
alxx@omap1:~$ cvm Hello<br />
Hello world!<br />
alxx@omap1:~$<br />
<br />
Test phoneme using its provided testclasses.zip<br />
alxx@omap1:~$cvm -cp /usr/lib/jvm/phoneme-advanced-personal-debug/testclasses.zip HelloWorld<br />
Hello world.<br />
alxx@omap1:~$<br />
<br />
<br />
phoneme with some extra files can be used to run javascript , jython and servlets<br />
see http://www.nslu2-linux.org/wiki/HowTo/UseJavaOnTheSlug</div>Alxxhttps://wiki.gumstix.com/index.php?title=Onboard_Java_Compiler&diff=5369Onboard Java Compiler2011-04-10T11:54:23Z<p>Alxx: /* Install phoneme jvm */</p>
<hr />
<div>To install a java vm , a compiler and runtime library.<br />
<br />
<br />
== Pre-requisites == <br />
<br />
Need to have these packages installed<br />
<br />
task-native-sdk<br />
<br />
opkg install task-native-sdk<br />
<br />
== Installation ==<br />
As root on a running gumstix with internet access.<br />
<br />
If you don't have internet access on your gumstix, you can download the packages and copy them to the gumstix via usb drive.<br />
May take a few goes to get all the dependencies. <br />
<br />
first add angstrom repo<br />
echo 'src/gz angstrom-base http://www.angstrom-distribution.org/feeds/unstable/ipk/glibc/armv7a/base'<br />
> /etc/opkg/angstrom-base.conf<br />
<br />
Install class path<br />
opkg install classpath<br />
opkg install classpath-dev <br />
<br />
If you need the graphical classes<br />
opkg install classpath-gtk<br />
<br />
If you are using graphical classes/gui remember to export the display<br />
export DISPLAY=:0.0<br />
<br />
Install cacao vm<br />
opkg install cacao<br />
<br />
Install jikes java compiler<br />
opkg install jikes<br />
<br />
== Install phoneme jvm ==<br />
If you need a java vm with debuging or remote debugging support or wish to use the phoneme jvm<br />
wget http://bugcommunity.com/downloads/files/phoneme-advanced-personal-debug_mr2-r1_armv6.ipk<br />
opkg install -force-depends phoneme-advanced-personal-debug_mr2-r1_armv6.ipk<br />
<br />
<br />
Once you have installed it add cvm to your path or create a symbolic link<br />
cvm is in /usr/lib/jvm/phoneme-advanced-personal-debug/bin <br />
<br />
sudo ln -s /usr/lib/jvm/phoneme-advanced-personal-debug/bin/cvm /usr/bin/cvm<br />
<br />
== Set the classpath for Jikes ==<br />
<br />
Set the bootclass path so jikes can find the classes<br />
export BOOTCLASSPATH=/usr/share/cacao/vm.zip:/usr/share/classpath/glibj.zip<br />
<br />
== Testing the install ==<br />
Once everything is installed and you are ready to run.<br />
<br />
=== Check the versions ===<br />
Check the versions and that the jvm's run.<br />
<br />
First cacao<br />
alxx@omap1:~$ java -version<br />
java version "1.5.0"<br />
CACAO version 0.99.4<br />
Copyright (C) 1996-2005, 2006, 2007, 2008<br />
CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO<br />
This is free software; see the source for copying conditions. There is NO<br />
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.<br />
<br />
alxx@omap1:~$ java -fullversion<br />
java full version "cacao-1.5.0"<br />
or<br />
alxx@omap1:~$ cacao -fullversion<br />
java full version "cacao-1.5.0"<br />
alxx@omap1:~$ <br />
<br />
Then phoneme<br />
alxx@omap1:~$ java-cdc -version<br />
Product: phoneME Advanced (phoneme_advanced_mr2-b97)<br />
Profile: Personal Profile Specification 1.1<br />
JVM: CVM phoneme_advanced_mr2-b97 (mixed mode)<br />
alxx@omap1:~$ <br />
or<br />
alxx@omap1:~$ cvm -version<br />
Product: phoneME Advanced (phoneme_advanced_mr2-b97)<br />
Profile: Personal Profile Specification 1.1<br />
JVM: CVM phoneme_advanced_mr2-b97 (mixed mode)<br />
alxx@omap1:~$<br />
<br />
=== Compile HelloWorld ===<br />
<br />
Then with the standard java hello world<br />
vim Hello.java<br />
/* Hello.java */<br />
<br />
public class Hello<br />
{<br />
public static void main(String[] args)<br />
{<br />
System.out.println("Hello world!");<br />
}<br />
}<br />
<br />
Save then compile<br />
alxx@omap1:~$ jikes Hello.java<br />
alxx@omap1:~$ ls<br />
Hello.class Hello.java<br />
<br />
=== Run the program ===<br />
<br />
Run it using cacao<br />
alxx@omap1:~$ java Hello<br />
Hello world!<br />
alxx@omap1:~$<br />
or<br />
alxx@omap1:~$ cacao Hello<br />
Hello world!<br />
alxx@omap1:~$<br />
<br />
<br />
Run it using phoneme<br />
alxx@omap1:~$ java-cdc Hello<br />
Hello world!<br />
alxx@omap1:~$<br />
or<br />
alxx@omap1:~$ cvm Hello<br />
Hello world!<br />
alxx@omap1:~$<br />
<br />
Test phoneme using its provided testclasses.zip<br />
alxx@omap1:~$cvm -cp /usr/lib/jvm/phoneme-advanced-personal-debug/testclasses.zip HelloWorld<br />
Hello world.<br />
alxx@omap1:~$<br />
<br />
<br />
phoneme with some extra files can be used to run javascript , jython and servlets<br />
see http://www.nslu2-linux.org/wiki/HowTo/UseJavaOnTheSlug</div>Alxxhttps://wiki.gumstix.com/index.php?title=Onboard_Java_Compiler&diff=5368Onboard Java Compiler2011-04-10T11:53:43Z<p>Alxx: /* Installation */</p>
<hr />
<div>To install a java vm , a compiler and runtime library.<br />
<br />
<br />
== Pre-requisites == <br />
<br />
Need to have these packages installed<br />
<br />
task-native-sdk<br />
<br />
opkg install task-native-sdk<br />
<br />
== Installation ==<br />
As root on a running gumstix with internet access.<br />
<br />
If you don't have internet access on your gumstix, you can download the packages and copy them to the gumstix via usb drive.<br />
May take a few goes to get all the dependencies. <br />
<br />
first add angstrom repo<br />
echo 'src/gz angstrom-base http://www.angstrom-distribution.org/feeds/unstable/ipk/glibc/armv7a/base'<br />
> /etc/opkg/angstrom-base.conf<br />
<br />
Install class path<br />
opkg install classpath<br />
opkg install classpath-dev <br />
<br />
If you need the graphical classes<br />
opkg install classpath-gtk<br />
<br />
If you are using graphical classes/gui remember to export the display<br />
export DISPLAY=:0.0<br />
<br />
Install cacao vm<br />
opkg install cacao<br />
<br />
Install jikes java compiler<br />
opkg install jikes<br />
<br />
=== Install phoneme jvm ===<br />
If you need a java vm with debuging or remote debugging support or wish to use the phoneme jvm<br />
wget http://bugcommunity.com/downloads/files/phoneme-advanced-personal-debug_mr2-r1_armv6.ipk<br />
opkg install -force-depends phoneme-advanced-personal-debug_mr2-r1_armv6.ipk<br />
<br />
<br />
Once you have installed it add cvm to your path or create a symbolic link<br />
cvm is in /usr/lib/jvm/phoneme-advanced-personal-debug/bin <br />
<br />
sudo ln -s /usr/lib/jvm/phoneme-advanced-personal-debug/bin/cvm /usr/bin/cvm<br />
<br />
== Set the classpath for Jikes ==<br />
<br />
Set the bootclass path so jikes can find the classes<br />
export BOOTCLASSPATH=/usr/share/cacao/vm.zip:/usr/share/classpath/glibj.zip<br />
<br />
== Testing the install ==<br />
Once everything is installed and you are ready to run.<br />
<br />
=== Check the versions ===<br />
Check the versions and that the jvm's run.<br />
<br />
First cacao<br />
alxx@omap1:~$ java -version<br />
java version "1.5.0"<br />
CACAO version 0.99.4<br />
Copyright (C) 1996-2005, 2006, 2007, 2008<br />
CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO<br />
This is free software; see the source for copying conditions. There is NO<br />
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.<br />
<br />
alxx@omap1:~$ java -fullversion<br />
java full version "cacao-1.5.0"<br />
or<br />
alxx@omap1:~$ cacao -fullversion<br />
java full version "cacao-1.5.0"<br />
alxx@omap1:~$ <br />
<br />
Then phoneme<br />
alxx@omap1:~$ java-cdc -version<br />
Product: phoneME Advanced (phoneme_advanced_mr2-b97)<br />
Profile: Personal Profile Specification 1.1<br />
JVM: CVM phoneme_advanced_mr2-b97 (mixed mode)<br />
alxx@omap1:~$ <br />
or<br />
alxx@omap1:~$ cvm -version<br />
Product: phoneME Advanced (phoneme_advanced_mr2-b97)<br />
Profile: Personal Profile Specification 1.1<br />
JVM: CVM phoneme_advanced_mr2-b97 (mixed mode)<br />
alxx@omap1:~$<br />
<br />
=== Compile HelloWorld ===<br />
<br />
Then with the standard java hello world<br />
vim Hello.java<br />
/* Hello.java */<br />
<br />
public class Hello<br />
{<br />
public static void main(String[] args)<br />
{<br />
System.out.println("Hello world!");<br />
}<br />
}<br />
<br />
Save then compile<br />
alxx@omap1:~$ jikes Hello.java<br />
alxx@omap1:~$ ls<br />
Hello.class Hello.java<br />
<br />
=== Run the program ===<br />
<br />
Run it using cacao<br />
alxx@omap1:~$ java Hello<br />
Hello world!<br />
alxx@omap1:~$<br />
or<br />
alxx@omap1:~$ cacao Hello<br />
Hello world!<br />
alxx@omap1:~$<br />
<br />
<br />
Run it using phoneme<br />
alxx@omap1:~$ java-cdc Hello<br />
Hello world!<br />
alxx@omap1:~$<br />
or<br />
alxx@omap1:~$ cvm Hello<br />
Hello world!<br />
alxx@omap1:~$<br />
<br />
Test phoneme using its provided testclasses.zip<br />
alxx@omap1:~$cvm -cp /usr/lib/jvm/phoneme-advanced-personal-debug/testclasses.zip HelloWorld<br />
Hello world.<br />
alxx@omap1:~$<br />
<br />
<br />
phoneme with some extra files can be used to run javascript , jython and servlets<br />
see http://www.nslu2-linux.org/wiki/HowTo/UseJavaOnTheSlug</div>Alxxhttps://wiki.gumstix.com/index.php?title=Onboard_Java_Compiler&diff=5367Onboard Java Compiler2011-04-10T11:52:05Z<p>Alxx: /* Check the versions */</p>
<hr />
<div>To install a java vm , a compiler and runtime library.<br />
<br />
<br />
== Pre-requisites == <br />
<br />
Need to have these packages installed<br />
<br />
task-native-sdk<br />
<br />
opkg install task-native-sdk<br />
<br />
== Installation ==<br />
As root on a running gumstix with internet access.<br />
<br />
If you don't have internet access on your gumstix, you can download the packages and copy them to the gumstix via usb drive.<br />
May take a few goes to get all the dependencies. <br />
<br />
first add angstrom repo<br />
echo 'src/gz angstrom-base http://www.angstrom-distribution.org/feeds/unstable/ipk/glibc/armv7a/base'<br />
> /etc/opkg/angstrom-base.conf<br />
<br />
Install class path<br />
opkg install classpath<br />
opkg install classpath-dev <br />
<br />
If you need the graphical classes<br />
opkg install classpath-gtk<br />
<br />
If you are using graphical classes/gui remember to export the display<br />
export DISPLAY=:0.0<br />
<br />
Install cacao vm<br />
opkg install cacao<br />
<br />
Install jikes java compiler<br />
opkg install jikes<br />
<br />
If you need a java vm with debuging or remote debugging support or wish to use the phoneme jvm<br />
wget http://bugcommunity.com/downloads/files/phoneme-advanced-personal-debug_mr2-r1_armv6.ipk<br />
opkg install -force-depends phoneme-advanced-personal-debug_mr2-r1_armv6.ipk<br />
<br />
<br />
Once you have installed it add cvm to your path or create a symbolic link<br />
cvm is in /usr/lib/jvm/phoneme-advanced-personal-debug/bin <br />
<br />
sudo ln -s /usr/lib/jvm/phoneme-advanced-personal-debug/bin/cvm /usr/bin/cvm <br />
<br />
== Set the classpath for Jikes ==<br />
<br />
Set the bootclass path so jikes can find the classes<br />
export BOOTCLASSPATH=/usr/share/cacao/vm.zip:/usr/share/classpath/glibj.zip<br />
<br />
== Testing the install ==<br />
Once everything is installed and you are ready to run.<br />
<br />
=== Check the versions ===<br />
Check the versions and that the jvm's run.<br />
<br />
First cacao<br />
alxx@omap1:~$ java -version<br />
java version "1.5.0"<br />
CACAO version 0.99.4<br />
Copyright (C) 1996-2005, 2006, 2007, 2008<br />
CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO<br />
This is free software; see the source for copying conditions. There is NO<br />
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.<br />
<br />
alxx@omap1:~$ java -fullversion<br />
java full version "cacao-1.5.0"<br />
or<br />
alxx@omap1:~$ cacao -fullversion<br />
java full version "cacao-1.5.0"<br />
alxx@omap1:~$ <br />
<br />
Then phoneme<br />
alxx@omap1:~$ java-cdc -version<br />
Product: phoneME Advanced (phoneme_advanced_mr2-b97)<br />
Profile: Personal Profile Specification 1.1<br />
JVM: CVM phoneme_advanced_mr2-b97 (mixed mode)<br />
alxx@omap1:~$ <br />
or<br />
alxx@omap1:~$ cvm -version<br />
Product: phoneME Advanced (phoneme_advanced_mr2-b97)<br />
Profile: Personal Profile Specification 1.1<br />
JVM: CVM phoneme_advanced_mr2-b97 (mixed mode)<br />
alxx@omap1:~$<br />
<br />
=== Compile HelloWorld ===<br />
<br />
Then with the standard java hello world<br />
vim Hello.java<br />
/* Hello.java */<br />
<br />
public class Hello<br />
{<br />
public static void main(String[] args)<br />
{<br />
System.out.println("Hello world!");<br />
}<br />
}<br />
<br />
Save then compile<br />
alxx@omap1:~$ jikes Hello.java<br />
alxx@omap1:~$ ls<br />
Hello.class Hello.java<br />
<br />
=== Run the program ===<br />
<br />
Run it using cacao<br />
alxx@omap1:~$ java Hello<br />
Hello world!<br />
alxx@omap1:~$<br />
or<br />
alxx@omap1:~$ cacao Hello<br />
Hello world!<br />
alxx@omap1:~$<br />
<br />
<br />
Run it using phoneme<br />
alxx@omap1:~$ java-cdc Hello<br />
Hello world!<br />
alxx@omap1:~$<br />
or<br />
alxx@omap1:~$ cvm Hello<br />
Hello world!<br />
alxx@omap1:~$<br />
<br />
Test phoneme using its provided testclasses.zip<br />
alxx@omap1:~$cvm -cp /usr/lib/jvm/phoneme-advanced-personal-debug/testclasses.zip HelloWorld<br />
Hello world.<br />
alxx@omap1:~$<br />
<br />
<br />
phoneme with some extra files can be used to run javascript , jython and servlets<br />
see http://www.nslu2-linux.org/wiki/HowTo/UseJavaOnTheSlug</div>Alxxhttps://wiki.gumstix.com/index.php?title=Onboard_Java_Compiler&diff=5366Onboard Java Compiler2011-04-10T11:50:16Z<p>Alxx: /* Testing the install */ add subheadings</p>
<hr />
<div>To install a java vm , a compiler and runtime library.<br />
<br />
<br />
== Pre-requisites == <br />
<br />
Need to have these packages installed<br />
<br />
task-native-sdk<br />
<br />
opkg install task-native-sdk<br />
<br />
== Installation ==<br />
As root on a running gumstix with internet access.<br />
<br />
If you don't have internet access on your gumstix, you can download the packages and copy them to the gumstix via usb drive.<br />
May take a few goes to get all the dependencies. <br />
<br />
first add angstrom repo<br />
echo 'src/gz angstrom-base http://www.angstrom-distribution.org/feeds/unstable/ipk/glibc/armv7a/base'<br />
> /etc/opkg/angstrom-base.conf<br />
<br />
Install class path<br />
opkg install classpath<br />
opkg install classpath-dev <br />
<br />
If you need the graphical classes<br />
opkg install classpath-gtk<br />
<br />
If you are using graphical classes/gui remember to export the display<br />
export DISPLAY=:0.0<br />
<br />
Install cacao vm<br />
opkg install cacao<br />
<br />
Install jikes java compiler<br />
opkg install jikes<br />
<br />
If you need a java vm with debuging or remote debugging support or wish to use the phoneme jvm<br />
wget http://bugcommunity.com/downloads/files/phoneme-advanced-personal-debug_mr2-r1_armv6.ipk<br />
opkg install -force-depends phoneme-advanced-personal-debug_mr2-r1_armv6.ipk<br />
<br />
<br />
Once you have installed it add cvm to your path or create a symbolic link<br />
cvm is in /usr/lib/jvm/phoneme-advanced-personal-debug/bin <br />
<br />
sudo ln -s /usr/lib/jvm/phoneme-advanced-personal-debug/bin/cvm /usr/bin/cvm <br />
<br />
== Set the classpath for Jikes ==<br />
<br />
Set the bootclass path so jikes can find the classes<br />
export BOOTCLASSPATH=/usr/share/cacao/vm.zip:/usr/share/classpath/glibj.zip<br />
<br />
== Testing the install ==<br />
Once everything is installed and you are ready to run.<br />
<br />
=== Check the versions ===<br />
Check the versions and that the jvm's run.<br />
<br />
alxx@omap1:~$ java -version<br />
java version "1.5.0"<br />
CACAO version 0.99.4<br />
Copyright (C) 1996-2005, 2006, 2007, 2008<br />
CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO<br />
This is free software; see the source for copying conditions. There is NO<br />
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.<br />
<br />
alxx@omap1:~$ java -fullversion<br />
java full version "cacao-1.5.0"<br />
<br />
alxx@omap1:~$ java-cdc -version<br />
Product: phoneME Advanced (phoneme_advanced_mr2-b97)<br />
Profile: Personal Profile Specification 1.1<br />
JVM: CVM phoneme_advanced_mr2-b97 (mixed mode)<br />
alxx@omap1:~$ <br />
<br />
alxx@omap1:~$ cvm -version<br />
Product: phoneME Advanced (phoneme_advanced_mr2-b97)<br />
Profile: Personal Profile Specification 1.1<br />
JVM: CVM phoneme_advanced_mr2-b97 (mixed mode)<br />
alxx@omap1:~$ <br />
<br />
=== Compile HelloWorld ===<br />
<br />
Then with the standard java hello world<br />
vim Hello.java<br />
/* Hello.java */<br />
<br />
public class Hello<br />
{<br />
public static void main(String[] args)<br />
{<br />
System.out.println("Hello world!");<br />
}<br />
}<br />
<br />
Save then compile<br />
alxx@omap1:~$ jikes Hello.java<br />
alxx@omap1:~$ ls<br />
Hello.class Hello.java<br />
<br />
=== Run the program ===<br />
<br />
Run it using cacao<br />
alxx@omap1:~$ java Hello<br />
Hello world!<br />
alxx@omap1:~$<br />
or<br />
alxx@omap1:~$ cacao Hello<br />
Hello world!<br />
alxx@omap1:~$<br />
<br />
<br />
Run it using phoneme<br />
alxx@omap1:~$ java-cdc Hello<br />
Hello world!<br />
alxx@omap1:~$<br />
or<br />
alxx@omap1:~$ cvm Hello<br />
Hello world!<br />
alxx@omap1:~$<br />
<br />
Test phoneme using its provided testclasses.zip<br />
alxx@omap1:~$cvm -cp /usr/lib/jvm/phoneme-advanced-personal-debug/testclasses.zip HelloWorld<br />
Hello world.<br />
alxx@omap1:~$<br />
<br />
<br />
phoneme with some extra files can be used to run javascript , jython and servlets<br />
see http://www.nslu2-linux.org/wiki/HowTo/UseJavaOnTheSlug</div>Alxxhttps://wiki.gumstix.com/index.php?title=Onboard_Java_Compiler&diff=5365Onboard Java Compiler2011-04-10T11:42:59Z<p>Alxx: /* Installation */</p>
<hr />
<div>To install a java vm , a compiler and runtime library.<br />
<br />
<br />
== Pre-requisites == <br />
<br />
Need to have these packages installed<br />
<br />
task-native-sdk<br />
<br />
opkg install task-native-sdk<br />
<br />
== Installation ==<br />
As root on a running gumstix with internet access.<br />
<br />
If you don't have internet access on your gumstix, you can download the packages and copy them to the gumstix via usb drive.<br />
May take a few goes to get all the dependencies. <br />
<br />
first add angstrom repo<br />
echo 'src/gz angstrom-base http://www.angstrom-distribution.org/feeds/unstable/ipk/glibc/armv7a/base'<br />
> /etc/opkg/angstrom-base.conf<br />
<br />
Install class path<br />
opkg install classpath<br />
opkg install classpath-dev <br />
<br />
If you need the graphical classes<br />
opkg install classpath-gtk<br />
<br />
If you are using graphical classes/gui remember to export the display<br />
export DISPLAY=:0.0<br />
<br />
Install cacao vm<br />
opkg install cacao<br />
<br />
Install jikes java compiler<br />
opkg install jikes<br />
<br />
If you need a java vm with debuging or remote debugging support or wish to use the phoneme jvm<br />
wget http://bugcommunity.com/downloads/files/phoneme-advanced-personal-debug_mr2-r1_armv6.ipk<br />
opkg install -force-depends phoneme-advanced-personal-debug_mr2-r1_armv6.ipk<br />
<br />
<br />
Once you have installed it add cvm to your path or create a symbolic link<br />
cvm is in /usr/lib/jvm/phoneme-advanced-personal-debug/bin <br />
<br />
sudo ln -s /usr/lib/jvm/phoneme-advanced-personal-debug/bin/cvm /usr/bin/cvm <br />
<br />
== Set the classpath for Jikes ==<br />
<br />
Set the bootclass path so jikes can find the classes<br />
export BOOTCLASSPATH=/usr/share/cacao/vm.zip:/usr/share/classpath/glibj.zip<br />
<br />
== Testing the install ==<br />
Once everything is installed and you are ready to run.<br />
<br />
First check the versions<br />
<br />
alxx@omap1:~$ java -version<br />
java version "1.5.0"<br />
CACAO version 0.99.4<br />
Copyright (C) 1996-2005, 2006, 2007, 2008<br />
CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO<br />
This is free software; see the source for copying conditions. There is NO<br />
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.<br />
<br />
alxx@omap1:~$ java -fullversion<br />
java full version "cacao-1.5.0"<br />
<br />
alxx@omap1:~$ cvm -version<br />
Product: phoneME Advanced (phoneme_advanced_mr2-b97)<br />
Profile: Personal Profile Specification 1.1<br />
JVM: CVM phoneme_advanced_mr2-b97 (mixed mode)<br />
alxx@omap1:~$ <br />
<br />
<br />
Then with the standard java hello world<br />
vim Hello.java<br />
/* Hello.java */<br />
<br />
public class Hello<br />
{<br />
public static void main(String[] args)<br />
{<br />
System.out.println("Hello world!");<br />
}<br />
}<br />
<br />
Save then compile<br />
alxx@omap1:~$ jikes Hello.java<br />
alxx@omap1:~$ ls<br />
Hello.class Hello.java<br />
<br />
Run it using cacao<br />
alxx@omap1:~$ java Hello<br />
Hello world!<br />
alxx@omap1:~$<br />
<br />
or<br />
alxx@omap1:~$ cacao Hello<br />
Hello world!<br />
alxx@omap1:~$<br />
<br />
<br />
Run it using phoneme<br />
alxx@omap1:~$ cvm Hello<br />
Hello world!<br />
alxx@omap1:~$<br />
<br />
Test phoneme using its provided testclasses.zip<br />
alxx@omap1:~$cvm -cp /usr/lib/jvm/phoneme-advanced-personal-debug/testclasses.zip HelloWorld<br />
Hello world.<br />
alxx@omap1:~$<br />
<br />
<br />
phoneme with some extra files can be used to run javascript , jython and servlets<br />
see http://www.nslu2-linux.org/wiki/HowTo/UseJavaOnTheSlug</div>Alxxhttps://wiki.gumstix.com/index.php?title=Onboard_Java_Compiler&diff=5364Onboard Java Compiler2011-04-10T11:06:18Z<p>Alxx: created page</p>
<hr />
<div>To install a java vm , a compiler and runtime library.<br />
<br />
<br />
== Pre-requisites == <br />
<br />
Need to have these packages installed<br />
<br />
task-native-sdk<br />
<br />
opkg install task-native-sdk<br />
<br />
== Installation ==<br />
As root on a running gumstix with internet access.<br />
<br />
If you don't have internet access on your gumstix, you can download the packages and copy them to the gumstix via usb drive.<br />
May take a few goes to get all the dependencies. <br />
<br />
first add angstrom repo<br />
echo 'src/gz angstrom-base http://www.angstrom-distribution.org/feeds/unstable/ipk/glibc/armv7a/base'<br />
> /etc/opkg/angstrom-base.conf<br />
<br />
Install class path<br />
opkg install classpath<br />
opkg install classpath-dev <br />
<br />
If you need the graphical classes<br />
opkg install classpath-gtk<br />
<br />
If you are using graphical classes/gui remember to export the display<br />
export DISPLAY=:0.0<br />
<br />
Install cacao vm<br />
opkg install cacao<br />
<br />
Install jikes java compiler<br />
opkg install jikes<br />
<br />
If you need a java vm with debuging or remote debugging support or wish to use the phoneme jvm<br />
wget http://bugcommunity.com/downloads/files/phoneme-advanced-personal-debug_mr2-r1_armv6.ipk<br />
opkg install -force-depends phoneme-advanced-personal-debug_mr2-r1_armv6.ipk<br />
<br />
<br />
Once everything is installed and your ready to run.<br />
<br />
Set the bootclass path so jikes can find the classes<br />
export BOOTCLASSPATH=/usr/share/cacao/vm.zip:/usr/share/classpath/glibj.zip<br />
<br />
<br />
then with the standard java hello world<br />
vim Hello.java<br />
/* Hello.java */<br />
<br />
public class Hello<br />
{<br />
public static void main(String[] args)<br />
{<br />
System.out.println("Hello world!");<br />
}<br />
}<br />
<br />
Save then compile<br />
alxx@omap1:~$ jikes Hello.java<br />
alxx@omap1:~$ ls<br />
Hello.class Hello.java<br />
<br />
Run it using cacao<br />
alxx@omap1:~$ java Hello<br />
Hello world!<br />
alxx@omap1:~$<br />
<br />
Run it using phoneme<br />
alxx@omap1:~$ java-cdc Hello<br />
Hello world!<br />
alxx@omap1:~$</div>Alxxhttps://wiki.gumstix.com/index.php?title=Category:How_to_-_JAVA&diff=5363Category:How to - JAVA2011-04-10T10:51:33Z<p>Alxx: add link to Onboard_Java_Compiler page</p>
<hr />
<div>1. [http://code.google.com/p/netbeams/wiki/GumstixOESystem This link] has instructions for installing classpath and JamVM.<br />
The instructions are based on outdated version numbers. Just substitute the current OE versions.<br />
<br />
2. A Gumstix customer has successfully built both Cacoa and JamVM on the Overo board using the instructions [http://wiki.openembedded.net/index.php/Java here].<br />
<br />
3. Add an java to overo with onboard compiler [[Onboard_Java_Compiler]]</div>Alxxhttps://wiki.gumstix.com/index.php?title=Eclipse_on_Gumstix_for_new_users&diff=5362Eclipse on Gumstix for new users2011-04-10T10:39:20Z<p>Alxx: /* Debug a Java Application */ removed extra space and added missing - in url for wget</p>
<hr />
<div>This guide provides step-by-step instructions for using the Eclipse Integrated Development Environment (IDE) to develop applications for the Gumstix COMs.<br />
<br />
We'll walk through these tasks:<br />
:* setting up Eclipse<br />
:* connection to your Gumstix system<br />
:* creating a simple "Hello, World!" Python program<br />
:* running a web server<br />
:* installing new packages on your Gumstix<br />
:* creating a small graphical Java application<br />
:* remote debugging of your Java application<br />
:* natively-compiling C/C++ code on your Gumstix<br />
:* remote debugging C/C++ using the GDB server interface.<br />
<br />
We will also explain how to set up a cross-compilation toolchain so you can develop C/C++ applications on your development computer and upload them to your Gumstix.<br />
<br />
Remember, Gumstix COMs are fully-fledged, albeit tiny, Linux systems so there are many tools we don't cover here. For example, [http://wiki.openembedded.net/index.php/OpenEmbedded_Tools_for_Eclipse_(OTE) this document] explains how to use the powerful OpenEmbedded build system within Eclipse.<br />
<br />
Required Tools:<br />
:* any Windows, Apple or Linux computer with a USB port<br />
:* recent version of the Java Runtime Environment (available [http://java.sun.com/javase/downloads/index.jsp here])<br />
:* a Gumstix COM running [http://www.gumstix.net/Setup-and-Programming/view/Overo-Setup-and-Programming/Downloading-pre-built-images/111.html up-to-date software]<br />
:* any expansion board of the Gumstix Overo series, such as Chestnut or Tobi, that has both a USB console port and a 10/100 <br />
:* Ethernet jack<br />
:* a 5V power supply<br />
:* an ethernet cable and internet connection<br />
:* a mini-A to Standard-A USB cable<br />
:* a [http://www.gumstix.net/Setup-and-Programming/view/Overo-Setup-and-Programming/Creating-a-bootable-microSD-card/111.html bootable microSD card] (only needed for native C/C++ compilation)<br />
<br />
Key Idea:<br />
[[File:GumstixEclipse1.jpg|thumb|right|upright=5]]<br />
<br />
==Download Eclipse==<br />
[http://www.eclipse.org/downloads/ Download] the Eclipse IDE for Java Developers for your Operating System: www.eclipse.org<br />
<br />
[[Image: GumstixEclipse2.jpg | center | 600px]]<br />
<br />
<br />
:* it is ''not'' necessary to install the Eclipse software; just double-click on the application once it has finished downloading<br />
:* when prompted, choose a workspace folder in which you want to store your projects and your configuration information<br />
:* then click through to the Eclipse workbench itself<br />
<br />
==Install Plugins==<br />
For developers, a great variety of additional features can be added to Eclipse from various repositories of plug-ins known as ''Update Sites''.<br />
To install a new plugin in Eclipse, first select the ''Update Site''.<br />
:* navigate to '''Help->Install New Software...'''<br />
:* select the Update Site for your version of Eclipse from the "Work with"dropdown menu<br />
<br />
[[File:GumstixEclipse3.jpg | center | 1000px]]<br />
<br />
:Note: If you are not sure which version of Eclipse you have, you can check by reopening Eclipse, it will be displayed on the loading screen.<br />
<br />
----<br />
Hint:<br />
If the update site is not available, you can add it by clicking the 'Add...' button on the right. For the Galileo release, you can use the URL http://dowload.eclipse.org/releases/galileo<br />
----<br />
<br />
As we are working with a remote system, we'll install the Remote System Explorer plugin.<br />
:* search for the ''Remote System Explorer End-User Runtime'' plugin<br />
:* select it for installation<br />
<br />
[[File:GumstixEclipse4.jpg | center | 600px]]<br />
<br />
Still in Eclipse,<br />
:* select "Next".... twice<br />
:* select the radio button to "ACCEPT" the terms of the license agreement<br />
:* choose "Yes" to restart Eclipse for the changes to take effect<br />
<br />
Once Eclipse has restarted, let's add two other useful plugins that allow connection to the console port of our Gumstix without needing a terminal emulator program such as kermit or TeraTerm.<br />
From within Eclipse,<br />
:* navigate to '''Help->Install New Software'''<br />
:* search on "Target" to find the ''Target Manager Terminal''<br />
<br />
[[File:GumstixEclipse5.jpg | center | 1000px]]<br />
<br />
:* select the ''Target Manager Terminal''<br />
:* click "Next"<br />
:* click "Finish" to complete installation<br />
:* choose "Yes" to restart Eclipse for the changes to take effect<br />
<br />
We'll also need to add a new update site by doing these steps in Eclipse:<br />
:* navigate to '''Help->Install New Software...'''<br />
:* click the "Add..." button<br />
:* type ''http://rxtx.qbang.org/eclipse'' into the ''Location'' field and create a name<br />
<br />
[[File:GumstixEclipse6.jpg | center | 1000px]]<br />
<br />
:* Click the "OK" button<br />
Go into the sub-directory as shown below to select the ''RXTX End-User Runtime'' plugin that this site provides.<br />
<br />
[[File:GumstixEclipse7.jpg | center | 1000px]]<br />
<br />
:* click "Next" twice<br />
:* select the radio button to "ACCEPT" the terms of the license agreement<br />
:* click "OK" at the security warning window<br />
:* click "Finish" to complete installation<br />
:* choose the "Yes" button to restart Eclipse for the changes to take effect<br />
<br />
==Connect Your Gumstix==<br />
Now it is time to connect your Gumstix---let's get started by establishing a console connection.<br />
:* mount your Gumstix COM down on to your expansion board<br />
:* plug the mini-A USB plug into the port marked CONSOLE and end of the cable into a standard USB port on your computer<br />
----<br />
Hint:<br />
Your computer should detect your Gumstix system when you first connect the USB cable, even though the power is not yet turned on. On Macintosh and Windows systems, a pop-up window should appear instructing you to download a new driver (do so) or notifying you that a USBserial device has been detected. If not, you can download drivers from [http://www.ftdichip.com/FTDrivers.htm this site]. Choose the "VCP" driver.<br />
Once you have downloaded this driver, make sure to unplug and then replug the USB cable running from your computer to your Gumstix expansion board so the Gumstix will be recognized by your computer.<br />
----<br />
:* connect your Gumstix to the internet using an ethernet cable<br />
NOTE: You still have NOT plugged the power cable in to the <br />
Gumstix expansion board! This diagram shows the locations<br />
of the USB 'CONSOLE' port and the 'POWER' input port on a <br />
Summit board on which an Overo COM has been mounted.<br />
<br />
[[File:GumstixEclipse8.jpg | center ]]<br />
<br />
:* if you are booting from a microSD card, insert this card now until you hear it click in place.<br />
Before applying power to the board, let's open up a connection to the console port.<br />
In Eclipse,<br />
:* navigate to '''Window->Show View->Other->Terminal->Terminal'''<br />
:* click on the 'N' connection icon in the window that appears<br />
<br />
[[File:GumstixEclipse9.jpg | center ]]<br />
<br />
:* make the connection using the following settings:<br />
Connection Type: Serial<br />
Port: <port to which your Gumstix is connected><br />
Baud Rate: 115200<br />
Data Bits: 8<br />
Stop Bits: 1<br />
Parity: none<br />
Flow Control: none<br />
Timeout: 5<br />
<br />
----<br />
Hint:<br />
The port to which your Gumstix is connected will have a different name depending on your Host operating system.<br />
:* On Windows, it should be ''USB-COM''<br />
:* On Macintosh, it should be ''/dev/tty.usbserial-xxxxxxxx'' where ''xxxxxxxx'' is an arbitrary string of characters<br />
:* On Linux, it should be ''/dev/ttyUSBx'' where ''x'' is a number.<br />
----<br />
<br />
[[File:GumstixEclipse10.jpg | center | 800px]]<br />
<br />
----<br />
Hint:<br />
If this does not work, or you wish to gain Console access via a *nix Shell instead, visit the tutorial on [[Gaining Console Connection via Terminal]]<br />
----<br />
<br />
*Now, it's time to apply power to the Gumstix expansion board so plug the 5V wall adapter into the power input jack on the Gumstix.<br />
<br />
You should see text appear in this window; for now, just let the Gumstix boot. When prompted, you can log in to the root account. The default credentials are:<br />
<br />
'''Overo'''<br />
<br />
username: root<br />
<br />
password: <leave blank><br />
<br />
<br />
'''VerdexPro'''<br />
<br />
username: root<br />
<br />
password: gumstix<br />
<br />
==Create a Web Site==<br />
Each Gumstix comes with a built-in package manager called opkg. A package manager is a useful tool for installing software; you can install everything from media players to GPS mapping tools to the Firefox web browser. In this example, you'll use opkg tool to install a new application for your Gumstix: the Apache web server.<br />
<br />
To make your own Gumstix web site, type the following in the terminal window:<br />
opkg update <Enter><br />
opkg install apache2 <Enter><br />
Before you start using Apache, which is now running, you'll need to find the IP address (internet address) of your Gumstix COM. To do this, type the following command into the terminal window:<br />
ifconfig | grep 'inet addr' <Enter><br />
You should see something like this appear on your screen.<br />
inet addr: 10.0.1.73 Bcast: 192.168.0.255 Mask: 255.255.255.0<br />
The IP address of your Gumstix is the first address shown: ''10.0.1.73'' in this case.<br />
Now,<br />
:* open up a web browser on your host computer<br />
:* type that IP address of your Gumstix into the address bar<br />
You should see something like this which is the default web site for Apache running on your Gumstix.<br />
<br />
[[File:GumstixEclipse11.jpg]]<br />
<br />
To make your web site say something more interesting, do the follow in your terminal window:<br />
:* type: ''nano /usr/share/apache2/htdocs/index.html''<br />
:* replace the words at the top of the screen "It Works" with the words "Gumstix Rocks!"<br />
:* press 'Ctrl+O' <Enter><br />
:* press 'Ctrl+X' to save and exit<br />
:* refresh your web browser<br />
<br />
==Write a Java Application==<br />
So far, you haven't actually used Eclipse other than as a console interface for your Gumstix. It is time to harness the power of Eclipse to write a small graphical Java application.<br />
In Eclipse.<br />
:* Navigate to '''File-> New-> Java Project''',<br />
:* Name the project ''gumstix-java''<br />
:* Select "Finish"<br />
Once the project is created,<br />
:* Select '''File->New->Class'''<br />
:* Name your class ''Hello''<br />
:* click "FINISH"<br />
<br />
Add the following code to your class:<br />
<br />
import javax.swing.JFrame;<br />
import javax.swing.JLabel;<br />
public class Hello {<br />
public static void main(String [] args) {<br />
JFrame frame = new JFrame("hello");<br />
final JLabel label = new JLabel("hello from Gumstix");<br />
frame.getContentPane().add(label);<br />
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);<br />
frame.pack();<br />
frame.setVisible(true);<br />
}<br />
}<br />
<br />
You should get something that looks like this:<br />
<br />
[[File:GumstixEclipse12.jpg | center | 600px]]<br />
<br />
Press the green run button to test drive our application on our host machine.<br />
<br />
----<br />
Hint:<br />
Eclipse has many auto-completion features. Simply typing /:*<Enter> before a class creates a standard documentation block. Likewise, pressing <Ctrl>+<Space> provides context specific auto-completion options. Many other hints for speedy development are explained in the tutorials [http://www.eclipse.org/resources/?category=Getting%20Started here].<br />
----<br />
<br />
==Upload Code==<br />
In Step 5 we discovered the IP address of our Gumstix. With this, we can connect to our Gumstix using the SSH protocol which allows us to rapidly transfer files. For this step, navigate to '''Window->Open Perspective->Other->Remote System Explorer''' and click on the connection icon in the ''Remote Systems'' panel on the left. Select ''SSH without shells'' as the connection type and press Next. Put the internet address you found in Step 5 into the field marked ''Host Name'' and hit finish. To test that everything is working correctly, right-click on the terminal item list under your new connection and select ''Launch Terminal''. A console interface exactly like the USB console interface we set up in Step 3 should pop up.<br />
<br />
<br />
----<br />
Hint:<br />
A 'Perspective' is an arrangement of windows and widgets, that is a specific view of the Eclipse workspace, designed for a particular task. If you wish to focus on any particular widget, double click the tab in Eclipse; return to the previous view by double-clicking again.<br />
----<br />
<br />
<br />
By installing the VNC viewer plugin, we can get a graphical interface to our Gumstix system. Do this by adding the ''Tools for mobile linux runtime'' plugin ('''Help->Install New Software''') from the main update site. To use, select the VNC viewer widget from '''Window->Show View->Other->VNC Category->VNC''' and click on the ''New Connection'' icon in the VNC Viewer panel. Again, the ''Host'' is the internet address of your Gumstix board.<br />
<br />
[[File:GumstixEclipse13.jpg | center | 800px]]<br />
<br />
Finally, we need to upload our java code before we can run it. Switch back to the Java Perspective ('''Window->Open Perspective->Java''') and right-click on our Java file and selecting Export. Choose the option to export file to a remote file system and choose to upload your ''Hello.class'' file.<br />
<br />
[[File:GumstixEclipse14.jpg | center | 600px]]<br />
<br />
You will need to ''Browse'' to find your Gumstix board; you should upload this code to your home directory on the Gumstix.<br />
<br />
==Debug a Java Application==<br />
We can debug our java application remotely from Eclipse. To do this, we need a Java Virtual Machine capable of doing debugging. This time, the package we need isn't available in our package sources however we can fetch the package directly from a web site and install it using the same opkg package management tool.<br />
wget http://bugcommunity.com/downloads/files/phoneme-advanced-personal-debug_mr2-r1_armv6.ipk <Enter><br />
opkg install -force-depends phoneme-advanced-personaldebug_mr2-r1_armv6.ipk <Enter><br />
Let's also update our Java libraries so we have access to the standard graphical libraries.<br />
opkg install classpath-gtk <Enter><br />
Next, let's start our Java code in debugging mode on the Overo:<br />
java-cdc -Xdebug -Xrunjwdp:transport=dHt_socket,server=y,suspend=y,address=1234 Hello <Enter><br />
Finally, let's connect to our debugging session by navigating in Eclipse to '''Run->Debug Configurations''' and double-clicking on Remote Java Application to create a new configuration. Fill in the form as shown below using the internet address found in the previous step.<br />
<br />
==Install a native C/C++ SDK==<br />
When we discussed Python and Java we noted that both are interpreted languages--- neither needs to be compiled. C and C++ code requires compilation which can be done natively---on the Gumstix itself---or on a development machine using a cross-compiler. To do native compilation, you need to install a compiler as well as any required libraries. You'll need to be booting from a microSD card as this installation takes approximately 75MB of space.<br />
$ echo 'src/gz angstrom-base http://www.angstrom-distribution.org/feeds/unstable/ipk/glibc/armv7a/base' > /etc/opkg/angstrom-base.conf<br />
$ opkg update<br />
$ opkg install task-native-sdk<br />
Firstly, we are adding a new package repository to our package manager and updating our list of available packages before actually installing the complete package needed to do native development.<br />
<br />
Let's create either of the following files in Eclipse, upload the code and then compile on the Gumstix using our newly installed compiler.<br />
<br />
===C++: HelloWorld.cpp===<br />
#include <iostream><br />
using namespace std;<br />
int main () {<br />
cout << "Gumstix runs on C++" << endl;<br />
return 0;<br />
}<br />
<br />
Save the file and issue the following commands to compile and run HelloWorld.cpp<br />
g++ -o hello hello.cpp <enter><br />
Gumstix runs on C++ <enter><br />
<br />
===C: HelloWorld.c===<br />
#include <stdio.h><br />
int main () {<br />
printf("Gumstix runs on C\n");<br />
return 0;<br />
}<br />
<br />
Save the file and issue the following commands to compile and run HelloWorld.c<br />
gcc -o hello hello.c<br />
Gumstix runs on C<br />
<br />
<TODO: More exciting examples using on-board LEDs.><br />
<br />
==Using GDB as a remote debugger in C/C++==<br />
These instructions will teach you how to download, install, and use the GDB debugger remotely on your Overo COM.<br />
<br />
<pre>NOTE: <br />
remote system - a device that is being operated remotely (via SSH, USB Serial, etc). This means that it is a device that you are operating from a different system <br />
(ie: if you are accessing the Overo COM via connection with your PC, then the Overo COM is a remote system).<br />
For the purpose of this guide, the Overo COM will be the remote system.<br />
<br />
local host - the device that is being used to work on (ie: If you are working on your PC, that is the local host. If you then connect to another computer via VNC, <br />
that is a remote system, and you laptop is still the localhost).<br />
For the purpose of this guide, your Personal Computer will be the local host.</pre><br />
<br />
Before starting, it is important to note there are many different ways to run a remote debugger. The most fundamental choice when debugging remotely is whether you want to:<br />
:*Run the debugger on the remote system or<br />
:*Run the debugger on the local host with a cross debugger on the remote system<br />
<br />
This guide will teach you how to download, install, and run the debugger on the remote system (choice A). If you wish to learn more about the cross debugger option, use Google. Also the wikipedia article on cross compilers (which operate in a very similar fashion) is very good, albeit a bit complicated. None of this is necessary in understanding the contents of this guide. <br />
<br />
For the purposes of this guide, we will be using the GDB: the GNU project debugger. As stated on their website:<br />
<br />
<pre>GDB, the GNU Project debugger, allows you to see what is going on `inside' another program while it executes -- or what another program was doing at the moment it <br />
crashed.<br />
<br />
GDB can do four main kinds of things (plus other things in support of these) to help you catch bugs in the act:<br />
- Start your program, specifying anything that might affect its behavior.<br />
- Make your program stop on specified conditions.<br />
- Examine what has happened, when your program has stopped.<br />
- Change things in your program, so you can experiment with correcting the effects of one bug and go on to learn about another.</pre><br />
<br />
While the reasons for using a debugger instead of trying to debug with the ‘brute force’ method of adding print statements throughout the entire program are enumerable, there are a few that stand out:<br />
# The ability to ‘step’ through a program<br />
#* The GDB debugger allows you to ‘step’ through a program. This means that instead of just executing the program and then leaving you with a final error message, it will execute one line at a time until the program crashes. This allows the user to see exactly where, and why, the program crashed. <br />
# The ability to set breakpoints<br />
#* The GDB debugger allows you to set breakpoints in the program. These are points where the CPU will stop executing the code and allow the user to decide whether to continue. This allows the user to explore what is ‘going on’ at certain points in the execution, something that otherwise is not possible. <br />
# The ability to look at the Backtrace<br />
#* This will show you where, and exactly why, your program crashed. Although SEGFAULT isn’t very useful, the backtrace will tell you what caused the SEGFAULT. Everything from what line, what variable, and even the address that variable was at.<br />
<br />
===Installing the GDB===<br />
Once the Overo COM has been connected to the local host, you should have access to the following command line:<br />
<pre>root@overo:~# </pre><br />
Although you are working on your local host, this command line is for the remote system. It is the same as if you opened up Terminal (for Mac, Linux) or XTerm (for Windows). You now have access and control of the remote system.<br />
<br />
Now there are some packages that must be downloaded and installed onto the Overo so that it can run the GDB environment. To do this issue the following command:<br />
<pre>opkg update <enter><br />
opkg install gdb <enter></pre><br />
This should spew out a bunch of text such as:<br />
<pre>Downloading http://www.angstrom...</pre><br />
Just let it run and once its done, you’ll have the GNU GDB debugger installed on your Overo COM.<br />
<br />
===Creating a C/C++ Program to Debug===<br />
Now, your Overo COM has a debugger installed and ready to use. However, this does not mean you are ready to go. There are two more things required before it is possible to use a GDB debugger.<br />
:* A C/C++ program<br />
:* A SDK to run the program on<br />
To see how to install a SDK and write/run a simple program in C/C++, see [[#Install a native C/C++ SDK]]. <br />
<br />
Once you have a program ready, you first must create an executable file. Lets use for example the C++ program HelloWorld.cpp. To create the executable file HelloWorld, issue the following command:<br />
<pre>g++ -o HelloWorld HelloWorld.cpp <enter></pre><br />
Now, to run the program:<br />
<pre>./HelloWorld <enter></pre><br />
To do the same thing with a C program (HelloWorld.c), issue the command<br />
<pre>gcc -o HelloWorld HelloWorld.c <enter></pre><br />
<pre>./HelloWorld <enter></pre><br />
<br />
What this command does is uses the GNU compiler (either g++ or gcc) and creates an executable object (HelloWorld) out of the C or C++ program file (either HelloWorld.cpp or HelloWorld.c). You may name the executable whatever you like, but it is considered best practice to name it the same thing as the program file.<br />
<br />
===Debugging the Program===<br />
Now that you have GDB installed and a C/C++ program ready to go, its time to debug. To open to GDB environment, run the following command<br />
<pre>gdb <enter></pre><br />
Some text should spit out, and the following command line should appear<br />
<pre>(gdb)</pre><br />
Now that the debugger is running, it is time to tell the debugger what program we want to debug. To do this, first we need to declare our HelloWorld file as an executable file. For this run the following command <br />
<pre>(gdb) exec-file HelloWorld <enter></pre><br />
Now that we have an executable file ready to be debugged, its time to run the program<br />
<pre>(gdb) run HelloWorld <enter></pre><br />
The debugger will now run your program. If the program has no syntax or logic errors, the program should run and end with the line:<br />
Program exited normally.<br />
If there are errors, or the program crashed, it is possible to extract the exact details of that crash by issuing the back trace command.<br />
<pre>(gdb) bt <enter></pre><br />
Once you are done you can quit by issuing the command:<br />
<pre>(gdb) quit <enter></pre><br />
<br />
A complete list of commands in GDB:<br />
www.yolinux.com/TUTORIALS/GDB-Commands.html<br />
<br />
====GDB Debugger Tutorial====<br />
For a complete GDB Debugger tutorial (very good tutorial, comes with sample code they walk you through and extra errors for you to debug yourself!):<br />
http://www.cs.cmu.edu/~gilpin/tutorial/<br />
<br />
Now you have a debugger up and running! Play around with it by putting errors into your program on purpose to see the powers of having a remote debugger!<br />
<br />
==Use a C/C++ cross-compiler==<br />
In order to do C/C++ development on our host machine, we need to add in a plugin to Eclipse. Also, we need to download an appropriate cross-compilation toolchain. For now, I recommend the lovely instructions from<br />
<br />
http://www.designarm.com/quickstart-guide/linux-software/eclipse.html &<br />
<br />
http://www.bugcommunity.com/wiki/index.php/BUG_Kernel_Development_with_Eclipse<br />
<br />
==Further Reading==<br />
===Internal===<br />
[[Gaining Console Connection via Terminal]]<br><br />
[[HelloWorld | HelloWorld in Python, C and C++]]<br><br />
[[Remote Debugging with GDB]] <br><br />
[[HelloWorld in Java]]<br />
<br />
===External===<br />
:* Tutorials built into Eclipse<br />
:* Bitbake commander<br />
:* OpenEmebedded|Poky docs + Bitbake docs<br />
:* Eclipse Plugin Tutorial<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
[[Category:How_to_-_eclipse]]</div>Alxx