Received: by 10.223.164.202 with SMTP id h10csp4749977wrb; Mon, 20 Nov 2017 22:20:16 -0800 (PST) X-Google-Smtp-Source: AGs4zMYvEx5MICZumkpyhClUmtv3Zg17J6ynm2HZf7KA8EYF/0kfKIyQxgdOmFuQ7EcZlPvYm54Q X-Received: by 10.84.129.2 with SMTP id 2mr16399641plb.343.1511245215935; Mon, 20 Nov 2017 22:20:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511245215; cv=none; d=google.com; s=arc-20160816; b=cfA4JnV7gXcsKmWS/pUqKhZMm2eG+xXGfqs8P6XQEi0jBgD2tGo/CEerdVQ84+x0UM IKfLYvRBgdHYxx5imQFsyq80Vv+xMPniPHLb3qcDOZDVgjsy9pER5nMUFzUEK+W40iFa 0WRL/QFDIpo30mvU8Sxs7ILZbyP36dZNrouud2UM4N/tg1HSSbMkuyWLlV828t9tlw2D IoEHaErYubpEI/k6BkwXyx76dGYuYfOUqyrZ7Wq8U6QNULwrgQReT9S5uPVyYYaT57Sc E2jx0NsHA0aXps53ATH3WK4dkJW6Go+q9vxyByy3CiQsIFcvBpvJgHUTs19N+iArFfLm zluA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:references:to:from:subject:reply-to :arc-authentication-results; bh=AgrTfAEioBG1Y0aQsb9n9+MYyLf9/rpKKYWzL6Iof1w=; b=uzohtX7zNSsvsgqyFghvf7x5JP1polGNyHk/4iIl0eqT4sfrcGe/E7cs5cuKo9ejIc 3g1N2Z3EoLNCLMO5PAHE6iDc/cJmGLnEvPhWMCC4cjy3InRF4Uk7uzsjmWNs//SH3E1D IG5cnjdz5lvMwiqAUMMhhkmm0bY6m807ZVsrKUnYuB/akf34f9/N63CxpYg3Nmgzw5IJ 39H5wOXLJqnSAMvPnBvW7WMioD8fn1g94D7ySDEOLB+oWHnB94zyxOos/UCP9KP47WMU qEqwXlnlc8YBqA2SwLwg+7pgHMtXy48t2A8ypSmrXVGlRnv0MZWNgDEfH2DnJ5kheue7 oYHA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3si4040455plt.771.2017.11.20.22.20.04; Mon, 20 Nov 2017 22:20:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752924AbdKUGT1 (ORCPT + 73 others); Tue, 21 Nov 2017 01:19:27 -0500 Received: from v-smtpout2.han.skanova.net ([81.236.60.155]:54355 "EHLO v-smtpout2.han.skanova.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751743AbdKUGTZ (ORCPT ); Tue, 21 Nov 2017 01:19:25 -0500 Received: from [10.175.196.237] ([37.123.169.62]) by cmsmtp with SMTP id H1tzeHg4jAXuLH1tzeEYBF; Tue, 21 Nov 2017 07:19:23 +0100 Reply-To: linux-kernel@emagii.com Subject: Re: RFC: Copying Device Tree File into reserved area of VMLINUX before deployment From: Ulf Samuelsson To: Frank Rowand , LKML , "devicetree@vger.kernel.org" , Rob Herring References: <0b31e22b-202f-6fca-28f2-e16e6af6c6b7@emagii.com> <0e54f9f0-1226-7f2e-3143-ea4e450058e6@gmail.com> <872e81dc-82ba-f838-c4f8-88d2208d23d2@emagii.com> Organization: eMagii Message-ID: <4d2f0bf4-d49a-27bc-75aa-11c78bc074fa@emagii.com> Date: Tue, 21 Nov 2017 07:19:22 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <872e81dc-82ba-f838-c4f8-88d2208d23d2@emagii.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-CMAE-Envelope: MS4wfPUpHrPEJ6Xq3a0KMeqlGKH7twcO43FfsMvUiYGTq8KnFRbDgO4wJB8x67D5z0J/yz3UqFq7srn2oVhZjApBDs88fHybgtkkPG7OjSCupiw5pTPG5SHl uRkO8Bo4ECA/zISg/YlH7oqk3C/+L9RNM4msfMRG8ctjKIhKCJhzL121SNVLcyYAz/FFGSVqkF0KlEWOrENCE/ceTt32AASOSeJlWThFhfu1OOj4R2sSXkZb t47RrLC1XDWo58AwlNps1x44/q1qO0CRXs7tNCQQdVFzwyfmt1URaBmt6Nz2Ygn/ Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2017-11-21 00:09, Ulf Samuelsson wrote: > > > On 2017-11-20 22:39, Frank Rowand wrote: >> Hi Ulf, Rob, >> >> On 11/20/17 15:19, Ulf Samuelsson wrote: >>> >>> >>> On 2017-11-20 05:32, Frank Rowand wrote: >>>> Hi Ulf, >>>> >>>> >>>> On 11/19/17 23:23, Frank Rowand wrote: >>>>> adding devicetree list, devicetree maintainers >>>>> >>>>> On 11/18/17 12:59, Ulf Samuelsson wrote: >>>>>> I noticed when checking out the OpenWRT support for the board that >>>>>> they have a method to avoid having to pass the device tree address >>>>>> to the kernel, and can thus boot device tree based kernels with >>>>>> U-boots that >>>>>> does not support device trees. >>>>>> >>>>>> Is this something that would be considered useful for including in >>>>>> mainstream: >>>>>> >>>>>> BACKGROUND: >>>>>> Trying to load a yocto kernel into a MIPS target (MT7620A based), >>>>>> and the U-Boot is more than stupid. >>>>>> Does not support the "run" command as an example. >>>>>> They modified the U-Boot MAGIC Word to complicate things. >>>>>> The U-Boot is not configured to use device tree files. >>>>>> The board runs a 2.6 kernel right now. >>>>>> >>>>>> Several attempts by me a and others to rebuild U-Boot according to >>>>>> the H/W vendors source code and build instructions results in a >>>>>> bricked unit. Bricked units cannot be recovered. >>>> >>>> Hopefully you have brought this to the attention of the vendor.  U-Boot >>>> is GPL v2 (or in some ways possibly GPL v2 or later), so if you can not >>>> build U-Boot that is equivalent to the binary U-Boot they shipped, the >>>> vendor may want to ensure that they are shipping the proper source and >>>> build instructions. >>>> >>> >>> I am not the one in contact with the H/W vendor. >>> The U-boot is pretty old, and from comments from those >>> in contact with them, the U-Boot knowledge at the H/W vendor >>> is minimal at best. >>> It might even be that they program an U-boot where the upgrade of the >>> U-boot is broken... >>> >>> >>>> >>>>>> Not my choice of H/W, so I cannot change it. >>>>>> >>>>>> >>>>>> =================================================================== >>>>>> OPENWRT: >>>>>> I noticed when checking out the OpenWRT support for the board that >>>>>> they have a method to avoid having to pass the device tree address >>>>>> to the kernel, and can thus boot device tree based kernels with >>>>>> U-boots that does not support device trees. >>>>>> >>>>>> What they do is to reserve 16 kB of kernel space, and tag it with >>>>>> an ASCII string "OWRTDTB:". After the kernel and dtb is built, a >>>>>> utility "patch-dtb" will update the vmlinux binary, copying in the >>>>>> device tree file. >>>>>> >>>>>> =================================================================== >>>>>> It would be useful to me, and I could of course patch the >>>>>> mainstream kernel, but first I would like to check if this is of >>>>>> interest for mainstream. >>>> >>>> Not in this form.  Hard coding a fixed size area in the boot image >>>> to contain the FDT (aka DTB) is a non-starter. >>> >>> OK, Is it the fixed size, which is a problem? >> >> Yes, it is the fixed size which is a problem. > > The size can of course be changed, by setting the size configuration > option (DTB_SIZE). > OpenWRT does not support that, but I think it needs to be there for a > generic option (but You have to recompile the kernel to increase the size). > > One problem is that you normally compile and link the kernel before you > compile the dtbs, so you do not know what size is until afterwards. > Found this link: https://csl.name/post/embedding-binary-data/ ======================================= ... Let's say you have an image target.dtb and want to embed it into your application. You can create an object file with image_dtb.o: mv image_dtb ld -r -b binary image_dtb -o image_dtb.o The object file will have three symbols in it, $ nm cat.o 0000000000000512 D _binary_image_dtb_end 0000000000000512 A _binary_image_dtb_size 0000000000000000 D _binary_image_dtb_start ======================================= This assumes that the dtbs are built before the kernel is linked. The copy step is neccessary, since the generated names are taken from the name of the "in file". (Would have been better, if they used the "out file") Otherwise you can create an assembler file which "incbin's" the dtb file. > >> >>> Is generally combining an image with a DTB into a single file also a >>> non-starter? >> >> Can you jump in here Rob?  My understanding is that >> CONFIG_ARM_APPENDED_DTB, >> which is the ARM based solution that Mark mentioned, was envisioned as a >> temporary stop gap until boot loaders could add devicetree support.  I >> don't >> know if there is a desire to limit this approach or to remove it in the >> future. >> >> I'm not sure why this feature should not be permanently supported. >> I'm being >> cautious, just in case I'm overlooking or missing an important issue, >> thus >> asking for Rob's input.  I do know that this feature does not advance the >> desires of people who want a single kernel (single boot image?) that >> runs on >> many different systems, instead of a boot image that is unique to each >> target platform.  But I don't see why that desire precludes also having >> an option to have a target specific boot image. > The main reason to keep it is when you are really constrained for memory. > The U-Boot on the board is 96 kB, which is just a fraction of a more > normal U-Boot. > Also, the u-boot is old. > > >> >> -Frank >> >> >>>> >>>> And again, I would first approach the H/W vendor before trying to >>>> come up with a work around like this. >>>> >>>> >>>>>> I envisage the support would look something like: >>>>>> >>>>>> ============ >>>>>> Kconfig. >>>>>> config MIPS >>>>>>       select    HAVE_IMAGE_DTB >>>>>> >>>>>> config    HAVE_IMAGE_DTB >>>>>>       bool >>>>>> >>>>>> if HAVE_IMAGE_DTB >>>>>> config     IMAGE_DTB >>>>>>       bool    "Allocated space for DTB within image >>>>>> >>>>>> config    DTB_SIZE >>>>>>       int    "DTB space (kB) >>>>>> >>>>>> config    DTB_TAG >>>>>>       string    "DTB space tag" >>>>>>       default    "OWRTDTB:" >>>>>> endif >>>>>> >>>>>> ============ >>>>>> Some Makefile >>>>>> obj-$(CONFIG_INCLUDE_DTB) += image_dtb.o >>>>>> >>>>>> ============ >>>>>> image_dtb.S: >>>>>>       .text >>>>>>       .align    5 >>>>>>       .ascii    CONFIG_DTB_TAG >>>>>>       EXPORT(__image_dtb) >>>>>>       .fill    DTB_SIZE * 1024 >>>>>> >>>>>> =================== >>>>>> arch/mips/xxx/of.c: >>>>>> >>>>>> #if    defined(CONFIG_IMAGE_DTB) >>>>>>       if () >>>>>>           __dt_setup_arch(__dtb_start); >>>>>>       else >>>>>>           __dt_setup_arch(&__image_dtb); >>>>>> #else >>>>>>       __dt_setup_arch(__dtb_start); >>>>>> #endif >>>>>> >>>>>> I imagine that if the support is enabled for a target, it should >>>>>> be possible to override it with a CMDLINE argument >>>>>>            They do something similar for the CMDLINE; copying it >>>>>> into the vmlinux, to allow a smaller boot >>> >> > -- Best Regards Ulf Samuelsson From 1584628452626861156@xxx Mon Nov 20 23:10:56 +0000 2017 X-GM-THRID: 1584466498009191251 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread