MAIXduino with GC0328 camera, mobilenet_v1, core dump: misaligned load or fault store

I am using a Maixduino with a GC0328 camera. Trying to get the example mobilenet_v1 running on this board and camera. Using version 0.3.11 of Maixduino package. Arduino IDE version 1.8.13.
I have replaced the Sipeed_OV2640 driver in the example for Maixduino_GC0328 driver.
It compiles just fine, but frequently a core dump: misaligned load
occurs. Or the program just blocks the whole board without any warnings. Sometimes a first picture is displayed however, with text “tinca tinca” and lots of mbdetect failure messages are in monitor screen.

For what I could detect it seems to go wrong in the mbshow part of the program most of the time (but not always, it looks as if there are random problems , timing ? maybe) .

Does anyone have a clue how to fix this / recognizes this problem ? (Other than: buy/use Sipeed OV2640 camera that is…)
If not , hints/tips on how to find the cause are welcome as well , I am completely stuck at it for now.

This is an example of monitor output:

init mobile net, load kmodel from SD card, it may takes a long time
core dump: fault store
Cause 0x0000000000000007, EPC 0x0000000080013858
reg00 = 0x0000300000000000, reg01 = 0x00000000800134b4
reg02 = 0x0000000080066800, reg03 = 0x0000000080031e60
reg04 = 0x000000008005ebc0, reg05 = 0x0000598000007580
reg06 = 0x0000000000000004, reg07 = 0x0000000000000000
reg08 = 0x0000000080031488, reg09 = 0x0000000000000020
reg10 = 0x0000000000000008, reg11 = 0x0000000080030cb8
reg12 = 0x00000000800bdc40, reg13 = 0x0000000100062900
reg14 = 0x00000000800314a8, reg15 = 0x0000000080031459
reg16 = 0x0000000080030d28, reg17 = 0x0000000080031458
reg18 = 0x0000000080030548, reg19 = 0x0000000080030ca8
reg20 = 0x0000000000010000, reg21 = 0x0000000000000001
reg22 = 0x0000000000000003, reg23 = 0x0000000080066abf
reg24 = 0x0000000000000003, reg25 = 0x0000000000000000
reg26 = 0x0000000000000000, reg27 = 0x0000000000000000
reg28 = 0x000000000000001f, reg29 = 0x00000000f90f0451
reg30 = 0x0001bc6f00037cdf, reg31 = 0x001f001f00000002
freg00 = 0x0000000000000000(), freg00 = 0x0000000080029a48()
freg02 = 0x0000000000000000(), freg00 = 0x0000000080029a58()
freg04 = 0x0000000000000000(), freg00 = 0x0000000080029a68()
freg06 = 0x0000000000000000(), freg00 = 0x0000000080029a78()
freg08 = 0x0000000000000000(), freg00 = 0x0000000080029aa0()
freg10 = 0x0000000000000000(), freg00 = 0x0000000080029ad0()
freg12 = 0x0000000000000000(), freg00 = 0x0000000080029af8()
freg14 = 0x0000000041bf13b8(), freg-536870912 = 0x0000000080029b08()
freg16 = 0x0000000000000000(), freg00 = 0x0000000080029b18()
freg18 = 0x0000000000000000(), freg00 = 0x0000000080029b40()
freg20 = 0x0000000000000000(), freg00 = 0x0000000080029b50()
freg22 = 0x0000000000000000(), freg00 = 0x0000000080029b60()
freg24 = 0x0000000000000000(), freg00 = 0x0000000080029b70()
freg26 = 0x0000000000000000(), freg00 = 0x0000000080029b80()
freg28 = 0x0000000000000000(), freg00 = 0x0000000080029ba8()
freg30 = 0x0000000000000000(), freg00 = 0x0000000080029bb8()
core dump: fault store
Cause 0x0000000000000007, EPC 0x0000000080013584
reg00 = 0x0001bc6f00037cdf, reg01 = 0x00000000800134b4
reg02 = 0x0000000080066280, reg03 = 0x0000000080031e60
reg04 = 0x000000008005ebc0, reg05 = 0x0000000080013ab2
reg06 = 0x000000008001ad34, reg07 = 0x0000000000000000
reg08 = 0x00000000800314a8, reg09 = 0x0000000000000410
reg10 = 0x000000000000001f, reg11 = 0x0000000080030cb8
reg12 = 0x0000000080031048, reg13 = 0x00000000800318b8
reg14 = 0x0000000100062900, reg15 = 0x0000000080031049
reg16 = 0x0000000000000008, reg17 = 0x0000000000000050
reg18 = 0x0000000080030548, reg19 = 0x0000000080030ca8
reg20 = 0x0000000000010000, reg21 = 0x0000000000000001
reg22 = 0x00000000800667a8, reg23 = 0x0000000080066abf
reg24 = 0x0000000000000003, reg25 = 0x0000000000000000
reg26 = 0x0000000000000000, reg27 = 0x0000000000000000
reg28 = 0x000000000000000a, reg29 = 0x000000000000003c
reg30 = 0x0001bc6f00037cdf, reg31 = 0x001f001f00000002
freg00 = 0x0000000000000000(), freg00 = 0x0000000080029a48()
freg02 = 0x0000000000000000(), freg00 = 0x0000000080029a58()
freg04 = 0x0000000000000000(), freg00 = 0x0000000080029a68()
freg06 = 0x0000000000000000(), freg00 = 0x0000000080029a78()
freg08 = 0x0000000000000000(), freg00 = 0x0000000080029aa0()
freg10 = 0x0000000056b30000(), freg00 = 0x0000000080029ad0()
freg12 = 0x0000000000000000(), freg00 = 0x0000000080029af8()
freg14 = 0x0000000041bf13b8(), freg-536870912 = 0x0000000080029b08()
freg16 = 0x0000000000000000(), freg00 = 0x0000000080029b18()
freg18 = 0x0000000000000000(), freg00 = 0x0000000080029b40()
freg20 = 0x0000000000000000(), freg00 = 0x0000000080029b50()
freg22 = 0x0000000000000000(), freg00 = 0x0000000080029b60()
freg24 = 0x0000000000000000(), freg00 = 0x0000000080029b70()
freg26 = 0x0000000000000000(), freg00 = 0x0000000080029b80()
freg28 = 0x0000000000000000(), freg00 = 0x0000000080029ba8()
freg30 = 0x0000000000000000(), freg00 = 0x0000000080029bb8()

