From patchwork Thu Jun 21 21:26:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 932962 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=lucaceresoli.net Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41BZXM6kdMz9s0W for ; Fri, 22 Jun 2018 07:26:59 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 51BC189654; Thu, 21 Jun 2018 21:26:57 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bu-Zic5-2nbO; Thu, 21 Jun 2018 21:26:46 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 12C92894F3; Thu, 21 Jun 2018 21:26:43 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 367191C25C5 for ; Thu, 21 Jun 2018 21:26:40 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 2E95789482 for ; Thu, 21 Jun 2018 21:26:40 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id iTg4qpV55r8u for ; Thu, 21 Jun 2018 21:26:37 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from srv-hp10-72.netsons.net (srv-hp10-72.netsons.net [94.141.22.72]) by whitealder.osuosl.org (Postfix) with ESMTPS id 8F5BE894E7 for ; Thu, 21 Jun 2018 21:26:37 +0000 (UTC) Received: from [146.241.228.40] (port=57463 helo=yard.fritz.box) by srv-hp10.netsons.net with esmtpa (Exim 4.89_1) (envelope-from ) id 1fW768-009PVV-O5; Thu, 21 Jun 2018 23:26:32 +0200 From: Luca Ceresoli To: buildroot@buildroot.org Date: Thu, 21 Jun 2018 23:26:23 +0200 Message-Id: <1529616385-15826-2-git-send-email-luca@lucaceresoli.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1529616385-15826-1-git-send-email-luca@lucaceresoli.net> References: <1529616385-15826-1-git-send-email-luca@lucaceresoli.net> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - srv-hp10.netsons.net X-AntiAbuse: Original Domain - buildroot.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lucaceresoli.net X-Get-Message-Sender-Via: srv-hp10.netsons.net: authenticated_id: luca+lucaceresoli.net/only user confirmed/virtual account not confirmed X-Authenticated-Sender: srv-hp10.netsons.net: luca@lucaceresoli.net X-Source: X-Source-Args: X-Source-Dir: Subject: [Buildroot] [PATCH v4 1/3] uboot: zynqmp: allow to use custom psu_init files X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.24 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Luca Ceresoli MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" U-Boot SPL configures pinmuxes, clocks and other low-level devices. On the Xilinx ZynqMP SoCs the code to do this resides in a file called psu_init_gpl.c which is initially generated by the Xilinx development tools. Add an option to pass these files from the outside (e.g. in the board files). For this to work properly, a patch to U-Boot is needed. However this patch must be applied by each defconfig using BR2_TARGET_UBOOT_ZYNQMP_PSU_INIT_DIR. If it were in boot/uboot/ to be applied unconditionally, it would break the build for configs using a U-Boot version where the patch is already applied. Signed-off-by: Luca Ceresoli --- Changes v3 -> v4: - don't copy the psu_init file(s) in the source tree, point to its path (which needs a patch sent upstream to work) - depend on BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG (Thomas) - point to the file, not the directory Changes v2 -> v3: - Add a bool option to show/hidw all ZynqMP-specific config knobs - Move this patch before "uboot: zynqmp: generate SPL image with PMUFW binary" - Reword Config.in text Changes v1 -> v2: - split from a larger patch doing 2 things - document the option of having psu_init_gpl.c without .h --- ...ynq-zynqmp-pass-the-PS-init-file-as-a-kco.patch | 175 +++++++++++++++++++++ boot/uboot/Config.in | 33 ++++ boot/uboot/uboot.mk | 15 ++ 3 files changed, 223 insertions(+) create mode 100644 board/zynqmp/patches/uboot/0004-arm-arm64-zynq-zynqmp-pass-the-PS-init-file-as-a-kco.patch diff --git a/board/zynqmp/patches/uboot/0004-arm-arm64-zynq-zynqmp-pass-the-PS-init-file-as-a-kco.patch b/board/zynqmp/patches/uboot/0004-arm-arm64-zynq-zynqmp-pass-the-PS-init-file-as-a-kco.patch new file mode 100644 index 000000000000..ab8108ee0c6a --- /dev/null +++ b/board/zynqmp/patches/uboot/0004-arm-arm64-zynq-zynqmp-pass-the-PS-init-file-as-a-kco.patch @@ -0,0 +1,175 @@ +From 4c9d54ab5a41d65000c8d249b6fb1b76056f1812 Mon Sep 17 00:00:00 2001 +From: Luca Ceresoli +Date: Wed, 20 Jun 2018 12:11:50 +0200 +Subject: [PATCH] arm/arm64: zynq/zynqmp: pass the PS init file as a kconfig + variable + +U-Boot needs to link ps7_init_gpl.c on Zynq or psu_init_gpl.c on +ZynqMP (PS init for short). The current logic to locate this file for +both platforms is: + + 1. if a board-specific file exists in + board/xilinx/zynq[mp]/$(CONFIG_DEFAULT_DEVICE_TREE)/ps?_init_gpl.c + then use it + 2. otherwise use board/xilinx/zynq/ps?_init_gpl.c + +In the latter case the file does not exist in the U-Boot sources and +must be copied in the source tree from the outside before starting the +build. This is typical when it is generated from Xilinx tools while +developing a custom hardware. However making sure that a +board-specific file is _not_ found (and used) requires some trickery +such as removing or overwriting all PS init files (e.g.: the current +meta-xilinx yocto layer [0]). + +This generates a few problems: + + * if the source tree is shared among different out-of-tree builds, + they will pollute (and potentially corrupt) each other + * the source tree cannot be read-only + * any buildsystem must add a command to copy the PS init file binary + * overwriting or deleting files in the source tree is ugly as hell + +Simplify usage by allowing to pass the path to the desired PS init +file in kconfig variable XILINX_PS_INIT_FILE. It can be an absolute +path or relative to $(srctree). If the variable is set, the +user-specified file will always be used without being copied +around. If the the variable is left empty, for backward compatibility +fall back to the old behaviour. + +Since the issue is the same for Zynq and ZynqMP, add one kconfig +variable in a common place and use it for both. + +Also use the new kconfig help text to document all the ways to give +U-Boot the PS init file. + +Build-tested with all combinations of: + - platform: zynq or zynqmp + - PS init file: from XILINX_PS_INIT_FILE (absolute, relative path, + non-existing), in-tree board-specific, in board/xilinx/zynq[mp]/ + - building in-tree, in subdir, in other directory + +[0] https://github.com/Xilinx/meta-xilinx/blob/b2f74cc7fe5c4881589d5e440a17cb51fc66a7ab/meta-xilinx-bsp/recipes-bsp/u-boot/u-boot-spl-zynq-init.inc#L9 + +Signed-off-by: Luca Ceresoli +Cc: Albert Aribaud +Cc: Michal Simek +Cc: Nathan Rossi +Submitted upstream: https://patchwork.ozlabs.org/patch/932392/ (slightly adapted to fix conflicts) +--- + arch/arm/Kconfig | 1 + + board/xilinx/Kconfig | 41 +++++++++++++++++++++++++++++++++++++++++ + board/xilinx/zynq/Makefile | 10 +++++++++- + board/xilinx/zynqmp/Makefile | 10 +++++++++- + 4 files changed, 60 insertions(+), 2 deletions(-) + create mode 100644 board/xilinx/Kconfig + +diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig +index 22234cde2ab6..e04979d0ef7e 100644 +--- a/arch/arm/Kconfig ++++ b/arch/arm/Kconfig +@@ -1293,4 +1293,5 @@ source "board/technologic/ts4600/Kconfig" + source "board/vscom/baltos/Kconfig" + source "board/woodburn/Kconfig" + source "board/work-microwave/work_92105/Kconfig" ++source "board/xilinx/Kconfig" + source "board/zipitz2/Kconfig" + + source "arch/arm/Kconfig.debug" +diff --git a/board/xilinx/Kconfig b/board/xilinx/Kconfig +new file mode 100644 +index 000000000000..aa3fa061edef +--- /dev/null ++++ b/board/xilinx/Kconfig +@@ -0,0 +1,41 @@ ++# Copyright (c) 2018, Luca Ceresoli ++# ++# SPDX-License-Identifier: GPL-2.0 ++ ++if ARCH_ZYNQ || ARCH_ZYNQMP ++ ++config XILINX_PS_INIT_FILE ++ string "Zynq/ZynqMP PS init file(s) location" ++ help ++ On Zynq and ZynqMP U-Boot SPL (or U-Boot proper if ++ ZYNQMP_PSU_INIT_ENABLED is set) is responsible for some ++ basic initializations, such as enabling peripherals and ++ configuring pinmuxes. The PS init file (called ++ psu_init_gpl.c on ZynqMP, ps7_init_gpl.c for Zynq-7000) ++ contains the code for such initializations. ++ ++ U-Boot contains PS init files for some boards, but each of ++ them describes only one specific configuration. Users of a ++ different board, or needing a different configuration, can ++ generate custom files using the Xilinx development tools. ++ ++ There are three ways to give a PS init file to U-Boot: ++ ++ 1. Set this variable to the path, either relative to the ++ source tree or absolute, where the psu_init_gpl.c or ++ ps7_init_gpl.c file is located. U-Boot will build this ++ file. ++ ++ 2. If you leave an empty string here, U-Boot will use ++ board/xilinx/zynq/$(CONFIG_DEFAULT_DEVICE_TREE)/ps7_init_gpl.c ++ for Zynq-7000, or ++ board/xilinx/zynqmp/$(CONFIG_DEFAULT_DEVICE_TREE)/psu_init_gpl.c ++ for ZynqMP. ++ ++ 3. If the above file does not exist, U-Boot will use ++ board/xilinx/zynq/ps7_init_gpl.c for Zynq-7000, or ++ board/xilinx/zynqmp/psu_init_gpl.c for ZynqMP. This file ++ is not provided by U-Boot, you have to copy it there ++ before the build. ++ ++endif +diff --git a/board/xilinx/zynq/Makefile b/board/xilinx/zynq/Makefile +index 5a76a26720cd..03ad5f0532ee 100644 +--- a/board/xilinx/zynq/Makefile ++++ b/board/xilinx/zynq/Makefile +@@ -5,10 +5,18 @@ + + obj-y := board.o + +-hw-platform-y :=$(shell echo $(CONFIG_DEFAULT_DEVICE_TREE)) ++ifneq ($(CONFIG_XILINX_PS_INIT_FILE),"") ++PS_INIT_FILE := $(shell cd $(srctree); readlink -f $(CONFIG_XILINX_PS_INIT_FILE)) ++init-objs := ps_init_gpl.o ++spl/board/xilinx/zynq/ps_init_gpl.o board/xilinx/zynq/ps_init_gpl.o: $(PS_INIT_FILE) ++ $(CC) $(c_flags) -I $(srctree)/$(src) -c -o $@ $^ ++endif + ++ifeq ($(init-objs),) ++hw-platform-y :=$(shell echo $(CONFIG_DEFAULT_DEVICE_TREE)) + init-objs := $(if $(wildcard $(srctree)/$(src)/$(hw-platform-y)/ps7_init_gpl.c),\ + $(hw-platform-y)/ps7_init_gpl.o) ++endif + + ifeq ($(init-objs),) + ifneq ($(wildcard $(srctree)/$(src)/ps7_init_gpl.c),) +diff --git a/board/xilinx/zynqmp/Makefile b/board/xilinx/zynqmp/Makefile +index 05ccd25dcef3..960b81fc5853 100644 +--- a/board/xilinx/zynqmp/Makefile ++++ b/board/xilinx/zynqmp/Makefile +@@ -5,10 +5,18 @@ + + obj-y := zynqmp.o + +-hw-platform-y :=$(shell echo $(CONFIG_DEFAULT_DEVICE_TREE)) ++ifneq ($(CONFIG_XILINX_PS_INIT_FILE),"") ++PS_INIT_FILE := $(shell cd $(srctree); readlink -f $(CONFIG_XILINX_PS_INIT_FILE)) ++init-objs := ps_init_gpl.o ++spl/board/xilinx/zynqmp/ps_init_gpl.o board/xilinx/zynqmp/ps_init_gpl.o: $(PS_INIT_FILE) ++ $(CC) $(c_flags) -I $(srctree)/$(src) -c -o $@ $^ ++endif + ++ifeq ($(init-objs),) ++hw-platform-y :=$(shell echo $(CONFIG_DEFAULT_DEVICE_TREE)) + init-objs := $(if $(wildcard $(srctree)/$(src)/$(hw-platform-y)/psu_init_gpl.c),\ + $(hw-platform-y)/psu_init_gpl.o) ++endif + + ifeq ($(init-objs),) + ifneq ($(wildcard $(srctree)/$(src)/psu_init_gpl.c),) +-- +2.7.4 + diff --git a/boot/uboot/Config.in b/boot/uboot/Config.in index 482711ca6410..b8bff9949e3d 100644 --- a/boot/uboot/Config.in +++ b/boot/uboot/Config.in @@ -365,6 +365,39 @@ config BR2_TARGET_UBOOT_ZYNQ_IMAGE for u-boot-dtb.img file so this U-Boot format is required to be set. +config BR2_TARGET_UBOOT_ZYNQMP + bool "Boot on the Xilinx ZynqMP SoCs" + depends on BR2_aarch64 + help + Enable options specific to the Xilinx ZynqMP family of SoCs. + +if BR2_TARGET_UBOOT_ZYNQMP + +config BR2_TARGET_UBOOT_ZYNQMP_PSU_INIT_FILE + string "Custom psu_init_gpl file" + depends on BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG + help + On ZynqMP the booloader is responsible for some basic + initializations, such as enabling peripherals and + configuring pinmuxes. The psu_init_gpl.c file (and, + optionally, psu_init_gpl.h) contains the code for such + initializations. + + Although U-Boot contains psu_init_gpl.c files for some + boards, each of them describes only one specific + configuration. Users of a different board, or needing a + different configuration, can generate custom files using the + Xilinx development tools. + + Set this variable to the path to your psu_init_gpl.c + file. psu_init_gpl.h, if needed, should be in the same + directory. U-Boot will build and link the user-provided file + instead of the built-in one. + + Leave empty to use the files provided by U-Boot. + +endif + config BR2_TARGET_UBOOT_ALTERA_SOCFPGA_IMAGE_CRC bool "CRC image for Altera SoC FPGA (mkpimage)" depends on BR2_arm diff --git a/boot/uboot/uboot.mk b/boot/uboot/uboot.mk index 03bd7ea743ed..e4571a6ccf9f 100644 --- a/boot/uboot/uboot.mk +++ b/boot/uboot/uboot.mk @@ -274,6 +274,17 @@ define UBOOT_INSTALL_IMAGES_CMDS $(BINARIES_DIR)/boot.scr) endef +ifeq ($(BR2_TARGET_UBOOT_ZYNQMP),y) + +ifneq ($(call qstrip,$(BR2_TARGET_UBOOT_ZYNQMP_PSU_INIT_FILE)),) +define UBOOT_ZYNQMP_KCONFIG_PSU_INIT + $(call KCONFIG_SET_OPT,CONFIG_XILINX_PS_INIT_FILE,"$(TOPDIR)/$(call qstrip,$(BR2_TARGET_UBOOT_ZYNQMP_PSU_INIT_FILE))", \ + $(@D)/.config) +endef +endif + +endif # BR2_TARGET_UBOOT_ZYNQMP + define UBOOT_INSTALL_OMAP_IFT_IMAGE cp -dpf $(@D)/$(UBOOT_BIN_IFT) $(BINARIES_DIR)/ endef @@ -323,6 +334,10 @@ UBOOT_DEPENDENCIES += host-mkpimage UBOOT_POST_INSTALL_IMAGES_HOOKS += UBOOT_CRC_ALTERA_SOCFPGA_IMAGE endif +define UBOOT_KCONFIG_FIXUP_CMDS + $(UBOOT_ZYNQMP_KCONFIG_PSU_INIT) +endef + ifeq ($(BR2_TARGET_UBOOT_ENVIMAGE),y) ifeq ($(BR_BUILDING),y) ifeq ($(call qstrip,$(BR2_TARGET_UBOOT_ENVIMAGE_SOURCE)),)