Forum Rule: Always post complete source code & details to reproduce any issue!
Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 26 to 50 of 55

Thread: SD card on a 4.0

  1. #26
    Senior Member
    Join Date
    Sep 2019
    Posts
    233
    Deleted the repeated SD.h folder, so I assume it's using the correct one now.

    But, throws this up? AudioStreams? Eh?

    Code:
    Build options changed, rebuilding all
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4\AudioStream.cpp: In member function 'int AudioConnection::connect(AudioStream&, unsigned char, AudioStream&, unsigned char)':
    
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4\AudioStream.cpp:339:7: warning: unused variable 'cr' [-Wunused-variable]
    
       int cr;
    
           ^
    
    Memory Usage on Teensy 4.0:
      FLASH: code:117844, data:27800, headers:8976   free for files:1876996
       RAM1: variables:77792, code:113768, padding:17304   free for local variables:315424
       RAM2: variables:12384  free for malloc/new:511904

  2. #27
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    8,281
    Quote Originally Posted by SteveSFX View Post
    Deleted the repeated SD.h folder, so I assume it's using the correct one now.

    But, throws this up? AudioStreams? Eh?

    Code:
    Build options changed, rebuilding all
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4\AudioStream.cpp: In member function 'int AudioConnection::connect(AudioStream&, unsigned char, AudioStream&, unsigned char)':
    
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4\AudioStream.cpp:339:7: warning: unused variable 'cr' [-Wunused-variable]
    
       int cr;
    
           ^
    
    Memory Usage on Teensy 4.0:
      FLASH: code:117844, data:27800, headers:8976   free for files:1876996
       RAM1: variables:77792, code:113768, padding:17304   free for local variables:315424
       RAM2: variables:12384  free for malloc/new:511904
    Its not throwing an error but giving a warning - I am seeing that periodically as well - you can safely ignore it. Honest know what it means but not sure why we are seeing it.

  3. #28
    Senior Member
    Join Date
    Sep 2019
    Posts
    233
    OK. A bit of fiddling, and declaring the includes in a different order has resulted in success so far.
    I have managed to get it to compile with the code in post #15 with littleFS.h and MTP_teensy.h.

    New flash memory IC's arriving from RS tomorrow, so I can then try and get my head around reading and writing images to the flash memory (no idea at the moment... Google here I come).

    Thanks for your help all

  4. #29
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    26,563
    Quote Originally Posted by SteveSFX View Post
    Quite possibly it is using the wrong sd library, but does that matter?
    Yes, it absolutely does matter.

    A lot of work goes into each Teensyduino release to test a set of libraries which work together. Starting with Teensyduino 1.54, we abandoned the ancient SD library (which only supported 8.3 filenames and up to 32GB cards) in favor of SdFat with SD replaced by a thin wrapper which just uses SdFat. We've also defining "File" as a base class, so libraries which use files aren't limited to only SD cards. More recently, work has been under way to extend File, SD, SdFat, LittleFS, USBHost_36 in a variety of ways (mostly concerning detecting media removal & changes) to integrate with MTP.

    If you copy SD into your {Documents}/Arduino/libraries folder, you're overriding all that effort we spend to make a set of libraries all work together properly. Especially if you have mismatched copies of SD & SdFat, or older versions libraries meant to work with the newer File class, you're just causing yourself a lot of pain.


    I hate changing things when it's working!
    Yeah, I get the "ain't broke, don't fix" approach. Obviously it is broken, because you're getting compile errors.

    Keeping everything static only works if you apply that approach to everything. Upgrading other stuff but keeping an old copy of SD library is just asking for things to not work. We develop and test this stuff as a set of libraries which are meant to work together.


    As for all that faff trying to use other versions of the IDE.....
    The good news for you is Arduino IDE (at least the pre-2.0 versions) does support a way to keep everything self-contained. It's called Arduino Portable Installation. It was originally meant for university students using the school's computers which change frequently or get wiped and reinstalled on a regular basis. Portable mode puts everything (all settings and saved files) into the Arduino software folder so you can have a self-contained copy of Arduino on portable media like a USB flash drive.

    Teensyduino installer will automatically recognize if your copy of Arduino has the portable folder and perform the installation accordingly.

    Sadly, portable mode doesn't work on modern MacOS. But it's great on Windows and Linux. Since you're using Windows, and you desire to keep your configuration static, please do yourself a huge favor and try using portable mode. You can have as many copies of Arduino in portable mode as you like. All of them will be fully self contained and unable to affect each other. Of course the main caveat to more than 1 copy of Arduino on any PC is you need to be aware of which version you're running. That's easy if you are in the practice of first opening Arduino, and then opening your code from Arduino's File > Open or File > Sketchbook or File > Examples menu. But if you are in the practice of clicking your code in Windows Explorer or other programs, then Windows will need to choose which copy of Arduino to run, and it probably will pick the wrong one.


    life's too short! lol
    I really hope you can understand the perspective from the point of view of developing these libraries. It could easily also be said "life is too short" regarding supporting software scenarios where a user intentionally mismatches a library like SD with different versions of SdFat or Teensy core library which is was never meant to use.
    Last edited by PaulStoffregen; 06-23-2022 at 12:16 PM.

  5. #30
    Senior Member
    Join Date
    Sep 2019
    Posts
    233
    Err... stupid here again

    In my post #16

    There is a line:

    #define PNG_FILENAME "/TG2.png" // Temp PNG file to load

    How the heck do I change that to a variable I can then influence with any file name I require? (Not TG2.png).
    At the start I will set it to a default filename and then later in the code I will change it to what I want.

    I assumed I would declare char PNG_FILENAME = "/TG2.png" ; or something, but 90 mins later and a whole host of errors thrown up all over the shop.... hmm

  6. #31
    Senior Member
    Join Date
    Apr 2020
    Location
    DFW area in Texas
    Posts
    416
    Quote Originally Posted by SteveSFX View Post
    How the heck do I change that to a variable I can then influence with any file name I require? (Not TG2.png).
    At the start I will set it to a default filename and then later in the code I will change it to what I want.
    @SteveSFX:

    Google is your friend !! The answer is quickly found by searching for "arduino SD card variable filename" . . .

    Just remember to make your array big enough to hold the *longest* filename that you expect to require.

    Good luck & have fun !!

    Mark J Culross
    KD5RXT

  7. #32
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    10,771
    As @kd5rxt-mark mentioned use an array...

    Quick follow on to that:

    Today @mjs513 posted about a new library for the round display in the thread: https://forum.pjrc.com/threads/70542...and-Teensy-4-x

    This is based on my ILI9341_t3n library... Probably at some point we code factor some of these libraries, like Adafruit did, but...

    I believe he may be adding the support for it into my: mtp_tft_picture_view github project which can be configured to show pictures stored on SD drives to several different display types,
    like (ILI9341, ILI9488, ST7735/89, RA8875, RA8876)

    Maybe at some point we will also port the simple viewer that we added to the MTP_Teensy project stripped down just for the ILI9341_t3 library

  8. #33
    Senior Member
    Join Date
    Sep 2019
    Posts
    233
    OK. I did Google. I believe my method using char was correct, it just doesn't work with the png image display routine.

    Been fun, but progress is slow so time to park this for a while I think.

    Post 32.... New library

    What am I missing?

    GC9A01A_t3n_font_Arial.c is in the SRC folder. I might actually load something one day and it compiles first time

    Code:
    C:\Users\steve\Documents\Arduino\libraries\GC9A01A_t3n-main\src\GC9A01A_t3n_font_Arial.c:1:36: fatal error: ili9341_t3n_font_Arial.h: No such file or directory
    
    compilation terminated.
    
    Error compiling for board Teensy 4.0.
    Last edited by SteveSFX; 06-25-2022 at 04:56 PM.

  9. #34
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    10,771
    Looks like we missed one… will look soon but network down…

  10. #35
    Senior Member
    Join Date
    Sep 2019
    Posts
    233
    Thanks. I think I sounded ungrateful there! I am not.... thank you for all your time and attention. It's user error 99.9% of the time!

  11. #36
    Senior Member
    Join Date
    Apr 2020
    Location
    DFW area in Texas
    Posts
    416
    Quote Originally Posted by SteveSFX View Post
    OK. I did Google. I believe my method using char was correct, it just doesn't work with the png image display routine.
    @SteveSFX:

    No...you are close to being in the same neighborhood, however, it seems that you are still missing the detailed understanding of a very important aspect in your declaration . . . take note of the RED square brackets below, which tells the compiler that you want to declare an array of chars:

    Code:
    I assumed I would declare char PNG_FILENAME[] = "/TG2.png";
    Without those square brackets, your original declaration was telling the compiler that you want a variable capable of storing a single character, but you are trying to stuff eight characters (plus a NULL terminator) into it !! You may not get what you expected from your original declaration (& the compiler may even try to give you a hint, complaining that your initializer exceeds the size of your declaration) !!

    If you include the square brackets as required, but you don't put anything between the brackets in the declaration (which is perfectly permissible), you'll get an array just big enough to hold the filename that you initialized it with. So, my earlier point was my feeble attempt to raise your awareness of the following: if you expect to require a filename larger than the one used to initialize your array, you'll need to specify the maximum length that you'll require (& don't forget to add one additional character to the count for the NULL terminator) in the declaration. For example, if you require "/0123456789ABCDEF.txt" as your maximum filename, that will be 21 characters, plus one for the NULL terminator, resulting in the following declaration:

    Code:
    char PNG_FILENAME[22] = "/TG2.png";
    Hope that makes the specifics of your required filename variable declaration more clear . . .

    Mark J Culross
    KD5RXT

  12. #37
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    10,771
    Sorry still over cell connection

    Or if using SD.h then instead hard code…

    Could use MAX_FILENAME_LEN
    which is a define in that header file

    Edit I believe font files were fixed so you may want to sync up

  13. #38
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    8,281
    Used an approach that @KurtE used:

    Code:
    #define SD_CS BUILTIN_SDCARD
    File imageFile;
    const char *name = nullptr;
    and in the body (setup in my case)
    Code:
     imageFile = SD.open("Horizon_GroundSky.bmp", FILE_READ);
      name = "Horizon_GroundSky.bmp";
      bmpDraw(imageFile, name, true);
    
      imageFile = SD.open("Indicator280.bmp", FILE_READ);
      name = "Indicator280.bmp";
      bmpDraw(imageFile, name, true);

  14. #39
    Senior Member
    Join Date
    Sep 2019
    Posts
    233
    This is what I had ... char PNG_FILENAME[22] = "/TG2.png";

    This is what I get


    Code:
    In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/Print.h:38:0,
    
                     from C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/Stream.h:24,
    
                     from C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/HardwareSerial.h:115,
    
                     from C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/WProgram.h:46,
    
                     from C:\Users\steve\AppData\Local\Temp\arduino_build_771662\pch\Arduino.h:6:
    
    Gauges_v14: In function 'void* myOpen(const char*, int32_t*)':
    Gauges_v14:262: error: expected ')' before 'PNG_FILENAME'
         Serial.println(F("ERROR: Failed to open " PNG_FILENAME " file for reading"));
    
                                                   ^
    
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/WString.h:45:58: note: in definition of macro 'F'
    
     #define F(string_literal) ((const __FlashStringHelper *)(string_literal))
    
                                                              ^
    
    Gauges_v14:262: error: expected ')' before ';' token
         Serial.println(F("ERROR: Failed to open " PNG_FILENAME " file for reading"));
    
                                                                                     ^
    
    Gauges_v14:262: error: expected ')' before ';' token
    In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/Print.h:38:0,
    
                     from C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/Stream.h:24,
    
                     from C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/HardwareSerial.h:115,
    
                     from C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/WProgram.h:46,
    
                     from C:\Users\steve\AppData\Local\Temp\arduino_build_771662\pch\Arduino.h:6:
    
    Gauges_v14:263: error: expected ')' before 'PNG_FILENAME'
         gfx->println(F("ERROR: Failed to open " PNG_FILENAME " file for reading"));
    
                                                 ^
    
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/WString.h:45:58: note: in definition of macro 'F'
    
     #define F(string_literal) ((const __FlashStringHelper *)(string_literal))
    
                                                              ^
    
    Gauges_v14:263: error: expected ')' before ';' token
         gfx->println(F("ERROR: Failed to open " PNG_FILENAME " file for reading"));
    
                                                                                   ^
    
    Gauges_v14:263: error: expected ')' before ';' token
    Multiple libraries were found for "SD.h"
     Used: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD
     Not used: C:\Program Files (x86)\Arduino\libraries\SD
    Multiple libraries were found for "SdFat.h"
     Used: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SdFat
     Not used: C:\Users\steve\Documents\Arduino\libraries\SdFat_-_Adafruit_Fork
     Not used: C:\Users\steve\Documents\Arduino\libraries\SdFat-master
    Multiple libraries were found for "Adafruit_NeoPixel.h"
     Used: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_NeoPixel
     Not used: C:\Users\steve\Documents\Arduino\libraries\Adafruit_NeoPixel-master
    expected ')' before 'PNG_FILENAME'
    Got some new duplicate library errors now. Doing my head in this!

  15. #40
    Senior Member
    Join Date
    Sep 2019
    Posts
    233
    Well I have a library called 'ILI9341_fonts-master' and it contains font_Arial.h.

    Yet... duplicate libraries and no compiling. Think my IDE is broken / a mess. Time to play Minecraft instead

    Code:
    Multiple libraries were found for "font_Arial.h"
    C:\Users\steve\Documents\Arduino\libraries\GC9A01A_t3n-main\src\GC9A01A_t3n_font_Arial.c:1:36: fatal error: ili9341_t3n_font_Arial.h: No such file or directory
    
     Used: C:\Users\steve\Documents\Arduino\libraries\ILI9341_fonts-master
    compilation terminated.
    
     Not used: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\ILI9341_t3
    Error compiling for board Teensy 4.0.

  16. #41
    Senior Member
    Join Date
    Sep 2019
    Posts
    233
    OK. SD card and filenames all sorted. Binned it all, found another system I have used before and we are all working.

    Gave up on the new screen library. The one I have works, so I will stick with that.

  17. #42
    Senior Member
    Join Date
    Sep 2019
    Posts
    233
    Display working fine..... but

    Add in my W25Q128JV flash memory IC and the screen corrupts.

    Seems to be when I connect any of the SPI pins
    Just for sanity:

    W25Q128JV
    1 = CS (has it's own chip select pin)
    2 = Dout (Shared with spi screen)
    3 - WP - Tied to 3.3v
    4 - 0v
    5 - Din (Shared with spi screen)
    6 - Clk (Shared with spi screen)
    7 - Hold - Tied to 3.3v
    8 - 3.3v

    Thoughts?
    New IC, so should be good

  18. #43
    Senior Member
    Join Date
    Oct 2019
    Location
    Calgary
    Posts
    130
    Are both the screen and memory IC tri-stating whatever signal is connected to MISO when they're not selected?

  19. #44
    Senior Member
    Join Date
    Sep 2019
    Posts
    233
    eh? Me thick.

    Not sure what is occuring.

    I have an SD module and the screen connected to the SPI pins. Each have their own CS.

    Added the flash IC and literally any of the flash SPI connections throws the screen (and sometimes the SD) into a fizzy. Even SCK, Miso or Mosi on their own which seems really odd. Hope it's not a dud IC... took RS forever to send it.

  20. #45
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    4,217
    Here is the paper that describes tri-stating (as well as using pull-up resistors on the CS pins, and making sure your libraries use transactions):


  21. #46
    Senior Member
    Join Date
    Sep 2019
    Posts
    233
    My concern is that it causes issues with any one of the SPI pins connected. Surely that would not be the case?

  22. #47
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    26,563
    Did you try the 2 resistor test on the MISO signal? (described in "Step 2: Proper MISO Tri-State Behavior" at the link MichaelMeissner shared)

    When all SPI devices have their CS pins high (not selected) your voltmeter should measure approx 1.65 volts on MISO because the 2 resistors. If you get a logic high near 3.3V or low near 0 volts, then start disconnecting the SPI devices from MISO until you find the one that's acting naughty.

  23. #48
    Senior Member
    Join Date
    Sep 2019
    Posts
    233
    OK. I will grab some resistors in the morning and have a go. It must be the flash acting up, as the SD and screen play together fine (well.. that's my logic)
    Thanks

  24. #49
    Senior Member
    Join Date
    Sep 2019
    Posts
    233
    It would appear that this flash IC is not behaving at all.

    All connected with a 10k pullup on the CS pin. All OK.
    Connect the SCK and the bus freezes. I'll grab some more 10k's tomorrow and look at that thread, but something is odd.
    Last edited by SteveSFX; 06-28-2022 at 10:19 PM.

  25. #50
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    26,563
    Quote Originally Posted by SteveSFX View Post
    It would appear that this flash IC is not behaving at all. ... something is odd.
    I would be very surprised if a W25Q128JV chip is causing SPI bus trouble.

    But we really don't even know if SPI bus problems, like a device driving MISO, are really the issue here. It's just a guess.

    If you don't see anything conclusively wrong with the 2 resistor MISO test, maybe this time (now 50th messages on this thread) might be a good time to consider a better way of engaging on this forum. You can see we're trying to help. But it's a lot of guesswork based on piecewise disclosure of what you're doing, with a lot of info missing. Other than msg #16 with 3 very nice photos of only the display, we can't see the actual hardware you're using. I just skimmed through all 49 messages and didn't see anywhere a clear picture of all the hardware you've connected, especially the SD card hardware.

    We might be able to help much more if you would give this thread something of a fresh start by summarizing all the hardware and software you're using. I doubt anyone will be able to reproduce the problem, since you have a rather unusual display. But still, writing a detailed message with a complete set of hardware & software info which any of us could theoretically use to reproduce the problem could really help give all of us a much clearer idea of what you're doing.

    We're much better at guessing what's wrong when we can see better.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •