-->
Page 1 of 1

Crash trying to write to SPIFFS

PostPosted: Tue Dec 25, 2018 11:46 pm
by treii28
I'm trying to convert a couple of sketches surrounding the Adafruit library for Jpeg serial cameras to work on an ESP-01 with a 1m memory chip. While I may play later trying to direct stream the image to the Async server code (if I can figure that part out), for the time being I am trying to write a temporary file from the camera to SPIFFS, but as soon as I call the File.write(buffer, len) function, my Esp01 is crashing and resetting.

The Adafruit library uses a handle to SoftwareSerial which I have made sure is using ESPSoftwareSerial (using platformio to code in CLion). I'm not sure what the restrictions on the camera are, but the Adafruit code seems to suggest that you have to download the image data in blocks. Most of the examples I have seen either read 32 or 64 bytes at a time from the camera using the Adafruit library's read function.
(I have yet to find a spec on the camera's protocol, but the byte value is being sent with a 2 digit hex value in a hex character string. So unless it's an MSB/LSB value set, it would seem to have a 255 limit?)

The examples then usually write to an SD card using:
File imgFile = SD.open("IMAGE.JPG", FILE_WRITE);
For SPIFFS, I changed this to:
File imgFile = SPIFFS.open("/IMAGE.JPG", "w");

But as soon as I read the first 64 bytes and go to write them, the esp-01 crashes. Relevant code:


Code: Select all/**
 * snap a picture on the jpeg camera using Adafruit_VC0706 library
 *   send resulting file direct from filesystem via ESP8266AsyncWebServer
 *
 * @param {AsyncWebServerRequest*} request
 * @return
 */
bool snapPic(AsyncWebServerRequest *request) {
    Serial.println("Snapping photo...");

    if (! cam.takePicture()) {
        Serial.println("Failed to snap!");
        returnFail(request, "Failed to snap picture.");
        return false;
    }
    else
        Serial.println("Picture taken!");

    // Create an image with the name Image.jpg
    String filename = "/Image.jpg";
    Serial.println("Writing file to SPIFFS: " + filename);
    // remove file if it already exists
    if (!SPIFFS.exists(filename)) SPIFFS.remove(filename);
    // Open the file for writing
    File imgFile = SPIFFS.open(filename, "w");

    // Get the size of the image (frame) taken
    uint16_t jpglen = cam.frameLength();
    //byte wCount = 0; // For counting # of writes

    // read 32/64 bytes at a time;
    uint16_t minByte = 64; // change 32 to 64 for a speedup but may not work with all setups!

    Serial.print("Storing ");
    Serial.print(jpglen, DEC);
    Serial.print(" byte image.");

    int32_t time = millis();

    // Read all the data up to # bytes!
    while (jpglen > 0) {
        uint8_t *buffer;
        uint8_t bytesToRead = min(minByte, jpglen);
        buffer = cam.readPicture(bytesToRead);
        Serial.print("-> Read ");  Serial.print(bytesToRead, DEC); Serial.println(" bytes"); // debugging
        /********* appears to be crashing on next line *********/
        imgFile.write(buffer, bytesToRead);
        Serial.print("Wrote -> ");  Serial.print(bytesToRead, DEC); Serial.println(" bytes"); // debugging
        /* normal feedback
        if(++wCount >= 64) { // Every 2K, give a little feedback so it doesn't appear locked up
            Serial.print('.');
            wCount = 0;
        }
         */
        jpglen -= bytesToRead;
    }
    imgFile.close();

    time = millis() - time;
    Serial.println("done!");
    Serial.print(time); Serial.println(" ms elapsed");

    request->send(SPIFFS, filename, "image/jpeg");
    return true;
}


Code output with crash dump is below:
Code: Select allSnapping photo...

Picture taken!
Writing file to SPIFFS: /Image.jpg

Storing 12336 byte image.
-> Read 64 bytes

Exception (28):
epc1=0x4021d090 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

ctx: sys
sp: 3fffead0 end: 3fffffb0 offset: 01a0

>>>stack>>>
3fffec70:  00000036 0000000a 3ffefa14 40212d24 
3fffec80:  3ffef190 3ffefb28 3ffef7dc 40212fc1 
3fffec90:  3fffecce 00369c66 402016a4 00000001 
3fffeca0:  00000040 3fff1784 3fff0d08 4020668c 
3fffecb0:  3ffef190 3ffefb28 3ffef768 402068b3 
3fffecc0:  00000000 00000000 3fff0d08 40203312 
3fffecd0:  3fff1784 00000006 3ffefa14 40212d24 
3fffece0:  3fff1784 00000040 3ffefa14 40212fc1 
3fffecf0:  3ffe91e2 00000000 4bc6a7f0 00003030 
3fffed00:  3fff26a4 00000040 3fff307c 402149f5 
3fffed10:  000a000c 00000000 3ffefa14 4021665d 
3fffed20:  3fff26a4 00000040 3ffefa14 40207c81 
3fffed30:  40216de0 00000000 000003e8 40213a3f 
3fffed40:  3fff307c 3fff297c 00000000 00000000 
3fffed50:  00000000 00000000 00000000 00000000 
3fffed60:  3fff2374 0000000f 0000000a 3fff30bc 
3fffed70:  0000004f 00000043 3fffedb0 401006dc 
3fffed80:  0000abed 00000000 0000003f 402139fc 
3fffed90:  00000002 3fffedb0 00000001 3fff2974 
3fffeda0:  00000002 3fff26a4 3fff26a4 40215f54 
3fffedb0:  00000000 00000000 00000000 4020ee38 
3fffedc0:  3fff26b4 3fff26a4 3fff2264 4020f1a4 
3fffedd0:  3ffefff0 00000014 3fff26d8 3fff2974 
3fffede0:  00000002 00000002 3fff26a4 4020cd60 
3fffedf0:  00000002 00000002 3fff26d8 40213d7c 
3fffee00:  3fff2974 00000000 00000000 3fff2974 
3fffee10:  00000002 00000002 3fff26a4 4020cff2 
3fffee20:  00000022 4010325e 00040000 40225027 
3fffee30:  00000000 4bc6a7f0 0000abc4 3ffefecc 
3fffee40:  00000000 00000000 3fff26d8 00000000 
3fffee50:  3fffc278 40101fdc 401066c6 00000000 
3fffee60:  3fff25c4 3fff28bc 00000000 4020d021 
3fffee70:  3fff25c4 3fff28bc 3ffefeac 40215b4c 
3fffee80:  3fff248c 00000001 00000015 00000001 
3fffee90:  3ffea5e8 c162cd4c 3ff209d0 3ffefecc 
3fffeea0:  3fff248c 3ffefeb0 3ffefeac 40215b90 
3fffeeb0:  3fff248c 3ffefeb0 3ffefeb1 40220760 
3fffeec0:  be01a8c0 00000000 00000000 00000000 
3fffeed0:  00000000 40224f38 000000bc 3fff28da 
3fffeee0:  3fff0028 3fff28bc 3fff0110 402246c5 
3fffeef0:  00000014 00000449 00000449 3fff0028 
3fffef00:  3fffdc80 3fff0994 3fff2374 3fff09f4 
3fffef10:  00000008 3fff0028 3fff28bc 4021db6c 
3fffef20:  3fffdc80 3fff0994 3fff2374 4021d9a7 
3fffef30:  40240a4e 3fff0994 3fff2374 40240a5f 
3fffef40:  3fff28cc 3fff28bc 00000002 3ffe85e4 
3fffef50:  40236062 00000000 3fff2374 4023c25f 
3fffef60:  40000f49 3fffdab0 3fffdab0 40000f49 
3fffef70:  40000e19 40001878 00000002 00000000 
3fffef80:  3fffff10 aa55aa55 00000070 4010441c 
3fffef90:  40104422 00000002 00000000 e298fc03 
3fffefa0:  4010000d 4b1cec84 7774dbfa 2b6ac17d 
3fffefb0:  00000000 3fffef4c 00000000 3fffff78 
3fffefc0:  3fffffd0 00000000 00000000 feefeffe 
3fffefd0:  feefeffe feefeffe feefeffe feefeffe 
3fffefe0:  feefeffe feefeffe feefeffe feefeffe 
3fffeff0:  feefeffe feefeffe feefeffe feefeffe 
3ffff000:  feefeffe feefeffe feefeffe feefeffe 
3ffff010:  feefeffe feefeffe feefeffe feefeffe 
3ffff020:  feefeffe feefeffe feefeffe feefeffe 
3ffff030:  feefeffe feefeffe feefeffe feefeffe 
3ffff040:  feefeffe feefeffe feefeffe feefeffe 
3ffff050:  feefeffe feefeffe feefeffe feefeffe 
3ffff060:  feefeffe feefeffe feefeffe feefeffe 
3ffff070:  feefeffe feefeffe feefeffe feefeffe 
3ffff080:  feefeffe feefeffe feefeffe feefeffe 
3ffff090:  feefeffe feefeffe feefeffe feefeffe 
3ffff0a0:  feefeffe feefeffe feefeffe feefeffe 
3ffff0b0:  feefeffe feefeffe feefeffe feefeffe 
3ffff0c0:  feefeffe feefeffe feefeffe feefeffe 
3ffff0d0:  feefeffe feefeffe feefeffe feefeffe 
3ffff0e0:  feefeffe feefeffe feefeffe feefeffe 
3ffff0f0:  feefeffe feefeffe feefeffe feefeffe 
3ffff100:  feefeffe feefeffe feefeffe feefeffe 
3ffff110:  feefeffe feefeffe feefeffe feefeffe 
3ffff120:  feefeffe feefeffe feefeffe feefeffe 
3ffff130:  feefeffe feefeffe feefeffe feefeffe 
3ffff140:  feefeffe feefeffe feefeffe feefeffe 
3ffff150:  feefeffe feefeffe feefeffe feefeffe 
3ffff160:  feefeffe feefeffe feefeffe feefeffe 
3ffff170:  feefeffe feefeffe feefeffe feefeffe 
3ffff180:  feefeffe feefeffe feefeffe feefeffe 
3ffff190:  feefeffe feefeffe feefeffe feefeffe 
3ffff1a0:  feefeffe feefeffe feefeffe feefeffe 
3ffff1b0:  feefeffe feefeffe feefeffe feefeffe 
3ffff1c0:  feefeffe feefeffe feefeffe feefeffe 
3ffff1d0:  feefeffe feefeffe feefeffe feefeffe 
3ffff1e0:  feefeffe feefeffe feefeffe feefeffe 
3ffff1f0:  feefeffe feefeffe feefeffe feefeffe 
3ffff200:  feefeffe feefeffe feefeffe feefeffe 
3ffff210:  feefeffe feefeffe feefeffe feefeffe 
3ffff220:  feefeffe feefeffe feefeffe feefeffe 
3ffff230:  feefeffe feefeffe feefeffe feefeffe 
3ffff240:  feefeffe feefeffe feefeffe feefeffe 
3ffff250:  feefeffe feefeffe feefeffe feefeffe 
3ffff260:  feefeffe feefeffe feefeffe feefeffe 
3ffff270:  feefeffe feefeffe feefeffe feefeffe 
3ffff280:  feefeffe feefeffe feefeffe feefeffe 
3ffff290:  feefeffe feefeffe feefeffe feefeffe 
3ffff2a0:  feefeffe feefeffe feefeffe feefeffe 
3ffff2b0:  feefeffe feefeffe feefeffe feefeffe 
3ffff2c0:  feefeffe feefeffe feefeffe feefeffe 
3ffff2d0:  feefeffe feefeffe feefeffe feefeffe 
3ffff2e0:  feefeffe feefeffe feefeffe feefeffe 
3ffff2f0:  feefeffe feefeffe feefeffe feefeffe 
3ffff300:  feefeffe feefeffe feefeffe feefeffe 
3ffff310:  feefeffe feefeffe feefeffe feefeffe 
3ffff320:  feefeffe feefeffe feefeffe feefeffe 
3ffff330:  feefeffe feefeffe feefeffe feefeffe 
3ffff340:  feefeffe feefeffe feefeffe feefeffe 
3ffff350:  feefeffe feefeffe feefeffe feefeffe 
3ffff360:  feefeffe feefeffe feefeffe feefeffe 
3ffff370:  feefeffe feefeffe feefeffe feefeffe 
3ffff380:  feefeffe feefeffe feefeffe feefeffe 
3ffff390:  feefeffe feefeffe feefeffe feefeffe 
3ffff3a0:  feefeffe feefeffe feefeffe feefeffe 
3ffff3b0:  feefeffe feefeffe feefeffe feefeffe 
3ffff3c0:  feefeffe feefeffe feefeffe feefeffe 
3ffff3d0:  feefeffe feefeffe feefeffe feefeffe 
3ffff3e0:  feefeffe feefeffe feefeffe feefeffe 
3ffff3f0:  feefeffe feefeffe feefeffe feefeffe 
3ffff400:  feefeffe feefeffe feefeffe feefeffe 
3ffff410:  feefeffe feefeffe feefeffe feefeffe 
3ffff420:  feefeffe feefeffe feefeffe feefeffe 
3ffff430:  feefeffe feefeffe feefeffe feefeffe 
3ffff440:  feefeffe feefeffe feefeffe feefeffe 
3ffff450:  feefeffe feefeffe feefeffe feefeffe 
3ffff460:  feefeffe feefeffe feefeffe feefeffe 
3ffff470:  feefeffe feefeffe feefeffe feefeffe 
3ffff480:  feefeffe feefeffe feefeffe feefeffe 
3ffff490:  feefeffe feefeffe feefeffe feefeffe 
3ffff4a0:  feefeffe feefeffe feefeffe feefeffe 
3ffff4b0:  feefeffe feefeffe feefeffe feefeffe 
3ffff4c0:  feefeffe feefeffe feefeffe feefeffe 
3ffff4d0:  feefeffe feefeffe feefeffe feefeffe 
3ffff4e0:  feefeffe feefeffe feefeffe feefeffe 
3ffff4f0:  feefeffe feefeffe feefeffe feefeffe 
3ffff500:  feefeffe feefeffe feefeffe feefeffe 
3ffff510:  feefeffe feefeffe feefeffe feefeffe 
3ffff520:  feefeffe feefeffe feefeffe feefeffe 
3ffff530:  feefeffe feefeffe feefeffe feefeffe 
3ffff540:  feefeffe feefeffe feefeffe feefeffe 
3ffff550:  feefeffe feefeffe feefeffe feefeffe 
3ffff560:  feefeffe feefeffe feefeffe feefeffe 
3ffff570:  feefeffe feefeffe feefeffe feefeffe 
3ffff580:  feefeffe feefeffe feefeffe feefeffe 
3ffff590:  feefeffe feefeffe feefeffe feefeffe 
3ffff5a0:  feefeffe feefeffe feefeffe feefeffe 
3ffff5b0:  feefeffe feefeffe feefeffe feefeffe 
3ffff5c0:  feefeffe feefeffe feefeffe feefeffe 
3ffff5d0:  feefeffe feefeffe feefeffe feefeffe 
3ffff5e0:  feefeffe feefeffe feefeffe feefeffe 
3ffff5f0:  feefeffe feefeffe feefeffe feefeffe 
3ffff600:  feefeffe feefeffe feefeffe feefeffe 
3ffff610:  feefeffe feefeffe feefeffe feefeffe 
3ffff620:  feefeffe feefeffe feefeffe feefeffe 
3ffff630:  feefeffe feefeffe feefeffe feefeffe 
3ffff640:  feefeffe feefeffe feefeffe feefeffe 
3ffff650:  feefeffe feefeffe feefeffe feefeffe 
3ffff660:  feefeffe feefeffe feefeffe feefeffe 
3ffff670:  feefeffe feefeffe feefeffe feefeffe 
3ffff680:  feefeffe feefeffe feefeffe feefeffe 
3ffff690:  feefeffe feefeffe feefeffe feefeffe 
3ffff6a0:  feefeffe feefeffe feefeffe feefeffe 
3ffff6b0:  feefeffe feefeffe feefeffe feefeffe 
3ffff6c0:  feefeffe feefeffe feefeffe feefeffe 
3ffff6d0:  feefeffe feefeffe feefeffe feefeffe 
3ffff6e0:  feefeffe feefeffe feefeffe feefeffe 
3ffff6f0:  feefeffe feefeffe feefeffe feefeffe 
3ffff700:  feefeffe feefeffe feefeffe feefeffe 
3ffff710:  feefeffe feefeffe feefeffe feefeffe 
3ffff720:  feefeffe feefeffe feefeffe feefeffe 
3ffff730:  feefeffe feefeffe feefeffe feefeffe 
3ffff740:  feefeffe feefeffe feefeffe feefeffe 
3ffff750:  feefeffe feefeffe feefeffe feefeffe 
3ffff760:  feefeffe feefeffe feefeffe feefeffe 
3ffff770:  feefeffe feefeffe feefeffe feefeffe 
3ffff780:  feefeffe feefeffe feefeffe feefeffe 
3ffff790:  feefeffe feefeffe feefeffe feefeffe 
3ffff7a0:  feefeffe feefeffe feefeffe feefeffe 
3ffff7b0:  feefeffe feefeffe feefeffe feefeffe 
3ffff7c0:  feefeffe feefeffe feefeffe feefeffe 
3ffff7d0:  feefeffe feefeffe feefeffe feefeffe 
3ffff7e0:  feefeffe feefeffe feefeffe feefeffe 
3ffff7f0:  feefeffe feefeffe feefeffe feefeffe 
3ffff800:  feefeffe feefeffe feefeffe feefeffe 
3ffff810:  feefeffe feefeffe feefeffe feefeffe 
3ffff820:  feefeffe feefeffe feefeffe feefeffe 
3ffff830:  feefeffe feefeffe feefeffe feefeffe 
3ffff840:  feefeffe feefeffe feefeffe feefeffe 
3ffff850:  feefeffe feefeffe feefeffe feefeffe 
3ffff860:  feefeffe feefeffe feefeffe feefeffe 
3ffff870:  feefeffe feefeffe feefeffe feefeffe 
3ffff880:  feefeffe feefeffe feefeffe feefeffe 
3ffff890:  feefeffe feefeffe feefeffe feefeffe 
3ffff8a0:  feefeffe feefeffe feefeffe feefeffe 
3ffff8b0:  feefeffe feefeffe feefeffe feefeffe 
3ffff8c0:  feefeffe feefeffe feefeffe feefeffe 
3ffff8d0:  feefeffe feefeffe feefeffe feefeffe 
3ffff8e0:  feefeffe feefeffe feefeffe feefeffe 
3ffff8f0:  feefeffe feefeffe feefeffe feefeffe 
3ffff900:  feefeffe feefeffe feefeffe feefeffe 
3ffff910:  feefeffe feefeffe feefeffe feefeffe 
3ffff920:  feefeffe feefeffe feefeffe feefeffe 
3ffff930:  feefeffe feefeffe feefeffe feefeffe 
3ffff940:  feefeffe feefeffe feefeffe feefeffe 
3ffff950:  feefeffe feefeffe feefeffe feefeffe 
3ffff960:  feefeffe feefeffe feefeffe feefeffe 
3ffff970:  feefeffe feefeffe feefeffe feefeffe 
3ffff980:  feefeffe feefeffe feefeffe feefeffe 
3ffff990:  feefeffe feefeffe feefeffe feefeffe 
3ffff9a0:  feefeffe feefeffe feefeffe feefeffe 
3ffff9b0:  feefeffe feefeffe feefeffe feefeffe 
3ffff9c0:  feefeffe feefeffe feefeffe feefeffe 
3ffff9d0:  feefeffe feefeffe feefeffe feefeffe 
3ffff9e0:  feefeffe feefeffe feefeffe feefeffe 
3ffff9f0:  feefeffe feefeffe feefeffe feefeffe 
3ffffa00:  feefeffe feefeffe feefeffe feefeffe 
3ffffa10:  feefeffe feefeffe feefeffe feefeffe 
3ffffa20:  feefeffe feefeffe feefeffe feefeffe 
3ffffa30:  feefeffe feefeffe feefeffe feefeffe 
3ffffa40:  feefeffe feefeffe feefeffe feefeffe 
3ffffa50:  feefeffe feefeffe feefeffe feefeffe 
3ffffa60:  feefeffe feefeffe feefeffe feefeffe 
3ffffa70:  feefeffe feefeffe feefeffe feefeffe 
3ffffa80:  feefeffe feefeffe feefeffe feefeffe 
3ffffa90:  feefeffe feefeffe feefeffe feefeffe 
3ffffaa0:  feefeffe feefeffe feefeffe feefeffe 
3ffffab0:  feefeffe feefeffe feefeffe feefeffe 
3ffffac0:  feefeffe feefeffe feefeffe feefeffe 
3ffffad0:  feefeffe feefeffe feefeffe feefeffe 
3ffffae0:  feefeffe feefeffe feefeffe feefeffe 
3ffffaf0:  feefeffe feefeffe feefeffe feefeffe 
3ffffb00:  feefeffe feefeffe feefeffe feefeffe 
3ffffb10:  feefeffe feefeffe feefeffe feefeffe 
3ffffb20:  feefeffe feefeffe feefeffe feefeffe 
3ffffb30:  feefeffe feefeffe feefeffe feefeffe 
3ffffb40:  feefeffe feefeffe feefeffe feefeffe 
3ffffb50:  feefeffe feefeffe feefeffe feefeffe 
3ffffb60:  feefeffe feefeffe feefeffe feefeffe 
3ffffb70:  feefeffe feefeffe feefeffe feefeffe 
3ffffb80:  feefeffe feefeffe feefeffe feefeffe 
3ffffb90:  feefeffe feefeffe feefeffe feefeffe 
3ffffba0:  feefeffe feefeffe feefeffe feefeffe 
3ffffbb0:  feefeffe feefeffe feefeffe feefeffe 
3ffffbc0:  feefeffe feefeffe feefeffe feefeffe 
3ffffbd0:  feefeffe feefeffe feefeffe feefeffe 
3ffffbe0:  feefeffe feefeffe feefeffe feefeffe 
3ffffbf0:  feefeffe feefeffe feefeffe feefeffe 
3ffffc00:  feefeffe feefeffe feefeffe feefeffe 
3ffffc10:  feefeffe feefeffe feefeffe feefeffe 
3ffffc20:  feefeffe feefeffe feefeffe feefeffe 
3ffffc30:  feefeffe feefeffe feefeffe feefeffe 
3ffffc40:  feefeffe feefeffe feefeffe feefeffe 
3ffffc50:  00000000 00000000 0000001f 40104bf5 
3ffffc60:  4000050c feefeffe feefeffe feefeffe 
3ffffc70:  4000437d 00000030 00000017 ffffffff 
3ffffc80:  60000200 00000008 ffffffff 80000000 
3ffffc90:  20000000 3fff1c9c 80000000 200f50c0 
3ffffca0:  80000000 3fff1890 000000bb 3fff1ca0 
3ffffcb0:  00000040 000f50c0 000f5100 00000030 
3ffffcc0:  feefeffe feefeffe 402372f7 00000001 
3ffffcd0:  ffffffff 00000000 3ffea021 00000008 
3ffffce0:  40237346 3ffed668 3fff0204 00000001 
3ffffcf0:  40237452 3ffed668 3fff0204 3ffed668 
3ffffd00:  00000002 00000000 00000020 40100f12 
3ffffd10:  3ffe9ed2 402363f7 3ffed668 3fff153c 
3ffffd20:  00000000 40229867 3ffeeb08 3fff0be4 
3ffffd30:  00000000 00000002 00000001 3ffed668 
3ffffd40:  3fff1eea 4010499b 3fff153c 3fff0994 
3ffffd50:  3fff1ea4 4022a2bb 3ffee2ac feefeffe 
3ffffd60:  3ffe9b12 4021d515 3ffefc70 3fff0994 
3ffffd70:  3fff1eea 0000002e 0000000c 3ffee9fc 
3ffffd80:  3ffe9b12 3ffe9b12 3fff09c7 3fff005d 
3ffffd90:  3fff0028 3fff0028 3fff1ea4 4021d86a 
3ffffda0:  4021dbff 00000000 3fff1eea 00000100 
3ffffdb0:  00000050 00000001 40104262 3ffee098 
3ffffdc0:  3ffee020 00000000 00000020 00000100 
3ffffdd0:  00000005 00000000 00000020 40100f12 
3ffffde0:  3ffe9ed5 40104317 3ffed960 00000012 
3ffffdf0:  00000005 00000000 00000020 40100f12 
3ffffe00:  3ffe9ed5 40104317 3ffed960 40101e02 
3ffffe10:  40101c2d 3ffed960 3ffee050 40100f12 
3ffffe20:  00007fff 029eeac4 3ffee36c 40101e02 
3ffffe30:  3ffea780 00000000 00000000 00000001 
3ffffe40:  00007fff 029eeac4 40102242 00000100 
3ffffe50:  7fffffff 3ffea780 3ffea780 00000001 
3ffffe60:  00000001 00004288 40102242 00000100 
3ffffe70:  00000000 029eeac4 00000000 4000050c 
3ffffe80:  3fffc278 40101fdc 3fffc200 00000022 
3ffffe90:  3ffea78c 029ee3a8 00002200 4000050c 
3ffffea0:  40000f83 00000030 0000001e ffffffff 
3ffffeb0:  40000ea3 00000023 00000001 00000001 
3ffffec0:  3fffdab0 00000000 3fffd9d0 3ffefad4 
3ffffed0:  00000000 00000000 00000001 3ffefacd 
3ffffee0:  00000000 3fffdad0 3ffefad4 00000030 
3ffffef0:  ffffffff 3fffc6fc 00000001 3ffefacd 
3fffff00:  00000000 3fffdad0 3ffefad4 00000030 
3fffff10:  00000000 3fffdad0 3ffefad4 00000030 
3fffff20:  3ffefc08 3ffefa14 3ffefa14 40212fc1 
3fffff30:  3ffe91e2 3fff233c 3ffef81c 3ffefad4 
3fffff40:  3fffdad0 00000018 3ffefa14 3ffe8bf9 
3fffff50:  3ffe8bfe 40210ac8 00000030 401004e8 
3fffff60:  40104d38 000fb3ea 3ffefb28 00000000 
3fffff70:  3ffef190 3ffefb28 3ffe85e4 3ffefb28 
3fffff80:  3fffdad0 3ffefad4 40214504 3fffefb0 
3fffff90:  402016ba 000000fa 000000fa 402016af 
3fffffa0:  00000000 00000000 00000001 40214525 
<<<stack<<<

 ets Jan  8 2013,rst cause:2, boot mode:(1,6)


 ets Jan  8 2013,rst cause:4, boot mode:(1,6)

wdt reset

Re: Crash trying to write to SPIFFS

PostPosted: Wed Dec 26, 2018 12:21 am
by treii28
I just tried the same sketch on my WEMOS D1 Mini (ESP-12 based) using D3 and D4 (corresponding pins for GPIO0 and GPIO2) and got the same result.

I'm suspicious of the buffer datatype and/or pointer type.
uint8_t *buffer;

I tried using a fixed length buffer as I saw the adafruit code appears to use a fixed length buffer, but I must be doing something wrong. Obviously I couldn't assign the fixed length array based on how their examples worked, but their examples bothered me as it's passing a pointer back out to a private member. I wasn't sure how that would be handled in memory or how it would persist.
So I copied the library to my local directory and added a second signature to the function that would accept an array pointer in so I could use a fixed length array and it at least worked on the write without causing a crash. Problem is, I must be doing something wrong in my new function as I don't seem to be getting jpeg data in the file.
What's the recommended way to pass byte data back and forth from function calls? Passing a fixed-length array pointer in? They're using uint8_t*, shouldn't that be byte?

Re: Crash trying to write to SPIFFS

PostPosted: Mon Dec 31, 2018 5:30 am
by FreddyVictor
I see that the function readPicture() can return a 0 which indcates an error condition
Is it by any chance returning a 0 ?

Just to add:
AFAIK there is no difference between uint8_t and a byte