SerialFlash usage SPI1 startup stops Touch function on SPI ILI9341

defragster

Senior Member+
Got a board hosting a T_4.1 with SPI ILI9341 and a bunch of other stuff including 1Gb SerialFlash chip on SPI1

Removing everything but those thing from the DEMO sketch here: https://github.com/Defragster/MiniBaseBd/blob/main/Demo_Repro/Demo_Repro.ino

Followed the code in SerialFlash and things look to use the passed SPI1 object with no reason to conflict.

Didn't look into ILI9341_t3. It works fine in the above sketch when this line #7 is commented:
#define THIS_GOOD // USE THIS TO TOGGLE SERFLASH

I migrated from the supplied board to a PCB with T_4.1 and three other sets of sockets and saw the same behavior with the supplied DEMO then started removing/cutting and without the other activity/devices the behavior repros here.

Display is an old PJRC 2.8" - supplied was a 3.2"and both exhibit the same behavior on both 'boards'
Supplied board had SMD 1Gb Winbond - here in use is a 64MB Winbond. Both work with SerialFlash examples [Erase, HdwTest, Copy_SD, ListFiles] wired to SPI1 (with 2 ALT pins as noted in code)

Activation for use of SerialFlash allows full display function on SPI but TOUCH values never return usably to code?

Various Oddities and rabbit holes getting here from two boards and displays. The 3.2" Touch panel is 180° rotated from the display (see code #define _ROT to handle that) When the two are not the same - on startup with SerialFlash then a SINGLE TOUCH point registers on startup without a touch. Sometimes the TOUCH works with a disconnected T_CS pin - or assigned to an unused pin - other times it does not.

If anyone wants to set it up as shown/needed to run the code the problem should show up. Where the code source of the issue is I've not gotten any farther yet.

With board shown I could move to default SPI1 pins - to test - but have not done that. The board design I got is not the first use - but the problem seems to present on the already shipping version as well. The ReadTest shows the 1Gb chip gives something over 5MB/sec so it is a good connection and option to have. The board as received had a UART connect to an ESP32 and the PJRC Audio board integrated on the PCB - but those were removed from code (along with QSPI PSRAM and FLASH) and not used in the REPRO_DEMO and the problem persists - so it isn't the maker's PCB as the image above uses wires noted in code to work on generic PCB.

Please post with any ideas or questions.

1733275002415.png
 
Notes on the repro - with the setup done.
Without setting it up the code compiled with 1.60Beta3 on IDE 2 using these libs:
Code:
Using library ILI9341_t3 at version 1.0 in folder: C:\Users\USER\AppData\Local\Arduino15\packages\teensy\hardware\avr\0.60.3\libraries\ILI9341_t3
Using library SPI at version 1.0 in folder: C:\Users\USER\AppData\Local\Arduino15\packages\teensy\hardware\avr\0.60.3\libraries\SPI
Using library XPT2046_Touchscreen at version 1.4 in folder: C:\Users\USER\AppData\Local\Arduino15\packages\teensy\hardware\avr\0.60.3\libraries\XPT2046_Touchscreen
Using library SerialFlash at version 0.5 in folder: C:\Users\USER\AppData\Local\Arduino15\packages\teensy\hardware\avr\0.60.3\libraries\SerialFlash

It runs and doing screen touched when it works displays the RAW X,Y coordinates -

Run SerMon as other spew shows there showing the code is running fine.

From SerMon: 'a' triggers the AUDIO button and 's' triggers the SCAN button
> this was first edit on source board to see the display was usably active when the Touch was 'offline', using shared SPI pins

Everything else worked - that code removed to confirm it wasn't part of the problem and cleaner Repro:
The 's'can asked the ESP32 to find all the broadcasting SSID's and return them for display
The 'a'udio would play a WAV from the SD Card
PSRAM reported online
LittleFs found the QSPI Flash
 
