Embedded Linux embedding for Flutter

Overview

Embedded Linux embedding for Flutter

build-test

This project was created to develop non-official embedded Linux embeddings of Flutter. This embedder is focusing on embedded Linux system use cases. It is also implemented based on Flutter desktop for Windows and has some unique features to use it in embedded systems.

Objective & Goal

Our objective is to use Flutter in embedded systems. We're developing this embedder to use Flutter in embedded products. Ultimately we would like to propose and contribute this software to the mainline of Flutter Engine, which means we would like to add embedded systems support into Flutter officially for all embedded developers. Please note that this is just our ideal, not the official opinion of the Flutter community.

We would be grateful if you could give us feedback on bugs and new feature requests. We would like to cover specifications of general-purpose embedded systems.

Features

  • Suitable for use in embedded systems
    • A few dependent libraries
    • Lightweight than Flutter desktop for Linux (Not using X11 and GTK)
    • The main target of this embedder is Arm64 devices. We haven't confirmed in Arm 32bit (ARMv7, armhf) devices
  • Wayland backend support
  • Direct rendering module (DRM) backend support
    • Generic Buffer Management (GBM)
    • EGLStream for NVIDIA devices (coming soon)
  • Always single window fullscreen
    • You can choose always-fullscreen or flexible-screen (any size) only when you use Wayland backend
  • Keyboard, mouse and touch inputs support
  • Equivalent quality to Flutter desktops
  • API compatibility with Flutter desktop for Windows and GLFW
    • APIs such as MethodChannel and EventChannel are completely the same with them

Supported platforms

This embedder supports x64 and Arm64 (aarch64, ARMv8) architectures on Linux which supports either Wayland backend or DRM backend.

Tested devices

