Arduino Yun SD problem

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
williamj
 
Posts: 2
Joined: Sat Jan 12, 2013 1:59 pm

Arduino Yun SD problem

Post by williamj »

I recently got my Arduino Yun from Adafruit (Order Confirmation No: 441109) and I have a problem getting it to write to a SD card. Basically, I can get the SD card to work via a USB card reader attached to the Host USB port on the Yun, but I can not get it to work via the SD card slot on the Yun.

To test writing to the SD card, I am using the Datalogger example program from Arduino
http://arduino.cc/en/Tutorial/YunDatalogger

My SD card is a 16GB card with MS-DOS (FAT32) format. I created an arduino folder by connecting it to my Mac via the card reader.

I reset the Yun (held down the WiFi button for more than 30 seconds) so that I could start from a clean state.

Starting with SD card in the Yun slot, I tried to see if I could see it from ssh.

root@billsyun:~# ls -la /mnt
drwxr-xr-x 2 root root 3 Aug 19 2013 .
drwxr-xr-x 1 root root 0 Mar 17 16:31 ..

root@billsyun:~# ls -ls /dev/s*
0 brw-r--r-- 1 root root 8, 0 Dec 31 1969 /dev/sda
/dev/shm:

I uploaded the data logger program and the Serial window showed:

Filesystem datalogger

error opening datalog.txt
error opening datalog.txt
error opening datalog.txt

I moved the SD card to the USB card reader and the program started writing values into the Serial window:

03/17/14-16:42:32 = 242,229,221
03/17/14-16:42:47 = 246,235,229
03/17/14-16:43:02 = 245,234,227
03/17/14-16:43:18 = 240,230,226

I could also see the SD disk when searching:
root@billsyun:~# ls -ls /dev/s*
0 brw-r--r-- 1 root root 8, 0 Dec 31 1969 /dev/sda
0 brw-r--r-- 1 root root 8, 16 Mar 17 16:42 /dev/sdb
0 brw-r--r-- 1 root root 8, 17 Mar 17 16:42 /dev/sdb1

root@billsyun:~# ls -la /mnt
drwxr-xr-x 1 root root 0 Mar 17 16:42 .
drwxr-xr-x 1 root root 0 Mar 17 16:31 ..
lrwxrwxrwx 1 root root 9 Mar 17 16:42 sd -> /mnt/sdb1
drwxr-xr-x 7 root root 32768 Dec 31 1969 sdb1

I could also look in the file /mnt/sdb1/datalog.txt and the data was indeed there.

When I moved the SD card from the USB reader back to the SD slot, the program went back to

error opening datalog.txt

I found a link that seems to indicate that some Yuns have a problem with their SD slot.
http://forum.arduino.cc/index.php?PHPSE ... c=201829.0

Is there something else that I should look at, or is likely to be a bad slot?

User avatar
williamj
 
Posts: 2
Joined: Sat Jan 12, 2013 1:59 pm

Re: Arduino Yun SD problem

Post by williamj »

One more problem: I think a linux help problem:

After I put the SD card back in the USB reader, I reloaded the data logger program and it seemed to work, but the data is being written some odd place. When I look for the card I get:

root@billsyun:/mnt/sda1# ls -la /mnt
drwxr-xr-x 1 root root 0 Aug 8 2013 .
drwxr-xr-x 1 root root 0 Mar 17 16:31 ..
lrwxrwxrwx 1 root root 9 Mar 17 16:42 sd -> /mnt/sdb1
drwxr-xr-x 7 root root 32768 Dec 31 1969 sda1
drwxr-xr-x 2 root root 0 Mar 17 17:07 sdb1
drwxr-xr-x 2 root root 0 Mar 17 16:52 sdc1

So, sda1 is my card. I can look at the data on the card and it doesn't have the most recent data. If I look at sdb1, there is a datalog.txt file with the newest data.

My guess is that I need to unlink the "sd -> /mnt/sdb1" somehow.

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Arduino Yun SD problem

Post by adafruit_support_mike »

The commands you're using to locate the SD card are a bit harder to deal with than the usual method: `df -k`. That will list all the filesystems the OS knows about, their mount points, and the amount of data/free space on each one.

At a guess, I'd say the OS is mounting the SD card to a new directory every time you hot-plug it to avoid filesystem corruption issues. The OS doesn't know which processes are using a filesystem, so it can't notify everyone when the filesystem is unmounted. If you unmount one filesystem then mount another to the same point, All Kinds Of Badness can ensue. It's safer to leave each mount point empty after unmounting the filesystem. The counter should reset when you reboot the Yun.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”