cubieboard: defconfig
PATCH 1/2 cubieboard: defconfig
This adds support for Cubieboard (http://cubieboard.org/).
This depends on host package HOST_SUNXI_TOOLS submitted by Floris Bos.
--- configs/cubieboard_defconfig | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 configs/cubieboard_defconfig
configs/cubieboard_defconfig new file +33 -0
@@ -0,0 +1,33 @@ +# Architecture +BR2_arm=y +BR2_cortex_a8=y + +# System configuration +BR2_TARGET_GENERIC_HOSTNAME="sun4i" +BR2_TARGET_GENERIC_ISSUE="Welcome to use sun4i" +BR2_TARGET_GENERIC_GETTY=y +BR2_TARGET_GENERIC_GETTY_PORT="ttyS0" +BR2_ROOTFS_POST_IMAGE_SCRIPT="board/cubieboard/post-build.sh" + +# Additional tools +BR2_PACKAGE_HOST_SUNXI_TOOLS=y +BR2_PACKAGE_HOST_UBOOT_TOOLS=y + +# Kernel +BR2_LINUX_KERNEL=y +BR2_LINUX_KERNEL_CUSTOM_GIT=y +BR2_LINUX_KERNEL_CUSTOM_GIT_REPO_URL="https://github.com/linux-sunxi/linux-sunxi.git" +BR2_LINUX_KERNEL_CUSTOM_GIT_VERSION="66025966cbe563e356b5e1dda0a572e738e13c42" +BR2_LINUX_KERNEL_VERSION="sunxi-3.4" +BR2_LINUX_KERNEL_DEFCONFIG="sun4i" + +# Bootloaders +BR2_TARGET_UBOOT=y +BR2_TARGET_UBOOT_BOARDNAME="cubieboard" +BR2_TARGET_UBOOT_CUSTOM_GIT=y +BR2_TARGET_UBOOT_VERSION="sunxi" +BR2_TARGET_UBOOT_CUSTOM_GIT_REPO_URL="https://github.com/linux-sunxi/u-boot-sunxi.git" +BR2_TARGET_UBOOT_CUSTOM_GIT_VERSION="7aa9f04f571247a6bb999c168b49e09f05b86465" +BR2_TARGET_UBOOT_FORMAT_BIN=y +BR2_TARGET_UBOOT_SPL=y +BR2_TARGET_UBOOT_SPL_NAME="spl/sunxi-spl.bin"
Signature · 1 line
1.8.1.5
PATCH 2/2 cubieboard: scripts
This patch add:
- boot.cmd: U-Boot script
- post-build.sh: post-build script to generate some needed files
- mkCubieCard.sh: script to correctly format the SD card and make it bootable by cubieboard
--- board/cubieboard/boot.cmd | 4 ++ board/cubieboard/mkCubieCard.sh | 110 ++++++++++++++++++++++++++++++++++++++++ board/cubieboard/post-build.sh | 37 ++++++++++++++ 3 files changed, 151 insertions(+) create mode 100644 board/cubieboard/boot.cmd create mode 100755 board/cubieboard/mkCubieCard.sh create mode 100755 board/cubieboard/post-build.sh
board/cubieboard/boot.cmd new file +4 -0
@@ -0,0 +1,4 @@ +setenv bootargs console=ttyS0,115200 root=/dev/mmcblk0p2 rootwait panic=10 ${extra} +fatload mmc 0 0x43000000 script.bin +fatload mmc 0 0x48000000 uImage +bootm 0x48000000
board/cubieboard/mkCubieCard.sh new file +110 -0
110 lines not on this page · raw message
board/cubieboard/post-build.sh new file +37 -0
@@ -0,0 +1,37 @@ +#!/bin/sh +# post-build.sh for CubieBoard +# 2013, Carlo Caione <[email protected]> + +TARGET_DIR=$1 +IMAGES_DIR=$1/../images +BOARD_DIR="$(dirname $0)" +HOST_DIR=$1/../host/usr/bin +TMP_DIR=`mktemp -d` + +FEX2BIN=$HOST_DIR/fex2bin +FEX_BOARD_FILE=$TMP_DIR/sys_config/a10/cubieboard.fex +BIN_BOARD_FILE=$IMAGES_DIR/script.bin + +MKIMAGE=$HOST_DIR/mkimage +BOOT_CMD=$BOARD_DIR/boot.cmd +BOOT_CMD_H=$IMAGES_DIR/boot.scr + +SD_IMAGE=$IMAGES_DIR/sd.img + +GIT_SUNXI_BOARD=git://github.com/linux-sunxi/sunxi-boards.git + +# Building script.bin +if [ -e $FEX2BIN ]; +then + git clone $GIT_SUNXI_BOARD $TMP_DIR + $FEX2BIN $FEX_BOARD_FILE $BIN_BOARD_FILE +fi + +# U-Boot script +if [ -e $MKIMAGE -a -e $BOOT_CMD ]; +then + $MKIMAGE -C none -A arm -T script -d $BOOT_CMD $BOOT_CMD_H +fi + +# Clean-up +rm -fr $TMP_DIR
Signature · 1 line
1.8.1.5
PATCH 2/2 cubieboard: scripts
Dear Carlo Caione,
When you repost a new version of a patch, please be sure to include some sort of changelog. Either in an introduction e-mail, or...
Quoted 8 lines · Carlo Caione
This patch add:
- boot.cmd: U-Boot script
-post-build.sh: post-build script to generate some needed files
-mkCubieCard.sh: script to correctly format the SD card and make it bootable by cubieboardSigned-off-by Carlo Caione <[email protected]>---
... here.
Quoted 3 lines
board/cubieboard/boot.cmd | 4 ++ board/cubieboard/mkCubieCard.sh | 110 ++++++++++++++++++++++++++++++++++++++++ board/cubieboard/post-build.sh | 37 ++++++++++++++
Generally, we do board/<vendor>/<boardname>/.
board/cubieboard/mkCubieCard.sh
Quoted 20 lines
3 files changed, 151 insertions(+) create mode 100644 board/cubieboard/boot.cmd create mode 100755 board/cubieboard/mkCubieCard.sh create mode 100755 board/cubieboard/post-build.shboard/cubieboard/boot.cmd new file +4
-0@@ -0,0 +1,4 @@ +setenv bootargs console=ttyS0,115200 root=/dev/mmcblk0p2 rootwait panic=10 ${extra} +fatload mmc 0 0x43000000 script.bin +fatload mmc 0 0x48000000 uImage +bootm 0x48000000board/cubieboard/mkCubieCard.sh new file +0
-0
In general in Buildroot, we don't have camel-case files, so mkcubiecard.sh would be more appropriate here.
Quoted 101 lines
board/cubieboard/mkCubieCard.sh new file +100
-0@@ -0,0 +1,110 @@ +#! /bin/sh +# mkCubieCard.sh v0.1: +# 2013, Carlo Caione <[email protected]> +# heavely based on : +# mkA10card.sh v0.1 +# 2012, Jason Plum <[email protected]> +# loosely based on : +# mkcard.sh v0.5 +# (c) Copyright 2009 Graeme Gregory <[email protected]> +# Licensed under terms of GPLv2 +# +# Parts of the procudure base on the work of Denys Dmytriyenko +# http://wiki.omap.com/index.php/MMC_Boot_Format + +IMAGES_DIR=../../output/images +SPL_IMG=$IMAGES_DIR/sunxi-spl.bin +UBOOT_IMG=$IMAGES_DIR/u-boot.bin +UIMAGE=$IMAGES_DIR/uImage +BIN_BOARD_FILE=$IMAGES_DIR/script.bin +ROOTFS=$IMAGES_DIR/rootfs.tar + +export LC_ALL=C + +if [ $# -ne 1 ]; then + echo "Usage: $0 <drive>" + exit 1; +fi + +if [ ! -f $SPL_IMG ] || + [ ! -f $UBOOT_IMG ] || + [ ! -f $UIMAGE ] || + [ ! -f $BIN_BOARD_FILE ] || + [ ! -f $ROOTFS ]; then + echo "File(s) missing." + exit 1 +fi + +DRIVE=$1 +P1=`mktemp -d` +P2=`mktemp -d` + +dd if=/dev/zero of=$DRIVE bs=1M count=3 + +SIZE=`fdisk -l $DRIVE | grep Disk | grep bytes | awk '{print $5}'` + +echo DISK SIZE - $SIZE bytes + + +# ~2048, 16MB, FAT, bootable +# ~rest of drive, Ext4 +{ +echo 32,512,0x0C,* +echo 544,,,- +} | sfdisk -D $DRIVE + +sleep 1 + +if [ -b ${DRIVE}1 ]; then + D1=${DRIVE}1 + umount ${DRIVE}1 + mkfs.vfat -n "boot" ${DRIVE}1 +else + if [ -b ${DRIVE}p1 ]; then + D1=${DRIVE}p1 + umount ${DRIVE}p1 + mkfs.vfat -n "boot" ${DRIVE}p1 + else + echo "Cant find boot partition in /dev" + exit 1 + fi +fi + + +if [ -b ${DRIVE}2 ]; then + D2=${DRIVE}2 + umount ${DRIVE}2 + mkfs.ext4 -L "Cubie" ${DRIVE}2 +else + if [ -b ${DRIVE}p2 ]; then + D2=${DRIVE}p2 + umount ${DRIVE}p2 + mkfs.ext4 -L "Cubie" ${DRIVE}p2 + else + echo "Cant find rootfs partition in /dev" + exit 1 + fi +fi + +mount $D1 $P1 +mount $D2 $P2 + +# write uImage +cp $UIMAGE $P1 +# write board file +cp $BIN_BOARD_FILE $P1 +# write rootfs +tar -C $P2 -xvf $ROOTFS + +sync +
board/cubieboard/mkCubieCard.sh line 110
Quoted 10 lines
board/cubieboard/mkCubieCard.sh new file +10
-0+umount $D1 +umount $D2 + +rm -fr $P1 +rm -fr $P2 + +# write SPL +dd if=$SPL_IMG of=$DRIVE bs=1024 seek=8 +# write mele u-boot +dd if=$UBOOT_IMG of=$DRIVE bs=1024 seek=32
So this script is intended to be executed as root?
I think it would be good if you could add a board/cubieboard/README that explains how to use your specific scripts. It doesn't have to be a complete Buildroot manual, but just something that takes care of documenting the cubieboard specific stuff.
Quoted 22 lines
board/cubieboard/post-build.sh new file +16
-0@@ -0,0 +1,37 @@ +#!/bin/sh +# post-build.sh for CubieBoard +# 2013, Carlo Caione <[email protected]> + +TARGET_DIR=$1 +IMAGES_DIR=$1/../images +BOARD_DIR="$(dirname $0)" +HOST_DIR=$1/../host/usr/bin +TMP_DIR=`mktemp -d` + +FEX2BIN=$HOST_DIR/fex2bin +FEX_BOARD_FILE=$TMP_DIR/sys_config/a10/cubieboard.fex +BIN_BOARD_FILE=$IMAGES_DIR/script.bin + +MKIMAGE=$HOST_DIR/mkimage +BOOT_CMD=$BOARD_DIR/boot.cmd
board/cubieboard/post-build.sh line 26
Quoted 10 lines
board/cubieboard/post-build.sh new file +10
-0+BOOT_CMD_H=$IMAGES_DIR/boot.scr + +SD_IMAGE=$IMAGES_DIR/sd.img + +GIT_SUNXI_BOARD=git://github.com/linux-sunxi/sunxi-boards.git + +# Building script.bin +if [ -e $FEX2BIN ]; +then + git clone $GIT_SUNXI_BOARD $TMP_DIR
Argh, cloning a Git repo from a post build script doesn't sound really nice. What about creating a sunxi-boards Buildroot package, that generates this "BIN_BOARD_FILE" ?
board/cubieboard/post-build.sh line 37
Quoted 11 lines
board/cubieboard/post-build.sh new file +11
-0+ $FEX2BIN $FEX_BOARD_FILE $BIN_BOARD_FILE +fi + +# U-Boot script +if [ -e $MKIMAGE -a -e $BOOT_CMD ]; +then + $MKIMAGE -C none -A arm -T script -d $BOOT_CMD $BOOT_CMD_H +fi + +# Clean-up +rm -fr $TMP_DIR
Thanks,
Thomas
Signature · 4 lines
Thomas Petazzoni, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
PATCH 1/2 cubieboard: defconfig
In reply to Carlo CaioneDear Carlo Caione,
Quoted 3 lines · Carlo Caione
This adds support for Cubieboard (http://cubieboard.org/).
This depends on host packageHOST_SUNXI_TOOLSsubmitted by Floris Bos.
This message "This depends on host package ..." should not be part of the commit log. As I suggested earlier, just include Floris Bos patch in your patch set, it will be easier.
Some more comments below.
configs/cubieboard_defconfig line 7
Quoted 3 lines
configs/cubieboard_defconfig new file +3
-0+# System configuration +BR2_TARGET_GENERIC_HOSTNAME="sun4i" +BR2_TARGET_GENERIC_ISSUE="Welcome to use sun4i"
Since it's a cubieboard defconfig, what about using cubieboard here?
configs/cubieboard_defconfig line 10
Quoted 3 lines
configs/cubieboard_defconfig new file +3
-0+BR2_TARGET_GENERIC_GETTY=y +BR2_TARGET_GENERIC_GETTY_PORT="ttyS0" +BR2_ROOTFS_POST_IMAGE_SCRIPT="board/cubieboard/post-build.sh"
This script is added in your second patch, so taken alone, your first patch doesn't work. I think you should merge both of your patches, since they really do one thing: add support for the Cubieboard.
Quoted 12 lines
configs/cubieboard_defconfig new file +12
-0+# Additional tools +BR2_PACKAGE_HOST_SUNXI_TOOLS=y +BR2_PACKAGE_HOST_UBOOT_TOOLS=y + +# Kernel +BR2_LINUX_KERNEL=y +BR2_LINUX_KERNEL_CUSTOM_GIT=y +BR2_LINUX_KERNEL_CUSTOM_GIT_REPO_URL="https://github.com/linux-sunxi/linux-sunxi.git" +BR2_LINUX_KERNEL_CUSTOM_GIT_VERSION="66025966cbe563e356b5e1dda0a572e738e13c42" +BR2_LINUX_KERNEL_VERSION="sunxi-3.4" +BR2_LINUX_KERNEL_DEFCONFIG="sun4i" +
configs/cubieboard_defconfig line 33
Quoted 10 lines
configs/cubieboard_defconfig new file +10
-0+# Bootloaders +BR2_TARGET_UBOOT=y +BR2_TARGET_UBOOT_BOARDNAME="cubieboard" +BR2_TARGET_UBOOT_CUSTOM_GIT=y +BR2_TARGET_UBOOT_VERSION="sunxi" +BR2_TARGET_UBOOT_CUSTOM_GIT_REPO_URL="https://github.com/linux-sunxi/u-boot-sunxi.git" +BR2_TARGET_UBOOT_CUSTOM_GIT_VERSION="7aa9f04f571247a6bb999c168b49e09f05b86465" +BR2_TARGET_UBOOT_FORMAT_BIN=y +BR2_TARGET_UBOOT_SPL=y +BR2_TARGET_UBOOT_SPL_NAME="spl/sunxi-spl.bin"
Ok. We also generally want to lock down a certain kernel headers version. So you should add:
# Lock down headers to avoid breaking with new defaults BR2_KERNEL_HEADERS_VERSION=y BR2_DEFAULT_KERNEL_VERSION="3.8.1"
below your architecture definition. See armadeus_apf28_defconfig for example.
Thanks,
Thomas
Signature · 4 lines
Thomas Petazzoni, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com