Skip to content

Commit

Permalink
simplify build process
Browse files Browse the repository at this point in the history
  • Loading branch information
dgsiegel committed May 4, 2022
1 parent 323ea1f commit 5bf2328
Show file tree
Hide file tree
Showing 15 changed files with 175 additions and 158 deletions.
37 changes: 37 additions & 0 deletions board/config_0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Please note that this is only a sample, we recommend you to change it to fit
# your needs.
# You should override this file using BR2_PACKAGE_RPI_FIRMWARE_CONFIG_FILE.
# See http://buildroot.org/manual.html#rootfs-custom
# and http://elinux.org/RPiconfig for a description of config.txt syntax

start_file=start.elf
fixup_file=fixup.dat

kernel=zImage

# To use an external initramfs file
#initramfs rootfs.cpio.gz

# Disable overscan assuming the display supports displaying the full resolution
# If the text shown on the screen disappears off the edge, comment this out
disable_overscan=1

# How much memory in MB to assign to the GPU on Pi models having
# 256, 512 or 1024 MB total memory
gpu_mem_256=100
gpu_mem_512=100
gpu_mem_1024=100

# Enable OTG host mode
dtoverlay=dwc2

# Enable serial console
enable_uart=1

# Disable boot delay
boot_delay=0

# Enable turbo mode during boot time
initial_turbo=10

camera_auto_detect=1
38 changes: 38 additions & 0 deletions board/config_0w.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Please note that this is only a sample, we recommend you to change it to fit
# your needs.
# You should override this file using BR2_PACKAGE_RPI_FIRMWARE_CONFIG_FILE.
# See http://buildroot.org/manual.html#rootfs-custom
# and http://elinux.org/RPiconfig for a description of config.txt syntax

start_file=start.elf
fixup_file=fixup.dat

kernel=zImage

# To use an external initramfs file
#initramfs rootfs.cpio.gz

# Disable overscan assuming the display supports displaying the full resolution
# If the text shown on the screen disappears off the edge, comment this out
disable_overscan=1

# How much memory in MB to assign to the GPU on Pi models having
# 256, 512 or 1024 MB total memory
gpu_mem_256=100
gpu_mem_512=100
gpu_mem_1024=100

# fixes rpi (3B, 3B+, 3A+, 4B and Zero W) ttyAMA0 serial console
dtoverlay=miniuart-bt

# Enable OTG host mode
dtoverlay=dwc2

# Enable serial console
enable_uart=1

# Disable boot delay
boot_delay=0

# Enable turbo mode during boot time
initial_turbo=10
38 changes: 38 additions & 0 deletions board/config_4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Please note that this is only a sample, we recommend you to change it to fit
# your needs.
# You should override this file using BR2_PACKAGE_RPI_FIRMWARE_CONFIG_FILE.
# See http://buildroot.org/manual.html#rootfs-custom
# and http://elinux.org/RPiconfig for a description of config.txt syntax

start_file=start4.elf
fixup_file=fixup4.dat

kernel=zImage

# To use an external initramfs file
#initramfs rootfs.cpio.gz

# Disable overscan assuming the display supports displaying the full resolution
# If the text shown on the screen disappears off the edge, comment this out
disable_overscan=1

# How much memory in MB to assign to the GPU on Pi models having
# 256, 512 or 1024 MB total memory
gpu_mem_256=100
gpu_mem_512=100
gpu_mem_1024=100

# fixes rpi (3B, 3B+, 3A+, 4B and Zero W) ttyAMA0 serial console
dtoverlay=miniuart-bt

# Enable OTG host mode
dtoverlay=dwc2

# Enable serial console
enable_uart=1

# Disable boot delay
boot_delay=0

# Enable turbo mode during boot time
initial_turbo=10
4 changes: 2 additions & 2 deletions board/genimage-raspberrypi0.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ image boot.vfat {
"rpi-firmware/fixup.dat",
"rpi-firmware/start.elf",
"rpi-firmware/overlays",
"zImage",
"camera.txt",
"enable-serial-debug",
"zImage"
"enable-serial-debug"
}
}
size = 16M
Expand Down
4 changes: 2 additions & 2 deletions board/genimage-raspberrypi0w.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ image boot.vfat {
"rpi-firmware/fixup.dat",
"rpi-firmware/start.elf",
"rpi-firmware/overlays",
"zImage",
"camera.txt",
"enable-serial-debug",
"zImage"
"enable-serial-debug"
}
}
size = 16M
Expand Down
4 changes: 2 additions & 2 deletions board/genimage-raspberrypi4.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ image boot.vfat {
"rpi-firmware/fixup.dat",
"rpi-firmware/start.elf",
"rpi-firmware/overlays",
"zImage",
"camera.txt",
"enable-serial-debug",
"zImage"
"enable-serial-debug"
}
}
size = 16M
Expand Down
30 changes: 30 additions & 0 deletions board/linux-additional.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Additional kernel config