New observation: With SerFlash the Pin 13 LED is generally OFF and doesn't blink on at all!
> Is something changing PinMode(13,OUTPUT) {or other SPI} for touch that Display write restores for the duration?
Building "//THIS_GOOD" to disable SerFlash then the LED GLOWS until TOUCHed then it flickers.
> > > SerFlash is killing that Touch read? Or is
XPT2046_Touchscreen not using proper SPI - looks right?
The SerMon 'a' and 's' with SerFlash active does flicker the LED during screen update!
This LED is hidden on the subject Test PCB - and just seen now after moving p#1 PCB and LED became visible.
Also Moved pin 37, SPI1 CS to 38 the default ALT CS for SPI1 and no change, so reverted to 37
p#1 image SPI1 wires in far right headers - moved left 3 sets as 26,27,37,39 usable there and adding ListFiles code it fully works.
> 2.5" less PCB trace - Listfiles more reliable and the TOUCH Still fails the same - get some unTouched hits at times

No Change: Swapped T_4.1 in the p#1 photo PCB - no QSPI soldered - just to remove the PSRAM startup success and prep to interface that.

If run with hardware and SerialFlash OFF - the buttons are hard to hit - so don't bother worrying - the MAP isn't ideal - as least for display here

Added ListFiles() and relocated screen print of X,Y touch ( it is screen coord - not RAW I see) : It is getting Spurios Touch at times

Updated p#1 github linked code - but here is the current for easy reading of horribly hacked 'code':
Code:
#include <ILI9341_t3.h>
#include <font_Arial.h>
#include <XPT2046_Touchscreen.h>
#include <SPI.h>
#include <SerialFlash.h>

#define THIS_GOOD  //  USE THIS TO TOGGLE SERFLASH

// touchscreen offset for four corners
#if 0
#define TS_MINX 400
#define TS_MINY 400
#define TS_MAXX 3879
#define TS_MAXY 3843
#else  //EDIT ABOVR for your screen - this one seems odd
#define TS_MINX 650
#define TS_MINY 900
#define TS_MAXX 2879
#define TS_MAXY 3100
#endif
// LCD control pins defined by the baseboard
#define TFT_CS 10
#define TFT_DC 9
#define TIRQ_PIN 2
#define TS_CS 8
#define TFT_ROT 1
#define TS_ROT 1

// Use main SPI bus MOSI=11, MISO=12, SCK=13 with different control pins
ILI9341_t3 tft = ILI9341_t3(TFT_CS, TFT_DC);
XPT2046_Touchscreen ts(TS_CS);  // Param 2 = NULL - No interrupts

// Define Audio button location and size
#define AUDIO_X 10
#define AUDIO_Y 10
#define AUDIO_W 105
#define AUDIO_H 32

// Define Scan button location and size
#define SCAN_X 10
#define SCAN_Y 50
#define SCAN_W 105
#define SCAN_H 32

#define BUTTON_FONT Arial_14

#define FLASH_CS 37  //Serial flash chip CS pin

// Subroutine prototypes
void SetScanButton(boolean);   // Handles Scan button when touched
void SetAudioButton(boolean);  // Handles Audio button when touched

// Misc flags to keep track of things
boolean isTouched = false;             // Flag if a touch is in process
boolean scanRequested = false;         // Flag if WiFi scan is in process
boolean audioAdapterAttached = false;  // Flag if SD card installed
boolean audioPlaying = false;          // Flag if audio is currently playing
boolean esp32Attached = false;         // Flag if ESP32 is attached

