Difference between revisions of "User:NicolasD"
m (→Copying the Android root filesystem) |
|||
Line 1: | Line 1: | ||
− | Désolé de pourrir les ' | + | Désolé de pourrir les 'recent changes' :) |
==Truc utile== | ==Truc utile== | ||
− | + | ===GRUB sur clé USB=== | |
− | + | Voici une petite astuce pour : | |
− | ''Attention, l'ordre des actions est important'' | + | * ne plus perdre GRUB lors de la réinstallation de Windows |
+ | * ne plus avoir accès à Windows après l'installation de Linux | ||
+ | * rendre inaccessible la partition Linux sur votre machine | ||
+ | L'astuce est d'installer '''que''' GRUB sur une clé USB. '''Attention, l'ordre des actions est important''' | ||
* Formatter la cle USB en fat32 (gparted) | * Formatter la cle USB en fat32 (gparted) | ||
* Récuperer la liste des disques monter ainsi que leur ID | * Récuperer la liste des disques monter ainsi que leur ID | ||
Line 26: | Line 29: | ||
</pre> | </pre> | ||
* Mettre le flag boot sur la cle USB (gparted) | * Mettre le flag boot sur la cle USB (gparted) | ||
− | + | ===make gconfig=== | |
+ | installer les bibliothèques pour lancer make gconfig | ||
+ | <pre class="host"> | ||
+ | sudo apt-get install libgtk2.0-dev libglib2.0-dev libglade2-dev | ||
+ | </pre> | ||
==Banc à sable== | ==Banc à sable== | ||
+ | Ce qui suit n'est qu'un brouillon avec les fautes de frappes et d'orthographe comme il se doit. | ||
==Prerequisites for Linux installation== | ==Prerequisites for Linux installation== | ||
===Install needed software packages=== | ===Install needed software packages=== | ||
− | + | Install these package for build the kernel image and for format the mmc/µSD card | |
<pre class="host"> | <pre class="host"> | ||
− | $ sudo apt-get install uboot-mkimage | + | $ sudo apt-get install uboot-mkimage mtd-utils |
</pre> | </pre> | ||
===Update the environment variables=== | ===Update the environment variables=== | ||
Line 45: | Line 53: | ||
export PATH=${PATH}:${ANDROID_SDK}/tools:${ANDROID_SOURCE}/bin | export PATH=${PATH}:${ANDROID_SDK}/tools:${ANDROID_SOURCE}/bin | ||
</pre> | </pre> | ||
− | |||
==Construction of Android environment== | ==Construction of Android environment== | ||
===Download Android source=== | ===Download Android source=== | ||
Line 94: | Line 101: | ||
$ cp ./arch/arm/boot/uImage $TFTPBOOT/apf27-linux.bin | $ cp ./arch/arm/boot/uImage $TFTPBOOT/apf27-linux.bin | ||
</pre> | </pre> | ||
− | |||
==Making SD card for boot== | ==Making SD card for boot== | ||
===Copying the Android root filesystem=== | ===Copying the Android root filesystem=== | ||
Line 100: | Line 106: | ||
<pre class="host"> | <pre class="host"> | ||
$ cd $ANDROID_SOURCE/out/target/product/generic | $ cd $ANDROID_SOURCE/out/target/product/generic | ||
− | $ mkdir $ANDROID_SOURCE/rootfs (or ' | + | $ mkdir $ANDROID_SOURCE/rootfs (or '$ sudo rm -rf $ANDROID_SOURCE/rootfs/*' if the folder already exist ) |
$ cp -a root/* $ANDROID_SOURCE/rootfs/ | $ cp -a root/* $ANDROID_SOURCE/rootfs/ | ||
$ cp -a system/* $ANDROID_SOURCE/rootfs/system/ | $ cp -a system/* $ANDROID_SOURCE/rootfs/system/ | ||
Line 107: | Line 113: | ||
$ sudo chmod -R a+rwX data system | $ sudo chmod -R a+rwX data system | ||
</pre> | </pre> | ||
− | |||
===Change init.rc=== | ===Change init.rc=== | ||
− | + | To do!!!! | |
− | == | + | ===Formatting an MMC/SD card=== |
+ | We will create two partitions on our mmc/sd card, The first one will use for Android memory card, the second one will use for Android file system. | ||
+ | First connect your card reader to your workstation, with the MMC/SD card inside. Type the '''dmesg''' command to see which device is used by your workstation. Let’s assume that this device is '''/dev/sdb''' | ||
+ | <pre class="host"> | ||
+ | $ dmesg | ||
+ | ... | ||
+ | [ 9145.613954] sdb: sdb1 sdb2 | ||
+ | [ 9145.615125] sd 10:0:0:0: [sdc] Attached SCSI removable disk | ||
+ | [ 9145.615258] sd 10:0:0:0: Attached scsi generic sg3 type 0 | ||
+ | </pre> | ||
+ | Type the mount command to check your currently mounted partitions. If MMC/SD partitions are mounted, unmount them.<br> | ||
+ | In a terminal edit partitions with fdisk: | ||
+ | <pre class="host"> | ||
+ | sudo fdisk /dev/sdb | ||
+ | </pre> | ||
+ | Delete any existing partition with the d command.<br> | ||
+ | Now, create the boot partition: | ||
+ | <pre class="host"> | ||
+ | Command (m for help): n | ||
+ | Command action | ||
+ | e extended | ||
+ | p primary partition (1-4) | ||
+ | p | ||
+ | Partition number (1-4): 1 | ||
+ | First cylinder (1-495, default 1): 1 | ||
+ | Last cylinder, +cylinders or +size{K,M,G} (1-239, default 239): +1G | ||
+ | </pre> | ||
+ | Change its type to FAT32: | ||
+ | <pre class="host"> | ||
+ | Command (m for help): t | ||
+ | Selected partition 1 | ||
+ | Hex code (type L to list codes): c | ||
+ | Changed system type of partition 1 to c (W95 FAT32 (LBA)) | ||
+ | </pre> | ||
+ | Using the n command again, create a second partition filling up the rest of your card (just accept default values).<br> | ||
+ | Now, format the partitions in your card: | ||
+ | <pre class="host"> | ||
+ | sudo mkfs.vfat -n MemoryCard -F 32 /dev/sdb1 | ||
+ | sudo mkfs.ext2 -L AndroidFS /dev/sdb2 | ||
+ | </pre> | ||
+ | Remove and insert your card again. Your new partitions should be mounted automatically.<br> | ||
+ | ===Copying data to the MMC/SD card=== | ||
+ | Now copy the Android root filesystem to the second partition. | ||
+ | <pre class="host"> | ||
+ | sudo rsync -a $ANDROID_SOURCE/rootfs/ /media/AndroidFS/ | ||
+ | </pre> | ||
+ | Finish by unmounting your MMC/SD partitions: | ||
+ | <pre class="host"> | ||
+ | sudo umount /media/MemoryCard | ||
+ | sudo umount /media/AndroidFS | ||
+ | </pre> | ||
+ | ==Boot setup== | ||
+ | The last thing left to do is to specify how the board boots Linux.<br> | ||
+ | In the U-boot prompt, make the mmc boot is on second partition of the MMC/SD card | ||
<pre class="apf"> | <pre class="apf"> | ||
# setenv mmcroot '/dev/mmcblk0p2 rw' | # setenv mmcroot '/dev/mmcblk0p2 rw' | ||
+ | </pre> | ||
+ | Now set the kernel command line arguments | ||
+ | <pre class="apf"> | ||
# setenv addmmcargs 'setenv bootargs ${bootargs} root=${mmcroot} rootfstype=${mmcrootfstype} init=\init androidboot.console=ttyS0' | # setenv addmmcargs 'setenv bootargs ${bootargs} root=${mmcroot} rootfstype=${mmcrootfstype} init=\init androidboot.console=ttyS0' | ||
+ | # saveenvmtd-utils | ||
</pre> | </pre> | ||
− | + | ==Debug== | |
− | + | <pre class="apf"> | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
# mount /dev/mmcblk0p2 /mnt/mmc | # mount /dev/mmcblk0p2 /mnt/mmc | ||
# strace -f -ff -tt -s 200 chroot /mnt/mmc /init androidboot.console=ttyS0 | # strace -f -ff -tt -s 200 chroot /mnt/mmc /init androidboot.console=ttyS0 | ||
# strace chroot /mnt/mmc /init androidboot.console=ttyS0 | # strace chroot /mnt/mmc /init androidboot.console=ttyS0 | ||
− | + | </pre> | |
− | + | ===Tester android avec l'emulateur=== | |
+ | [http://developer.android.com/guide/developing/tools/emulator.html emulator] | ||
+ | <pre class="host"> | ||
$ make ARCH=arm goldfish_defconfig | $ make ARCH=arm goldfish_defconfig | ||
$ make ARCH=arm CROSS_COMPILE=../prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/arm-eabi | $ make ARCH=arm CROSS_COMPILE=../prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/arm-eabi | ||
Line 154: | Line 191: | ||
$ ~/dev/android-sdk-linux_x86-1.5_r3/tools/android create avd -n APF27-H -t 2 -s 272x480 | $ ~/dev/android-sdk-linux_x86-1.5_r3/tools/android create avd -n APF27-H -t 2 -s 272x480 | ||
$ ~/dev/android-sdk-linux_x86-1.5_r3/tools/android create avd -n APF27-L -t 2 -s 480x272 | $ ~/dev/android-sdk-linux_x86-1.5_r3/tools/android create avd -n APF27-L -t 2 -s 480x272 | ||
− | |||
$ $ANDROID/out/host/linux-x86/bin/emulator -avd APF27-H -sysdir $ANDROID/out/target/product/generic/ -kernel $ANDROID/kernel/arch/arm/boot/zImage -data $ANDROID/out/target/product/generic/userdata.img -ramdisk $ANDROID/out/target/product/generic/ramdisk.img -system $ANDROID/out/target/product/generic/system.img | $ $ANDROID/out/host/linux-x86/bin/emulator -avd APF27-H -sysdir $ANDROID/out/target/product/generic/ -kernel $ANDROID/kernel/arch/arm/boot/zImage -data $ANDROID/out/target/product/generic/userdata.img -ramdisk $ANDROID/out/target/product/generic/ramdisk.img -system $ANDROID/out/target/product/generic/system.img | ||
− | + | </pre> | |
− | + | ==Android Root File system== | |
− | + | ||
− | Android Root File system | + | |
− | + | ||
Android emulator has 3 basic images on tools/lib/images directory. | Android emulator has 3 basic images on tools/lib/images directory. | ||
− | + | * '''ramdisk.img''' is gziped cpio archive. ramdisk.img is a small partition image that is mounted read-only by the kernel at boot time. It only contains /init and a few config files. It is used to start init which will mount the rest of the system images properly and run the init procedure. A Ramdisk is a standard Linux feature. It is made just for the Android and do special things to start up the Android system. | |
− | + | * '''system.img''' is a partition image that will be mounted as / and thus contains all system binaries. | |
− | + | * '''userdata.img''' is a partition image that can be mounted as /data and thus contains all application-specific and user-specific data. | |
− | + | '''/system''' directory has libraries and default system packages (*.apk). /data directory has timezone, cache, and ''ApiDemos.apk'' package.<br> | |
− | + | The main services are zygote('''/system/bin/app_process'''), runtime('''/system/bin/runtime'''), and dbus('''/system/bin/dbus-daemon'''). You can see the '''/etc/init.rc''' file on the Android ramdisk image. | |
− | + | <pre class="apf"> | |
− | + | ||
− | system.img and | + | |
− | + | ||
− | /system directory has libraries and default system packages (*.apk). /data directory has timezone, cache, and ApiDemos.apk package. | + | |
− | + | ||
− | The main services are zygote(/system/bin/app_process), runtime(/system/bin/runtime), and dbus(/system/bin/dbus-daemon). You can see the /etc/init.rc file on the Android ramdisk image. | + | |
− | + | ||
... | ... | ||
zygote { | zygote { | ||
Line 197: | Line 223: | ||
} | } | ||
... | ... | ||
− | + | </pre> | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + |
Revision as of 10:50, 30 July 2009
Désolé de pourrir les 'recent changes' :)
Contents
Truc utile
GRUB sur clé USB
Voici une petite astuce pour :
- ne plus perdre GRUB lors de la réinstallation de Windows
- ne plus avoir accès à Windows après l'installation de Linux
- rendre inaccessible la partition Linux sur votre machine
L'astuce est d'installer que GRUB sur une clé USB. Attention, l'ordre des actions est important
- Formatter la cle USB en fat32 (gparted)
- Récuperer la liste des disques monter ainsi que leur ID
$ sudo blkid /dev/sda1: UUID="CC5C86435C862872" TYPE="ntfs" /dev/sda5: UUID="aad30bf1-d620-4244-9fb5-42f4a38075fb" TYPE="ext3" /dev/sda6: TYPE="swap" UUID="e3163bab-1fcc-4bcd-844d-7dcabc35015c" /dev/sdb1: UUID="4C9D-547F" TYPE="vfat"
- installer Grub sur la cle USB
$ grub-install --no-floppy --root-directory=/media/disk /dev/sdb1 (remplacer sdb1 par la valeur récupérée avec la commande précédente)
- demonter le disque USB
$ sudo umount /media/disk
- Installer le MBR
$ sudo install-mbr /dev/sdb1
- Mettre le flag boot sur la cle USB (gparted)
make gconfig
installer les bibliothèques pour lancer make gconfig
sudo apt-get install libgtk2.0-dev libglib2.0-dev libglade2-dev
Banc à sable
Ce qui suit n'est qu'un brouillon avec les fautes de frappes et d'orthographe comme il se doit.
Prerequisites for Linux installation
Install needed software packages
Install these package for build the kernel image and for format the mmc/µSD card
$ sudo apt-get install uboot-mkimage mtd-utils
Update the environment variables
Theses environment variables install the Android and Armadeus folder in our home directory, but of course, it can be placed anywhere!
export ANDROID_SOURCE=~/apf27droid export ANDROID_SDK=~/android-sdk-linux_x86-1.5_r3 export ARMADEUS=~/armadeus-3.1 export PATH=${PATH}:${ANDROID_SDK}/tools:${ANDROID_SOURCE}/bin
Construction of Android environment
Download Android source
The getting Android source document describes how to set up our local work environment.
Follow theses instructions until Installing Repo.
$ mkdir ANDROID_SOURCE $ cd $ANDROID_SOURCE $ mkdir bin $ curl http://android.git.kernel.org/repo >$ANDROID_SOURCE/bin/repo $ chmod a+x $ANDROID_SOURCE/bin/repo $ repo init -u git://android.git.kernel.org/platform/manifest.git -b android-sdk-1.5_r3 $ repo sync
Since android-sdk-1.5_r3 branch, the Linux kernel isn't with the Android source, We can download it in a compress archive (tar.gz) file with this android-kernel-2.6.29 (about (70Mib) or with git repository (more 300Mib)
$ mkdir $ANDROID_SOURCE/kernel $ cd $ANDROID_SOURCE/kernel $ git clone git://android.git.kernel.org/kernel/common.git android-2.6.29
Apply the Armadeus patchset
Je n'ai pas indiqué (a faire) dans les pré-requit, il faut naturelle avoir installé et compilé le projet Armadeus-3.1. Dans un second temps, j'indiquerai les différentes actions pour ne pas être obliger à compiler le projet Armadeus, notamment pour la rustine patch-2.6.29.4.bz2
$ $ARMADEUS/buildroot/toolchain/patch-kernel.sh $ANDROID_SOURCE/kernel $ARMADEUS/downloads patch-2.6.29.4.bz2 $ $ARMADEUS/buildroot/toolchain/patch-kernel.sh $ANDROID_SOURCE/kernel $ARMADEUS/buildroot/toolchain/kernel-headers linux-2.6.29.4-\*.patch{,.gz,.bz2} $ $ARMADEUS/buildroot/toolchain/patch-kernel.sh $ANDROID_SOURCE/kernel $ARMADEUS/buildroot/target/device/armadeus/linux/kernel-patches/2.6.29.4 \*.patch{,.gz,.bz2} $ mkdir $ANDROID_SOURCE/kernel/drivers/armadeus $ cp -r $ARMADEUS/target/linux/modules/* $ANDROID_SOURCE/kernel/drivers/armadeus $ cp $ARMADEUS/target/device/armadeus/apf27/apf27-linux-2.6.29.config $ANDROID_SOURCE/kernel/arch/arm/configs/apf27_android_defconfig
Battery patch
At the beginning, reboot happened over again even though Android logo appeared on board. Result of investigation, we found that battery power was returned with 0 when boot.. A effectuer!!!!
update android kernel configuration for APF27
C'est un point délicat, Google/Android ne donne aucune informations dessus
compile Android kernel
$ cd $ANDROID_SOURCE/kernel $ make ARCH=arm mrproper $ make ARCH=arm apf27_android_defconfig $ make ARCH=arm CROSS_COMPILE=../prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/arm-eabi- uImage $ cp ./arch/arm/boot/uImage $TFTPBOOT/apf27-linux.bin
Making SD card for boot
Copying the Android root filesystem
Android’s root file system is generated in $ANDROID_SOURCE/out/target/product/generic
$ cd $ANDROID_SOURCE/out/target/product/generic $ mkdir $ANDROID_SOURCE/rootfs (or '$ sudo rm -rf $ANDROID_SOURCE/rootfs/*' if the folder already exist ) $ cp -a root/* $ANDROID_SOURCE/rootfs/ $ cp -a system/* $ANDROID_SOURCE/rootfs/system/ $ cd $ANDROID_SOURCE/rootfs $ sudo chown -R root.root . $ sudo chmod -R a+rwX data system
Change init.rc
To do!!!!
Formatting an MMC/SD card
We will create two partitions on our mmc/sd card, The first one will use for Android memory card, the second one will use for Android file system. First connect your card reader to your workstation, with the MMC/SD card inside. Type the dmesg command to see which device is used by your workstation. Let’s assume that this device is /dev/sdb
$ dmesg ... [ 9145.613954] sdb: sdb1 sdb2 [ 9145.615125] sd 10:0:0:0: [sdc] Attached SCSI removable disk [ 9145.615258] sd 10:0:0:0: Attached scsi generic sg3 type 0
Type the mount command to check your currently mounted partitions. If MMC/SD partitions are mounted, unmount them.
In a terminal edit partitions with fdisk:
sudo fdisk /dev/sdb
Delete any existing partition with the d command.
Now, create the boot partition:
Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-495, default 1): 1 Last cylinder, +cylinders or +size{K,M,G} (1-239, default 239): +1G
Change its type to FAT32:
Command (m for help): t Selected partition 1 Hex code (type L to list codes): c Changed system type of partition 1 to c (W95 FAT32 (LBA))
Using the n command again, create a second partition filling up the rest of your card (just accept default values).
Now, format the partitions in your card:
sudo mkfs.vfat -n MemoryCard -F 32 /dev/sdb1 sudo mkfs.ext2 -L AndroidFS /dev/sdb2
Remove and insert your card again. Your new partitions should be mounted automatically.
Copying data to the MMC/SD card
Now copy the Android root filesystem to the second partition.
sudo rsync -a $ANDROID_SOURCE/rootfs/ /media/AndroidFS/
Finish by unmounting your MMC/SD partitions:
sudo umount /media/MemoryCard sudo umount /media/AndroidFS
Boot setup
The last thing left to do is to specify how the board boots Linux.
In the U-boot prompt, make the mmc boot is on second partition of the MMC/SD card
# setenv mmcroot '/dev/mmcblk0p2 rw'
Now set the kernel command line arguments
# setenv addmmcargs 'setenv bootargs ${bootargs} root=${mmcroot} rootfstype=${mmcrootfstype} init=\init androidboot.console=ttyS0' # saveenvmtd-utils
Debug
# mount /dev/mmcblk0p2 /mnt/mmc # strace -f -ff -tt -s 200 chroot /mnt/mmc /init androidboot.console=ttyS0 # strace chroot /mnt/mmc /init androidboot.console=ttyS0
Tester android avec l'emulateur
$ make ARCH=arm goldfish_defconfig $ make ARCH=arm CROSS_COMPILE=../prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/arm-eabi # créer des AVD (Android Virtual Device) $ ~/dev/android-sdk-linux_x86-1.5_r3/tools/android create avd -n APF27-H -t 2 -s 272x480 $ ~/dev/android-sdk-linux_x86-1.5_r3/tools/android create avd -n APF27-L -t 2 -s 480x272 $ $ANDROID/out/host/linux-x86/bin/emulator -avd APF27-H -sysdir $ANDROID/out/target/product/generic/ -kernel $ANDROID/kernel/arch/arm/boot/zImage -data $ANDROID/out/target/product/generic/userdata.img -ramdisk $ANDROID/out/target/product/generic/ramdisk.img -system $ANDROID/out/target/product/generic/system.img
Android Root File system
Android emulator has 3 basic images on tools/lib/images directory.
- ramdisk.img is gziped cpio archive. ramdisk.img is a small partition image that is mounted read-only by the kernel at boot time. It only contains /init and a few config files. It is used to start init which will mount the rest of the system images properly and run the init procedure. A Ramdisk is a standard Linux feature. It is made just for the Android and do special things to start up the Android system.
- system.img is a partition image that will be mounted as / and thus contains all system binaries.
- userdata.img is a partition image that can be mounted as /data and thus contains all application-specific and user-specific data.
/system directory has libraries and default system packages (*.apk). /data directory has timezone, cache, and ApiDemos.apk package.
The main services are zygote(/system/bin/app_process), runtime(/system/bin/runtime), and dbus(/system/bin/dbus-daemon). You can see the /etc/init.rc file on the Android ramdisk image.
... zygote { exec /system/bin/app_process args { 0 -Xzygote 1 /system/bin 2 --zygote } autostart 1 } runtime { exec /system/bin/runtime autostart 1 } ... dbus { exec /system/bin/dbus-daemon args.0 --system args.1 --nofork autostart 1 } ...