RP2040 and LVGL

Description

I used generated code from squareline. Tried to compile, but it throws error
{standard input}: Assembler messages:
{standard input}: Error: unaligned opcodes detected in executable segment
exit status 1
Compilation error: exit status 1

What MCU/Processor/Board and compiler are you using? RP2040

What LVGL version are you using?

What do you want to achieve?

What have you tried so far?

I run TFT espi library alone using examples. It works pretty well, so problem must be in LVGL. I also tried using Adafruit_GFX

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

/*You code here*/

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.

Hi,
I can gladly try to help you because I am working on the same subject:

pico lvgl ILI9341 xpt2046

However there are a lot of questions that should be answered to understand the problem:

I used generated code from squareline. Tried to compile, but it throws error
{standard input}: Assembler messages:
{standard input}: Error: unaligned opcodes detected in executable segment
exit status 1
Compilation error: exit status 1

→ Please share your generated code together with the information about your core application .

What MCU/Processor/Board and compiler are you using? RP2040

RP2040 ok but what is your board? what is your display?

What LVGL version are you using?

???

What do you want to achieve?

What have you tried so far?

I run TFT espi library alone using examples.

which examples? Share the link. Do you use any IDE ( VsCode, Arduino IDE, Eclipse etc), what is your framework ( PicoSDK, Arduino-Pico (Earlephilhower), Wizio-Pico etc.), do you use PlatformIO ….

It works pretty well, so problem must be in LVGL. I also tried using Adafruit_GFX

How did you try Adafruit GFX?

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

Share your code; both LvGL code and the application. if application is long you may share a part of it

/*You code here*/

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.

Yes please !

Even a very small detail makes you application works or not!

I have a similar problem and found this thread when searching. Like the OP, the basic TFT_eSPI library by Bodmer works fine with the examples and my own projects. I’d like to use LVGL for its higher level capabilities.

Environment:
macOS 12.3.1
Pico W (but also fails with standard Pico)
ILI9341 display using SPI
Arduino IDE 1.8.19 (latest)
arduino-pico core 3.1.1 (latest)
LVGL Arduino library 8.3.6 (latest)
GCC 10.3.0 (included with Arduino core)

The error is from the assembler, which runs after the compiler has successfully compiled the C code. The file being compiled is lv_obj.c, which is part of the core LVGL code, so it seems unrelated to any specific example or demo. Google finds a few historical references to this GCC error in other projects but nothing relevant.

Compiler output (redacted):

/Users/xxx/Library/Arduino15/packages/rp2040/tools/pqt-gcc/1.5.0-b-c7bab52/bin/arm-none-eabi-gcc -c -Wall -Wextra -Werror=return-type -Wno-ignored-qualifiers -DCFG_TUSB_MCU=OPT_MCU_RP2040 -DUSBD_PID=0x000a -DUSBD_VID=0x2e8a -DUSBD_MAX_POWER_MA=250 "-DUSB_MANUFACTURER=\"Raspberry Pi\"" "-DUSB_PRODUCT=\"Pico\"" -DPICO_CYW43_ARCH_THREADSAFE_BACKGROUND=1 -DCYW43_LWIP=1 -DLWIP_IPV6=0 -DLWIP_IPV4=1 -DLWIP_IGMP=1 -DLWIP_CHECKSUM_CTRL_PER_NETIF=1 "-DARDUINO_VARIANT=\"rpipico\"" -DTARGET_RP2040 -march=armv6-m -mcpu=cortex-m0plus -mthumb -ffunction-sections -fdata-sections -fno-exceptions -DARM_MATH_CM0_FAMILY -DARM_MATH_CM0_PLUS -MMD -iprefix/Users/xxx/Library/Arduino15/packages/rp2040/hardware/rp2040/3.1.0/ @/Users/xxx/Library/Arduino15/packages/rp2040/hardware/rp2040/3.1.0/lib/platform_inc.txt -I/Users/xxx/Library/Arduino15/packages/rp2040/hardware/rp2040/3.1.0/include -std=gnu17 -g -pipe -DF_CPU=133000000L -DARDUINO=10819 -DARDUINO_RASPBERRY_PI_PICO "-DBOARD_NAME=\"RASPBERRY_PI_PICO\"" -DARDUINO_ARCH_RP2040 -Os -I/Users/xxx/Library/Arduino15/packages/rp2040/hardware/rp2040/3.1.0/cores/rp2040 -I/Users/xxx/Library/Arduino15/packages/rp2040/hardware/rp2040/3.1.0/variants/rpipico -I/Users/xxx/Documents/Arduino/libraries/TFT_eSPI -I/Users/xxx/Library/Arduino15/packages/rp2040/hardware/rp2040/3.1.0/libraries/SPI/src -I/Users/xxx/Library/Arduino15/packages/rp2040/hardware/rp2040/3.1.0/libraries/LittleFS/src -I/Users/xxx/Documents/Arduino/libraries/lvgl/src /Users/xxx/Documents/Arduino/libraries/lvgl/src/core/lv_obj.c -o /var/folders/03/s3pv8qk91w78m4_st_nbxl5m0000gn/T/arduino_build_571161/libraries/lvgl/core/lv_obj.c.o
{standard input}: Assembler messages:
{standard input}: Error: unaligned opcodes detected in executable segment
1 Like