//===============================================================================
//  Initialization
//===============================================================================
void setup() {
  Serial.begin(115200);  //Initialize USB serial port to computer

  // Required to get SPI1 to work with Flash chip
  //SPI1.setMOSI(26); // EXPECTED PIN
  //SPI1.setSCK(27); // EXPECTED PIN
  SPI1.setMISO(39);
  SPI1.setCS(FLASH_CS);
  //  SPI1.begin();  // DONE IN SERIALFLASH

  // Setup LCD screen
  tft.begin();
  tft.setRotation(TFT_ROT);  // Rotates screen to match the baseboard orientation
  // Setup touch Screen
  ts.begin();
  ts.setRotation(TS_ROT);  // Sets the touch screen orientation
  tft.fillScreen(ILI9341_BLUE);
  tft.setCursor(1, 110);  // Set initial cursor position
  tft.setFont(Arial_10);  // Set initial font style and size

#ifdef THIS_GOOD
  // This commented section kills touch when SerialFlash.begin is executed
  // Check for Flash on baseboard
  if (!SerialFlash.begin(SPI1, FLASH_CS)) {
    Serial.println(F("Unable to access SPI Flash chip"));
    tft.println("Unable to access SPI Flash Chip");
  }

  unsigned char id[5];
  SerialFlash.readID(id);
  Serial.print("ID=");
  Serial.println(id[0]);
  Serial.println(id[1]);
  Serial.println(id[2]);
  Serial.println(id[3]);
  Serial.println(id[4]);
  Serial.println();

  Serial.printf("ID: %02X %02X %02X\n", id[0], id[1], id[2]);
  unsigned long sizeFlash = SerialFlash.capacity(id);

  if (sizeFlash > 0) {
    Serial.print("Flash Memory has ");
    Serial.print(sizeFlash);
    Serial.println(" bytes");
    //  tft.printf("Flash Mfr Code EF = ID: %02X %02X %02X\n", id[0], id[1], id[2]);
    tft.printf("SPI NOR Flash Memory Size = %d Mbyte\n", sizeFlash / 1000000 * 8);
  }
  ListFiles();
#endif  // XXXXX */

  audioAdapterAttached = true;  // fake this to enable touch button
  tft.println();

  esp32Attached = true;
  Serial.print("\tUSB input like Touch: 'a'udio or 's'can ");

  // Draw buttons
  SetAudioButton(false);
  SetScanButton(false);
}
//===============================================================================
//  Main
//===============================================================================
void loop() {
  //    SetAudioButton(false);

  // Check to see if the touch screen has been touched
  TS_Point p, pT;
  p.x = 0;   // signal no touch
  pT.x = 0;  // signal no touch
  if (ts.touched())
    p = ts.getPoint();
  if (p.x && isTouched == false) {
    // Map the touch point to the LCD screen
    pT.x = p.x;
    pT.y = p.y;
    p.x = map(p.x, TS_MINY, TS_MAXY, 0, tft.width());
    p.y = map(p.y, TS_MINX, TS_MAXX, 0, tft.height());
    isTouched = true;

    // Look for a Scan Button Hit
    if ((p.x > SCAN_X) && (p.x < (SCAN_X + SCAN_W))) {
      if ((p.y > SCAN_Y) && (p.y <= (SCAN_Y + SCAN_H))) {
        Serial.println("Scan Button Hit");
        if (esp32Attached) SetScanButton(true);
      }
    }
    // Look for an Audio Button Hit
    if ((p.x > AUDIO_X) && (p.x < (AUDIO_X + AUDIO_W))) {
      if ((p.y > AUDIO_Y) && (p.y <= (AUDIO_Y + AUDIO_H))) {
        Serial.println("Audio Button Hit");
        if (audioAdapterAttached && !audioPlaying) {
          SetAudioButton(true);
        } else if (audioAdapterAttached && audioPlaying) {
          SetAudioButton(false);
        }
      }
    }
  }
  if (pT.x) {              //} && p.x < 3000) {
    Serial.print("x = ");  // Show our touch coordinates for each touch
    Serial.print(p.x);
    Serial.print(", y = ");
    Serial.print(p.y);
    Serial.println();

    tft.fillRect(1, SCAN_Y + SCAN_H, 360, 24, ILI9341_BLUE);  // Clear previous scan
    tft.setCursor(1, 90);
    tft.setFont(BUTTON_FONT);
    tft.setTextColor(ILI9341_WHITE);
    tft.print("x = ");  // Show our touch coordinates for each touch
    tft.print(p.x);
    tft.print(", y = ");
    tft.print(p.y);

    delay(50);  // Debounce touchscreen a bit
  }

  if (!ts.touched() && isTouched) {
    isTouched = false;  // touchscreen is no longer being touched, reset flag
  }
  // If we requested a scan, look for serial data coming back from the ESP32S
  if (scanRequested) {
    Serial.print("Read incoming data");
    tft.setCursor(10, 90);
    tft.setFont(Arial_10);
    scanRequested = false;  // Reset the scan flag and button
    SetScanButton(false);
  }
  checkUSB();  // Confirm full function when Touch fails
}

void checkUSB() {
  if (Serial.available()) {
    char inC;
    while (Serial.available()) {
      inC = Serial.read();
      switch (inC) {
        case 'a':
          Serial.println("Audio Button Hit");
          if (audioAdapterAttached && !audioPlaying) {
            SetAudioButton(true);
          } else if (audioAdapterAttached && audioPlaying) {
            SetAudioButton(false);
          }
          break;
        case 's':
          Serial.println("Scan Button Hit");
          if (esp32Attached) SetScanButton(true);
          break;
      }
    }
  }
}

//===============================================================================
//  Routine to draw Audio button current state and control audio playback
//===============================================================================
void SetAudioButton(boolean audio) {
  tft.setCursor(AUDIO_X + 8, AUDIO_Y + 8);
  tft.setFont(BUTTON_FONT);
  tft.setTextColor(ILI9341_WHITE);

  if (!audio) {  // button is set inactive, redraw button inactive
    tft.fillRoundRect(AUDIO_X, AUDIO_Y, AUDIO_W, AUDIO_H, 4, ILI9341_RED);
    tft.print("Play Audio");
    audioPlaying = false;
    Serial.println("Audio being stopped");
  } else {
    tft.fillRoundRect(AUDIO_X, AUDIO_Y, AUDIO_W, AUDIO_H, 4, ILI9341_GREEN);
    tft.print("Playing");
    audioPlaying = true;
    Serial.print("Audio being played: ");
    delay(1000);  // wait for library to parse WAV info
  }
}
//===============================================================================
//  Routine to draw scan button current state and initiate scan request
//===============================================================================
void SetScanButton(boolean scanning) {
  tft.setCursor(SCAN_X + 8, SCAN_Y + 8);
  tft.setFont(BUTTON_FONT);
  tft.setTextColor(ILI9341_WHITE);

  if (!scanning) {  // Button is inactive, redraw button
    tft.fillRoundRect(SCAN_X, SCAN_Y, SCAN_W, SCAN_H, 4, ILI9341_RED);
    tft.print("Scan WiFi");
  } else {                                                     // Button is active, redraw button
    tft.fillRect(1, SCAN_Y + SCAN_H, 360, 240, ILI9341_BLUE);  // Clear previous scan
    tft.fillRoundRect(SCAN_X, SCAN_Y, SCAN_W, SCAN_H, 4, ILI9341_GREEN);
    tft.print("Scanning");
    scanRequested = true;  // Set flag that we requested scan
    Serial.println("Scan being requested");
  }
  delay(1000);  // wait for library to parse WAV info
  ListFiles();
}

void spaces(int num) {
  for (int i = 0; i < num; i++) {
    Serial.print(' ');
  }
  for (int i = 0; i < num; i++) {
    tft.print(' ');
  }
}

void ListFiles() {
#ifdef THIS_GOOD
  tft.fillRect(1, SCAN_Y + SCAN_H, 360, 240, ILI9341_BLUE);  // Clear previous scan
  tft.setCursor(1, 120);
  tft.setFont(Arial_14);
  tft.printf("CAN'T TOUCH THIS!");
  tft.setFont(Arial_8);
  tft.setTextColor(ILI9341_RED);
  tft.printf("CAN'T TOUCH THIS!");
  tft.setTextColor(ILI9341_WHITE);
  SerialFlash.opendir();
  uint32_t fCnt = 0;
  tft.println("\n");
  while (1) {
    char filename[64];
    uint32_t filesize;
    if (SerialFlash.readdir(filename, sizeof(filename), filesize)) {
      tft.printf("  File %d:", fCnt++);
      Serial.print(F("  "));
      Serial.print(filename);
      spaces(20 - strlen(filename));
      Serial.print(F("  "));
      Serial.print(filesize);
      Serial.print(F(" bytes"));
      Serial.println();

      tft.print(F(" "));
      tft.print(filename);
      spaces(20 - strlen(filename));
      tft.print(F(" "));
      tft.print(filesize);
      tft.print(F(" bytes"));
      tft.println();
    } else {
      break;  // no more files
    }
  }
#endif  // XXXXX */
}
 
It has been a while since I have played with the touch. Wonder if it or the flash chip are holding onto the MISO signal?
Would also double check that CS pins are correct at the time you are trying to access each of them.

Also, when I have multiple SPI objects on the same SPI buss, and their devices don't have hardware PU resistors on their CS pins,
I make sure to do something like: pinMode(csPin, OUTPUT); digitalWrite(csPin, HIGH);
And I do it for all of the devices on that buss, before I do any of the init/begin methods to start up/configure that device

Side note: this time it did not end up in junk folder :D
 
Thx @KurtE and @mjs513

SPI only has single device - PJRC ILI9341 with Touch.
SPI1 has the SerialFlash on it - and nothing else.

Display works in both cases.
Touch works, unless SerialFlash is started.
Code:
// LCD control pins defined by the baseboard
#define TFT_CS 10
#define TFT_DC 9
#define TIRQ_PIN 2
#define TS_CS 8
#define TFT_ROT 1
#define TS_ROT 1

// Use main SPI bus MOSI=11, MISO=12, SCK=13 with different control pins
ILI9341_t3 tft = ILI9341_t3(TFT_CS, TFT_DC);
XPT2046_Touchscreen ts(TS_CS);  // Param 2 = NULL - No interrupts

... //setup
  // Setup LCD screen
  tft.begin();
  tft.setRotation(TFT_ROT);  // Rotates screen to match the baseboard orientation
  // Setup touch Screen
  ts.begin();

And SerialFlash in setup:
Code:
#define FLASH_CS 37  //Serial flash chip CS pin
  // Required to get SPI1 to work with Flash chip
  //SPI1.setMOSI(26); // EXPECTED PIN
  //SPI1.setSCK(27); // EXPECTED PIN
  SPI1.setMISO(39);
  SPI1.setCS(FLASH_CS);
  //  SPI1.begin();  // DONE IN SERIALFLASH
 
  ...
  #ifdef THIS_GOOD
  // This commented section kills touch when SerialFlash.begin is executed
  // Check for Flash on baseboard
  if (!SerialFlash.begin(SPI1, FLASH_CS)) {
    Serial.println(F("Unable to access SPI Flash chip"));
    tft.println("Unable to access SPI Flash Chip");
  }
 
#define FLASH_CS 37 //Serial flash chip CS pin // Required to get SPI1 to work with Flash chip //SPI1.setMOSI(26); // EXPECTED PIN //SPI1.setSCK(27); // EXPECTED PIN SPI1.setMISO(39); SPI1.setCS(FLASH_CS); // SPI1.begin(); // DONE IN SERIALFLASH ... #ifdef THIS_GOOD // This commented section kills touch when SerialFlash.begin is executed // Check for Flash on baseboard if (!SerialFlash.begin(SPI1, FLASH_CS)) { Serial.println(F("Unable to access SPI Flash chip")); tft.println("Unable to access SPI Flash Chip"); }
Interesting how the quote of this ...

But wondering about: SPI1.setCS(FLASH_CS);

Is the Serial Flash library assuming that the CS pin is controlled by SPI? That is asserted/deasserted I believe on each byte?
Especially since you also have: if (!SerialFlash.begin(SPI1, FLASH_CS))
Which I would think implies that the library wants to control the CS pin...
 
Looking at SerialFash library, my c++ stuff is a bit vague on some stuff. In particular object references.

That is the cpp file has:
Code:
static SPIClass& SPIPORT = SPI;
and the begin method has:
Code:
bool SerialFlashChip::begin(SPIClass& device, uint8_t pin)
{
    SPIPORT = device;
    return begin(pin);
}

So it is assigning a reference to a reference...
Does that more or less act the same as doing: SPI = SPI1;

Also are you only allowed one SPIFlash chip? if not they must all be on the same SPI buss as
this assigns a global (although static) variable...
Would have expected it to be a member variable... maybe holding pointer.

I thought about the only thing that could change one of these references is to do it in the contructor...

But could be completely wrong.
 
@defragster

Wondering if its an issue with tri-state buffer or possible of needing resistors on the cs lines.
Possible? Doesn't seem like that should be an issue.
But these PJRC displays - as the only thing on an SPI bus just always work.
Only the intro of a device on SPI1 - unique pins and software - creates this problem?
 
Yes, p#7 did show quote 'funny'
Looking at SerialFash library, my c++ stuff is a bit vague on some stuff. In particular object references.
...
So it is assigning a reference to a reference...
Does that more or less act the same as doing: SPI = SPI1;

Also are you only allowed one SPIFlash chip? if not they must all be on the same SPI buss as
this assigns a global (although static) variable...
Would have expected it to be a member variable... maybe holding pointer.

I thought about the only thing that could change one of these references is to do it in the contructor...

But could be completely wrong.
I wasn't clear on the c++ there - but it works and passing in the requested info SerialFlash works without issue.
Reading the code everything looked well ordered, with no hardcoded refs like to SPI or assumed default bus/pins.
It does appropriate the CS pin directly.

Pin 0 is default SPI CS1 (used for UART1 on Proto board) - started to test on that - but may have gotten sidetracked when wire length broke connection seen adding the ListFiles.

CONFIRMED NO Difference using Default SPI pins {CS1=0 and MISO1=1} (not available on Proto board) - but they are here:
Code:
#define FLASH_CS 0 //37  //Serial flash chip CS pin
...    // NO SPI1 Pin override!
  //xx SPI1.setMISO(39);
  //XX SPI1.setCS(FLASH_CS);
...
if (!SerialFlash.begin(SPI1, FLASH_CS)) {

Here is the current state with "SPI" Touch NO_GOOD, but LCD fine, and Serial Flash working on default "SPI1" pins
This pictured board is easy to edit - unlike the Proto board that has hardwired PCB traces - but the behavior is the same, so not a Proto PCB error.
1733345318111.png


<EDIT>: Note there is a SPURIOUS touch point displayed - that is from NO TOUCH - something occasionally triggers that, but actual touch DOES not cause the Pin #13 SCK to trigger any longer - until SerMon 'a' or 's' sent to confirm display function
> Something has interfered with normal/Expected 'PinMode()' settings as needed for Touch.
 
Back to my question about reference versus pointer...
For the heck of it, try my quick and dirty fork/branch:


Again unclear to me what assigning one reference to another, but for example here is a quick and dirty stupid example:
Code:
class FOO {
  public:
    FOO(uint8_t sv) : val(sv) {}
    uint8_t val;
    void setVal(uint8_t v) {val = v;}
};

FOO foo1(1);
FOO foo2(2);

FOO &foor = foo1;

void print_foos() {
  Serial.printf("%u %u %u\n", foo1.val, foo2.val, foor.val);
}

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  while (!Serial && millis() < 5000) {}
  print_foos();
  foor.setVal(3);
  print_foos();
  foo1.setVal(4);
  foo2.setVal(5);
  print_foos();
  foor = foo2;
  print_foos();
  foor.setVal(6);
  print_foos();
  foo1.setVal(7);
  foo2.setVal(8);
  print_foos();

}

void loop() {
  // put your main code here, to run repeatedly:

}

Output:
Code:
1 2 1
3 2 3
4 5 4
5 5 5
6 5 6
7 8 7
 
foo2.setVal(5);
print_foos(); // 5 5 5
foor = foo2;
print_foos();
"Looks like" that shows the expected anticipated suggestion that the reference maps back to foo1 being the same thing?

Seems easy test here is to do library hack: edit C:\Users\USER\AppData\Local\Arduino15\packages\teensy\hardware\avr\0.60.3\libraries\SerialFlash\SerialFlashChip.cpp
static SPIClass& SPIPORT = SPI1; // Was SPI not SPI1

and then this works with default SPI1 pins in use:
//xx if (!SerialFlash.begin(SPI1, FLASH_CS)) { if (!SerialFlash.begin(FLASH_CS)) {

THAT WORKS! Good point of befuddlement @KurtE !!! We have TOUCH - and SerialFlash !!!!

So this code is NOT doing what 'we' suggest it is doing:
bool SerialFlashChip::begin(SPIClass& device, uint8_t pin) { SPIPORT = device; return begin(pin); }
> it does not allow that 'static ... SPIPORT' to fully change at runtime??

That was one of my first wonders - what is passed and used for "SPIClass& device" ???

It is weird the SPI1 SerialFlash works - and the only side effect (observed so far) is that SPI Touch goes away?

THOUGH: That explains why BAD THINGS happened when setup(){ xyz.begin() } order of the devices was re-ordered in first attempt to resolve.
 
Did you try my GitHub version in msg #11, I changed reference to pointer and begin method sets it to address of reference passed in. Like many of our other libraries
 
Did you try my GitHub version in msg #11, I changed reference to pointer and begin method sets it to address of reference passed in. Like many of our other libraries
Yep thats a better approach so that
Code:
static bool begin(SPIClass& device, uint8_t pin = 6);
actually work the way it is suppose to.
 
For the heck of it, try my quick and dirty fork/branch:

POINTERS WORK! - skipped this for reading example code ... found and tested ...

It is now back and working on the original board from @KenHahn
1733361610563.png


Downloaded the ZIP and pulled JUST the SerialFlashChip.cpp file to this system and it works perfectly!

The start screen shows this: All devices accounted for and working!
PSRAM Memory Size = 8 Mbyte
NAND Flash Memory Size = 265289728 bytes / 253 Mbyte / 2 Gbit
Flash Memory has 134217728 bytes
SD card is installed
ESP32 was found
 
@PaulStoffregen or @jmarsh or other c++ nerd - is there a way to have this (p#12) properly resolved to specify alternate SPIClass& SPIPORT at runtime?
Yes... rewrite it because references don't work the way that code intends them.

References can only be "bound" at creation, so static SPIClass& SPIPORT = SPI; mean SPIPORT will always refer to SPI. When the SerialFlashChip::begin() later tries to do SPIPORT = device;, it actually copies the contents of $device into SPI, so any other code that refers to SPI will now also end up using $device.

So SerialFlash needs to be rewritten (preferably templated), and SPIClass should really have its copy methods disabled so this sort of error won't go unnoticed.
 
Yes... rewrite it because references don't work the way that code intends them.
Good to know @jmarsh

@KurtE - are you going to do a PR? The pointer usage works - not sure about other changes

No change in header or prototype - just referenced as a pointer now throughout the MANY uses in that file.
1733376930804.png
 
Already did msg 17:)
Opps - I thought that was just a repeat of the github since I skipped before ... and skipped again

Good work @KurtE

<edit> Added a comment to PR that it was tested to work on T_4.1 board above, and two of the PCB's (with T_4.1)
 
Last edited:
Back
Top