From eb352fc6168b382bebd4587baadaecd754c96229 Mon Sep 17 00:00:00 2001 From: Dalon Westergreen Date: Mon, 18 Apr 2016 19:02:58 -0700 Subject: Clean up variables for uboot -> Moved common variables to socfpga.inc --- classes/image_types_socfpga.bbclass | 134 --------------------------- conf/machine/arria5.conf | 6 +- conf/machine/cyclone5.conf | 13 ++- conf/machine/include/socfpga.inc | 9 ++ recipes-bsp/u-boot/u-boot-socfpga_2016.03.bb | 15 +-- recipes-bsp/u-boot/u-boot-target-env.inc | 69 -------------- 6 files changed, 26 insertions(+), 220 deletions(-) delete mode 100644 classes/image_types_socfpga.bbclass delete mode 100644 recipes-bsp/u-boot/u-boot-target-env.inc diff --git a/classes/image_types_socfpga.bbclass b/classes/image_types_socfpga.bbclass deleted file mode 100644 index 609e651..0000000 --- a/classes/image_types_socfpga.bbclass +++ /dev/null @@ -1,134 +0,0 @@ -inherit image_types - -IMAGE_BOOTLOADER ?= "u-boot-socfpga" -SDCARD_ROOTFS ?= "${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ext3" - -# Boot partition size [in KiB] -IMAGE_ROOTFS_ALIGNMENT_cyclone5 ?= "2048" -IMAGE_ROOTFS_ALIGNMENT_arria5 ?= "2048" -IMAGE_ROOTFS_ALIGNMENT_arria10 ?= "10240" - -BOOT_SPACE ?= "102400" - -IMAGE_DEPENDS_sdcard = "parted-native:do_populate_sysroot \ - dosfstools-native:do_populate_sysroot \ - mtools-native:do_populate_sysroot \ - virtual/kernel:do_deploy \ - ${@d.getVar('IMAGE_BOOTLOADER', True) and d.getVar('IMAGE_BOOTLOADER', True) + ':do_deploy' or ''}" - -SDCARD_GENERATION_COMMAND_cyclone5 = "generate_28nm_sdcard" -SDCARD_GENERATION_COMMAND_arria5 = "generate_28nm_sdcard" - -# -# Generate the boot image with the boot scripts and required Device Tree -# files -_generate_boot_image() { - local boot_part=$1 - - # Create boot partition image - BOOT_BLOCKS=$(LC_ALL=C parted -s ${SDCARD} unit b print \ - | awk "/ $boot_part / { print substr(\$4, 1, length(\$4 -1)) / 1024 }") - - # mkdosfs will sometimes use FAT16 when it is not appropriate, - # resulting in a boot failure from SYSLINUX. Use FAT32 for - # images larger than 512MB, otherwise let mkdosfs decide. - if [ $(expr $BOOT_BLOCKS / 1024) -gt 512 ]; then - FATSIZE="-F 32" - fi - - rm -f ${WORKDIR}/boot.img - mkfs.vfat -n "${BOOTDD_VOLUME_ID}" -S 512 ${FATSIZE} -C ${WORKDIR}/boot.img $BOOT_BLOCKS - - mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${MACHINE}.bin ::/${KERNEL_IMAGETYPE} - - # Copy boot scripts - for item in ${BOOT_SCRIPTS}; do - src=`echo $item | awk -F':' '{ print $1 }'` - dst=`echo $item | awk -F':' '{ print $2 }'` - - mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/$src ::/$dst - done - - # Copy device tree file - if test -n "${KERNEL_DEVICETREE}"; then - for DTS_FILE in ${KERNEL_DEVICETREE}; do - DTS_BASE_NAME=`basename ${DTS_FILE} | awk -F "." '{print $1}'` - if [ -e "${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTS_BASE_NAME}.dtb" ]; then - kernel_bin="`readlink ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${MACHINE}.bin`" - kernel_bin_for_dtb="`readlink ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTS_BASE_NAME}.dtb | sed "s,$DTS_BASE_NAME,${MACHINE},g;s,\.dtb$,.bin,g"`" - if [ $kernel_bin = $kernel_bin_for_dtb ]; then - mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTS_BASE_NAME}.dtb ::/${DTS_BASE_NAME}.dtb - fi - else - bbfatal "${DTS_FILE} does not exist." - fi - done - fi -} - -generate_28nm_sdcard () { - # Create partition table - parted -s ${SDCARD} mklabel msdos - parted -s ${SDCARD} unit KiB mkpart primary fat32 ${IMAGE_ROOTFS_ALIGNMENT} $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED}) - parted -s ${SDCARD} unit KiB mkpart primary $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED}) $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED} \+ $ROOTFS_SIZE) - parted -s ${SDCARD} unit KiB mkpart primary 1024 2048 - - #set part 3 to type a2 for spl / uboot image - echo -ne "\xa2" | dd of=${SDCARD} bs=1 count=1 seek=482 conv=notrunc - - dd if=${DEPLOY_DIR_IMAGE}/${SPL_BINARY} of=${SDCARD} conv=notrunc seek=1 bs=$(expr 1024 \* 1024) - - parted ${SDCARD} print - - _generate_boot_image 1 - # Burn Partition - dd if=${WORKDIR}/boot.img of=${SDCARD} conv=notrunc,fsync seek=1 bs=$(expr ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) - dd if=${SDCARD_ROOTFS} of=${SDCARD} conv=notrunc,fsync seek=1 bs=$(expr ${BOOT_SPACE_ALIGNED} \* 1024 + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) - - # Burn uboot env - if [ -e "${DEPLOY_DIR_IMAGE}/u-boot-envs/${CONFIG_TYPE}.bin" ] - then - dd of=${DEPLOY_DIR_IMAGE}/u-boot-envs/${CONFIG_TYPE}.bin of=${SDCARD} bs=1 count=1 seek=512 - fi -} - -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 - - # Align boot partition and calculate total SD card image size - BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE} + ${IMAGE_ROOTFS_ALIGNMENT} - 1) - BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE_ALIGNED} - ${BOOT_SPACE_ALIGNED} % ${IMAGE_ROOTFS_ALIGNMENT}) - SDCARD_SIZE=$(expr ${IMAGE_ROOTFS_ALIGNMENT} + ${BOOT_SPACE_ALIGNED} + $ROOTFS_SIZE + ${IMAGE_ROOTFS_ALIGNMENT}) - - # Initialize a sparse file - SDCARD="${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.sdcard" - dd if=/dev/zero of=${SDCARD} bs=1 count=0 seek=$(expr 1024 \* ${SDCARD_SIZE}) - - if [ "x${UBOOT_CONFIG}" != "x" ] - then - for config in ${UBOOT_MACHINE}; do - i=`expr $i + 1`; - for type in ${UBOOT_CONFIG}; do - j=`expr $j + 1`; - if [ $j -eq $i ] - then - CONFIG_TYPE="${type}" - UBOOT_SFP_IMAGE="${SPL_IMAGE}-${MACHINE}-${type}" - ${SDCARD_GENERATION_COMMAND} - fi - done - unset j - done - unset i - else - UBOOT_SFP_IMAGE="${SPL_IMAGE}-${MACHINE}" - ${SDCARD_GENERATION_COMMAND} - fi -} - -# The sdcard requires the rootfs filesystem to be built before using -# it so we must make this dependency explicit. -IMAGE_TYPEDEP_sdcard = "${@d.getVar('SDCARD_ROOTFS', 1).split('.')[-1]}" \ No newline at end of file diff --git a/conf/machine/arria5.conf b/conf/machine/arria5.conf index 193403c..1cd460d 100644 --- a/conf/machine/arria5.conf +++ b/conf/machine/arria5.conf @@ -4,9 +4,13 @@ require conf/machine/include/socfpga.inc -PREFERRED_VERSION_u-boot-socfpga ?= "2016.03" +PREFERRED_VERSION_u-boot-socfpga ?= "2016.03%" UBOOT_CONFIG ?= "arria5-socdk" +UBOOT_CONFIG[arria5-socdk] = "socfpga_arria5_defconfig,sdcard" + KMACHINE = "arria5" +# Default kernel devicetrees +KERNEL_DEVICETREE_arria5 ?= "socfpga_arria5_socdk.dtb" diff --git a/conf/machine/cyclone5.conf b/conf/machine/cyclone5.conf index 7d0aab0..7f39d39 100644 --- a/conf/machine/cyclone5.conf +++ b/conf/machine/cyclone5.conf @@ -4,9 +4,18 @@ require conf/machine/include/socfpga.inc -PREFERRED_VERSION_u-boot-socfpga ?= "2016.03" +PREFERRED_VERSION_u-boot-socfpga ?= "2016.03%" -UBOOT_CONFIG ?= "cyclone5-socdk" +UBOOT_CONFIG ??= "cyclone5-socdk" + +UBOOT_CONFIG[cyclone5-socdk] = "socfpga_cyclone5_defconfig" +UBOOT_CONFIG[de0-nano-soc] = "socfpga_de0_nano_soc_defconfig" +UBOOT_CONFIG[mcvevk] = "socfpga_mcvevk_defconfig" +UBOOT_CONFIG[sockit] = "socfpga_sockit_defconfig" +UBOOT_CONFIG[socrates] = "socfpga_socrates_defconfig" +UBOOT_CONFIG[sr1500] = "socfpga_sr1500_defconfig" KMACHINE = "cyclone5" +# Default kernel devicetrees +KERNEL_DEVICETREE ?= "socfpga_cyclone5_socdk.dtb socfpga_cyclone5_sockit.dtb socfpga_cyclone5_socrates.dtb socfpga_cyclone5_de0_sockit.dtb" diff --git a/conf/machine/include/socfpga.inc b/conf/machine/include/socfpga.inc index 6932620..19106a1 100644 --- a/conf/machine/include/socfpga.inc +++ b/conf/machine/include/socfpga.inc @@ -25,3 +25,12 @@ MACHINE_FEATURES = "kernel26" # file system images required IMAGE_FSTYPES ?= "cpio ext3 tar.gz" +# u-boot setup +UBOOT_SUFFIX = "img" + +# AV and CV uBoot + SPL mkpimage type binary +SPL_BINARY_cyclone5 = "u-boot-with-spl.sfp" +SPL_BINARY_arria5 = "u-boot-with-spl.sfp" + + + diff --git a/recipes-bsp/u-boot/u-boot-socfpga_2016.03.bb b/recipes-bsp/u-boot/u-boot-socfpga_2016.03.bb index 1d0376e..9189715 100644 --- a/recipes-bsp/u-boot/u-boot-socfpga_2016.03.bb +++ b/recipes-bsp/u-boot/u-boot-socfpga_2016.03.bb @@ -6,23 +6,10 @@ SRCREV = "df61a74e6845ec9bdcdd48d2aff5e9c2c6debeaa" LICENSE = "GPLv2+" LIC_FILES_CHKSUM = "file://Licenses/README;md5=a2c678cfd4a4d97135585cad908541c6" -PV = "v2016.03" +PV = "2016.03" PV_append = "+git${SRCPV}" DEPENDS += "dtc-native" -UBOOT_CONFIG ??= "cyclone5-socdk arria5-socdk de0-nano-soc sockit socrates" -UBOOT_CONFIG[cyclone5-socdk] = "socfpga_cyclone5_defconfig" -UBOOT_CONFIG[arria5-socdk] = "socfpga_arria5_defconfig" -UBOOT_CONFIG[de0-nano-soc] = "socfpga_de0_nano_soc_defconfig" -UBOOT_CONFIG[mcvevk] = "socfpga_mcvevk_defconfig" -UBOOT_CONFIG[sockit] = "socfpga_sockit_defconfig" -UBOOT_CONFIG[socrates] = "socfpga_socrates_defconfig" -UBOOT_CONFIG[sr1500] = "socfpga_sr1500_defconfig" - -UBOOT_SUFFIX = "img" - -SPL_BINARY_cyclone5 = "u-boot-with-spl.sfp" -SPL_BINARY_arria5 = "u-boot-with-spl.sfp" diff --git a/recipes-bsp/u-boot/u-boot-target-env.inc b/recipes-bsp/u-boot/u-boot-target-env.inc deleted file mode 100644 index c418a16..0000000 --- a/recipes-bsp/u-boot/u-boot-target-env.inc +++ /dev/null @@ -1,69 +0,0 @@ -# Handle severals environments generation for u-boot - -#Env binary size -ENV_SIZE = "0x1000" - -ENV_BIN_DIR = "${WORKDIR}/target_env_bin" - -# Env deploy dir is the name of directory where binary envs will be deployed -ENV_DEPLOY_DIR="u-boot-envs" - -# Env deploy src dir is the name of directory where txt envs will be deployed -ENV_SRC_DEPLOY_DIR="u-boot-envs-src" - -do_build_mkimage_tool () { - HOSTCC="${CC}" HOSTLD="${LD}" HOSTLDFLAGS="${LDFLAGS}" HOSTSTRIP=true oe_runmake sandbox_defconfig - HOSTCC="${CC}" HOSTLD="${LD}" HOSTLDFLAGS="${LDFLAGS}" HOSTSTRIP=true oe_runmake tools -} - -python do_environment_mkimage() { - import subprocess - import shutil - # list env variant target files - target_root_dir = d.getVar('WORKDIR',True) - # env files only for UBOOT_CONFIG - env_uboot_config = d.getVar('UBOOT_CONFIG',True) - env_files = [] - for f in os.listdir(target_root_dir): - if f.endswith(".env"): - env_files.append(os.path.join(target_root_dir,f)) - env_bin_dir = d.getVar("ENV_BIN_DIR",True) - # cleans if it exists env_bin directory - shutil.rmtree(env_bin_dir, ignore_errors=True) - # create env bin directory - os.mkdir(env_bin_dir) - print 'Building binary environments in : %s' % env_bin_dir - # iterate targets list to build binary environment files - for target_env in env_files : - # get only filename without path and extension - target_filename = os.path.splitext(os.path.basename(target_env))[0] - if target_filename not in env_uboot_config: - continue - # build output file path with ext - target_bin = os.path.join(env_bin_dir, - target_filename + '.bin') - # generated mkenvimage tool command line - cmd_mkimg ='cat %s | grep -v -E "^$|^\#" |' \ - ' ./tools/mkenvimage -s %s -r -o %s -' \ - % ( target_env, - d.getVar("ENV_SIZE",True), target_bin) - print 'Building binary for %s target:' % (target_filename) - print '%s' % cmd_mkimg - # execute shell command - ret = subprocess.call(cmd_mkimg, shell=True) - if ret: return ret - return 0 -} - -do_deploy_append() { - install -d ${DEPLOYDIR} - # deploy binary U-boot environments - echo "Deploying U-boot Environments binary files in ${DEPLOYDIR}/${ENV_DEPLOY_DIR}" - install -d ${DEPLOYDIR}/${ENV_DEPLOY_DIR} - - - cp ${ENV_BIN_DIR}/*.bin ${DEPLOYDIR}/${ENV_DEPLOY_DIR} -} - -addtask build_mkimage_tool after do_compile before do_environment_mkimage -addtask environment_mkimage after do_build_mkimage_tool before do_deploy -- cgit v1.2.3-54-g00ecf