Android aosp source allwinner

Загрузка и сборка AOSP

Решил поделиться своей инструкцией как собрать AOSP (Android Open Source Project). Эта инструкция будет полезна тем кто хочет посмотреть что-же внутри Android и возможно заняться системной разработкой. В любом случаи эти знания полезны для понимания самого Android, как раз для этого и решил собрать AOSP.

Проект собираю на elementary 5.1 OS Ubuntu 18.04 LTS (bionic), пытался на MacOS собрать, но так и не удалось. Для исходников и сборки нужно 200 Гб на жестком диске (лучше SSD, на обычном производительность сильно проседает). Так же много времени, я потратил чтобы скачать и собрать около 20 часов, частично виновата «слабая» конфигурация моего компьютера. У меня установлено всего 8 Гб оперативной памяти, но увеличил размер swap-а до 16 Гб.

Загружаем AOSP

Установить требуемые пакеты для загрузки и сборки :

Создаем папку и качаем repo утилиту для загрузки исходного кода

Исходники AOSP состоят из отдельных проектов с собственными git-репозиториями, repo позволяет упросить всю загрузку всех проектов и разложить по нужным папкам.

  • -u — урл git-репозитория с манифестом
  • -b — ветка (самая последняя на текущий момент)
  • —depth — скачивать только одну ветку (если не использовать, то для каждого репозитория скачается весь индекс, что увеличит время загрузки и место на диске)

Выбрал самую последнюю версию Android 10. Не использую develop или master, так как там устаревший манифест и проект скорее не соберется.

Теперь можно запустить загрузку исходников AOSP

  • -c — скачивать только текущую ветку манифеста (как указал выше — android-10.0.0_r45)
  • -j — количество потоков, обычно указывается столько доступно процессоров
  • —no-tags — не скачивать тэги с репозитариев
  • —no-clone-bundle — не пытаться качать clone.bundle (упакованная репа, которая уменьшить время на загрузку, но не у всех сервер формирует этот bundle),

—no-clone-bundle можно попробовать убрать, что в теории ускорит скачивание, но у меня заваливается с 404 ошибкой

Скачивание может занять минуты и часы, теперь с repo закончили, если нужно почитать больше то ищите в официальной документации: https://source.android.com/setup/develop/repo

Сборка

Настраиваем среду разработчика:

x86_64 — указывается под какой девайс собирать, в данном случае Generic x86_64 подходит для эмуляторов, если будете запускать на Nexus девайсах, то ищите детали в документации https://source.android.com/setup/build/building#choose-a-target

eng — тип сборки (сокращение от engineering), с максимальными логами и дополнительными утилитами для отладки. Другие тип сборки думаю не особо интересны

Для сборки java файлов увеличиваем Heap size, если этого не сделать, то сборка всего завалится с StackOverflow ошибкой:

Так же можно добавить в .bashrc чтобы постоянно не повторять команду

Все, теперь готовы к сборке:

Можно не использовать CCACHE, что уменьшит количество занимаемого места на диске, но увеличит время повторной сборки. На моем «слабом» компьютере сборка заняла где-то 16 часов.

После окончания сборки, запускаем эмулятор:

-show-kernel — выводить уведомления в консоль

Если нажать Enter, то попадем в консоль эмулятора

Если эмулятор не запустился, нужно будет проверить что включена виртуализация

Готовим IDE для отладки

Для начала необходимо сгенериовать проект для IDE, проект генерируется для IDEA. Собираем модули для генератора:

Чтобы весь AOSP затолкать в проект, то просто запускаем генератор

Но сгенерированный IDEA проект будет очень «тяжелым». Одно открытие и индексация занимает достаточно много времени. Лучше генерировать IDEA проект для каждого отдельного проекта, например для Android фреймворка

Весь список доступных проектов можно посмотреть в

Открываем сгенерированный base.iml (находится в папке frameworks/base) в IDEA. Дальше нужно настроить Java, только нужно подключать java без библиотек, так как у AOSP-а свои реализации.

Запускаем отладку

Для начала необходимо запустить monitor

