How to use simulator with latest LVGL version?

Hi,

I want to test some code in a simulator. I found this Platformio simulator but I found that it uses an old version of LVGL and the code I want to test (on v8.1) does not work.

How can I update the simulator to use the latest LVGL version?

I tried updating the lib_deps in platformio.ini but that didn’t do the trick. I get:

Library Manager: Installing lvgl @ ~8.1.1
Warning! Could not find the package with 'lvgl @ ~8.1.1' requirements for your system 'linux_x86_64'
Library Manager: Installing lv_drivers @ ~8.1.1
Warning! Could not find the package with 'lv_drivers @ ~8.1.1' requirements for your system 'linux_x86_64'
Found 0 compatible libraries

I’m not familiar with Platformio so I don’t know how to fix that. If there’s another alternative that I can use on Linux, I’m also open to try a different simulator.

Thank you!

v8.1.1 is not in the PlatformIO library (yet):
image

You could try:

lib_deps =
    git+https://github.com/lvgl/lvgl.git

I’m with you, andresovela. I abandoned the simulator when 8.x came out. I’d love step-by-step instructions on how to upgrade the simulator when a new version comes out. I’m sure it’s easy: just “git” the latest, unzip and move to wherever lvgl lives (depends not only on platform but chosen IDE? I’m using CodeBlocks.) And probably change/move lvconf.h? Reboot, pray, a few possum hairs … voila!

I tried that and it did seem to do something, but the program does not compile yet.

This is what my platformio.ini looks like:

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; http://docs.platformio.org/page/projectconf.html

[platformio]
default_envs = emulator_64bits

; Shared options
[env]
build_flags =
  ; Don't use lv_conf.h. Tweak params via platfom.ini.
  -D LV_CONF_SKIP
  -D LV_CONF_INCLUDE_SIMPLE
  ; Add more defines below to overide lvgl:/src/lv_conf_simple.h
lib_deps =
    git+https://github.com/lvgl/lvgl.git
lib_archive = false


[env:emulator_64bits]
platform = native@^1.1.3
extra_scripts = support/sdl2_build_extra.py
build_flags =
  ${env.build_flags}
  -D LV_LOG_LEVEL=LV_LOG_LEVEL_INFO
  -D LV_LOG_PRINTF=1
  ; Add recursive dirs for hal headers search
  !python -c "import os; print(' '.join(['-I {}'.format(i[0].replace('\x5C','/')) for i in os.walk('hal/sdl2')]))"
  -lSDL2
  ; SDL drivers options
  -D LV_LVGL_H_INCLUDE_SIMPLE
  -D LV_DRV_NO_CONF
  -D USE_MONITOR
  -D MONITOR_ZOOM=2
  -D USE_MOUSE
  -D USE_MOUSEWHEEL
  -D USE_KEYBOARD
lib_deps =
  ${env.lib_deps}
  git+https://github.com/lvgl/lv_drivers.git
src_filter =
  +<*>
  +<../hal/sdl2>


[env:emulator_32bits]
extends = env:emulator_64bits
build_flags =
  ${env:emulator_64bits.build_flags}
  -m32


[env:stm32f429_disco]
platform = ststm32@^8.0.0
board = disco_f429zi
framework = stm32cube
build_flags =
  ${env.build_flags}
  -D LV_LOG_LEVEL=LV_LOG_LEVEL_NONE
  ; header's default is 25MHz, but board uses 8MHz crystal
  -D HSE_VALUE=8000000
  ; Add recursive dirs for hal headers search
  !python -c "import os; print(' '.join(['-I {}'.format(i[0].replace('\x5C','/')) for i in os.walk('hal/stm32f429_disco')]))"
lib_deps =
  ${env.lib_deps}
  BSP-ili9341
  BSP-stmpe811
src_filter =
  +<*>
  +<../hal/stm32f429_disco>

I only changed the lib_deps fields in [env] and [env:emulator_64bits].

This is the console output after attempting to build:

Compiling .pio/build/emulator_64bits/lib4c2/lv_drivers/win_drv.o
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:17:3: warning: #warning "MONITOR is deprecated, use SDL instead. See lv_drivers/sdl/sdl.c" [-Wcpp]
   17 | # warning "MONITOR is deprecated, use SDL instead. See lv_drivers/sdl/sdl.c"
      |   ^~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:21:3: warning: #warning "KEYBOARD is deprecated, use SDL instead. See lv_drivers/sdl/sdl.c" [-Wcpp]
   21 | # warning "KEYBOARD is deprecated, use SDL instead. See lv_drivers/sdl/sdl.c"
      |   ^~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:25:3: warning: #warning "MOUSE is deprecated, use SDL instead. See lv_drivers/sdl/sdl.c" [-Wcpp]
   25 | # warning "MOUSE is deprecated, use SDL instead. See lv_drivers/sdl/sdl.c"
      |   ^~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:29:3: warning: #warning "MOUSEWHEEL is deprecated, use SDL instead that. See lv_drivers/sdl/sdl.c" [-Wcpp]
   29 | # warning "MOUSEWHEEL is deprecated, use SDL instead that. See lv_drivers/sdl/sdl.c"
      |   ^~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:53:10: error: #include expects "FILENAME" or <FILENAME>
   53 | #include SDL_INCLUDE_PATH
      |          ^~~~~~~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:68:5: error: unknown type name ‘SDL_Window’
   68 |     SDL_Window * window;
      |     ^~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:69:5: error: unknown type name ‘SDL_Renderer’
   69 |     SDL_Renderer * renderer;
      |     ^~~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:70:5: error: unknown type name ‘SDL_Texture’
   70 |     SDL_Texture * texture;
      |     ^~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:84:34: error: unknown type name ‘SDL_Event’
   84 | int quit_filter(void * userdata, SDL_Event * event);
      |                                  ^~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:88:27: error: unknown type name ‘SDL_Event’
   88 | static void mouse_handler(SDL_Event * event);
      |                           ^~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:89:32: error: unknown type name ‘SDL_Event’
   89 | static void mousewheel_handler(SDL_Event * event);
      |                                ^~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:90:37: error: unknown type name ‘SDL_Keycode’
   90 | static uint32_t keycode_to_ctrl_key(SDL_Keycode sdl_key);
      |                                     ^~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:91:30: error: unknown type name ‘SDL_Event’
   91 | static void keyboard_handler(SDL_Event * event);
      |                              ^~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:61:30: error: ‘SDL_TEXTINPUTEVENT_TEXT_SIZE’ undeclared here (not in a function)
   61 | #define KEYBOARD_BUFFER_SIZE SDL_TEXTINPUTEVENT_TEXT_SIZE
Compiling .pio/build/emulator_64bits/hal/sdl2/app_hal.o
      |                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:117:17: note: in expansion of macro ‘KEYBOARD_BUFFER_SIZE’
  117 | static char buf[KEYBOARD_BUFFER_SIZE];
      |                 ^~~~~~~~~~~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c: In function ‘sdl_init’:
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:130:5: warning: implicit declaration of function ‘SDL_Init’; did you mean ‘sdl_init’? [-Wimplicit-function-declaration]
  130 |     SDL_Init(SDL_INIT_VIDEO);
      |     ^~~~~~~~
      |     sdl_init
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:130:14: error: ‘SDL_INIT_VIDEO’ undeclared (first use in this function)
  130 |     SDL_Init(SDL_INIT_VIDEO);
      |              ^~~~~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:130:14: note: each undeclared identifier is reported only once for each function it appears in
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:132:5: warning: implicit declaration of function ‘SDL_SetEventFilter’ [-Wimplicit-function-declaration]
  132 |     SDL_SetEventFilter(quit_filter, NULL);
      |     ^~~~~~~~~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:132:24: error: ‘quit_filter’ undeclared (first use in this function)
  132 |     SDL_SetEventFilter(quit_filter, NULL);
      |                        ^~~~~~~Compiling .pio/build/emulator_64bits/src/inter_medium_35.o
