During last couple of months I see quite big interest in building products on
A20 SoC. This chip can be bought for 6USD in
quantity. Most important features are:
Dual-Core ARM Cortex-A7 (ARMv7)
Mali-400 MP2
HDMI, VGA and LCD
MMC and NAND
OTG and 2 Host ports
Tracking media related to low-end mobile market IMHO the hottest SoCs are
Allwinner A20 and Rockchip RK3288.
A20 ship with dozen development boards like Cubieboard or pcDuino series,
Banana Pi, MarsBoard or Hummingbird. About a year ago I choose to buy
Cubietruck and this led to couple interesting projects from porting
USBSniffer to
writing bare-metal bootloader based on U-boot code. Below setup is not
complicated but contain many pieces and looking for correct procedure for each one
is headache. Especially I felt that when I did it once couple months ago and
was not able to recover my setup without over a day of googling. Because I
of that I decided to write this post and leave notes for me and
others who want bootstrap Cubietruck setup.
Some configs and scripts can be found on github repo.
Linux development workstation (I use Debian stretch/sid)
USB to TTL serial adapter - best would be with original FT232RL, but Chinese
substitutes also works
microSD card
Ethernet cable - to connect your CT to router
good power supply 5V/2.5A - USB should also work when taking care about power
budget of whole setup
HDMI or VGA monitor - nice to have
General approach
Bootloader (U-Boot) obtain IP address dynamically then using hard coded
information about TFTP server it downloads script which contain instruction
about next steps. Usually next steps include downloading kernel over TFTP and
passing to it parameter indicating that rootfs should be mounted over NFS and
pointing to server location.
Because different U-Boot scripts are required for sunxi-3.4 and mainline
kernel I toggle config on tftp server.
Below I put together various pieces spread across network to have it in one
place.
git clone git://git.denx.de/u-boot.git
cd u-boot
make CROSS_COMPILE=arm-linux-gnueabihf- Cubietruck_defconfig
make CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
To boot sunxi-3.4 setting ARM architecture -> Enable workarounds for booting old kernels is required.
1
make CROSS_COMPILE=arm-linux-gnueabihf- -j$(nproc)
[23:42:38] pietrushnic:u-boot git:(master) $ make CROSS_COMPILE=arm-linux-gnueabihf- -j8
make: arm-linux-gnueabihf-gcc: Command not found
/bin/sh: 1: arm-linux-gnueabihf-gcc: not found
dirname: missing operand
Try 'dirname --help' for more information.
scripts/kconfig/conf --silentoldconfig Kconfig
CHK include/config.h
UPD include/config.h
GEN include/autoconf.mk
/bin/sh: 1: arm-linux-gnueabihf-gcc: not found
GEN include/autoconf.mk.dep
/bin/sh: 1: arm-linux-gnueabihf-gcc: not found
scripts/Makefile.autoconf:47: recipe for target 'include/autoconf.mk.dep' failed
make[1]: *** [include/autoconf.mk.dep] Error 1
make[1]: *** Waiting for unfinished jobs....
scripts/Makefile.autoconf:72: recipe for target 'include/autoconf.mk' failed
make[1]: *** [include/autoconf.mk] Error 1
GEN spl/include/autoconf.mk
/bin/sh: 1: arm-linux-gnueabihf-gcc: not found
scripts/Makefile.autoconf:75: recipe for target 'spl/include/autoconf.mk' failed
make[1]: *** [spl/include/autoconf.mk] Error 1
make: *** No rule to make target 'include/config/auto.conf', needed by 'include/config/uboot.release'. Stop.
git clone -b sunxi-3.4 --depth 1 https://github.com/linux-sunxi/linux-sunxi.git
cd linux-sunxi
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- sun7i_defconfig
Ethernet driver have to be built-in, because when included as module do not
start early enough to mount rootfs over NFS.
1
2
3
4
sed -i 's:CONFIG_SUNXI_GMAC=m:CONFIG_SUNXI_GMAC=y:g' .config
make -j$(nproc) ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- uImage modules
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=output modules_install
cd ..
script.bin
1
2
3
4
5
6
7
git clone git://github.com/linux-sunxi/sunxi-tools.git
git clone git://github.com/linux-sunxi/sunxi-boards.git
cd sunxi-tools
make fex2bin
cd ..
cd sunxi-boards
vim sys_config/a20/cubietruck.fex
git clone git://github.com/mripard/linux.git -b sunxi-next
cd linux
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- sunxi_defconfig
make -j$(nproc) ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage dtbs
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=output modules modules_install
Below script add flexibility to booting process by allowing user to replace on
server boot.scr. This makes Cubietruck able to dual boot sunxi-3.4 and
mainline kernel. Please replace <my_tftp_server_ip> with your TFTP address.
1
2
3
4
5
6
7
8
cat <<EOT > boot.cmd
# this file should be placed on boot SD card partition
setenv serverip <my_tftp_server_ip>
setenv autoload no
dhcp
tftp 0x44000000 ct/boot.scr
source 0x44000000
EOT
Make U-Boot readable image:
1
2
3
mkimage -C none -A arm -T script -d boot.cmd boot.scr
sudo cp boot.scr /mnt
sudo umount /mnt
Hopefully above shell history drop is readable for you, most of above content
can be googled - I just needed place to store notes from scratchpad. If you hit
some problems do not bother to ask in comments. If you like this post or think
it can be helpful for others please share.
Founder and Embedded Systems Consultant at 3mdeb as well as freelance CTO of Vitro Technology and CEO of LPN Plant. Passionate about building firmware that enables advanced hardware features in modern products. Dedicated to customers that treat embedded software security and upgradeability as forethought. Open source firmware evangelist interested in platform security and trusted computing. In favor of fixed price projects with a clear definition of success.