• Home
  • Help
  • Search
  • Login
  • Register
Pages: 1 [2]
Author Topic: FTDI device on the Sheeva  (Read 21742 times)
31000aku
Newbie
*

Karma: 0
Posts: 5


View Profile WWW
« Reply #15 on: May 02, 2009, 03:52:00 PM »

Hm...I built a kernel from the git repository a few hours ago and there was no need to change the bootargs. I only did
Code:
setenv mainlineLinux yes
setenv arcNumber 2097
saveenv
and the plug is booting fine.
I changed from 2.6.22.18 to 2.6.30.
Logged

German SheevaPlug community - www.sheevaplug.de

moridin1138
Newbie
*

Karma: 0
Posts: 7


View Profile
« Reply #16 on: May 02, 2009, 05:46:24 PM »

Hm...I built a kernel from the git repository a few hours ago and there was no need to change the bootargs. I only did
Code:
setenv mainlineLinux yes
setenv arcNumber 2097
saveenv
and the plug is booting fine.
I changed from 2.6.22.18 to 2.6.30.

Finally got it working on the Linux machine.

I had to do as above but also:

Code:
setenv bootargs rootfstype=jffs2 console=ttyS0,115200 mtdparts=orion_nand:0x400000@0x100000(uImage),0x1fb00000@0x500000(rootfs) rw root=/dev/mtdblock1 rw ip=192.168.2.9:192.168.2.1:192.168.2.1:255.255.255.0:DB88FXX81:eth0:none

I am up and running again, and shall test the FTDI USB-Serial adapters I have soon...

Thanks for everyone's help!
Logged

pauldy
Newbie
*

Karma: 0
Posts: 17


View Profile
« Reply #17 on: May 12, 2009, 10:03:12 AM »

Just some quick notes to help others looking at this device.

I got my FTDI 4232H up and running and the pins are finally all toggling and not just the RTS line.

I was able to interact with the serial port using the ftdi_sio module.  I was able to get the vendor/product ids using lsudb.  Once the module was loaded I used moshiach's post reguarding udev.

I created /etc/udev/rules.d/10-ftdi-4232h.rules and added the following.

Code:
SYSFS{idProduct}=="6011",SYSFS{idVendor}=="0403",ACTION=="add",RUN+="/sbin/modprobe -q ftdi-sio product=0x6011 vendor=0x0403",SYMLINK+"USB[0-3]" ENV{PRODUCT}=="0403/6011/500",ACTION=="remove",RUN+="/sbin/rmmod ftdi_sio usbserial"

After a reboot I had my symlinks for /dev/ttyUSB0-3.  I wrote a quick c app and was able to toggle the rts line without issue.  While trying to find a way to add support to mono I came across libftdi, this makes the process super simple and if your using one of these modules to extend the gpio of the plug it is worth looking at.

http://www.intra2net.com/en/developer/libftdi/

It takes a while to come up with all the dependencies but once complete it worked like a champ.
Logged

pauldy
Newbie
*

Karma: 0
Posts: 17


View Profile
« Reply #18 on: May 13, 2009, 07:58:20 AM »

Last night I got a chance to use the libftdi library on the 2.6.18 kernel and it worked fine.  So apparently with that lib updating the kernel isn't even necessary.
Logged

robreilly
Newbie
*

Karma: 0
Posts: 2


View Profile
« Reply #19 on: May 20, 2009, 10:08:56 AM »

cbxbiker61,

I wanted to thank you for building a sheeva-2.6.22.19 kernel and serial modules.  My primary reason for buying the Plug was to write articles about it and feed it data from an Arduino microcontroller.  Although I've written about Linux for years, my experience has been on the applications and business side.  I've had almost no experience building kernels or modules, so when I saw that the Plug didn't have any serial drivers...needless to say, I was stuck.  That's all changed now that I can send (and hopefully receive) data to the device. 

Again, thanks for putting the image and modules together.   You can find  a couple of my Plug Computer articles on Linux.com.

Could you send me your email address and contact info.

