Difference between revisions of "U-booting Funtoo on the TI AM335x X2 SBC-B2"

From Funtoo
Jump to navigation Jump to search
Line 27: Line 27:
== U-Boot Building ==
== U-Boot Building ==


Notice the use of O=$XC_LINUX_PREFIX to control output. Remove this directory is you need to clean for a rebuild.
Notice the use of O=$XC_LINUX_PREFIX to control output. Remove this directory is you need to clean for a rebuild. DTC is the device tree compiler location. Again, a mystery.  
{{console|body=
{{console|body=
# wget $UBOOT_URL -O $UBOOTS/$UBOOT
# wget $UBOOT_URL -O $UBOOTS/$UBOOT
Line 39: Line 39:
# ARCH=$ARCH CROSS_COMPILE=$CROSSDEV_TARGET- make O=$XC_LINUX_PREFIX DTC=$XC_KERNEL_SRC/scripts/dtc/dtc
# ARCH=$ARCH CROSS_COMPILE=$CROSSDEV_TARGET- make O=$XC_LINUX_PREFIX DTC=$XC_KERNEL_SRC/scripts/dtc/dtc
}}
}}


== Setup Stage3 ==
== Setup Stage3 ==

Revision as of 20:33, February 8, 2017

Introduction

Installing Funtoo to a Raspberry Pi is fun, but there are a lot more boards out there. For example, the carrier boards that hold a DIMM mounted AM335x series cpu. To get this going, we need to use the U-Boot bootloader, some knowledge of serial consoles, and a lot of patience.

   Note

When you pick a board, documentation is just as important as hardware features. Without it, you WILL be hunting down someone in Shenzhen to explain why the board refuses to boot (you forgot to ground C8, of course).

See http://funtoo.org/Crossdev_Automation for the xcompile_variables.sh script and environment variables referenced here, and a more complete introduction to the process via a complete install of Funtoo to Raspberry Pi 2 and 3.


Kernel Building

This is an example of using manufacturer supplier scripts for defconfig generation. Don't forget to adjust the make jobs with -j <N> or just alias make="make -j<N>" to copy paste the commands directly.

Defconfig Generation

root # cd $XC_KERNEL_SRC
root # ARCH=$ARCH CROSS_COMPILE=$CROSSDEV_TARGET ti_config_fragments/defconfig_builder.sh -t ti_sdk_am3x_release
root # ARCH=$ARCH CROSS_COMPILE=$CROSSDEV_TARGET make ti_sdk_am3x_release_defconfig


root # ARCH=$ARCH CROSS_COMPILE=$CROSSDEV_TARGET- make uImage LOADADDR=0x82000000
root # ARCH=$ARCH CROSS_COMPILE=$CROSSDEV_TARGET- make modules
root # ARCH=$ARCH CROSS_COMPILE=$CROSSDEV_TARGET- make am335x-evm.dtb am335x-evmsk.dtb am335x-bone.dtb am335x-boneblack.dtb am335x-bonegreen.dtb am335x-icev2.dtb

U-Boot Building

Notice the use of O=$XC_LINUX_PREFIX to control output. Remove this directory is you need to clean for a rebuild. DTC is the device tree compiler location. Again, a mystery.

root # wget $UBOOT_URL -O $UBOOTS/$UBOOT
root # cd $UBOOTS
root # mkdir u-boot && tar xf $UBOOT -C u-boot --strip-components 1
root # cd $XC_UBOOT
root # ARCH=$ARCH CROSS_COMPILE=$CROSSDEV_TARGET- make mrproper
root # ARCH=$ARCH CROSS_COMPILE=$CROSSDEV_TARGET- make distclean
root # rm -r ./$XC_LINUX_PREFIX
root # ARCH=$ARCH CROSS_COMPILE=$CROSSDEV_TARGET- make O=$XC_LINUX_PREFIX am335x_evm_config
root # ARCH=$ARCH CROSS_COMPILE=$CROSSDEV_TARGET- make O=$XC_LINUX_PREFIX DTC=$XC_KERNEL_SRC/scripts/dtc/dtc

Setup Stage3

We set up the boot partion differently. The rest of the steps are the similar. Our board has a hardware clock as well.

root # sed -i "s/\/dev\/sda1.*/\/dev\/mmcblk0p1 \/boot/uboot vfat defaults 0 2/" $XC_STAGE3S/etc/fstab 
root # mkdir -p $XC_STAGE3S/boot/uboot

Copy Over Kernel Files

root # cd $XC_KERNEL_SRC
root # ARCH=$ARCH CROSS_COMPILE=$CROSSDEV_TARGET- INSTALL_MOD_PATH=$XC_STAGE3S INSTALL_MOD_STRIP=1 make modules_install
root # cp arch/arm/boot/dts/*.dtb  $XC_STAGE3S/boot
root # get_kernel_release() { (cd $XC_KERNEL_SRC ; ARCH=$ARCH CROSS_COMPILE=$CROSSDEV_TARGET- make kernelrelease;) }
root # rm $XC_STAGE3S/lib/modules/`get_kernel_release`/{build,source}

Copy Over U-Boot Files

Leave a blank line at the end of the u-boot config. For some reason or other.

root # cp $XC_UBOOT/$XC_LINUX_PREFIX/{MLO,u-boot.img,u-boot.bin} $XC_STAGE3S/boot/uboot
root # cp arch/arm/boot/uImage $XC_STAGE3S/boot/uboot
root # echo "bootargs=console=ttyO0,115200n8 root=/dev/mmcblk0p2 mem=128M rootwait
bootcmd=mmc rescan; fatload mmc 0 0x82000000 uImage; bootm 0x82000000
uenvcmd=boot
" > $XC_STAGE3S/boot/uboot/uEnv.txt

Install to the Board

Make an image.

root # dd if=/dev/zero of=/dev/<your_dev> bs=1024 count=1024
root # parted -s /dev/<your_dev> mklabel msdos
root # parted -s /dev/<your_dev> unit cyl mkpart primary fat32 -- 0 9
root # parted -s /dev/<your_dev> set 1 boot on
root # parted -s /dev/<your_dev> unit cyl mkpart primary ext2 -- 9 -2

Mount and Rsync.

root # mkdir -p /mnt/funtoo
root # mount /dev/<your_dev>2 /mnt/funtoo
root # mkdir -p /mnt/funtoo/boot/uboot
root # mount /dev/<your_dev>1 /mnt/funtoo/boot/uboot
root # rsync -avz --exclude "usr/portage/*" $XC_STAGE3S/{boot,bin,etc,home,lib,mnt,opt,root,run,sbin,srv,tmp,usr,var,dev} /mnt/funtoo
root # mkdir /mnt/funtoo/{proc,sys}
root # umount -R /mnt/funtoo