NAND flash support in 1.54

@mjs513 - got the latest 2hr old changes. Will get it built and at least a quick look shortly.

@KurtE - I made sure to test T_4.1 before - did skip that once - always a bit of wonder while waiting for it to dry. Did you do NAND before or after the edge pins? I suppose before - that is tight spacing.
 
This :: int w25n01g_t4::readBytes(uint32_t Address, uint8_t *data, int length)
\w25n01g_t4.cpp:562:1: warning: no return statement in function returning non-void [-Wreturn-type]
doesn't have any:: return int_??;

After a run leaving the 42 on NAND - a Power Off/On fails to find the 42's after Init?
Code:
    NAND ============================ check42() : COMPARE !!!!
	 took 4709744 elapsed us
Good, 	Found 42 in NAND 0x8000000 Times
[B]Begin Init[/B]
Found W25N01G Flash Chip
[B][COLOR="#FF0000"]    NAND ============================ check42() : COMPARE !!!!
  0=     255
	+++ NOT 42 Good Run of 1 {bad @ 0}[/COLOR][/B]

The 42's are found on UPLOAD or RESET. Almost like something isn't 'READY' for first read on fresh POWER up?
 
This :: int w25n01g_t4::readBytes(uint32_t Address, uint8_t *data, int length)

doesn't have any:: return int_??;

After a run leaving the 42 on NAND - a Power Off/On fails to find the 42's after Init?
Code:
    NAND ============================ check42() : COMPARE !!!!
	 took 4709744 elapsed us
Good, 	Found 42 in NAND 0x8000000 Times
[B]Begin Init[/B]
Found W25N01G Flash Chip
[B][COLOR="#FF0000"]    NAND ============================ check42() : COMPARE !!!!
  0=     255
	+++ NOT 42 Good Run of 1 {bad @ 0}[/COLOR][/B]

The 42's are found on UPLOAD or RESET. Almost like something isn't 'READY' for first read on fresh POWER up?

Worse than that - there is a major bug in the lib - as soon as I remove power the chip looses what we wrote !!!!

has a test use this instead of check42(false) in setup! and you will see what I mean:
Code:
  //check42(false);
  memset(x42, 0, arraySize);
  myNAND.readBytes(0, x42, arraySize);

  for (uint16_t i = 0; i < arraySize; i++) {
    Serial.printf("0x%02x, ", x42[i]);
    if (i % 100 == 0) Serial.println();
  } Serial.println();

  Serial.println();
  //Lets try an erase
  //myNAND.deviceErase();  //Erase chip
  //Serial.println("Reading Data");
  memset(buffer, 0, 2048);
  myNAND.readBytes(4094, buffer, 16);
  
  for (uint16_t i = 0; i < 16; i++) {
    Serial.printf("0x%02x, ", buffer[i]);
  } Serial.println();
 
It looks like you are trying to write twice to the same page out of order, which I think is forbidden.
Code:
  memset(buffer, 0xFF, 2048);
  for (uint16_t i = 0; i < 2048; i++) buffer[i] = i;
  myNAND.writeBytes(4094, buffer, 16);

  //Serial.println("Reading Data");
  memset(buffer, 0, 2048);
  myNAND.readBytes(4094, buffer, 16);

  for (uint16_t i = 0; i < 16; i++) {
    Serial.printf("0x%02x, ", buffer[i]);
  } Serial.println();


  const uint8_t beefy[] = "DEADBEEFdeadbeef\n";
  //Serial.println("Loading data");
  Dprint( (char *)beefy )
  memset(buffer, 0, 2048);
  for(uint8_t j = 0; j < sizeof(beefy); j++) buffer[j] = beefy[j];

  myNAND.writeBytes(4000, buffer, sizeof(beefy));

EDIT: "The pages within the block have to be programmed sequentially from the lower order page address to the higher order page address within the block. Programming pages out of sequence is prohibited." So Maybe you can do (up to 4) writes to the page out of order? But you can't go back and program at address 0 after address 4000+?
 
Think that restriction is on a per Program Execute command. But even with that it doesn't explain why the data is not being retained by flash after power off.

Even if I only do a single write and read operation when power is recycled i will still get 0xff, for instance:
Code:
Begin Init
Found W25N01G Flash Chip
[On power recycle]
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
[After write and then read]
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,

Yet if I just reload the sketch you see:
Code:
Begin Init
Found W25N01G Flash Chip

0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 

0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
Data is retained?

