Building FreeBSD's SDIO driver for BeagleBone Black
Hi all, This post mainly concern with building FreeBSD's SDIO driver for BeagleBone Black by cross compiling it on AMD platform. I had few unresolved issues with the master branch of current FreeBSD tree. So, for this i used another unofficial branch: https://github.com/kibab/freebsd/tree/mmcam-new . It does have the required KERNCONF file with stable SDIO driver.
A lot of steps below are similar to the one given on: https://forums.freebsd.org/threads/cross-compiling-beaglebone-on-amd64.64718/#post-384835 with slight but inevitable changes.
Procedure:
Great, you are now ready to go and dd the obtained bbb.img image to sd card. With every thing working kernel should boot up with multiple MMCCAM debug logs as in here. In case of any error, feel free to post it on the forums or comment below.
References:
A lot of steps below are similar to the one given on: https://forums.freebsd.org/threads/cross-compiling-beaglebone-on-amd64.64718/#post-384835 with slight but inevitable changes.
Procedure:
- Before proceeding you need to first install git.
sudo pkg update -f sudo pkg install git
- Setup project directory by mkdir /BBB
- Clone the repository to /BBB/src by
git clone -b mmcam-new https://github.com/kibab/freebsd.git /BBB/src
- Setup environment variables as
setenv BASEDIR /BBB setenv MAKEOBJDIRPREFIX $BASEDIR/obj setenv TARGET arm setenv TARGET_ARCH armv6
Note that sometime it shows an error like: Undefined command setenv, in that case just switch to root as sudo -E su and then try setting the environment variables again. - Create image file and setup MSDOS filesystem for u-boot
truncate -s 2048M /BBB/bbb.img mdconfig -f /BBB/bbb.img -u md0 gpart create -s MBR md0 gpart add -t \!12 -s 10m md0 newfs_msdos -F12 -L 'MSDOSBOOT' /dev/md0s1 gpart set -a active -i 1 md0
- Make Buildworld and buildkernel
cd $BASEDIR/src make -j8 buildworld TARGET=arm TARGET_ARCH=armv6 UBLDR_LOADADDR=0x88000000 -DWITH_FDT __MAKE_CONF=/dev/null SRCCONF=/dev/null make buildkernel TARGET_ARCH=armv6 KERNCONF=BEAGLEBONE-MMCCAM
Note here, that if your FreeBSD AMD environment is on virtual box, for above builds to be successful you need around 2Gb of RAM and 4Gb of Swap memory with -j7 option. Swap space can be checked via swapinfo command. For adding more swap just head towards: https://www.freebsd.org/doc/handbook/adding-swap-space.html - Mount the MSDOS partition and copy the uboot stuff to it.
mount_msdosfs /dev/md0s1 /mnt cp /usr/ports/sysutils/u-boot-beaglebone/work/u-boot-2018.03/MLO /mnt cp /usr/ports/sysutils/u-boot-beaglebone/work/u-boot-2018.03/boot.scr /mnt cp /usr/ports/sysutils/u-boot-beaglebone/work/u-boot-2018.03/u-boot.img /mnt cp /BBB/obj/arm.armv6/BBB/src/sys/boot/arm/uboot/ubldr /mnt cp /BBB/obj/arm.armv6/BBB/src/sys/boot/arm/uboot/ubldr.bin /mnt umount /mnt
Note that sysutils/u-boot-beaglebone port doesn't come by default, in fresh FreeBSD installation. It has to be installed bypkg install u-boot-beaglebone cd /usr/ports/sysutils/u-boot-beaglebone/ && make install clean
- Make the freebsd-ufs partition
mkdir /mnt1 gpart add -t freebsd md0 gpart create -s BSD md0s2 gpart add -t freebsd-ufs md0s2 newfs /dev/md0s2a tunefs -N enable -j enable -t enable /dev/md0s2a mount /dev/md0s2a /mnt1
- Do installworld, installkernel into the partition
make installworld TARGET_ARCH=armv6 DESTDIR=/mnt1 make distribution TARGET_ARCH=armv6 DESTDIR=/mnt1 make installkernel TARGET_ARCH=armv6 KERNCONF=BEAGLEBONE-MMCCAM DESTDIR=/mnt1
- Install setup, create fstab and rc.conf
touch /mnt1/firstboot mkdir /mnt1/boot/msdos ee /mnt1/etc/fstab # Custom /etc/fstab for FreeBSD embedded images /dev/sdda0s1 /boot/msdos msdosfs rw,noatime 0 0 /dev/sdda0s2a / ufs rw,noatime 1 1 ee /mnt1/etc/rc.conf hostname="beaglebone" ifconfig_DEFAULT="DHCP" sshd_enable="YES" sendmail_enable="NONE" sendmail_submit_enable="NO" sendmail_outbound_enable="NO" sendmail_msp_queue_enable="NO"
- Complete setup by
umount /mnt1 mdconfig -d -u0
Great, you are now ready to go and dd the obtained bbb.img image to sd card. With every thing working kernel should boot up with multiple MMCCAM debug logs as in here. In case of any error, feel free to post it on the forums or comment below.
References:
- https://forums.freebsd.org/threads/cross-compiling-beaglebone-on-amd64.64718/#post-384835
- http://freebsd-arm.freebsd.narkive.com/dZ0TaVwR/bbb-imx6-hummingboard-sdio-driver#post14
- https://wiki.freebsd.org/SDIO
Comments
Post a Comment