Well, some kind of progress in this issue. By applying a bunch of delay( ) statements I have managed to get things more stable, in the sense that it now does keeps running a bit better. Occasional crashes keep occurring however. On other occasions mbdetect() start to return -2 values continously after a first normal return. Plus, only name recognized is always tench, Tinca tinca. Finally, after displaying a (> 50) number of images the camera image start with scattered green pixels until it just shows noise. covering the lens for a second seems to bring it back to normal. Just as if there is some capacitive build-up of electrons in the lens chip itself. Maybe the driver has issues there (?). The same occurs when running the ‘selfie’ example on this board.

Below the code part of MBNet_1000.cpp with the delay() statements and Serial.println() statements I have added for debugging. As said, this seems to work somewhat better but still does not recognize anything… :frowning:

int MBNet_1000::detect()
{
uint8_t* img;
uint8_t* img888;
//uint16_t* img565;

img = _camera.snapshot();
if(img == nullptr || img==0)
    return -1;
img888 = _camera.getRGB888();
//img565 = _camera.getRGB565();
//_lcd.fillRect(224,0, _lcd.width()-224, _lcd.height(), COLOR_RED);
//_lcd.drawImage(0, 0, _camera.width(), _camera.height(), img565);
delay(50);
int kpu_ret = _kpu.forward(img888);
if(kpu_ret != 0)
{
    Serial.println("kpu forward result : " + String(kpu_ret));
    return -2;
}
while( !_kpu.isForwardOk() ) {
  delay(10);
}
kpu_ret = _kpu.getResult((uint8_t**)&_result, &_count); 
if( kpu_ret != 0)
{
    Serial.println("_kpu.getResult returned : " + String(kpu_ret));
    return -3;
    
}
return 0;

}

