From 7828a18b90d0e7ad8d035732f041ac7fc097bc4c Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Fri, 14 May 2021 00:26:11 -0700 Subject: [PATCH] linux-firmware-beaglev-bcm43430: Add recipe This packages bluetooth/Wifi firmware blobs into a package Help lld linker Use -mno-relax to compile the kernel with clang when using lld for linker ( with LLVM=1 ) Signed-off-by: Khem Raj --- .../linux-firmware-beaglev-bcm43430.bb | 51 +++++++++++++++++++ recipes-kernel/linux/linux-starfive-dev.bb | 14 +---- ...-Use-mno-relax-when-using-lld-linker.patch | 51 +++++++++++++++++++ recipes-kernel/linux/linux-starfive_5.12.bb | 3 ++ 4 files changed, 106 insertions(+), 13 deletions(-) create mode 100644 recipes-kernel/firmware/linux-firmware-beaglev-bcm43430.bb create mode 100644 recipes-kernel/linux/linux-starfive/0001-riscv-Use-mno-relax-when-using-lld-linker.patch diff --git a/recipes-kernel/firmware/linux-firmware-beaglev-bcm43430.bb b/recipes-kernel/firmware/linux-firmware-beaglev-bcm43430.bb new file mode 100644 index 0000000..7acd344 --- /dev/null +++ b/recipes-kernel/firmware/linux-firmware-beaglev-bcm43430.bb @@ -0,0 +1,51 @@ +# Copyright (C) 2021 Khem Raj +# Released under the MIT license (see COPYING.MIT for the terms) + +SUMMARY = "WIFI/BT Binary Blobs" +HOMEPAGE = "https://github.com/esmil/linux/blob/starlight/firmware/brcm" +LICENSE = "\ + Firmware-broadcom_bcm43xx \ +" + +LICENSE_${PN} = "Firmware-broadcom_bcm43xx" +LIC_FILES_CHKSUM = "\ + file://LICENCE.broadcom_bcm43xx;md5=3160c14df7228891b868060e1951dfbc \ +" + +# These are not common licenses, set NO_GENERIC_LICENSE for them +# so that the license files will be copied from fetched source +NO_GENERIC_LICENSE[Firmware-broadcom_bcm43xx] = "LICENCE.broadcom_bcm43xx" + +SRC_URI = "https://github.com/esmil/linux/raw/starlight/firmware/brcm/brcmfmac43430-sdio.bin;name=brcmfmac43430 \ + https://github.com/esmil/linux/raw/starlight/firmware/brcm/brcmfmac43430-sdio.clm_blob;name=brcmfmac43430-clm \ + https://raw.githubusercontent.com/esmil/linux/starlight/firmware/brcm/nvram_ap6236.txt;name=nvram \ + https://raw.githubusercontent.com/esmil/linux/starlight/firmware/brcm/brcmfmac43430-sdio.AP6212.txt;name=AP6212 \ + https://raw.githubusercontent.com/RPi-Distro/firmware-nonfree/master/LICENCE.broadcom_bcm43xx;name=license \ + " +SRC_URI[brcmfmac43430.sha256sum] = "ffbb2dbf135a4c22fdb00716088c556ff6b43fcff1503a59c3f2097992b18b96" +SRC_URI[brcmfmac43430-clm.sha256sum] = "3ce2e8884dbd37d63ca8bae07bf7ea17c110070f41a87c9832eac57f201e2e5d" +SRC_URI[AP6212.sha256sum] = "fdef0603345dd023ad28c0eff2d5167915c617bee2d6944da9a6da1c4ac87ca5" +SRC_URI[nvram.sha256sum] = "ed5d5509c9eff922dc55ddffa654d6fb54ae3f391ff60dd3c50be5b63bc64152" +SRC_URI[license.sha256sum] = "b16056fc91b82a0e3e8de8f86c2dac98201aa9dc3cbd33e8d38f1b087fcec30d" + +S = "${WORKDIR}" + +inherit allarch + +CLEANBROKEN = "1" + +do_configure () { + : +} + +do_install () { + for f in brcmfmac43430-sdio.AP6212.txt brcmfmac43430-sdio.bin brcmfmac43430-sdio.clm_blob nvram_ap6236.txt + do + install -Dm 0644 ${S}/$f ${D}${nonarch_base_libdir}/firmware/brcm/$f + done + ln -s brcmfmac43430-sdio.AP6212.txt ${D}${nonarch_base_libdir}/firmware/brcm/brcmfmac43430-sdio.beagle,beaglev-starlight-jh7100.txt +} + +FILES_${PN} = "${nonarch_base_libdir}/firmware/brcm/" + +INSANE_SKIP = "arch" diff --git a/recipes-kernel/linux/linux-starfive-dev.bb b/recipes-kernel/linux/linux-starfive-dev.bb index b5a7bd4..e780709 100644 --- a/recipes-kernel/linux/linux-starfive-dev.bb +++ b/recipes-kernel/linux/linux-starfive-dev.bb @@ -8,6 +8,7 @@ KERNEL_VERSION_SANITY_SKIP = "1" SRCREV = "${AUTOREV}" BRANCH = "starlight" SRC_URI = "git://github.com/esmil/linux.git;protocol=git;branch=${BRANCH} \ + file://0001-riscv-Use-mno-relax-when-using-lld-linker.patch \ file://extra.cfg \ file://modules.cfg \ " @@ -17,17 +18,4 @@ LINUX_VERSION_EXTENSION_append = "-starlight" KBUILD_DEFCONFIG_beaglev-starlight-jh7100 = "starlight_defconfig" -# Install firmwate blobs for wifi/bt -do_install_append() { - for f in brcmfmac43430-sdio.AP6212.txt brcmfmac43430-sdio.bin brcmfmac43430-sdio.clm_blob nvram_ap6236.txt - do - install -Dm 0644 ${S}/firmware/brcm/$f ${D}${nonarch_base_libdir}/firmware/brcm/$f - done - ln -s brcmfmac43430-sdio.AP6212.txt ${D}${nonarch_base_libdir}/firmware/brcm/brcmfmac43430-sdio.beagle,beaglev-starlight-jh7100.txt -} - -PACKAGES += "linux-firmware-beaglev-bcm43430" - -FILES_linux-firmware-beaglev-bcm43430 = "${nonarch_base_libdir}/firmware/brcm/" - COMPATIBLE_MACHINE = "(beaglev-starlight-jh7100)" diff --git a/recipes-kernel/linux/linux-starfive/0001-riscv-Use-mno-relax-when-using-lld-linker.patch b/recipes-kernel/linux/linux-starfive/0001-riscv-Use-mno-relax-when-using-lld-linker.patch new file mode 100644 index 0000000..143eafd --- /dev/null +++ b/recipes-kernel/linux/linux-starfive/0001-riscv-Use-mno-relax-when-using-lld-linker.patch @@ -0,0 +1,51 @@ +From b49fbbed96b6e5d898377020d6b717a21aad6282 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Fri, 14 May 2021 00:23:05 -0700 +Subject: [PATCH v2] riscv: Use -mno-relax when using lld linker + +lld does not implement the RISCV relaxation optimizations like GNU ld +therefore disable it when building with lld, Also pass it to +assembler when using external GNU assembler ( LLVM_IAS != 1 ), this +ensures that relevant assembler option is also enabled along. if these +options are not used then we see following relocations in objects + +0000000000000000 R_RISCV_ALIGN *ABS*+0x0000000000000002 + +These are then rejected by lld +ld.lld: error: capability.c:(.fixup+0x0): relocation R_RISCV_ALIGN requires unimplemented linker relaxation; recompile with -mno-relax but the .o is already compiled with -mno-relax + +Signed-off-by: Khem Raj +Cc: Paul Walmsley +Cc: Palmer Dabbelt +Cc: Albert Ou +Cc: Nathan Chancellor +Cc: Nick Desaulniers +--- +v2: Use CONFIG_LD_IS_LLD instead of LLVM check + + arch/riscv/Makefile | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile +index 3eb9590a0775..4be020695428 100644 +--- a/arch/riscv/Makefile ++++ b/arch/riscv/Makefile +@@ -38,6 +38,15 @@ else + KBUILD_LDFLAGS += -melf32lriscv + endif + ++ifeq ($(CONFIG_LD_IS_LLD),y) ++ KBUILD_CFLAGS += -mno-relax ++ KBUILD_AFLAGS += -mno-relax ++ifneq ($(LLVM_IAS),1) ++ KBUILD_CFLAGS += -Wa,-mno-relax ++ KBUILD_AFLAGS += -Wa,-mno-relax ++endif ++endif ++ + # ISA string setting + riscv-march-$(CONFIG_ARCH_RV32I) := rv32ima + riscv-march-$(CONFIG_ARCH_RV64I) := rv64ima +-- +2.31.1 + diff --git a/recipes-kernel/linux/linux-starfive_5.12.bb b/recipes-kernel/linux/linux-starfive_5.12.bb index 4628f4a..d8a6fe4 100644 --- a/recipes-kernel/linux/linux-starfive_5.12.bb +++ b/recipes-kernel/linux/linux-starfive_5.12.bb @@ -4,6 +4,9 @@ inherit kernel require recipes-kernel/linux/linux-yocto.inc SRC_URI = "git://github.com/starfive-tech/linux.git;protocol=git;branch=esmil_starlight \ + file://0001-riscv-Use-mno-relax-when-using-lld-linker.patch \ + file://extra.cfg \ + file://modules.cfg \ " LINUX_VERSION ?= "5.12.3"