# Disable unneeded modules
# CONFIG_NET is not set
# CONFIG_BT is not set
# CONFIG_SOUND is not set
# CONFIG_SND is not set
# CONFIG_DVB_USB is not set

# USB Serial
CONFIG_USB_G_SERIAL=y
CONFIG_USB_CDC_COMPOSITE=y

# USB ConfigFS
CONFIG_USB_GADGET=y
CONFIG_USB_CONFIGFS=y
CONFIG_USB_CONFIGFS_SERIAL=y

# SquashFS
CONFIG_SQUASHFS=y
CONFIG_SQUASHFS_XATTR=y
CONFIG_SQUASHFS_LZ4=y
CONFIG_SQUASHFS_LZO=y
CONFIG_SQUASHFS_XZ=y

# Camera
CONFIG_MEDIA_SUPPORT=y
CONFIG_MEDIA_USB_SUPPORT=y
CONFIG_USB_VIDEO_CLASS=y

53 changes: 0 additions & 53 deletions board/linux-raspberrypi4.config

This file was deleted.

7 changes: 1 addition & 6 deletions board/post-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ mkdir -p "${TARGET_DIR}"/etc/systemd/system/getty.target.wants
ln -sf /usr/lib/systemd/system/serial-getty@.service "${TARGET_DIR}"/etc/systemd/system/getty.target.wants/serial-getty@ttyGS0.service
sed '/^ExecStart=/ s/-o .-p -- ..u./--skip-login --noclear --noissue --login-options "-f root"/' -i "${TARGET_DIR}"/usr/lib/systemd/system/serial-getty@.service

# Add wireless wpa for wlan0
#ln -sf /usr/lib/systemd/system/wpa_supplicant@.service "${TARGET_DIR}"/etc/systemd/system/multi-user.target.wants/wpa_supplicant@wlan0.service

if ! grep -qE '/var' "${TARGET_DIR}/etc/fstab"; then
echo 'tmpfs /var tmpfs rw,mode=1777,size=64m' >> "${TARGET_DIR}/etc/fstab"
fi
Expand All @@ -30,9 +27,7 @@ ln -sf /dev/null "${TARGET_DIR}"/etc/systemd/system/sys-kernel-debug.mount
ln -sf /dev/null "${TARGET_DIR}"/etc/systemd/system/dev-mqueue.mount
ln -sf /dev/null "${TARGET_DIR}"/etc/systemd/system/systemd-update-utmp.service
ln -sf /dev/null "${TARGET_DIR}"/etc/systemd/system/systemd-update-utmp-runlevel.service
if [[ ${TARGET_DIR} != *"raspberrypi0cam"* ]]; then
ln -sf /dev/null "${TARGET_DIR}"/etc/systemd/system/network.service
fi
ln -sf /dev/null "${TARGET_DIR}"/etc/systemd/system/network.service

# Set os-release file
SHOWMEWEBCAM_VERSION=$(support/scripts/setlocalversion "${BR2_EXTERNAL_PICAM_PATH}")
Expand Down
99 changes: 17 additions & 82 deletions board/post-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,90 +5,30 @@ set -e
GENIMAGE_CFG="$(dirname "$0")/genimage-${BOARDNAME}.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"
# Inform the kernel about the filesystem and ro state
if ! grep -qE 'rootfstype=squashfs ro' "${BINARIES_DIR}/rpi-firmware/cmdline.txt"; then
sed '/^root=/ s/$/ rootfstype=squashfs ro/' -i "${BINARIES_DIR}/rpi-firmware/cmdline.txt"
fi

# 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"
;;
--configure-picam)
# Configure picam
if ! grep -qE '^dtoverlay=dwc2' "${BINARIES_DIR}/rpi-firmware/config.txt"; then

cat << __EOF__ >> "${BINARIES_DIR}/rpi-firmware/config.txt"
dtoverlay=dwc2
__EOF__
fi

# Configure uart on 40-pin header
if ! grep -qE '^enable_uart=1' "${BINARIES_DIR}/rpi-firmware/config.txt"; then

cat << __EOF__ >> "${BINARIES_DIR}/rpi-firmware/config.txt"
enable_uart=1
__EOF__
fi
if ! grep -qE 'modules-load=dwc2,libcomposite' "${BINARIES_DIR}/rpi-firmware/cmdline.txt"; then
sed '/^root=/ s/$/ modules-load=dwc2,libcomposite/' -i "${BINARIES_DIR}/rpi-firmware/cmdline.txt"
fi