I know what is causing that error. Damn I have to think what it was… Give me a day to poke about and see if I can find where I changed things in order to get it to work.

I am going to do a code compare with what is on the repo and see if I can locate where the issue is.

Thanks.

From my issue at the arduino-pico project, it seems to be a compiler bug. There is a workaround for advanced users: Strange compiler error · Issue #1359 · earlephilhower/arduino-pico · GitHub

I don’t know exactly what code is triggering the bug but I may experiment with some non-functional edits to see if it goes away.

I believe it’s because of unused variables/ There are 2 of them that are declared inside of functions and I honestly don’t remember where they are not am I able to locate the code I changed. While I did not experience your exact problem I encountered compiler errors because of those variables.

To avoid this problem forget about Arduino IDE and use Visual Studio code with Platformio installed on it.
Create new project with “your project name” “raspberry pi Pico board”
Change the content of Platformio.ini


[env:rpipico]
platform = GitHub - maxgerhardt/platform-raspberrypi: Raspberry Pi: development platform for PlatformIO
board = pico
framework = arduino
board_build.core = earlephilhower


step 2: Save your project.
step 3: go to your saved project folder
step 4: copy the content of ui folder given by SLS into platformio / your project/ src
step 5: rename file ui.uno - main.cpp
step 6: copy the content of libraries folder given by SLS into platformio / your project/ lib

I assume you have modified the contents of the “user_setup.h” file according to your hardware.

compile and upload !
(for example)
My “user_setup.h”:
#define ILI9488_DRIVER // WARNING: Do not connect ILI9488 display SDO to MISO if other devices share the SPI bus (TFT SDO does NOT tristate when CS is high)
#define TFT_MISO 0
#define TFT_MOSI 3
#define TFT_SCLK 2
#define TFT_CS 20 // Chip select control pin
#define TFT_DC 22 // Data Command control pin
#define TFT_RST 21
#define TOUCH_CS 14 // Chip select pin (T_CS) of touch screen

// Comment out the #define below to stop the SPIFFS filing system and smooth font code being loaded
// this will save ~20kbytes of FLASH
#define SMOOTH_FONT

#define SPI_FREQUENCY 27000000

// Optional reduced SPI frequency for reading TFT
#define SPI_READ_FREQUENCY 20000000

// The XPT2046 requires a lower SPI clock rate of 2.5MHz so we define that here:
#define SPI_TOUCH_FREQUENCY 2500000
#define USE_HSPI_PORT

I hope this will help you.

1 Like

this setting worked for me
resim