Odroid xu3 cross compile setup
1. 下载安装img并扩展sd卡
http://odroid.in/ubuntu_14.04lts/
download ubuntu-14.04.1lts-lubuntu-odroid-xu3-20150212.img.xz
下载 OS Image flashing tool for
Download and unzip this file.
http://dn.odroid.com/DiskImager_ODROID/Win32DiskImager-odroid-v1.3.zip
download 后烧录成功
SD 卡的安装和扩容
扩充前
root@odroid-desktop:~# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/mmcblk0p2 3150076 2132236 857792 72% / none 4 0 4 0% /sys/fs/cgroup udev 892784 4 892780 1% /dev tmpfs 178812 1000 177812 1% /run none 5120 8 5112 1% /run/lock none 894060 72 893988 1% /run/shm none 102400 12 102388 1% /run/user /dev/mmcblk0p1 102182 7714 94468 8% /media/boot
默认的镜像剩余大小固定,如使用8/16G SD card时需要对没有分配的空间进行扩容
1. 先把烧录上述image的 SD card 通过USB card reader插入到一个Linux host,然后 fdisk 删除并创建分区
Disk /dev/sdb: 7948 MB, 7948206080 bytes 245 heads, 62 sectors/track, 1021 cylinders, total 15523840 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0003f9f7 Device Boot Start End Blocks Id System /dev/sdb1 4096 208895 102400 c W95 FAT32 (LBA) /dev/sdb2 208896 6610943 3201024 83 Linux root@odroid-desktop:~# fdisk /dev/sdb 208896 为First sector
1
2
3
4
5
6
7
8
9
10
11
|
sudo fdisk /dev/mmcblk0 p (see starting block of p2, e.g. 266240) d (delete) 2 (partition 2) n ( new ) p (primary) 2 (partition 2) 266240 (starting block) <enter> (it will take ending block as end partition, so you have entire space) w (write partitions) |
2. 使用该SD卡启动并做resize2fs
oot@odroid-desktop:~# resize2fs /dev/mmcblk0p2 resize2fs 1.42.9 (4-Feb-2014) Filesystem at /dev/mmcblk0p2 is mounted on /; on-line resizing required old_desc_blocks = 1, new_desc_blocks = 1 The filesystem on /dev/mmcblk0p2 is now 3863424 blocks long. root@odroid-desktop:~# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/mmcblk0p2 15213368 2139708 12426548 15% / none 4 0 4 0% /sys/fs/cgroup udev 892784 4 892780 1% /dev tmpfs 178812 1012 177800 1% /run none 5120 0 5120 0% /run/lock none 894060 72 893988 1% /run/shm none 102400 12 102388 1% /run/user /dev/mmcblk0p1 102182 7714 94468 8% /media/boot root@odroid-desktop:~# fdisk -l
2. 在xu3上编译内核
参考http://odroid.com/dokuwiki/doku.php?id=en:xu3_building_kernel
但是按照下面指示,不能创建 uInitrd ramdisk image in host PC
http://odroid.com/dokuwiki/doku.php?id=en:xu3_building_kernel
所以,builder kernel 只能在odroid上做
Please follow the instructions below to rebuild the Linux Kernel for ODROID. Those instructions cover native build of the Kernel. 1. Install dependencies: apt-get install build-essential libqt4-dev libncurses5-dev git 2. Clone Repo: git clone –depth 1 https://github.com/hardkernel/linux.git -b odroidxu3-3.10.y odroidxu-3.10.y git clone --depth 1 https://github.com/hardkernel/linux.git -b odroidxu3-3.10.y odroidxu3-3.10.y 1.Configure Kernel: make odroidxu3_defconfig 2.Do changes if you need/want: make menuconfig or make xconfig 3.Build Kernel and Modules: make -j9 4.Install zImage: cp arch/arm/boot/zImage /media/boot 5.Install DTB File: cp arch/arm/boot/dts/exynos5422-odroidxu3.dtb /media/boot 6.Install Modules: make modules_install 7.Copy .config to /boot for initramfs creation: cp .config /boot/config-`make kernelrelease` 8.Create initramfs: update-initramfs -c -k `make kernelrelease` 9.Create uInitrd: mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 -n uInitrd -d /boot/initrd.img-`make kernelrelease` /boot/uInitrd-`make kernelrelease` 10.Install new uInitrd: cp /boot/uInitrd-`make kernelrelease` /media/boot/uInitrd 11.reboot: sync && reboot
设置代理
sudo vi /etc/apt/apt.conf
Acquire::http::Proxy "http://rootproxy.cypress.com:8080";
sudo apt-get install build-essential libqt4-dev libncurses5-dev
同步时间
sudo find linux |xargs touch
make -j9
sudo cp arch/arm/boot/zImage /media/boot
.....cp others follow above instructions
reboot
制作patch
diff -urN linux-orig/linux/arch/arm/boot/dts/ linux/arch/arm/boot/dts/ >> powerloss.patch
打patch
patch -p1 < powerloss.patch
3. 应用编译
odroid 应用编译需要安装hardfloat版本的编译器
apt-get install gcc-arm-linux-gnueabihf
4. 安装交叉编译内核
arm-linux-gnueabihf-gcc-4.6 hello.c -o hello
其实这个是不需要的,ramdisk制作的时候还得需要在odroid xu3上
按照参考下载http://dn.odroid.com/ODROID-XU/compiler/arm-eabi-4.6.tar.gz
#arm-eabi- gcc cannot execute binary file
查看文件是elf 64-bit ,Linux 是32bit的
root@rzhou-pc:/opt/arm-eabi-4.6/bin# file arm-eabi-gcc
arm-eabi-gcc: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, BuildID[sha1]=0x8017f14da2903b7ff324011e39c63adc9355ed07, stripped
下载32位的交叉编译
https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/+/jb-release
tar -zxvf arm-eabi-4.6-jb-release.tar.gz -C toolchain/
安装成功后下载linux源码树
git clone --depth 1 https://github.com/hardkernel/linux.git -b odroidxu3-3.10.y
cd linux make odroidxu3_defconfig make