Which one is good to use Torizon or Toradex Linux with LXDE?

Hello World,
I’m working on a project where I need to display Real Time data in Parallel LCD, and these data will be collecting from some sensors where these sensors gonna communicate with basic embedded protocols like I2c or SPI, so now considering these 2 things

  1. GUI(GTK 3.0)
  2. Integrating sensors with I2c and SPI
    which OS do I need to use for my development, Torzion or Toradex Linux with LXDE?
    Here for GUI I’m gonna use GTK 3.0 and I need to write drivers for I2c and SPI for sensor integration.

Hi @Nolan_Maverick ,

You can use both TorizonCore and our LXDE images, but I’d recommend using TorizonCore since the LXDE images are older, legacy releases.

I saw your last question here: What Linux OS do I need to use to create and use GTK application? and given that it is related to this one, let me clarify one point in particular:

  • When you tried doing sudo apt-get update inside the container, you ran the command as user torizon, which doesn’t have a password in the container; that’s why you couldn’t execute the update. You can get around this by entering the container as root by specifying --user 0 in docker run, but all changes you do there will not be saved. See below how to avoid this.

Keep in mind that TorizonCore was made specifically to use applications inside containers, so there are some caveats to be aware of like:

  • By default, when inside a container every extra package you install via apt install will not be saved after you stop the container. If you need GTK related packages installed in the container you can create a new Docker image by writing a Dockerfile, as instructed here: Modifying TorizonCore Debian Based Container Images | Toradex Developer Center.

  • Also by default a container is not aware of any device connected to the module. You can expose a device with the --device option when running a container e.g.

docker run -it --rm --device=/dev/apalis-uart2 <image_name>

As an alternative way to develop and deploy applications on TorizonCore while abstracting some of the details surrounding Docker, you can use our Visual Studio Code Extension for Torizon to develop your project.

Let me know if this made things clearer.

EDIT: Grammar correction

Best regards,
Lucas Akira

1 Like

Hello @lucas_a.tx ,
I followed your instructions, and then I’m able to apt update and download gtk2.0 and gedit text editor,
I edited code in gedit which pops up as GUI,
using gedit I add these C lines for simple GTK application.

#include <gtk/gtk.h>

int main(int argc, char *argv) {

gtk_init(&argc, &argv);

g_printf("Hello World\n");   
    
return 0;

}
It compiled well, but while trying to run I got the error as shown below

Error: cannot open display: :0
but gedit is also a GUI the why its displaying?

Hi @Nolan_Maverick ,

I followed your instructions, and then I’m able to apt update and download gtk2.0 and gedit text editor,
I edited code in gedit which pops up as GUI,
using gedit I add these C lines for simple GTK application.

The instructions you followed were about running the terminal container as root (--user 0), is this correct?

It compiled well, but while trying to run I got the error as shown below

I was able to reproduce this and it looks like it’s related to the fact you’re executing the GTK program as root in Wayland.

It should work if you change the user to torizon before executing the program. Change the user with:

su -s /bin/bash torizon

I was able to run your test code once I executed the program as user torizon. For reference, compilation was done with:

gcc simple.c -o simple `pkg-config --cflags --libs gtk+-2.0`

Given that you’ll probably develop a more complex program than the example you showed, I strongly recommend that you create a new Docker image using Dockerfile with all GTK libraries installed instead of developing on a running container like you’re doing now. See here how to do this.

For instance, you can avoid running the container as root when using a Docker image with all dependencies already installed.

Hope this helps you.

Best regards,
Lucas Akira