Sunday, 17 March 2019

Notes taken during Android BSP porting

How to set cross compile path?

export ARCH=arm
export PATH=$PATH:/u/mini2440/opt/FriendlyARM/toolschain/4.4.3/bin/
export CROSS_COMPILE=arm-none-linux-gnueabi-
You need to run

cd $HOME
source .bashrc   > it update and load bashrc
gedit .bashrc > to see it’s content
echo $PATH > to confirm your update


Where android starts?
[Oreo/imx-o8.0.0_1.0.0_ga/android_build/system/core/init]
int main(int argc, char** argv)

/u/androidporting/Oreo/imx-o8.0.0_1.0.0_ga/android_build/device/fsl/imx6
For all the make file.

Bitbake - build system

Underoid android BSP, we have so many folder. Tell me the purpose of each folder?
1. abi - This folder contains a sub folder called cpp which actually contains many C++ files linked to many places.

2. android
repo init -u git://github.com/CyanogenMod/android.git
Yes, it's that android.git folder.

3. art - Yeah, it is the folder that deals with the compilation of the latest android ART runtime. If you're looking into source directories of some other android versions, you won't fins it obviously.

4. bionic - Bionic is mainly a port of the BSD C library to our Linux kernel with the following additions/changes:
- No support for locales.
- No support for wide chars (i.e. multi-byte characters).
- its own smallish implementation of pthreads based on Linux futexes.
- Support for x86, ARM and ARM thumb CPU instruction sets and kernel interfaces.

5. bootable - Boot and startup related code. Some of it is legacy, the fastboot protocol info could be interesting since it is implemented by boot loaders in a number of devices such as the Nexus ones.

6. build - The main entry point of the build system resides here - envsetup.sh, if you follow the instruction in source.android.com you will see that the first step before you do anything to build Android is to use the command source build/envsetup.sh
The script will check few things to make sure all the needed application available in the local machine. It also setup the devices that can be built, which is extracted from the directory device.

7. cts - the compatibility tests. The test suite to ensure that a build complies with the Android specification.

8. dalvik - This is the folder responsible for the compilation of the Dalvik runtime for the Android devices.
*Have a look at the difference between the two(art and dalvik) folders and you'll have an idea of how things work in that case*
9. Development - This directory contains application that are not part of the deployed app in the OS. There are some useful application such as widget builder, etc

10. Device - It contains the device specific configurations for many devices.
Note - Many people ask me what, the folders like 'common' and 'generic are for, so here -

