unbrick01.mdwn (8026B)
1 # Installing pmOS on the Samsung A52 4G 2 3 ## Unlocking the bootloader 4 5 - set up the Android phone. 6 - connect to Wi-Fi (mandatory for `OEM unlocking option to show up`) 7 - navigate to the phone’s settings 8 - all the way at the bottom press on `About Phone` 9 - click on `Software Information` and click 7 times on `Build number` until the phone states: `Developer mode has been enabled`. 10 - press `back` twice and scroll down to `Developer Options` 11 - enable `OEM unlocking` and `USB debugging`. If `OEM unlocking` is not there, reboot the phone and try again. 12 13 ## Installation Heimdall 14 15 Two options: use the version provided by your OS, or compile from scratch if your OS does not provide a `heimdall` binary, or if this binary is too old. We need at least `v2.2.2`. 16 17 ### OS version 18 19 On Debian (for instance): 20 21 ```sh 22 sudo apt install heimdall-flash 23 ``` 24 25 ### Compilation 26 27 Upstream project is located at [https://git.sr.ht/~grimler/heimdall](https://git.sr.ht/~grimler/heimdall). Compilation steps: 28 29 ```bash 30 git clone https://git.sr.ht/~grimler/Heimdall 31 cd Heimdall 32 mkdir build && cd build 33 cmake -DDISABLE_FRONTEND=ON .. 34 make -j$(nproc) 35 ``` 36 37 You can copy the resulting `heimdall` binary to your `$PATH` (e.g. `cp bin/heimdall ~/.local/bin/`). or you can `sudo make install` and `heimdall` will be installed system-wide in `/usr/local/bin`. 38 39 ## postmarketOS (pmbootstrap) 40 41 ### installing pmbootstrap 42 43 Follow the steps on the [pmOS wiki](https://wiki.postmarketos.org/wiki/Pmbootstrap/Installation) 44 45 ### bootstrapping 46 47 Run `pmbootstrap init` for a random device (samsung a5) and set it up. 48 after that I followed newbytes instructions: 49 50 ```bash 51 cd $(pmbootstrap config aports) 52 git fetch origin 53 git switch newbyte/a52-v25.12 54 ``` 55 56 Run `pmbootstrap init` again. Now you are able to select `a52q`. Pick the following options: 57 58 ```bash 59 Channel [v25.12]: v25.12 60 Vendor [samsung]: samsung 61 Device codename [a5]: a52q 62 Username [user]: user 63 Provider [default]: pulseaudio 64 Provider [default]: wpa_supplicant 65 User interface [none]: none 66 Install systemd [default]: default 67 Change them? (y/n) [n]: n 68 Extra packages [openssh]: openssh 69 Use this timezone instead of GMT? (y/n) [y]: y 70 Locale [en_US]: en_US 71 Device hostname [samsung-a52q]: unbrick01 72 Would you like to copy these public keys to the device? (y/n) [n]: n 73 Build outdated packages during 'pmbootstrap install'? (y/n) [y]: y 74 Zap existing chroots to apply configuration? (y/n) [y]: y 75 ``` 76 77 ### installing pmOS 78 79 After this boot your device into `Download Mode`. You can get in `Download Mode` by fully powering off the device. Then, while holding `Volume Up` & `Volume Down` plug in a USB-C cable that is connected to your computer until you see a ‘Download’ screen. Release the buttons and press `Volume Up` to get in `Download Mode`. You will need to do this a few times :) 80 81 When in `Download Mode`, run `pmbootstrap install` and follow the steps. Then, flash the kernel by running `pmbootstrap flasher --no-reboot flash_kernel`. 82 83 > If you get an error that `zstd` is not found. Install it manually by running `pmbootstrap chroot -- apk add zstd` and try again to flash the kernel. 84 85 Turn the phone off again, enter `Download Mode` again and flash the rootfs `pmbootstrap flasher --no-reboot flash_rootfs`. 86 87 Turn the phone off again, enter `Download Mode` again and flash the DTBO which you can get from here [https://github.com/map220v/postmarket_samsung_a72q/releases/tag/dtbo](https://github.com/map220v/postmarket_samsung_a72q/releases/tag/dtbo). You flash this with the compiled heimdall by running `heimdall flash --DTBO emptyDTBO.img` 88 89 When you reboot the phone now you should see the pmOS splash screen followed by tty 90 91 ## SSH to device 92 93 After you boot to a TTY you can ssh into the phone after you give the phone an ip address. Find the phone with the command 94 95 `ip a` 96 97 Usually the phone has a random string like this `enx9ad89e8d8f22`. This is a USB network interface. Give this interface a ip address 98 99 `sudo dhclient enx9ad89e8d8f22` 100 101 Now you can SSH into the phone with the username and password set during `pmbootstrap install`. 102 103 `ssh user@172.16.42.1` 104 105 ## Share internet connection 106 107 Run a few commands on your machine and on the phone. You need to know the primary network interface name of your machine from which you are connected to the net. It could be `en0` or `wlan1` or `wlxc0d3d34d`, use `ip a` to find it. 108 109 On your machine: 110 111 ```sh 112 sudo sysctl net.ipv4.ip_forward=1 113 # for OS with iptables (you can find your net interface with `ip a`.) 114 sudo iptables -t nat -A POSTROUTING -o <primary-net-interface> -j MASQUERADE 115 # for OS with nftables 116 sudo nft add table inet nat 117 sudo nft add chain inet nat postrouting '{ type nat hook postrouting priority srcnat ; }' 118 sudo nft add rule inet nat postrouting oifname <primary-net-interface> masquerade 119 ``` 120 On the phone: 121 122 ``` 123 sudo ip route add default via 172.16.42.2 124 echo "nameserver 9.9.9.9" | sudo tee /etc/resolv.conf 125 ``` 126 127 and you should share a connection now. To enable localhost access on the phone, edit /etc/network/interfaces and add the following 128 129 ```bash 130 auto lo 131 iface lo inet loopback 132 ``` 133 134 ping `127.0.0.1` to test 135 136 # Testing functionality 137 138 ## evtest 139 140 Install [`evtest`](https://wiki.postmarketos.org/wiki/Input_devices#Using_evtest_to_show_input_events) with `apk add evtest` 141 142 Run `evtest /dev/input/event0` and press the power button to get a response. 143 144 ```bash 145 Event: time 151283560.995643, type 1 (EV_KEY), code 116 (KEY_POWER), value 1 146 Event: time 151283560.995643, -------------- SYN_REPORT ------------ 147 Event: time 151283561.130515, type 1 (EV_KEY), code 116 (KEY_POWER), value 0 148 Event: time 151283561.130515, -------------- SYN_REPORT ------------ 149 150 ``` 151 152 __*All*__ hardware buttons __*and*__ the touchscreen are working. 153 154 * `KEY_POWER` is mapped to `/dev/input/event0` 155 * `KEY_VOLUMEUP` is mapped to `/dev/input/event3` 156 * `KEY_VOLUMEDOWN` is mapped to `/dev/input/event1` 157 * `ABS_X`, `ABS_Y` (touchscreen) etc. is mapped to `/dev/input/event2` 158 159 ## Install pd and libpd 160 161 Make sure the date of the phone is set. Manually works by running `date -s "2026-05-05 10:22:00"`. Change the date/time accordingly. 162 Or run `apk add chrony && rc-service chronyd start` to a ntp service. 163 164 Add the testing repo to the bottom of the `/etc/apk/repositories` file 165 166 ```bash 167 @edge https://dl-cdn.alpinelinux.org/alpine/edge/testing 168 ``` 169 170 Update apk and install `pd` and `libpd`. 171 172 ```bash 173 apk update 174 apk add pure-data@edge libpd-dev@edge libpd@edge 175 ``` 176 177 ### sidequest: compiling Pd from scratch 178 179 In case `pd` is not packaged for your architecture, or if you need a more recent version. 180 181 ```sh 182 sudo apk add build-base autoconf automake libtool alsa-lib-dev jack-dev 183 git clone https://github.com/pure-data/pure-data 184 cd pure-data 185 ./autogen.sh 186 LIBS="`pkg-config -libs jack alsa`" ./configure --enable-alsa --enable-jack 187 make -j$(nproc) 188 sudo make install 189 ``` 190 191 ## Python 192 193 Installing python so we can run a simple script that sends `evdev` (touch) events over a local socket to pd. 194 195 ```sh 196 apk add python3 py3-evdev 197 ``` 198 199 Clone the repo and run the python script 200 201 ```bash 202 git clone https://git.xpub.nl/ugrnm/unbrick01.git 203 cd unbrick01/pd/startup 204 python touch2pd.py 205 ``` 206 207 If you touch the touchscreen, you should see `x` and `y` coordinates in the shell. These coordinates are being send on `localhost` to port `1337` 208 209 ## pd 210 211 Now to receive the send touch coordinates, run the example pd patch in the shell 212 213 ```bash 214 cd ~/unbrick01/pd/patch/unstable 215 pd -nogui -stderr phone_test.pd 216 ``` 217 218 touch the touchscreen and you should see the coordinates printed in the shell and you should hear sound, but `--- no soundcards ---` (yet) 219 220 # BRAINDUMP 221 222 for things that may be useful in the future... 223 224 Turn on the speaker volume on minimal (`none` postmarketOS profile) `samsung-m0` device: 225 226 ```sh 227 alsaucm -c 0 set _verb HiFi set _enadev Speaker 228 ``` 229 230 Start JACK without X/DBUS/etc 231 232 ```sh 233 JACK_NO_AUDIO_RESERVATION=1 jackd -d alsa 234 ``` 235 236 Start JACK without X/DBUS/etc *and* force 16bit (necessary for galaxy SIII) 237 238 ```sh 239 JACK_NO_AUDIO_RESERVATION=1 jackd -d alsa -S 240 ```