Heres the setup to do that:
Code:
void setup() {
  Serial.begin(115200);
  delay(1000);
  Serial.println("Begin Init");

  myNAND.begin();

  //check42(false);
  //Serial.println("Reading Data");
  memset(buffer, 0, 2048);
  myNAND.readBytes(0, buffer, 16);

  for (uint16_t i = 0; i < 16; i++) {
    Serial.printf("0x%02x, ", buffer[i]);
  } Serial.println();

  Serial.println();
 
  //Lets try an erase
  //myNAND.deviceErase();  //Erase chip

  memset(buffer, 0, 2048);
  for (uint16_t i = 0; i < 2048; i++) buffer[i] = i;
  myNAND.writeBytes(0, buffer, 16);

  //Serial.println("Reading Data");
  memset(buffer, 0, 2048);
  myNAND.readBytes(0, buffer, 16);

  for (uint16_t i = 0; i < 16; i++) {
    Serial.printf("0x%02x, ", buffer[i]);
  } Serial.println();


  const uint8_t beefy[] = "DEADBEEFdeadbeef\n";
  //Serial.println("Loading data");
  Dprint( (char *)beefy )
  memset(buffer, 0, 2048);
  for(uint8_t j = 0; j < sizeof(beefy); j++) buffer[j] = beefy[j];

  //myNAND.writeBytes(4000, buffer, sizeof(beefy));

  //Serial.println("Reading Data");
  memset(buffer, 0, 2048);
  //myNAND.readBytes(4000, buffer, 20);
/*
  for (uint16_t i = 0; i < sizeof(beefy); i++) {
    Serial.printf("0x%02x[%c], ", buffer[i], buffer[i]);
  } Serial.println();
*/
  //check42(true);
}
Ok have some errands to do so will have to try and figure out whats going on. Have no idea why not retained.
 
Looks like the T4.1 still runs now ;)

Code:
Begin Init

Found W25N01G Flash Chip

    NAND ============================ check42() : COMPARE !!!!
	 took 4709764 elapsed us
Good, 	Found 42 in NAND 0x8000000 Times
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 

DEADBEEFdeadbeef
0x44[D], 0x45[E], 0x41[A], 0x44[D], 0x42[B], 0x45[E], 0x45[E], 0x46[F], 0x64[d], 0x65[e], 0x61[a], 0x64[d], 0x62[b], 0x65[e], 0x65[e], 0x66[f], 0x0a[
], 0x00[
It is interesting that cut and paste only showed this much... Probably the null character killed showing output after that, which I did another paste from...
Code:
0x2a, 

0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 

0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a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 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 




    NAND ========== memory map ======  ====== check42() : WRITE !!!!
		NAND length 0x8000000 element size of 1
	 took 5067115 elapsed us
    NAND ============================ check42() : COMPARE !!!!
	 took 4709798 elapsed us
Good, 	Found 42 in NAND 0x8000000 Times

Have not looked much yet at sketch to know if this is good or bad. ;)

Edit: Note: I was sort of confused as you mention check42, but your dump shows 0x2a ;) I wonder if they are related :D
 
That’s good now power off and on and you will get the bad message.

Yeah got me too at first but 0x2a is 42 decimal :). Still don’t know why data isn’t retained.
 
Indeed a print of 0x0 breaks the output copy paste. I put in an IF() case for altered print somewhere once when it wanted to print zero.

Not getting time to test/work on this :( - phone calls and then tax prep time.

Wondering if data getting lost on power off - or if there is a reset of chip somewhere before setup() on cold start - or if the chip is really not made ready to read until after some later code runs and that persists across warm restarts? i.e. Maybe the check42(false) is too early in setup()?
> thinking alter check42 to only write half of NAND - then at end of setup() check some value in page over halfway - Print the value found and then if not expected value write it to a known value and then repeat and it should only show wrong value the first time.
 
Didn't look much at the code - but unpacked a new T_4.1 - loaded an SD Test sketch that worked logging values to new SD card.

Soldered a NAND and a PSRAM - brushed clean with 90% ISO - dried with hairdryer - cooled and let sit under a fan for a minute.

> Booted to run SD code again
> Upload/Ran PJRC PSRAM_Mem_Test FINE on 8MB!
> Upload/Ran NAND_SPI_TEST once { expected no 42's in fresh NAND chip on first run }
> - then warm reset - 42's were gone?
> - then warm reset - 42's were present

ALL GOOD! - except disappearing 42's - on that first reset - and again on COLD power up.

T:\tCode\T_4.1\SD_Write\SD_Write.ino Jul 13 2020 23:10:11
Initializing SD card...
DL200318.csv
card initialized.
1012,10,6
...
1010,10,6
EXTMEM Memory Test, 8 Mbyte
CCM_CBCMR=B5AE8304 (88.0 MHz)
testing with fixed pattern 5A698421
testing with pseudo-random sequence, seed=2976674124
...
testing with fixed pattern 00000000
test ran for 36.66 seconds
All memory tests passed :)
Begin Init
Found W25N01G Flash Chip

NAND ============================ check42() : COMPARE !!!!
0= 255
+++ NOT 42 Good Run of 1 {bad @ 0}
...
... // did a WARM RESET
...
NAND ========== memory map ====== ====== check42() : WRITE !!!!
NAND length 0x8000000 element size of 1
Begin Init
Found W25N01G Flash Chip

NAND ============================ check42() : COMPARE !!!!
+++ NOT 42 Good Run of 8 {bad @ 0}
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
DEADBEEFdeadbeef
...
Good, Found 42 in NAND 0x8000000 Times
Begin Init
Found W25N01G Flash Chip
NAND ============================ check42() : COMPARE !!!!
took 4703808 elapsed us
Good, Found 42 in NAND 0x8000000 Times
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
DEADBEEFdeadbeef

*Note - yeah the 42's are decimal ( thought I made them HEX, but not }
- and the 42() test code is not what it was looking back at prior code for PSRAM testing - but can't look more until other paperwork done ...
 
@PaulStoffregen
First hope all is well with everything going on and you are getting the boot loader chip done :)

