unbrick01.mdwn (9054B)
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 Start the networking service with `rc-service networking start` en enable it on boot with `rc-update add networking boot` 135 136 ping `127.0.0.1` to test 137 138 # Installing audio driver 139 To install a working audio driver, run `extract-firmware.sh` as root 140 141 ```bash 142 sudo extract-firmware.sh 143 ``` 144 Reboot the phone and check if there are soundcards available with `aplay -l` 145 146 ## playing sound (test) 147 148 route audio to the headphone jack 149 150 `alsaucm -c "Galaxy A52" set _verb HiFi set _enadev Headphones` 151 152 play test sound 153 154 `speaker-test -D hw:0,1 -c 2 -t sine -f 440` 155 156 you can increase the volume with the following two commands 157 158 ``` 159 amixer -c 0 cset name='HPHL Volume' 20 160 amixer -c 0 cset name='HPHR Volume' 20 161 ``` 162 163 # Testing functionality 164 165 ## evtest 166 167 Install [`evtest`](https://wiki.postmarketos.org/wiki/Input_devices#Using_evtest_to_show_input_events) with `apk add evtest` 168 169 Run `evtest /dev/input/event0` and press the power button to get a response. 170 171 ```bash 172 Event: time 151283560.995643, type 1 (EV_KEY), code 116 (KEY_POWER), value 1 173 Event: time 151283560.995643, -------------- SYN_REPORT ------------ 174 Event: time 151283561.130515, type 1 (EV_KEY), code 116 (KEY_POWER), value 0 175 Event: time 151283561.130515, -------------- SYN_REPORT ------------ 176 177 ``` 178 179 __*All*__ hardware buttons __*and*__ the touchscreen are working. 180 181 * `KEY_POWER` is mapped to `/dev/input/event0` 182 * `KEY_VOLUMEUP` is mapped to `/dev/input/event3` 183 * `KEY_VOLUMEDOWN` is mapped to `/dev/input/event1` 184 * `ABS_X`, `ABS_Y` (touchscreen) etc. is mapped to `/dev/input/event2` 185 186 ## Install pd and libpd 187 188 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. 189 Or run `apk add chrony && rc-service chronyd start` to a ntp service. 190 191 Add the testing repo to the bottom of the `/etc/apk/repositories` file 192 193 ```bash 194 @edge https://dl-cdn.alpinelinux.org/alpine/edge/testing 195 ``` 196 197 Update apk and install `pd` and `libpd`. 198 199 ```bash 200 apk update 201 apk add pure-data@edge libpd-dev@edge libpd@edge 202 ``` 203 204 ### sidequest: compiling Pd from scratch 205 206 In case `pd` is not packaged for your architecture, or if you need a more recent version. 207 208 ```sh 209 sudo apk add build-base autoconf automake libtool alsa-lib-dev jack-dev 210 git clone https://github.com/pure-data/pure-data 211 cd pure-data 212 ./autogen.sh 213 LIBS="`pkg-config -libs jack alsa`" ./configure --enable-alsa --enable-jack 214 make -j$(nproc) 215 sudo make install 216 ``` 217 218 ## Python 219 220 Installing python so we can run a simple script that sends `evdev` (touch) events over a local socket to pd. 221 222 ```sh 223 apk add python3 py3-evdev 224 ``` 225 226 ## Starting unbrick01 227 228 Clone the repo and run the python script 229 230 ```bash 231 git clone https://git.xpub.nl/ugrnm/unbrick01.git 232 cd unbrick01/pd/startup 233 python touch2pd.py 234 ``` 235 236 And run `pd` 237 238 ```bash 239 cd unbrick01/pd/patch/unstable 240 pd -stderr -nogui -jack chkahichdahk.pd 241 ``` 242 243 If you touch the touchscreen, you should see `x` and `y` coordinates in the shell. These coordinates are being send on `localhost` to port `10101`. 244 245 ## jackd 246 247 start the `jackd` server 248 TODO: run this as a `rc-service`, cannot get it to work yet 249 250 `JACK_NO_AUDIO_RESERVATION=1 jackd -r -d alsa -P -d hw:0,1 -S` 251 252 ## pd 253 254 Now to receive the send touch coordinates, run the example pd patch in the shell 255 256 ```bash 257 cd unbrick01/pd/patch/unstable 258 pd -nogui -stderr -jack chkahichdahk.pd 259 ``` 260 261 touch the touchscreen and you should see the coordinates printed in the shell and you should hear sound! 262 263 temp fix without JACK 264 ```sh 265 pd -nosleep -r 48000 -stderr -noadc -nogui chkahichdahk.pd # speaker 266 ``` 267 268 # BRAINDUMP 269 270 for things that may be useful in the future... 271 272 Turn on the speaker volume on minimal (`none` postmarketOS profile) `samsung-m0` device: 273 274 ```sh 275 alsaucm -c 0 set _verb HiFi set _enadev Speaker 276 ``` 277 278 Start JACK without X/DBUS/etc 279 280 ```sh 281 JACK_NO_AUDIO_RESERVATION=1 jackd -d alsa 282 ``` 283 284 Start JACK without X/DBUS/etc *and* force 16bit (necessary for galaxy SIII) 285 286 ```sh 287 JACK_NO_AUDIO_RESERVATION=1 jackd -d alsa -S 288 ```