构建openwrt

Steps:css

准备工做:html

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

    

Step1:编译openwrt源码缓存

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

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

  • 选择Target Profile为Cubietruckrest

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

    而后保存生成.config文件
内存

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


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:

NAME start block size
MBR 0 1 block
u-boot-with-spl.bin 16 (8 KB) ~250 KB
FAT 2048 (1 MB) 15 MB
EXT4 32768 (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





    

            






参考资料:




相关文章
相关标签/搜索