Teensy 3.6 and SD program problems

Status
Not open for further replies.

spencoid

Well-known member
I bought a 3.6 a long time ago but never used it. I have an SD project so tried it.
It is behaving very strangely. I looked on the forum and elsewhere
but can not find an answer. I tries doing the 15 second reset thing but it
did not work. Here is the history: I succeeded at getting the sample
SD test to work. Then I added a simple while loop to test how long it
takes to write a test to the sd card 1000000 times. After that I
could "load" a new program and got no errors but the new program was
not loaded, the old one was not replaced. Now for the strangeness. I
could load blink and it blinked the LED but if I tried to load
another program, the old program was still there, not blink but the
previous one. Any suggestions as to what to try before I toss this. I
have spent about 2 hours and can not get it to do anything other than
what is described above.

I tried this on two computers with the same results but I don't think
I ever loaded the code listed below on the other computer. My first
thought was that arduino was using the wrong hex file but the right
hex is in the location listed by verbose compile output so i don't
think it is a software issue.
I have new 3.5s on the way and hopefully that will solve the problem. Never had a similar problem with anything before 3.5 and I have used quite a few of them over the years.

Code:
 /*
   SD card read/write

  This example shows how to read and write data to and from an SD card 
 file
  The circuit:
  * SD card attached to SPI bus as follows:
  ** MOSI - pin 11, pin 7 on Teensy with audio board
  ** MISO - pin 12
  ** CLK - pin 13, pin 14 on Teensy with audio board
  ** CS - pin 4, pin 10 on Teensy with audio board

  created   Nov 2010
  by David A. Mellis
  modified 9 Apr 2012
  by Tom Igoe

  This example code is in the public domain.

  */

 #include <SD.h>
 #include <SPI.h>

 File myFile;

 // change this to match your SD shield or module;
 // Arduino Ethernet shield: pin 4
 // Adafruit SD shields and modules: pin 10
 // Sparkfun SD shield: pin 8
 // Teensy audio board: pin 10
 //Teensy 3.5 & 3.6 on-board: BUILTIN_SDCARD
 // Wiz820+SD board: pin 4
 // Teensy 2.0: pin 0
 // Teensy++ 2.0: pin 20
 const int chipSelect = BUILTIN_SDCARD;

 void setup()
 {
  //UNCOMMENT THESE TWO LINES FOR TEENSY AUDIO BOARD:
  //SPI.setMOSI(7);  // Audio shield has MOSI on pin 7
  //SPI.setSCK(14);  // Audio shield has SCK on pin 14

  // Open serial communications and wait for port to open:
   Serial.begin(9600);
    while (!Serial) {
     ; // wait for serial port to connect. Needed for Leonardo only
   }


   Serial.print("Initializing SD card...");

   if (!SD.begin(chipSelect)) {
     Serial.println("initialization failed!");
     return;
   }
   Serial.println("initialization done.");

   // open the file. note that only one file can be open at a time,
   // so you have to close this one before opening another.
   myFile = SD.open("test.txt", FILE_WRITE);

   // if the file opened okay, write to it:
   if (myFile) {
     unsigned long start_time = millis();;
     unsigned long end_time;
     unsigned long diff_time;
 //    for (unsigned long i=0; i < 1000000; i++){
 //      myFile.println("102168");
 //    }
     end_time = millis();
     diff_time = end_time - start_time;
     Serial.print("diff time ");
     myFile.println(diff_time);
     // close the file:
     myFile.close();
     Serial.println("done.");
   } else {
     // if the file didn't open, print an error:
     Serial.println("error opening test.txt");
   }

   // re-open the file for reading:
   myFile = SD.open("test.txt");
   if (myFile) {
     Serial.println("test.txt:");

     // read from the file until there's nothing else in it:
     while (myFile.available()) {
         Serial.write(myFile.read());
     }
     // close the file:
     myFile.close();
   } else {
     // if the file didn't open, print an error:
     Serial.println("error opening test.txt");
   }
 }

 void loop()
 {
     // nothing happens after setup
 }
 
Last edited by a moderator:
p#1 code worked on T_3.6 here.

Edited this to last line of setup and upload worked and this printed : Serial.println("Done - exit setup()");

Did a Reset and it ran again, and after three runs there are three 0's printed since no millis() elapse between the times marked.


The T_3.6 is a bit tricky without the RED LED of the T_4.x.
>> Starting a second timer and pressing for 15 seconds then releasing should work.

As far as 'old code' showing up - the only way that seems possible is if TeensyLoader is active with that file at hand and the Button were pushed that will cause that code to be uploaded.

The Teensy only ever holds a single program and on programming all prior code is formatted away during the upload that resides in the same area.
 
my code has the for statement commented out but when I load the program it runs the old program. the folder in which the bin is supposed to be is the right one. i even copied the text of the source to a new sketch and it builds another code folder and again the bin is right. Again the strangest thing is that I can load blink and only blink and get a working blink. then loading the original sketch with the for staement does not update it, it still tries to do the for statement.
is it possible that I fucked something up by having a 1000000 count for statement? Did I kill the bootloader some how? I tried reburning the bootloader but get this error
Arduino: 1.8.15 (Windows 10), TD: 1.54, Board: "Teensy 3.6, Serial, 180 MHz, Faster, US English"

Error while burning bootloader: missing 'bootloader.tool' configuration parameter

i think i should just toss this almost new 3.6 and hope the 3.5s on the way will work as do all the 3.2s I also tested on. I just got the 3.5 and it does exactly the same thing so the 3.6 could be good. this is so strange. i have no idea what to try next.
 
