This note sheet includes my expreinces in working with Beagle Bone Blue. I hope it helps you. You can add issue for problems and pull requests are wellcome.
- enter
sudo fdisk -l <name.img> - multiply sector size by start of partiion you need to mount
- then enter below command by importing result value from previous section
sudo mount -o loop,offset=<result-value>,ro <name.img> /mnt
- Edit sudo vi /etc/resolv.conf and add these lines:
nameserver 8.8.8.8
nameserver 8.8.4.4
sudo route add default gw <host-machine-ip> usb0
echo 1 > /proc/sys/net/ipv4/ip_forwardifconfig -aiptables --table nat --append POSTROUTING --out-interface <wireless-interface> -j MASQUERADEiptables --append FORWARD --in-interface <usb-etherent-interface> -j ACCEPT
wget https://s3.amazonaws.com/angstrom/demo/beaglebone/Angstrom-Cloud9-IDE-GNOME-eglibc-ipk-v2012.12-beaglebone-2013.06.20.img.xztar xvf Angstrom-Cloud9-IDE-GNOME-eglibc-ipk-v2012.12-beaglebone-2013.06.20.img.xzdd if=Angstrom-Cloud9-IDE-GNOME-eglibc-ipk-v2012.12-beaglebone-2013.06.20.img of=/dev/mmcblk0
load mmc 0:2 0x82000000 /boot/uImageload mmc 0:2 0x88000000 /boot/am335x-boneblue.dtbsetenv bootargs console=ttyO0,115200 root=/dev/mmcblk0p2 rwbootm 0x82000000 - 0x88000000
sudo minicom- reset the board, press any key and while you are in uboot command line enter
loadx - then
ctrl+zand thens - choose
xmodemfrom the menu - go to file location in host machine and select
uEnv.txt - note the download address and size
- enter
env import -t <laod address> <size>example:env import -t 0x82000000 290 - now your defined vars in
uEnv.txtis loaded into your uboot environment variables.
| Binary | DDR Ram Load Address |
|---|---|
| Linux Kernel | 0x82000000 |
| DTB or FDT | 0x88000000 |
| RAMDISK or INITRAMFS | 0x88080000 |
- Disconnect sd card and micro usb and power board with adapter
- While board connected over uart0 to PC run minicom
- Plug power when pressing SD button and release it after power up
- When you see
Cpressctrl+aand thensand select xmodem - Choose
SPLpre-built image and hit enter - Repeat 4 and 5 step but for
u-boot.img - enter
loadx 0x820000000and Repeat 4 and 5 steps but foruImage - enter
loadx 0x880000000and Repeat 4 and 5 steps but foram335x-boneblack.dtb - enter
loadx 0x880800000and Repeat 4 and 5 steps but forinitramfs10.entersetenv bootargs console=ttyO0,115200 root=/dev/ram0 rw initrd=0x8808000011.enterbootm 0x82000000 0x88080000 0x88000000
wget https://toolchains.bootlin.com/downloads/releases/toolchains/armv7-eabihf/tarballs/armv7-eabihf--uclibc--stable-2018.11-1.tar.bz2tar xf armv7-eabihf--uclibc--stable-2018.11-1.tar.bz2 -C ~/x-tools
sudo apt install gcc-arm-linux-gnueabihf
sudo apt install flexexport PATH=~/x-tools/armv7-eabihf--uclibc--stable-2018.11-1/bin/:$PATHmake ARCH=arm CROSS_COMPILE=arm-linux- distcleanmake ARCH=arm CROSS_COMPILE=arm-linux- am335x_evm_configmake ARCH=arm CROSS_COMPILE=arm-linux- menuconfigmake ARCH=arm CROSS_COMPILE=arm-linux- -j4
wget https://www.busybox.net/downloads/busybox-1.31.1.tar.bz2tar xf busybox-1.31.1.tar.bz2cd busybox-1.31.1make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- defconfigmake ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfigmake ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- CONFIG_PREFIX=<install_path> install
sudo apt install lzopwget https://github.com/beagleboard/linux/archive/4.14.zip -o linux-4.14.zipunzip linux-4.14.zipcd linux-4.14make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- distcleanmake ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bb.org_defconfigmake ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfigmake ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- uImage dtbs LOADADDR=0x80008000 -j4or to build zImage domake ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j4 modulesmake ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=<path_of_the_RFS> modules_install
Copy files to sdcard to boot and run linux from sdcard
- Build two partiion on sdcard one for boot with fat filesystem and boot flag enabled and another with ext2.
Then Format both and name first partition as BOOT and second as ROOTFS.
You can use commands below. Assign $MYDSIK with your real device file path in
/dev:
MYDISK=/dev/mmcblk1
echo -e "o\nn\np\n1\n\n+200M\na\n1\nt\nc\nn\np\n2\n\n\nw\n" | fdisk $MYDISK ; fdisk -l $MYDISK
sudo mkfs.vfat ${MYDISK}p1
sudo mkfs.ext2 ${MYDISK}p2
sudo mlabel -i ${MYDISK}p1 ::BOOT
sudo e2label ${MYDISK}p2 ROOTFS
- Mount the boot partition on
/mnt:
sudo mount ${MYDISK}p1 /mnt
- copy
MLOandu-boot.imginto BOOT partition mounted. - umount the boot partition and mount rootfs partition on
/mnt:
sudo umount ${MYDISK}p1
sudo mount ${MYDISK}p2 /mnt
- copy root file system from where installed by busybox into ROOTFS partion
- make
bootanddevdirectory in ROOTFS partiotion - copy kernel built image from
arch/arm/boot/uImageintobootdirectory of ROOTFS partition - copy device tree file from
arch/arm/boot/dts/am335x-boneblue.dtbintobootdirectory of ROOTFS partition - make
procdirctory in the rootfs directory - make
etc/init.ddirectory in the rootfs directory of beaglebone - go rootfs directory and run
sudo nano etc/init.d/rcSand add below lines
#!/bin/sh
echo "Mounting proc"
mount -t proc /proc /proc
12.Adding inittab is not nessecary. if you want to add inititab into /etc you can find it in examples/inittab in busybox source folder
copy these contents to a file named uEnv.txt and copy it into boot partition alongside u-boot.img and MLO
console=ttyS0,115200n8
netargs=setenv bootargs console=ttyO0,115200n8 root=/dev/mmcblk0p2 rw rootfstype=ext3 rootwait debug earlyprintk mem=512M
netboot=echo Booting from microSD ...; setenv autoload no ; load mmc 0:2 ${loadaddr} /boot/uImage ; load mmc 0:2 ${fdtaddr} /boot/am335x-boneblue.dtb ; run netargs ; bootm ${loadaddr} - ${fdtaddr}
uenvcmd=run netboot
sudo apt install tftpd-hpasudo chown tftp:tftp /var/lib/tftpbootsudo apt install nfs-kernel-serversudo nano /etc/exports- add this line
/srv/nfs/bbb *(rw,sync,no_root_squash,no_subtree_check) sudo mkdir -p /srv/nfs/bbb- copy root file system built with busy box without parent directory into
/srv/nfs/bbb sudo exportfs -arvsudo service nfs-kernel-server restartnmcli con add type ethernet ifname enxf8dc7a000001 ip4 192.168.9.1/24- Go to kernel source folder run make menuconfig Find the ”USB Gadget precomposed configurations” and set it to * to become static instead of module so that there is
CONFIG_USB_ETH=yin .config. Then make kernel source again.
- If you have a uImage do:
- copy kernel built image from
arch/arm/boot/uImageinto/var/lib/tftpboot - copy device tree file from
arch/arm/boot/dts/am335x-boneblue.dtbinto/var/lib/tftpboot
- copy kernel built image from
- And If you have a zImage do:
cat arch/arm/boot/zImage arch/arm/boot/dts/am335x-boneblue.dtb > /var/lib/tftpboot/zImage
setenv ethact usb_ethersetenv usbnet_devaddr f8:dc:7a:00:00:02setenv usbnet_hostaddr f8:dc:7a:00:00:01set ipaddr 192.168.9.2set serverip 192.168.9.1tftpboot 0x82000000 ${serverip}:uImagetftpboot 0x88000000 ${serverip}:am335x-boneblue.dtbset rootpath /srv/nfs/bbb,nolock,wsize=1024,rsize=1024,nfsvers=3 rootwait rootdelay=2set bootargs console=ttyO0,115200n8 g_ether.dev_addr=${usbnet_devaddr} g_ether.host_addr=${usbnet_hostaddr} root=/dev/nfs rw nfsroot=${serverip}:${rootpath} ip=${ipaddr}:::::usb0bootm 0x82000000 - 0x88000000
You can also concatenate all of the above commands in one command and run it in u-boot. I do an example of it but this time with zImage:
setenv ipaddr 192.168.9.2;setenv serverip 192.168.9.1;setenv ethact usb_ether;setenv usbnet_devaddr f8:dc:7a:00:00:02;setenv usbnet_hostaddr f8:dc:7a:00:00:01;setenv rootpath /srv/nfs/bbb,nolock,wsize=1024,rsize=1024,nfsvers=3 rootwait rootdelay=3;setenv bootargs console=ttyO0,115200n8 g_ether.dev_addr=${usbnet_devaddr} g_ether.host_addr=${usbnet_hostaddr} root=/dev/nfs rw nfsroot=${serverip}:${rootpath} ip=${ipaddr}:::::usb0;tftpboot ${loadaddr} ${serverip}:zImage;bootz ${loadaddr}
Source: https://bootlin.com/blog/tftp-nfs-booting-beagle-bone-black-wireless-pocket-beagle/
You just need to add usb ethernet adapter to beaglebone. These steps are for ax88179 to work under u-boot for other devices you can walk through similar steps.
- In steps in compile u-boot after entering
make menuconfigsearch these two settings and make sure they are enabled and then build u-boot again.USB_HOST_ETHER=yUSB_ETHER_ASIX88179=y - In steps in compile kernel after entering
make menuconfigsearch these two settings and make sure they are enabled and then build kernel again.CONFIG_USB_NET_AX88179_178A=yUSB_NET_AX8817X=y - Go through steps 1 to 10 in host machine part of Boot kernel from network with ethernet over usb-device
- copy u-boot.img and MLO into sdcard boot partiotion
- copy uImage and am335x-boneblue.dtb into
/var/lib/tftpboot sudo ifconfig <interface-label> 192.168.6.10
- Power the board only with 12V adapter not usb cable
- press any key to stop booting
usb startset ipaddr 192.168.6.20ping 192.168.6.10- if you succedd you receive
host 192.168.6.10 is alivein your terminal. set serverip 192.168.6.10tftpboot 0x82000000 ${serverip}:uImagetftpboot 0x88000000 ${serverip}:am335x-boneblue.dtbset rootpath /srv/nfs/bbb,nolock,wsize=1024,rsize=1024,nfsvers=3 rootwait rootdelay=5set bootargs console=ttyO0,115200n8 root=/dev/nfs rw nfsroot=${serverip}:${rootpath} ip=${ipaddr}- `bootm 0x82000000 - 0x88000000
console=ttyO0,115200n8
ipaddr=192.168.6.20
serverip=192.168.6.10
rootpath=/srv/nfs/bbb,nolock,wsize=1024,rsize=1024,nfsvers=3 rootwait rootdelay=5
loadtftp=echo Booting from network ...;tftpboot ${loadaddr} ${serverip}:uImage; tftpboot ${fdtaddr} ${serverip}:am335x-boneblue.dtb
netargs=setenv bootargs console=${console} root=/dev/nfs rw nfsroot=${serverip}:${rootpath} ip=${ipaddr}
uenvcmd=setenv autoload no;usb start; run loadtftp; run netargs; bootm ${loadaddr} - ${fdtaddr}
console=ttyO0,115200n8
ipaddr=192.168.9.2
serverip=192.168.9.1
ethact=usb_ether
usbnet_devaddr=f8:dc:7a:00:00:02
usbnet_hostaddr=f8:dc:7a:00:00:01
rootpath=/srv/nfs/bbb,nolock,wsize=1024,rsize=1024,nfsvers=3 rootwait rootdelay=3
loadtftp=echo Booting from network ...;tftpboot ${loadaddr} ${serverip}:uImage; tftpboot ${fdtaddr} ${serverip}:am335x-boneblue.dtb
netargs=setenv bootargs console=${console} g_ether.dev_addr=${usbnet_devaddr} g_ether.host_addr=${usbnet_hostaddr} root=/dev/nfs rw nfsroot=${serverip}:${rootpath} ip=${ipaddr}:::::usb0
uenvcmd=setenv autoload no; run loadtftp; run netargs; bootm ${loadaddr} - ${fdtaddr}
Kernel after booting run init program as first program ans gives pid 1 to it. Kernel by default search below paths in order to find the init program.
init=<location of init program>in u-boot- /sbin/init
- /etc/init
- /bin/init
- /bin/sh
modprobe g_ethersudo ifconfig 192.168.7.2 up
After compiling with toolchain you need copy program wiht needed libs and the linker from toolchain lib directory to lib/ folder of target root file system:
- write a hello world program with c language and name it
hello.c arm-linux-gnueabihf-gcc -o app hello.csudo cp app /srv/nfs/bbb/cd /usr/arm-linux-gnueabihf/libsudo cp -P libc.so.6 /srv/nfs/bbb/lib/sudo cp -P libc-2.23.so /srv/nfs/bbb/lib/sudo cp -P ld* /srv/nfs/bbb/lib/
setenv ethact usb_ether;setenv usbnet_devaddr f8:dc:7a:00:00:02;setenv usbnet_hostaddr f8:dc:7a:00:00:01;set ipaddr 192.168.9.2;set serverip 192.168.9.1;tftpboot ${loadaddr} ${serverip}:uEnv.txt; fatwrite mmc 0:1 ${loadaddr} uEnv.txt ${filesize}
setenv ethact usb_ether;setenv usbnet_devaddr f8:dc:7a:00:00:02;setenv usbnet_hostaddr f8:dc:7a:00:00:01;set ipaddr 192.168.9.2;set serverip 192.168.9.1;tftpboot ${loadaddr} ${serverip}:MLO; fatwrite mmc 0:1 ${loadaddr} MLO ${filesize}
Get u-boot.img from host machine by ethernet over usb-dvivce and save it over sdcard boot partition:
setenv ethact usb_ether;setenv usbnet_devaddr f8:dc:7a:00:00:02;setenv usbnet_hostaddr f8:dc:7a:00:00:01;set ipaddr 192.168.9.2;set serverip 192.168.9.1;tftpboot ${loadaddr} ${serverip}:u-boot.img; fatwrite mmc 0:1 ${loadaddr} u-boot.img ${filesize}
setenv ethact usb_ether;setenv usbnet_devaddr f8:dc:7a:00:00:02;setenv usbnet_hostaddr f8:dc:7a:00:00:01;set ipaddr 192.168.9.2;set serverip 192.168.9.1;loadbootenv=tftpboot ${loadaddr} ${serverip}:uEnv.txt'
arm-linux-ldd rootfs/bin/busybox
- Go to rootfs directory
sudo apt install gcc-arm-linux-gnueabihfarm-linux-gnueabihf-gcc --print-sysrootcp -a /usr/arm-linux-gnueabihf/lib/* lib
wget https://www.zlib.net/zlib-1.2.11.tar.gztar xf zlib-1.2.11.tar.gzcd zlib-1.2.11.tar.gzCC=arm-linux-gnueabihf-gcc ./configure --prefix /usrmakemkdir ../buildmake install DESTDIR=../buildtree ../buildmkdir ../zlib-testscp test/example.c ../zlib-tests/cd ../zlib-tests/arm-linux-gnueabihf-gcc example.c -I ../build/usr/include/ -L ../build/usr/lib/ -lzor
export CFLAGS="-I ../build/usr/include"
export LDFLAGS="-L ../build/usr/lib"
arm-linux-gcc example.c $CFLAGS $LDFLAGS -lz
or
export PKG_CONFIG_PATH=../build/usr/lib/pkgconfig
export PKG_CONFIG_SYSROOT_DIR=../build
arm-linux-gcc example.c $(pkg-config --cflags --libs zlib)
sudo cp -a ../build/usr/lib/libz.so* ../rootfs/libsudo cp a.out ../rootfs- run it on board with command
./a.out
wget https://matt.ucc.asn.au/dropbear/releases/dropbear-2019.78.tar.bz2tar xf dropbear-2019.78.tar.bz2cd dropbear-2019.78./configure --host=arm-linux-gnueabihf --with-zlib=../build/usr --prefix=/usrmake -j4make install DESTDIR=../buildcd ..sudo cp -P build/usr/sbin/dropbear rootfs/usr/sbin/sudo cp -P build/usr/bin/d* rootfs/usr/bin/mkdir -p rootfs/etc/dropbear
vi /etc/passwdand enter below content into it:
root:x:0:0:root:/root:/bin/sh
passwdand enter a passwordvi /etc/init.d/rcSand add below contects into it:
mkdir /dev/pts
mount -t devpts /dev/pts /dev/pts
/usr/sbin/dropbear -FERor if you sure about functionality you can add it toetc/init.d/rcSlike below:
/usr/sbin/dropbear -ER
source for one problem according work: https://lists.ucc.gu.uwa.edu.au/pipermail/dropbear/2007q2/000583.html
export PATH=~/x-tools/armv7-eabihf--uclibc--stable-2018.11-1/bin/:$PATH
arm-linux-ldd <program>
arm-linux-readelf -d <program>
arm-linux-gcc --print-sysroots
arm-linux-strip <program>
1.bdinfo command in u-boot.
2. Safely availabls space ranges from -> start address to sp start - 0x100000(stack size) address
##Problem in running make menuconfig
It needs gcc , ncurese and bison just run sudo apt install gcc libncurses5-dev bison and run make menuconfig again.
Over host machine you should compile again u-boot with CONFIG_ENV_FAT_DEVICE_AND_PART=1:1 to save env on your eMMC.
For that I build a new config with this config modified that you can apply to u-boot project.
export PATH=~/x-tools/armv7-eabihf--uclibc--stable-2018.11-1/bin/:$PATHgit apply boot_from_emmc.patchmake ARCH=arm CROSS_COMPILE=arm-linux- distcleanmake ARCH=arm CROSS_COMPILE=arm-linux- am335x_evm_env_store_on_emmc_configmake ARCH=arm CROSS_COMPILE=arm-linux- -j4- copy created MLO and u-boot.img and uEnv.txt into boot partition of sdcard that you created before.
- copy
flash_bootable_mmc.shinto your rootfs.
- Insert SD card and press SD button to boot the board with sdcard.
- After booting the kernel from sd card run command below to make eMMC bootable:
./flash_bootable_mmc.sh /dev/mmcblk0 /dev/mmcblk1 - Reboot the board and press any key to stop u-boot from automic booting the kernel.
- In u-boot shell enter below commands:
setenv mmcdev 1
saveenv`
- Remove sd card, reset the board and enjoy booting over eMMC
- download this example:https://github.com/bootlin/training-materials/tree/master/code/hello-param
- compile it with simple command:
make
- go through steps above to get kernel 4.14 for beaglebone and compile it
- then apply this patch to it:
0001-Add-test-module-hello-and-new-hello.patch - use
menuconfig, go todevice driveroption and add new modules as modules not built-in. - then compile kenrel and modules again and install them on board
- you can you use them with the command
modprobe <module-name> - you can also apply
0002-Use-kernel-api-in-hello-module.patchto source and then0003-Use-linkded-list-in-hello-module.patchand test updates.
- Clone poky project with command :
git clone -b kirkstone https://git.yoctoproject.org/git/poky --depth=1 - Run
source poky/oe-init-build-env - Open
conf/local.confwith your favourite editor and do below modifications:- Uncomment MACHINE ?= "beaglebone-yocto"
- Add
KERNEL_DEVICETREE:append = " am335x-boneblue.dtbto tell to bitbake to build the beaglebone blue device tree for you - Add
PREFERRED_VERSION_linux-yocto = "5.10%"to tell to bitbake to build the version 5.10 of kernel. at now it doesn't work with 5.15
- Run
bitbake core-image-minimalto build linux image - Run the below command to copy the image to your sd card:
sudo bmaptool copy --bmap tmp/deploy/images/beaglebone-yocto/core-image-minimal-beaglebone-yocto.wic.bmap tmp/deploy/images/beaglebone-yocto/core-image-minimal-beaglebone-yocto.wic /dev/mmcblk0
- Do Linux kernel configuration mentioned in the document [https://bootlin.com/doc/training/embedded-linux-bbb/embedded-linux-bbb-labs.pdf] and compile
- Do what is said in part Lab2: Advanced Yocto configuration in [https://bootlin.com/doc/training/yocto/yocto-labs.pdf]
Another way: you can use the meta-custom layer https://github.com/HosseinAssaran/meta-custom-yoctotraining.git and everything has been done for you. You just need to define beaglebone-yocto as MACHINE in your local.conf and you get the image working with /nfs directory on your host machine.
- Do what ever you did above except modifying extlinux.conf
- Add uEnv.txt to boot partition of your sd card and fill it with below contents:
console=ttyO0,115200n8 ipaddr=192.168.0.100 serverip=192.168.0.1 usbnet_devaddr=f8:dc:7a:00:00:02 usbnet_hostaddr=f8:dc:7a:00:00:01 netargs=setenv bootargs console=${console} root=/dev/nfs ip=${ipaddr}:::::usb0 g_ether.dev_addr=${usbnet_devaddr} g_ether.host_addr=${usbnet_hostaddr} nfsroot=${serverip}:/nfs,nfsvers=3,tcp rootwait rw bootcmd=tftp 0x81000000 zImage; tftp 0x82000000 am335x-boneblue.dtb; bootz 0x81000000 - 0x82000000 uenvcmd=run netargs; run bootcmd
> Written with H.Assaran