Jump to content

User:Ybon

From postmarketOS Wiki

Dumbphone user interested in running Linux on it

Owns Devices

Device Notes
Nokia 8110 4G (nokia-argon)


Installing PostmarketOS on Nokia 8110 4G

Resources

Install

Prepare the device

  • upgrade kaiOS to latest (v17.00.17.01)
  • turn on debugger mode (`*#*#33284#*#*`)
  • optionally temporary root (with Wallace) to make backups

Prepare work machine (arch linux)

Install packages arm-none-eabi-gcc dtc capstone python-capstone python-pyusb keystone python-keystone

EDL

 git clone https://github.com/msm8916-mainline/lk2nd.git
 cd lk2nd
 make TOOLCHAIN_PREFIX=arm-none-eabi- lk2nd-msm8909

This should output a path to a lk2nd.img file.

Test that the Qualcomm is already visible:

   lsusb | grep Qualcomm

Should output something like:

   Bus 001 Device 056: ID 05c6:9039 Qualcomm, Inc. Android

Then (edl from andybalholm, including this PR https://github.com/andybalholm/edl/pull/1):

   git clone -b Fix_device_busy_error_16 https://github.com/radio-van/edl
   adb reboot edl
   sudo python edl.py -loader ../8110.mbn -w boot ../lk2nd/build-lk2nd-msm8909/lk2nd.img -sectorsize 512 -memory eMMC

Output:

   Qualcomm Sahara / Firehose Client (c) B.Kerler 2018-2019.
   Using loader ../8110.mbn ...
   Waiting for the device
   Device detected :)
   Mode detected: Firehose
   TargetName=MSM8909
   MemoryName=eMMC
   Version=1
   Writing to physical partition 0, sector 270432, sectors 669
   Progress: |██████████████████████████████████████████████████| 100.0% Complete
   Wrote ../lk2nd/build-lk2nd-msm8909/lk2nd.img to sector 270432.

Now turning on the phone, I have:

pmboostrap

  • `pmbootstrap init` => using all the defaults, but `sxmo-de-sway`
  • `pmbootstrap config`
       [pmbootstrap]
       aports = /home/ybon/.local/var/pmbootstrap/cache_git/pmaports
       auto_zap_misconfigured_chroots = no
       boot_size = 256
       build_default_device_arch = False
       build_pkgs_on_install = False
       ccache_size = 5G
       device = nokia-argon
       extra_packages = none
       extra_space = 0
       hostname = 
       is_default_channel = False
       jobs = 4
       kernel = stable
       keymap = 
       locale = en_US.UTF-8
       qemu_redir_stdio = False
       ssh_key_glob = ~/.ssh/*.pub
       ssh_keys = True
       sudo_timer = False
       systemd = default
       timezone = Europe/Paris
       ui = sxmo-de-sway
       ui_extras = False
       user = ybon
       work = /home/ybon/.local/var/pmbootstrap
   
       [providers]
   
       [mirrors]
       alpine = http://dl-cdn.alpinelinux.org/alpine/
       alpine_custom = none
       pmaports = http://mirror.postmarketos.org/postmarketos/
       pmaports_custom = none
       systemd = http://mirror.postmarketos.org/postmarketos/extra-repos/systemd/
       systemd_custom = none
  • `pmbootstrap install`

Output:

   [12:07:52] *** (1/4) PREPARE NATIVE CHROOT ***
   [12:07:53] (native) Creating chroot
   [12:07:56] (native) install cryptsetup util-linux parted
   [12:07:57] *** (2/4) CREATE DEVICE ROOTFS ("nokia-argon") ***
   [12:07:58] (native) install qemu-arm
   [12:07:59] Register qemu binfmt (arm)
   [12:07:59] (rootfs_nokia-argon) Creating chroot
   [12:08:06] (rootfs_nokia-argon) install postmarketos-base device-nokia-argon postmarketos-ui-sxmo-de-i3 device-nokia-argon-nonfree-firmware postmarketos-base-nofde doas doas-sudo-shim w3m sfeed adwaita-icon-theme clickclack postmarketos-artwork-wallpapers ttyescape xcalc font-droid font-droid-nonlatin font-twemoji lang font-droid font-droid-nonlatin font-twemoji lang
   [12:08:35] (rootfs_nokia-argon) install postmarketos-mkinitfs
   [12:08:36] (rootfs_nokia-argon) mkinitfs
   [12:08:50]  *** SET LOGIN PASSWORD FOR: 'ybon' ***
   New password: 
   Retype new password: 
   passwd: password updated successfully
   [12:10:00] NOTE: No valid keymap specified for device
   [12:10:03] *** (3/4) PREPARE INSTALL BLOCKDEVICE ***
   [12:10:04] (native) create nokia-argon.img (1249M)
   [12:10:04] (native) mount /dev/install (nokia-argon.img)
   [12:10:05] (native) partition /dev/install (boot: 256M, reserved: 0M, root: the rest)
   [12:10:05] Mounting partitions of /dev/loop0 inside the chroot
   [12:10:05] (native) install e2fsprogs
   [12:10:06] (native) format /dev/installp2 (root, ext4)
   [12:10:06] (native) mount /dev/installp2 to /mnt/install
   [12:10:06] (native) install e2fsprogs
   [12:10:07] (native) format /dev/installp1 (boot, ext2), mount to /mnt/install/boot
   [12:10:08] (native) create /etc/fstab
   [12:10:08] (rootfs_nokia-argon) mkinitfs
   [12:10:26] *** (4/4) FILL INSTALL BLOCKDEVICE ***
   [12:10:26] (native) copy rootfs_nokia-argon to /mnt/install/
   [12:10:39] (native) make sparse rootfs
   [12:10:39] (native) install android-tools
   [12:10:46] 
   [12:10:46] *** FLASHING INFORMATION ***
   [12:10:46] Run the following to flash your installation to the target device:
   [12:10:46] * pmbootstrap flasher flash_rootfs
   [12:10:46]   Flashes the generated rootfs image to your device:
   [12:10:46]   /home/ybon/.local/var/pmbootstrap/chroot_native/home/pmos/rootfs/nokia-argon.img
   [12:10:46]   (NOTE: This file has a partition table, which contains /boot and / subpartitions. That way we don't need to change the partition layout on your device.)
   [12:10:46] * pmbootstrap flasher flash_kernel
   [12:10:46]   Flashes the kernel + initramfs to your device:
   [12:10:46]   /home/ybon/.local/var/pmbootstrap/chroot_rootfs_nokia-argon/boot
   [12:10:46]   (NOTE: fastboot also supports booting the kernel/initramfs directly without flashing. Use 'pmbootstrap flasher boot' to do that.)
   [12:10:46] * If the above steps do not work, you can also create symlinks to the generated files with 'pmbootstrap export' and flash outside of pmbootstrap.
   [12:10:46] 
   [12:10:46] *** SSH DAEMON INFORMATION ***
   [12:10:46] SSH daemon is enabled (disable with --no-sshd).
   [12:10:46] Login as 'ybon' with the password given during installation.
   [12:10:46] 
   [12:10:46] *** FIREWALL INFORMATION ***
   [12:10:46] Firewall is enabled, but may not work (couldn't determine if kernel supports nftables).
   [12:10:46] For more information: https://postmarketos.org/firewall
   [12:10:46] 
   [12:10:46] NOTE: chroot is still active (use 'pmbootstrap shutdown' as necessary)
   [12:10:46] DONE!


  • `pmbootstrap flasher flash_rootfs`

Ouptut:

   [12:11:26] (native) flash rootfs image
   [12:11:27] (native) install android-tools
   Sending sparse 'userdata' 1/4 (255944 KB)          OKAY [  8.079s]
   Writing 'userdata'                                 OKAY [100.859s]
   Sending sparse 'userdata' 2/4 (254159 KB)          OKAY [  8.046s]
   Writing 'userdata'                                 OKAY [ 29.891s]
   Sending sparse 'userdata' 3/4 (245641 KB)          OKAY [  7.754s]
   Writing 'userdata'                                 OKAY [ 24.939s]
   Sending sparse 'userdata' 4/4 (58004 KB)           OKAY [  1.833s]
   Writing 'userdata'                                 OKAY [ 40.341s]
   Finished. Total time: 221.920s
   [12:15:09] NOTE: chroot is still active (use 'pmbootstrap shutdown' as necessary)
   [12:15:09] DONE!
  • `pmbootstrap flasher flash_kernel`

Output:

   [sudo] password for ybon: 
   [12:16:34] (rootfs_nokia-argon) install device-nokia-argon
   [12:16:35] (rootfs_nokia-argon) install postmarketos-mkinitfs
   [12:16:36] (rootfs_nokia-argon) mkinitfs
   [12:16:53] INFO: config-postmarketos-qcom-msm8916.armv7 has suboptimal configuration (category:default), run 'pmbootstrap kconfig check' for details!
   [12:16:53] INFO: config-postmarketos-qcom-msm8916.armv7 has suboptimal configuration (category:default), run 'pmbootstrap kconfig check' for details!
   [12:16:53] WARNING: config-postmarketos-qcom-msm8916.armv7 isn't configured properly (category:default), run 'pmbootstrap kconfig check' for details!
   [12:16:53] INFO: config-postmarketos-qcom-msm8916.armv7 has suboptimal configuration (category:community_various), run 'pmbootstrap kconfig check' for details!
   [12:16:53] INFO: config-postmarketos-qcom-msm8916.armv7 has suboptimal configuration (category:filesystems), run 'pmbootstrap kconfig check' for details!
   [12:16:53] WARNING: config-postmarketos-qcom-msm8916.armv7 isn't configured properly (category:filesystems), run 'pmbootstrap kconfig check' for details!
   [12:16:53] WARNING: config-postmarketos-qcom-msm8916.armv7 isn't configured properly (category:hardening), run 'pmbootstrap kconfig check' for details!
   [12:16:53] WARNING: config-postmarketos-qcom-msm8916.armv7 isn't configured properly (category:immutable), run 'pmbootstrap kconfig check' for details!
   [12:16:53] INFO: config-postmarketos-qcom-msm8916.armv7 has suboptimal configuration (category:input), run 'pmbootstrap kconfig check' for details!
   [12:16:53] INFO: config-postmarketos-qcom-msm8916.armv7 has suboptimal configuration (category:input), run 'pmbootstrap kconfig check' for details!
   [12:16:53] INFO: config-postmarketos-qcom-msm8916.armv7 has suboptimal configuration (category:input), run 'pmbootstrap kconfig check' for details!
   [12:16:54] INFO: config-postmarketos-qcom-msm8916.armv7 has suboptimal configuration (category:input), run 'pmbootstrap kconfig check' for details!
   [12:16:54] INFO: config-postmarketos-qcom-msm8916.armv7 has suboptimal configuration (category:iwd), run 'pmbootstrap kconfig check' for details!
   [12:16:54] INFO: config-postmarketos-qcom-msm8916.armv7 has suboptimal configuration (category:iwd), run 'pmbootstrap kconfig check' for details!
   [12:16:54] INFO: config-postmarketos-qcom-msm8916.armv7 has suboptimal configuration (category:iwd), run 'pmbootstrap kconfig check' for details!
   [12:16:54] INFO: config-postmarketos-qcom-msm8916.armv7 has suboptimal configuration (category:usb_gadgets), run 'pmbootstrap kconfig check' for details!
   [12:16:54] INFO: config-postmarketos-qcom-msm8916.armv7 has suboptimal configuration (category:zram), run 'pmbootstrap kconfig check' for details!
   [12:16:54] INFO: config-postmarketos-qcom-msm8916.armv7 has suboptimal configuration (category:zram), run 'pmbootstrap kconfig check' for details!
   [12:16:54] WARNING: config-postmarketos-qcom-msm8916.armv7 isn't configured properly (category:usb), run 'pmbootstrap kconfig check' for details!
   [12:16:54] INFO: config-postmarketos-qcom-msm8916.aarch64 has suboptimal configuration (category:default), run 'pmbootstrap kconfig check' for details!
   [12:16:54] INFO: config-postmarketos-qcom-msm8916.aarch64 has suboptimal configuration (category:default), run 'pmbootstrap kconfig check' for details!
   [12:16:54] WARNING: config-postmarketos-qcom-msm8916.aarch64 isn't configured properly (category:default), run 'pmbootstrap kconfig check' for details!
   [12:16:54] INFO: config-postmarketos-qcom-msm8916.aarch64 has suboptimal configuration (category:community_various), run 'pmbootstrap kconfig check' for details!
   [12:16:54] INFO: config-postmarketos-qcom-msm8916.aarch64 has suboptimal configuration (category:filesystems), run 'pmbootstrap kconfig check' for details!
   [12:16:54] WARNING: config-postmarketos-qcom-msm8916.aarch64 isn't configured properly (category:filesystems), run 'pmbootstrap kconfig check' for details!
   [12:16:54] WARNING: config-postmarketos-qcom-msm8916.aarch64 isn't configured properly (category:hardening), run 'pmbootstrap kconfig check' for details!
   [12:16:54] WARNING: config-postmarketos-qcom-msm8916.aarch64 isn't configured properly (category:immutable), run 'pmbootstrap kconfig check' for details!
   [12:16:54] INFO: config-postmarketos-qcom-msm8916.aarch64 has suboptimal configuration (category:input), run 'pmbootstrap kconfig check' for details!
   [12:16:54] INFO: config-postmarketos-qcom-msm8916.aarch64 has suboptimal configuration (category:input), run 'pmbootstrap kconfig check' for details!
   [12:16:54] INFO: config-postmarketos-qcom-msm8916.aarch64 has suboptimal configuration (category:input), run 'pmbootstrap kconfig check' for details!
   [12:16:54] INFO: config-postmarketos-qcom-msm8916.aarch64 has suboptimal configuration (category:input), run 'pmbootstrap kconfig check' for details!
   [12:16:55] INFO: config-postmarketos-qcom-msm8916.aarch64 has suboptimal configuration (category:iwd), run 'pmbootstrap kconfig check' for details!
   [12:16:55] INFO: config-postmarketos-qcom-msm8916.aarch64 has suboptimal configuration (category:iwd), run 'pmbootstrap kconfig check' for details!
   [12:16:55] INFO: config-postmarketos-qcom-msm8916.aarch64 has suboptimal configuration (category:iwd), run 'pmbootstrap kconfig check' for details!
   [12:16:55] INFO: config-postmarketos-qcom-msm8916.aarch64 has suboptimal configuration (category:usb_gadgets), run 'pmbootstrap kconfig check' for details!
   [12:16:55] INFO: config-postmarketos-qcom-msm8916.aarch64 has suboptimal configuration (category:zram), run 'pmbootstrap kconfig check' for details!
   [12:16:55] INFO: config-postmarketos-qcom-msm8916.aarch64 has suboptimal configuration (category:zram), run 'pmbootstrap kconfig check' for details!
   [12:16:55] WARNING: config-postmarketos-qcom-msm8916.aarch64 isn't configured properly (category:usb), run 'pmbootstrap kconfig check' for details!
   [12:16:55] (native) flash kernel postmarketos-qcom-msm8916
   [12:16:56] (native) install android-tools
   Sending 'boot' (16426 KB)                          OKAY [  0.521s]
   Writing 'boot'                                     OKAY [  1.352s]
   Finished. Total time: 1.901s
   [12:16:58] You will get an IP automatically assigned to your USB interface shortly.
   [12:16:58] Then you can connect to your device using ssh after pmOS has booted:
   [12:16:58] ssh ybon@172.16.42.1
   [12:16:58] NOTE: If you enabled full disk encryption, you should make sure that Unl0kr has been properly configured for your device
   [12:16:58] NOTE: chroot is still active (use 'pmbootstrap shutdown' as necessary)
   [12:16:58] DONE!

But now, turning on the phone, I'm stuck on that screen:

And if I switch on with "UP" pressed, I've

But I can SSH:

   $ ssh 172.16.42.1
   Welcome to postmarketOS! o/
 
   This distribution is based on Alpine Linux.
   First time using postmarketOS? Make sure to read the cheatsheet in the wiki:
 
   -> https://postmarketos.org/cheatsheet
 
   You may change this message by editing /etc/motd.
   Sxmo is not running
   nokia-argon:~$ 

postinstall

  • Add "panel_mipi_dbi" module
echo "panel_mipi_dbi" | sudo tee -a /etc/modules
sudo reboot

Add a device profile:

sudo vim /usr/bin/sxmo_deviceprofile_nokia,argon.sh

And add this:

#!/bin/sh
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2022 Sxmo Contributors
export SXMO_NO_VIRTUAL_KEYBOARD=1
export DMENU_WRAP_AROUND=1
export SXMO_SCREEN_WIDTH=240
export SXMO_SCREEN_HEIGHT=320

Then make the file executable:

sudo chmod +x /usr/bin/sxmo_deviceprofile_nokia,argon.sh

- Long-press on the power button to start a terminal, then up to run the last command (which is sxmo_appmenu.sh), and voilà (or run this from SSH: `DISPLAY=:0 sxmo_appmenu.sh`)

thumb]
thumb]

To give more space to the menu, add this in .config/wofi/config

x=0
y=0
width=99%
height=90%

And reduce font-size in .config/wofi/style.css.

To disable XWayland, add this is .config/sxmo/sway:

xwayland disable

And let conky display itself in wayland by adding this in .config/sxmo/conky.conf:

conky.config = {
    out_to_x = false,
    out_to_wayland = true,
    […]
}

To switch on/off the keyboard backlight when the lid is off/on, in the file .config/sxmo/sway, replace

bindswitch lid:on exec sxmo_wm.sh display off
bindswitch lid:off exec sxmo_wm.sh display on

with:

bindswitch lid:on exec sxmo_wm.sh display off && brightnessctl -d white:kbd_backlight set 0
bindswitch lid:off exec sxmo_wm.sh display on && brightnessctl -d white:kbd_backlight set 255

Buttons binding

In .config/sxmo/sway add:

# Keypad key bindings
# To open contextual menu on "right menu" press
bindsym XF86KbdLcdMenu2 exec sxmo_appmenu.sh
# To open dialer menu on "pickup phone" press
bindsym XF86PickupPhone exec sxmo_modemdial.sh

To make the power button only open the power menu (I feel like state management is useless in a keypad phone with slider):

diff --git a/configs/default_hooks/sxmo_hook_inputhandler.sh b/configs/default_hooks/sxmo_hook_inputhandler.sh
index 94260fc..fca2af6 100755
--- a/configs/default_hooks/sxmo_hook_inputhandler.sh
+++ b/configs/default_hooks/sxmo_hook_inputhandler.sh
@@ -353,20 +353,12 @@ esac
 
 #standard handling
 case "$ACTION" in
-       "powerbutton_one")
-               if echo "$WMCLASS" | grep -i "megapixels"; then
-                       sxmo_type.sh -k space
-               else
-                       sxmo_state.sh click
-               fi
-               exit 0
-               ;;
-       "powerbutton_two")
-               sxmo_state.sh click 2
+       "menuright")
+               sxmo_appmenu.sh "$WMCLASS" "$WMNAME"
                exit 0
                ;;
-       "powerbutton_three")
-               sxmo_terminal.sh
+       "powerbutton_one")
+               sxmo_appmenu.sh power
                exit 0
                ;;
        "voldown_one")

Keypad support

Install `fctix5` and build deps for the addon:

doas apk add fcitx5-dev cmake g++ extra-cmake-modules make

Make it autostart by adding a superd service

doas vim /usr/share/superd/services/fcitx5.service

With this content:

[Unit]
Description=Fcitx5 daemon

[Service]
Type=simple
Restart=on-failure
ExecStart=fcitx5 -r

Then

superctl enable fcitx5
superctl start fcitx5

Fetch addon source:

cd /tmp
wget https://codeberg.org/ybon/fcitx5-t9/archive/main.zip
unzip main.zip
cd fcitx5-t9/
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr

Should output something like this:

   -- The C compiler identification is GNU 15.2.0
   -- The CXX compiler identification is GNU 15.2.0
   -- Detecting C compiler ABI info
   -- Detecting C compiler ABI info - done
   -- Check for working C compiler: /usr/bin/cc - skipped
   -- Detecting C compile features
   -- Detecting C compile features - done
   -- Detecting CXX compiler ABI info
   -- Detecting CXX compiler ABI info - done
   -- Check for working CXX compiler: /usr/bin/c++ - skipped
   -- Detecting CXX compile features
   -- Detecting CXX compile features - done
   -- Installing in the same prefix as Fcitx, adopting their path scheme by default
   -- Configuring done (4.5s)
   -- Generating done (0.0s)
   -- Build files have been written to: /tmp/fcitx5-t9/build
make

Should output something like this:

 [ 50%] Building CXX object src/CMakeFiles/t9.dir/t9.cpp.o
 [100%] Linking CXX shared library t9.so
 [100%] Built target t9
doas make install

Should output something like this:

 [100%] Built target t9
 Install the project...
 -- Install configuration: ""
 -- Installing: /usr/lib/fcitx5/t9.so
 -- Installing: /usr/share/fcitx5/addon/t9.conf
 -- Installing: /usr/share/fcitx5/inputmethod/t9.conf

Edit fcitx5 profile:

doas vim ~/.config/fcitx5/profile

Add this content:

[Groups/0]
Name=Default
Default Layout=en
DefaultIM=keyboard-en

[Groups/0/Items/0]
Name=t9
Layout=

[Groups/0/Items/1]
Name=keyboard-en
Layout=

[GroupOrder]
0=Default

Add this in .profile and .config/sxmo/profile:

export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS=@im=fcitx
export SXMO_MENU=wofi

(Default menu does not support input methods, so we need to switch to wofi.)

Now reboot and T9 should be active!

Audio

Kernel work from Affe Null, thanks to him!

git clone -b sound-nokia-argon https://github.com/yohanboniface/linux/
cd linux
cp ~/.local/var/pmbootstrap/cache_git/pmaports/device/testing/linux-postmarketos-qcom-msm8916/config-postmarketos-qcom-msm8916.armv7 arch/arm/configs/msm8916_defconfig
# envkernel.sh is in the pmbootstrap git repo
source ../pmbootstrap/helpers/envkernel.sh
make msm8916_defconfig
make
pmbootstrap build --envkernel linux-postmarketos-qcom-msm8916
pmbootstrap sideload linux-postmarketos-qcom-msm8916 --install-key
# With phone on fastboot mode (reboot with Down pressed)
pmbootstrap flasher flash_kernel

In the file /usr/share/alsa/ucm2/platforms/msm8916/qdsp6.conf, change "CS-Voice" by "VoiceMMode1" (four occurrences).

Tips

  • to connect to wifi from SSH:
nmcli --ask dev wifi connect XXX
  • to activate SIM:
mmcli -i any --pin=1234
  • make a screenshot (from SSH):
WAYLAND_DISPLAY="wayland-1" grim

This will save the image in ~/Pictures/