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 51

Thread: Teensy 4.1 external flash memory question.

  1. #26
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,551
    Just as a FYI - just ordered a few of the SIM version and another T4.1 to test with from Digikey. Have a feeling this is going to come up again.

  2. #27
    Member
    Join Date
    Jul 2020
    Location
    California
    Posts
    29
    I ran it about 40 minutes for formatting.

    It is not able to execute erase command.

    Since software is keep printing dots, I think software is forever waiting for hardware signal.

    Click image for larger version. 

Name:	unnamed.png 
Views:	6 
Size:	10.4 KB 
ID:	21071 Click image for larger version. 

Name:	Capture1.PNG 
Views:	6 
Size:	8.6 KB 
ID:	21072

    While I'm waiting, I'll keep reading the code alongside with Winbond flash memory instructions.

  3. #28
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,551
    That assessment agrees with what I said in an earlier post.

    If i had the same setup I would look at the status registers using the printStatusRegs function call. Would make the follow
    Code:
    void spiffs_t4::printStatusRegs() {
    #if 1
      uint8_t val;
    
      flexspi_ip_read(8, flashBaseAddr[_spiffs_region], &val, 1 );
      Serial.print("Status 1:");
      Serial.println(val, BIN); //lets me see the bits more easily against the datasheet
    
      // cmd index 9 = read Status register #2 SPI
      flexspi_ip_read(9, flashBaseAddr[_spiffs_region], &val, 1 );
      Serial.print("Status 2:");
      Serial.println(val, BIN); //lets me see the bits more easily against the datasheet
    #endif
    }
    I would put it in eraseDevice and watFlash. You may get a lot of spew but you can put a test on it to print it periodically or just pull the usb cable.

    Order the SIM chip from digikey earlier today, may have at end of week for testing.

    EDIT:
    Forgot to add - bits you want to check is that the chip is write enabled (WEL) and no protection bits are set.
    Last edited by mjs513; 07-21-2020 at 10:43 PM.

  4. #29
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,551
    Ok - think i figured it out.

    My fault in reading - While we “Enter QPI (38h)” the QE bit is never actually set which for the "M" chip it needs to be. Saw a note in this note in the lib which i missed:
    Code:
    	  //TODO!!!!! set QPI enable bit in status reg #2 if not factory set!!!!!
    Dang it - should have saw this yesterday!

  5. #30
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,551
    @Han
    After the TODO statement can you add this:
    Code:
    	  if( flashID[1] == 0x70){
    		  uint8_t val;
    		  flexspi_ip_read(9, flashBaseAddr[_spiffs_region], &val, 1 ); //read status Reg2
    		  val |= 1<<1;
    		  FLEXSPI2_LUT28 = LUT0(CMD_SDR, PINS1, 0x31) | LUT1(WRITE_SDR, PINS1, 1);
    		  flexspi_ip_write(7, flashBaseAddr[_spiffs_region], val, 1);
    	  }
    think this is correct to set the QE bit which is bit 2 of status register-2. Can you give this a try or make necessary corrections.
    Last edited by mjs513; 07-22-2020 at 02:22 PM.

  6. #31
    Member
    Join Date
    Jul 2020
    Location
    California
    Posts
    29
    @mjs513

    Sorry about a late reply, I just got back to my office.

    I will make the changes you gave me and let you know about it.

    Thank you

  7. #32
    Member
    Join Date
    Jul 2020
    Location
    California
    Posts
    29
    So, this is what I did.
    Click image for larger version. 

Name:	image.png 
Views:	9 
Size:	38.0 KB 
ID:	21082

    It's currently not taking any characters after making that change.
    Click image for larger version. 

Name:	unnamed.png 
Views:	10 
Size:	6.4 KB 
ID:	21083

  8. #33
    Member
    Join Date
    Jul 2020
    Location
    California
    Posts
    29
    Quote Originally Posted by mjs513 View Post
    That assessment agrees with what I said in an earlier post.

    If i had the same setup I would look at the status registers using the printStatusRegs function call. Would make the follow
    Code:
    void spiffs_t4::printStatusRegs() {
    #if 1
      uint8_t val;
    
      flexspi_ip_read(8, flashBaseAddr[_spiffs_region], &val, 1 );
      Serial.print("Status 1:");
      Serial.println(val, BIN); //lets me see the bits more easily against the datasheet
    
      // cmd index 9 = read Status register #2 SPI
      flexspi_ip_read(9, flashBaseAddr[_spiffs_region], &val, 1 );
      Serial.print("Status 2:");
      Serial.println(val, BIN); //lets me see the bits more easily against the datasheet
    #endif
    }
    I would put it in eraseDevice and watFlash. You may get a lot of spew but you can put a test on it to print it periodically or just pull the usb cable.

    Order the SIM chip from digikey earlier today, may have at end of week for testing.

    EDIT:
    Forgot to add - bits you want to check is that the chip is write enabled (WEL) and no protection bits are set.
    Regarding to this suggestion,

    I was able to capture this debug output...
    Click image for larger version. 