возможно потребуется дополнительно поставить jre
sudo apt install openjdk-8-jre-headless

Выбираем процесс, который будем отлаживать. В monitor-е выбираем процесс и справа от порта процесса появится /8700, это как раз порт отладчика, к нему можно подключаться через IDEA.
Все системные штуки находятся в system_process. Его мы и будем отлаживать.

monitor один самых полезных инструментов при отладке и исследования работы AOSP

В проекте добавляем новую Remote конфигурацию, только указываем 8700 порт. Именно к этому порту и будем подключаться

Запускаем Debug (Run → Debug)

Чтобы удостоверится, что все подключилось поставьте брейкпоинт в frameworks/base/services/core/java/com/android/server/wm/ActivityTaskManagerService.java файле на метод:

и запустить любое приложение на эмуляторе (например, Settings).

Источник

[TUTORIAL/DEV]Build AOSP Android 2.3.7 for Allwinner A10 tablets (Teclast P76Ti)

sztupy

Inactive Recognized Developer

I haven’t really found any kind of guides on how to build a complete AOSP android build from source (kernel and software) for Allwinner A10 tablets like the Ainol Novo 7 Advanced or the Teclast P76Ti.

I have a Teclast P76TI (rev4), and the following guide is only tested on such a device. As it’s mostly based on the source drop of the Ainol Novo 7 Advanced, it should also work on that too.

sztupy

Inactive Recognized Developer

Part 1: Preparations

For building and creating a LiveSuite flashable package you will need the following:

  • For building the kernel and android you will need a 64 bit Linux machine. Ubuntu 10.04 64 bit is preferred for Gingerbread builds
  • For creating the LiveSuite flashable images, and actually flashing you will need a Windows machine. Windows 7 x64 works fine, as should Windows XP 32 bit too.
  • You will also need a working LiveSuite image file, for your tablet. Make sure that you can flash it to your device without problems!
Читайте также:  Спутниковый адаптер для андроид

Virtual machines are fine, if you have enough memory available. To build Android in a VM, you should give it at least 2GB of RAM. Alternatively if you’re using Linux, you can create a Windows VM for the image creation or flashing part.

For the rest of the tutorial I will assume you are using a Linux Virtual Machine on a Windows box.

For building the kernel and AOSP you will need at least 35GB of free space in your linux machine (the more the better). To create the images you will need an additional 2GB of space on your Windows machine.

B: Getting the kernel and AOSP sources

First initialize your Linux machine according to this page: http://source.android.com/source/initializing.html

Here are the most important commands:

Now create a directory on your linux machine. The path should contain no spaces in it. Inside this directory first pull the kernel source from the allwinner github page:

Make sure that the kernel resides in the lichee directory

Now download AOSP Android. We will use Gingerbread version 2.3.7:

Allwinner uses a special init, which has a few additional commands that you have to download too:

You will also need the device descriptors for the tablets:

You might simply use a compiler that is supplied for AOSP, they are inside the android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/ directory. Alternatively you can also download the ARM compiler of CodeSourcery. Get the arm-2009q3 / arm-none-linux-gnueabi version, and unpack it inside a directory.

If ready, go on to next step: building the kernel

sztupy

Inactive Recognized Developer

Part 2: Building the kernel

Change to the directory of the kernel. Now edit the file scripts/build_sun4i_crane.sh

Change the line «export CROSS_COMPILE=» to point to the ARM compiler. For example if you extracted the CodeSourcery files to /opt then use:

The default .config file is more or less the same that is supplied with your tablet. On the Teclast P76TI you can actually extract the .config file used from /proc using «adb pull /proc/config.gz» Not sure about other vendors.

Now you have to compile. Issue the command:

This will build the kernel and modules inside the the «output» directory.

Next step is to compile Android

sztupy

Inactive Recognized Developer

Part 3: Building Android

Go to the android directory. Now setup android using:

Here select your device (option 6 or 7 depending on your tablet)

After you have selected it issue a make command:

This will take a while. If you’re using ubuntu 11.10 make might fail, but you can fix it using these fixes: http://groups.google.com/group/android-building/browse_thread/thread/3484e7797909d014