Hate to bother you but really stuck at this point. Looks like we are reading and writing to the chip. BUT big problem that we can't figure out is when we do a power on/off cycle the data isn't retained by the NAND chip. As long as we retain power all works fine. Any ideas? There is not much out there on people using the W25N01G that i could find.

Know you don't want to get too side tracked.
 
Sorry I've been AWOL, but I don't think we need Paul just yet. I see a couple bugs and/or potential things to try still, so I'll see if I have any luck playing with it.
  • Several methods using uint16_t for addresses which should be uint32_t
  • I think the LUT is doing the address to page and column calculation itself so they might be happening twice?
 
Good to have added focus - hoping to add some soon :) If only extended samples to track working versus other points.

Where does NAND's format before write happen?
What happens if the cache is disabled - if enabled - to test on this range. Of course 32KB doesn't cover much of 128MB - unless it is acting up to return 42.
 
It isn't currently formatting, but the chip is initially formatted, and we don't appear to be disturbing that yet. As far as I can tell nothing is actually making it from the on chip buffer to the NAND storage on the flash, although the copy from the Teensy to the buffer is working, which is why some stuff sort of seems to work until power down.
 
It isn't currently formatting, but the chip is initially formatted, and we don't appear to be disturbing that yet. As far as I can tell nothing is actually making it from the on chip buffer to the NAND storage on the flash, although the copy from the Teensy to the buffer is working, which is why some stuff sort of seems to work until power down.

Morning - just on my first cup of coffee. Thought about that as well but..

