RP2040 crashes after adding an object to a tile

I am trying to create a UI using a Adafruit Feather RP2040 paired with a Adafruit Featherwing TFT. I have the following widgets:

screen:
    tileview
       tile1
       tile2

With those widgets, the UI works fine. However, as soon as I add an object with lv_obj_t *grid = lv_obj_create(tile1) it seems that the RP crashes (I no longer get output on the serial console, I can’t open the com port any more, and the screen is not responsive).

For reference, here is the actual code that I am using:

    lv_style_t style;
    lv_style_init(&style);
    lv_style_set_radius(&style, 5);
    lv_style_set_outline_width(&style, 2);
    lv_style_set_outline_color(&style, lv_palette_main(LV_PALETTE_BLUE));
    lv_style_set_outline_pad(&style, 0);

    // create the tile view
    lv_obj_t *tileview = lv_tileview_create(lv_screen_active());
    lv_obj_set_size(tileview, TFT_W - 20, TFT_H - 20);
    //lv_obj_set_scrollbar_mode(tileview, LV_SCROLLBAR_MODE_OFF);
    lv_obj_t *tile1 = lv_tileview_add_tile(tileview, 0, 0, LV_DIR_RIGHT);
    lv_obj_add_style(tile1, &style, 0);
    lv_obj_t *tile2 = lv_tileview_add_tile(tileview, 1, 0, LV_DIR_LEFT);

    lv_obj_t *grid = lv_obj_create(tile1);

Can someone help me understand what is happening?

Thank you.

Try set your style as static

static lv_style_t style

Thank you. That got me further but I fear I am missing something fundamental. It now crashes using this code:

    const int32_t col_dsc[] = { 50, 50, 50, 50, LV_GRID_TEMPLATE_LAST};
    const int32_t row_dsc[] = { LV_GRID_FR(1), 50, 50, LV_GRID_TEMPLATE_LAST };

    static lv_style_t style;
    lv_style_init(&style);
    lv_style_set_radius(&style, 5);
    lv_style_set_outline_width(&style, 2);
    lv_style_set_outline_color(&style, lv_palette_main(LV_PALETTE_BLUE));
    lv_style_set_outline_pad(&style, 0);

    // create the tile view
    lv_obj_t *tileview = lv_tileview_create(lv_screen_active());
    lv_obj_set_size(tileview, TFT_W, TFT_H);
    //lv_obj_set_scrollbar_mode(tileview, LV_SCROLLBAR_MODE_OFF);
    lv_obj_t *tile1 = lv_tileview_add_tile(tileview, 0, 0, LV_DIR_RIGHT);
    lv_obj_t *tile2 = lv_tileview_add_tile(tileview, 1, 0, LV_DIR_LEFT);

    lv_obj_t *grid = lv_obj_create(tile1);
    lv_obj_set_grid_dsc_array(grid, col_dsc, row_dsc);
    lv_obj_set_size(grid, TFT_W - 30, TFT_H - 30);
    lv_obj_center(grid);
    lv_obj_set_layout(grid, LV_LAYOUT_GRID);
    lv_obj_add_style(grid, &style, 0);

    lv_obj_t *label = lv_label_create(grid);

If I remove the last line from the code above, it works. But when I add it back in, the RP starts crashing again.

Seems you are out of stack. Check lvconf memory size and setup.

Im not familiar with RP2040 debug capabilities, but I would suggest to enable LVGLs log print feature, and print trace level info - it will help you troubleshoot some of these issues

I tried setting the stack size to:

#define LV_TASK_STACK_SIZE (128U * 1024U)

But that did nothing. It still crashes. I then tried

#define LV_MEM_SIZE (128U * 1024U) /*[bytes]*/
#define LV_TASK_STACK_SIZE (32U * 1024U)

still no-go. Still crashing.