After the building is complete you have to create the image files. Run the following command:

(substitute tcp76ti_r4 with ainovo7a if you’re using the other tablet)

The image files will be ready in the directory «out/target/product/crane-tcp76ti_r4/images/» or «out/target/product/crane-ainovo7a/images/»

Copy the three files from here (root.img, recovery.img, system.img), and the «bImage» file from the «output» directory of the kernel to your Windows machine.

The next step is creating the flashable image, and flashing your build

sztupy

Inactive Recognized Developer

Part 4: Flashing

A: Initialize kitchen

First download my A10 flash kitchen from this site: http://android.sztupy.hu/dl/a10/a10_flash_kitchen_v1.zip
This is based on the ainol novo 7 soruce drop, but only contains the nescessary files, and has a few batch scripts to automate the process.
There is also a v2, wich also supports ICS firmwares: http://android.sztupy.hu/dl/a10/a10_flash_kitchen_v2.zip

First unzip the files to a directory. You will see a few directories and to commands here: extract_image.bat and create_image.bat

First we have to extract an official image for your tablet. Simply comply the image file to this directory, and rename it to «original.img». If done, run extract_image.bat. This command should extract your image to the _extract directory.

Next you need to extract the bootfs inside the _bootfs directory. You have multiple options on how to do this:

1. Get the bootfs from your device on-line using adb:

2. Get the bootfs from the extracted image file using Linux:

A. Copy the RFSFAT16_BOOTFS_000000000.fex file to linux
B.

C. Copy the contents of the b2 directory to Windows, inside the _bootfs directory of the kitchen

If you have initialized the kitchen, you have to copy the four files from linux (system.img, root.img, recovery.img and bImage) inside the _input directory. You will also need to rename the .img files to .fex (so they should be system.fex, root.fex, recovery.fex).

If you are done with this, then run create_image.bat. It will create an output.img file, that can be flashed to the device using LiveSuite.

sztupy

Inactive Recognized Developer

Additional information for developers:

1. Difference between AOSP 2.3.4 and Novo7 android 2.3.4

fonix232

Senior Member

sztupy

Inactive Recognized Developer

Yeah, saw that. Also their build script used «convert» on the image.cfg, but that file wasn’t in lua anyway (except for the image parts part which seems to be a lua hash).

There are also a lot of compiled files that are compiled inside the image file and which are neither the bootfs nor android or the kernel. I don’t yet know what they are for, but I think they are used by LiveSuite during the flashing.

fonix232

Senior Member

Yeah, saw that. Also their build script used «convert» on the image.cfg, but that file wasn’t in lua anyway (except for the image parts part which seems to be a lua hash).

Читайте также:  Стандартные звуки будильника андроид

There are also a lot of compiled files that are compiled inside the image file and which are neither the bootfs nor android or the kernel. I don’t yet know what they are for, but I think they are used by LiveSuite during the flashing.

I know most of the files from the flashing, they are the following:
— SYS_CONFIG is used as a command bunch for LiveSuite. It tells the app how to flash, what to flash, where, and it configures the device too (screen size, ram info, cpu info, etc)
— Boot0 and Boot1 bins are NAND bootloaders
— FED FES and FET tools are NAND flashing utilities, checksums, hardware scanner, and other tools used during flashing.
— ‘12345678’ files are bootloaders, config files, and tools for SDMMC flashing, if there’s a device with SDMMC internal instead of NAND, these are used
— Split seems to be some kind of ID string, I had no luck retrieving it’s usage and meaning.

So you say, that the actual Lua parts are the image encryption parts of eDragonEx? Interesting, maybe I’ve missed that spot with my tool.

Источник

[TUTORIAL/DEV]Build AOSP Android 2.3.7 for Allwinner A10 tablets (Teclast P76Ti)

telerian

Senior Member

sztupy

Inactive Recognized Developer

db260179

Member

Compiling the kernel should be ok, as it is the same source for all a10 tablets.

I’ve attempted a fresh kernel and android source build.

