It is not defined in your code. Is it a parameter defined in one of the libraries or am I missing something ?
I would really like to use this method and it looks quite nice but I am missing a piece of the puzzle here.
Can you help me , maybe with a bit more code on the declarations and used libraries so I can fix this ?
Kind regards
Robert
DSalomon wrote:This is a little late, but it can help somebody, doing a little changes to your code @CodeBreaker and the @martinayotte advice, I tested and this worked for me.Code: Select allvoid handleSpiffsUpload() {
HTTPUpload& upload = WebServer.upload();
if(upload.status == UPLOAD_FILE_START)
{
Serial.setDebugOutput(true);
WiFiUDP::stopAll();
Serial.printf("Update: %s\n", upload.filename.c_str());
}
else if(upload.status == UPLOAD_FILE_WRITE)
{
uint32_t startSpiffs = (uint32_t)&_SPIFFS_start - 0x40200000;
uint32_t _sector = (startSpiffs + upload.totalSize)/ SPI_FLASH_SEC_SIZE;
uint32_t data = (uint32_t)upload.buf;
Serial.printf("Location: 0x%x, TotalSize: %d", startSpiffs + upload.totalSize, upload.totalSize);
if((startSpiffs + upload.totalSize) % FLASH_SECTOR_SIZE == 0 )
{
if (spi_flash_erase_sector(_sector) == SPI_FLASH_RESULT_OK)
{
Serial.print(", Erased");
}
else
Serial.print(", ErrorErase");
}
if (spi_flash_write(startSpiffs + upload.totalSize, reinterpret_cast<uint32_t*>(data), upload.currentSize) == SPI_FLASH_RESULT_OK)
Serial.print(", Writen");
else
Serial.print(", ErrorWritten");
Serial.print("\n");
// _sector++;
}
else if(upload.status == UPLOAD_FILE_END)
{
Serial.printf("Update Success: %u\n ... \n", upload.totalSize);
Serial.setDebugOutput(false);
}
yield();
}
Regards,