~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:145:5: warning: implicit declaration of function ‘SDL_StartTextInput’ [-Wimplicit-function-declaration]
  145 |     SDL_StartTextInput();
      |     ^~~~~~~~~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:150:5: warning: implicit declaration of function ‘SDL_CreateThread’ [-Wimplicit-function-declaration]
  150 |     SDL_CreateThread(tick_thread, "tick", NULL);
      |     ^~~~~~~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c: In function ‘sdl_event_handler’:
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:346:5: error: unknown type name ‘SDL_Event’
  346 |     SDL_Event event;
      |     ^~~~~~~~~
Compiling .pio/build/emulator_64bits/src/main.o
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:347:11: warning: implicit declaration of function ‘SDL_PollEvent’ [-Wimplicit-function-declaration]
  347 |     while(SDL_PollEvent(&event)) {
      |           ^~~~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:348:9: warning: implicit declaration of function ‘mouse_handler’ [-Wimplicit-function-declaration]
  348 |         mouse_handler(&event);
      |         ^~~~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:349:9: warning: implicit declaration of function ‘mousewheel_handler’ [-Wimplicit-function-declaration]
  349 |         mousewheel_handler(&event);
      |         ^~~~~~~~~~~~~~~~~~
Compiling .pio/build/emulator_64bits/src/test.o
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:350:9: warning: implicit declaration of function ‘keyboard_handler’ [-Wimplicit-function-declaration]
  350 |         keyboard_handler(&event);
      |         ^~~~~~~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:352:20: error: request for member ‘type’ in something not a structure or union
  352 |         if((&event)->type == SDL_WINDOWEVENT) {
      |                    ^~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:352:30: error: ‘SDL_WINDOWEVENT’ undeclared (first use in this function)
  352 |         if((&event)->type == SDL_WINDOWEVENT) {
      |                              ^~~~~~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:353:28: error: request for member ‘window’ in something not a structure or union
  353 |             switch((&event)->window.event) {
      |                            ^~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:354:24: error: missing binary operator before token "("
  354 | #if SDL_VERSION_ATLEAST(2, 0, 5)
      |                        ^
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:357:22: error: ‘SDL_WINDOWEVENT_EXPOSED’ undeclared (first use in this function)
  357 |                 case SDL_WINDOWEVENT_EXPOSED:
      |                      ^~~~~~~~~~~~~~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c: At top level:
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:399:34: error: unknown type name ‘SDL_Event’
  399 | int quit_filter(void * userdata, SDL_Event * event)
      |                                  ^~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c: In function ‘monitor_sdl_clean_up’:
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:417:5: warning: implicit declaration of function ‘SDL_DestroyTexture’ [-Wimplicit-function-declaration]
  417 |     SDL_DestroyTexture(monitor.texture);
      |     ^~~~~~~~~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:418:5: warning: implicit declaration of function ‘SDL_DestroyRenderer’ [-Wimplicit-function-declaration]
  418 |     SDL_DestroyRenderer(monitor.renderer);
      |     ^~~~~~~~~~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:419:5: warning: implicit declaration of function ‘SDL_DestroyWindow’ [-Wimplicit-function-declaration]
  419 |     SDL_DestroyWindow(monitor.window);
      |     ^~~~~~~~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:428:5: warning: implicit declaration of function ‘SDL_Quit’ [-Wimplicit-function-declaration]
  428 |     SDL_Quit();
      |     ^~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c: In function ‘window_create’:
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:439:17: warning: implicit declaration of function ‘SDL_CreateWindow’ [-Wimplicit-function-declaration]
  439 |     m->window = SDL_CreateWindow("TFT Simulator",
      |                 ^~~~~~~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:440:31: error: ‘SDL_WINDOWPOS_UNDEFINED’ undeclared (first use in this function)
  440 |                               SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
      |                               ^~~~~~~~~~~~~~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:37:33: error: ‘MONITOR_HOR_RES’ undeclared (first use in this function)
   37 | # define SDL_HOR_RES            MONITOR_HOR_RES
      |                                 ^~~~~~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:441:31: note: in expansion of macro ‘SDL_HOR_RES’
  441 |                               SDL_HOR_RES * SDL_ZOOM, SDL_VER_RES * SDL_ZOOM, flag);       /*last param. SDL_WINDOW_BORDERLESS to hide borders*/
      |                               ^~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:38:33: error: ‘MONITOR_VER_RES’ undeclared (first use in this function)
   38 | # define SDL_VER_RES            MONITOR_VER_RES
      |                                 ^~~~~~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:441:55: note: in expansion of macro ‘SDL_VER_RES’
  441 |                               SDL_HOR_RES * SDL_ZOOM, SDL_VER_RES * SDL_ZOOM, flag);       /*last param. SDL_WINDOW_BORDERLESS to hide borders*/
      |                                                       ^~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:443:19: warning: implicit declaration of function ‘SDL_CreateRenderer’ [-Wimplicit-function-declaration]
  443 |     m->renderer = SDL_CreateRenderer(m->window, -1, SDL_RENDERER_SOFTWARE);
      |                   ^~~~~~~~~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:443:53: error: ‘SDL_RENDERER_SOFTWARE’ undeclared (first use in this function)
  443 |     m->renderer = SDL_CreateRenderer(m->window, -1, SDL_RENDERER_SOFTWARE);
      |                                                     ^~~~~~~~~~~~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:444:18: warning: implicit declaration of function ‘SDL_CreateTexture’ [-Wimplicit-function-declaration]
  444 |     m->texture = SDL_CreateTexture(m->renderer,
      |                  ^~~~~~~~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:445:33: error: ‘SDL_PIXELFORMAT_ARGB8888’ undeclared (first use in this function)
  445 |                                 SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STATIC, SDL_HOR_RES, SDL_VER_RES);
      |                                 ^~~~~~~~~~~~~~~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:445:59: error: ‘SDL_TEXTUREACCESS_STATIC’ undeclared (first use in this function)
  445 |                                 SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STATIC, SDL_HOR_RES, SDL_VER_RES);
      |                                                           ^~~~~~~~~~~~~~~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:446:5: warning: implicit declaration of function ‘SDL_SetTextureBlendMode’ [-Wimplicit-function-declaration]
  446 |     SDL_SetTextureBlendMode(m->texture, SDL_BLENDMODE_BLEND);
      |     ^~~~~~~~~~~~~~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:446:41: error: ‘SDL_BLENDMODE_BLEND’ undeclared (first use in this function)
  446 |     SDL_SetTextureBlendMode(m->texture, SDL_BLENDMODE_BLEND);
      |                                         ^~~~~~~~~~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c: In function ‘window_update’:
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:463:5: warning: implicit declaration of function ‘SDL_UpdateTexture’ [-Wimplicit-function-declaration]
  463 |     SDL_UpdateTexture(m->texture, NULL, m->tft_fb, SDL_HOR_RES * sizeof(uint32_t));
      |     ^~~~~~~~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:37:33: error: ‘MONITOR_HOR_RES’ undeclared (first use in this function)
   37 | # define SDL_HOR_RES            MONITOR_HOR_RES
      |                                 ^~~~~~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:463:52: note: in expansion of macro ‘SDL_HOR_RES’
  463 |     SDL_UpdateTexture(m->texture, NULL, m->tft_fb, SDL_HOR_RES * sizeof(uint32_t));
      |                                                    ^~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:468:5: warning: implicit declaration of function ‘SDL_RenderClear’ [-Wimplicit-function-declaration]
  468 |     SDL_RenderClear(m->renderer);
      |     ^~~~~~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:477:5: warning: implicit declaration of function ‘SDL_RenderCopy’ [-Wimplicit-function-declaration]
  477 |     SDL_RenderCopy(m->renderer, m->texture, NULL, NULL);
      |     ^~~~~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:478:5: warning: implicit declaration of function ‘SDL_RenderPresent’ [-Wimplicit-function-declaration]
  478 |     SDL_RenderPresent(m->renderer);
      |     ^~~~~~~~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c: At top level:
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:481:27: error: unknown type name ‘SDL_Event’
  481 | static void mouse_handler(SDL_Event * event)
      |                           ^~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:523:32: error: unknown type name ‘SDL_Event’
  523 | static void mousewheel_handler(SDL_Event * event)
      |                                ^~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:557:30: error: unknown type name ‘SDL_Event’
  557 | static void keyboard_handler(SDL_Event * event)
      |                              ^~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:592:37: error: unknown type name ‘SDL_Keycode’
  592 | static uint32_t keycode_to_ctrl_key(SDL_Keycode sdl_key)
      |                                     ^~~~~~~~~~~
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c: In function ‘tick_thread’:
.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:646:9: warning: implicit declaration of function ‘SDL_Delay’ [-Wimplicit-function-declaration]
  646 |         SDL_Delay(5);
      |         ^~~~~~~~~
*** [.pio/build/emulator_64bits/lib4c2/lv_drivers/sdl/sdl.o] Error 1
In file included from hal/sdl2/app_hal.c:5:
.pio/libdeps/emulator_64bits/lv_drivers/indev/mouse.h:26:2: warning: #warning "Deprecated, use the SDL driver instead. See lv_drivers/sdl/sdl.c" [-Wcpp]
   26 | #warning "Deprecated, use the SDL driver instead. See lv_drivers/sdl/sdl.c"
      |  ^~~~~~~
In file included from hal/sdl2/app_hal.c:6:
.pio/libdeps/emulator_64bits/lv_drivers/indev/mousewheel.h:26:2: warning: #warning "Deprecated, use the SDL driver instead. See lv_drivers/sdl/sdl.c" [-Wcpp]
   26 | #warning "Deprecated, use the SDL driver instead. See lv_drivers/sdl/sdl.c"
      |  ^~~~~~~
In file included from hal/sdl2/app_hal.c:7:
.pio/libdeps/emulator_64bits/lv_drivers/indev/keyboard.h:26:2: warning: #warning "Deprecated, use the SDL driver instead. See lv_drivers/sdl/sdl.c" [-Wcpp]
   26 | #warning "Deprecated, use the SDL driver instead. See lv_drivers/sdl/sdl.c"
      |  ^~~~~~~
hal/sdl2/app_hal.c: In function ‘hal_setup’:
hal/sdl2/app_hal.c:40:12: error: unknown type name ‘lv_disp_buf_t’
   40 |     static lv_disp_buf_t disp_buf;
      |            ^~~~~~~~~~~~~
hal/sdl2/app_hal.c:41:27: error: ‘LV_HOR_RES_MAX’ undeclared (first use in this function); did you mean ‘LV_HOR_RES’?
   41 |     static lv_color_t buf[LV_HOR_RES_MAX * 10];                     /*Declare a buffer for 10 lines*/
      |                           ^~~~~~~~~~~~~~
      |                           LV_HOR_RES
hal/sdl2/app_hal.c:41:27: note: each undeclared identifier is reported only once for each function it appears in
hal/sdl2/app_hal.c:42:5: warning: implicit declaration of function ‘lv_disp_buf_init’; did you mean ‘lv_disp_drv_init’? [-Wimplicit-function-declaration]
   42 |     lv_disp_buf_init(&disp_buf, buf, NULL, LV_HOR_RES_MAX * 10);    /*Initialize the display buffer*/
      |     ^~~~~~~~~~~~~~~~
      |     lv_disp_drv_init
hal/sdl2/app_hal.c:47:13: error: ‘lv_disp_drv_t’ {aka ‘struct _lv_disp_drv_t’} has no member named ‘buffer’
   47 |     disp_drv.buffer = &disp_buf;
      |             ^
*** [.pio/build/emulator_64bits/hal/sdl2/app_hal.o] Error 1
============================================================================= [FAILED] Took 4.26 seconds =============================================================================

Environment      Status    Duration
---------------  --------  ------------
emulator_64bits  FAILED    00:00:04.256
======================================================================= 1 failed, 0 succeeded in 00:00:04.256 =======================================================================
The terminal process "platformio 'run', '--environment', 'emulator_64bits'" terminated with exit code: 1.

I agree with @bewing that a full how-to tutorial wouldbe very much appreciated.

1 Like

It seems that there is a problem with SDL2. A quick Google search says that I can check whether I have SDL2 installed with

> yum search SDL2

The output seems to indicate I do have it installed.

========================== Name Exactly Matched: SDL2 ==========================
SDL2.x86_64 : Cross-platform multimedia library
SDL2.i686 : Cross-platform multimedia library
========================= Name & Summary Matched: SDL2 =========================
SDL2-static.x86_64 : Static libraries for SDL2
SDL2-static.i686 : Static libraries for SDL2
SDL2_gfx.i686 : SDL2 graphics drawing primitives and other support functions
SDL2_gfx.x86_64 : SDL2 graphics drawing primitives and other support functions
SDL2_gfx-devel.i686 : Development files for SDL2_gfx
SDL2_gfx-devel.x86_64 : Development files for SDL2_gfx
SDL2_gfx-docs.noarch : API Documentation for SDL2_gfx
SDL2_image-devel.i686 : Development files for SDL2_image
SDL2_image-devel.x86_64 : Development files for SDL2_image
SDL2_mixer-devel.i686 : Development files for SDL2_mixer
SDL2_mixer-devel.x86_64 : Development files for SDL2_mixer
SDL2_ttf.i686 : TrueType font rendering library for SDL2
SDL2_ttf.x86_64 : TrueType font rendering library for SDL2
SDL2_ttf-devel.i686 : Development files for SDL2_ttf
SDL2_ttf-devel.x86_64 : Development files for SDL2_ttf
anarch-SDL2.x86_64 : Suckless, anarcho-pacifist Doom clone that runs everywhere
                   : (SDL2 version)
gambas3-gb-sdl2.x86_64 : Gambas3 component for sdl2
gambas3-gb-sdl2-audio.x86_64 : Gambas3 component for sdl2-audio
mingw32-SDL2_image.noarch : MinGW Windows port of the Image loading library for
                          : SDL2
mingw32-SDL2_ttf.noarch : MinGW Windows port of the TrueType font handling
                        : library for SDL2
mingw64-SDL2_image.noarch : MinGW Windows port of the Image loading library for
                          : SDL2
mingw64-SDL2_ttf.noarch : MinGW Windows port of the TrueType font handling
                        : library for SDL2
============================== Name Matched: SDL2 ==============================
SDL2-devel.x86_64 : Files needed to develop Simple DirectMedia Layer
                  : applications
SDL2-devel.i686 : Files needed to develop Simple DirectMedia Layer applications
SDL2_image.i686 : Image loading library for SDL
SDL2_image.x86_64 : Image loading library for SDL
SDL2_mixer.i686 : Simple DirectMedia Layer - Sample Mixer Library
SDL2_mixer.x86_64 : Simple DirectMedia Layer - Sample Mixer Library
SDL2_net.i686 : SDL portable network library
SDL2_net.x86_64 : SDL portable network library
SDL2_net-devel.i686 : Libraries and includes to develop SDL networked
                    : applications
SDL2_net-devel.x86_64 : Libraries and includes to develop SDL networked
                      : applications
mingw32-SDL2.noarch : MinGW Windows port of SDL cross-platform multimedia
                    : library
mingw32-SDL2-static.noarch : MinGW Windows port of SDL cross-platform multimedia
                           : library
mingw32-SDL2_mixer.noarch : MinGW Windows port of Simple DirectMedia Layer's
                          : Sample Mixer Library
mingw64-SDL2.noarch : MinGW Windows port of SDL cross-platform multimedia
                    : library
mingw64-SDL2-static.noarch : MinGW Windows port of SDL cross-platform multimedia
                           : library
mingw64-SDL2_mixer.noarch : MinGW Windows port of Simple DirectMedia Layer's
                          : Sample Mixer Library
============================ Summary Matched: SDL2 =============================
baresip-sdl.x86_64 : SDL2 video output driver for baresip
koules-sdl.x86_64 : SDL2 variant of a multiplayer action game
1 Like

I managed to compile the simulator after following the compiler errors and changing a bunch of stuff. It was not trivial. There were APIs that needed to be changed, deprecated things that needed to be replaced, etc.

So now it’s compiling, but when I run it it exits immediately with error -11. Any ideas?

Alright, I got it working now. I had to make some variables static and add some missing variable initializations on app_hal.c

For future reference:

platformio.ini:

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; http://docs.platformio.org/page/projectconf.html

[platformio]
default_envs = emulator_64bits

; Shared options
[env]
build_flags =
  -D LV_CONF_INCLUDE_SIMPLE
  ; Add more defines below to overide lvgl:/src/lv_conf_simple.h
lib_deps =
    git+https://github.com/lvgl/lvgl.git
lib_archive = false


[env:emulator_64bits]
platform = native@^1.1.3
extra_scripts = support/sdl2_build_extra.py
build_flags =
  ${env.build_flags}
  -D LV_LOG_LEVEL=LV_LOG_LEVEL_INFO
  -D LV_LOG_PRINTF=1
  ; Add recursive dirs for hal headers search
  !python -c "import os; print(' '.join(['-I {}'.format(i[0].replace('\x5C','/')) for i in os.walk('hal/sdl2')]))"
  -lSDL2
  ; SDL drivers options
  -D LV_LVGL_H_INCLUDE_SIMPLE
  -D LV_CONF_INCLUDE_SIMPLE
  -D USE_SDL
  -I src
lib_deps =
  ${env.lib_deps}
  git+https://github.com/lvgl/lv_drivers.git
src_filter =
  +<*>
  +<../hal/sdl2>


[env:emulator_32bits]
extends = env:emulator_64bits
build_flags =
  ${env:emulator_64bits.build_flags}
  -m32


[env:stm32f429_disco]
platform = ststm32@^8.0.0
board = disco_f429zi
framework = stm32cube
build_flags =
  ${env.build_flags}
  -D LV_LOG_LEVEL=LV_LOG_LEVEL_NONE
  ; header's default is 25MHz, but board uses 8MHz crystal
  -D HSE_VALUE=8000000
  ; Add recursive dirs for hal headers search
  !python -c "import os; print(' '.join(['-I {}'.format(i[0].replace('\x5C','/')) for i in os.walk('hal/stm32f429_disco')]))"
lib_deps =
  ${env.lib_deps}
  BSP-ili9341
  BSP-stmpe811
src_filter =
  +<*>
  +<../hal/stm32f429_disco>

I also had to copy the lv_conf_template.h and lv_drv_conf_template.h header files as lv_conf.h and lv_drv_conf.h.

In app_hal.c I had to remove all the old monitor/mouse/keyboard header files, and added #include "sdl/sdl.h" and #include "lvgl.h".

I had to replace the monitor/mouse functions by SDL functions:

  • sdl_init() instead of monitor_init()
  • sdl_display_flush() instead of monitor_flush()
  • sdl_mouse_read() instead of mouse_read()

I had to fix some types that were renamed in v8 I guess:

  • lv_disp_draw_buf_t instead of lv_disp_buf_t
  • disp_drv.draw_buf instead of disp_drv.buffer

Made some variables static:

  • disp_drv
  • indev_drv

Initialized the following variables:

    disp_drv.hor_res = SCREEN_WIDTH;
    disp_drv.ver_res = SCREEN_HEIGHT;

Also added those definitions to have a 480x320 screen resolution.

I don’t remember if I had to change anything else. Unfortunately I downloaded the simulator as a zip from Github instead of cloning the repo, so I don’t have the diffs.

I hope this is of help to somebody else :slight_smile:

1 Like