Going to type a discourse here because sometimes it helps me see what i am doing. According to the datasheet 2 things have to happen to get the data onto the chip:
  1. Load the data into the buffer region of the chip (done with randomProgramDataLoad or programDataLoad.
  2. Execute the programExecute command which requires the page addresss.

The data loads require a 16-bit column address per the datasheet and the progarmExecute requires a 32-bit page address. The functions use 2 defines to do this based on the linear address:
Code:
#define LINEAR_TO_COLUMN(laddr) ((laddr) % PAGE_SIZE)
#define LINEAR_TO_PAGE(laddr) ((laddr) / PAGE_SIZE)
The page size is 2048 by the way.

As I am typing this I changed the column address to 32-bit's but the conversion to linear to column stayed at 16-bit per the datasheet for column addressing.

Ok so lets do a little experiment. Uncomment check42(true) so the last thing that happens is filing chip with42's or 0x2a and lets read 16 bytes from address 20,480 which should be page 10 since page 0 is loaded on power on or reset. So on reset if page 0 is auto loaded and we look at page 10 if the data wasn;t really written to page 10 we should see 0xffs or some other value.

On first run you since you may not have run check42 you get:
Code:
Begin Init
Found W25N01G Flash Chip
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 

0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 

DEADBEEFdeadbeef
0x44[D], 0x45[E], 0x41[A], 0x44[D], 0x42[B], 0x45[E], 0x45[E], 0x46[F], 0x64[d], 0x65[e], 0x61[a], 0x64[d], 0x62[b], 0x65[e], 0x65[e], 0x66[f], 0x00[

Now if we press the pgm button:
Code:
Begin Init
Found W25N01G Flash Chip

0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 


0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 
DEADBEEFdeadbeef
0x44[D], 0x45[E], 0x41[A], 0x44[D], 0x42[B], 0x45[E], 0x45[E], 0x46[F], 0x64[d], 0x65[e], 0x61[a], 0x64[d], 0x62[b], 0x65[e], 0x65[e], 0x66[f], 0x00[

So if the data is not really being written to the chip the page 10 with readbytes from page 10 shouldn't be 0x2a's.

But if we do a power off and power on we get back to the problem:
Code:
Begin Init
Found W25N01G Flash Chip
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
[
No data?

Does this make any sense or am I missing something?
 
Made a tiny bit of progress. It seems that the operand on the commands using the page address is wrong. It was originally 0x20. I thought it should be 0x10, since it's only two bytes, but that doesn't work either. With 0x18 I do get stuff actually written to and read from the chip through a power cycle. I'm not sure if that's actually using the correct page though, or if it should be 0x14 because we used 12 bits for the column? If so should the dummy bits be reduced to keep the alignment? Should it be 0x18 with no dummy bits?

I turned off the 42 stuff for now just trying to get data to persist after the initial write is commented out and power cycled, and I also made a lot of minor readability (for my taste) changes, take em or leave em...

View attachment NAND_SPI_TEST_7_15.zip
 
Made a tiny bit of progress. It seems that the operand on the commands using the page address is wrong. It was originally 0x20. I thought it should be 0x10, since it's only two bytes, but that doesn't work either. With 0x18 I do get stuff actually written to and read from the chip through a power cycle. I'm not sure if that's actually using the correct page though, or if it should be 0x14 because we used 12 bits for the column? If so should the dummy bits be reduced to keep the alignment? Should it be 0x18 with no dummy bits?

I turned off the 42 stuff for now just trying to get data to persist after the initial write is commented out and power cycled, and I also made a lot of minor readability (for my taste) changes, take em or leave em...

Dont think its working even with those changes. I changed your sketch slightly since 0xFF are defaults if there is no data to:
Code:
  //read address 3000 on start
  Serial.println("Test Read");
  memset(buffer, 0xFF, 2048);
  myNAND.readBytes(3000, buffer, 16);
  for (uint16_t i = 0; i < 16; i++) {
    Serial.printf("0x%02x, ", buffer[i]);
  } Serial.println();

  Serial.println("Test Write");
  for (uint16_t i = 0; i < 2048; i++) buffer[i] = i;
  myNAND.writeBytes(0, buffer, 16);
  myNAND.writeBytes(3000, buffer, 16);
  
  //read address 3000 after write to 3000.
  Serial.println("Test Read");
  memset(buffer, 0xFF, 2048);
  myNAND.readBytes(3000, buffer, 16);
  for (uint16_t i = 0; i < 16; i++) {
    Serial.printf("0x%02x, ", buffer[i]);
  } Serial.println();

After a reset it looks good:
Code:
Test Read
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 

Test Write
Test Read
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,

Now if i remove power and turn it back on
Code:
est Read
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 

Test Write
Test Read
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
Same issue looks like - data is not read on power cycle.


According to the datasheet while you are using a 16 bit address the chip only looks at the first 12bits and discards the other 4 so 16bits is right.
 
Try address 0 instead of 3000, as I said I'm not at all confident about the page addresses, but I currently boot with no write code enabled and get the test sequence...
 
Try address 0 instead of 3000, as I said I'm not at all confident about the page addresses, but I currently boot with no write code enabled and get the test sequence...

Ok. First run through ran sketch using address 0 and wrote data to address 0. Next I loaded the sketch with just reading the bytes at address 0 with no writes and as expected it worked:
Code:
Test Read on start
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,

Cycled power and got all 0xFFs:
Code:
Test Read on start
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,

EDIT: Look at the RM for the RT1050 and search for W25n01g - may give you some insight
 
Well great, apparently some random thing I did during testing was what managed to get the ProgramExecute working because I 100% for sure have the data stored somewhere on my chip.
 
Well great, apparently some random thing I did during testing was what managed to get the ProgramExecute working because I 100% for sure have the data stored somewhere on my chip.

Welcome to my world and the joys of programing :)
 
I don't have the 1050 manual, but from the link you posted on page 1 it appears to be using 24bit page address with no dummy bits in the sample code LUT.
 
Yeah but that doesn't match the requirement in the datasheet and it doesnt look like its using quad data loads either. As an experiment maybe should just use serial (PINS1) instead of QUAD loads and writes?
 
This code is definitely loading into the buffer because when I use it for read() I can get back the test sequence that's somewhere on my chip. Who knows where that data might be, but it's saved and this code is putting it into the buffer.

Code:
  FLEXSPI2_LUT48 = LUT0(CMD_SDR, PINS1, PAGE_DATA_READ) | LUT1(DUMMY_SDR, PINS1, 8);
  FLEXSPI2_LUT49 = LUT0(ADDR_SDR, PINS1, 0x18);

  flexspi_ip_command(12, flashBaseAddr + addr);

Trying to use a matching format for the ProgramExecute and EraseBlock commands isn't getting me anywhere though, even when I'm just trying to read and write to page 0.
 
There were some problems with the timeouts in the read stuff, so the page wouldn't always make it to the buffer. I think this is another incremental improvement. I seem to be able to write and erase, and have stuff persist over a power cycle, but I thought I had a fix before...
View attachment NAND_SPI_TEST_7_15_PM.zip
 
Back
Top