Skip to content

Commit 9f4deba

Browse files
authored
Merge pull request #127 from Hixie/patch-2
Create GETTING_STARTED.md
2 parents b1c7a7c + a495b59 commit 9f4deba

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

GETTING_STARTED.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Getting Started with flutter-pi
2+
3+
These instructions summarize the information in the [README.md](README.md) file. See that file for more details.
4+
In each step below with Bash commands, the commands start with a set of `export` commands that you should update appropriately.
5+
6+
1. Build a Raspberry Pi with a touchscreen. This will be your target.
7+
8+
2. Prepare your target for flutter-pi (see "Configuring your Raspberry Pi" in the README for details):
9+
```bash
10+
export APPNAME=hello_pi # change this to the name of your application
11+
12+
# one-time setup
13+
sudo usermod -a -G render $USER
14+
sudo apt --yes install libgl1-mesa-dev libgles2-mesa-dev libegl-mesa0 libdrm-dev libgbm-dev
15+
sudo apt --yes install gpiod libgpiod-dev libsystemd-dev libinput-dev libudev-dev libxkbcommon-dev
16+
sudo apt --yes install ttf-mscorefonts-installer fontconfig
17+
sudo fc-cache
18+
if [ `uname -m` == 'armv7l' ]; then export ARM=arm; else export ARM=arm64; fi
19+
mkdir -p ~/dev
20+
pushd ~/dev
21+
git clone --depth 1 --branch engine-binaries https://github.com/ardera/flutter-pi.git engine-binaries
22+
sudo cp ~/dev/engine-binaries/$ARM/libflutter_engine.so.* /usr/lib
23+
sudo cp ~/dev/engine-binaries/$ARM/icudtl.dat /usr/lib
24+
sudo cp ~/dev/engine-binaries/flutter_embedder.h /usr/include
25+
git clone https://github.com/ardera/flutter-pi.git
26+
cd flutter-pi; make
27+
# per-application setup
28+
mkdir -p ~/dev/$APPNAME
29+
popd
30+
echo You will need to set ARM to: $ARM
31+
```
32+
33+
Take a note of the last line of output. It should say you need "arm" or "arm64". This is used to set ARM below.
34+
35+
Take a note of which version of Flutter the binaries were compiled for. This is used to set VERSION below. It should be clear from the commit messages of the latest commit to the repo: https://github.com/ardera/flutter-pi/tree/engine-binaries
36+
37+
3. Configure your target. Run `sudo raspi-config`, and configure the system as follows:
38+
1. Select `Boot Options` -> `Desktop / CLI` -> `Console` (or `Console (Autologin)`).
39+
2. Select `Advanced Options` -> `GL Driver` -> `GL (Fake-KMS)`.
40+
3. Select `Advanced Options` -> `Memory Split` and set it to `16`.
41+
4. Exit `raspi-config` and reboot when offered.
42+
43+
4. Download, install, and configure Flutter on a host machine (not the Raspberry Pi), then create an application, compile it, and run it.
44+
These instructions will put the version of Flutter you will use for the Raspberry Pi into the `~/dev/flutter-for-pi` directory so as to not interfere with your normal Flutter installation.
45+
For the purposes of these instructions we'll assume this is an x64 Linux workstation.
46+
```bash
47+
export VERSION=... # set this to the version determined above, e.g. 1.22.4
48+
export ARM=... # set this to "arm" or "arm64" as determined above
49+
export TARGET=... # set this to your Raspberry Pi's hostname
50+
export APPNAME=hello_pi # same as what you used earlier
51+
export TARGETUSER=pi # set this to your username on the raspberry pi, e.g. "pi" or $USER if it's the same as on the host
52+
53+
mkdir -p ~/dev
54+
pushd ~/dev
55+
# one-time setup
56+
git clone --branch $VERSION https://github.com/flutter/flutter.git flutter-for-pi
57+
~/dev/flutter-for-pi/bin/flutter precache
58+
git clone --depth 1 --branch engine-binaries https://github.com/ardera/flutter-pi.git engine-binaries
59+
chmod +x engine-binaries/$ARM/gen_snapshot_linux_x64
60+
# create the application
61+
flutter-for-pi/bin/flutter create $APPNAME
62+
# compile the application
63+
cd $APPNAME
64+
../flutter-for-pi/bin/flutter packages get # this might not be necessary
65+
../flutter-for-pi/bin/flutter build bundle --no-tree-shake-icons --precompiled
66+
../flutter-for-pi/bin/cache/dart-sdk/bin/dart \
67+
../flutter-for-pi/bin/cache/dart-sdk/bin/snapshots/frontend_server.dart.snapshot \
68+
--sdk-root ~/dev/flutter-for-pi/bin/cache/artifacts/engine/common/flutter_patched_sdk_product \
69+
--target=flutter \
70+
--aot --tfa -Ddart.vm.product=true \
71+
--packages .packages --output-dill build/kernel_snapshot.dill --depfile build/kernel_snapshot.d \
72+
package:$APPNAME/main.dart
73+
../engine-binaries/$ARM/gen_snapshot_linux_x64 \
74+
--causal_async_stacks --deterministic --snapshot_kind=app-aot-elf \
75+
--strip --sim_use_hardfp --no-use-integer-division \
76+
--elf=build/app.so build/kernel_snapshot.dill
77+
# upload the application
78+
rsync --recursive ~/dev/$APPNAME/build/flutter_assets/ $TARGETUSER@$TARGET:dev/$APPNAME
79+
scp ~/dev/$APPNAME/build/app.so $TARGETUSER@$TARGET:dev/$APPNAME/app.so
80+
# run the application
81+
ssh $TARGETUSER@$TARGET "killall" "flutter-pi"
82+
ssh $TARGETUSER@$TARGET "dev/flutter-pi/out/flutter-pi" "--release" "~/dev/$APPNAME"
83+
popd
84+
```
85+
86+
That's it!

0 commit comments

Comments
 (0)