Monthly Archives: September 2018

Smartphones #2: Working phone? Ain’t nobody got time for that

samsung-s6500d:

This phone has a “working” pmos port, if you consider a phone that reboots after 2 minutes as a working one. I wanted to try to flash newest  Linux kernel on it but here’s the problem:

New kernel uses pretty easy to edit and maintain  dtb files that contains all information about phone, SoC and other hardware components. But before that all these information were hard-coded in the kernel, often i many different files, making it harder to edit and update. I’d have to write dtb file from scratch, using old source as a base. Since it’s nice to see what are you doing, I need some kind of output to know what happens inside the phone. Sadly, creating dtb file from scratch I must acknowledge that sound, USB, screen and basically nothing that would help me will work yet :/. There is however one thing that should work always: UART(see glossary), a good old text mode.

Here lies the problem, or rather several problems. The first one is where is UART physically located  in the device, fortunately UART on Samsung devices is easy to get.

Micro-USB plug have 5 pins, as opposed to four in regular USB plug used in PC. By connecting ground and ID (this is that additional pin) through various resistors the phone changes function of USB socket.

When these two pins are disconnected the USB port works as usual allowing you to connect smartphone to PC; 300kΩ — phone enters  download/fastboot mode, on some models the yellow triangle warning about unofficial software disappears (sadly not on this one).

UART mode had caused me some trouble, since there are several similar modes but only few of them are useful to me. So I built small resistor box to test the phone with most popular resistor values, which should make this part easy.

The second issue is what is needed in the dtb file to start and use UART or get any kind of output running, which I’ll probably have to determine experimentally. For now I’m thinking about two solutions: first one is to use “earlycon”, which, in theory, requires only UART address and hopefully the kernel should so everything automatically ; the second solution requires defining where is serial port, its parameters, clocks etc, and that involves digging through the old kernel source code in search for answers.

 

afterword:

I wrote more than I initially thought I would, I see that I really need to polish my English, hopefully writing more or less regularly will help me with that 🙂 When it comes to smartphones I’ll probably focus on this phone for a while, the next part of the series will have to wait though as I have more urgent things to do, there is a possibility of new blog post about Google Cardboard VR in near future 🙂

 

glossary:

DTS is a compiled DTB file, also known as  Device tree, that file contains information about all components of the device, such as CPU, GPU, memory, screen, etc. It allows to compile one generic kernel which then reads DTS file and activates needed peripherals instead of compiling specialized kernel for each phone.

UART (a.k.a serial port, rs232, COM port) — very simple communication protocol, easy to implement even when nothing else is working

Smartphones #1: two bricks in one day

The beginning of the series about smartphones that I experiment on and try to run postmarketOS.

auchan-s6s5in3g:

As it turn out I was able to flash and run recovery made for the different phone with the same SoC, bricking Android at the same time :/. There’s no video but adb works and that alone was enough to make a backup from which I was able to retrieve dts file(see glossary). That file may simplify porting process immensely. Why? With newer Linux kernels (including newest one) I may be able to use generic kernel made for the SoC brand used in this phone (Spreadtrum) and combine it with the dts file to get kernel boot on this device.

sony-taoshan:

This will make a fine addition to my collection, there’s an LineageOS kernel for it which, in theory, should allow for easy porting pmos. Oh naive me. After flashing pmos even kernel didn’t work so I thought about making backup of the whole phone before I hardbrick it, but I needed custom recovery for this. Sadly, as most phones have separate boot and recovery partitions this one does not >:(. I can’t just flash recovery since it would overwrite existing kernel, preventing currently installed system from booting. For each system/kernel I’d have to pack files for recovery mode which would be annoying, so for now I have phone with no working system on it, without backup, waiting for influx of my patience.

glossary:

DTS is a compiled DTB file, also known as  Device tree, that file contains information about all components of the device, such as CPU, GPU, memory, screen, etc. It allows to compile one generic kernel which then reads DTS file and activates needed peripherals instead of compiling specialized kernel for each phone.

fastboot – special mode in smartphones which allows for installation of new firmware, replacing whole partition instead of single files

recovery – special mode in smartphones which allows for installation of new firmware, or updating it without reflashing everything; resetting phone to factory default or making backups