Added configuration for RaspberryPi 4B

This commit is contained in:
imi415 2021-06-20 18:30:24 +08:00
parent 2f851594c2
commit 7c5b4ee908
Signed by: imi415
GPG Key ID: 17F01E106F9F5E0A
8 changed files with 279 additions and 0 deletions

View File

@ -0,0 +1,30 @@
image boot.vfat {
vfat {
files = {
"bcm2711-rpi-4-b.dtb",
"rpi-firmware/cmdline.txt",
"rpi-firmware/config.txt",
"rpi-firmware/fixup.dat",
"rpi-firmware/start.elf",
"rpi-firmware/overlays",
"Image"
}
}
size = 32M
}
image sdcard.img {
hdimage {
}
partition boot {
partition-type = 0xC
bootable = "true"
image = "boot.vfat"
}
partition rootfs {
partition-type = 0x83
image = "rootfs.ext4"
}
}

View File

@ -0,0 +1,11 @@
#!/bin/sh
set -u
set -e
# 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

View File

@ -0,0 +1,60 @@
#!/bin/bash
set -e
BOARD_DIR="$(dirname $0)"
BOARD_NAME="$(basename ${BOARD_DIR})"
GENIMAGE_CFG="${BOARD_DIR}/genimage-${BOARD_NAME}.cfg"
GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
for arg in "$@"
do
case "${arg}" in
--add-miniuart-bt-overlay)
if ! grep -qE '^dtoverlay=' "${BINARIES_DIR}/rpi-firmware/config.txt"; then
echo "Adding 'dtoverlay=miniuart-bt' to config.txt (fixes ttyAMA0 serial console)."
cat << __EOF__ >> "${BINARIES_DIR}/rpi-firmware/config.txt"
# fixes rpi (3B, 3B+, 3A+, 4B and Zero W) ttyAMA0 serial console
dtoverlay=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
;;
--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
# Pass an empty rootpath. genimage makes a full copy of the given rootpath to
# ${GENIMAGE_TMP}/root so passing TARGET_DIR would be a waste of time and disk
# space. We don't rely on genimage to build the rootfs image, just to insert a
# pre-built one in the disk image.
trap 'rm -rf "${ROOTPATH_TMP}"' EXIT
ROOTPATH_TMP="$(mktemp -d)"
rm -rf "${GENIMAGE_TMP}"
genimage \
--rootpath "${ROOTPATH_TMP}" \
--tmppath "${GENIMAGE_TMP}" \
--inputpath "${BINARIES_DIR}" \
--outputpath "${BINARIES_DIR}" \
--config "${GENIMAGE_CFG}"
exit $?

View File

@ -0,0 +1,99 @@
Raspberry Pi
Intro
=====
These instructions apply to all models of the Raspberry Pi:
- the original models A and B,
- the "enhanced" models A+ and B+,
- the model B2 (aka Raspberry Pi 2)
- the model B3 (aka Raspberry Pi 3).
- the model B4 (aka Raspberry Pi 4).
How to build it
===============
Configure Buildroot
-------------------
There are two RaspberryPi defconfig files in Buildroot, one for each
major variant, which you should base your work on:
For models A, B, A+ or B+:
$ make raspberrypi_defconfig
For model Zero (model A+ in smaller form factor):
$ make raspberrypi0_defconfig
For model 2 B:
$ make raspberrypi2_defconfig
For model 3 B and B+:
$ make raspberrypi3_defconfig
For model 4 B:
$ make raspberrypi4_defconfig
Build the rootfs
----------------
Note: you will need to have access to the network, since Buildroot will
download the packages' sources.
You may now build your rootfs with:
$ make
(This may take a while, consider getting yourself a coffee ;-) )
Result of the build
-------------------
After building, you should obtain this tree:
output/images/
+-- bcm2708-rpi-b.dtb [1]
+-- bcm2708-rpi-b-plus.dtb [1]
+-- bcm2709-rpi-2-b.dtb [1]
+-- bcm2710-rpi-3-b.dtb [1]
+-- bcm2710-rpi-3-b-plus.dtb [1]
+-- bcm2711-rpi-4-b.dtb [1]
+-- boot.vfat
+-- rootfs.ext4
+-- rpi-firmware/
| +-- bootcode.bin
| +-- cmdline.txt
| +-- config.txt
| +-- fixup.dat
| +-- start.elf
| `-- overlays/ [2]
+-- sdcard.img
`-- zImage
[1] Not all of them will be present, depending on the RaspberryPi
model you are using.
[2] Only for the Raspberry Pi 3/4 Models (overlay miniuart-bt is needed
to enable the RPi3 serial console otherwise occupied by the bluetooth
chip). Alternative would be to disable the serial console in cmdline.txt
and /etc/inittab.
How to write the SD card
========================
Once the build process is finished you will have an image called "sdcard.img"
in the output/images/ directory.
Copy the bootable "sdcard.img" onto an SD card with "dd":
$ sudo dd if=output/images/sdcard.img of=/dev/sdX
Insert the SDcard into your Raspberry Pi, and power it up. Your new system
should come up now and start two consoles: one on the serial port on
the P1 header, one on the HDMI output where you can login using a USB
keyboard.

View File

