Search code examples
bashcross-compilingyoctobitbakeu-boot

Trouble replicating bash script as Bitbake recipe


I'm trying to build U-boot-socfpga for a DE10-Nano using a Bitbake recipe for my Yocto setup.

I have a bash script that is able to build a working u-boot-with-spl.sfp file.

python2 $UBOOT_DIR/arch/arm/mach-socfpga/cv_bsp_generator/cv_bsp_generator.py \
        -i $HDL_DIR/projects/cn0540/de10nano/hps_isw_handoff/system_bd_sys_hps/ \
        -o $UBOOT_DIR/board/altera/cyclone5-socdk/qts
    (
        cd $UBOOT_DIR
        export CROSS_COMPILE=arm-linux-gnueabihf-
        make socfpga_cyclone5_defconfig
        make -j8
    )

The script is working with u-boot-socfpga_v2022.10

The Bitbake recipe I wrote is:

LICENSE="CLOSED"
PROVIDES = "virtual/bootloader"
 
I_SWEAR_TO_MIGRATE_TO_PYTHON3 = "yes"
 
inherit pythonnative deploy uboot-extlinux-config uboot-config
DEPENDS += "python-native u-boot-mkimage-native bison-native bc-native dtc-native flex-native"
DEPENDS += "swig-native"
 
EXTRA_OEMAKE = 'CROSS_COMPILE=${TARGET_PREFIX} CC="${TARGET_PREFIX}gcc ${TOOLCHAIN_OPTIONS}" V=1'
EXTRA_OEMAKE += 'HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}"'
EXTRA_OEMAKE += 'STAGING_INCDIR=${STAGING_INCDIR_NATIVE} STAGING_LIBDIR=${STAGING_LIBDIR_NATIVE}'
 
SRC_URI = "git://github.com/altera-opensource/u-boot-socfpga.git;branch=socfpga_v2022.10;protocol=https"
#2022.10
SRCREV = "b1598f9fda404684e726f4138aa2650d8742397a"
#SRCREV ?= "${AUTOREV}"
 
HANDOFF_FILES_DIR = "${THISDIR}/files/handoff_files/"
UBOOT_SCR = "u-boot.scr"
SPL_BINARY = "u-boot-with-spl.sfp"
 
FILES:${PN} = "/boot ${UBOOT_EXTLINUX_INSTALL_DIR}/${UBOOT_EXTLINUX_CONF_NAME}"
#FILES:${PN}-extlinux = "${UBOOT_EXTLINUX_INSTALL_DIR}/${UBOOT_EXTLINUX_CONF_NAME}"
 
S = "${WORKDIR}/git"
B = "${WORKDIR}/build"
 
UBOOT_CONFIG[cyclone5-socdk] = "socfpga_cyclone5_defconfig"
 
do_compile() {
    python ${S}/arch/arm/mach-socfpga/cv_bsp_generator/cv_bsp_generator.py \
        -i ${HANDOFF_FILES_DIR} \
        -o ${S}/board/altera/cyclone-socdk/qts
 
    oe_runmake -C ${S} socfpga_cyclone5_defconfig
    oe_runmake -C ${S}
 
    mkimage -C none -A arm -T script -d ${THISDIR}/files/u-boot.cmd ${B}/${UBOOT_SCR}
}
 
do_install() {
    install -D -m 644 ${B}/${UBOOT_SCR} ${D}/boot/${UBOOT_SCR}
 
    install -m 644 ${S}/${SPL_BINARY} ${D}/boot/${SPL_BINARY}
 
    install -Dm 0644 ${UBOOT_EXTLINUX_CONFIG} ${D}/${UBOOT_EXTLINUX_INSTALL_DIR}/${UBOOT_EXTLINUX_CONF_NAME}
}
 
do_deploy() {
    rm -f ${DEPLOYDIR}/${SPL_BINARY}
    install -m 644 ${S}/${SPL_BINARY} ${DEPLOYDIR}/${SPL_BINARY}
 
    install -m 644 ${B}/${UBOOT_SCR} ${DEPLOYDIR}/${UBOOT_SCR}
 
    install -m 644 ${UBOOT_EXTLINUX_CONFIG} ${DEPLOYDIR}/${UBOOT_EXTLINUX_CONF_NAME}
}
 
IMAGE_BOOT_FILE:append = "${UBOOT_SCR}"
addtask deploy before do_build after do_compile

The recipe does create a u-boot-with-spl.sfp file, but when tested on the device, no output is given.

I have tried setting EXTRA_OEMAKE += "CROSS_COMPILE=arm-linux-gnueabihf-" but I got an error that arm-linux-gnueabihf-gcc: was not found from make.

I also tried going to the git folder for the recipe, and manually calling

export CROSS_COMPILE=arm-linux-gnueabihf-
make socfpga_cyclone5_defconfig
make -j8

but that too produced a u-boot file that gave no output when tested.

Am I missing something for my environment?


Solution

  • I had a typo in the do_compile section.

    The output directory for cv_bsp_generator.py should have been ${S}/board/altera/cyclone5-socdk/qts

    I also implemented the changes suggested by @skandigraun