-
-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from ardera/feature-anholt-v3d
Use anholts v3d driver by default
- Loading branch information
Showing
5 changed files
with
1,019 additions
and
357 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,60 @@ | ||
# flutter-pi | ||
A light-weight Flutter Engine Embedder for Raspberry Pi that's using the broadcom APIs. Inspired by https://github.com/chinmaygarde/flutter_from_scratch. | ||
A light-weight Flutter Engine Embedder for Raspberry Pi. Inspired by https://github.com/chinmaygarde/flutter_from_scratch. | ||
Flutter-pi also runs without X11, so you don't need to boot into Raspbian Desktop & have X11 and LXDE load up; just boot into the command-line. | ||
|
||
Currently supported are basic, pure-dart Apps & mouse input (no mouse cursor yet). | ||
Not yet supported are Method & Platform-channels, touchscreen input; and probably a lot more. | ||
Currently supported are basic, pure-dart Apps (not using any plugins), mouse input (no mouse cursor yet), touchscreen input, and the StandardMethodCodec method-channels (currently needs fixing). | ||
Not yet supported are JSON method-channels. Generally, flutter-pi is not yet ready to be used as a base for your project. | ||
|
||
## Running | ||
This branch (feature-v3d-anholt) doesn't support the legacy GL driver anymore. You need to activate the anholt v3d driver in raspi-config. Go to raspi-config -> Advanced -> GL Driver -> and select fake-KMS. Full-KMS is a bit buggy and doesn't work with the Raspberry Pi 7" display (or generally, any DSI display). | ||
|
||
For some reason performance is much better when I gave the GPU only 16M RAM in fake-kms. I don't know why. | ||
|
||
Also, you need to tell flutter-pi which input device to use and whether it's a touchscreen or mouse. Input devices are typically located at `/dev/input/...`. Just run `evtest` (`sudo apt install evtest`) to find out which exact path you should use. Currently only one input device is supported by flutter-pi. | ||
|
||
Run using | ||
```bash | ||
./flutter-pi /path/without/trailing/slash [flutter arguments...] | ||
./flutter-pi [flutter-pi options...] /path/without/trailing/slash [flutter engine arguments...] | ||
``` | ||
where `/path/without/trailing/slash` is the path of the flutter asset bundle directory (i.e. the directory containing the kernel_blob.bin) | ||
|
||
`[flutter-pi options...]` are: | ||
- `-t /path/to/device` where `/path/to/device` is a path to a touchscreen input device (typically `/dev/input/event0` or similiar) | ||
- `-m /path/to/device` where `/path/to/device` is a path to a mouse input device (typically `/dev/input/mouse0` or `/dev/input/event0` or similiar) | ||
|
||
`/path/without/trailing/slash` is the path of the flutter asset bundle directory (i.e. the directory containing the kernel_blob.bin) | ||
of the flutter app you're trying to run. | ||
|
||
The `[flutter arguments...]` will be passed as commandline arguments to the flutter engine. | ||
`[flutter engine arguments...]` will be passed as commandline arguments to the flutter engine. You can find a list of commandline options for the flutter engine [Here](https://github.com/flutter/engine/blob/master/shell/common/switches.h); | ||
|
||
## Building the asset bundle | ||
You need a correctly installed flutter SDK. (i.e. the `flutter` tool must be in your PATH) | ||
|
||
Example for flutter_gallery: (note that the flutter_gallery example doesn't work with flutter-pi, since it requires plugins) | ||
```bash | ||
cd ./flutter/examples/flutter_gallery | ||
../../bin/flutter build bundle | ||
cd flutter/examples/flutter_gallery | ||
flutter build bundle | ||
``` | ||
After that `./flutter/examples/flutter_gallery/build/flutter_assets` would be a valid path to pass as an argument to flutter-pi. | ||
After that `flutter/examples/flutter_gallery/build/flutter_assets` would be a valid path to pass as an argument to flutter-pi. | ||
|
||
## Compiling (on the Raspberry Pi) | ||
You first need a `libflutter_engine.so` and `flutter_embedder.h`. [Here](https://medium.com/flutter/flutter-on-raspberry-pi-mostly-from-scratch-2824c5e7dcb1) | ||
are some rough guidelines on how to build it. (Note: the icudtl.dat that is generated during the engine compilation needs to be on the RPi too, but it's not needed for compilation of flutter-pi) | ||
|
||
## Compiling | ||
You first need a valid `libflutter_engine.so`. [Here](https://medium.com/flutter/flutter-on-raspberry-pi-mostly-from-scratch-2824c5e7dcb1) | ||
are some rough guidelines on how to build it. | ||
You also need some dependencies; run `sudo apt install libgl1-mesa-dev libgles2-mesa-dev libegl-meso0 libdrm-dev libgbm-dev`. | ||
|
||
Compiling the embedder: | ||
```bash | ||
mkdir out | ||
cc -D_GNU_SOURCE \ | ||
-lrt -lbrcmGLESv2 -lflutter_engine -lpthread -ldl -lbcm_host -lvcos -lvchiq_arm -lm \ | ||
`pkg-config --cflags --libs dri gbm libdrm glesv2 egl` -lrt -lflutter_engine -lpthread -ldl \ | ||
./src/flutter-pi.c ./src/methodchannel.c -o ./out/flutter-pi | ||
``` | ||
|
||
## Cross-Compiling | ||
You need a valid `libflutter_engine.so`, `flutter_embedder.h`, a valid raspberry pi sysroot including the /opt directory, and a valid toolchain targeting | ||
arm-linux-gnueabihf. Then execute: | ||
```bash | ||
mkdir out | ||
/path/to/cross_c_compiler \ | ||
-D_GNU_SOURCE \ | ||
--sysroot /path/to/sysroot \ | ||
-I/path/to/sysroot/opt/vc/include \ | ||
-I/directory/containing/flutter_embedder.h/ \ | ||
-L/path/to/sysroot/opt/vc/lib \ | ||
-L/directory/containing/libflutter_engine.so/ \ | ||
-lrt -lbrcmEGL -lbrcmGLESv2 -lflutter_engine -lpthread -ldl -lbcm_host -lvcos -lvchiq_arm -lm \ | ||
./src/flutter-pi.c ./src/methodchannel.c -o ./out/flutter-rpi | ||
``` | ||
## Performance | ||
Performance is actually better than I expected. With most of the apps inside the `flutter SDK -> examples -> catalog` directory I get smooth 50-60fps. | ||
|
||
## Touchscreen Bug | ||
~~If you use the official 7 inch touchscreen, performance will feel much worse while dragging something. This seems to be some bug in the touchscreen driver. The embedder / userspace only gets around 25 touch events a second, meaning that while dragging something (like in tabbed_app_bar.dart), the position of the object being dragged is only updated 25 times a second. This results in the app looking like it runs at 25fps. The touchscreen could do up to 100 touch updates a second though.~~ | ||
|
||
[This has been fixed.](https://github.com/raspberrypi/linux/issues/3227) If you want to get the fix, you can run (rpi-update)[https://github.com/hexxeh/rpi-update], which will update your system to the newest version. | ||
|
Oops, something went wrong.