decode reset issue -- bug?
freemanzwin opened this issue · comments
hi.
(sorry. my english very poor.)
- my firmware scheme:
- read SD file -> copy to psram -> jpeg decode-> display lcd
- my test module system:
-
Arduino/PlatformIO
-
H/W
ESP32
ST7789 240x240
SD -
Library
eSPI
JPEGDEC
- test sample code:
typedef struct _ImageData{
String name;
uint32_t sz;
uint8_t *data;
}ImageData;
bool loadImageFile(ImageData *image)
{
File file;
file = SD.open(image->name);
if (!file) {
Serial.printf("Error opening %s file\n", image->name.c_str());
return false;
}
image->sz = file.size();
if((image->data = (uint8_t *)ps_malloc(image->sz)) == NULL)
{
Serial.println("Failed to malloc");
file.close();
return false;
}
Serial.printf("Opening %s file, size: %d\n", image->name.c_str(), image->sz);
file.read((uint8_t *)image->data, image->sz);
file.close();
return true;
}
void JPEGDraw(JPEGDRAW *pDraw)
{
tft.pushImage(pDraw->x, pDraw->y, pDraw->iWidth, pDraw->iHeight, pDraw->pPixels);
} /* JPEGDraw() */
void setup() {
Serial.begin(115200);
//while (!Serial);
Serial.println("Starting...");
if(initSdCard(SD_CS) == 0)
log_n("SD Card mounted!");
imageData.name = "/images/cat1.jpg";
if(loadImageFile(&imageData) == false){
Serial.print(imageData.name);
Serial.println(" Image Load Error !!!");
return;
}
// put your setup code here, to run once:
tft.begin();
tft.setRotation(3); // PyPortal native orientation
tft.setSwapBytes(true);
} /* setup() */
void loop() {
int i;
long lTime;
int iOption[4] = {0, JPEG_SCALE_HALF, JPEG_SCALE_QUARTER, JPEG_SCALE_EIGHTH};
int iCenterX[4] = {0,80,120,140};
int iCenterY[4] = {0,60,90,105};
for (i=0; i<4; i++)
{
tft.fillScreen(TFT_BLACK);
tft.startWrite(); // Not sharing TFT bus on PyPortal, just CS once and leave it
if (jpeg.openRAM(imageData.data, imageData.sz, JPEGDraw))
{
lTime = micros();
if (jpeg.decode(iCenterX[i],iCenterY[i], iOption[i]))
{
lTime = micros() - lTime;
Serial.printf("%d x %d image, decode time = %d us\n", jpeg.getWidth() >> i, jpeg.getHeight() >> i, (int)lTime);
}
else{
Serial.printf("\ndecode Error %s file. Error: %d\n", imageData.name.c_str(), jpeg.getLastError());
}
jpeg.close();
}
else
Serial.printf("openRAM Error opening %s file\n", imageData.name.c_str());
delay(2000); // pause between images
} // for i
} /* loop() */
- Exception error message
Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x4008bf40 PS : 0x00060031 A0 : 0x8008a98a A1 : 0x3ffb1c80
A2 : 0x00000000 A3 : 0x00000000 A4 : 0x3ffc5b20 A5 : 0x3ffb1c60
A6 : 0x00000000 A7 : 0x3ffb0060 A8 : 0x8008be11 A9 : 0x3ffb1c50
A10 : 0x3ffbedf4 A11 : 0x000000fe A12 : 0x00000001 A13 : 0x00000000
A14 : 0x00000000 A15 : 0x00000000 SAR : 0x0000001f EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000030 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0x0fffee3a
Backtrace: 0x4008bf40:0x3ffb1c80 0x4008a987:0x3ffb1ca0 0x4008ccdd:0x3ffb1cc0 0x40086f5a:0x3ffb1cd0 0x4000c2ee:0x3ffb1d90 0x400d6bf2:0x3ffb1da0 0x400d13b5:0x3ffb1f50 0x400da6c5:0x3ffb1fb0 0x4008a899:0x3ffb1fd0
--------------------------------------------------------------
PC: 0x4008bf40: xTaskIncrementTick at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/tasks.c line 2596
EXCVADDR: 0x00000030
Decoding stack results
0x4008bf40: xTaskIncrementTick at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/tasks.c line 2596
0x4008a987: xPortSysTickHandler at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 289
**0x400d6bf2: JPEGDEC::decode(int, int, int) at D:\workspace\Arduino\libraries\JPEGDEC\src/jpeg.c line 1307**
0x400d13b5: loop() at D:\workspace\Arduino\code\ESP32_JPEGDEC_adafruit_gfx_demo_sd/ESP32_JPEGDEC_adafruit_gfx_demo_sd.ino line 210
0x400da6c5: loopTask(void*) at C:\Users\freemanz\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.4\cores\esp32\main.cpp line 19
0x4008a899: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143
- error location in file -> print insert
static void JPEGGetMoreData(JPEGIMAGE *pPage)
{
// printf("Getting more data...\n");
// move any existing data down
if ((pPage->iVLCSize - pPage->iVLCOff) >= FILE_HIGHWATER)
return; // buffer is already full; no need to read more data
if (pPage->iVLCOff != 0)
{
printf("JPEGGetMoreData: %d(pPage->iVLCSize) - %d(pPage->iVLCOff) = %d \n", pPage->iVLCSize, pPage->iVLCOff, pPage->iVLCSize - pPage->iVLCOff);
memcpy(pPage->ucFileBuf, &pPage->ucFileBuf[pPage->iVLCOff], pPage->iVLCSize - pPage->iVLCOff);
pPage->iVLCSize -= pPage->iVLCOff;
pPage->iVLCOff = 0;
pPage->bb.pBuf = pPage->ucFileBuf; // reset VLC source pointer too
}
if (pPage->JPEGFile.iPos < pPage->JPEGFile.iSize && pPage->iVLCSize < FILE_HIGHWATER)
{
int i;
// Try to read enough to fill the buffer
i = (*pPage->pfnRead)(&pPage->JPEGFile, &pPage->ucFileBuf[pPage->iVLCSize], JPEG_FILE_BUF_SIZE - pPage->iVLCSize); // max length we can read
// Filter out the markers
pPage->iVLCSize += JPEGFilter(&pPage->ucFileBuf[pPage->iVLCSize], &pPage->ucFileBuf[pPage->iVLCSize], i, &pPage->ucFF);
}
} /*
- print result
[D][esp32-hal-psram.c:48] psramInit(): PSRAM enabled
Starting...
SD Card Type: SDHC
SD Card Size: 3776MB
Total space: 3768MB
Used space: 5MB
Free space: 3762MB
SD opened!
[E][Blink.cpp:174] setup(): SD Card mounted!
Opening /images/cat1.jpg file, size: 65528
JPEGGetMoreData: 2046(pPage->iVLCSize) - 1538(pPage->iVLCOff) = 508
JPEGGetMoreData: 2045(pPage->iVLCSize) - 1537(pPage->iVLCOff) = 508
JPEGGetMoreData: 2045(pPage->iVLCSize) - 1602(pPage->iVLCOff) = 443
JPEGGetMoreData: 2043(pPage->iVLCSize) - 1543(pPage->iVLCOff) = 500
JPEGGetMoreData: 2046(pPage->iVLCSize) - 1563(pPage->iVLCOff) = 483
JPEGGetMoreData: 2044(pPage->iVLCSize) - 1554(pPage->iVLCOff) = 490
JPEGGetMoreData: 2044(pPage->iVLCSize) - 1607(pPage->iVLCOff) = 437
JPEGGetMoreData: 2046(pPage->iVLCSize) - 1638(pPage->iVLCOff) = 408
JPEGGetMoreData: 2043(pPage->iVLCSize) - 1613(pPage->iVLCOff) = 430
JPEGGetMoreData: 2046(pPage->iVLCSize) - 1564(pPage->iVLCOff) = 482
JPEGGetMoreData: 2046(pPage->iVLCSize) - 1622(pPage->iVLCOff) = 424
JPEGGetMoreData: 2046(pPage->iVLCSize) - 1603(pPage->iVLCOff) = 443
JPEGGetMoreData: 2046(pPage->iVLCSize) - 1599(pPage->iVLCOff) = 447
JPEGGetMoreData: 2045(pPage->iVLCSize) - 1545(pPage->iVLCOff) = 500
JPEGGetMoreData: 2046(pPage->iVLCSize) - 1611(pPage->iVLCOff) = 435
JPEGGetMoreData: 2044(pPage->iVLCSize) - 1606(pPage->iVLCOff) = 438
JPEGGetMoreData: 2047(pPage->iVLCSize) - 1589(pPage->iVLCOff) = 458
JPEGGetMoreData: 2044(pPage->iVLCSize) - 1539(pPage->iVLCOff) = 505
JPEGGetMoreData: 2046(pPage->iVLCSize) - 1573(pPage->iVLCOff) = 473
JPEGGetMoreData: 2045(pPage->iVLCSize) - 1607(pPage->iVLCOff) = 438
JPEGGetMoreData: 2046(pPage->iVLCSize) - 1577(pPage->iVLCOff) = 469
JPEGGetMoreData: 2046(pPage->iVLCSize) - 1625(pPage->iVLCOff) = 421
JPEGGetMoreData: 2047(pPage->iVLCSize) - 1630(pPage->iVLCOff) = 417
JPEGGetMoreData: 2043(pPage->iVLCSize) - 1614(pPage->iVLCOff) = 429
JPEGGetMoreData: 2046(pPage->iVLCSize) - 1547(pPage->iVLCOff) = 499
JPEGGetMoreData: 2044(pPage->iVLCSize) - 1617(pPage->iVLCOff) = 427
JPEGGetMoreData: 2046(pPage->iVLCSize) - 1544(pPage->iVLCOff) = 502
JPEGGetMoreData: 2047(pPage->iVLCSize) - 1603(pPage->iVLCOff) = 444
JPEGGetMoreData: 2048(pPage->iVLCSize) - 1644(pPage->iVLCOff) = 404
JPEGGetMoreData: 2045(pPage->iVLCSize) - 1563(pPage->iVLCOff) = 482
JPEGGetMoreData: 2045(pPage->iVLCSize) - 1579(pPage->iVLCOff) = 466
JPEGGetMoreData: 2047(pPage->iVLCSize) - 1594(pPage->iVLCOff) = 453
JPEGGetMoreData: 2046(pPage->iVLCSize) - 1537(pPage->iVLCOff) = 509
JPEGGetMoreData: 2046(pPage->iVLCSize) - 1548(pPage->iVLCOff) = 498
JPEGGetMoreData: 2046(pPage->iVLCSize) - 1633(pPage->iVLCOff) = 413
JPEGGetMoreData: 2046(pPage->iVLCSize) - 1602(pPage->iVLCOff) = 444
JPEGGetMoreData: 2046(pPage->iVLCSize) - 1598(pPage->iVLCOff) = 448
JPEGGetMoreData: 2043(pPage->iVLCSize) - 1610(pPage->iVLCOff) = 433
JPEGGetMoreData: 2045(pPage->iVLCSize) - 1542(pPage->iVLCOff) = 503
JPEGGetMoreData: 2047(pPage->iVLCSize) - 1583(pPage->iVLCOff) = 464
**JPEGGetMoreData: 1355(pPage->iVLCSize) - 1584(pPage->iVLCOff) = -229**
Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x4008bed8 PS : 0x00060031 A0 : 0x8008a972 A1 : 0x3ffbbf10
A2 : 0x00000000 A3 : 0x00000000 A4 : 0x3ffc58ac A5 : 0x00000001
A6 : 0x00060120 A7 : 0x00000000 A8 : 0x8008bda9 A9 : 0x3ffbbee0
A10 : 0x3ffbedf4 A11 : 0x000000fe A12 : 0x00000001 A13 : 0x00000000
A14 : 0x00000000 A15 : 0x00000000 SAR : 0x0000001d EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000030 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000
Backtrace: 0x4008bed8:0x3ffbbf10 0x4008a96f:0x3ffbbf30 0x4008cb81:0x3ffbbf50 0x40086f42:0x3ffbbf60 0x400f980f:0x3ffbc020 0x400dc4bf:0x3ffbc040 0x4008bd72:0x3ffbc060 0x4008a881:0x3ffbc080
Rebooting...
ets Jun 8 2016 00:22:57
rst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5828
entry 0x400806ac
Thank you for the detailed bug report. It unfortunately doesn't help me to know what went wrong. Can you please email me the JPEG file? I'll test here on my setup. I have an ESP32 with PSRAM, so I can test it. Send to bitbank@pobox.com.
The file has been sent. thanks.
Thank you for the detailed bug report. It unfortunately doesn't help me to know what went wrong. Can you please email me the JPEG file? I'll test here on my setup. I have an ESP32 with PSRAM, so I can test it. Send to bitbank@pobox.com.
The file has been sent. please check. thanks.
Thank you for sending the file. It allowed me to see and fix the problem. I created a new release with the fix and I also merged the Floyd-Steinberg dither code into it.