Gentoo on a PinePhone making it a usable phone en

By stealthgun on Friday 26 March 2021 10:30 - Comments (4)
Category: Algemeen, Views: 3.471

This is part two of the Gentoo on a PinePhone blog.

In part one you installed the base system and getting it bootable, this blog we are going into making it a usable phone.


Phosh
Phosh can be installed using:
code:
1
emerge --ask gui-wm/phosh-meta


Now start and enabled phosh and other services
code:
1
2
3
4
5
systemctl --now enable seatd
systemctl --now enable phosh
systemctl --now enable eg25-manager
systemctl --now enable NetworkManager #if not done before
systemctl --now enable ModemManager


What is missing now is a onscreen keyboard.
I am using x11-misc/squeekboard but you can choose your own.

To install squeekboard just run
code:
1
emerge --ask x11-misc/squeekboard


I have found some trouble intalling squeekboard so I've just build it myself.
First you need the emoticons package

code:
1
emerge --ask media-fonts/noto-emoji


Then pull the git repo and compile the source.
code:
1
2
3
4
5
6
7
$ git clone https://source.puri.sm/Librem5/squeekboard.git
$ cd squeekboard
$ mkdir _build
$ meson _build/ --prefix=/usr/
$ cd _build
$ ninja
$ ninja install


To make sure it shows up enable gnome onscreen keyboard
code:
1
gsettings set org.gnome.desktop.a11y.applications screen-keyboard-enabled true


afterwards make sure its configured for phosh.

