构建openwrt

构建openwrt

Steps:

准备工作:

    下载openwrt源码: git clone git://git.openwrt.org/openwrt.git

    

Step1:编译openwrt源码

    先执行make menuconfig命令,然后有下列几个地方要更改:

  • 选择Target System为llwinner A1x/A20/A3x

  • 选择Target Profile为Cubietruck

  • 选择Target Images,设置Boot大小与Root大小(我用的是4G卡,Boot设置为100M,Root设置为3600M)

    然后保存生成.config文件

    接下来执行make -j8 (我的机子是双核四线程的,总共8个线程,so..j8)


Step2:为SD卡分区

    使用命令:fdisk /dev/sdb (注:sdb为我机子SD卡的盘符,其他因机子而异)

    创建两个分区 /dev/sdb1 与 /dev/sdb2,分别为boot分区与root分区,具体大小看你Step1所编译的大小

    将第一个分区格式化为vfat格式:  mkfs.vfat /dev/sdb1

    

Step3:写卡系统

     以下操作都是基于下面表完成的. 

    SD layout   

    SD layout with 512 byte blocks:

NAMEstart blocksize
MBR01 block
u-boot-with-spl.bin16 (8 KB)~250 KB
FAT2048 (1 MB)15 MB
EXT432768 (16 MB)rest

1.将spl写到CD卡第8k内存处:

    dd if=bin/sunxi/uboot-sunxi-Cubietruck/openwrt-sunxi-Cubietruck-u-boot-with-spl.bin of=/dev/sdb bs=1024 seek=8


2.挂载/dev/sdb1到/mnt

  mount -t vfat /dev/sdb1 /mnt


3.复制boot相关文件到/mnt

  cp bin/sunxi/uboot-sunxi-Cubietruck/openwrt-sunxi-Cubietruck-uEnv.txt /mnt/uEnv.txt

  cp bin/sunxi/sun7i-a20-cubietruck.dtb /mnt/dtb

  cp bin/sunxi/openwrt-sunxi-uImage /mnt/uImage


4.重定义root系统文件的大小(刚才在make menuconfig那定义了,现在可以不用执行)

  resize2fs bin/sunxi/openwrt-sunxi-root.ext4 3600M


5.将root根文件系统写道/dev/sdb2

  dd if=bin/sunxi/openwrt-sunxi-root.ext4 of=/dev/sdb2 bs=128k


6.将缓存内容写到SD卡,并卸载/mnt

  sync

  umount /mnt


END


以上方法如果失败,Step3直接换成以下命令:

   dd if=bin/sunxi/openwrt-sunxi-Cubietruck-sdcard-vfat-ext4.img of=/dev/sdb





    

            






参考资料:






posted @ 2015-04-22 10:06  /bin  阅读(811)  评论(0编辑  收藏  举报