准备一台Linux 例如(ubuntu10.10)的PC
一 编译android源码,制作文件系统
1、下载android源码
(1)、 Downloading the Source Tree Installing Repo
mkdir ~/bin
PATH=~/bin:$PATH
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
chmod a+x ~/bin/repo
(2)、Initializing a Repo client
mkdir WORKING_DIRECTORY
cd WORKING_DIRECTORY
repo init -u https://android.googlesource.com/platform/manifest
下载特定版本的android源码可以用 -b来指定
repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
(3)、Getting the files
repo sync
windows环境android源码下载: http://yuanzhifei89.iteye.com/blog/1117549
2、kernel下载
现在大家发现以前的Android 的Linux Kernel 下载方法不能用了,如下
$ git clone git://android.git.kernel.org/kernel/common.git
修改git为http后可以下载
$ git clone https://android.googlesource.com/kernel/common
总大下为400+MB,
下载完成后可能发现common文件夹下什么也没有,
$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/android-2.6.39
remotes/origin/android-3.0
remotes/origin/master
$ git checkout remotes/origin/android-3.0
就可以看到基于linux 3.0的android内核了。
3、编译源码
编译见http://www.cnblogs.com/mengshu-lbq/archive/2011/01/08/1930577.html
4、编译内核
http://blog.csdn.net/wanjf_912/article/details/7597161
5、搭建网络开发环境
1> 安装nfs服务器
sudo apt-get install nfs-kernel-server nfs-common
2> 修改nfs服务器配置文件/etc/exports ,确保有以下配置项
/nfsroot/rootfs *(rw,no_root_squash,sync)
我们在内核中已经固定,手机通过网络方式启动,默认从 /nfsroot/rootfs
读取文件系统,修改配置项后需要重启nfs服务器:
sudo /etc/init.d/nfs-kernel-server restart
3> 配置网络根文件系统
拷贝 out/target/product/littleton/root/ 内容到 /nfsroot/rootfs 目录
拷贝 out/target/product/littleton/system 内容到 /nfsroot/rootfs/system
修改 /nfsroot/rootfs/init.rc 去掉几个mount命令
二 ubuntu下烧录内核和文件系统
1、硬件:
手机一台
usb转串口线一根
usb转网卡线一根
2、软件环境
1> tftp 服务器
执行脚本: setup_tftpd.sh 安装和配置tftp服务器,我们默认以 /tftpboot 为 tftp服务器的根目录,需要下载的文件都放在该目录下。
3> 烧录镜像文件
用以下文件为例,示范通过tftp烧写内核和文件系统
内核 zImage0917
系统分区: system0918.img
数据分区 data0918.img
待烧写的以上文件必须存在于tftp服务器根目录/tftpboot下。
具体步骤:
首先连接好硬件设备进入blob下载模式
1> blob 起来后按任意键
Processing obm parameters...
Can't detect micco. Set PMIC as normal I2C mode.
NAND flash(Manu=0x98 Device=0xba) detected!
Slot 0 Found
get relocation table
Found Main Bad block table at address 0x0f000000, version 0x01
Found Mirror Bad block table at address 0x0efc0000, version 0x01
Consider yourself BLOBed!
blob version 2.0.5-pre3 for Marvell Littleton
Copyright (C) 1999 2000 2001 2002 2003 Jan-Derk Bakker and Erik Mouw
blob comes with ABSOLUTELY NO WARRANTY; read the GNU GPL for details.
This is free software, and you are welcome to redistribute it
under certain conditions; read the GNU GPL for details.
length not align with page size, change to 0x0
Read flash from 0x60000, length 0x0
Done
Autoboot (2 seconds) in progress, press any key to stop ..
Autoboot aborted
Type "help" to get a list of commands
blob>
2> 通过 tftp 下载内核到pc内存 0x80800000 地址处
blob> tftp zImage0917
Begin init ether usbnet!!!
***** Plug-in USB cable & config usbdnet now ******
exit check_usb_connection:1
TFTPing zImage0917*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ OK.
received 6144 blocks (3145156 bytes)
tftp_cmd: file 'zImage0917' loaded via tftp to address 0x80800000.
3> 擦除原来的内核分区,0x100000 为分区起始地址,0x300000为分区长度
blob> nanderase -z 0x100000 0x400000
the current NAND chip does not support Block Unlocking.
Erase 0x300000 length data from flash: 0x100000
Erase flash from 0x100000, length 0x300000
........................Done
4> 烧写内存 0x80800000 开始 实际长度为 3145156 的内核数据到起始地址为 0x100000 的内核分区
blob> nandwrite -z 0x80800000 0x100000 3145156
the current NAND chip does not support Block Unlocking.
Write 0x2ffdc4 length data from RAM: 0x80800000 to flash: 0x100000
Write flash from 0x100000, length 0x2ffdc4
Erase flash from 0x100000, length 0x300000
........................Done
........................Done
5> 下载系统分区镜像文件到pc内存 0x80800000 地址处
blob> tftp system0918.img
TFTPing system0918.img*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ OK.
received 113138 blocks (57925824 bytes)
tftp_cmd: file 'system0918.img' loaded via tftp to address 0x80800000.
6> 擦除原来的flash系统分区
blob> nanderase -z 0x500000 0x4000000
the current NAND chip does not support Block Unlocking.
Erase 0x3e0f800 length data from flash: 0x400000
Erase flash from 0x400000, length 0x3e0f800
...................................................................................
...................................................................................
...................................................................................
..........................Done
7> 烧写数据到flash系统分区
blob> nandwrite -y 0x80800000 0x500000 57925824
the current NAND chip does not support Block Unlocking.
Write 0x373e0c0 length data from RAM: 0x80800000 to flash: 0x400000
Write flash from 0x400000, length 0x3591800
Erase flash from 0x400000, length 0x3591800
....................................................................................
.....................................................................................
................................................................................Done
....................................................................................
....................................................................................
................................................................Done
8> 下载数据分区镜像文件到pc内存 0x80800000 地址处
blob> tftp data0918.img
TFTPing data0918.img*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ OK.
received 33992 blocks (17402880 bytes)
tftp_cmd: file 'data0918.img' loaded via tftp to address 0x80800000.
blob>
9> 擦除原来的flash数据分区
blob> nanderase -z 0x4500000 0xBB00000
the current NAND chip does not support Block Unlocking.
Erase 0xa81f000 length data from flash: 0x4400000
Erase flash from 0x4400000, length 0xa81f000
.....................................................................................
.....................................................................................
.....................................................................................
.....................................................................................
...................................................Done
10> 烧写数据镜像到flash数据分区
blob> nandwrite -y 0x80800000 0x4500000 17402880
the current NAND chip does not support Block Unlocking.
Write 0x1098c00 length data from RAM: 0x80800000 to flash: 0x4400000
Write flash from 0x4400000, length 0x1018000
Erase flash from 0x4400000, length 0x1018000
..................................................................................Done
..................................................................................Done
blob>
flash分区图:
*******************************************
* * * * *
* blob * kernel * system * data *
* * * * *
*******************************************
nanderase -z 0x100000 0x400000
tftp zImage
nandwrite -z 0x80800000 0x100000
烧写system.img:
nanderase -z 0x500000 0x4000000
tftp system.img
nandwrite -y 0x80800000 0x500000
烧写 userdata.img :
nanderase -z 0x4500000 0xBB00000
tftp userdata.img
nandwrite -y 0x80800000 0x4500000
========================