Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch tegra_xusb: fix xusb static firmware build



details:   https://anonhg.NetBSD.org/src/rev/3e1583f3f504
branches:  trunk
changeset: 943281:3e1583f3f504
user:      jakllsch <jakllsch%NetBSD.org@localhost>
date:      Sat Aug 29 19:06:17 2020 +0000

description:
tegra_xusb: fix xusb static firmware build

To work around objcopy and ld now being unable to create a EABI5 object
from a binary, use the assembler directive .incbin in inline assembly
to pull in the firmware blob.

This also probably makes TEGRA210_XUSB_BIN_STATIC actually work.

diffstat:

 sys/arch/arm/nvidia/files.tegra      |   4 +++-
 sys/arch/arm/nvidia/tegra_xusb-fw.mk |  23 -----------------------
 sys/arch/arm/nvidia/tegra_xusb.c     |  30 ++++++++++++++++++++++++------
 sys/arch/evbarm/conf/mk.generic      |   4 +---
 4 files changed, 28 insertions(+), 33 deletions(-)

diffs (126 lines):

diff -r 8d315ab128d5 -r 3e1583f3f504 sys/arch/arm/nvidia/files.tegra
--- a/sys/arch/arm/nvidia/files.tegra   Sat Aug 29 18:54:33 2020 +0000
+++ b/sys/arch/arm/nvidia/files.tegra   Sat Aug 29 19:06:17 2020 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.tegra,v 1.51 2020/07/08 22:28:21 uwe Exp $
+#      $NetBSD: files.tegra,v 1.52 2020/08/29 19:06:17 jakllsch Exp $
 #
 # Configuration info for NVIDIA Tegra ARM Peripherals
 #
@@ -108,6 +108,8 @@
 attach xhci at fdt with tegra_xusb : firmload
 file   arch/arm/nvidia/tegra_xusb.c            tegra_xusb
 defflag        opt_tegra.h                             TEGRA_XUSB_DEBUG
+defflag        opt_tegra.h                             TEGRA124_XUSB_BIN_STATIC
+defflag        opt_tegra.h                             TEGRA210_XUSB_BIN_STATIC
 
 # SDMMC
 attach sdhc at fdt with tegra_sdhc
