diff --git a/board/raspberrypi/config_common.txt b/board/raspberrypi/config_common.txt index c09ecca..fdcdff7 100644 --- a/board/raspberrypi/config_common.txt +++ b/board/raspberrypi/config_common.txt @@ -7,7 +7,8 @@ start_file=start.elf fixup_file=fixup.dat -kernel=zImage +device_tree=bcm2835-rpi-b-plus.dtb +kernel=u-boot.bin # To use an external initramfs file #initramfs rootfs.cpio.gz @@ -15,9 +16,10 @@ kernel=zImage # 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 +enable_uart=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 +gpu_mem_256=64 +gpu_mem_512=64 +gpu_mem_1024=128 diff --git a/board/raspberrypi/genimage.cfg b/board/raspberrypi/genimage.cfg deleted file mode 100644 index 6c09b4f..0000000 --- a/board/raspberrypi/genimage.cfg +++ /dev/null @@ -1,53 +0,0 @@ -/* genimage.cfg - SD card image layout for Raspberry Pi - * - * Partition layout: - * - boot (FAT32, 64MB): kernel, device tree, bootloader files - * - rootfs (ext4, 256MB): root filesystem - * - * The final image is written to sdcard.img. - * - * Adjust partition sizes as needed for your project. Projects can - * override this file by providing their own genimage.cfg and setting - * GENIMAGE_CFG in their post-image script. - */ - -image boot.vfat { - vfat { - files = { - "bcm2710-rpi-3-b.dtb", - "bcm2711-rpi-4-b.dtb", - "rpi-firmware/bootcode.bin", - "rpi-firmware/start.elf", - "rpi-firmware/fixup.dat", - "rpi-firmware/config.txt", - "rpi-firmware/cmdline.txt", - "Image" - } - } - - size = 64M -} - -image rootfs.ext4 { - ext4 { - label = "rootfs" - } - - size = 256M -} - -image sdcard.img { - hdimage { - } - - partition boot { - partition-type = 0xC - bootable = "true" - image = "boot.vfat" - } - - partition rootfs { - partition-type = 0x83 - image = "rootfs.ext4" - } -} diff --git a/board/raspberrypi/genimage.cfg.in b/board/raspberrypi/genimage.cfg.in new file mode 100644 index 0000000..fd38b86 --- /dev/null +++ b/board/raspberrypi/genimage.cfg.in @@ -0,0 +1,25 @@ +image boot.vfat { + vfat { + files = { +#BOOT_FILES# + } + } + + size = 32M +} + +image sdcard.img { + hdimage { + } + + partition boot { + partition-type = 0xC + bootable = "true" + image = "boot.vfat" + } + + partition rootfs { + partition-type = 0x83 + image = "rootfs.ext4" + } +} diff --git a/board/raspberrypi/post-image.sh b/board/raspberrypi/post-image.sh new file mode 100755 index 0000000..9b9eac9 --- /dev/null +++ b/board/raspberrypi/post-image.sh @@ -0,0 +1,44 @@ +#!/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" + +# generate genimage from template if a board specific variant doesn't exists +if [ ! -e "${GENIMAGE_CFG}" ]; then + GENIMAGE_CFG="${BINARIES_DIR}/genimage.cfg" + FILES=() + + for i in "${BINARIES_DIR}"/*.dtb "${BINARIES_DIR}"/rpi-firmware/*; do + FILES+=( "${i#${BINARIES_DIR}/}" ) + done + + KERNEL=$(sed -n 's/^kernel=//p' "${BINARIES_DIR}/rpi-firmware/config.txt") + FILES+=( "${KERNEL}" ) + + BOOT_FILES=$(printf '\\t\\t\\t"%s",\\n' "${FILES[@]}") + sed "s|#BOOT_FILES#|${BOOT_FILES}|" "${BOARD_DIR}/genimage.cfg.in" \ + > "${GENIMAGE_CFG}" +fi + +# 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 $? diff --git a/board/raspberrypi/post_image.sh b/board/raspberrypi/post_image.sh deleted file mode 100755 index d06ebc8..0000000 --- a/board/raspberrypi/post_image.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -# post_image.sh - Common post-image script for Raspberry Pi -# -# Called by Buildroot after filesystem images (ext4, etc.) are generated. -# Arguments: -# $1 = path to the images directory (e.g., output/images) -# -# Environment: -# BR2_EXTERNAL_RPI_COMMON_PATH = path to this external tree -# BINARIES_DIR = same as $1 -# BUILD_DIR = path to the build directory -# -# This script uses genimage to assemble the final SD card image -# from the boot files and root filesystem. - -set -e - -BOARD_DIR="${BR2_EXTERNAL_RPI_COMMON_PATH}/board/raspberrypi" - -# Use project-specific genimage.cfg if it exists, otherwise use common one. -# Projects can override by setting GENIMAGE_CFG in their own post-image script. -GENIMAGE_CFG="${GENIMAGE_CFG:-${BOARD_DIR}/genimage.cfg}" - -# genimage requires a temporary directory -GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp" -rm -rf "${GENIMAGE_TMP}" - -genimage \ - --rootpath "${TARGET_DIR}" \ - --tmppath "${GENIMAGE_TMP}" \ - --inputpath "${BINARIES_DIR}" \ - --outputpath "${BINARIES_DIR}" \ - --config "${GENIMAGE_CFG}" - -echo ">>> SD card image generated: ${BINARIES_DIR}/sdcard.img" diff --git a/board/raspberrypi/uboot_defconfig b/board/raspberrypi/uboot_defconfig new file mode 100644 index 0000000..e7a1961 --- /dev/null +++ b/board/raspberrypi/uboot_defconfig @@ -0,0 +1,51 @@ +CONFIG_ARM=y +CONFIG_ARCH_CPU_INIT=y +CONFIG_ARCH_BCM283X=y +CONFIG_TEXT_BASE=0x00008000 +CONFIG_SYS_MALLOC_F_LEN=0x400 +CONFIG_TARGET_RPI=y +CONFIG_NR_DRAM_BANKS=1 +CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y +CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x7ffff00 +CONFIG_ENV_SIZE=0x4000 +CONFIG_DEFAULT_DEVICE_TREE="bcm2835-rpi-b" +CONFIG_OF_LIBFDT_OVERLAY=y +CONFIG_SYS_LOAD_ADDR=0x1000000 +CONFIG_EFI_LOADER=y +CONFIG_BOOTSTD_DEFAULTS=y +CONFIG_OF_BOARD_SETUP=y +CONFIG_FDT_SIMPLEFB=y +CONFIG_USE_PREBOOT=y +CONFIG_SYS_PBSIZE=1049 +# CONFIG_DISPLAY_CPUINFO is not set +# CONFIG_DISPLAY_BOARDINFO is not set +CONFIG_MISC_INIT_R=y +CONFIG_SYS_PROMPT="U-Boot> " +CONFIG_CMD_GPIO=y +CONFIG_CMD_MMC=y +CONFIG_CMD_USB=y +CONFIG_CMD_FS_UUID=y +CONFIG_ENV_FAT_DEVICE_AND_PART="0:1" +CONFIG_ENV_RELOC_GD_ENV_ADDR=y +CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y +CONFIG_TFTP_TSIZE=y +CONFIG_BCM2835_GPIO=y +CONFIG_MMC_SDHCI=y +CONFIG_MMC_SDHCI_BCM2835=y +CONFIG_PINCTRL=y +# CONFIG_PINCTRL_GENERIC is not set +# CONFIG_REQUIRE_SERIAL_CONSOLE is not set +CONFIG_SYSINFO=y +CONFIG_SYSINFO_SMBIOS=y +CONFIG_USB=y +CONFIG_USB_DWC2=y +CONFIG_USB_KEYBOARD=y +CONFIG_USB_HOST_ETHER=y +CONFIG_USB_ETHER_SMSC95XX=y +CONFIG_VIDEO=y +# CONFIG_VIDEO_BPP8 is not set +# CONFIG_VIDEO_BPP16 is not set +CONFIG_SYS_WHITE_ON_BLACK=y +CONFIG_VIDEO_BCM2835=y +CONFIG_CONSOLE_SCROLL_LINES=10 +CONFIG_PHYS_TO_BUS=y diff --git a/configs/raspberrypi_common_defconfig b/configs/raspberrypi_common_defconfig index cc7f525..5aca594 100644 --- a/configs/raspberrypi_common_defconfig +++ b/configs/raspberrypi_common_defconfig @@ -6,13 +6,13 @@ BR2_GLOBAL_PATCH_DIR="board/raspberrypi/patches" BR2_DOWNLOAD_FORCE_CHECK_HASHES=y BR2_SYSTEM_DHCP="eth0" BR2_ROOTFS_POST_BUILD_SCRIPT="board/raspberrypi/post-build.sh" -BR2_ROOTFS_POST_IMAGE_SCRIPT="board/raspberrypi/post-image.sh" +BR2_ROOTFS_POST_IMAGE_SCRIPT="$(BR2_EXTERNAL_RPI_COMMON_PATH)/board/raspberrypi/post-image.sh" BR2_LINUX_KERNEL=y BR2_LINUX_KERNEL_CUSTOM_TARBALL=y BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="$(call github,raspberrypi,linux,21b410140c47ffab5668399f6f143c7d7b935c8b)/linux-21b410140c47ffab5668399f6f143c7d7b935c8b.tar.gz" BR2_LINUX_KERNEL_DEFCONFIG="bcmrpi" BR2_LINUX_KERNEL_DTS_SUPPORT=y -BR2_LINUX_KERNEL_INTREE_DTS_NAME="broadcom/bcm2708-rpi-b-rev1 broadcom/bcm2708-rpi-b broadcom/bcm2708-rpi-b-plus broadcom/bcm2708-rpi-cm" +BR2_LINUX_KERNEL_INTREE_DTS_NAME="broadcom/bcm2835-rpi-b-plus broadcom/bcm2708-rpi-b-plus" BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y BR2_PACKAGE_XZ=y @@ -28,6 +28,11 @@ BR2_TARGET_ROOTFS_EXT2=y BR2_TARGET_ROOTFS_EXT2_4=y BR2_TARGET_ROOTFS_EXT2_SIZE="120M" # BR2_TARGET_ROOTFS_TAR is not set +BR2_TARGET_UBOOT=y +BR2_TARGET_UBOOT_USE_CUSTOM_CONFIG=y +BR2_TARGET_UBOOT_CUSTOM_CONFIG_FILE="$(BR2_EXTERNAL_RPI_COMMON_PATH)/board/raspberrypi/uboot_defconfig" +BR2_TARGET_UBOOT_NEEDS_OPENSSL=y +BR2_TARGET_UBOOT_NEEDS_GNUTLS=y BR2_PACKAGE_HOST_DOSFSTOOLS=y BR2_PACKAGE_HOST_GENIMAGE=y BR2_PACKAGE_HOST_KMOD_XZ=y