Go Down

Topic: Yun Rev 2 will not address SD card through bridge (Read 28327 times) previous topic - next topic

mcdmdphd

Feb 23, 2020, 06:05 pm Last Edit: Feb 23, 2020, 06:31 pm by mcdmdphd Reason: add a P.S.
I had a power surge at home in Knoxville which damaged several original Yun cards. They were running seismometers using a rather long and complex program (an older version of which can be found on this project page

-> https://hackaday.io/project/20735-device-for-seismic-noise-analysis   <-  

under the "files" section.

I bought two rev 2 boards, initialized them to be able to access the Linux side with Putty and Filezilla, installed my most recent working program and -- no data was logged. I have tried everything and read every relevant topic on this forum a hundred times, but the program that used to work on the original Yun can not create files or directories on Rev 2. I have rebooted, reinstalled the system to the factory original several times, tried every "fix" offered here for SD card issues, re-formatted the cards with FAT and FAT32, tried 3 different clock libraries, 3 different clock modules, added an arduino folder to the root directory, added delays after Bridge.begin() and Filesystem.begin(), tried all kinds of different sda1 settings with the web interface, etc. Attempts to get the program to log data on the SD card have failed at every turn. Other programs like datalogger programs downloaded from the forum (written in the past for the original Yun have failed. I can access the SD card and read and write files to it wirelessly with Putyy and Filezilla. No problem.

I remember a couple of years ago that I had a similar issue a couple of years ago that was fixed by making a small change in an obscure file recommended by a poster on this or maybe another forum. Can't remember what it was or where I found that post.

HEEEELP!!!!

If you have a look at the program, please don't be too critical of the sloppy nature of the programming or (especially!!!!) the comments in the program. I would love to hear a real wonk tell me what I am doing wrong, suggest something else to try or tell me if this is truly a bug in the new Yun Ver 2.

I am about to return these to Amazon and pay extra for the old version - some are still available out there. But that would be an end to the future development of this project.

If anyone with real skills out there is interested on working on a socially meaningful project, this is it and I could sure use a partner!!!!!! Or two... :smiley-confuse:

P.S. I am not interested in doing anything with Disk Expander - been there & done that in the past and i will never go down that rat hole of undocumented nonsense again!

pert

When something is going wrong, it's very helpful to remove as many variables from the situation as possible. Your sketch is very complex, so it makes troubleshooting very difficult. It's likely that much of the code in your sketch is completely irrelevant to the problem you're having, so it only makes troubleshooting more difficult, and you getting assistance less likely. The solution is to determine the absolute minimum amount of code that can still reproduce the problem. Towards that goal, try uploading this sketch to your Yun Rev. 2:
Code: [Select]
#include <FileIO.h>

void setup() {
  // Initialize the Bridge and the Serial
  Bridge.begin();
  Serial.begin(9600);
  FileSystem.begin();

  while (!SerialUSB); // wait for Serial port to connect.
  SerialUSB.println("Filesystem datalogger\n");
}


void loop() {
  File dataFile = FileSystem.open("/mnt/sda1/datalog.txt", FILE_APPEND);

  if (dataFile) {
    SerialUSB.println("success opening datalog.txt");
    dataFile.close();
  }
  else {
    SerialUSB.println("error opening datalog.txt");
  }

  delay(5000);
}

Then open Serial Monitor. After it starts running, do you see "success opening datalog.txt" or "error opening datalog.txt"?

mcdmdphd

You program worked - thanks so much! I was convinced that it was a hardware or bridge software problem.I'll try to figure out what I'm doing wrong based on this.

pert

That's good news! Now you are able to put the board in a working and a non-working state, which is a good position to be in for troubleshooting. You know the problem lies somewhere in the difference between the two sketches. Unfortunately, there is a lot of difference between the two. My advice would be to start systematically removing code from your original sketch, testing to be sure the problem still occurs after each segment of code is removed. If you can get it down to the minimum amount of code that will still cause the problem, the problem will likely become clear. If not, we will likely be able to help you out once we see that minimal demonstration sketch.

mcdmdphd

#4
Feb 23, 2020, 11:18 pm Last Edit: Feb 23, 2020, 11:22 pm by mcdmdphd
Uhh - spoke too soon, Pert. The program you suggested works only if the Yun is connected by serial cable to my computer. The following version does not create or append datalog.txt when uploaded and monitored via wifi, whether or not the Serial.begin line is commented, whether the other serial print line are commented and whether or not the 1st two delays are included. Huh? Ideas?




#include <FileIO.h>

void setup() {

  // Initialize the Bridge and the Serial
  Bridge.begin();
  delay(5000);

  Serial.begin(9600);
  delay(5000);

  FileSystem.begin();
  delay(5000);
 
  //  while (!SerialUSB); // wait for Serial port to connect.
  //  SerialUSB.println("Filesystem datalogger\n");
}

void loop() {
  File dataFile = FileSystem.open("/mnt/sda1/datalog.txt", FILE_APPEND);

  dataFile.print("Just print something for once! ");
 
  dataFile.println();
 
  dataFile.close();

  delay(5000);
 
  //  if (dataFile) {
  //    SerialUSB.println("success opening datalog.txt");
  //    dataFile.close();
  //  }
  //  else {
  //    SerialUSB.println("error opening datalog.txt");
  //  }

 
}

mcdmdphd

I have now officially tried everything. Conclusion?

2 defective cards, or a real problem with Rev 2. The bottom line is that my programs that work on the original Yun do not work on Yun Rev 2.

If anyone has ever written a program for Yun Rev 2 that writes data to the SD card without being connected by USB serial to a computer, I would appreciate you posting it so I can try it on my cards.

mcdmdphd

#6
Feb 27, 2020, 06:06 am Last Edit: Feb 27, 2020, 01:12 pm by mcdmdphd Reason: add a pic
There are now well over a thousand views and nobody has posted a response indicating that they have been able to get the file system to access the SD card without the USB cable plugged in to a computer. I got two brand new Yun Rev 2 cards today and they again will not access the card. A program that works on Version 1 just does not work on Rev 2. The cards are not compatible.

Since arduino has provided us with no documentation whatsoever of what the changes are between Version 1 and Rev 2, the situation looks hopeless for me. I am returning all four of my Rev 2 cards (Thanks, Jeff Bezos and Amazon prime!)

Next stop - chinese Yun clone.


mcdmdphd

The incompatibility arises from the presence of  RTC modules and their associated drivers. If I abandon the use of an external RTC module I can write to the SD card. Many different RTC modules were tried. Again, this is an actual difference between the first Yun and Rev2.

ShapeShifter

So the RTC is interfering. Which module is it, and how is it connected? With more details, maybe we can figure out if it is a hardware or software conflict.

Part of the problem with getting a reply is that I don't think there are many of the previously active forum members who have a Rev 2 board. I don't, and since there is scant documentation on the differences, as you pointed out, it's hard to give advice other than general tips as was offered by pert.

WhidbeyBill

Hi guys, For what's it worth, I have sketches writing/reading uSD cards that run on 3 versions, original Yuns, (I call 'em Rev 0), The Yun Rev 1's aka the DogHunter Arduino.org board, and the latest release Yun Rev 2. With the exception of the pre-mapped interrupt for monitoring Linux boot, I have found no differences in operation. My ONE exception, which drew me to this topic, is that the FAT32 diskscan (fsck) does not work on the Rev 2 Openwrt compilation. If a write operation on the Rev2 board is somehow fragmented, the OS marks the Fat32 partition as READ-ONLY and the sketch will no longer write data. I found a couple of workarounds, but shutting down removing the SD and checking in Windows USB adapter is not a practical solution. I have posted this on the forum, but as yet, have no idea if The Openwrt compilation has been updated for the YUN to fix this. The system log reflects the failure to run 'dosfsck' and I added a bit of code to rc.local to run  /usr/sbin/fsck.fat -a /dev/sda1 and this puts the collected fragment on the /sda1 partition.

Go Up