We have to wire up the PN532 NFC Module. Depending on the protocol used we need to wire it up for either SPI or I2C. I would always recommend to wire up for both protocols!
- Alwayse needed are the three wires for
VCC,GNDandIRQ(hereGPIO16) I2Cneeds theSDAand theSCLwiresSPIneedsMOSI,MISO,SCLK/SCK,CEO/SS
Just connect the corresponding wires from the PN532 with the Raspberry Pi (no fancy cross wiring just SDA -> SDA, SCL -> SCL, MOSI -> MOSI, ...) according to the following picture:
- NOTE: the bottom of this picture is where the USB-Ports of the Pi are and the right side is on the edge of the Pi!
-
First setup the
wpa_supplicant.confwhich is located in/etc/wpa_supplicant(full path is/etc/wpa_supplicant/wpa_supplicant.conf)
Past the following content into the file:network={ ssid="eduroam" password="[PLAIN-TEXT-PASSWORD-UNI-POTSDAM]" identity="[SHORT-VERSION-USERNAME(UNI-POTSDAM-LOGIN)]@uni-potsdam.de" anonymous_identity="[email protected]" key_mgmt=WPA-EAP eap=PEAP phase2="auth=MSCHAPV2" }Replace the [...] with your Username and Password!
-
Reboot the pi
-
You have to do this as actual root (sudo won't work here!). Become sudo by entering:
sudo -i -
Configure the wifi with:
wpa_passphrase "WLAN-NAME" "WLAN-PASSWORT" >> /etc/wpa_supplicant/wpa_supplicant.conf -
Exit the root user:
exit -
Reboot:
sudo reboot
- Sometimes you may also have to edit
/etc/network/interfacesand add the following lines:allow-hotplug wlan0 iface wlan0 inet manual wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf iface wlan0 inet dhcp -
- First kill all the
wpa_supplicantservices and bring down all the ethernet devices with the following commands:ifdown wlan0 ifdown wlan0 killall wpa_supplicant
- You can now debug the newly made configuraiton with
sudo wpa_supplicant -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf. (Optionally you can add -B for deamon mode or -d for debug infos (-dd even more debug infos))
- First kill all the
- Extra infos on this website
Detail instructions can be found here.
-
Navigate to the home directory with:
cd -
Just copy and past the following script which is based on the official instructions (script last updated: 03.03.2022)
#!/bin/bash # Update the pi echo "Updating Pi" sudo apt update -y sudo apt upgrade -y sudo apt dist-upgrade -y # Install the engine binaries from `https://github.com/ardera/flutter-engine-binaries-for-arm` echo "Installing newest flutter engine binaries from 'https://github.com/ardera/flutter-engine-binaries-for-arm'" git clone --depth 1 https://github.com/ardera/flutter-engine-binaries-for-arm.git engine-binaries cd engine-binaries sudo ./install.sh cd .. # Install flutter-pi from source from `https://github.com/ardera/flutter-pi` echo "Installing flutter-pi" sudo apt install -y git vim cmake libgl1-mesa-dev \ libgles2-mesa-dev libegl1-mesa-dev libdrm-dev libgbm-dev \ ttf-mscorefonts-installer fontconfig libsystemd-dev libinput-dev \ libudev-dev libxkbcommon-dev libgstreamer1.0-dev \ libgstreamer-plugins-base1.0-dev libgstreamer-plugins-bad1.0-dev \ gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly \ gstreamer1.0-plugins-bad gstreamer1.0-libav sudo fc-cache git clone https://github.com/ardera/flutter-pi cd flutter-pi mkdir build cd build cmake .. make -j`nproc` sudo make install cd ../.. sudo usermod -a -G render pi # Some Information for the user echo "" echo "" echo "After script termination open 'sudo raspi-config' and set Autologin Shell, SPI enabled and GPU Memory 64" echo "Than you can start deploying the flutter app stated in 'https://github.com/ardera/flutter-pi'" echo "You have to start at 'Building the asset bundle'"
-
Open raspi-config:
sudo raspi-config
-
Switch to console mode:
System Options -> Boot / Auto Loginand selectConsole. -
Raspbian buster only, skip this if you're on bullseye (or newer - which is normally the case) - if you encoutner an
[flutter-pi] Could not query DRM device list: No such file or directoryerror try this setting too
Enable the V3D graphics driver:
Advanced Options -> GL Driver -> GL (Full KMS) -
Configure the GPU memory
Performance Options -> GPU Memoryand enter64. -
Enable SPI and I2C:
Interface Options -> SPI -> YesandInterface Options -> I2C -> Yes -
Leave
raspi-config. -
Give the
pipermission to use 3D acceleration - normally this is already done in the script but doing it again does no harm. (NOTE: potential security hazard. If you don't want to do this, launchflutter-piusingsudoinstead - the flutter-pi script above usally already enabled this!)sudo usermod -a -G render pi
-
Finish and reboot:
sudo shutdown -r now
Compiling the Flutter App for Raspberry Pi (not needed if you use the precompiled app from release_build - See info section Precompiled App)
IMPORTANT: Do all this on a Linux
x86_64machine which is not the Raspberry Pi (since the Pi isarm!)
For performance reason you could also execute every command on any development machine except for the third step inCompiling the appsince thegen_snapshot_linux_x64_releaseexecutable is only compiled forx64as the name says
We want create a file structure that looks like the following:
engine_binaries/
│
├─ arm/
│ │
│ ├─ gen_snapshot_linux_x64_release
│
├─ install.sh
│
flutter_terminal/
│
├─ build/
│ ├─ flutter_assets/
│ │ ├─ app.so
│
├─ lib/
│ ├─ main.dart
│
├─ README.md
-
Install flutter on the system - always make sure that the engine binaries version installed on the Raspberry Pi (when setting up
flutter-pi) matches the Flutter version which is used to compile the app - (just follow the instructions here) - basically just:sudo snap install flutter --classic -
Now clone the engine binaries:
git clone --depth 1 https://github.com/ardera/flutter-engine-binaries-for-arm.git engine-binaries
Important check that the engine binaries version equals the used flutter verion (flutter --version) -
After that actual clone the project
git clone https://gitlab.hpi.de/fachschaftsrat/wallet/flutter_terminal flutter_terminal -
Change into the project with:
cd flutter_terminal -
Edit the
env.example.yamlin a way that it works for you and copy/rename it toenv.yamlfor example with:mv env.example.yaml env.yaml -
Get all the flutter packages with
flutter pub get -
Generate all the files that need code generation with:
flutter pub run build_runner build -
Build the flutter bundle with:
flutter build bundle
Now we should have the following setup:
- The app dir is called
flutter_terminal- The engine binaries are in
engine-binaries- The
nameinflutter_terminal/pubspec.yamlisterminal_frontend- The Flutter SDK should be downloaded and reachable with
flutter sdk-path(execute this or any other Flutter command at least once to trigger the SDK download)
-
If you aren't already in the flutter project directory change into it with:
cd flutter_terminal -
Execute the following to build the kernel snapshot:
$(flutter sdk-path)/bin/cache/dart-sdk/bin/dart \ $(flutter sdk-path)/bin/cache/dart-sdk/bin/snapshots/frontend_server.dart.snapshot \ --sdk-root $(flutter sdk-path)/bin/cache/artifacts/engine/common/flutter_patched_sdk_product \ --target=flutter \ --aot \ --tfa \ -Ddart.vm.product=true \ --packages .packages \ --output-dill build/kernel_snapshot.dill \ --verbose \ --depfile build/kernel_snapshot.d \ package:terminal_frontend/main.dart
-
Build the
app.sowith thegen_snapshot_linux_x64_releasefrom the engine binaries repo (When building forarm64add the--sim-use-hardfpflag)../engine-binaries/arm/gen_snapshot_linux_x64_release \ --deterministic \ --snapshot_kind=app-aot-elf \ --elf=build/flutter_assets/app.so \ --strip \ build/kernel_snapshot.dill
(Be aware that for this step the engine binaries must be located inside the parent directory as shown in the folder structure at the top)
- Copying everything into
~/FsrTerminalon the Pi by executingrsync -a ./build/flutter_assets/ [email protected]:~/FsrTerminal/
-
Copy the precompiled app from this repo to the Pi or clone it on the Pi and copy the
release_build/FsrTerminaldirectory to/home/pi. Now the following path should exist:/home/pi/FsrTerminal! -
Inside the
FsrTerminalrename theassets/env.example.yamltoenv.yamlby executing:mv assets/env.example.yaml assets/env.yaml -
Edit the
assets/env.yamlfile according to your setup!
-
Create a new file in
/etc/systemd/systemcalledfsr-terminal.servicewithsudo touch /etc/systemd/system/fsr-terminal.service -
Past in the following content (with
sudo vim /etc/systemd/system/fsr-terminal.service):[Unit] Description=The service starting and controlling the FSR Terminal Flutter App After=multi-user.target # Getting a little fancy with the restart options here # The next 3 options are tightly connected to each other # Give up restarting and exec StartLimitAction - if it fails 15 times (=StartLimitBurst) within 300 (=StartLimitIntervalSec) seconds StartLimitBurst=15 StartLimitIntervalSec=300 StartLimitAction=reboot-force [Service] User=pi # Sometimes the flutter-pi path must be given in absolute form ExecStart=/home/pi/FsrTerminal/assets/StartScript.sh ExecStop=/usr/bin/killall flutter-pi # Always try to restart Restart=always # Retry restart after 10s RestartSec=10 # Useful during debugging; remove it once the service is working #StandardOutput=console [Install] WantedBy=multi-user.target
-
Reload the service-files though the new service will be found
sudo systemctl daemon-reload -
Enable the service by executing
sudo systemctl enable fsr-terminal -
Make the
StartScript.shexecutable with:sudo chmod 755 ~/FsrTerminal/assets/StartScript.sh -
When starting the service with
sudo systemctl start fsr-terminalthe app should start as normal otherwise see theTroubleshootingsection below -
After a restart the system should automatically open the FSR Terminal
-
Check the output of
systemctl status fsr-terminal -
Check the outputs of
journalctl -u fsr-terminal -
Check what happens when you execute the command executed by the start up service - look in
/etc/systemd/system/fsr-terminal.serviceforExecStart=... -
Make sure the
~/FsrTerminalgot the755permission withsudo chmod 755 ~/FsrTerminal -
Sometimes you also have to change the
ExecStartof thefsr-terminal.servicefile directive so that you use an absolute path forflutter-pi -
Debug the serive by uncommenting the last line of the
[Service]section in the/etc/systemd/system/fsr-terminal.servicefile and start the service withsystemctl start fsr-terminal(if it's somehow already/still running kill it withsystemctl stop fsr-terminal) -
Verifying the corectness of the config file with
sudo systemd-analyze verify /etc/systemd/system/fsr-terminal.service