diff -r 8d315ab128d5 -r 3e1583f3f504 sys/arch/arm/nvidia/tegra_xusb-fw.mk
--- a/sys/arch/arm/nvidia/tegra_xusb-fw.mk      Sat Aug 29 18:54:33 2020 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-#      $NetBSD: tegra_xusb-fw.mk,v 1.2 2017/09/19 20:46:12 jmcneill Exp $
-
-.if defined(TEGRA124_XUSB_BIN_STATIC)
-MD_OBJS+=      tegra124_xusb_bin.o
-CPPFLAGS+=     -DTEGRA124_XUSB_BIN_STATIC
-
-tegra124_xusb_bin.o:   $S/arch/arm/nvidia/tegra124_xusb.bin
-       -rm -f ${.OBJDIR}/tegra124_xusb.bin
-       -ln -s $S/arch/arm/nvidia/tegra124_xusb.bin ${.OBJDIR}
-       ${OBJCOPY} -I binary -O default -B arm tegra124_xusb.bin \
-           --rename-section .data=.rodata ${.TARGET}
-.endif
-
-.if defined(TEGRA210_XUSB_BIN_STATIC)
-MD_OBJS+=      tegra210_xusb_bin.o
-CPPFLAGS+=     -DTEGRA210_XUSB_BIN_STATIC
-
-tegra210_xusb_bin.o:   $S/arch/arm/nvidia/tegra210_xusb.bin
-       -rm -f ${.OBJDIR}/tegra210_xusb.bin
-       -ln -s $S/arch/arm/nvidia/tegra210_xusb.bin ${.OBJDIR}
-       ${OBJCOPY} -I binary -O default -B arm tegra210_xusb.bin \
-           --rename-section .data=.rodata ${.TARGET}
-.endif
diff -r 8d315ab128d5 -r 3e1583f3f504 sys/arch/arm/nvidia/tegra_xusb.c
--- a/sys/arch/arm/nvidia/tegra_xusb.c  Sat Aug 29 18:54:33 2020 +0000
+++ b/sys/arch/arm/nvidia/tegra_xusb.c  Sat Aug 29 19:06:17 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_xusb.c,v 1.19 2019/10/13 06:11:31 skrll Exp $ */
+/* $NetBSD: tegra_xusb.c,v 1.20 2020/08/29 19:06:17 jakllsch Exp $ */
 
 /*
  * Copyright (c) 2016 Jonathan A. Kollasch
@@ -30,7 +30,7 @@
 #include "opt_tegra.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tegra_xusb.c,v 1.19 2019/10/13 06:11:31 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_xusb.c,v 1.20 2020/08/29 19:06:17 jakllsch Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -74,13 +74,29 @@
 static int     tegra_xusb_intr_mbox(void *);
 
 #ifdef TEGRA124_XUSB_BIN_STATIC
-extern const char _binary_tegra124_xusb_bin_size[];
 extern const char _binary_tegra124_xusb_bin_start[];
+extern const char _binary_tegra124_xusb_bin_end[];
+__asm__(
+".section \".rodata\"\n"
+"_binary_tegra124_xusb_bin_start:\n"
+".incbin \"../external/nvidia-firmware/tegra/dist/tegra124/xusb.bin\"\n"
+".size _binary_tegra124_xusb_bin_start, . - _binary_tegra124_xusb_bin_start\n"
+"_binary_tegra124_xusb_bin_end:\n"
+".previous\n"
+);
 #endif
 
 #ifdef TEGRA210_XUSB_BIN_STATIC
-extern const char _binary_tegra210_xusb_bin_size[];
 extern const char _binary_tegra210_xusb_bin_start[];
+extern const char _binary_tegra210_xusb_bin_end[];
+__asm__(
+".section \".rodata\"\n"
+"_binary_tegra210_xusb_bin_start:\n"
+".incbin \"../external/nvidia-firmware/tegra/dist/tegra210/xusb.bin\"\n"
+".size _binary_tegra210_xusb_bin_start, . - _binary_tegra210_xusb_bin_start\n"
+"_binary_tegra210_xusb_bin_end:\n"
+".previous\n"
+);
 #endif
 
 enum xusb_type {
@@ -729,7 +745,8 @@
        switch (psc->sc_txd->txd_type) {
        case XUSB_T124:
 #if defined(TEGRA124_XUSB_BIN_STATIC)
-               firmware_size = (uintptr_t)&_binary_tegra124_xusb_bin_size;
+               firmware_size = (uintptr_t)&_binary_tegra124_xusb_bin_end
+                   - (uintptr_t)&_binary_tegra124_xusb_bin_start;
                fw_static = __UNCONST(_binary_tegra124_xusb_bin_start);
 #else
                fw_path = "nvidia/tegra124";
@@ -737,7 +754,8 @@
                break;
        case XUSB_T210:
 #if defined(TEGRA210_XUSB_BIN_STATIC)
-               firmware_size = (uintptr_t)&_binary_tegra210_xusb_bin_size;
+               firmware_size = (uintptr_t)&_binary_tegra210_xusb_bin_end
+                   - (uintptr_t)&_binary_tegra210_xusb_bin_start;
                fw_static = __UNCONST(_binary_tegra210_xusb_bin_start);
 #else
                fw_path = "nvidia/tegra210";
diff -r 8d315ab128d5 -r 3e1583f3f504 sys/arch/evbarm/conf/mk.generic
--- a/sys/arch/evbarm/conf/mk.generic   Sat Aug 29 18:54:33 2020 +0000
+++ b/sys/arch/evbarm/conf/mk.generic   Sat Aug 29 19:06:17 2020 +0000
@@ -1,6 +1,4 @@
-#      $NetBSD: mk.generic,v 1.9 2019/12/16 11:00:30 skrll Exp $
-
-.include "$S/arch/arm/nvidia/tegra_xusb-fw.mk"
+#      $NetBSD: mk.generic,v 1.10 2020/08/29 19:06:18 jakllsch Exp $
 
 .if !empty(MACHINE_ARCH:M*eb)
 EXTRA_LINKFLAGS+=      --be8



Home | Main Index | Thread Index | Old Index