meta-digi-arm: Add recipes-bsp/u-boot
Also add the image_types_digi class. Signed-off-by: Alex Gonzalez <alex.gonzalez@digi.com>
This commit is contained in:
parent
f00c7efcef
commit
10c7f1c840
|
|
@ -0,0 +1,199 @@
|
|||
inherit image_types
|
||||
|
||||
IMAGE_BOOTLOADER ?= "u-boot"
|
||||
|
||||
# Handle u-boot suffixes
|
||||
UBOOT_SUFFIX ?= "bin"
|
||||
UBOOT_PADDING ?= "0"
|
||||
UBOOT_SUFFIX_SDCARD ?= "${UBOOT_SUFFIX}"
|
||||
|
||||
#
|
||||
# Handles i.MX mxs bootstream generation
|
||||
#
|
||||
|
||||
# IMX Bootlets Linux bootstream
|
||||
IMAGE_DEPENDS_linux.sb = "elftosb-native imx-bootlets virtual/kernel"
|
||||
IMAGE_LINK_NAME_linux.sb = ""
|
||||
IMAGE_CMD_linux.sb () {
|
||||
kernel_bin="`readlink ${KERNEL_IMAGETYPE}-${MACHINE}.bin`"
|
||||
kernel_dtb="`readlink ${KERNEL_IMAGETYPE}-${MACHINE}.dtb || true`"
|
||||
linux_bd_file=imx-bootlets-linux.bd-${MACHINE}
|
||||
if [ `basename $kernel_bin .bin` = `basename $kernel_dtb .dtb` ]; then
|
||||
# When using device tree we build a zImage with the dtb
|
||||
# appended on the end of the image
|
||||
linux_bd_file=imx-bootlets-linux.bd-dtb-${MACHINE}
|
||||
cat $kernel_bin $kernel_dtb \
|
||||
> $kernel_bin-dtb
|
||||
rm -f ${KERNEL_IMAGETYPE}-${MACHINE}.bin-dtb
|
||||
ln -s $kernel_bin-dtb ${KERNEL_IMAGETYPE}-${MACHINE}.bin-dtb
|
||||
fi
|
||||
|
||||
# Ensure the file is generated
|
||||
rm -f ${IMAGE_NAME}.linux.sb
|
||||
elftosb -z -c $linux_bd_file -o ${IMAGE_NAME}.linux.sb
|
||||
|
||||
# Remove the appended file as it is only used here
|
||||
rm -f $kernel_bin-dtb
|
||||
}
|
||||
|
||||
|
||||
# U-Boot mxsboot generation to SD-Card
|
||||
UBOOT_SUFFIX_SDCARD_mxs ?= "mxsboot-sdcard"
|
||||
IMAGE_DEPENDS_uboot.mxsboot-sdcard = "u-boot-mxsboot-native u-boot"
|
||||
IMAGE_CMD_uboot.mxsboot-sdcard = "mxsboot sd ${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.${UBOOT_SUFFIX} \
|
||||
${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.${UBOOT_SUFFIX_SDCARD}"
|
||||
|
||||
# Default to 3.4GiB images
|
||||
SDCARD_SIZE ?= "3400"
|
||||
|
||||
# Boot partition volume id
|
||||
BOOTDD_VOLUME_ID ?= "Boot ${MACHINE}"
|
||||
|
||||
# Addional space for boot partition
|
||||
BOOT_SPACE ?= "5MiB"
|
||||
|
||||
IMAGE_DEPENDS_sdcard = "parted-native dosfstools-native mtools-native \
|
||||
virtual/kernel ${IMAGE_BOOTLOADER}"
|
||||
|
||||
SDCARD = "${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.sdcard"
|
||||
|
||||
SDCARD_GENERATION_COMMAND_mxs = "generate_mxs_sdcard"
|
||||
SDCARD_GENERATION_COMMAND_mx5 = "generate_imx_sdcard"
|
||||
SDCARD_GENERATION_COMMAND_mx6 = "generate_imx_sdcard"
|
||||
|
||||
#
|
||||
# Create an image that can by written onto a SD card using dd for use
|
||||
# with i.MX SoC family
|
||||
#
|
||||
# External variables needed:
|
||||
# ${SDCARD_ROOTFS} - the rootfs image to incorporate
|
||||
# ${IMAGE_BOOTLOADER} - bootloader to use {u-boot, barebox}
|
||||
#
|
||||
# The disk layout used is:
|
||||
#
|
||||
# 0 - 1M - reserved to bootloader (not partitioned)
|
||||
# 1M - BOOT_SPACE - kernel
|
||||
# BOOT_SPACE - SDCARD_SIZE - rootfs
|
||||
#
|
||||
generate_imx_sdcard () {
|
||||
# Create partition table
|
||||
parted -s ${SDCARD} mklabel msdos
|
||||
parted -s ${SDCARD} mkpart primary 1MiB ${BOOT_SPACE}
|
||||
parted -s ${SDCARD} mkpart primary ${BOOT_SPACE} 100%
|
||||
parted ${SDCARD} print
|
||||
|
||||
case "${IMAGE_BOOTLOADER}" in
|
||||
imx-bootlets)
|
||||
bberror "The imx-bootlets is not supported for i.MX based machines"
|
||||
exit 1
|
||||
;;
|
||||
u-boot)
|
||||
dd if=${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.${UBOOT_SUFFIX_SDCARD} of=${SDCARD} conv=notrunc seek=2 skip=${UBOOT_PADDING} bs=512
|
||||
;;
|
||||
barebox)
|
||||
dd if=${DEPLOY_DIR_IMAGE}/barebox-${MACHINE}.bin of=${SDCARD} conv=notrunc seek=1 skip=1 bs=512
|
||||
dd if=${DEPLOY_DIR_IMAGE}/bareboxenv-${MACHINE}.bin of=${SDCARD} conv=notrunc seek=1 bs=512k
|
||||
;;
|
||||
*)
|
||||
bberror "Unkown IMAGE_BOOTLOADER value"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
BOOT_BLOCKS=$(LC_ALL=C parted -s ${SDCARD} unit b print \
|
||||
| awk '/ 1 / { print substr($4, 1, length($4 -1)) / 1024 }')
|
||||
mkfs.vfat -n "${BOOTDD_VOLUME_ID}" -S 512 -C ${WORKDIR}/boot.img $BOOT_BLOCKS
|
||||
mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/uImage-${MACHINE}.bin ::/uImage
|
||||
if [ -e "${KERNEL_IMAGETYPE}-${MACHINE}.dtb" ]; then
|
||||
kernel_bin="`readlink ${KERNEL_IMAGETYPE}-${MACHINE}.bin`"
|
||||
kernel_dtb="`readlink ${KERNEL_IMAGETYPE}-${MACHINE}.dtb`"
|
||||
if [ `basename $kernel_bin .bin` = `basename $kernel_dtb .dtb` ]; then
|
||||
mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${MACHINE}.dtb ::/machine.dtb
|
||||
fi
|
||||
fi
|
||||
|
||||
dd if=${WORKDIR}/boot.img of=${SDCARD} conv=notrunc seek=1 bs=1M
|
||||
dd if=${SDCARD_ROOTFS} of=${SDCARD} conv=notrunc seek=1 bs=${BOOT_SPACE}
|
||||
}
|
||||
|
||||
#
|
||||
# Create an image that can by written onto a SD card using dd for use
|
||||
# with i.MXS SoC family
|
||||
#
|
||||
# External variables needed:
|
||||
# ${SDCARD_ROOTFS} - the rootfs image to incorporate
|
||||
# ${IMAGE_BOOTLOADER} - bootloader to use {imx-bootlets, u-boot}
|
||||
#
|
||||
generate_mxs_sdcard () {
|
||||
# Create partition table
|
||||
parted -s ${SDCARD} mklabel msdos
|
||||
|
||||
case "${IMAGE_BOOTLOADER}" in
|
||||
imx-bootlets)
|
||||
# The disk layout used is:
|
||||
#
|
||||
# 1M - BOOT_SPACE - kernel
|
||||
# BOOT_SPACE - SDCARD_SIZE - rootfs
|
||||
#
|
||||
parted -s ${SDCARD} mkpart primary 1MiB ${BOOT_SPACE}
|
||||
parted -s ${SDCARD} mkpart primary ${BOOT_SPACE} 100%
|
||||
|
||||
# Empty 4 bytes from boot partition
|
||||
dd if=/dev/zero of=${SDCARD} conv=notrunc seek=2048 count=4
|
||||
|
||||
# Write the bootstream in (2048 + 4) bytes
|
||||
dd if=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.linux.sb of=${SDCARD} conv=notrunc seek=1 seek=2052
|
||||
;;
|
||||
u-boot)
|
||||
# The disk layout used is:
|
||||
#
|
||||
# 1M - 2M - reserved to bootloader and other data
|
||||
# 2M - BOOT_SPACE - kernel
|
||||
# BOOT_SPACE - SDCARD_SIZE - rootfs
|
||||
#
|
||||
parted -s ${SDCARD} mkpart primary 1MiB 2MiB
|
||||
parted -s ${SDCARD} mkpart primary 2MiB ${BOOT_SPACE}
|
||||
parted -s ${SDCARD} mkpart primary ${BOOT_SPACE} 100%
|
||||
|
||||
dd if=${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.${UBOOT_SUFFIX_SDCARD} of=${SDCARD} conv=notrunc seek=1 skip=${UBOOT_PADDING} bs=1MiB
|
||||
BOOT_BLOCKS=$(LC_ALL=C parted -s ${SDCARD} unit b print \
|
||||
| awk '/ 2 / { print substr($4, 1, length($4 -1)) / 1024 }')
|
||||
|
||||
mkfs.vfat -n "${BOOTDD_VOLUME_ID}" -S 512 -C ${WORKDIR}/boot.img $BOOT_BLOCKS
|
||||
mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/uImage-${MACHINE}.bin ::/uImage
|
||||
if [ -e "${KERNEL_IMAGETYPE}-${MACHINE}.dtb" ]; then
|
||||
kernel_bin="`readlink ${KERNEL_IMAGETYPE}-${MACHINE}.bin`"
|
||||
kernel_dtb="`readlink ${KERNEL_IMAGETYPE}-${MACHINE}.dtb`"
|
||||
if [ `basename $kernel_bin .bin` = `basename $kernel_dtb .dtb` ]; then
|
||||
mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${MACHINE}.dtb ::/machine.dtb
|
||||
fi
|
||||
fi
|
||||
|
||||
dd if=${WORKDIR}/boot.img of=${SDCARD} conv=notrunc seek=2 bs=1MiB
|
||||
;;
|
||||
*)
|
||||
bberror "Unkown IMAGE_BOOTLOADER value"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Change partition type for mxs processor family
|
||||
bbnote "Setting partition type to 0x53 as required for mxs' SoC family."
|
||||
echo -n S | dd of=${SDCARD} bs=1 count=1 seek=450 conv=notrunc
|
||||
|
||||
parted ${SDCARD} print
|
||||
|
||||
dd if=${SDCARD_ROOTFS} of=${SDCARD} conv=notrunc seek=1 bs=${BOOT_SPACE}
|
||||
}
|
||||
|
||||
IMAGE_CMD_sdcard () {
|
||||
if [ -z "${SDCARD_ROOTFS}" ]; then
|
||||
bberror "SDCARD_ROOTFS is undefined. To use sdcard image from Freescale's BSP it needs to be defined."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Initialize a sparse file
|
||||
dd if=/dev/zero of=${SDCARD} bs=1 count=0 seek=$(expr 1000 \* 1000 \* ${SDCARD_SIZE})
|
||||
|
||||
${SDCARD_GENERATION_COMMAND}
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
# Copyright (C) 2011 Freescale Semiconductor
|
||||
# Copyright (C) 2012 Digi International
|
||||
# Released under the MIT license (see COPYING.MIT for the terms)
|
||||
|
||||
DESCRIPTION = "bootloader for Digi platforms"
|
||||
require recipes-bsp/u-boot/u-boot.inc
|
||||
|
||||
PROVIDES += "u-boot-digi"
|
||||
|
||||
LICENSE = "GPLv2+"
|
||||
LIC_FILES_CHKSUM = "file://COPYING;md5=4c6cde5df68eff615d36789dc18edd3b"
|
||||
|
||||
DEPENDS_mxs += "elftosb-native"
|
||||
|
||||
PR = "r8"
|
||||
|
||||
# Revision for MX28 based platforms.
|
||||
SRCREV_mxs = "DUB-4.1.2"
|
||||
|
||||
# Revision for MX51 and MX53 platforms
|
||||
# [DIGI] This is currently the agonzal/yocto branch
|
||||
# [DIGI] until DIGI-UBOOT-93 is fixed.
|
||||
SRCREV_mx5 = "f684e0259c4a9f63476a3694d9f0f5a6d21b1943"
|
||||
|
||||
SRC_URI = "git://log-sln-cvs.digi.com/data/vcs/git/u-boot-denx.git"
|
||||
|
||||
UBOOT_MACHINE_ccxmx53js = "ccxmx53js_config"
|
||||
UBOOT_MACHINE_ccxmx51js = "ccxmx51js_config"
|
||||
UBOOT_MACHINE_ccardxmx28js = "ccardxmx28js_config"
|
||||
|
||||
UBOOT_MAKE_TARGET = "u-boot.bin"
|
||||
UBOOT_SUFFIX = "bin"
|
||||
UBOOT_PADDING = "2"
|
||||
|
||||
S = "${WORKDIR}/git"
|
||||
EXTRA_OEMAKE += 'HOSTSTRIP=true'
|
||||
|
||||
PACKAGE_ARCH = "${MACHINE_ARCH}"
|
||||
|
||||
# [DIGI] GNU gold linker is an alternative to GNU linker.
|
||||
do_compile_prepend() {
|
||||
if [ "${@base_contains('DISTRO_FEATURES', 'ld-is-gold', 'ld-is-gold', '', d)}" = "ld-is-gold" ] ; then
|
||||
sed -i 's/$(CROSS_COMPILE)ld/$(CROSS_COMPILE)ld.bfd/g' config.mk
|
||||
fi
|
||||
}
|
||||
|
||||
COMPATIBLE_MACHINE = "(mxs|mx5)"
|
||||
|
||||
Loading…
Reference in New Issue