Hi Mirzak,
Apologies, I left this sleeping.
This is a bootable run of buildroot on a CM3.
Unfortunately, the HDMI output did not run well and as well, there was a stop at some point at crng init done. I learnt from the web that this could be solved with rng-tools or haveg. I attempted to use them, but couldnt really solve it.
Furthermore, most of the indicated project at the beginning of this post is very useful, however I was not able to find all the incompatibilities.
The relevant files to make this work, are basically the post build and image scripts, the right version of the bootloader and placing a correct roofts. It is not clear to me if at the end, the version of bootloader used (2018.07) might have been an issue.
boot.cmd
fdt addr ${fdt_addr}
fdt get value bootargs /chosen bootargs
run mender_setup
mmc dev ${mender_uboot_dev}
load ${mender_uboot_root} ${kernel_addr_r} /boot/uImage
bootm ${kernel_addr_r} - ${fdt_addr}
run mender_try_to_recover
genimage-raspberrypi.cfg
image boot.vfat {
vfat {
files = {
"bcm2710-rpi-3-b.dtb",
"bcm2710-rpi-3-b-plus.dtb",
"bcm2710-rpi-cm3.dtb",
"u-boot.bin",
"config.txt",
"boot.scr",
"rpi-firmware/bootcode.bin",
"rpi-firmware/fixup.dat",
"rpi-firmware/start.elf",
"rpi-firmware/cmdline.txt",
"rpi-firmware/overlays"
}
}
size = 32M
}
image sdcard.img {
hdimage {
}
partition boot {
partition-type = 0xC
bootable = "true"
image = "boot.vfat"
}
partition rootfsa {
partition-type = 0x83
image = "rootfs.ext4"
}
partition rootfsb {
partition-type = 0x83
image = "rootfs.ext4"
}
partition data {
partition-type = 0x83
image = "data.img"
}
}
post-build.sh
#!/bin/sh
set -ue
BOARD_DIR="$(dirname $0)"
BOARD_NAME="$(basename ${BOARD_DIR})"
# Add a console on tty1
if [ -e ${TARGET_DIR}/etc/inittab ]; then
grep -qE '^tty1::' ${TARGET_DIR}/etc/inittab || \
sed -i '/GENERIC_SERIAL/a\
tty1::respawn:/sbin/getty -L tty1 0 vt100 # HDMI console' ${TARGET_DIR}/etc/inittab
fi
mkdir -p ${TARGET_DIR}/data
cp /home/manu/cm3/config.txt ${BINARIES_DIR}/config.txt
post-image.sh
#!/bin/bash
set -e
BOARD_DIR="$(dirname $0)"
BOARD_NAME="$(basename ${BOARD_DIR})"
GENIMAGE_CFG="/home/manu/cm3/genimage-raspberrypi.cfg"
GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
# 32M data partition
DATA_PART_SIZE=128
for arg in "$@"
do
case "${arg}" in
--add-pi3-miniuart-bt-overlay)
if ! grep -qE '^dtoverlay=' "${BINARIES_DIR}/rpi-firmware/config.txt"; then
echo "Adding 'dtoverlay=pi3-miniuart-bt' to config.txt (fixes ttyAMA0 serial console)."
cat << __EOF__ >> "${BINARIES_DIR}/rpi-firmware/config.txt"
# fixes rpi3 ttyAMA0 serial console
dtoverlay=pi3-miniuart-bt
__EOF__
fi
;;
--aarch64)
# Run a 64bits kernel (armv8)
sed -e '/^kernel=/s,=.*,=Image,' -i "${BINARIES_DIR}/rpi-firmware/config.txt"
if ! grep -qE '^arm_64bit=1' "${BINARIES_DIR}/rpi-firmware/config.txt"; then
cat << __EOF__ >> "${BINARIES_DIR}/rpi-firmware/config.txt"
# enable 64bits support
arm_64bit=1
__EOF__
fi
# Enable uart console
if ! grep -qE '^enable_uart=1' "${BINARIES_DIR}/rpi-firmware/config.txt"; then
cat << __EOF__ >> "${BINARIES_DIR}/rpi-firmware/config.txt"
# enable rpi3 ttyS0 serial console
enable_uart=1
__EOF__
fi
;;
--gpu_mem_256=*|--gpu_mem_512=*|--gpu_mem_1024=*)
# Set GPU memory
gpu_mem="${arg:2}"
sed -e "/^${gpu_mem%=*}=/s,=.*,=${gpu_mem##*=}," -i "${BINARIES_DIR}/rpi-firmware/config.txt"
;;
esac
done
rm -rf "${GENIMAGE_TMP}"
# Make a 32M data partition file
rm -rf ${BINARIES_DIR}/data.img
dd if=/dev/zero of=${BINARIES_DIR}/data.img bs=1M count=${DATA_PART_SIZE}
mkfs.ext4 ${BINARIES_DIR}/data.img
genimage \
--rootpath "${TARGET_DIR}" \
--tmppath "${GENIMAGE_TMP}" \
--inputpath "${BINARIES_DIR}" \
--outputpath "${BINARIES_DIR}" \
--config "${GENIMAGE_CFG}"
exit $?