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_forward
ifconfig -a
iptables --table nat --append POSTROUTING --out-interface <wireless-interface> -j MASQUERADE
iptables --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.xz
tar xvf Angstrom-Cloud9-IDE-GNOME-eglibc-ipk-v2012.12-beaglebone-2013.06.20.img.xz
dd if=Angstrom-Cloud9-IDE-GNOME-eglibc-ipk-v2012.12-beaglebone-2013.06.20.img of=/dev/mmcblk0
load mmc 0:2 0x82000000 /boot/uImage
load mmc 0:2 0x88000000 /boot/am335x-boneblue.dtb
setenv bootargs console=ttyO0,115200 root=/dev/mmcblk0p2 rw
bootm 0x82000000 - 0x88000000
sudo minicom
- reset the board, press any key and while you are in uboot command line enter
loadx
- then
ctrl+z
and thens
- choose
xmodem
from 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.txt
is 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
C
pressctrl+a
and thens
and select xmodem - Choose
SPL
pre-built image and hit enter - Repeat 4 and 5 step but for
u-boot.img
- enter
loadx 0x820000000
and Repeat 4 and 5 steps but foruImage
- enter
loadx 0x880000000
and Repeat 4 and 5 steps but foram335x-boneblack.dtb
- enter
loadx 0x880800000
and Repeat 4 and 5 steps but forinitramfs
10.entersetenv bootargs console=ttyO0,115200 root=/dev/ram0 rw initrd=0x88080000
11.enterbootm 0x82000000 0x88080000 0x88000000
wget https://toolchains.bootlin.com/downloads/releases/toolchains/armv7-eabihf/tarballs/armv7-eabihf--uclibc--stable-2018.11-1.tar.bz2
tar xf armv7-eabihf--uclibc--stable-2018.11-1.tar.bz2 -C ~/x-tools
sudo apt install gcc-arm-linux-gnueabihf
sudo apt install flex
export PATH=~/x-tools/armv7-eabihf--uclibc--stable-2018.11-1/bin/:$PATH
make ARCH=arm CROSS_COMPILE=arm-linux- distclean
make ARCH=arm CROSS_COMPILE=arm-linux- am335x_evm_config
make ARCH=arm CROSS_COMPILE=arm-linux- menuconfig
make ARCH=arm CROSS_COMPILE=arm-linux- -j4
wget https://www.busybox.net/downloads/busybox-1.31.1.tar.bz2
tar xf busybox-1.31.1.tar.bz2
cd busybox-1.31.1
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- CONFIG_PREFIX=<install_path> install
sudo apt install lzop
wget https://github.com/beagleboard/linux/archive/4.14.zip -o linux-4.14.zip
unzip linux-4.14.zip
cd linux-4.14
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- distclean
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bb.org_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- uImage dtbs LOADADDR=0x80008000 -j4
or to build zImage domake ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j4 modules
make 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
MLO
andu-boot.img
into 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
boot
anddev
directory in ROOTFS partiotion - copy kernel built image from
arch/arm/boot/uImage
intoboot
directory of ROOTFS partition - copy device tree file from
arch/arm/boot/dts/am335x-boneblue.dtb
intoboot
directory of ROOTFS partition - make
proc
dirctory in the rootfs directory - make
etc/init.d
directory in the rootfs directory of beaglebone - go rootfs directory and run
sudo nano etc/init.d/rcS
and 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-hpa
sudo chown tftp:tftp /var/lib/tftpboot
sudo apt install nfs-kernel-server
sudo 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 -arv
sudo service nfs-kernel-server restart
nmcli 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=y
in .config. Then make kernel source again.
- If you have a uImage do:
- copy kernel built image from
arch/arm/boot/uImage
into/var/lib/tftpboot
- copy device tree file from
arch/arm/boot/dts/am335x-boneblue.dtb
into/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_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 0x82000000 ${serverip}:uImage
tftpboot 0x88000000 ${serverip}:am335x-boneblue.dtb
set rootpath /srv/nfs/bbb,nolock,wsize=1024,rsize=1024,nfsvers=3 rootwait rootdelay=2
set 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
bootm 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 menuconfig
search these two settings and make sure they are enabled and then build u-boot again.USB_HOST_ETHER=y
USB_ETHER_ASIX88179=y
- In steps in compile kernel after entering
make menuconfig
search these two settings and make sure they are enabled and then build kernel again.CONFIG_USB_NET_AX88179_178A=y
USB_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 start
set ipaddr 192.168.6.20
ping 192.168.6.10
- if you succedd you receive
host 192.168.6.10 is alive
in your terminal. set serverip 192.168.6.10
tftpboot 0x82000000 ${serverip}:uImage
tftpboot 0x88000000 ${serverip}:am335x-boneblue.dtb
set rootpath /srv/nfs/bbb,nolock,wsize=1024,rsize=1024,nfsvers=3 rootwait rootdelay=5
set 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_ether
sudo 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.c
sudo cp app /srv/nfs/bbb/
cd /usr/arm-linux-gnueabihf/lib
sudo 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-gnueabihf
arm-linux-gnueabihf-gcc --print-sysroot
cp -a /usr/arm-linux-gnueabihf/lib/* lib
wget https://www.zlib.net/zlib-1.2.11.tar.gz
tar xf zlib-1.2.11.tar.gz
cd zlib-1.2.11.tar.gz
CC=arm-linux-gnueabihf-gcc ./configure --prefix /usr
make
mkdir ../build
make install DESTDIR=../build
tree ../build
mkdir ../zlib-tests
cp test/example.c ../zlib-tests/
cd ../zlib-tests/
arm-linux-gnueabihf-gcc example.c -I ../build/usr/include/ -L ../build/usr/lib/ -lz
or
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/lib
sudo cp a.out ../rootfs
- run it on board with command
./a.out
wget https://matt.ucc.asn.au/dropbear/releases/dropbear-2019.78.tar.bz2
tar xf dropbear-2019.78.tar.bz2
cd dropbear-2019.78
./configure --host=arm-linux-gnueabihf --with-zlib=../build/usr --prefix=/usr
make -j4
make install DESTDIR=../build
cd ..
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/passwd
and enter below content into it:
root:x:0:0:root:/root:/bin/sh
passwd
and enter a passwordvi /etc/init.d/rcS
and add below contects into it:
mkdir /dev/pts
mount -t devpts /dev/pts /dev/pts
/usr/sbin/dropbear -FER
or if you sure about functionality you can add it toetc/init.d/rcS
like 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/:$PATH
git apply boot_from_emmc.patch
make ARCH=arm CROSS_COMPILE=arm-linux- distclean
make ARCH=arm CROSS_COMPILE=arm-linux- am335x_evm_env_store_on_emmc_config
make 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.sh
into 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 driver
option 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.patch
to source and then0003-Use-linkded-list-in-hello-module.patch
and 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.conf
with your favourite editor and do below modifications:- Uncomment MACHINE ?= "beaglebone-yocto"
- Add
KERNEL_DEVICETREE:append = " am335x-boneblue.dtb
to 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-minimal
to 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