Rob Reilly
robreilly@earthlink.net
http://home.earthlink.net/~robreilly
Logged

jmknapp
Newbie
*

Karma: 0
Posts: 45



View Profile
« Reply #20 on: May 20, 2009, 06:37:57 PM »

I've tested sending and receiving data to an Arduino & it works--in my case I used the 2.6.30-rc5 kernel with the usbserial and ftdi_sio modules. The Arduino doesn't have much of a current draw & is powered through the USB without issue.  I suppose if a lot of the I/O pins were used to produce the maximum current (40ma each) there might be a problem.

It's interesting to think of what this does exactly for the plug's capabilities/applications. At the least, it adds six channels of A/D sensing along with 14 or however many digital I/O bits to control and/or sense things.

Joe
Logged

chunkyks
Newbie
*

Karma: 3
Posts: 27


View Profile
« Reply #21 on: July 21, 2009, 10:13:16 AM »

So, I have a solution to this problem that requires no flashing, but isn't /quite/ working yet, I was wondering if any skilled coders out there could advise.

What I've done is simply use libftdi [apt-get install libftdi-dev] to write a userland "driver". It creates a unix pseudoterminal and simply proxies data to and from the ftdi device. Instead of using /dev/ttyUSB0 [as you'd usually use], you'd use /dev/pts/{number} [the actual device is printed to stdout by the userspace program]. I think someone knowlegable with udev/hotplug can make this whole thing entirely transparent; plugging in this device would start the process and smylink the pty to /dev/ttyUSBftdi0 or something.

Before posting the code, I'll explain the problem: It seems that regularly, there's some kind of buffering going on. I can open the device using minicom to communicate with my ftdi device [it's an OBDPro usb device]. While using it, it works fine most of the time [now that I've put in the buffer purge calls], but regularly I find that I have to hit enter a couple times to get anything to happen. I think it's blocking in a read from the device [at least, that's kinda what strace suggests], I just don't know how to try and fix it.