On my sysbay MP98 (same as onda vi30) there must of been custom code added to the goodix source and mma7660 gsensor as I cant get the touch screen/gsensor to work.

So a custom android source is the only thing working correctly at the moment.

telerian

Senior Member

sztupy

Inactive Recognized Developer

Compiling the kernel should be ok, as it is the same source for all a10 tablets.

I’ve attempted a fresh kernel and android source build.

On my sysbay MP98 (same as onda vi30) there must of been custom code added to the goodix source and mma7660 gsensor as I cant get the touch screen/gsensor to work.

So a custom android source is the only thing working correctly at the moment.

In the released code the gsensor works by using a service called «memsicd». There are some tablets which do not use this memsicd service (like the LY-F1)

Touch screens are also different on tablets. Goodix is used on some of them and F5TX is used on others. LY-F1 uses F5TX, so goodix drivers will not work on it.

sztupy

Inactive Recognized Developer

telerian

Senior Member

Sorry for asking a lot but am a bit of a newbie on Android dev but I did a lot of modding and compiling on Linux (Redhat/Fedora)

Do you mean I download a stock kernel from kernel.org or there is a 3.0.8 kernel from Allwinner ?

If I get a stock 3.0.8 and compile bluetooth, bluetooth USB modules (bluetooth.ko and btusb.ko) and bluetoothd and move those to the tablet without changing the kernel on the tablet would that work ?

sztupy

Inactive Recognized Developer

Sorry for asking a lot but am a bit of a newbie on Android dev but I did a lot of modding and compiling on Linux (Redhat/Fedora)

Do you mean I download a stock kernel from kernel.org or there is a 3.0.8 kernel from Allwinner ?

If I get a stock 3.0.8 and compile bluetooth, bluetooth USB modules (bluetooth.ko and btusb.ko) and bluetoothd and move those to the tablet without changing the kernel on the tablet would that work ?

There is no released 3.0.8 allwinner kernel yet, so yes, download one from kernel.org

It might be, though you might need to tweak some configs in the kernel

telerian

Senior Member

There is no released 3.0.8 allwinner kernel yet, so yes, download one from kernel.org

It might be, though you might need to tweak some configs in the kernel

naydimme

Member

Hi, first of all thanks for all your work and help.

I own an A10 based tablet, similar to Ainol Novo 7 Advanced. 7″, capacitive, with capacitive buttons for home, apps and back. It has just one front facing camera.

I’ve tried several ICS firmwares for MOMO ployer, Ainol Novo 7 Advanced, LY FY, Teclast, etc. but the best I have is firmware loading, running correctly but no wifi or camera support. Brightness isn’t working either.

With another firmware I managed to make wifi work, but camera keeps force closing and the touchscreen is inverted.

So, I would like to know if I could combine drivers from different firmwares and make everything work correctly.

sztupy

Inactive Recognized Developer

Hi, first of all thanks for all your work and help.

I own an A10 based tablet, similar to Ainol Novo 7 Advanced. 7″, capacitive, with capacitive buttons for home, apps and back. It has just one front facing camera.

I’ve tried several ICS firmwares for MOMO ployer, Ainol Novo 7 Advanced, LY FY, Teclast, etc. but the best I have is firmware loading, running correctly but no wifi or camera support. Brightness isn’t working either.

With another firmware I managed to make wifi work, but camera keeps force closing and the touchscreen is inverted.

So, I would like to know if I could combine drivers from different firmwares and make everything work correctly.

Yes you can, here are some guidelines I used:

First get a kernel where the hardware buttons work as they are not compiled as modules in ICS (so you can’t load them later). It is preferred that the FW you use should have a working wifi too (at least the /system partition).

Читайте также:  Android permission get account

Next try to find an original FW release for your hardware (it’s fine if it is only gingerbread), and unpack it using the tools. You can find all hardware parameters inside the script.bin and script0.bin files. There is a ruby tool inside the imagesuite directory that can decompile those files.

The ICS firmware should have an already decompiled sys_config1.fex in one of it’s partitions after you run unimg. Edit it, and search for differences (csi0, csi1 are the camera drivers, ctp is the touch screen driver, if those don’t work, simply replace these parameters)

