Now with a Teensy 4.1, we got a built-in Ethernet module DP83825I.
I have a separate stand alone software that gets a HTML file from a SD card and save it to an external flash memory.
Code:
extern "C" uint8_t external_psram_size;
#include <SD.h>
#include <SPI.h>
#include <spiffs_t4.h>
#include <spiffs.h>
spiffs_t4 eFLASH;
//Setup files IO
spiffs_file file1;
#define DO_DEBUG 1
char ART_buf_ART_Webserver[387500];
char fname1[16] = "ART_Webserver";
elapsedMicros my_us;
void setup() {
while (!Serial);
Serial.println("\n" __FILE__ " " __DATE__ " " __TIME__);
Serial.printf("PSRAM: %d MB\n", external_psram_size);
Serial.println("\n Enter y in 10 seconds to format FlashChip - other to skip");
uint32_t pauseS = millis();
char chIn = 9;
while ( pauseS + 10000 > millis() && 9 == chIn ) {
if ( Serial.available() ) {
do {
if ( chIn != 'y' )
chIn = Serial.read();
else
Serial.read();
}
while ( Serial.available() );
}
}
if ( chIn == 'y' ) {
int8_t result = eFLASH.begin();
if(result == 0) {
eFLASH.eraseFlashChip();
} else if(result == 1){
eFLASH.eraseDevice();
} else {
Serial.println("ERROR!");
}
}
Serial.print("Initializing SD card...");
// see if the card is present and can be initialized:
if (!SD.begin(BUILTIN_SDCARD)) {
Serial.println("Card failed, or not present");
// don't do anything more:
return;
}
Serial.println("card initialized.");
Serial.println();
Serial.println("Mount SPIFFS:");
eFLASH.begin();
eFLASH.fs_mount();
// open the file.
File ART_Webserver_file = SD.open("RD0030~1.HTM");
if (ART_Webserver_file) {
uint32_t count = 0;
while (ART_Webserver_file.available()) {
ART_buf_ART_Webserver[count] = ART_Webserver_file.read();
count++;
}
ART_buf_ART_Webserver[count] = '\0';
Serial.println("Write files...");
eFLASH.f_writeFile(fname1, ART_buf_ART_Webserver, SPIFFS_CREAT | SPIFFS_TRUNC | SPIFFS_RDWR);
Serial.println("Writing successful");
ART_Webserver_file.close();
} else {
Serial.println("error opening RD0030~1.HTM file, power cycle the Teensy 4.1");
return;
}
memset(ART_buf_ART_Webserver, 0, sizeof(ART_buf_ART_Webserver));
Serial.println("Read file:");
eFLASH.f_readFile(fname1, ART_buf_ART_Webserver, sizeof(ART_buf_ART_Webserver)/sizeof(char), SPIFFS_RDONLY);
Serial.println(ART_buf_ART_Webserver);
Serial.println();
Serial.println("Mount SPIFFS:");
Serial.println("Directory contents:");
eFLASH.fs_listDir();
}
void loop() {
}
After that, using an actual code for this project, I just simply read that to an EXTMEM char buffer...
and client.print the whole char array which is a string.
But, I get this as an output
If you pay attention to the html file from client side, client side web browser didn't get the whole html file.
It's actually truncated at the middle of the code for some reason.
Compared to my Teensy 4.0 project to this one, there are three different factors.
- I'm currently using built-in Ethernet module with NativeEthernet.h library.
- Hardware set up looks like this.
I just cut off the RJ45 and directly solder it to T4.1.
-Instead of converting a HTML file to a c-string, now I get that using spiffs feature.
Other than that, HTML file and other software components are the same.
Should I just go back to Wiz850 and use a simple Ethernet.h library?
I'm no Ethernet related engineer but willing to learn what is really going on.
Already went over couple different engineering department in our company but no one knows what's the core issue I'm missing.