The code itself appears thus:
Code:
/** \file
 \brief Provide a pty to access an ftdi device, in case of missing kernel driver

gcc -o ftdipty ftdipty.c -lftdi
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <ftdi.h>

int main(int argc, const char **argv) {
int ret;

// Create an ftdi context
struct ftdi_context *ftdic;
if (NULL == (ftdic = ftdi_new())) {
fprintf(stderr, "ftdi_new failed\n");
return 1;
}

int vendorid = 0x0403;
int product = 0x6001;

// Open the ftdi device
if (0 > (ret = ftdi_usb_open(ftdic, vendorid, product))) {
fprintf(stderr, "unable to open ftdi device: %d (%s)\n", ret, ftdi_get_error_string(ftdic));
ftdi_free(ftdic);
return 1;
}

// Open the pseudoterminal
int fd = posix_openpt(O_RDWR | O_NOCTTY);
if(-1 == fd) {
perror("Couldn't posix_openpt");
return 1;
}
grantpt(fd);
unlockpt(fd);
fcntl(fd,F_SETFL,O_NONBLOCK);

// Print the pty slave name
static char ptyname[1024];
if(0 != ptsname_r(fd, ptyname, sizeof(ptyname))) {
perror("Couldn't get pty slave");
return 1;
}

printf("%s successfully opened pty. Name: %s\n", argv[0], ptyname);


// Seriously, how f**king cheesy is this.
while(1) {
char buf[4096];
int nbytes;

// printf("About to read from the pty\n");
if(0 < (nbytes = read(fd, buf, sizeof(buf)))) {
// printf("About to write to the ftdi\n");
ftdi_write_data(ftdic, buf, nbytes);
}

if(0 < (ret = ftdi_usb_purge_buffers(ftdic))) {
fprintf(stderr, "unable to purge ftdi buffers: %d (%s)\n", ret, ftdi_get_error_string(ftdic));
break;
}

// Just to stop it using 100% cpu
usleep(50);

// printf("About to read from the ftdi\n");
if(0 < (nbytes = ftdi_read_data(ftdic, buf, sizeof(buf)))) {
// printf("About to write to the pty\n");
write(fd, buf, nbytes);
}

if(0 < (ret = ftdi_usb_purge_buffers(ftdic))) {
fprintf(stderr, "unable to purge ftdi buffers: %d (%s)\n", ret, ftdi_get_error_string(ftdic));
break;
}
}


// Close the pty
close(fd);

// Close the ftdi device
if (0 > (ret = ftdi_usb_close(ftdic))) {
fprintf(stderr, "unable to close ftdi device: %d (%s)\n", ret, ftdi_get_error_string(ftdic));
return EXIT_FAILURE;
}

// Free the ftdi context
ftdi_free(ftdic);

return 0;
}

Any help would be massively appreciated,
Gary (-;
« Last Edit: July 21, 2009, 10:47:01 AM by chunkyks » Logged

chunkyks
Newbie
*

Karma: 3
Posts: 27


View Profile
« Reply #22 on: August 03, 2009, 10:16:30 AM »

Just one bump, in case anyone's able to help out; I still haven't got the code above fully working yet, and I'm at a loss as to how to fix it.

Gary (-;
Logged

chunkyks
Newbie
*

Karma: 3
Posts: 27


View Profile
« Reply #23 on: October 01, 2009, 10:24:25 PM »

I got it working, in the end. The source is available here: ftdipty.c

So, without needing to reflash, you can install libftdi and libftdi-dev from the default repository, and run this. It creates an entry /dev/pts/{something} that can be communicated with [mostly] as you would a serial terminal. Just don't call tcsetattr and expect anything useful to happen :-)

Gary (-;
Logged

abl2910
Newbie
*

Karma: 0
Posts: 8


View Profile
« Reply #24 on: October 30, 2009, 11:42:14 AM »

 Hello
Can i use the readme file and execute this on my sheevaplug ver. 2.6.22.18
i am missing the ttyUSB0 ore ttyUSB1

abl2910


I just added usb-serial support to the the kernel  image/modules located here.

IPV4: http://sheeva.with-linux.com/sheeva/

IPV6: http://sheeva6.with-linux.com/sheeva/

If you want to test it (as root) just download the README to your sheevaplug.  chmod 755 README. ./README.  It'll install the modules and the new uImage.  After a successful flash just reboot.

my usb-serial  driver has been patched to allow full-speed downloads (1.5MBit) using high-speed wireless modems, (EVDO for example) as per this thread. http://www.evdoforums.com/thread4381.html Anyone interested in testing out EVDO modems with SheevaPlug?


Logged

abl2910
Newbie
*

Karma: 0
Posts: 8


View Profile
« Reply #25 on: October 31, 2009, 09:47:02 AM »

Hello
please help with this sheevaplug, i'am new to linux and i have try to use the readme file to get new image, but i set the env and the bootargs before i run th readme file.
Can i boot from the old image again if i change bootargs and env?

abl2910
Logged

matt276
Newbie
*

Karma: -1
Posts: 1


View Profile
« Reply #26 on: November 04, 2009, 03:34:01 AM »

I just updated with Sheevaplug Installer and plug my ftdi device, now i can communicate with ttyUSB0.
Thank you for this excellent work.

I love my Sheevaplug :d

Matt
Logged

peter a
Full Member
***

Karma: 0
Posts: 132


View Profile
« Reply #27 on: March 15, 2010, 06:54:12 AM »

Yep , and I would like to talk about spam ,  and the odds of what look like spam messages coming from users with the added number of 44 , what the odds of that.
Logged

ypodim
Newbie
*

Karma: 0
Posts: 1


View Profile
« Reply #28 on: August 31, 2010, 05:10:57 PM »

Here is how I got the FTDI serial module to load and create the ttyUSBx devices successfully, using the latest vendor and product codes with the kernel module:

http://www.polychronis.gr/how-to/loading-the-ftdi-serial-module-on-the-sheevaplug/
Logged

Pages: 1 [2]
Print
Jump to: