From 4e663cef8f0fb950a8751a4e3ae236cc85db244e Mon Sep 17 00:00:00 2001 From: Yves Vandervennet Date: Thu, 4 Sep 2014 13:43:44 -0500 Subject: Yocto layer for Altera's SoCFPGA Signed-off-by: Yves Vandervennet --- COPYING.MIT | 17 ++++ README | 10 ++ conf/layer.conf | 14 +++ conf/machine/include/socfpga.inc | 27 ++++++ conf/machine/socfpga_arria5.conf | 8 ++ conf/machine/socfpga_cyclone5.conf | 8 ++ recipes-bsp/uboot/u-boot-socfpga.inc | 89 +++++++++++++++++ recipes-bsp/uboot/u-boot-socfpga_2013.01.01.bb | 1 + recipes-kernel/linux/linux-altera-latest.inc | 5 + recipes-kernel/linux/linux-altera-ltsi-rt_3.10.bb | 6 ++ recipes-kernel/linux/linux-altera-ltsi.inc | 5 + recipes-kernel/linux/linux-altera-ltsi_3.10.bb | 4 + recipes-kernel/linux/linux-altera.inc | 112 ++++++++++++++++++++++ recipes-kernel/linux/linux-altera_3.15.bb | 6 ++ 14 files changed, 312 insertions(+) create mode 100644 COPYING.MIT create mode 100644 README create mode 100644 conf/layer.conf create mode 100644 conf/machine/include/socfpga.inc create mode 100644 conf/machine/socfpga_arria5.conf create mode 100644 conf/machine/socfpga_cyclone5.conf create mode 100755 recipes-bsp/uboot/u-boot-socfpga.inc create mode 100755 recipes-bsp/uboot/u-boot-socfpga_2013.01.01.bb create mode 100644 recipes-kernel/linux/linux-altera-latest.inc create mode 100755 recipes-kernel/linux/linux-altera-ltsi-rt_3.10.bb create mode 100644 recipes-kernel/linux/linux-altera-ltsi.inc create mode 100755 recipes-kernel/linux/linux-altera-ltsi_3.10.bb create mode 100755 recipes-kernel/linux/linux-altera.inc create mode 100755 recipes-kernel/linux/linux-altera_3.15.bb diff --git a/COPYING.MIT b/COPYING.MIT new file mode 100644 index 0000000..fb950dc --- /dev/null +++ b/COPYING.MIT @@ -0,0 +1,17 @@ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README b/README new file mode 100644 index 0000000..a9126cc --- /dev/null +++ b/README @@ -0,0 +1,10 @@ +The official OpenEmbedded/Yocto BSP layer for Altera SoCFPGA platforms + +This layer works with poky and Angstrom + +Please follow the recommended setup procedures of your OE distribution. + + +Send pull requests, patches, comments or questions to yvanderv@opensource.altera.com + +Maintainer: yvanderv@opensource.altera.com diff --git a/conf/layer.conf b/conf/layer.conf new file mode 100644 index 0000000..f611a31 --- /dev/null +++ b/conf/layer.conf @@ -0,0 +1,14 @@ +# We have a conf and classes directory, append to BBPATH +BBPATH .= ":${LAYERDIR}" + +# We have a recipes directory, add to BBFILES +BBFILES += "${LAYERDIR}/recipes*/*/*.bb ${LAYERDIR}/recipes*/*/*.bbappend" + +BBFILE_COLLECTIONS += "meta-altera" +BBFILE_PATTERN_meta-altera := "^${LAYERDIR}/" +# increase the number +BBFILE_PRIORITY_meta-altera = "6" + +# yves +BBDEBUG = "yes" + diff --git a/conf/machine/include/socfpga.inc b/conf/machine/include/socfpga.inc new file mode 100644 index 0000000..60ba002 --- /dev/null +++ b/conf/machine/include/socfpga.inc @@ -0,0 +1,27 @@ +SOC_FAMILY = "socfpga" + +require conf/machine/include/tune-cortexa9.inc + +# this variable specifies the kernel to be built: linux-altera or linux-altera-ltsi +# this affects the PREFERRED_PROVIDER of virtual/kernel +# it can be overriden from the environment, using BB_ENV_EXTRAWHITE +KERNEL_PROVIDER?="linux-altera-ltsi" +PREFERRED_PROVIDER_virtual/kernel = "${KERNEL_PROVIDER}" + +PREFERRED_PROVIDER_virtual/bootloader = "u-boot-socfpga" + +# Increase this everytime you change something in the kernel +MACHINE_KERNEL_PR = "r1" + +UBOOT_ENTRYPOINT = "0x80008000" +UBOOT_LOADADDRESS = "0x80008000" + +SERIAL_CONSOLE = "115200 ttyS0" + +KERNEL_IMAGETYPE = "zImage" +MACHINE_EXTRA_RRECOMMENDS = " kernel-modules" +MACHINE_FEATURES = "kernel26" + +# file system images required +IMAGE_FSTYPES ?= "cpio ext3 tar.gz" + diff --git a/conf/machine/socfpga_arria5.conf b/conf/machine/socfpga_arria5.conf new file mode 100644 index 0000000..022c6a8 --- /dev/null +++ b/conf/machine/socfpga_arria5.conf @@ -0,0 +1,8 @@ +#@TYPE: Machine +#@NAME: SOCFPGA +#@DESCRIPTION: Machine configuration for the Cyclone V SoC" + +require conf/machine/include/socfpga.inc + +UBOOT_MACHINE = "socfpga_arria5" + diff --git a/conf/machine/socfpga_cyclone5.conf b/conf/machine/socfpga_cyclone5.conf new file mode 100644 index 0000000..e4d3b5b --- /dev/null +++ b/conf/machine/socfpga_cyclone5.conf @@ -0,0 +1,8 @@ +#@TYPE: Machine +#@NAME: SOCFPGA +#@DESCRIPTION: Machine configuration for the Cyclone V SoC" + +require conf/machine/include/socfpga.inc + +UBOOT_MACHINE = "socfpga_cyclone5" + diff --git a/recipes-bsp/uboot/u-boot-socfpga.inc b/recipes-bsp/uboot/u-boot-socfpga.inc new file mode 100755 index 0000000..5655c12 --- /dev/null +++ b/recipes-bsp/uboot/u-boot-socfpga.inc @@ -0,0 +1,89 @@ +DESCRIPTION = "U-boot bootloader for Altera socfpga" +HOMEPAGE = "http://www.altera.com/" +SECTION = "bootloaders" +PROVIDES += " virtual/bootloader u-boot" + +inherit deploy + +PARALLEL_MAKE="" +PACKAGES="" + +# the following variables can be passed from the env +# using BB_ENV_WHITELIST to override the defaults +UBOOT_REPO?="git://git.rocketboards.org/u-boot-socfpga.git" +UBOOT_BRANCH?="socfpga_v${PV}" +UBOOT_PROT?="http" +UBOOT_TAG?="${AUTOREV}" + +SRC_URI = "${UBOOT_REPO};protocol=${UBOOT_PROT};branch=${UBOOT_BRANCH}" +LIC_FILES_CHKSUM = "file://${S}/COPYING;startline=26;md5=1707d6db1d42237583f50183a5651ecb" +SRCREV_pn-${PN} = "${UBOOT_TAG}" + +S = "${WORKDIR}/git" + +# GCC 4.5.1 builds unusable binaries using -Os, remove it from OPTFLAGS +EXTRA_OEMAKE = "CROSS_COMPILE=${TARGET_PREFIX}" + +python () { + if not d.getVar("UBOOT_MACHINE", True): + PN = d.getVar("PN", True) + FILE = os.path.basename(d.getVar("FILE", True)) + bb.debug(1, "To build %s, see %s for instructions on \ + setting up your machine config" % (PN, FILE)) + raise bb.parse.SkipPackage("because UBOOT_MACHINE is not set") +} + +UBOOT_ELF ?= "u-boot-${MACHINE}-${PV}-${PR}" +UBOOT_IMAGE ?= "u-boot-${MACHINE}-${PV}-${PR}.bin" +UBOOT_IMAGE_UIMAGE ?= "u-boot-${MACHINE}-${PV}-${PR}.img" +UBOOT_IMAGE_SPL ?= "u-boot-spl-${MACHINE}-${PV}-${PR}.bin" +UBOOT_ELF_SPL ?= "u-boot-spl-${MACHINE}-${PV}-${PR}" +UBOOT_BINARY ?= "u-boot.bin" +UBOOT_SYMLINK_ELF ?= "u-boot-${MACHINE}" +UBOOT_SYMLINK ?= "u-boot-${MACHINE}.bin" +UBOOT_SYMLINK_UIMAGE ?= "u-boot-${MACHINE}.img" +UBOOT_SYMLINK_SPL ?= "u-boot-spl-${MACHINE}.bin" +UBOOT_SYMLINK_ELF_SPL ?= "u-boot-spl-${MACHINE}" +UBOOT_MAKE_TARGET ?= "all" +INC_PR = "r0" + +LICENSE = "GPLv2+" + +do_compile () { + unset LDFLAGS + unset CFLAGS + unset CPPFLAGS + oe_runmake ${UBOOT_MACHINE} + oe_runmake ${UBOOT_MAKE_TARGET} +} + +do_install () { + install -d ${D}/boot + install ${S}/${UBOOT_BINARY} ${D}/boot/${UBOOT_IMAGE} + install ${S}/spl/u-boot-spl ${D}/boot/${UBOOT_ELF_SPL} + install ${S}/u-boot ${D}/boot/${UBOOT_ELF} + ln -sf ${UBOOT_IMAGE} ${D}/boot/${UBOOT_BINARY} +} + +FILES_${PN} = "/boot" + +do_deploy () { + install ${S}/u-boot.bin ${DEPLOYDIR}/${UBOOT_IMAGE} + install ${S}/u-boot.img ${DEPLOYDIR}/${UBOOT_IMAGE_UIMAGE} + install ${S}/spl/u-boot-spl.bin ${DEPLOYDIR}/${UBOOT_IMAGE_SPL} + install ${S}/spl/u-boot-spl ${DEPLOYDIR}/${UBOOT_ELF_SPL} + install ${S}/u-boot ${DEPLOYDIR}/${UBOOT_ELF} + + cd ${DEPLOYDIR} + rm -f ${UBOOT_SYMLINK} + ln -sf ${UBOOT_IMAGE} ${UBOOT_SYMLINK} + rm -f ${UBOOT_SYMLINK_UIMAGE} + ln -sf ${UBOOT_IMAGE_UIMAGE} ${UBOOT_SYMLINK_UIMAGE} + rm -f ${UBOOT_SYMLINK_SPL} + ln -sf ${UBOOT_IMAGE_SPL} ${UBOOT_SYMLINK_SPL} + rm -f ${UBOOT_SYMLINK_ELF_SPL} + ln -sf ${UBOOT_ELF_SPL} ${UBOOT_SYMLINK_ELF_SPL} + rm -f ${UBOOT_SYMLINK_ELF} + ln -sf ${UBOOT_ELF} ${UBOOT_SYMLINK_ELF} +} +addtask deploy before do_build after do_compile diff --git a/recipes-bsp/uboot/u-boot-socfpga_2013.01.01.bb b/recipes-bsp/uboot/u-boot-socfpga_2013.01.01.bb new file mode 100755 index 0000000..1beca44 --- /dev/null +++ b/recipes-bsp/uboot/u-boot-socfpga_2013.01.01.bb @@ -0,0 +1 @@ +require u-boot-socfpga.inc diff --git a/recipes-kernel/linux/linux-altera-latest.inc b/recipes-kernel/linux/linux-altera-latest.inc new file mode 100644 index 0000000..edf09b2 --- /dev/null +++ b/recipes-kernel/linux/linux-altera-latest.inc @@ -0,0 +1,5 @@ +KERNEL_BRANCH?="socfpga-${PV}" + +require recipes-kernel/linux/linux-altera.inc + + diff --git a/recipes-kernel/linux/linux-altera-ltsi-rt_3.10.bb b/recipes-kernel/linux/linux-altera-ltsi-rt_3.10.bb new file mode 100755 index 0000000..9946554 --- /dev/null +++ b/recipes-kernel/linux/linux-altera-ltsi-rt_3.10.bb @@ -0,0 +1,6 @@ +DTB_SUBDIR="dts/" + +KERNEL_BRANCH?="socfpga-${PV}-ltsi-rt" + +require recipes-kernel/linux/linux-altera.inc + diff --git a/recipes-kernel/linux/linux-altera-ltsi.inc b/recipes-kernel/linux/linux-altera-ltsi.inc new file mode 100644 index 0000000..8b058e5 --- /dev/null +++ b/recipes-kernel/linux/linux-altera-ltsi.inc @@ -0,0 +1,5 @@ +KERNEL_BRANCH?="socfpga-${PV}-ltsi" + +require recipes-kernel/linux/linux-altera.inc + + diff --git a/recipes-kernel/linux/linux-altera-ltsi_3.10.bb b/recipes-kernel/linux/linux-altera-ltsi_3.10.bb new file mode 100755 index 0000000..1ba1a60 --- /dev/null +++ b/recipes-kernel/linux/linux-altera-ltsi_3.10.bb @@ -0,0 +1,4 @@ +DTB_SUBDIR="dts/" + +require recipes-kernel/linux/linux-altera-ltsi.inc + diff --git a/recipes-kernel/linux/linux-altera.inc b/recipes-kernel/linux/linux-altera.inc new file mode 100755 index 0000000..3a8ac1d --- /dev/null +++ b/recipes-kernel/linux/linux-altera.inc @@ -0,0 +1,112 @@ +PR = "r1" + +KERNEL_REPO?="git://git.rocketboards.org/linux-socfpga.git" +KERNEL_PROT?="http" +KERNEL_DEFCONFIG?="socfpga_defconfig" +KERNEL_TAG?="${AUTOREV}" + +SRC_URI = "${KERNEL_REPO};protocol=${KERNEL_PROT};branch=${KERNEL_BRANCH}" + +SRCREV_pn-${PN} = "${KERNEL_TAG}" + +inherit kernel +SECTION = "kernel" +DESCRIPTION = "Altera Linux kernel" +LICENSE = "GPLv2" + +COMPATIBLE_MACHINE = "socfpga" + +LIC_FILES_CHKSUM = "file://${S}/COPYING;md5=d7810fab7487fb0aad327b76f1be7cd7" + +S = "${WORKDIR}/git" + +MACHINE_DEFCONFIG = "${KERNEL_DEFCONFIG}" + +do_configure() { + export INITRAMFS_IMAGE_FILE="${INITRAMFS_IMAGE}-${MACHINE}.cpio" + + unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE + export CROSS_COMPILE="${TARGET_PREFIX}" + export ARCH=${ARCH} + + oe_runmake ${MACHINE_DEFCONFIG} CONFIG_BLK_DEV_INITRD=y + + cp .config .config.ori + + grep CONFIG_BLK_DEV_INITRD .config || echo "CONFIG_BLK_DEV_INITRD=y" >> .config + grep CONFIG_INITRAMFS_SOURCE .config || echo "CONFIG_INITRAMFS_SOURCE=\"\"" >> .config + grep CONFIG_INITRAMFS_ROOT_UID .config || echo "CONFIG_INITRAMFS_ROOT_UID=0" >> .config + grep CONFIG_INITRAMFS_ROOT_GID .config || echo "CONFIG_INITRAMFS_ROOT_GID=0" >> .config + grep CONFIG_INITRAMFS_COMPRESSION_NONE .config || echo "CONFIG_INITRAMFS_COMPRESSION_NONE=y" >> .config + + if [ ! -z ${INITRAMFS_IMAGE} ] && [ -e ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_FILE} ]; then + cp ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_FILE} . + echo "Found valid initramfs ${INITRAMFS_IMAGE_FILE}" + sed -i "s|^.*CONFIG_BLK_DEV_INITRD[ =].*$|CONFIG_BLK_DEV_INITRD=y|g" .config + sed -i "s|^.*CONFIG_INITRAMFS_SOURCE[ =].*$|CONFIG_INITRAMFS_SOURCE=\"${INITRAMFS_IMAGE_FILE}\"|g" .config + sed -i "s|^.*CONFIG_INITRAMFS_ROOT_UID[ =].*$|CONFIG_INITRAMFS_ROOT_UID=0|g" .config + sed -i "s|^.*CONFIG_INITRAMFS_ROOT_GID[ =].*$|CONFIG_INITRAMFS_ROOT_GID=0|g" .config + sed -i "s|^.*CONFIG_INITRAMFS_COMPRESSION_NONE[ =].*$|CONFIG_INITRAMFS_COMPRESSION_NONE=y|g" .config + oe_runmake oldconfig + else + rm -f *.cpio + echo "Initramfs disabled or can't find valid initramfs ${INITRAMFS_IMAGE_FILE}" + sed -i "s|^CONFIG_BLK_DEV_INITRD=.*$|# CONFIG_BLK_DEV_INITRD is not set|g" .config + sed -i "s|^CONFIG_INITRAMFS_SOURCE=\".*\"$|# CONFIG_INITRAMFS_SOURCE is not set|g" .config + sed -i "s|^CONFIG_INITRAMFS_ROOT_UID=.*$|# CONFIG_INITRAMFS_ROOT_UID is not set|g" .config + sed -i "s|^CONFIG_INITRAMFS_ROOT_GID=.*$|# CONFIG_INITRAMFS_ROOT_GID is not set|g" .config + sed -i "s|^CONFIG_INITRAMFS_COMPRESSION_NONE=.*$|# CONFIG_INITRAMFS_COMPRESSION_NONE is not set|g" .config + oe_runmake oldconfig + fi +} + +kernel_do_compile() { + unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE + oe_runmake __headers CC="${KERNEL_CC}" LD="${KERNEL_LD}" + oe_runmake ${KERNEL_IMAGETYPE_FOR_MAKE} ${KERNEL_ALT_IMAGETYPE} CC="${KERNEL_CC}" LD="${KERNEL_LD}" LOADADDR=0x8000 + if test "${KERNEL_IMAGETYPE_FOR_MAKE}.gz" = "${KERNEL_IMAGETYPE}"; then + gzip -9c < "${KERNEL_IMAGETYPE_FOR_MAKE}" > "${KERNEL_OUTPUT}" + fi +} + +do_compile_dtb() { + unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE + sync + oe_runmake ARCH=${ARCH} CROSS_COMPILE="${TARGET_PREFIX}" dtbs || + oe_runmake ARCH=${ARCH} CROSS_COMPILE="${TARGET_PREFIX}" dtbs +} + +addtask compile_dtb after do_compile before do_build + +KERNEL_DEVICETREE ?= "socfpga_vt socfpga_cyclone5 socfpga_arria5" + +do_deploy_dtb() { + install -d ${DEPLOY_DIR_IMAGE} + cd ${DEPLOY_DIR_IMAGE} + if test -n "${KERNEL_DEVICETREE}"; then + for DTB_FILE in ${KERNEL_DEVICETREE}; do + DTB_SYMLINK_NAME="${DTB_FILE}.dtb" + DEVICE_TREE_OUTPUT="${S}/arch/${ARCH}/boot/${DTB_SUBDIR}${DTB_FILE}.dtb" + DTB_NAME="${DTB_FILE}-${DATETIME}.dtb" + if [ ! -f ${DEVICE_TREE_OUTPUT} ]; then + echo "Warning: ${DEVICE_TREE_OUTPUT} is not available!" + continue + fi + install -m 0644 ${DEVICE_TREE_OUTPUT} ${DTB_NAME} + rm -f ${DTB_SYMLINK_NAME} + ln -sf ${DTB_NAME} ${DTB_SYMLINK_NAME} + done + fi +} + +addtask deploy_dtb after do_compile_dtb before do_build + +VMLINUX_NAME ?= "vmlinux-${PV}-${PR}-${MACHINE}-${DATETIME}" + +kernel_do_deploy_append() { + install -m 0644 ${S}/vmlinux ${DEPLOYDIR}/${VMLINUX_NAME} + cd ${DEPLOYDIR} && + rm -f vmlinux && + ln -sf ${VMLINUX_NAME} vmlinux +} + diff --git a/recipes-kernel/linux/linux-altera_3.15.bb b/recipes-kernel/linux/linux-altera_3.15.bb new file mode 100755 index 0000000..535b526 --- /dev/null +++ b/recipes-kernel/linux/linux-altera_3.15.bb @@ -0,0 +1,6 @@ +DTB_SUBDIR="dts/" + +KERNEL_DEVICETREE = "socfpga_cyclone5_socdk socfpga_arria5_socdk socfpga_vt" + +require recipes-kernel/linux/linux-altera-latest.inc + -- cgit v1.2.3-54-g00ecf