> common - This directory contains gps information and also a script that allows you to extract proprietary binary files from your phone to be part of the build process.(You can try to have a look at your device's device tree and then the cm.mk file, where you could find relations of these files. In my case, it shows like this:
Code:
# Include GSM stuff
$(call inherit-product, vendor/cm/config/gsm.mk)
-and-
# Inherit some common cyanogenmod stuff.
$(call inherit-product, device/common/gps/gps_eu_supl.mk)
> generic - This directory contains the generic device configuration that is called ‘goldfish’. This is the device classification used when building the emulator.

> Google - This directory contains the Android Accessories Kit code. It contains a demokit Android app that allows you to control the ADK board. The ADK firmware can be check out here http://code.google.com/p/microbridge/. There is a good article about this here.

> sample - This directory contains a full example of writing your own Android platform shared library, without changing the Android framework. It also shows how to write JNI code for incorporating native code into the library, and a client application that uses the library. This example is ONLYfor people working with the open source platform to create a system image that will be delivered on a device which will include a custom library as shown here. It can not be used to create a third party shared library, which is not currently supported in Android.

11. docs - I contains an important sub-folder called source.android.com. Contains tutorials, references, and miscellaneous information relating to the Android Open Source Project (AOSP). The current iteration of this site is fully static HTML (notably lacking in javascript and doxygen content), and is and/or was maintained by skyler (illustrious intern under Dan Morrill and assistant to the almighty JBQ).

12. external - This directory contains source code for all external open source projects such as SQLite, Freetype, webkit and webview.

13. frameworks - Ah, one of the most important directories. it contains the sources for the framework. Here you will find the implementation of key services such as the System Server with the Package- and Activity managers. A lot of the mapping between the java application APIs and the native libraries is also done here.
A special note on this one - I'd recommend new users to not to play with any file/folder inside the frameworks folder, maybe your ROM doesn't boots then.

14. hardware - Hardware related source code such as the Android hardware abstraction layer specification and implementation. This folder also contains the reference Radio Interface Layer(RIL - To communicate with the modem side) implementation.

15. Kernel - It's not a default folder in the source code, but it's a part of device configuration set-up. It contains the kernel source of your device.

16. libcore - I'll explain this one with the important folders inside this, since every folder performs a different function.
  • dalvik - DalvikVM runtime for Android
  • dom - Java test classes for DOM
  • expectations - Contains information about the test cases
  • include - Some C/C++ include files that used for Array and String handling
  • json - JSON based Java implementation
  • luni - Contains test source code for loading .jar and .dex files
  • support - Contains support class file for testing Dalvik
  • xml - XML pull and push implementation

17. libnativehelper - I have no idea on this one. If someone knows, share your knowledge.

18. ndk - Contains build scripts and helper files for building the NDK
19. out(Everyone's favorite directory) - The build output will be placed here after you run make. The folder structure is out/target/product/. In the default build for the emulator the output will be placed in out/target/product/generic. This is where you will find the images used by the emulator to start (or to be downloaded and flashed to a device if you are building for a hardware target).

20. packages - Standard Android application that are available as part of the AOSP - Camera, SMS, Dialer, Launcher, etc

21. pdk - I believe that 'pdk' is the Platform Development Kit, it's basically an SDK/set of tools that Google sends to OEMs to evaluate their framework ahead of each major Android upgrade since Android 4.1.

22. prebuilt - Contains files that are distributed in binary form for convenience. Examples include the cross compilations toolchains for different development machines.

23. sdk - This directory contains lots of apps that are not part of operating system. There are quite useful apps that developers can leverage on and can be enhanced further as part of the operating system.

24. system - Source code files for the core Android system. That is the minimal Linux system that is started before the Dalvik VM and any java based services are enabled. This includes the source code for the init process and the default init.rc script that provide the dynamic configuration of the platform.

25. tools - Some external important tools that help in compiling. Not sure though. :/

26. vendor - This directory contains vendors specific libraries. Most of the proprietary binary libraries from non-open source projects are stored here when building AOSP


Why am I here?
  1. How to port other root fs to my android terminal?
  2. How to configure a GPIO PIN?


What is root file system?
First part is uds - unix directory structure. mkdri
2. Device nodes : represents also known as sudo file system - > files are handled by major number. - mknode (/dev)
Scripts - editor
Bin - (ls, cd, linux command)
Lib - (compilation library)

What is busybox and what is it’s use case?
Busybox is program able to run any linux command. It has strip down version of veevry command. Terminal having low memory need less app so that it can run successfully.



Which all folders are important for modifying any code or hardware behaviour?
Arch folder and driver folders are BSP folder. Most of the changes need to be here.

kernel_imx/kernel - is actually written by linus. All scheduler and other are writtenten there.

Where in code kernel starts?
kernel_imx/init > main.c > start_kernel() > setup_arch() - calls imx6q_init_machine in board file.

Where is the board file?
kernel_imx/arch/arm/mach-imx/mach-imx6q.c
DT_MACHINE_START(IMX6Q, "Freescale i.MX6 Quad/DualLite (Device Tree)")
    .l2c_aux_val     = 0,
    .l2c_aux_mask    = ~0,
    .smp        = smp_ops(imx_smp_ops),
    .map_io        = imx6q_map_io,
    .init_irq    = imx6q_init_irq,
    .init_machine    = imx6q_init_machine,
    .init_late      = imx6q_init_late,
    .dt_compat    = imx6q_dt_compat,
MACHINE_END

System Processes are in bracket. First thread is kthreadd.

Process id
1 ?        Ss 0:02 /sbin/init splash

How to know which one is first process or thread?
static noinline void __ref rest_init(void)
{
    int pid;

    rcu_scheduler_starting();
    /*
    * We need to spawn init first so that it obtains pid 1, however
    * the init task will end up wanting to create kthreads, which, if
    * we schedule it before we create kthreadd, will OOPS.
    */
    kernel_thread(kernel_init, NULL, CLONE_FS);
    numa_default_policy();
    pid = kernel_thread(kthreadd, NULL, CLONE_FS | CLONE_FILES);

}


Final file is vmlinux.

Kernel boot strap unzip the kernel and is part of zImage.
uImage has uboot speacific header
zImage has kernel boot strap in piggi zip kernel image

Bootm process the boot hearder in os image





rest_init(void) [main.c] > kernel_init(void *unused) [main.c] > try_to_run_init_process("/sbin/init") [main.c] >

What is little kernel?
Little Kernel is the boot loader that performs the basic tasks of hardware initialization,
reading the Linux kernel and ramdisk from storage and loading it up to RAM, setting up initial registers and command line arguments for the Linux kernel, and jumps to the kernel. LK is based on the open source project on www.kernel.org.

What is the respective function or folder while using uboot?

Source
Physical component type
Physical component
u-boot-imx/arch/arm/cpu/
Arch
armv7
Core
Arm cortex a9
mach-<soc>
u-boot-imx/arch/arm/imx-common
soc
imx6

u-boot-imx/board/phytec/pcm058
som
phycore-imx6

sbc
Phy board mira




Pcm058.c is main file.

Pending:

Where is device tree file??
device tree is a set of text files in the Linux kernel source tree that describe the hardware of a certain platform. It is located at arch/arm/boot/dts/ and can have two extensions:
  • *.dtsi files are device tree source include files. They describe hardware that is common to several platforms which include these files on their *.dts files.
  • *.dts files are device tree source files. They describe one specific platform.


U_BOOT_CMD help us create new command

1973  scp /sbin/udhcpc ganesh@192.168.1.249:/sbin/udhcpc
1974  sudo scp /sbin/udhcpc ganesh@192.168.1.249:/sbin/udhcpc
1975  ssh-keygen -f "/root/.ssh/known_hosts" -R 192.168.1.249
1976  sudo ssh-keygen -f "/root/.ssh/known_hosts" -R 192.168.1.249
1977  sudo scp /sbin/udhcpc ganesh@192.168.1.249:/sbin/udhcpc
1978  sudo scp /sbin/udhcpc ganesh@192.168.1.249:~/
1979  ssh ganesh@192.168.1.10
1980  ssh ganesh@192.168.1.2
1981  exit
1982  ssh kishore@192.168.1.29
1983  cd ganesh/
1984  ls
1985  cd sam/
1986  ls
1987  vi imx_sim.c
1988  sudo poweroff
1989  sudo apt-get install bluez
1990  ssh ganesh@192.168.1.10
1991  ssh ganesh@192.168.1.2
1992  sudo minicom
1993  ssh ganesh2192.168.1.1
1994  ssh ganesh@192.168.1.1
1995  ls
1996  cd Desktop/mukesh/
1997  tar -xvf arm-cortexa9-linux-gnueabihf.tar.bz2
1998  tar -xvf kernel_imx.tar.gz
1999  ls
2000  cd Desktop/mukesh/
2001  ls
2002  tar -xvf u-boot-imx.tar.gz
2003  sync
2004  cd u-boot-imx/
2005  ls
2006  cd ..
2007  cd u-boot-imx/
2008  ls
2009  cd arch/
2010  ls
2011  ls arm/
2012  cd arm/imx-common/
2013  ls
2014  cd ..
2015  ls
2016  ls cpu/
2017  ls mach-
2018  ls mach-tegra/
2019  cd ../..
2020  cd board/phytec/
2021  ls
2022  cd pcm058
2023  ls
2024  cd ..
2025  cd cmd/
2026  ls
2027  vi tftp.
2028  vi net.c
2029  cd ..
2030  cd configs/
2031  ls
2032  cd ..
2033  make pcm
2034  ls
2035  vi Makefile
2036  make distclean
2037  make pcm058_defconfig
2038  make
2039  make distclean
2040  sudo make distclean
2041  make clean
2042  make distclean
2043  make pcm058_defconfig
2044  make
2045  cd ..
2046  ls
2047  tar -xvf arm-cortexa9-linux-gnueabihf.tar.bz2
2048  cd arm-cortexa9-linux-gnueabihf/
2049  cd gcc-4.7.3-glibc-2.16.0-binutils-2.22-kernel-3.0.35-sanitized/bin/
2050  pwd
2051  cd ../../..
2052  vi envsetup.sh
2053  . envsetup.sh
2054  make clean
2055  cd u-boot-imx/
2056  make clean
2057  make distclean
2058  sudo apt-get install u-boot-tools
2059  make pcm058_defconfig
2060  make

How to configure cross compiler for Uboot build?
Please follow the commands below:

2047  tar -xvf arm-cortexa9-linux-gnueabihf.tar.bz2
2048  cd arm-cortexa9-linux-gnueabihf/
2049  cd gcc-4.7.3-glibc-2.16.0-binutils-2.22-kernel-3.0.35-sanitized/bin/
2050  pwd
2051  cd ../../..
2052  vi envsetup.sh
2053  . envsetup.sh
2054  make clean
2055  cd u-boot-imx/
2056  make clean
2057  make distclean
2058  sudo apt-get install u-boot-tools
2059  make pcm058_defconfig
2060  make


For kernel understanding:

1990  cd Desktop/mukesh/
1991  tar -xvf arm-cortexa9-linux-gnueabihf.tar.bz2
1992  tar -xvf kernel_imx.tar.gz
1993  ls
1994  cd ..
1995  tar -xvf kernel_imx.tar.gz
1996  ls
1997  rm -rf kernel_imx
1998  ls
1999  exit
2000  cd /media/kishore/KISHORE/
2001  ls
2002  tar -xvf kernel_imx.tar.gz
2003  cd kernel_imx/
2004  ls
2005  cd arch/arm/mach-
2006  cd arch/arm/mach-imx/devices/
2007  ls
2008  cd ..
2009  ls
2010  vi imx35-dt.c
2011  vi imx6sl_low_power_idle.S
2012  ls
2013  vi mach-imx6q.c
2014  cd..
2015  cd ..
2016  ls
2017  cd configs/
2018  ls
2019  vi mira_oreo_defconfig
2020  history


How do we configure io pin in Linux in Uboot?
Use the function imx_iomux_v3_setup_multiple_pads to understand it better.

What are important file in arch/arm/kernel?
Head.s and head-common.s

What are important file in arch/arm/plat-<soc_family>?

arch/arm/mach-<soc-family> is for sytem on module file.

What is arch/arm/dtc

What is dts file?

What is Data structure file? Device tree.
In the Linux kernel source tree, there are .dts (i.e., device tree source) and .dtsi (i.e., device tree source include).
.dtb is the binary form of the .dts in a similar sense what a binary executable is to an assembly source:
arm/arch/boot/dts file is configure your devices with various settings
arm/arm/mach<som name> for SOM file in kernel

Drivers
/gpio
/i2c
/spi
/usb
/net

What kind of Driver type in linux?
Bus driver - gpio - mdd in windows
Device driver or client driver -

Under linux what is diff between platform driver and device?



What is Android booting steps?
Below are the steps:
  1. Power on
  2. Soc boot rom code(BRC) get executed and check for boot config pins
  3. BRC loads primary boot Loader PBL or Device Configuration Data DCD
  4. PBL loads BL
  5. BL loads Kernel
  6. Kernel mounts RFS drive
  7. Execute the init process
  8. Init process follow RC script. RC -

What is DCD and what is it’s benefit? Can we use everywhere?
It Initialize DDR controller registers. The code is simple instruction and It is part of header of boot loader. Not all SoC vendor support it.

What is PBL and what is the purpose?
PBL is small size boot loader and responsible to init ddr ram and flash. It gets copy to internal ram of soc and then gets executed. It can be part of main boot loader of separate boot loader.

How to see all boot messages from embedded linux board?
Please follow the steps below:
  1. Install minicom using “sudo apt-get install minicom
  2. Run sudo minicom -s
  3. Configure Baudrate, USB device or serial device.
  4. Run the command boot



What is device tree and how it different?

I have seen GPIO file where once input is changes, file gets value? Why it is so? Explain.

What is barebox and uboot? How they are different? How barebox is different from uboot and special use cases?
Barebox support many filesystem while uboot doesn’t support. The embedded linux community has  strong sup[port for barebox hence it is preferred. Most of the file system code in barebox is taken from kernel source hence it easy to understand it.


What is zimage and why it is named like that? What it contain?
It has all packages, drivers.

How to conenct to TFTP and what is the use case?
Run the following command
  1. ssh loseronlyme@192.168.1.117 and enter remote terminal password
  2. Go to folder from which file needs to be copied
  3. scp -r *  ee207885@192.168.1.118:~/ , enter host terminal password
What all command run for Oreo BSP compilation?

Please follow the command below:
619  ls
 620  cd imx-o8.0.0_1.0.0_ga/android_build/
 621  source build/envsetup.sh
 622  lunch
 623  make clean
 624  make -j6
 625  jack-diagnose
 626  vi $HOME/.jack-server/config.properties
 627  prebuilts/misc/linux-x86/ccache/ccache -M 50G
 628  export USE_CCACHE=1
 629  prebuilts/misc/linux-x86/ccache/ccache -M 50G
 630  make -j6
 631  vi external/v8/src/heap/heap.cc
 632  jack-admin start-server
 633  sudo apt-get  install openjdk-8-*
 634  sudo apt-get install jack-tools
 635  sudo apt-get  install openjdk-8-*
 636  make -j4
 637  prebuilts/sdk/tools/jack-admin stop-server 2>&1 > /dev/null
 638  prebuilts/sdk/tools/jack-admin cleanup-server 2>&1 > /dev/null
 639  prebuilts/sdk/tools/jack-admin start-server 2>&1 > /dev/null
 640  sudo apt-get install libjack-dev
 641  jack-admin start-serve
 642  ls
 643  cd out/
 644  ls
 645  cd target/product/sabresd_6dq/
 646  ls
 647  cd ../../
 648  ls
 649  cd prebuilts/sdk/tools/
 650  ls
 651  cd li
 652  cd lib/
 653  ls
 654  cd ..
 655  ls
 656  cd jills/
 657  ls
 658  cd ..
 659  ls
 660  vi mainDexClasses
 661  ls
 662  vi jack_for_module.mk
 663  vi Android.mk
 664  mma
 665  cd ../../
 666  cd ../
 667  make -j6
 668  vi /home/ee207885/.jack-server
 669  vi /home/ee207885/.jack-server/client.
 670  vi /home/ee207885/.jack-server/client.pem
 671  vi /home/ee207885/.jack-server/server.pem
 672  vi /home/ee207885/.jack-server/config.properties
 673  vi prebuilts/sdk/tools/jack-admin
 674  vi /home/ee207885/.jack-server/config.properties
 675  make -j6l
 676  make -j6
 677  cd out/target/product/sabresd_6dq/

No comments:

Post a Comment