From patchwork Sun Jul 21 17:59:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Auer X-Patchwork-Id: 1135204 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=aisec.fraunhofer.de Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45sq3Y6pBnz9sBZ for ; Tue, 23 Jul 2019 03:53:43 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 3831CC21E12; Mon, 22 Jul 2019 17:49:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=KHOP_BIG_TO_CC autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 63C3CC220FA; Mon, 22 Jul 2019 13:15:31 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 35DF2C21DD4; Sun, 21 Jul 2019 18:01:03 +0000 (UTC) Received: from mail-edgeKA24.fraunhofer.de (mail-edgeka24.fraunhofer.de [153.96.1.24]) by lists.denx.de (Postfix) with ESMTPS id 0FB61C21CB1 for ; Sun, 21 Jul 2019 18:00:56 +0000 (UTC) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2HeAQB5pzRd/xmnZsBmHAEBAQQBAQcEAQGBVAYBAQsBghZtUgEfPIdnhTGJGIMNgTMBlkyBewkBAQEBAQEBAQEIHxABAYEEgzyCVSM1CA4BAwEBBQEBAQEGAgJphR4MhC9fdgFBBYEeIA6DJwGCCqpyg3WEeYFICQGBKgGHB4RXgVc/gRABgl2LGgSORZweBwKBOWJdBIV3jSgMG4ItiwWKWI5mkjGEFoFRATeBWDMaJIM7CYlohxc9ATKPVQEB X-IPAS-Result: A2HeAQB5pzRd/xmnZsBmHAEBAQQBAQcEAQGBVAYBAQsBghZtUgEfPIdnhTGJGIMNgTMBlkyBewkBAQEBAQEBAQEIHxABAYEEgzyCVSM1CA4BAwEBBQEBAQEGAgJphR4MhC9fdgFBBYEeIA6DJwGCCqpyg3WEeYFICQGBKgGHB4RXgVc/gRABgl2LGgSORZweBwKBOWJdBIV3jSgMG4ItiwWKWI5mkjGEFoFRATeBWDMaJIM7CYlohxc9ATKPVQEB X-IronPort-AV: E=Sophos;i="5.64,291,1559512800"; d="scan'208";a="16085677" Received: from mail-mtadd25.fraunhofer.de ([192.102.167.25]) by mail-edgeKA24.fraunhofer.de with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Jul 2019 20:00:54 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0BKAADrpjRdfRBhWMBmHAEBAQQBAQcEAQGBVAYBAQsBgwNSIDyNGIwmmACBewkBAwEBAQEBCB8QAQGEQIJ3NQgOAQMBAQQBAQIBBhQBARY6hSUMhgMBQQWBHiAOgycBggqqc4hugUgJAYEqAYcHhi4/gRABgl2LGgSORZweBwKBOWJdBIV3jSgMG4ItiwWKWI5mlkeBUQE1gVkzGiSDOwmJaIcXPQMwj1UBAQ X-IronPort-AV: E=Sophos;i="5.64,291,1559512800"; d="scan'208";a="52897831" Received: from fgdemucivp01ltm.xch.fraunhofer.de (HELO FGDEMUCIMP11EXC.ads.fraunhofer.de) ([192.88.97.16]) by mail-mtaDD25.fraunhofer.de with ESMTP/TLS/AES256-SHA; 21 Jul 2019 20:00:49 +0200 Received: from localhost.de (10.80.233.50) by FGDEMUCIMP11EXC.ads.fraunhofer.de (10.80.232.42) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 21 Jul 2019 20:00:47 +0200 From: Lukas Auer To: Date: Sun, 21 Jul 2019 19:59:52 +0200 Message-ID: <20190721180002.26993-1-lukas.auer@aisec.fraunhofer.de> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-11.0.0.4179-8.200.1013-24780.003 X-TM-AS-Result: No--10.899200-8.000000-31 X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-Mailman-Approved-At: Mon, 22 Jul 2019 13:15:29 +0000 Cc: Joe Hershberger , Alistair Francis , Miquel Raynal , Eugeniu Rosca , Chris Packham , Michal Simek , Marek Vasut , Marek Vasut , Tien Fong Chee , Alexander Graf , Stefan Roese , Ryder Lee , Heinrich Schuchardt Subject: [U-Boot] [RFC PATCH 00/11] SPL support for RISC-V X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This series adds support for SPL to RISC-V U-Boot. Images can be booted via OpenSBI (FW_DYNAMIC firmware) or by directly jumping to them. In the former case, OpenSBI and U-Boot proper are bundled as a FIT image and made available to U-Boot SPL. Currently, only the QEMU board enables U-Boot SPL with a dedicated configuration. It uses RAM as SPL boot device. On many RISC-V CPUs, the device tree is provided to U-Boot by the first stage bootloader. This requires changes to U-Boot SPL (patches 1, 2 and 3), which modify the behavior on other boards as well. To get feedback on this, I am therefore sending this series as RFC first. To test this series, OpenSBI has to be compiled first. The fw_dynamic.bin binary must be copied into the U-Boot root directory. Alternatively, the location of the binary can be specified with the OPENSBI environment variable. U-Boot can then be build as normal using the configuration qemu-riscv64_spl_defconfig for 64-bit builds or qemu-riscv32_spl_defconfig for 32-bit builds. The outputs from the build process are the U-Boot SPL binary (spl/u-boot-spl.bin) and the U-Boot FIT image (u-boot.itb) containing U-Boot proper and OpenSBI. U-Boot can be run in QEMU with the following command. qemu-system-riscv64 -nographic -machine virt -kernel spl/u-boot-spl \ -device loader,file=u-boot.itb,addr=0x80200000 Lukas Auer (11): fdtdec: make CONFIG_OF_PRIOR_STAGE available in SPL Makefile: support building SPL FIT images without device trees spl: fit: use U-Boot device tree when FIT image has no device tree riscv: add run mode configuration for SPL spl: support booting via RISC-V OpenSBI riscv: add SPL support riscv: support SPL stack and global data relocation riscv: add a generic FIT generator script riscv: set default FIT generator script and build target for SPL builds riscv: qemu: add SPL configuration doc: update QEMU RISC-V documentation Kconfig | 4 +- Makefile | 8 +- arch/Kconfig | 6 ++ arch/riscv/Kconfig | 36 +++++++-- arch/riscv/cpu/ax25/Kconfig | 6 +- arch/riscv/cpu/cpu.c | 6 +- arch/riscv/cpu/generic/Kconfig | 5 +- arch/riscv/cpu/start.S | 62 ++++++++++++++- arch/riscv/cpu/u-boot-spl.lds | 82 +++++++++++++++++++ arch/riscv/include/asm/encoding.h | 2 +- arch/riscv/include/asm/spl.h | 31 ++++++++ arch/riscv/lib/Makefile | 8 +- arch/riscv/lib/mkimage_fit_opensbi.sh | 100 ++++++++++++++++++++++++ arch/riscv/lib/spl.c | 48 ++++++++++++ board/emulation/qemu-riscv/Kconfig | 10 +++ board/emulation/qemu-riscv/MAINTAINERS | 2 + board/emulation/qemu-riscv/qemu-riscv.c | 17 ++++ common/image.c | 1 + common/spl/Kconfig | 17 ++++ common/spl/Makefile | 1 + common/spl/spl.c | 8 +- common/spl/spl_fit.c | 37 ++++++--- common/spl/spl_opensbi.c | 85 ++++++++++++++++++++ configs/qemu-riscv32_spl_defconfig | 11 +++ configs/qemu-riscv64_spl_defconfig | 12 +++ doc/README.qemu-riscv | 56 ++++++++++++- include/configs/qemu-riscv.h | 14 ++++ include/fdtdec.h | 2 +- include/image.h | 1 + include/opensbi.h | 40 ++++++++++ include/spl.h | 5 ++ lib/fdtdec.c | 6 +- 32 files changed, 687 insertions(+), 42 deletions(-) create mode 100644 arch/riscv/cpu/u-boot-spl.lds create mode 100644 arch/riscv/include/asm/spl.h create mode 100755 arch/riscv/lib/mkimage_fit_opensbi.sh create mode 100644 arch/riscv/lib/spl.c create mode 100644 common/spl/spl_opensbi.c create mode 100644 configs/qemu-riscv32_spl_defconfig create mode 100644 configs/qemu-riscv64_spl_defconfig create mode 100644 include/opensbi.h