void MBNet_1000::show()
{
float prob;
const char* name;
uint8_t i, j;
uint16_t* img;

//Serial.print("just before _count set");   

_count /= sizeof(float);

Serial.print("After _count operation ");   

label_init();

Serial.print("After init.");  

label_sort();

Serial.print("After label_sort."); 

Serial.println("Just before j-loop."); 

for ( j = 0; j < 5; j++) {
   Serial.println("j="+String(j));
   delay(10);
   _statistics[j].updated = false;
   
}
delay(10);
for (i = 0; i < STATISTICS_NUM; i++) {
  label_get(i, &prob, &name);
  Serial.println(" name(" + String(i) + ") = " + _statistics[i].name);
}


for ( i = 0; i < 5; i++)
  {
	 Serial.print("i=" + String(i));
	 label_get(i, &prob, &name);
    for(j=0; j<STATISTICS_NUM; j++)
    {
      
        if(_statistics[j].name == NULL)
        {
            _statistics[j].name = name;
            _statistics[j].sum  = prob;
            _statistics[j].updated = true;
            break;
        }
        else if( _statistics[j].name == name )
        {
            _statistics[j].sum += prob;
            _statistics[j].updated = true;
            break;
        }
        else
        {
        }
    }
    Serial.print(" j:"+String(j)+" i:"+String(i));
    if( j == STATISTICS_NUM)
    {
      
        float min = _statistics[0].sum;
        j = 0;
        for(i=1; i<STATISTICS_NUM; i++)
        {
            if(_statistics[i].name)
            {
                if(_statistics[i].sum <= min)
                {
                    min = _statistics[i].sum;
                    j = i;
                }
            }
        }
        _statistics[j].name = name;
        _statistics[j].sum  = prob;
        _statistics[j].updated = true;
    }
}

Serial.print("After first stats block.");  

float max = _statistics[0].sum;
float second = 0;
uint8_t index1=0, index2 = 0;
for(i=0; i<STATISTICS_NUM; i++)
{
    if(_statistics[i].name)
    {
        if(_statistics[i].sum > max)
        {
            max = _statistics[i].sum;
            index1 = i;
        }
        else if(_statistics[i].sum > second && _statistics[i].sum<max)
        {
            index2 = i;
        }
    }
    if( !_statistics[i].updated )
    {
        float tmp = _statistics[i].sum - _statistics[i].sum*2/5;
        if( tmp < 0)
            tmp = 0;
        _statistics[i].sum = tmp;
    }
}

Serial.print("Getting camera image...");


img = _camera.getRGB565();
Serial.println("... have it!");
delay(10);

_lcd.fillRect(224,0, _lcd.width()-224, _lcd.height(), COLOR_RED);
_lcd.drawImage(0, 0, _camera.width(), _camera.height(), img);
_lcd.setTextSize(2);
_lcd.setTextColor(COLOR_WHITE);
_lcd.setCursor(0,0);
_lcd.println(_statistics[index1].name);
_lcd.println("-----");
_lcd.println(_statistics[index2].name);
_lcd.println("=======");
_lcd.println(_names[_index[0]]);
_lcd.println(_names[_index[1]]);
_lcd.println(_names[_index[2]]);
_lcd.println(_names[_index[3]]);
_lcd.println(_names[_index[4]]);

}

I have exactly the same problem! It is annoying, that such a fantastic board stucks with a small software bug, or isn’t it a small bug, maybe there is a bigger problem underlying. Is someone looking for it? It would be very helpful, thanks in advance. Thank you josvl for your contribution.

It is still not working, even after inserting the suggested delays from josvl. Here is the serial output (not complete only the beginning):

17:05:43.972 -> init mobile net, load kmodel from SD card, it may take a long time
17:06:05.098 -> core dump: fault store
17:06:05.098 -> Cause 0x0000000000000007, EPC 0x0000000080013aca
17:06:05.098 -> reg[00] = 0x0000000000000000, reg[01] = 0x0000000080013744
17:06:05.098 -> reg[02] = 0x0000000080066d30, reg[03] = 0x00000000800322f0