Access SD card with USB port

Hi.

I was wondering if it is possible to access microSD card data from the USB port of the Yun. Maybe it is by changing Yun's configuration or by editing a new script?

Let me explain a little bit about my application. The Yun is a datalogger and logs informations on his microSD card. The Yun is hide in a little box and has a USB antenna which is going out of the box. The microSD port on the Yun is not accessible but the USB port is, since it is used for the antenna. I use a FTP client on the Yun to download microSD card's data on a FTP server. This part is working pretty well. I just want to have a backup and make sure that I can access data with another option. If, for some reason, the connection with the server is not working anymore, I want to unplug the USB antenna and access my data with a USB cable.

For the moment, I have no idea how to start or where to start. I am not a OpenWRT or Linux professionnal, but I have some experience with those.

I hope you guys can help me !

First off, there are two USB ports on the Yun.

  • A micro-USB port that is connected to the '32U4 processor (the one that runs the sketch.)
  • A full size USB port that is connected to the Ar9331 processor (the one that runs Linux.)

Port #1 is a device port: you can connect it to a host device like a computer, but you cannot connect another device to it. Using that port, when connected to a computer, your Yun can appear like a serial port, a keyboard, or a mouse. There is no native support for it to act like a mass storage device. There is the LUFA library that supposedly can make the Yun appear to the computer as if it were a mass storage device, but from the little I've read about it, it's difficult to implement and slow. I would also imagine that it takes up a lot of the limited code space you have in a sketch.

Port #2 is a host port: you can connect devices to it like keyboards, thumb drives, web cameras, etc, but you cannot connect it to another host like a computer.

You say the USB port is available outside of your enclosure, and that it has an "antenna" connected to it. It can't be strictly an antenna, that makes no sense. It must be some sort of device like a WiFi interface (which would be redundant since there is already one on the Yun) or a cellular radio, or some other sort of radio. If so, I'm assuming you are talking about the large Type A USB port that is the host port on the Linux processor. I don't know of a way to connect that port to another computer so that the computer thinks it is a mass storage drive.

Perhaps a solution is to plug a USB thumb drive into that port? You could do some Linux programming to look for new devices connected to the USB port, and if it's a mass storage device it could make a copy of the SD card data onto the USB drive. If you have some sort of user interface on your device, and can initiate a copy that would give you more control, but you should be able to set it up to automatically copy whenever a USB drive is mounted. That way, the idea would be to unplug your "antenna" and connect a USB drive to back up your data. Then, you would remove the USB drive and connect it to your computer to transfer the files. Basically, a kind of sneaker-net.

Getting the Yun to recognize the USB drive should be easy - just plug it in and should be automatically mounted.

Copying the files should be easy - it's just a shell script full of copy commands.

Detecting when the USB drive has been inserted and removed, and calling the copy script will be the trick. I'm sure it can be done, I just don't have enough Linux experience, especially with handling USB devices, to help with that part.

Because the SD card is handled by the Linux processor, and the USB host port is also handled by the Linux processor, adding this ability shouldn't really affect your sketch, it is really just a bunch of Linux programming.

First off, there are two USB ports on the Yun.
A micro-USB port that is connected to the '32U4 processor (the one that runs the sketch.)
A full size USB port that is connected to the Ar9331 processor (the one that runs Linux.)

Sorry, it seemed clear to me but it wasn't for you. I was talking about the type A USB port of the atheros.

You say the USB port is available outside of your enclosure, and that it has an "antenna" connected to it. It can't be strictly an antenna, that makes no sense. It must be some sort of device like a WiFi interface (which would be redundant since there is already one on the Yun) or a cellular radio, or some other sort of radio. If so, I'm assuming you are talking about the large Type A USB port that is the host port on the Linux processor. I don't know of a way to connect that port to another computer so that the computer thinks it is a mass storage drive.

You are right, I said "antenna" to make short but it is a Ralink chip with antenna. I configured the Yun to use this chip as the default WiFi interface.

Detecting when the USB drive has been inserted and removed, and calling the copy script will be the trick. I'm sure it can be done, I just don't have enough Linux experience, especially with handling USB devices, to help with that part.

You have a great idea, I did not think about that. I don't have a lot of Linux experience but I'm pretty sure it could work. I will search on the net to try this option and keep the thread up to date. Thank you !