Add the keyboard layout to the user (https://source.puri.sm/Li...ree/master/data/keyboards)

for the US version
code:
1
2
3
cd $HOME/.local/share/squeekboard/keyboards #create if its not there yet
wget https://source.puri.sm/Librem5/squeekboard/-/raw/master/data/keyboards/us.yaml
wget https://source.puri.sm/mozzwald/squeekboard/-/raw/c1737c763f295e2a71f574d3d436ec7899adf9f1/data/keyboards/terminal.yaml


code:
1
nano -w /etc/xdg/autostart/sm.puri.Squeekboard.desktop


code:
1
2
3
4
5
6
7
8
9
[Desktop Entry]
Name=Squeekboard
GenericName=Squeekboard Virtual Keyboard
Comment=Virtual Keyboard
Exec=/usr/bin/squeekboard
Terminal=false
Type=Application
NoDisplay=true
Categories=GTK;Utility;


Phone apps
There are some pinephone applications that now needs installing you can just run:
code:
1
emerge --ask app-mobilephone/pinephone


Ive installed these extra applications to make it more usable
code:
1
 emerge --ask media-sound/lollypop mail-client/geary media-plugins/gst-plugins-x264


Browser
Finding a good browser is crusial for a workable (smart)phone. There are two good options beside the default gnome webbrowser. You can try and compile Firefox or Chromium but they are very hefty compilations even with distcc on. I'm still trying to find a way to compile firefox without an error.

In the mean time I did find a good solution, a binary version of Chromium for arm64. It's part of the stha09 overlay, but I've also included it in my own overlay.

So what you can now do is simply run
code:
1
emerge --ask www-client/chromium-bin


This installs the binary version of Chromium, from what I can tell this is still a very fast browser but without a very hefty compile time.

For Firefox a working compile I did was using the following

code:
1
nano -w /etc/portage/package.use/firefox


code:
1
www-client/firefox -clang hwaccel openh264 -screencast system-av1 system-harfbuzz system-icu system-jpeg system-libevent system-libvpx system-web


Flatpak
Some applications are not really available so im using flatpak for those applications then you can install applications from flathub aswell.

code:
1
emerge --ask sys-apps/flatpak


then run
code:
1
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo


XMPP Client (Dino)
I myself use XMPP for some people so I can work around Facebook.
My prefered Linux client is Dino, wich at this moment is not native phone ready but there is a branch that is. So we need to build it ourself.

You can just download the zip file for the branch and then build it

code:
1
2
3
4
5
6
7
8
pinephone /var/tmp # emerge --ask media-gfx/qrencode net-libs/libsignal-protocol-c
pinephone /var/tmp # wget https://github.com/dino/dino/archive/refs/heads/feature/handy.zip
pinephone /var/tmp # unzip handy.zip 
pinephone /var/tmp # cd dino-feature-handy/
pinephone /var/tmp # ln -s /usr/bin/valac-0.48 /usr/bin/valac
pinephone /var/tmp/dino-feature-handy # ./configure --prefix=/usr/
pinephone /var/tmp/dino-feature-handy # make
pinephone /var/tmp/dino-feature-handy # make install


Anbox
In order to make the phone Daily useable alot of users will need andriod apps. We can use anbox for this but its not natively avalible for Gentoo so we need to build this ourself.

My experience is that anbox is very unstable, craches alot and apps dont always start. Its better to find alternative applications for the android apps then use anbox at the moment. But to give it a try I've included it in this blog.

If you followed part one you should have networkmanager installed, we can add the anbox network using that:
code:
1
nmcli con add type bridge ifname anbox0 -- connection.id anbox-net ipv4.method shared ipv4.addresses 10.0.2.1/24


Edit two files to make sure lxc will work correctly
code:
1
nano -w /etc/portage/env/remove-newsuidmap


code:
1
EXTRA_ECONF="--enable-subordinate-ids=no"


code:
1
nano -w /etc/portage/package.env/sys-apps_shadow-remove-newsuidmap


code:
1
sys-apps/shadow remove-newsuidmap


Then run
code:
1
emerge -1 sys-apps/shadow


Afterwards install the following depencies
code:
1
emerge --ask media-libs/sdl2-image app-emulation/lxc dev-libs/properties-cpp media-libs/glm dev-util/android-tools


Now download and build anbox

code:
1
2
3
4
5
6
7
$ git clone https://github.com/anbox/anbox.git --recurse-submodules
$ cd anbox
$ mkdir build
$ cd build
$ cmake .. -DENABLE_WAYLAND="$(usex wayland)"
$ make
$ make install


I found that with GCC 10+ the tests break so what you can do is after step 2 is do
code:
1
nano -w CMakeLists.txt


And then Comment line 141

code:
1
#add_subdirectory(tests)


Everythings once agian installs in /usr/local you can just move it to /usr yourself.

After you build anbox you need an android image and the startup scripts.

Download the image to /var/lib/anbox
code:
1
wget http://alexmitter.org/downloads/anbox/anbox_image_builder_image/android.img


Under dev create the binderfs directory
code:
1
2
3
pinephone / # cd /dev/
pinephone /dev # mkdir binderfs
pinephone /dev # mount -t binder none /dev/binderfs


You can add the followig to your fstab
code:
1
none                         /dev/binderfs binder   nofail  0      0


Next we need to create the services
code:
1
nano -w /lib/systemd/system/anbox-container-manager.service


code:
1
2
3
4
5
6
7
8
9
[Unit]
Description=Anbox Container Manager
Documentation=man:anbox(1)

[Service]
ExecStart=/usr/bin/anbox container-manager --daemon --data-path=/var/lib/anbox --container-network-gateway=10.0.2.1

[Install]
WantedBy=multi-user.target


Start and enable the service
code:
1
2
3
systemctl --now enable dnsmasq
systemctl --now enable lxc
systemctl --now enable anbox-container-manager


Create a second service
code:
1
nano -w /etc/systemd/user/anbox-session-manager.service


code:
1
2
3
4
5
6
7
8
9
10
11
12
13
[Unit]
Description=Anbox Session Manager
Documentation=man:anbox(1)
After=basic.target
Wants=basic.target

[Service]
ExecStart=/usr/bin/anbox session-manager --gles-driver=host
Restart=on-failure
RestartSec=5s

[Install]
WantedBy=graphical-session.target


and enable this service for the user
code:
1
systemctl --user enable --now anbox-session-manager.service

Gentoo on a PinePhone en

By stealthgun on Friday 26 February 2021 20:30 - Comments (1)
Category: Algemeen, Views: 6.398

I've been looking at the PinePhone for a long time and this year I decided to get one msyelf.
The one that I ordered is the PinePhone KDE version with the Convergence package. So I have 32gb eccm and 3gb Ram.

The thing is knew allready is that the OS it came wiith i would not see boot. Because my Linux distro of choice is Gentoo. With the low specs of a phone I am also very intressted in what I can get out of a phone with Gentoo Linux.

Where to Begin
So first l've looked at allready availible documentation and I found some.
Gentoo Pinephone wiki entry 1
Gentoo Pinephone wiki entry 2

Both where good starting points but are both missing abit of information, so hence this blog post.

So for the disk I am gonna do the following:
eccm:
128mb of nothing (needs to be a linux partition)
5Gb is swap (to make sure the system thinks we always have enough RAM)
~26GB of / (ext4) (Just the rest of the left space)

SDcard
180 gb of /home (ext4)
72 gb of /var (ext4)

You can follow juist the normal prepare disks from the gentoo installation.

/var is a large directory same goes for /home so thats why I want to have those two on a SDcard wich should save enough space for the rest of the OS installation. On the eccm disk since for my own Linux Desktop PC excluding those two directories the system uses 18gb space.

Due to some software for the pinephone beeing non open-rc compatible I have to use systemd, I do not like this choice but without systemd your system is gonna be less usable as a phone.

So eventough I do not like systemd I do think its the best option for the installation so use the systemd arm64 stage3 for your installation.

I am using postmarketOS from a sdcard to boot and from there just follow the amd64 handbook to create the system and chroot into it.

nano is not installed by default so if you want to use it you can just do apk add nano.

Build the system
Since the phone itself is quite weak you can use distcc to speed it all up if you want I am not going into the distcc settings and options in this blog.

The make.conf I am using is:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# These settings were set by the catalyst build script that automatically
# built this stage.
# Please consult /usr/share/portage/config/make.conf.example for a more
# detailed example.
CHOST="aarch64-unknown-linux-gnu"
COMMON_FLAGS="-march=armv8-a+crypto+crc -mtune=cortex-a53 -O2 -pipe -fomit-frame-pointer -ftree-vectorize"
CFLAGFS="${COMMON_FLAGS}"
CXXFLAGS="${COMMON_FLAGS}"
FCFLAGS="${COMMON_FLAGS}"
FFLAGS="${COMMON_FLAGS}"
MAKEOPTS="-j5"

# NOTE: This stage was built with the bindist Use flag enabled
PORTDIR="/var/db/repos/gentoo"
DISTDIR="/var/cache/distfiles"
PKGDIR="/var/cache/binpkgs"

# This sets the language of build output to English.
# Please keep this setting intact when reporting bugs.
LC_MESSAGES=C

#Use flags
USE="wayland phosh gles2 p-boot eg25-manager pinephone chromium samba truetype alsa elogind bluetooth cups ipv6 omemo pulseaudio dhcpcd systemd networkmanager -opengl egl wifi mobile"

#Needed for the video drivers
VIDEO_CARDS="lima"

#Gentoo Mirror
GENTOO_MIRRORS="https://ftp.snt.utwente.nl/pub/os/linux/gentoo"


Ive added the following file aswell
code:
1
nano -w /mnt/gentoo/etc/portage/package.use/pinephone


code:
1
/etc/portage/package.use/pinephone

content
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
sys-apps/systemd cryptsetup homed
media-libs/mesa -llvm
>=x11-libs/libdrm-2.4.102 libkms
net-misc/networkmanager connection-sharing
media-libs/libsdl2 gles2 -tslib
media-libs/libvpx postproc
sys-libs/zlib minizip
media-fonts/dejavu -X
media-video/vlc -X opus
media-tv/v4l-utils -bpf -qt5
media-video/ffmpeg vaapi
sci-geosciences/gpsd -X -qt5 python
>=media-plugins/grilo-plugins-0.3.12 flickr
>=sys-libs/zlib-1.2.11-r3 static-libs
media-libs/libsdl2 kms tslib
>=media-video/ffmpeg-4.3.1 opus
x11-libs/tslib -sdl
net-wireless/bluez user-session
x11-libs/cairo gles2-only
net-libs/webkit-gtk gles2-only
>=dev-lang/python-3.9.2 -bluetooth -sqlite


And unmask some packages at the moment since Gnome 40 is beeing tested on.

code:
1
nano -w /etc/portage/package.unmask


code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
gui-libs/gtk
gnome-base/gnome-shell
gnome-extra/gnome-shell-extensions
x11-wm/mutter
x11-libs/pango
dev-cpp/pangomm
dev-libs/vala-common
dev-lang/vala
gnome-base/nautilus
app-misc/tracker
app-misc/tracker-miners
gnome-base/gnome-settings-daemon
gnome-extra/gnome-calendar
media-sound/gnome-music


As always with gentoo change the USE flags as you see fit, this is what I want for my system.
The reason why -march is not native, is the fact that for distcc you need to specify the flags.

The VIDEO_CARDS needs to be set to "lima" and its important to set the use flags"gles2" since else the video-card might not work optimal because this way you force the emedded opengl settings.

Now to be sure lets set the accept_keywords (I dont want everything on unstable):
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#Gnome
gnome-extra/chrome-gnome-shell ~arm64
mail-client/geary ~arm64
net-im/chatty ~arm64
x11-misc/squeekboard ~arm64
net-dns/dnsmasq ~arm64
media-video/megapixels ~arm64
media-libs/hdr-plus ~arm64
media-sound/lollypop ~arm64
x11-themes/sound-theme-librem5 ~arm64
media-sound/gnome-music ~arm64
gui-libs/libhandy ~arm64
dev-libs/feedbackd ~arm64
gnome-extra/evolution-data-server ~arm64
mail-client/evolution ~arm64
sci-geosciences/gnome-maps ~arm64
gnome-extra/iio-sensor-proxy ~arm64
app-editors/gedit ~arm64
gnome-base/gnome-control-center ~arm64
gnome-extra/gnome-contacts ~arm64
gnome-extra/gnome-calculator ~arm64
gnome-extra/gnome-calendar ~arm64
gnome-extra/gnome-clocks ~arm64
gnome-base/gnome-keyring ~arm64
gnome-base/gnome-desktop ~arm64
gnome-base/gnome-session ~arm64
gnome-base/gsettings-desktop-schemas ~arm64
gnome-base/nautilus ~arm64
media-video/totem ~arm64
app-dicts/gnome-dictionary ~arm64
gnome-extra/gnome-power-manager ~arm64
gnome-extra/sushi ~arm64
net-libs/gnome-online-accounts ~arm64
net-libs/webkit-gtk ~arm64
x11-themes/adwaita-icon-theme ~arm64
x11-themes/gnome-backgrounds ~arm64
www-client/epiphany ~arm64
x11-terms/gnome-terminal ~arm64
app-text/evince ~arm64
x11-libs/vte ~arm64
gnome-base/gnome-shell ~arm64
app-misc/tracker ~arm64
dev-libs/libportal ~arm64
app-misc/tracker-miners ~arm64
dev-libs/gjs ~arm64
gui-libs/gtk ~arm64
x11-libs/gtk+ ~arm64
x11-wm/mutter ~arm64
net-wireless/gnome-bluetooth ~arm64
net-libs/libnma ~arm64
dev-libs/libgweather ~arm64
gnome-base/gnome-settings-daemon ~arm64
gnome-extra/gnome-system-monitor ~arm64
gnome-base/gdm ~arm64
app-misc/jq ~arm64
sci-geosciences/geocode-glib ~arm64
x11-misc/colord ~arm64
dev-libs/glib ~arm64
gnome-extra/zenity ~arm64
dev-util/sysprof ~arm64
dev-util/sysprof-capture ~arm64
dev-util/sysprof-common ~arm64
dev-libs/libdazzle ~arm64
7media-libs/hdr-plus ~arm64
media-gfx/zbar ~arm64
dev-libs/folks ~arm64
media-libs/gsound ~arm64
gnome-extra/gnome-color-manager ~arm64
gnome-base/libgnomekbd ~arm64
gnome-extra/nm-applet ~arm64
dev-libs/libpeas ~arm64
gui-libs/tepl ~arm64
gui-libs/amtk ~arm64
dev-libs/olm ~arm64
dev-libs/gom ~arm64
net-misc/modemmanager ~arm64
net-libs/libqmi ~arm64
media-sound/callaudiod ~arm64
dev-util/wayland-scanner ~arm64
x11-themes/gnome-backgrounds ~arm64
x11-libs/pango ~arm64
gnome-base/gnome-desktop ~arm64
sci-geosciences/gnome-maps ~arm64
gnome-extra/evolution-ews ~arm64
gnome-extra/portfolio ~arm64
gnome-extra/gnome-weather ~arm64
sci-geosciences/gnome-maps ~arm64
media-libs/libchamplain ~arm64
net-libs/libgfbgraph ~arm64

#Phosh
dev-embedded/imx-usb-loader ~arm64
dev-embedded/jlink ~arm64
dev-embedded/mfgtool ~arm64
dev-embedded/mkbootimg ~arm64
gui-wm/phosh ~arm64
gui-wm/phosh-meta ~arm64
x11-wm/phoc ~arm64
gnome-extra/postmarketos-tweaks ~arm64

#Webclients
www-client/chromium ~arm64
www-client/microsoft-edge-dev ~arm64
www-client/firefox ~arm64
www-client/chromium-bin ~arm64

#Phone things
app-mobilephone/flashlight ~arm64
app-mobilephone/mobile-config-firefox ~arm64
app-mobilephone/pinephone-modem-scripts ~arm64
app-mobilephone/pinephone-softsleep ~arm64
app-mobilephone/pinephone ~arm64
app-mobilephone/usb-tethering ~arm64
net-voip/calls ~arm64
x11-plugins/purple-mm-sms ~arm64
net-misc/ofono ~arm64
net-misc/ofonoctl ~arm64
net-misc/eg25-manager ~arm64
net-dialup/atinout ~arm64
dev-libs/libphonenumber ~arm64
sys-firmware/anx7688-firmware ~arm64
sys-firmware/ov5640-firmware ~arm64
sys-firmware/rtl8723bt-firmware ~arm64

#Other
virtual/libgudev ~arm64
sys-power/gtherm ~arm64
sys-kernel/pinephone-sources ~arm64
sys-kernel/gentoo-sources ~arm64
media-libs/alsa-ucm-pinephone ~arm64
media-sound/wys ~arm64
net-vpn/networkmanager-openvpn ~arm64
app-office/LibreOffice ~arm64
app-misc/neofetch ~arm64
media-libs/mesa ~arm64
net-misc/owncloud-client ~arm64
app-emulation/snapd ~arm64
sys-boot/osk-sdl ~arm64
sci-geosciences/gpsd ~arm64
dev-libs/wayland ~arm64
dev-util/gdbus-codegen ~arm64
app-emulation/lxc ~arm64
dev-libs/properties-cpp ~arm64
dev-util/android-tools ~arm64
dev-libs/libwacom ~arm64
dev-libs/gobject-introspection ~arm64
dev-libs/gobject-introspection-common ~arm64
media-plugins/grilo-plugins ~arm64
app-text/asciidoc ~arm64
net-libs/libqmi ~arm64
media-libs/gstreamer ~arm64
dev-util/gdbus-codegen ~arm64
dev-libs/glib ~arm64
dev-python/nautilus-python ~arm64
dev-lang/vala ~arm64
dev-libs/vala-common ~arm64
dev-util/ninja ~arm64
sys-apps/systemd ~arm64
sys-kernel/linux-headers ~arm64
net-misc/networkmanager ~arm64
net-misc/modemmanager ~arm64
net-misc/dhcpcd ~arm64
app-accessibility/at-spi2-core ~arm64
dev-python/pylast ~arm64
media-plugins/gst-plugins-taglib ~arm64

#Geary
dev-lang/vala ~arm64
dev-libs/vala-common ~arm64
net-mail/ytnef ~arm64
dev-perl/MIME-tools ~arm64
sys-libs/glibc ~arm64
app-text/nuspell ~arm64
net-libs/libvoikko ~arm64
dev-libs/glib ~arm64

#Neofetch
www-client/w3m ~arm64
x11-apps/xrandr ~arm64
x11-apps/xwininfo ~arm64

#Anbox
net-proxy/squid ~arm64


The first emerge I am doing is (after the initial sync):
code:
1
emerge --ask app-eselect/eselect-repository dev-vcs/git app-admin/sudo


Now I can add the extra repo my own repo GJDWebserver:
code:
1
eselect repository add gjdwebserver git https://github.com/stealthgun/gjdwebserver-overlay.git


Now sync again and we can select a profile, keep in mind that we are selection a systemd profile:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
pine64-pinephone / # eselect profile list
Available profile symlink targets:
  [1]   default/linux/arm64/17.0 (stable)
  [2]   default/linux/arm64/17.0/desktop (stable)
  [3]   default/linux/arm64/17.0/desktop/gnome (stable)
  [4]   default/linux/arm64/17.0/desktop/gnome/systemd (stable)
  [5]   default/linux/arm64/17.0/desktop/plasma (stable)
  [6]   default/linux/arm64/17.0/desktop/plasma/systemd (stable)
  [7]   default/linux/arm64/17.0/desktop/systemd (stable)
  [8]   default/linux/arm64/17.0/developer (stable)
  [9]   default/linux/arm64/17.0/systemd (stable) *
  [10]  default/linux/arm64/17.0/big-endian (exp)
  [11]  default/linux/arm64/17.0/musl (exp)
  [12]  default/linux/arm64/17.0/musl/hardened (exp)
pine64-pinephone / # eselect profile set 4


After doing this you can emerge @world and after that the tools you want to use this is gonna take some time.

The emerge I did was:
code:
1
emerge --ask app-admin/syslog-ng sys-process/cronie sys-kernel/pinephone-sources net-misc/dhcpcd net-wireless/iw net-wireless/wpa_supplicant sys-apps/mlocate net-misc/openssh


Building the kernel
Since we a system with packages its time to build the kernel.

code:
1
2
3
4
5
6
7
8
9
10
11
12
pine64-pinephone / # emerge -ask pinephone-sources (if not done before)
pine64-pinephone / # eselect kernel list
Available kernel symlink targets:
  [1]   linux-5.11.0-r1 *
pine64-pinephone / # cd /usr/src/linux
pine64-pinephone / # make pinephone_defconfig
pine64-pinephone / # make Image dtbs modules
pine64-pinephone / # cp ./arch/arm64/boot/Image /boot/vmlinuz-5.11.0-r1-pinephone-arm64
pine64-pinephone / # cp ./arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone*.dtb /boot
pine64-pinephone / # make modules_install
pine64-pinephone / # make firmware_install
pine64-pinephone / # make headers_install INSTALL_HDR_PATH=/usr


If you want to use anbox add the following to the .config after make pinephone_defconfig
code:
1
2
3
4
5
6
7
8
9
10
CONFIG_ANDROID=y
CONFIG_ANDROID_BINDER_IPC=m
CONFIG_ANDROID_BINDERFS=y
CONFIG_ANDROID_BINDER_DEVICES="binder,hwbinder,vndbinder"
CONFIG_MACVLAN=y
CONFIG_BRIDGE=y
CONFIG_TUN=y
CONFIG_USER_NS=y
CONFIG_UTS_NS=y
CONFIG_VETH=y


This aswell is gonna take some times, so take a coffee break.

Bootloader
If you have the kernel done its time to create the bootloader

You can follow the p-boot README to install p-boot binary and other files into pinephone's /boot folder.

You can clone to git repo into /tmp using
code:
1
pine64-pinephone /tmp # git clone https://megous.com/git/p-boot



And if you dont want to build it all just copy everything in dist/ to boot
code:
1
2
3
4
pine64-pinephone /tmp/p-boot # cd dist/
pine64-pinephone /tmp/p-boot/dist # ls
fw-debug.bin  fw.bin  p-boot-conf  p-boot-conf-native  p-boot-serial.bin  p-boot.bin
pine64-pinephone /tmp/p-boot/dist # cp * /boot/


What is missing at this point is an initramfs we can build that using dracut
code:
1
emerge --ask sys-kernel/dracut


The config /etc/dracut.conf should look like this
code:
1
2
3
4
5
6
7
8
9
# PUT YOUR CONFIG IN separate files
# in /etc/dracut.conf.d named "<name>.conf"
# SEE man dracut.conf(5) for options

# Equivalent to -H
hostonly="yes"

# Choose compression program for the image
compress="lz4"


Create and edit the file /etc/dracut.conf.d/dracut-pp.conf
code:
1
nano -w /etc/dracut.conf.d/dracut-pp.conf


code:
1
2
3
4
5
6
7
8
9
10
# load kernel modules that's needed to run accelarated osk SDL
force_drivers+=" lima gpu_sched goodix evdev sun6i_mipi_dsi sun8i-drm-hdmi sun8i-mixer panel-sitronix-st7703 "
# pmic
force_drivers+=" axp20x-pek axp20x_adc "
# force feedback
force_drivers+=" gpio-vibra "
# encryption module
force_drivers+=" crc-t10dif "
# emmc/sd driver
force_drivers+=" sunxi-mmc "


Then in /boot run
code:
1
pine64-pinephone /boot # dracut -m "rootfs-block base" --host-only --kver 5.11.0


Your boot directory should now look something like this
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
pine64-pinephone /boot # ls -l
total 24284
-rw-r--r-- 1 root root      342 Feb 26 16:58 boot.conf
drwxr-xr-x 2 root root     4096 Feb 26 16:58 files
-rw-r--r-- 1 root root    59496 Feb 26 16:38 fw-debug.bin
-rw-r--r-- 1 root root    59496 Feb 26 16:38 fw.bin
-rw------- 1 root root 10551208 Feb 26 17:18 initramfs-5.11.0.img
drwx------ 2 root root     4096 Feb 26 16:32 lost+found
-rwxr-xr-x 1 root root    50512 Feb 26 16:38 p-boot-conf
-rwxr-xr-x 1 root root    44520 Feb 26 16:38 p-boot-conf-native
-rw-r--r-- 1 root root    27136 Feb 26 16:38 p-boot-serial.bin
-rw-r--r-- 1 root root    32768 Feb 26 16:38 p-boot.bin
-rw-r--r-- 1 root root    38825 Feb 26 16:18 sun50i-a64-pinephone-1.0.dtb
-rw-r--r-- 1 root root    39040 Feb 26 16:18 sun50i-a64-pinephone-1.1.dtb
-rw-r--r-- 1 root root    39027 Feb 26 16:18 sun50i-a64-pinephone-1.2.dtb
-rw-r--r-- 1 root root 14063624 Feb 26 16:18 vmlinuz-5.11.0-r1-pinephone-arm64


You need the first partition of the boot media formatted as linux (83) partition, with enough space for kernel and other files.

Now write the p-boot.bin to boot media
code:
1
$ sudo dd if=p-boot.bin of=/dev/mmcblk2 bs=1024 seek=8


The boot config should look something like this

code:
1
2
3
4
5
6
7
8
9
10
$ cat /boot/boot.conf
device_id = pp3 (PP 1.2a)
no          = 0
  name      = Gentoo 5.11.0 (EMMC)
  atf       = fw.bin
  dtb       = sun50i-a64-pinephone-1.2.dtb
  linux     = vmlinuz-5.11.0-r1-pinephone-arm64
  initramfs = initramfs-5.11.0.img
  bootargs  = console=tty1 console=ttyS0,115200 root=/dev/mmcblk2p3 rootfstype=ext4 rw rootwait quiet
  splash    = files/pboot2.argb


The command to write boot kernel and other files to boot partition

code:
1
2
$ cd /boot
$ ./p-boot-conf . /dev/mmcblk2p1


Before rebooting make sure you run
code:
1
emerge --ask sys-firmware/anx7688-firmware sys-firmware/ov5640-firmware sys-firmware/rtl8723bt-firmware


In order to get the correct firmware for the kernel

After your initial boot into the system you need to do
code:
1
2
3
4
root #hostnamectl set-hostname pinephone
root #localectl set-keymap us # or whatever your keyboard is
root #timedatectl set-timezone Europe/Amsterdam # or wathever your time-zone is
root #timedatectl set-ntp true


To use the phone/simcard without a password add your user to the "plugdev" group

Dont forget to add everything needed to automaticly start after booting.

Finalizing
After this and following just the normal Gentoo setup steps (if not done earlier) like your network config, locale, time and timezone settings you can boot into the system. You can just follow the handbook for this since its a generic setup and not arm64 or pinephone specific.

In part two we are going into making it a usable phone with phosh and anbox.

I will create more blogs about using the pinephone for real using Gentoo.
So I hope this blog is helpfull for you into considering Gentoo for your Linux Phone.

Update
I've been working on Phosh now and I have updated the accept_keywords list in the blog and my own overlay to get it all working. My phone is now running the emerge for it. A thing to keep in mind is that rust is getting pulled with it so its gonna be a hefty emerge on the phone itself.

Update 2
Added anbox steps into the blog for if you want to use anbox on the pinephone

Word of Warcraft Private Server (MariaDB naar Oracle APEX Ontwikkelen)

Door stealthgun op dinsdag 26 mei 2020 16:00 - Reacties (11)
Categorie: Algemeen, Views: 3.648

Vanwege de Corona maatregelen heb ik de laatste tijd thuis wat meer tijd over. Dus het was weer eens tijd voor een uitzoek projectje.

Ik heb al wel vaker op Private Servers van World of Warcraft gespeeld, het is een grijs gebied. Maar dacht waarom het niet zelf eens proberen op te zetten. Dat is de Shattered Sun Sever geworden.

Ik kwam uit op de CMaNGOS core, wat je nodig hebt is een Server een database en je bent klaar. Alleen nu is het jammere dat mijn "hoofd" database een Oracle 18c (XE) database is.


Dus hoe verenig je dat? De CManNGOS database staat dus nu in een MariaDB database op mijn (Gentoo) Linux server. Maar mijn website(s) draaien op Oracle APEX. Een van deze websites is dus nu ook de website van de WoW server: https://tbc.gjdwebserver.nl.

Zelf vind ik Oracle heel fijn, dit omdat het mijn werk is maar ook omdat je vrijwel alles kan doen vanuit een Oracle database. Alle mails die verstuurd worden vanuit de website komen van de Oracle Database via de "utl_smtp" procedure. Hierdoor is het mogelijk om een procedure te maken die de email verstuurd.

code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
create or replace PROCEDURE PROC_SEND_MAIL (v_to varchar2, v_from varchar2, v_subject varchar2, v_body varchar2) AS 

smtp_conn utl_smtp.connection;

BEGIN
smtp_conn := utl_smtp.open_connection('smtp.example.com', 25); -- SMTP on port 25 
utl_smtp.helo(smtp_conn, 'smtp.example.com');
utl_smtp.mail(smtp_conn, v_from);
utl_smtp.rcpt(smtp_conn, v_to);

utl_smtp.data(smtp_conn,
'From: From Name <'||v_from||'>' || utl_tcp.crlf ||
'To: ' || v_to || utl_tcp.crlf ||
'Subject: ' ||v_subject||utl_tcp.crlf||
'MIME-Version: 1.0'||utl_tcp.crlf||
'Content-type:text/html;charset=iso-8859-1'||utl_tcp.crlf||
utl_tcp.crlf || v_body);

utl_smtp.quit(smtp_conn);

END PROC_SEND_MAIL;


Maar hoe krijg je nou de MariaDB informatie in je Oracle Database? Het antwoord is een database link aanmaken. Wat je hiervoor als eerste nodig hebt is een ODBC koppeling naar je MariaDB database.

Daarna moet je wat aanpassingen doen in je Oracle installatie namelijk wat config bestanden aanpassen zodat je de ODBC koppeling kan gebruiken. Een goede uitleg daarover kan je hier vinden.

Als je de koppeling werkend hebt kan je hele leuke dingen doen, want je kan namelijk de Logica vanuit je Oracle database gebruiken om data te manipuleren of uit de MariaDB database te halen. Een voorbeeld hiervan zijn ingame tickets, deze zet ik om in een zelf gemaakt ticket systeem in de Oracle Database met Oracle APEX als frontend.

Ik heb een view aangemaakt die de benodigede gegevens laad vanuit de MariaDB database, dit omdat je vanuit een Procdure (of functie) niet direct de DBLINK kan aanroepen.

code:
1
2
  CREATE OR REPLACE FORCE EDITIONABLE VIEW "TBC"."VIEW_INGAME_TICKETS_FIXED" ("id", "category", "state", "status", "level", "author_guid", "author_name", "locale", "mapid", "x", "y", "z", "o", "TEXT", "created", "updated", "seen", "answered", "closed", "assignee_guid", "assignee_name", "conclusion", "notes") DEFAULT COLLATION "USING_NLS_COMP"  AS 
  select "id","category","state","status","level","author_guid","author_name","locale","mapid","x","y","z","o","TEXT","created","updated","seen","answered","closed","assignee_guid","assignee_name","conclusion","notes" from VIEW_INGAME_TICKETS_FIXED@DBLINK_TBCCHARACTERS;


Hier na kan je de data dus opslaan en manipuleren zoals ik in deze procedure doe.

code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
create or replace PROCEDURE PROC_MIGRATE_TICKETS AS 
v_id number;
v_charid number;
v_ticketid number;
v_accountid number;

v_date number;

v_username varchar2(32767);
v_email varchar2(32767);

v_from varchar2(32000);
v_text varchar2(32000);
v_subject varchar2(32000);
v_text_temp1 varchar2(32000);
v_text_temp2 varchar2(32000);

--Get the open tickets into the cursor with their ID's
CURSOR c_opentickets IS 
        SELECT "id","author_guid" FROM VIEW_INGAME_TICKETS_FIXED WHERE "state" = 0 AND "closed" = 0;

BEGIN
    --INSERT THE TICKETS INTO THE SYSTEM
    INSERT INTO TBL_WEB_TICKETS (INGAMETID,USERMADE,TITLE,"DESCRIPTION",STATUS,ISSUETYPE) SELECT "id",FUNCTION_FIND_ACCOUNTID_FROM_CHARID("author_guid"),'Ingame ticket',TEXT,'New','Ticket' FROM VIEW_INGAME_TICKETS_FIXED WHERE "state" = 0 AND "closed" = 0;
    COMMIT;
    
    --Loop trough the cursor and see         
    OPEN c_opentickets;
    LOOP
    FETCH c_opentickets INTO v_id,v_charid;
    EXIT WHEN c_opentickets%notfound; 
    
    SELECT TID INTO v_ticketid FROM TBL_WEB_TICKETS WHERE INGAMETID = v_id;
    v_accountid := FUNCTION_FIND_ACCOUNTID_FROM_CHARID(v_charid);
    
    --Get the email from the databse
    SELECT "email" INTO v_email FROM VIEW_ACCOUNT WHERE "id" = v_accountid;
    SELECT "username" INTO v_username FROM VIEW_ACCOUNT WHERE "id" = v_accountid;
    
    --Send a mail to the ingame character with the web ticket id
     
    SELECT EMAILFROM INTO v_from FROM TBL_WEB_EMAILS WHERE EID = 2;
    SELECT EMAILHEADER INTO v_subject FROM TBL_WEB_EMAILS WHERE EID = 2;
    SELECT EMAILTEXT INTO v_text_temp1 FROM TBL_WEB_EMAILS WHERE EID = 2;
        
    v_text_temp2 := regexp_replace(v_text_temp1, '<<username>>', v_username);
    v_text := regexp_replace(v_text_temp2, '<<ticketid>>', v_ticketid);
        
    PROC_SEND_MAIL(v_email, v_from, v_subject, v_text);
                
    END LOOP;    
    CLOSE c_opentickets;    
    
    v_date := ROUND((SYSDATE - DATE '1970-01-01' ) * 86400);
    
    --Update the MySQL database so the tickets are now closed ingame
    UPDATE VIEW_INGAME_TICKETS SET "state" = 1, "closed" = v_date WHERE "state" = 0 AND "closed" = 0;
    COMMIT;
END PROC_MIGRATE_TICKETS;


De mogelijkheden zijn nu eindeloos. Kijken hoeveel spelers online zijn en dit op de website plaatsen? Maak een view aan en het werkt.

code:
1
2
3
4
5
6
7
8
  CREATE OR REPLACE FORCE EDITIONABLE VIEW "TBC"."VIEW_PLAYER_ONLINE_COUNT" ("REALMID", "PLAYERCOUNT", "PLAYERCOUNTALLIANCE", "PLAYERCOUNTHORDE") DEFAULT COLLATION "USING_NLS_COMP"  AS 
  SELECT RL."id" AS REALMID, count(CASE WHEN CH."online" = 1 THEN 1 END) AS PLAYERCOUNT, count(CASE WHEN CH."online" = 1 AND CH."race" IN (1,2,3,4,11) THEN 1 END) AS PLAYERCOUNTALLIANCE, count(CASE WHEN CH."online" = 1 AND CH."race" IN (5,6,7,8,9,10) THEN 1 END) AS PLAYERCOUNTHORDE
FROM "realmlist"@DBLINK_TBCREALMD RL
, "account"@DBLINK_TBCREALMD AC
, "characters"@DBLINK_TBCCHARACTERS CH
WHERE AC."active_realm_id"(+) =  RL."id"
AND AC."id" = CH."account"(+)
GROUP BY RL."id";


Mensen onderschatten wel eens wat de kracht is van een Database en leggen alles op het programmeren terwijl naar mijn idee je veel kan vanuit een goede database zonder dat je een regel code buiten de database hoeft te typen. Oracle APEX draait nu eenmaal ook in de database zelf, waardoor alle data die gebruikt wordt bijna niet over en weer hoeven te worden gestuurd.

Heb je intresse in de server of wil je meer informatie over hoe APEX of Oracle werkt? Je bent altijd welkom op de Discord Server: https://discord.com/invite/rASJru2

Dark Harvest: Grote update aan het spel

Door stealthgun op vrijdag 27 september 2019 10:44 - Reacties (5)
Categorie: Algemeen, Views: 2.154

Het is even geleden dat ik hier voor het laatst een blog heb gemaakt, maar ik ben de laatste tijd erg druk geweest met het optimalizeren van mijn spel Dark Harvest. Ik heb veel (nuttige) feedback gekregen waarmee ik aan de slag ben gegaan.

Het hele spel is nog eens grondig nagelopen op bugs, ik heb veel dingen waardoor het spel extra houterig overkwam aangepast of geopmitmaliseerd en er zijn veel nieuwe features bij gekomen.


De complete Changelog

De itch.io devblog.

Download het spel

Character overview
Een van de nieuwe features is de character overview, dit miste nog in het spel.

https://img.itch.zone/aW1nLzI1MTY0MTgucG5n/original/AnKUAN.png

Je kan nu de skillpoints die je krijgt voor ieder nieuw level inzetten in een attribuut naar keuze, deze moet je ook inzetten omdat de vijanden iets sneller schalen dan jij levelt, dus de gehele progressie van het spel is er ook op ontwikkeld dat je je character sterker maakt met skillpoints.

offline modus
Het spel heeft nu ook een offline modus, dit zorgt ervoor dat je (mocht je dat niet willen) nooit een account hoeft te maken om het spel te kunnen spelen.

https://img.itch.zone/aW1nLzI0NDE1NTYucG5n/original/9Ubk2X.png
Offline modus kan je simpel weg activeren door bij het inlog scherm op 'Play Offline' te klikken.

In offline mode heb je alleen toegang tot de twee gratis heroes en je hebt geen toegang tot alle online features zoals chat, achievements en andere social features.

Je wordt niet gelimiteerd in de content verder, dus je kan het gehele spel spelen in offline modus.

Controller Support
Deze update brengt ook seamless controller suport. Dit komt er op neer dat je kan wisselen tussen een controller en toetsenbord/muis 'on the fly' het enige wat je hoeft te doen is de andere controller te gebruiken en de UI wisselt met je mee.

https://media.indiedb.com/cache/images/games/1/69/68738/thumb_620x2000/Seamless_Controls.gif

De muis
Tot deze versie was het niet standaard zo dat je de aangepaste muis cursor zag, door wat bugs kwam het vaak voor dat je de gewone windows muis cursor voor je had, dit had als gevolg dat het spel nogal 'goedkoop' overkwam, deze update heeft dit opgelost en je ziet nu (als het goed is) altijd de aangepaste muis.

De website
De website is ook flink onder handen genomen.
Deze was eerste gemaakt in PHP met een Microsft SQL database, maar is nu aangepast naar een Oracle Database met Oracle APEX. Dit heeft als voordeel dat de ontwikkel tijd voor mij drastich is afgenomen.

De website is nu ook op je mobiel beter leesbaar.

https://img.itch.zone/aW1nLzI0NjIwODQucG5n/original/dxjsHF.png

Je account data is ook uitgebreid op de website, zo kan je nu wat overzichten zien en je kan zien welke Heroes/Skins je in bezit hebt.

https://img.itch.zone/aW1nLzI1MTEwNDcucG5n/original/r8R5Mn.png

Wat Oracle APEX nu ook mogelijk maakt is het gebruik maken van Oracle RESTFull Data Services, dit is een zeer makelijke manier om (direct) vanuit een Oracle database REST API's te kunnen maken.

Deze REST API's worden op meerder plekken in het spel gebruikt onderandere voor het weergeven van de nieuws artikelen in het spel.

https://img.itch.zone/aW1nLzI0NjI4NjEucG5n/original/EPU8Wr.png

Dark Harvest is genomineerd, maar jij kan helpen om Dark Harvest de indie game van 2018 te maken!

Door stealthgun op dinsdag 11 december 2018 09:43 - Reacties (3)
Categorie: Algemeen, Views: 2.427

Het was al zo mooi en het wordt alleen maar mooier! Dark Harvest behoort al tot de top 100 van indie games. De gehele top 100 kan je hier vinden.

Dark Harvest is nu officieel genomineerd; maar ik heb jullie hulp nogmaals nodig om Dark Harvest nummer 1 te maken!

Jij kan helpen om Dark Harvest Indie game van 2018 te maken door te stemmen:

Het stemmen is iets veranderd, als je op vote now op de pagina drukt krijg je de top 100 te zien, als je daar Role Playing Games open klikt kan je Dark Harvest als eerste spel zien en hier kan je op "vote now" klikken.

https://www.darkharvestgame.com/images/newsletter/ioty.png

Ik dank jullie alvast voor het stemmen!