defragster
Senior Member+
@PaulStoffregen - Question - re p#375 - seems a locked T_4.1 cannot report 9Blinks and that is expected behavior?
Morning allI thought I would try some goofing off and see how hard some of this might be... Maybe should be own thread.
So far, I have put up a few changes in my fork and new branch: https://github.com/KurtE/cores/tree/variants_override
Cool that you started playing with LittleFS - getting sidetracked on getting a OV7670 camera working with the dev board - been a while so trying to remember what we did....LittleFS_RAM myfs; works but ListFiles was a boring start with empty disk.
Losing USB and getting the red flashed
C:\Users\Merli\AppData\Local\Temp\.arduinoIDE-unsaved2024010-5676-1uspepn.7ijm\LittleFS_PSRAM_Simple_Datalogger\LittleFS_PSRAM_Simple_Datalogger.ino Jan 10 2024 07:31:36
Initializing LittleFS ...LittleFS initialized.
Menu Options:
l - List files on disk
e - Erase files on disk
s - Start Logging data (Restarting logger will append records to existing log)
x - Stop Logging data
d - Dump Log
h - Menu
Space Used = 4096
Filesystem Size = 7340032
Directory
---------
Logging Data!!!
9,8,9
8,8,8
8,8,8
9,8,8
9,8,8
9,8,8
8,7,8
9,8,8
8,8,8
9,8,8
9,8,8
8,8,8
9,8,8
9,8,8
9,8,8
8,8,8
9,8,8
9,8,8
8,8,8
8,8,8
9,8,8
9,9,8
9,8,8
9,8,8
8,8,8
9,8,8
9,8,8
Stopped Logging Data!!!
Records written = 27
Dumping Log!!!
9,8,9
8,8,8
8,8,8
9,8,8
9,8,8
9,8,8
8,7,8
9,8,8
8,8,8
9,8,8
9,8,8
8,8,8
9,8,8
9,8,8
9,8,8
8,8,8
9,8,8
9,8,8
8,8,8
8,8,8
9,8,8
9,9,8
9,8,8
9,8,8
8,8,8
9,8,8
9,8,8
I know I am not @PaulStoffregenKnow this was discussed somewhere else but how is the chip identified as a micromod or 4.1 or 4.0 - there has to be a chip id burn in someplace????
#if defined(ARDUINO_TEENSY40)
0x00200000, // sflashA1Size 0x50
#elif defined(ARDUINO_TEENSY41)
0x00800000, // sflashA1Size 0x50
#elif defined(ARDUINO_TEENSY_MICROMOD)
0x01000000, // sflashA1Size 0x50
#else
#error "Unknow flash chip size";
#endif
// For USB types that don't explicitly define BCD_DEVICE,
// use the minor version number to help teensy_ports
// identify which Teensy model is used.
#if defined(__IMXRT1062__) && defined(ARDUINO_TEENSY40)
0x79, 0x02, // Teensy 4.0
#elif defined(__IMXRT1062__) && defined(ARDUINO_TEENSY41)
0x80, 0x02, // Teensy 4.1
#elif defined(__IMXRT1062__) && defined(ARDUINO_TEENSY_MICROMOD)
0x81, 0x02, // Teensy MicroMod
#else
0x00, 0x02,
#endif
Obviously still WIP - as there is something horribly wrong with the DataLogger example, yet both of the others are working on SDRAM DevBoard!
Noticed that but they all depend onAs I mentioned in the post yesterday bootdata.c file, there is:
defined(ARDUINO_TEENSY40)
char* buf;
buf = (char*)malloc(390 * 1024 * sizeof(char));
if (!myfs.begin(&buf, 390 * 1024 * sizeof(char))) {
Serial.printf("Error starting %s\n", "PSRAM RAM DISK");
while (1) {
// Error, so don't do anything more - stay stuck here
}
}
You're passing the address of buf to myfs.begin() instead of the value directly.@defragster
I tried this with bot a teens4.1 and the dev boardh and both would just restart (note I commented out the scb 0x9... for testing)
Code:char* buf; buf = (char*)malloc(390 * 1024 * sizeof(char)); if (!myfs.begin(&buf, 390 * 1024 * sizeof(char))) { Serial.printf("Error starting %s\n", "PSRAM RAM DISK"); while (1) { // Error, so don't do anything more - stay stuck here } }
Think there may be an issue with using malloc with littlefs not sure if it a setting yet - now back to the camera stuff
If you run out of things to add, I can probably think of a few othersI'll reach out in March, we should have a next gen devboard by then with some more features that's been requested by mjs513 and jmarsh.
ok - just tried it again and it worked. Ok strange - when I did it the first time it failed. Argh - getting a headache with this!!! Thanks for making me try it again.You're passing the address of buf to myfs.begin() instead of the value directl
/*
LittleFS datalogger
This example shows how to log data from three analog sensors
to an storage device such as a FLASH.
This example code is in the public domain.
*/
#include <LittleFS.h>
// NOTE: This option is only available on the Teensy 4.1 board with added bottomside PSRAM chip(s) in place.
// This declares the LittleFS Media type and gives a text name to Identify in use
LittleFS_RAM myfs;
#include <SDRAM_t4.h>
//constructor for
SDRAM_t4 sdram;
#define MYPSRAM 7 // compile time PSRAM size and is T_4.1 specific either 8 or 16, or smaller portion
//EXTMEM char buf[MYPSRAM * 1024 * 1024]; // Contents preserved with Power on Restart and Upload
File dataFile; // Specifes that dataFile is of File type
int record_count = 0;
bool write_data = false;
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(115200);
while (!Serial) {
// wait for serial port to connect.
}
Serial.println("\n" __FILE__ " " __DATE__ " " __TIME__);
if(CrashReport) {
Serial.print(CrashReport);
while(1);
}
// sdram.begin initializes the available SDRAM Module
// begin defaults to 32mb but you can specify the size
// from begin
// begin(uint16 external_memory_size) where size is in
// MB
if(!sdram.begin()) {
Serial.printf("SDRAM Init Failed!!!\n");
while(1);
};
Serial.print("Initializing LittleFS ...");
// see if you are able to create a RAM disk in the space you a lotted
// buf = is the name of the array you created, sizedf(buf) is how large the
// array is, in our case 390 * 1024.
char* buf;
buf = (char*)sdram_malloc(MYPSRAM * 1024 * 1024 * sizeof(char));
if (!myfs.begin(buf, MYPSRAM * 1024 * 1024 * sizeof(char))) {
Serial.printf("Error starting %s\n", "PSRAM RAM DISK");
while (1) {
// Error, so don't do anything more - stay stuck here
}
}
Serial.println("LittleFS initialized.");
menu();
}
void loop()
{
if ( Serial.available() ) {
char rr;
rr = Serial.read();
switch (rr) {
case 'l': listFiles(); break;
case 'e': eraseFiles(); break;
case 's':
{
Serial.println("\nLogging Data!!!");
write_data = true; // sets flag to continue to write data until new command is received
// opens a file or creates a file if not present, FILE_WRITE will append data to
// to the file created.
dataFile = myfs.open("datalog.txt", FILE_WRITE);
logData();
}
break;
case 'x': stopLogging(); break;
case 'd': dumpLog(); break;
case '\r':
case '\n':
case 'h': menu(); break;
}
while (Serial.read() != -1) ; // remove rest of characters.
}
if(write_data) logData();
}
void logData()
{
// make a string for assembling the data to log:
String dataString = "";
// read three sensors and append to the string:
for (int analogPin = 0; analogPin < 3; analogPin++) {
int sensor = analogRead(analogPin);
dataString += String(sensor);
if (analogPin < 2) {
dataString += ",";
}
}
// if the file is available, write to it:
if (dataFile) {
dataFile.println(dataString);
// print to the serial port too:
Serial.println(dataString);
record_count += 1;
} else {
// if the file isn't open, pop up an error:
Serial.println("error opening datalog.txt");
}
delay(100); // run at a reasonable not-too-fast speed for testing
}
void stopLogging()
{
Serial.println("\nStopped Logging Data!!!");
write_data = false;
// Closes the data file.
dataFile.close();
Serial.printf("Records written = %d\n", record_count);
}
void dumpLog()
{
Serial.println("\nDumping Log!!!");
// open the file.
dataFile = myfs.open("datalog.txt");
// if the file is available, write to it:
if (dataFile) {
while (dataFile.available()) {
Serial.write(dataFile.read());
}
dataFile.close();
}
// if the file isn't open, pop up an error:
else {
Serial.println("error opening datalog.txt");
}
}
void menu()
{
Serial.println();
Serial.println("Menu Options:");
Serial.println("\tl - List files on disk");
Serial.println("\te - Erase files on disk");
Serial.println("\ts - Start Logging data (Restarting logger will append records to existing log)");
Serial.println("\tx - Stop Logging data");
Serial.println("\td - Dump Log");
Serial.println("\th - Menu");
Serial.println();
}
void listFiles()
{
Serial.print("\n Space Used = ");
Serial.println(myfs.usedSize());
Serial.print("Filesystem Size = ");
Serial.println(myfs.totalSize());
printDirectory(myfs);
}
void eraseFiles()
{
myfs.quickFormat(); // performs a quick format of the created di
Serial.println("\nFiles erased !");
}
void printDirectory(FS &fs) {
Serial.println("Directory\n---------");
printDirectory(fs.open("/"), 0);
Serial.println();
}
void printDirectory(File dir, int numSpaces) {
while(true) {
File entry = dir.openNextFile();
if (! entry) {
//Serial.println("** no more files **");
break;
}
printSpaces(numSpaces);
Serial.print(entry.name());
if (entry.isDirectory()) {
Serial.println("/");
printDirectory(entry, numSpaces+2);
} else {
// files have sizes, directories do not
printSpaces(36 - numSpaces - strlen(entry.name()));
Serial.print(" ");
Serial.println(entry.size(), DEC);
}
entry.close();
}
}
void printSpaces(int num) {
for (int i=0; i < num; i++) {
Serial.print(" ");
}
}
C:\Users\Merli\AppData\Local\Temp\.arduinoIDE-unsaved2024010-34448-7vj3fm.x2xk\LittleFS_PSRAM_Simple_Datalogger\LittleFS_PSRAM_Simple_Datalogger.ino Jan 10 2024 10:58:44
Initializing LittleFS ...LittleFS initialized.
Menu Options:
l - List files on disk
e - Erase files on disk
s - Start Logging data (Restarting logger will append records to existing log)
x - Stop Logging data
d - Dump Log
h - Menu
Space Used = 4096
Filesystem Size = 7340032
Directory
---------
Logging Data!!!
7,3,7
7,4,8
7,3,8
6,3,8
6,3,8
7,4,10
7,4,8
8,4,8
6,2,8
8,3,8
7,4,9
8,3,8
7,3,9
8,2,9
7,3,6
7,2,8
7,2,11
7,3,8
6,3,8
7,2,8
5,3,8
7,3,8
7,2,8
7,3,9
7,3,8
8,2,8
8,3,8
7,3,9
Stopped Logging Data!!!
Records written = 28
Dumping Log!!!
7,3,7
7,4,8
7,3,8
6,3,8
6,3,8
7,4,10
7,4,8
8,4,8
6,2,8
8,3,8
7,4,9
8,3,8
7,3,9
8,2,9
7,3,6
7,2,8
7,2,11
7,3,8
6,3,8
7,2,8
5,3,8
7,3,8
7,2,8
7,3,9
7,3,8
8,2,8
8,3,8
7,3,9
Space Used = 4096
Filesystem Size = 7340032
Directory
---------
datalog.txt 198
All eLCDIF/FlexIO2 pins have been brought out.I have not checked yet to see how many display signals are brought out.. Like maybe enough to connect to something like:
https://www.adafruit.com/product/1590 ?
@mjs513 - this issue {p#374 & #375} was the existing shipped RAM example - not PSRAM or SDRAM - just: char buf[ 390 * 1024 ]; // BUFFER in RAM1Not TD 1.59 specific! Clean 1.8.19 unzipped to two folders then 1.57 in one and 1.58 in the other have the similar behavior
> except counting 8 Blinks on TD1.57 - and 9 Blinks on 1.59.4.
> Had to go back to 1.58 : it fails to show on USB, but is not showing any Blink codes.
BETA 4 of 1.59 Issue ? @PaulStoffregen
Clean unzip of Arduino IDE 1.8.19 to new folder and install TD 1.59.4.
Using example: "...\hardware\teensy\avr\libraries\LittleFS\examples\Test_Integrity\RAM\RAM.ino"
Build default FASTER and it works as expected with 1st T_4.1 below.
Build DEBUG and it goes OFFLINE/Missing after Upload.
> 1st T_4.1 LOCKED and NO BLINKS on power on
> 2nd T_4.1 pre-lockable and 9Blinks on power on.
just to reiterate - prior posts had no relation to SDRAM - JUST LittleFS using RAM on DEBUG build on a T_4.1@PaulStoffregen - @defragster
If I try that same sketch on a T4.1 it freezes the T41. If I unplug it and plug it back in it show the 9 red blinks.
EDIT: If reload the psram simple datalogger sketch it works with the SCB set at 0x9......
Bottom line - dont include sdram_t4 if there is no SDRAM chip available.
As I said, it is hard to resist adding things when there is space
It was an early task I mentioned - finally remembered it might be a fun test - FUN IT HAS NOT BEENCool that you started playing with LittleFS - getting sidetracked on getting a OV7670 camera working with the dev board - been a while so trying to remember what we did....
Nope - not needed when using the library - only need the mod to the t_mm.ld if you want to use it like extmem which Paul has already said he is not going to entertain for now.noticed coreFiles on the extra github created does not include the T_MM.LD.
Dont see why it shouldnt build - will check when I get a chance - probably late todayThe post #386 SDRAM example - like the one here - fails building here under 1.8.19 for some reason. Mayve there is something else in cores out of sync?
D:\Users\Merli\Documents\Arduino\sketch_jan11a\sketch_jan11a.ino Jan 11 2024 12:17:57
CrashReport:
A problem occurred at (system time) 12:18:1
Code was executing from address 0x6D86
CFSR: 400
(IMPRECISERR) Data bus error but address not related to instruction
Temperature inside the chip was 50.12 °C
Startup CPU clock speed is 600MHz
Reboot was caused by auto reboot after fault or bad interrupt detected
Opps - Yes, it builds - no issues there. But will not run as prev noted.The post #386 SDRAM example - like the one here - fails building here under 1.8.19 for some reason. Mayve there is something else in cores out of sync?
Builds fine for me using faster but I get a crash report when it runs
...
SCB_MPU_RBAR = 0x80000000 | REGION(i++); // SEMC: SDRAM, NAND, SRAM, etc
SCB_MPU_RASR = MEM_CACHE_WBWA | READWRITE | NOEXEC | SIZE_1G;
// hardware: https://forum.pjrc.com/index.php?threads/73898/#post-334041
// software: https://github.com/mjs513/SDRAM_t4
asm("nop"); // allow a few cycles for bus writes before enable MPU
asm("nop");
asm("nop");
asm("nop");
asm("nop");
asm("nop");
SCB_MPU_CTRL = SCB_MPU_CTRL_ENABLE;
Does a volatile dmb (or possibly dsb) instruction work in place of the nops?Recommend testing with the latest core library startup.c (which enables 80000000-BFFFFFFF). Testing (without SDRAM) showed a delay is needed between writing the MPU config and actually enabling the MPU.
Thanks Paul - thought crossed my mind about delays but never tried itRecommend testing with the latest core library startup.c (which enables 80000000-BFFFFFFF). Testing (without SDRAM) showed a delay is needed between writing the MPU config and actually enabling the MPU.
Sketch | T4.1 | Dev board | Other | ||
w 2mb | w/o 2mb | w/2mb | w/o 2mb | ||
LittleFS/SDRAM | Works, dies gracefully | Works, dies gracefully | works - runs successfully | looses the Dev board | TO MAKE IT WORK with no 2 2mb HAD TO COMMENT OUT ONE NOP??? Timinig issue??? |
ILI9341_t3n/Camer/SDRAM | Not tested | Not Tested | works - runs successfully | works - runs successfully | TO MAKE IT WORK HAD TO COMMENT OUT ONE NOP??? Timinig issue??? |
ILI9488/Camer/SDRAM (note special branch used) | Not tested | Not Tested | works - runs successfully | works - runs successfully | TO MAKE IT WORK HAD TO COMMENT OUT ONE NOP??? Timinig issue??? |
LittleFS Pgm Data logger | Works | Works | Works | Works | TO MAKE IT WORK HAD TO COMMENT OUT ONE NOP??? Timinig issue??? |