Вступ до портування

Цей перший розділ познайомить Вас із особливостями портування/перенесення Ubuntu Touch на пристрій з Android. Зауважте, що це написано більше для загального розуміння для тих, хто не має великого досвіду портування прошивок. У наступних розділах ми спробували диференціювати опис, зберігши основний текст більш лаконічним та спробувати задовольнити потреби більш досвідчених читачів, водночас надаючи посилання на додаткову інформацію для менш досвідчених.

Ці настанови написані як послідовність кроків, які допоможуть виконати ідеальне портування. Хоча портування буває непередбачуваним та заплутаним. Кожен пристрій має свої особливості та можливо Вам прийдеться пройти деякі кроки декілька разів, щось пропустити, зіткнутися з новими незадокументованими викликами.

Що таке Ubuntu Touch?

Ubuntu Touch — операційна система для мобільних пристроїв з відкритим кодом. Її можна перенести на пристрої, які постачаються (чи постачалися) з ОС Android. На жаль, більшість цих пристроїв залежні у певній мірі від закритого програмного забезпечення.

Точніше кажучи, постачальники пристроїв, як правило, зберігають код, який спілкується безпосередньо з обладнанням пристрою (низькорівневі драйвери пристроїв), пропрієтарним (закритим). Ці компоненти зазвичай мають назву vendor „blobs“ (Binary Large OBjects, двійкові великі об’єкти). Ці «блоби/двоби» повинні бути додані до Вашої прошивки Ubuntu Touch. Зауважте, що ці компоненти є унікальними не лише для кожного пристрою, а й для кожної версії Android. Саме тому є необхідним мати під час компіляції прошивки правильну версію компонентів.

Саме через це для більшості комерційних пристроїв Ubuntu Touch не можна просто зібрати з вихідного коду. Замість цього для портування на ці пристрої потрібно зазначені раніше «блоби» виробників інтегрувати до системи, яку можна скомпілювати з джерельного коду.

Наступний компонент Ubuntu Touch — це зібрана попередньо коренева система, яку потрібно встановити на пристрій. Цей компонент напряму з обладнанням не спілкується. Але ця комунікація налаштована через шар апаратних абстракцій (Hardware Abstraction Layer, HAL), який потрібно зібрати для кожного пристрою окремо, тому що у кожного пристрою своя власна архітектура обладнання. Цей компонент називається Halium та він доступний у різних версіях відповідно до версій Android.

Цей Проєкт Halium активує можливість запуску Linux на обладнанні Android. Це спільна робота кількох мобільних операційних систем, зокрема Lune OS, Droidian та Ubuntu Touch.

Портування прошивки Ubuntu Touch відбувається поверх Halium GSI (Generic System Interface, загальний системний інтерфейс). Про це детальніше йдеться далі. Іноді також може бути корисним тестування з іншою операційною системою, щоб розглянути проблему з різних точок зору.

Halium є невід’ємною частиною прошивки Ubuntu Touch та доступний у формі відкритого коду. Розробка нових версіх Halium — дуже важлива задача, оскільки наразі існують лише декілька версій Halium. Кожна прошивка Ubuntu Touch заснована на одній з доступних версій Halium та «блобах» виробників (vendor blobs) з відповідних версій Android. Подивіться уважно на два перших стопці наведеної нижче таблиці.

Таким чином прошивка/порт Ubuntu Touch складається з таких компонентів:
  • Коренева система (rootfs) Ubuntu Touch (UT)

  • Halium (міститься в образах boot та system)

  • Файли виробника (vendor blobs)

Для створення робочої прошивки Ubuntu Touch Ви як портувальник повинні зібрати ядро Halium, яке буде встановлене разом з кореневою системою Ubuntu Touch (rootfs) та Halium GSI.

Версії Android та Halium

Halium зроблений з використанням початкового коду для модифікованої версії ОС Android, яка має назву LineageOS (див. вебсайт LineageOS та її wiki). Необхідний початковий код доступний онлайн та для компіляції правильної версії Halium під кожний окремий пристрій, його потрібно завантажити на комп’ютер. У наданій нижче таблиці міститься інформація про те яка версія для якого Halium потрібна.

Версія Android

Версія Halium

Lineage OS (LOS)

7.1

7.1

14.1

9.0

9.0

16.0

10.0

10.0

17.1

11.0

11.0

18.1

12.0

12.0

19.1

13.0

13.0

20.0

Починаючи з версії 20.04, Ubuntu Touch зазвичай будується на Halium 9.0 чи новіше. Старі версії Halium вважаються застарілими та більше для нових портів не підтримуються.

Generic System Image

Starting with Android version 9.0, a significant change of architecture was introduced. The device-specific vendor blobs now reside on a separate partition instead of sharing a partition with the rest of the system image. This separation of device-specific code from generic code made possible what is known as the Generic System Image (GSI).

A GSI is a system image that is built to be able to function with a wide range of devices. Android devices, as of version 9.0, use a GSI. For more information, see the Android Developer pages

The development of the Android GSI architecture also cleared the way for the now available generic Halium 9.0 arm64 system image (hereafter referred to as the Halium GSI, or simply the GSI) which is used for Ubuntu Touch. This, however, is somewhat different from the Android GSI. For a more detailed explanation of the Halium GSI, please refer to the wiki page on Gitlab CI builds of the generic Halium system image.

What does this mean for the porting process?

Since the GSI is a prebuilt, device-independent component, it effectively simplifies the task of building a viable port by removing much of the meticulous and time consuming task of getting the hardware-specific vendor blobs compiled into the system image and configured to function properly.

The challenges of the porting process

Building the necessary components and getting them to work together properly always involves an amount of code modifications, configuring and testing.

Luckily, there is a community of porters out there who are eager to see Ubuntu Touch ported to new devices. When you run into trouble, you should search the sources below (Getting community help) to see if others before you have solved the issue. There are online Telegram chat groups you can join to ask for help, but please bear in mind that those participating are doing so in their spare time.

Примітка

In the past there used to be different methods for porting. Find the historic details linked in the deprecated porting section.

Prior knowledge and skills

Porters come in all sizes and shapes, so to speak. Therefore, this guide does not presuppose extensive knowledge or skills in any particular field. You should, however, as a bare minimum be familiar with some common shell commands and be comfortable working from the terminal on you host PC. Furthermore, the guide is based on a host PC running Linux. If you have some knowledge of programming, this will come in handy at some point, especially if you are familiar with C / C++. Also, you should familiarize yourself with git and set up a Github or Gitlab account to keep track of your code changes. It is wise to start documenting your steps from the very beginning.

We have attempted to give a certain amount of explanation along the way. However, this guide is not an in-depth reference into the architecture and inner workings of Ubuntu Touch, and gaining a deeper understanding will consequently require an amount of research on your part.

Getting community help

When you run into trouble, and you will, refer to one or more of the sources below:

General advice

The more rigorous you are at making notes and documenting your steps, the less time you will spend backtracking your steps and guessing your way along. When dealing with issues that arise along the way, it is wise to work on them one at a time. If you try to correct several things at once, you risk ending up trying to guess which changes solved a given issue, which easily leads to breaking the functionality in question once more at some later stage.

If you are not discouraged after reading this, we welcome your efforts and wish you the best of luck!

The next section presents a key to the rest of this guide.