cross-compiler
crossdev -S -t armv7a-hardfloat-linux-gnueabi
u-boot + SPL
- SPL是上电后启动代码, 用于启动u-boot.
- SPL完全取代了Allwinner的boot0跟boot1代码.
- NAND启动是
ROM -> boot0 -> boot1 -> linux kernel
- SD启动是
ROM -> spl -> u-boot -> linux kernel
- 如果用livesuite的image做的SD卡也是有boot0跟boot1的.
- u-boot repo: https://github.com/linux-sunxi/u-boot-sunxi
- sunxi是主分支, 与upstream u-boot(master)同步.
compile u-boot
- To see a list of typical targets:
make help
- See
boards.cfg
for a list of known board types.
grep sunxi boards.cfg | awk ‘{print $7}’
cat boards.cfg | grep pcDuino3
对比可以看到跟cubieboard2基本一样.
Active arm armv7 sunxi - sunxi Linksprite_pcDuino3 sun7i:LINKSPRITE_PCDUINO3,SPL,SUNXI_GMAC,FAST_MBUS -
- Board names ending with _FEL are configured for USB-Booting.
- Out-of-Source compile u-boot:
make distclean
mkdir build
CROSS_COMPILE=armv7a-hardfloat-linux-gnueabi- make Linksprite_pcDuino3_config O=build
CROSS_COMPILE=armv7a-hardfloat-linux-gnueabi- make O=build -j8
生成文件
- 完整包含u-boot跟SPL:
u-boot-sunxi-with-spl.bin
- u-boot:
u-boot.img
- SPL:
spl/sunxi-spl.bin
对SD卡进行分区
- mac插入sd卡后, 卸载掉自动挂载的分区, 在virtualbox的port配置上添加对应的usb口的sd卡, 这样在vbox中就能识别到sd卡了.
- mac上的fdisk命令跟linux上的不同, 在virtualbox中对SD卡进行分区, 也可以用板子flash上的系统直接做.
root@ubuntu:~# fdisk /dev/mmcblk0
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-31260671, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-31260671, default 31260671): +64M
Command (m for help): n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): p
Partition number (1-4, default 2):
Using default value 2
First sector (133120-31260671, default 133120):
Using default value 133120
Last sector, +sectors or +size{K,M,G} (133120-31260671, default 31260671):
Using default value 31260671
Command (m for help): p
Disk /dev/mmcblk0: 16.0 GB, 16005464064 bytes
4 heads, 16 sectors/track, 488448 cylinders, total 31260672 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: 0x00000000
Device Boot Start End Blocks Id System
/dev/mmcblk0p1 2048 133119 65536 83 Linux
/dev/mmcblk0p2 133120 31260671 15563776 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
mkfs.ext2 /dev/mmcblk0p1
, mkfs.ext4 /dev/mmcblk0p2
sudo mount -t vfat /dev/sdb1 /mnt
cd /mnt
vim uEnv.txt
fdt_high=ffffffff
loadkernel=fatload mmc 0 0x46000000 uImage
loaddtb=fatload mmc 0 0x49000000 dtb
bootargs=console=ttyS0,115200 earlyprintk root=/dev/mmcblk0p2 rootwait
uenvcmd=run loadkernel && run loaddtb && bootm 0x46000000 - 0x49000000
建立boot分区
- dd命令在虚拟机里写入会失败, 在mac下dd,
sudo dd if=u-boot-sunxi-with-spl.bin of=/dev/disk2 bs=1024 seek=8
建立root分区
- 下载stage3-armv7a_hardfp-20140819.tar.bz2,
releases/arm/autobuilds/current-stage3/
, http://distfiles.gentoo.org/releases/arm/autobuilds/current-stage3-armv7a_hardfp/
- 在pcduino上的ubuntu系统中, 启动后, 再插入sd卡, 然后
mkdir -p /mnt/gentoo/
, mount /dev/mmcblp0p2 /mnt/gentoo/
, wget http://distfiles.gentoo.org/releases/arm/autobuilds/current-stage3-armv7a_hardfp/
, tar xjpf stage3-armv7a_hardfp-20140819.tar.bz2 -C /mnt/gentoo/
- 修改
/etc/fstab
编译内核
git clone git://github.com/linux-sunxi/linux-sunxi.git
make help
mkdir build
CROSS_COMPILE=armv7a-hardfloat-linux-gnueabi- ARCH=arm make sun7i_defconfig O=build -j3
CROSS_COMPILE=armv7a-hardfloat-linux-gnueabi- ARCH=arm make uImage modules O=build -j3
su
CROSS_COMPILE=/usr/bin/armv7a-hardfloat-linux-gnueabi- ARCH=arm make modules_install INSTALL_MOD_PATH=/mnt/gentoo
fex2bin
git clone git://github.com/linux-sunxi/sunxi-tools.git
make fex2bin
board configurations
git clone git://github.com/linux-sunxi/sunxi-boards.git
硬件连接
pcDuino <-> 串口调试 <-> PC USB
pcDuino <-> OTG <-> PC USB
overlay
- portage位置
- emerge支持cross-compile
- overlay
- layman支持