Name:	image (4).png 
Views:	7 
Size:	34.8 KB 
ID:	21084
    Click image for larger version. 

Name:	image (3).png 
Views:	9 
Size:	33.2 KB 
ID:	21085

    After first 2 loops 1110001 -> 0, register status number is set to 1010101(never change after this).
    So status 1 and 2 are the same as 1010101.
    If you don't mind it, could you check this one too?

  9. #34
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,551
    Ok thanks for testing. From your last output you can see that the QE bit is not set in status register 2. As for why it hangs must have something wrong with my LUTs and write.

  10. #35
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,551
    @Han
    Sorry for the delay in getting back to you but got sidetracked. Can you give this a try, it doesn't hang my T4.1
    Code:
    	  if( flashID[1] == 0x70){
    		uint8_t val[0];
    		flexspi_ip_read(9, flashBaseAddr[_spiffs_region], &val, 1 );	
    
    		val[0] |= 1<<1;
    
    		FLEXSPI2_LUT28 = LUT0(CMD_SDR, PINS1, 0x50);
    		flexspi_ip_command(7, flashBaseAddr[_spiffs_region]);
    
    		  FLEXSPI2_LUT28 = LUT0(CMD_SDR, PINS1, 0x31) | LUT1(WRITE_SDR, PINS1, 1);
    		  flexspi_ip_write(7, flashBaseAddr[_spiffs_region], val, 1);
    	  }
    Changes highlighted in Red

  11. #36
    Member
    Join Date
    Jul 2020
    Location
    California
    Posts
    29
    Code:
    C:\Users\issac\OneDrive\Documents\Arduino\libraries\SPIFFS_t4\examples\flashtest6\flashtest6.ino Jul 22 2020 11:42:10
    
    PSRAM: 8 MB
    
     Enter 'y' in 6 seconds to format FlashChip - other to skip
    
    Status 1:1010000
    
    Status 2:1010000
    
    Status 1:1010101
    
    Status 2:1010101
    
    Status 1:10000
    
    Status 2:1010111
    
    Erasing... (may take some time)
    
    
    Chip erased in 0 seconds.
    
    
    Mount SPIFFS:
    
    Status 1:1010000
    
    Status 2:1010111
    
    Status 1:1010101
    
    Status 2:1010101
    
    Status 1:1010000
    
    Status 2:1010111
    
    Mount ADDR 0x800000 with res: 0
    Write file:
    
    Hello World! What a wonderful World :)
    
    errno -10010
    
    
    Directory contents:
    
    Read file:
    
    errno -10010
    
    
    
    
    
        ERAM ========== memory map ===== array* ======== check24() : WRITE !!!!
    ERAM length 0x7FFFFE element size of 1
    took 241413 elapsed us
        ERAM ============================ check24() : COMPARE !!!!
    took 225148 elapsed us
    Good, Found 24 in ERAM 7FFFFE Times
    
    
    Mount SPIFFS:
    
    Mount ADDR 0x800000 with res: 0
    Directory contents:
    It's no longer holding but it shows errorno -10010

    Quote Originally Posted by mjs513 View Post
    @Han
    Sorry for the delay in getting back to you but got sidetracked. Can you give this a try, it doesn't hang my T4.1
    Your T4.1 set up with W25Q128JVSIM running without a problem?

  12. #37
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,551
    Thanks. Looks something wit erase. But chip has life since check 24 isn’t throwing errors. QE bit is set so that’s a good sign. This would be easier when I get thE q chip to test with.

  13. #38
    Member
    Join Date
    Jul 2020
    Location
    California
    Posts
    29
    Take your time.

    Again, thank you so much for thoughtful assistance.

  14. #39
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,551
    @Han
    Yep my SIM chip is running without problems and believe me I am abusing it with all the dev work I did with it. Wonder if you could do me one mre thing. I am attaching a copy of my spiffs_t4 library that I am using. Was wondering if you could give it a try with flashtest6. Just replace your current folder with the attached. Just want to make sure we are at the same version with all the things we have been trying.
    Attached Files Attached Files

  15. #40
    Member
    Join Date
    Jul 2020
    Location
    California
    Posts
    29
    Quote Originally Posted by mjs513 View Post
    Before you unsolder the chip, the version i think you are using, isn't the latest so cant guarantee all examples or that it still works. The most current branch is: https://github.com/PaulStoffregen/te...FFS-FLASH-ONLY.
    I thought this is the right one?

    Welp, at this point, I can only hope on your latest library.

    I will test it out with that library.

  16. #41
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,551
    It is but we were making changes to our local copies so just want to make sure we are both on the same page. Once we get th Q version working I will push the update to github

    Mike

  17. #42
    Member
    Join Date
    Jul 2020
    Location
    California
    Posts
    29
    Code:
    C:\Users\issac\OneDrive\Documents\Arduino\libraries\SPIFFS_t4\examples\flashtest6\flashtest6.ino Jul 22 2020 12:41:10
    
    PSRAM: 8 MB
    
     Enter 'y' in 6 seconds to format FlashChip - other to skip
    
    Status 1:1110001
    
    Status 2:1110001
    
    Status 1:10000
    
    Status 2:10010
    
    Status 1:10000
    
    Status 2:10010
    
    Erasing... (may take some time)
    
    ...............................................................
    Chip erased in 31 seconds.
    
    
    Mount SPIFFS:
    
    Status 1:1010000
    
    Status 2:1010010
    
    Status 1:1010000
    
    Status 2:1010010
    
    Status 1:1010000
    
    Status 2:1010010
    
    Mount ADDR 0x800000 with res: 0
    Write file:
    
    Hello World! What a wonderful World :)
    
    
    
    Directory contents:
    
    my_file1 [0001] size:38
    Read file:
    
    Hello World! What a wonderful World :)
    
    
    
    
        ERAM ========== memory map ===== array* ======== check24() : WRITE !!!!
    ERAM length 0x7FFFFE element size of 1
    took 232263 elapsed us
        ERAM ============================ check24() : COMPARE !!!!
    took 225149 elapsed us
    Good, Found 24 in ERAM 7FFFFE Times
    
    
    Mount SPIFFS:
    
    Mount ADDR 0x800000 with res: 0
    Directory contents:
    
    my_file1 [0001] size:38
    It's working!

  18. #43
    Member
    Join Date
    Jul 2020
    Location
    California
    Posts
    29
    Quote Originally Posted by mjs513 View Post
    It is but we were making changes to our local copies so just want to make sure we are both on the same page. Once we get th Q version working I will push the update to github

    Mike
    I see, I was confused for a moment.

    M version is working without a problem now.

    Was it a QE bit all along?

  19. #44
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,551
    Yeah! Now aren’t you glad I asked you to try the same lib I was using

  20. #45
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,551
    Yep! Was the we bit all along! Sorry it took so long to register with me otherwise would have had you up and running a couple if days ago

  21. #46
    Member
    Join Date
    Jul 2020
    Location
    California
    Posts
    29
    Yes, I'm very glad that you shared with me XD

    If I had to work this out alone, it could've took me months to just to understand what is really going on between T4.1 and flash memory.

    I did see the difference from Q version but I had no idea I'm even guessing it right.

    I don't know what to say to tell you my full gratitude. All I can say is thank you in a formal way

  22. #47
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,551
    No need for thanks. Glad you tried it with the 'Q' version. Was bound to happen sooner or later, so appreciate letting us know that we could work out the issue. Will do some clean up and then push the changes to Github. Hope it helps your project.

  23. #48
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,551
    Oh - you might want to check out this thread on MTP Responder for SPIFFS. It setup up T4.1 to look like a USB drive in Windows so you can pull your spiff files off the flash and onto the PC.

    It is based on the MTP Responder which allows you to pull files from the SD Card to the PC and vice-versa.

  24. #49
    Member
    Join Date
    Jul 2020
    Location
    California
    Posts
    29
    It was my honor working with you.

    And I can assure you that T4.1 will be the heart of our project.

    Can't wait to see the official update.

    Sincerely,

    Alex Han

  25. #50
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,551
    Alex - just pushed the update to GITHUB - same link you posted. No real changes.

    Been fun - hope you can share your project at some point. Everyone is always interested - been some interesting projects out there.

Posting Permissions

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