Board/SoC Vendor OS Display backend Status
Desktop (x64) Intel Ubuntu18.04 Wayland ✔️
Desktop (x64) Intel Ubuntu18.04 DRM ✔️
Jetson Nano NVIDIA JetPack 4.3 Wayland ✔️
Jetson Nano NVIDIA JetPack 4.3 DRM See: #1
Raspberry Pi 4 Model B Raspberry Pi Foundation Ubuntu 20.10 Wayland ✔️
Raspberry Pi 4 Model B Raspberry Pi Foundation Ubuntu 20.10 DRM ✔️ (#9)
i.MX 8MQuad EVK NXP Sumo (kernel 4.14.98) Wayland ✔️
i.MX 8MQuad EVK NXP Sumo (kernel 4.14.98) DRM Not tested
i.MX 8M Mini EVKB NXP Sumo (kernel 4.14.98) Wayland ✔️
i.MX 8M Mini EVKB NXP Sumo (kernel 4.14.98) DRM Not tested
Zynq Xilinx - - Not tested
RB5 Development Kit Qualcomm - - Not tested

Contributing

Now, we cannot accept any Pull Request (PR). Because We are building a system (e.g. CLA) to accept PRs, so please wait for a while the system is getting ready! However, we are always welcome to report bugs and request new features by creating issues.

With the assumption, our final goal of this software openly is to be merged this embedder into Flutter Engine after getting feedbacks. And Google CLA will be required when we do that in the future. Therefore, we cannot easily accept an external PR. However, you can free to create issues for reporting bugs and requesting new features.

See also: Contributing to the Flutter engine

Contents

1. Install libraries

You need to install the following dependent libraries to build and run. Here introduce how to install the libraries on Ubuntu OS and x64 hosts.

Mandatory

  • clang (for building)
  • cmake (for building)
  • build-essential (for building)
  • pkg-config (for building)
  • EGL
  • xkbcommon
  • OpenGL ES (>=2.0)
$ sudo apt install clang build-essential pkg-config libegl1-mesa-dev libxkbcommon-dev libgles2-mesa-dev

Only when you use Wayland backend

  • libwayland
$ sudo apt install libwayland-dev

Only when you use weston desktop-shell

  • weston (>=6.0.1)
$ sudo apt install weston

Only when you use DRM backend

  • libdrm
  • libgbm
  • libinput
  • libudev
  • libsystemd
$ sudo apt install libdrm-dev libgbm-dev libinput-dev libudev-dev libsystemd-dev

Install Flutter core embedder library

This embedder requres libflutter_engine.so (Flutter embedder library). You need to install libflutter_engine.so to /usr/lib. See: Building Flutter Engine embedder

Or you can download a specific pre-built Flutter Engine from Google's infra by the following steps, but it's limited to debug mode and x64 targets.

[Step1] Check the version (SHA) of the channel you want to use.

[Step2] Download Flutter Engine embedder library. Note that replace FLUTTER_ENGINE with the SHA of the Flutter engine you want to use.

$ curl -O https://storage.googleapis.com/flutter_infra/flutter/FLUTTER_ENGINE/linux-x64/linux-x64-embedder

[Step3] Install the library. Note that the downloaded library is only debug mode and for x64 targets.

$ unzip ./linux-x64-embedder
$ sudo cp ./libflutter_engine.so /usr/lib

2. Examples

There are sample projects in examples directory. You can also comunicate with Dart code by using the plugin APIs with the same specifications as with Flutter desktops for Windows.

3. Building

Build for Wayland backend (Stand-alone Wayland app)

$ mkdir build
$ cd build
$ cmake -DUSER_PROJECT_PATH=examples/flutter-wayland-client ..
$ make

Build for DRM backend

$ mkdir build
$ cd build
$ cmake -DUSER_PROJECT_PATH=examples/flutter-drm-backend ..
$ make

Build for Wayland backend (weston desktop-shell)

This binary will run as a desktop-shell by setting weston.ini when Weston starts. See Settings of weston.ini file.

$ mkdir build
$ cd build
$ cmake -DUSER_PROJECT_PATH=examples/flutter-weston-desktop-shell ..
$ make

User configuration parameters (CMAKE options)

Please edit cmake/user_config.cmake file.

Option Description
USE_DRM Use DRM backend instead of Wayland
DESKTOP_SHELL Work as weston desktop-shell
USE_VIRTUAL_KEYBOARD Use Virtual Keyboard (only when you use DESKTOP_SHELL)
USE_GLES3 Use OpenGLES3 instead of OpenGLES2

4. Running Flutter app

Install Flutter SDK

See also: Desktop support for Flutter

$ git clone https://github.com/flutter/flutter
$ sudo mv flutter /opt/
$ export PATH=$PATH:/opt/flutter/bin
$ flutter config --enable-linux-desktop
$ flutter doctor

Please note that you must use the same version (channel) that you built Flutter embedder for. I recommend that you use the latest version of the master channel for both the SDK and Flutter Engine. See also: Building Flutter Engine embedder

Build Flutter app

Here introduce how to build the flutter sample app.

for x64 targets on x64 hosts / for Arm64 targets on Arm64 hosts

$ flutter create sample
$ cd sample/
$ flutter build linux
$ cd ..

for Arm64 targets on x64 hosts

Comming soon. We are contributing to support this now. See: https://github.com/flutter/flutter/issues/74929

Run Flutter app

Run with Wayland backend

Wayland compositor (weston) must be running before running the program.

$ ./flutter-client ./sample/build/linux/x64/release/bundle

Run with DRM backend

You need to switch from GUI which is running X11 or Wayland to the Character User Interface (CUI). In addition, FLUTTER_DRM_DEVICE must be set properly. The default value is /dev/dri/card0.

$ Ctrl + Alt + F3 # Switching to CUI
$ FLUTTER_DRM_DEVICE="/dev/dri/card1" ./flutter-drm-backend ./sample/build/linux/x64/release/bundle

If you want to switch back from CUI to GUI, run Ctrl + Alt + F2 keys in a terminal.

Note

You need to run this program by a user who has the permission to access the input devices(/dev/input/xxx), if you use the DRM backend. Generally, it is a root user or a user who belongs to an input group.

5. Settings of weston.ini file (Only when you use weston desktop-shell)

Sets the following parameters when this embedder works as a desktop-shell on weston. Sample file can be found examples/config/weston.ini. See also man weston.ini.

shell section

Specifies the path to the binary file to start as the shell when weston starts.

Field Description
client ${path to the binary}/flutter-desktop-shell

extended section

An extended section for this embedder. The entries that can appear in this section are:

Field Description
show-cursor Set whether to show mouse cursor (boolean)
flutter-project-path Set an absolute path or relative path from the binary file to Flutter project path (string)
Comments
  • On-screen keyboard doesn't work

    On-screen keyboard doesn't work

    Currently, the virtual keyboard input is only enabled when running as weston-desktop-shell. Reported from: https://twitter.com/PakoSStoyanov/status/1391034963030597632

    bug wayland on-screen keyboard 
    opened by HidenoriMatsubayashi 36
  • Can't run Gallery app

    Can't run Gallery app

    Can't start the Gallery app using the embedder. There are no log messages to help narrow down why that is:

    $ ./flutter-client ./gallery/build/linux/x64/release/bundle     
    
    

    Observed on my x64 system as well as the PinebookPro (rk3399) and PinePhone (Allwinner A64).

    Tried with drm client and debug modes as well - still no feedback from the system as to why it doesn't want to start.

    bug wayland 
    opened by psstoyanov 22
  • Add Yocto support

    Add Yocto support

    Do you have a plan to add a Yocto support for flutter-embedded-linux?

    Yocto Layer for the Flutter already exists : https://github.com/jwinarske/meta-flutter

    It has support for some of the engines, such as flutter-pi.

    enhancement yocto 
    opened by jmarijan 19
  • Mouse cursor is visible even when no mouse is connected

    Mouse cursor is visible even when no mouse is connected

    There is a mouse cursor that appears even when no mouse is connected, on flutter-pi it only comes up when a mouse is connected however in this case it comes up by default on. This is on a gbm backend

    drm mouse-cursor 
    opened by Taha-Firoz 18
  • Test in various Wayland compositors

    Test in various Wayland compositors

    At the moment using the standalone wayland client appears to be made to work only within a Weston environment. My attempts to use the embedder with other Wayland environments such as Plasma Wayland, wlroots based ones like Wayfire result in the following error:

    [ERROR][linuxes_window_wayland.cc(627)] Invalid compositor and shell.
    Failed to create view controller.
    

    I haven't attempted to run the embedder within Cage or Phosh but I don't expect different results.

    From what I can see, this is because the defined shell protocol is specific to Weston's implementation: https://github.com/sony/flutter-embedded-linux/tree/master/src/wayland/protocol

    Would using a different shell implementation like xdg allow for more Wayland environments to be supported? Or is the error given by the embedder a result from different check defined somewhere in linuxes_window_wayland.h?

    From the Wayland book, I can see the section explaining on how to generate the C headers and glue code. Would experiments with other shell protocols be useful to the project?

    My understanding isn't as complete as I would like it to be so I don't know if I'm just using the Wayland client incorrectly in this case.

    wayland 
    opened by psstoyanov 17
  • Building flutter-engine with fontconfig support

    Building flutter-engine with fontconfig support

    If we want to display CJK characters using system font, we have to enable fontconfig support. Just add --enable-fontconfig to ./flutter/tools/gn command. Could you please consider enabling this in your CI pipeline when you build the artifacts?

    enhancement 
    opened by andreadaoud 14
  • Run with Wayland backend

    Run with Wayland backend

    After following the docs, I have been trying to run with Wayland backend, however I get the error which I have been unable to resolve:

    ./flutter-client --bundle=./sample/build/linux/x64/release/bundle/
    embedder.cc (939): 'FlutterEngineInitialize' returned 'kInvalidArguments'. Not running in AOT mode but could not resolve the kernel binary.
    [ERROR][flutter_linuxes_engine.cc(221)] Failed to start Flutter engine: error 2
    Failed to create view controller.
    Failed to create a Flutter window.
    

    Any help would be greatly appreciated! Thanks

    opened by alfiedouglas-tewke 13
  • Ozone abstraction

    Ozone abstraction

    Hi, I was wondering if you might be interested in using Ozone to abstract away the back ends for Wayland, DRM, etc.

    That would also bring along support for X11, Cast and any future backends as well.

    There is no dependency on any other toolkit like GTK or even a dependency on Chromium.

    It would bring along support for running headless, using hardware overlays and zero-copy texture uploads for things like low power hardware accelerated video on embedded and desktop platforms.

    opened by oilipheist 13
  • [README] Installing the embedder library and using different modes (debug/profile/release)

    [README] Installing the embedder library and using different modes (debug/profile/release)

    The documentation implies that libflutter_engine.so has to be installed here:

    • https://github.com/sony/flutter-embedded-linux#install-flutter-core-embedder-library and here:
    • https://github.com/sony/flutter-embedded-linux/blob/master/BUILDING-ENGINE-EMBEDDER.md#5-install-embedder-library

    While this is the preferred method, the libraries can be loaded without placing them in /urs/lib. The following method can be used instead: LD_LIBRARY_PATH=<path_to_engine> ./flutter-client ./sample/build/linux/x64/debug/bundle

    This could be useful when:

    • Switching quickly between debug / profile / release modes for the Flutter application without replacing libflutter_engine.so
    documentation 
    opened by psstoyanov 13
  • DRM doesn't work the PinePhone

    DRM doesn't work the PinePhone

    Using PinePhone running ManjaroARM with Plasma Mobile, the DRM backend doesn't work. Device information:

    • Allwinner A64
    • kernel: Linux plasma-mobile 5.11.4-1-MANJARO-ARM #1 SMP Sun Mar 7 19:22:26 UTC 2021 aarch64 GNU/Linux
    • mesa: 20.3.4 (the device is using the Lima driver)

    Flutter version:

    $ flutter --version
    Flutter 2.1.0-11.0.pre.164 • channel unknown • unknown source
    Framework • revision ede798e029 (2 days ago) • 2021-03-09 01:34:02 -0500
    Engine • revision 2441c476a6
    Tools • Dart 2.13.0 (build 2.13.0-116.0.dev)
    

    LLDB trace when running the drm backend:

    Process 29798 launched: '/home/kde/flutter-embedded-linux/build/flutter-drm-backend' (aarch64)
    [ERROR][native_window_drm.cc(185)] Couldn't get resources
    Process 29798 stopped
    * thread #1, name = 'flutter-drm-bac', stop reason = signal SIGSEGV: invalid address (fault address: 0x20)
        frame #0: 0x0000aaaaaab2e570 flutter-drm-backend`flutter::NativeWindowDrm::FindConnector(this=0x0000aaaaaac75870, resources=0x0000000000000000) at native_window_drm.cc:215:34
       212 	}
       213 	
       214 	drmModeConnectorPtr NativeWindowDrm::FindConnector(drmModeResPtr resources) {
    -> 215 	  for (int i = 0; i < resources->count_connectors; i++) {
        	                                 ^
       216 	    auto connector = drmModeGetConnector(drm_device_, resources->connectors[i]);
       217 	    // pick the first connected connector
       218 	    if (connector->connection == DRM_MODE_CONNECTED) {
    

    I don't have a RPi4 to verify if it is the same issue as the one observed with https://github.com/sony/flutter-embedded-linux/issues/9

    bug drm mouse-cursor 
    opened by psstoyanov 12
  • cmake gives linker error while performing cmake --build .

    cmake gives linker error while performing cmake --build .

    I am following steps mentioned in wiki, I tried prebuilt libflutter_engine.so (elinux-arm64-debug, elinux-arm64-release, elinux-x64), but every time, cmake is throwing same issue, I am sharing error here.

    [email protected]:build$ sudo cmake -DUSER_PROJECT_PATH=examples/flutter-wayland-client -DCMAKE_BUILD_TYPE=Debug ..
    User project: examples/flutter-wayland-client
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /home/ubuntu/flutter-projects/mylxc_flutter/flutter-embedded-linux/build
    [email protected]:build$ sudo cmake --build .
    [  1%] Linking CXX executable flutter-client
    /usr/bin/ld: libflutter_engine.so: error adding symbols: file in wrong format
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make[2]: *** [CMakeFiles/flutter-client.dir/build.make:857: flutter-client] Error 1
    make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/flutter-client.dir/all] Error 2
    make: *** [Makefile:130: all] Error 2
    

    Please help me out!

    NOTE: I have installed Yocto for cross building Cross Building from x64 to arm64

    Thanks in advance

    question 
    opened by Khalid-Faisal 11
  • Install flutter on Variscite i.MX8M Nano

    Install flutter on Variscite i.MX8M Nano

    Hello everybody

    I would need help installing flutter in a Variscite card equipped with i.MX8M Nano processor.

    I started to follow the guide, but it is not clear to me how to proceed and in what order the various steps should be followed.

    Then is there a way to compile on a macOS with M1 and then run on this card?

    The things that are mostly unclear to me are where it says to refer to the cmake build path, and also where to find the flutter-client it refers to in some places in the guide, but I don't find where this is installed.

    Thank you

    opened by marco-1988 0
  • Poor render performances on iMX 8 Nano (X11)

    Poor render performances on iMX 8 Nano (X11)

    Hello and thanks again for the package !

    I am having trouble to see good performances on my linux device. I am running my flutter app (release mode) on an IMX 8 Nano under Debian 11.

    My device has no GPU, 1 CPU with 1 core - 1Go of RAM - 1Go disk space. I run the flutter app under OpenBox in X11.

    Animation are very janky and missing a lot of frames (Navigator.push with the default animation), scrolling a ListView above other widgets is also laggy. The CPU is also rising up to 90% while scrolling a ListView.builder. Any Transform.translate animation style is janky.

    I would like to run a Wayland compositor but i can't find a good one :

    • Weston doesn't run standalone - DRM is not supported and under a Openbox - XFCE it works but the performances are worse.
    • GNOME requires 2Go disk space that i have not.

    I have seen that you have tested :

    Capture d’écran 2022-09-16 à 17 20 37

    May i know which Wayland compositor did you use please ? Do you think my device hardware specifications are enough (without GPU or only 1 core) to run a usual Flutter app ?

    Thanks a lot in advance

    Note : I have run a basic flutter app with only a ListView.builder inside, the scrolling is rising the CPU up to 90% but the animation is quite smooth on X11 (OpenBox). If i scroll a ListView.builder above a Container that has a Image.asset behind (100x100 with 100Kb), it starts lagging.

    question x11 
    opened by Tom3652 18
  • Software rendering support

    Software rendering support

    From https://github.com/sony/flutter-elinux/issues/124

    Because I think that many embedded device have no GPU. I want to know if elinux flutter can run on CPU?

    enhancement question 
    opened by HidenoriMatsubayashi 1
  • Add JSON config/ini file to launch instead of command line only

    Add JSON config/ini file to launch instead of command line only

    I've worked in quiet a few designs in possible config files to launch the embedder from instead of the just command line parameters. It could help make it a lot clearer to start your application and configurations can be more detailed if we do.

    enhancement 
    opened by Taha-Firoz 7
  • flutter-client fails to start Dart VM HTTP Service

    flutter-client fails to start Dart VM HTTP Service

    Hi,

    I've built the debug wayland recipes using meta-flutter and can run flutter apps in debug mode. Whenever I start a flutter app (by using flutter-client -b /path/to/bundle) I get the following error

    flutter: Could not start Dart VM service HTTP server:
    SocketException: Failed to create server socket (OS Error: Cannot assign requested address, errno = 99), address = 127.0.0.1, port = 0
    #0      _NativeSocket.bind (dart:io-patch/socket_patch.dart:996:7)
    <asynchronous suspension>
    #1      Server.startup.startServer (dart:vmservice_io/vmservice_server.dart:424:19)
    <asynchronous suspension>
    #2      Server.startup (dart:vmservice_io/vmservice_server.dart:443:11)
    <asynchronous suspension>
    

    and subsequently I am unable to attach the debugger. This also fails when using flutter custom-devices on a host machine to try and debug (same error).

    Why would this be, is there a way to see a more verbose log?

    Thanks

    question 
    opened by LeoBound 8
Releases(3316dd8728)
Owner
Sony
Sony Corporation
Sony
A Flutter Youtube and Video Downloader

A Flutter Desktop GUI App of Youtube-dl which download video from Youtube, Facebook (both public and private)

superatom 21 Oct 10, 2022
Which companies are using Flutter in Turkey 🇹🇷

Which companies are using Flutter in Turkey ???? You can easily see which companies are using Flutter in Turkey. Also, you can easily handle your Flut

Adem Furkan Özcan 42 Dec 31, 2022
Linux Terminal Service Manager (LTSM) is a set of service programs that allows remote computers to connect to a Linux operating system computer using a remote terminal session (over VNC or RDP)

Linux Terminal Service Manager (LTSM) is a set of service programs that allows remote computers to connect to a Linux operating system computer using a remote terminal session (over VNC)

null 34 Dec 16, 2022
C++ library for creating an embedded Rest HTTP server (and more)

The libhttpserver reference manual Tl;dr libhttpserver is a C++ library for building high performance RESTful web servers. libhttpserver is built upon

Sebastiano Merlino 711 Dec 27, 2022
A portable MQTT C client for embedded systems and PCs alike.

MQTT-C is an MQTT v3.1.1 client written in C. MQTT is a lightweight publisher-subscriber-based messaging protocol that is commonly used in IoT and net

Liam Bindle 570 Dec 29, 2022
FreeModbus is a Modbus ASCII/RTU and Modbus TCP implementation for embedded systems

FreeModbus is a Modbus ASCII/RTU and Modbus TCP implementation for embedded systems. It provides an implementation of the Modbus Application Protocol

Mahmood Hosseini 22 Oct 11, 2022
Open source file system for small embedded systems

STORfs Open Source File System Release Version 1.0.2 Created by: KrauseGLOBAL Solutions, LLC What is STORfs? STORfs is an open source flash file syste

null 17 Jul 26, 2022
Common utilities useful for embedded systems that are often not included in an RTOS or the standard C library.

Welcome to Fitterbap, the Firmware toolkit to enable reliable best architecture practices! Fitterbap provides common utilities useful for embedded systems that are often not included in an RTOS or the standard C library.

Jetperch 20 Dec 7, 2022
Enabling services on your device 81 Jan 6, 2023
WebSockets in C for Embedded Applications

WebSockets in C WIC is a C99 implementation of rfc6455 websockets designed for embedded applications. WIC decouples the websocket protocol from the tr

Cameron Harper 59 Dec 28, 2022
Run statically-compiled WebAssembly apps on any embedded platform

embedded-wasm-apps Run native, statically-compiled AssemblyScript, Rust, C/C++, TinyGo, Zig, etc. apps on any platform How it works The approach is si

Volodymyr Shymanskyy 112 Dec 20, 2022
Hyelicht is an IoT/embedded project for home decoration/automation.

Hyelicht is an IoT/embedded project for home decoration/automation. Its software allows you to do colorful painting and animations on a LED-b

Eike Hein 107 Dec 23, 2022
SixtyFPS is a toolkit to efficiently develop fluid graphical user interfaces for any display: embedded devices and desktop applications

SixtyFPS is a toolkit to efficiently develop fluid graphical user interfaces for any display: embedded devices and desktop applications. We support multiple programming languages, such as Rust, C++, and JavaScript.

SixtyFPS 5.5k Jan 2, 2023
Event-driven network library for multi-threaded Linux server in C++11

Muduo is a multithreaded C++ network library based on the reactor pattern. http://github.com/chenshuo/muduo Copyright (c) 2010, Shuo Chen. All righ

Shuo Chen 12.4k Jan 1, 2023
Drogon: A C++14/17 based HTTP web application framework running on Linux/macOS/Unix/Windows

English | 简体中文 | 繁體中文 Overview Drogon is a C++14/17-based HTTP application framework. Drogon can be used to easily build various types of web applicat

An Tao 8.5k Jan 5, 2023
Cross-connect Linux interfaces with XDP

Cross-connect Linux interfaces with XDP redirect xdp-xconnect daemon is a long-running process that uses a YAML file as its configuration API. For exa

Michael Kashin 50 Dec 9, 2022
web server that will print hello world on the screen only for linux users

a simple http server side lib only for linux users Note: This lib is currently under development you can check the source code and even use it but dn'

notaweeb 11 Mar 14, 2021
Linux Application Level Firewall based on eBPF and NFQUEUE.

eBPFSnitch eBPFSnitch is a Linux Application Level Firewall based on eBPF and NFQUEUE. It is inspired by OpenSnitch, and Douane, but utilizing modern

Harpo Roeder 665 Dec 29, 2022
Free Media Player for Windows and Linux with Youtube support.

SMPLAYER SMPlayer is a free media player for Windows and Linux with Youtube support.

Ricardo 324 Dec 27, 2022