@ -0,0 +1,79 @@
BR2_aarch64=y
BR2_cortex_a72=y
BR2_TOOLCHAIN_BUILDROOT_GLIBC=y
BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_10=y
BR2_PACKAGE_GLIBC_UTILS=y
BR2_BINUTILS_VERSION_2_36_X=y
BR2_GCC_VERSION_10_X=y
BR2_TOOLCHAIN_BUILDROOT_CXX=y
BR2_GCC_ENABLE_LTO=y
BR2_PACKAGE_HOST_GDB=y
BR2_PACKAGE_HOST_GDB_TUI=y
BR2_PACKAGE_HOST_GDB_PYTHON3=y
BR2_GDB_VERSION_10=y
BR2_TARGET_GENERIC_HOSTNAME="system-agent-raspberrypi-4b"
BR2_TARGET_GENERIC_ISSUE="ARE U OKAY ?"
BR2_INIT_SYSTEMD=y
# BR2_TARGET_ENABLE_ROOT_LOGIN is not set
BR2_SYSTEM_BIN_SH_BASH=y
BR2_SYSTEM_DEFAULT_PATH="/bin:/sbin:/usr/bin:/usr/sbin"
BR2_GENERATE_LOCALE="en_US.UTF-8"
BR2_TARGET_LOCALTIME="Asia/Tokyo"
BR2_ROOTFS_USERS_TABLES="$(BR2_EXTERNAL_system_agent_PATH)/customizations/users.table"
BR2_ROOTFS_OVERLAY="$(BR2_EXTERNAL_system_agent_PATH)/customizations/overlay"
BR2_ROOTFS_POST_BUILD_SCRIPT="$(BR2_EXTERNAL_system_agent_PATH)/board/iminc/raspberrypi-4b-system-agent/post-build.sh"
BR2_ROOTFS_POST_IMAGE_SCRIPT="$(BR2_EXTERNAL_system_agent_PATH)/board/iminc/raspberrypi-4b-system-agent/post-image.sh"
BR2_ROOTFS_POST_SCRIPT_ARGS="--add-miniuart-bt-overlay --aarch64"
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_TARBALL=y
BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="$(call github,raspberrypi,linux,081f560bde7188ca6f40cf297bd55c680e0179c0)/linux-081f560bde7188ca6f40cf297bd55c680e0179c0.tar.gz"
BR2_LINUX_KERNEL_DEFCONFIG="bcm2711"
BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL_system_agent_PATH)/board/iminc/raspberrypi-4b-system-agent/linux.fragment"
BR2_LINUX_KERNEL_DTS_SUPPORT=y
BR2_LINUX_KERNEL_INTREE_DTS_NAME="broadcom/bcm2711-rpi-4-b"
BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
BR2_PACKAGE_LINUX_TOOLS_CPUPOWER=y
BR2_PACKAGE_LINUX_TOOLS_GPIO=y
BR2_PACKAGE_LINUX_TOOLS_IIO=y
BR2_PACKAGE_E2FSPROGS=y
BR2_PACKAGE_E2FSPROGS_E4DEFRAG=y
BR2_PACKAGE_E2FSPROGS_RESIZE2FS=y
BR2_PACKAGE_RPI_FIRMWARE=y
BR2_PACKAGE_RPI_FIRMWARE_VARIANT_PI4=y
BR2_PACKAGE_GPTFDISK=y
BR2_PACKAGE_GPTFDISK_GDISK=y
BR2_PACKAGE_GPTFDISK_SGDISK=y
BR2_PACKAGE_I2C_TOOLS=y
BR2_PACKAGE_SPI_TOOLS=y
BR2_PACKAGE_UBOOT_TOOLS=y
BR2_PACKAGE_UBOOT_TOOLS_FIT_SUPPORT=y
BR2_PACKAGE_UBOOT_TOOLS_MKIMAGE=y
BR2_PACKAGE_UBOOT_TOOLS_MKENVIMAGE=y
BR2_PACKAGE_UBOOT_TOOLS_DUMPIMAGE=y
BR2_PACKAGE_LIBOPENSSL_BIN=y
BR2_PACKAGE_LIBOPENSSL_ENGINES=y
BR2_PACKAGE_LIBGPIOD=y
BR2_PACKAGE_LIBGPIOD_TOOLS=y
BR2_PACKAGE_LIBIIO=y
# BR2_PACKAGE_LIBIIO_IIOD is not set
BR2_PACKAGE_LIBIIO_TESTS=y
BR2_PACKAGE_LIBCURL=y
BR2_PACKAGE_LIBCURL_CURL=y
BR2_PACKAGE_NETWORK_MANAGER=y
BR2_PACKAGE_NETWORK_MANAGER_TUI=y
BR2_PACKAGE_NETWORK_MANAGER_MODEM_MANAGER=y
BR2_PACKAGE_OPENSSH=y
BR2_PACKAGE_BASH_COMPLETION=y
BR2_PACKAGE_FILE=y
BR2_PACKAGE_SUDO=y
BR2_PACKAGE_COREUTILS=y
BR2_PACKAGE_HTOP=y
BR2_PACKAGE_UTIL_LINUX_HWCLOCK=y
BR2_PACKAGE_VIM=y
BR2_TARGET_ROOTFS_EXT2=y
BR2_TARGET_ROOTFS_EXT2_4=y
BR2_TARGET_ROOTFS_EXT2_SIZE="128M"
# BR2_TARGET_ROOTFS_TAR is not set
BR2_PACKAGE_HOST_DOSFSTOOLS=y
BR2_PACKAGE_HOST_GENIMAGE=y
BR2_PACKAGE_HOST_MTOOLS=y