Next recompile this file (using script.exe), and replace script0.bin and script.bin with the compiled file inside the bootfs. Replace the other partitions at will. Re-create the image using the second A10 kitchen I released.

You might also need to copy the system/lib/hw directory from a working ICS or GB ROM. (ICS is preferred)

debugger1024

New member

Part 2: Building the kernel

Change to the directory of the kernel. Now edit the file scripts/build_sun4i_crane.sh

Change the line «export CROSS_COMPILE=» to point to the ARM compiler. For example if you extracted the CodeSourcery files to /opt then use:

The default .config file is more or less the same that is supplied with your tablet. On the Teclast P76TI you can actually extract the .config file used from /proc using «adb pull /proc/config.gz» Not sure about other vendors.

Now you have to compile. Issue the command:

This will build the kernel and modules inside the the «output» directory.

Next step is to compile Android

hi, i am new to this.
may i know where is the ‘output’ directory that you are referring to?
i only able to find the zImage in arch/arm/boot/zImage, and where can i get the ‘bImage’ that you mentioned?

and i am using Allwiner Novo 7 Elf with A10, ICS 4.0.3 and kernel version 3.0.8, do you think i can downgrade it as per your guideline?

Senior Member

sztupy

Inactive Recognized Developer
Senior Member

you’re talking about AOSP ICS, right?

CyanogenMod has some codes to use legacy environment. I’m using Mali related files from GB ROM with «-DMISSING_EGL_EXTERNAL_IMAGE -DMISSING_EGL_PIXEL_FORMAT_YV12». you can pick necessary changes from CM9 source for AOSP ICS.

I forgot detail(sorry) but probably gralloc needs to be cared too. gralloc from GB ROM will be crashed by SIGFPE, then you’ll need to recompile gralloc from source with some change.
or you can pick working gralloc binary from my CM9 zip which originates from some ICS ROM.

some tweaks are also necessary for audio, wifi, vibrator, touchscreen, USB, and so on.

to explain everything is difficult because actual work was done by CM guys in most cases, but I can answer something about my CM9 files.

naydimme

Member

Yes you can, here are some guidelines I used:

First get a kernel where the hardware buttons work as they are not compiled as modules in ICS (so you can’t load them later). It is preferred that the FW you use should have a working wifi too (at least the /system partition).

Next try to find an original FW release for your hardware (it’s fine if it is only gingerbread), and unpack it using the tools. You can find all hardware parameters inside the script.bin and script0.bin files. There is a ruby tool inside the imagesuite directory that can decompile those files.

The ICS firmware should have an already decompiled sys_config1.fex in one of it’s partitions after you run unimg. Edit it, and search for differences (csi0, csi1 are the camera drivers, ctp is the touch screen driver, if those don’t work, simply replace these parameters)

Next recompile this file (using script.exe), and replace script0.bin and script.bin with the compiled file inside the bootfs. Replace the other partitions at will. Re-create the image using the second A10 kitchen I released.

You might also need to copy the system/lib/hw directory from a working ICS or GB ROM. (ICS is preferred)

Thanks for your help, I’m starting to follow your steps, but I have some doubts:

First get a kernel where the hardware buttons work as they are not compiled as modules in ICS (so you can’t load them later). It is preferred that the FW you use should have a working wifi too (at least the /system partition).

The only working (everything, camera, wifi, buttons, touchscreen. ) firmware I have for my tablet is a Gingerbread one, it’s running kernel 2.6.36

Next try to find an original FW release for your hardware (it’s fine if it is only gingerbread), and unpack it using the tools. You can find all hardware parameters inside the script.bin and script0.bin files. There is a ruby tool inside the imagesuite directory that can decompile those files.

I’ve got an original GB release. If I use unimg I get an error saying that this is not a valid win32 application.

Anyway, I have an already unpacked image from another PC, using directly the tool unimg, from a Novo advanced ICS ROM, but I can’t find sys_config1.fex. Is it located in _SYS_CONFIG000000.hdr. How can I look into that partition. The image has this structure:

Источник

Оцените статью