# Set the bootloader delay to 0 seconds
if ! grep -qE '^boot_delay=0' "${BINARIES_DIR}/rpi-firmware/config.txt"; then
cat << __EOF__ >> "${BINARIES_DIR}/rpi-firmware/config.txt"
boot_delay=0
__EOF__
fi

# Set turbo mode for boot
if ! grep -qE '^initial_turbo' "${BINARIES_DIR}/rpi-firmware/config.txt"; then
cat << __EOF__ >> "${BINARIES_DIR}/rpi-firmware/config.txt"
initial_turbo=10
__EOF__
fi

# Inform the kernel about the filesystem and ro state
if ! grep -qE 'rootfstype=squashfs ro' "${BINARIES_DIR}/rpi-firmware/cmdline.txt"; then
sed '/^root=/ s/$/ rootfstype=squashfs ro/' -i "${BINARIES_DIR}/rpi-firmware/cmdline.txt"
fi
# Suppress kernel output during boot
if ! grep -qE 'quiet' "${BINARIES_DIR}/rpi-firmware/cmdline.txt"; then
sed '/^root=/ s/$/ quiet/' -i "${BINARIES_DIR}/rpi-firmware/cmdline.txt"
fi

if ! grep -qE 'modules-load=dwc2,libcomposite' "${BINARIES_DIR}/rpi-firmware/cmdline.txt"; then
sed '/^root=/ s/$/ modules-load=dwc2,libcomposite/' -i "${BINARIES_DIR}/rpi-firmware/cmdline.txt"
fi

# Suppress kernel output during boot
if ! grep -qE 'quiet' "${BINARIES_DIR}/rpi-firmware/cmdline.txt"; then
sed '/^root=/ s/$/ quiet/' -i "${BINARIES_DIR}/rpi-firmware/cmdline.txt"
fi

# Add default camera.txt and add custom config if it exists
cp "$BR2_EXTERNAL_PICAM_PATH/package/piwebcam/camera.txt" "${BINARIES_DIR}/camera.txt"
if [ -f "$BR2_EXTERNAL_PICAM_PATH/camera.txt" ]; then
cat << __EOF__ >> "${BINARIES_DIR}/camera.txt"
# Add default camera.txt and add custom config if it exists
cp "$BR2_EXTERNAL_PICAM_PATH/package/piwebcam/camera.txt" "${BINARIES_DIR}/camera.txt"
if [ -f "$BR2_EXTERNAL_PICAM_PATH/camera.txt" ]; then
cat << __EOF__ >> "${BINARIES_DIR}/camera.txt"
# User settings added during build
__EOF__
cat "$BR2_EXTERNAL_PICAM_PATH/camera.txt" >> "${BINARIES_DIR}/camera.txt"
fi
cat "$BR2_EXTERNAL_PICAM_PATH/camera.txt" >> "${BINARIES_DIR}/camera.txt"
fi

# Add default enable-serial-debug file
cat << __EOF__ >> "${BINARIES_DIR}/enable-serial-debug"
Expand All @@ -101,11 +41,6 @@ __EOF__
# have to manually create this file if you want to access the console.
__EOF__

;;
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
Expand Down
9 changes: 0 additions & 9 deletions build-showmewebcam.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,7 @@ esac
CONFIG_="BR2" KCONFIG_CONFIG="configs/${BOARDNAME}_defconfig" "$BUILDROOT_DIR/support/kconfig/merge_config.sh" -m -r configs/config "configs/$BOARDNAME"
sed "1i ### DO NOT EDIT, this file was automatically generated\n" -i "configs/${BOARDNAME}_defconfig"

# Merge kernel configurations
if [ -f "board/linux-${BOARDNAME}.config" ]; then
KCONFIG_CONFIG="board/linux.config" "$BUILDROOT_DIR/support/kconfig/merge_config.sh" -m -r board/linux-base.config "board/linux-${BOARDNAME}.config"
else
cp board/linux-base.config board/linux.config
fi
sed "1i ### DO NOT EDIT, this file was automatically generated\n" -i board/linux.config

# Create full buildroot configuration
BR2_EXTERNAL="$(pwd)" make O="$(pwd)/output/$BOARDNAME" -C "$BUILDROOT_DIR" "${BOARDNAME}_defconfig"

# Build
make -C "output/$BOARDNAME" all
Loading

0 comments on commit 5bf2328

Please sign in to comment.