my code has the for statement commented out but when I load the program it runs the old program. the folder in which the bin is supposed to be is the right one. i even copied the text of the source to a new sketch and it builds another code folder and again the bin is right. Again the strangest thing is that I can load blink and only blink and get a working blink. then loading the original sketch with the for staement does not update it, it still tries to do the for statement.
is it possible that I fucked something up by having a 1000000 count for statement? Did I kill the bootloader some how? I tried reburning the bootloader but get this error
Arduino: 1.8.15 (Windows 10), TD: 1.54, Board: "Teensy 3.6, Serial, 180 MHz, Faster, US English"

Error while burning bootloader: missing 'bootloader.tool' configuration parameter

i think i should just toss this almost new 3.6 and hope the 3.5s on the way will work as do all the 3.2s I also tested on. I just got the 3.5 and it does exactly the same thing so the 3.6 could be good. this is so strange. i have no idea what to try next. i downloaded new arduino and teensy. i deleted everything found with arduino init other than my programs folder. i rebooted. it is still the same with 3.5 and 3.6. 3.2 works fine. i upl;oaded many programs and they all work as they should. there is something wrong with the recent version or arduino, teensyduino and the 3.5 and 6
 
Some confusion somewhere - The T_3.6 should do only what it is programmed to do - and once reprogrammed there is no way it can run any prior code without have it programmed again over USB.

Perhaps your Arduino IDE install is corrupted? It has happened a few times where clean install of IDE and then TeensyInstaller made all well.

If that is corrupted the T_3.5 may not be any more workable.

Seeing anything like this is odd and bad : Error while burning bootloader: missing 'bootloader.tool' configuration parameter

Uncommenting the for 1,000,000 it runs. Ran that twice then put the comments back and ran again and it worked as expected
Code:
// end first run
// ...
102168
10329
Done - exit setup()

// end second run
// ...
102168
10329
Done - exit setup()

// end third run with 1M commented again
// ...
102168
102168
10329
0
Done - exit setup()

This shows writing 1M copies of the number line to the file takes over 10 seconds.

NOTE: When running after there are some 1M copies of '102168' in the file this code:
Code:
     while (myFile.available()) {
         Serial.write(myFile.read());
     }
Will not complete ONLY after showing all of the lines in the file. That takes some time and requires a healthy Serial Monitor to not possibly have the Serial USB get into an odd state.

And edit to the code to see how long the print takes to complete - for two million entries : diff time 28945

That is a long time to wait and any attempt to program during that time will likely fail with the USB being busy.
 
i have no idea what to try next.

I have the feeling that we know only a part of the story.

As @defragster said, there is only a single program on any teensy, namely the last one you programmed.
If the teensy after reprogramming runs a different program, this only can mean that the teensy loader was passed or is using the wrong program.
To avoid this, simply kill the teensy loader (teensy.exe). I do this also when changing Teensy model (e.g. 3.5 -3.6 etc)

Also how did you install the system. E.g. Teensyduino does not work with Arduino Windows App.
 
Sorry about all the time I wasted of others

OMG I feel like such an idiot. There is nothing wrong with anything. I also wasted a ton of time for myself. The serial print I was seeing was the reading of the SD card and printing it. This was all my fault but I do have an excuse:)

I have stage four prostate cancer and am on ADT which has serious side effects including "brain fog" fatigue that is severe at times. I used to be pretty smart but every day is different. If I get a lot of exercise I can have a fairly clear headed day but I have been off my regular routine. For a few days I was really clear headed and was able to finish some programs that I wanted to finish before my mental state really collapsed. So i thought I was OK and stopped questioning my mental abilities but obviously not. When I was really messed up i missed the most obvious programming errors but thought I was beyond that. Obviously not.

I am really sorry about the time I have wasted of others. I need to learn to evaluate my abilities before programming and take a long vacation or just stop if I am not up to the task. This is really difficult for me, I have always been the smart guy in any crowd. I am just an amateur programmer but have managed to get buy with the occasional help of this forum and others. But now I am almost as dumb as some of the people I have spent my life avoiding. It is supposedly possible to take a vacation from the treatment which others have done when they could not stand the side effects. I have an appointment with my medical oncologist in about a week and I might discuss this and also the possibility of taking adderall. If I lose the ability to program and also ride my bike I might as well kill myself. Please don't take this as something that needs to be reported, I will probably have a different attitude if I do fall apart this much. I have always said that it is impossible to understand the state of mind of another until you experience a very similar condition that affects them.
 
You are right you only had part of the story. I did not explain my crippled mental state. My most recent posting explains all of that. I got this reply just after I finished posting. Again,sorry for any time that my confusion has wasted. I will try to figure out how to better address my mental state before posting. I have gotten good advise from this forum and hope to in the future but if I post anything really seems too wacky please remind me to look for the obvious. If I had been more clear about what I was seeing on the serial monitor and maybe attached a screenshot someone would have probably figured this out. Low testosterone can be bad for old guys but none at all is a real challenge to deal with.
 
@spencoid - No problem - glad resolution was simple enough - and happy to help.

All the best with your treatment!

This is certainly true - though I've seen enough to know : "it is impossible to understand the state of mind of another ..."
> and seen it to learn that when in an affected state - they may be the last to recognize it.
 
I should have said I have always said that it is impossible to understand the state of mind of another (or yourself at another stage) until you experience a very similar condition.
 
Status
Not open for further replies.
Back
Top