From patchwork Thu Dec 24 12:44:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chris LaRocque X-Patchwork-Id: 560934 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ozlabs.org (Postfix) with ESMTP id 369F7140C3E for ; Fri, 25 Dec 2015 00:10:16 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 5B846A6021; Thu, 24 Dec 2015 13:10:15 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IbEnKzKUz-AC; Thu, 24 Dec 2015 13:10:11 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id CD3F7A6027; Thu, 24 Dec 2015 13:10:10 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 9C2DE1C16BD for ; Thu, 24 Dec 2015 13:10:09 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 8D2D5A602D for ; Thu, 24 Dec 2015 13:10:09 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zWP99jFlsTwk for ; Thu, 24 Dec 2015 13:10:07 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from plane.gmane.org (plane.gmane.org [80.91.229.3]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 06BE3A6029 for ; Thu, 24 Dec 2015 13:10:07 +0000 (UTC) Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1aC5ed-0004wY-BR for buildroot@uclibc.org; Thu, 24 Dec 2015 14:10:03 +0100 Received: from pool-173-50-96-7.nrflva.fios.verizon.net ([173.50.96.7]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 24 Dec 2015 14:10:03 +0100 Received: from clarocq by pool-173-50-96-7.nrflva.fios.verizon.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 24 Dec 2015 14:10:03 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: buildroot@uclibc.org From: Chris LaRocque Date: Thu, 24 Dec 2015 07:44:03 -0500 Lines: 1428 Message-ID: References: <1450890296.2355509.475056490.71128E4E@webmail.messagingengine.com> <20151223184751.12365336@free-electrons.com> <1450893821.3034067.475093450.34890777@webmail.messagingengine.com> <1450894505.3036056.475106194.467AC874@webmail.messagingengine.com> <20151223193943.21a6f0fc@free-electrons.com> <1450910736.3752716.475291418.490BB3EA@webmail.messagingengine.com> <20151223235253.0afe702e@free-electrons.com> <1450917779.3775953.475348978.37FAC3A8@webmail.messagingengine.com> Mime-Version: 1.0 X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: pool-173-50-96-7.nrflva.fios.verizon.net User-Agent: KNode/4.10.5 Subject: Re: [Buildroot] trying to use https://github.com/beagleboard/linux.git with buildroot X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Craig Swank wrote: > Here is another thing I've found: > > https://github.com/beagleboard/linux/issues/49 > > In that issue the person had some addresses set incorrectly in uEnv.txt, > but mine doesn't have any addresses set: > > bootpart=0:1 > bootdir= > uenvcmd=run loadimage;run loadramdisk;run findfdt;run loadfdt;run ram > boot > > Is there something that needs to be set in uEnv.txt? > > > On Wed, Dec 23, 2015, at 02:52 PM, Thomas Petazzoni wrote: >> Dear Craig Swank, >> >> On Wed, 23 Dec 2015 14:45:36 -0800, Craig Swank wrote: >> > Is it strange to you that when I do the build the output/build >> > directory has both of these dirs? >> > >> > ➜ buildroot git:(master) ✗ ls output/build/linux-* >> > output/build/linux-4.1.4-ti-r9 >> > output/build/linux-headers-3.12.10 >> >> No, it is perfectly fine. linux-headers is used when building the >> toolchain. linux is used to build the kernel itself. >> >> Thomas >> -- >> Thomas Petazzoni, CTO, Free Electrons >> Embedded Linux, Kernel and Android engineering >> http://free-electrons.com > > Hello Craig I use the beagleboard.org/linux and here's some of my kernel 4.1 config. I have a working build for kernel 3.8 as well if you'd like. # # Kernel Header Options # # BR2_KERNEL_HEADERS_3_2 is not set # BR2_KERNEL_HEADERS_3_4 is not set # BR2_KERNEL_HEADERS_3_10 is not set # BR2_KERNEL_HEADERS_3_12 is not set # BR2_KERNEL_HEADERS_3_14 is not set # BR2_KERNEL_HEADERS_3_18 is not set BR2_KERNEL_HEADERS_4_1=y # BR2_KERNEL_HEADERS_4_2 is not set # BR2_KERNEL_HEADERS_4_3 is not set # BR2_KERNEL_HEADERS_VERSION is not set BR2_DEFAULT_KERNEL_HEADERS="4.1.13" and # Kernel # BR2_LINUX_KERNEL=y # BR2_LINUX_KERNEL_LATEST_VERSION is not set # BR2_LINUX_KERNEL_SAME_AS_HEADERS is not set # BR2_LINUX_KERNEL_CUSTOM_VERSION is not set # BR2_LINUX_KERNEL_CUSTOM_TARBALL is not set BR2_LINUX_KERNEL_CUSTOM_GIT=y # BR2_LINUX_KERNEL_CUSTOM_HG is not set # BR2_LINUX_KERNEL_CUSTOM_LOCAL is not set BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://github.com/beagleboard/linux.git" BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="4.1.13-ti-r36" BR2_LINUX_KERNEL_VERSION="4.1.13-ti-r36" BR2_LINUX_KERNEL_PATCH="" # BR2_LINUX_KERNEL_USE_DEFCONFIG is not set BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="$(TOPDIR)/output/build/linux-4.1.13-ti- r36/arch/arm/configs/bb.org_defconfig" BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="" # BR2_LINUX_KERNEL_UIMAGE is not set # BR2_LINUX_KERNEL_APPENDED_UIMAGE is not set BR2_LINUX_KERNEL_ZIMAGE=y # BR2_LINUX_KERNEL_APPENDED_ZIMAGE is not set # BR2_LINUX_KERNEL_VMLINUX is not set # BR2_LINUX_KERNEL_IMAGE_TARGET_CUSTOM is not set BR2_LINUX_KERNEL_DTS_SUPPORT=y BR2_LINUX_KERNEL_USE_INTREE_DTS=y # BR2_LINUX_KERNEL_USE_CUSTOM_DTS is not set BR2_LINUX_KERNEL_INTREE_DTS_NAME="am335x-bone am335x-boneblack" # BR2_LINUX_KERNEL_INSTALL_TARGET is not set My uEnv.txt bootfile=zImage fdtfile=am335x-boneblack.dtb loadaddr=0x80007fc0 fdtaddr=0x80F80000 loadfdt=fatload mmc 0:1 ${fdtaddr} ${fdtfile} loaduimage=fatload mmc 0:1 ${loadaddr} ${bootfile} console=ttyO0,115200n8 mmcroot=/dev/mmcblk0p2 mmcrootfstype=ext2 uenvcmd=mmc rescan; run loaduimage; run loadfdt; run fdtboot fdtboot=run mmc_args; run mmcargs; bootz ${loadaddr} - ${fdtaddr} mmc_args=setenv bootargs console=${console} ${optargs} root=${mmcroot} rw rootfstype=${mmcrootfstype} rootwait You'll need to patch the host DTC (for the cape manager and cape overlays. Heres my patch (hack) derived from Robert Nelsons bb.org-overlays. set BR2_GLOBAL_PATCH_DIR to a valid path create the folder DTC in BR2_GLOBAL_PATCH_DIR and place the patch file named: host-dtc-1.4.1.patch within... host-dtc-1.4.1.patch ********************************************** dtc_tests () { @@ -399,6 +401,8 @@ tree1_tests dtc_tree1_merge.test.dtb test_tree1.dtb run_dtc_test -I dts -O dtb -o dtc_tree1_merge_labelled.test.dtb test_tree1_merge_labelled.dts tree1_tests dtc_tree1_merge_labelled.test.dtb test_tree1.dtb + run_dtc_test -I dts -O dtb -o dtc_tree1_label_noderef.test.dtb test_tree1_label_noderef.dts + run_test dtbs_equal_unordered dtc_tree1_label_noderef.test.dtb test_tree1.dtb run_dtc_test -I dts -O dtb -o multilabel_merge.test.dtb multilabel_merge.dts run_test references multilabel.test.dtb run_test dtbs_equal_ordered multilabel.test.dtb multilabel_merge.test.dtb @@ -610,6 +614,28 @@ run_wrap_test $DTPUT $dtb -cp /chosen run_wrap_test $DTPUT $dtb -cp /chosen/son + # Start again with a fresh dtb + run_dtc_test -O dtb -p $(stat -c %s $text) -o $dtb $dts + + # Node delete + run_wrap_test $DTPUT $dtb -c /chosen/node1 /chosen/node2 /chosen/node3 + run_fdtget_test "node3\nnode2\nnode1" $dtb -l /chosen + run_wrap_test $DTPUT $dtb -r /chosen/node1 /chosen/node2 + run_fdtget_test "node3" $dtb -l /chosen + + # Delete the non-existent node + run_wrap_error_test $DTPUT $dtb -r /non-existent/node + + # Property delete + run_fdtput_test "eva" $dtb /chosen/ name "" -ts "eva" + run_fdtput_test "016" $dtb /chosen/ age "" -ts "016" + run_fdtget_test "age\nname\nbootargs\nlinux,platform" $dtb -p /chosen + run_wrap_test $DTPUT $dtb -d /chosen/ name age + run_fdtget_test "bootargs\nlinux,platform" $dtb -p /chosen + + # Delete the non-existent property + run_wrap_error_test $DTPUT $dtb -d /chosen non-existent-prop + # TODO: Add tests for verbose mode? } --- a/checks.c 2015-12-10 14:50:21.537561920 -0500 +++ b/checks.c 2015-12-01 17:11:59.266242047 -0500 @@ -458,6 +458,8 @@ struct node *node, struct property *prop) { struct marker *m = prop->val.markers; + struct fixup *f, **fp; + struct fixup_entry *fe, **fep; struct node *refnode; cell_t phandle; @@ -466,14 +468,73 @@ refnode = get_node_by_ref(dt, m->ref); if (! refnode) { + if (!dt->is_plugin) { FAIL(c, "Reference to non-existent node or label \"%s\"\n", m->ref); continue; } + /* allocate fixup entry */ + fe = xmalloc(sizeof(*fe)); + + fe->node = node; + fe->prop = prop; + fe->offset = m->offset; + fe->next = NULL; + + /* search for an already existing fixup */ + for_each_fixup(dt, f) + if (strcmp(f->ref, m->ref) == 0) + break; + + /* no fixup found, add new */ + if (f == NULL) { + f = xmalloc(sizeof(*f)); + f->ref = m->ref; + f->entries = NULL; + f->next = NULL; + + /* add it to the tree */ + fp = &dt->fixups; + while (*fp) + fp = &(*fp)->next; + *fp = f; + } + + /* and now append fixup entry */ + fep = &f->entries; + while (*fep) + fep = &(*fep)->next; + *fep = fe; + + /* mark the entry as unresolved */ + *((cell_t *)(prop->val.val + m->offset)) = + cpu_to_fdt32(0xdeadbeef); + continue; + } + + /* if it's a local reference, we need to record it */ + if (symbol_fixup_support) { + + /* allocate a new local fixup entry */ + fe = xmalloc(sizeof(*fe)); + + fe->node = node; + fe->prop = prop; + fe->offset = m->offset; + fe->next = NULL; + + /* append it to the local fixups */ + fep = &dt->local_fixups; + while (*fep) + fep = &(*fep)->next; + *fep = fe; + } + phandle = get_node_phandle(dt, refnode); *((cell_t *)(prop->val.val + m->offset)) = cpu_to_fdt32(phandle); } + } ERROR(phandle_references, NULL, NULL, fixup_phandle_references, NULL, &duplicate_node_names, &explicit_phandles); @@ -652,6 +713,45 @@ } TREE_WARNING(obsolete_chosen_interrupt_controller, NULL); +static void check_auto_label_phandles(struct check *c, struct node *dt, + struct node *node) +{ + struct label *l; + struct symbol *s, **sp; + int has_label; + + if (!symbol_fixup_support) + return; + + has_label = 0; + for_each_label(node->labels, l) { + has_label = 1; + break; + } + + if (!has_label) + return; + + /* force allocation of a phandle for this node */ + (void)get_node_phandle(dt, node); + + /* add the symbol */ + for_each_label(node->labels, l) { + + s = xmalloc(sizeof(*s)); + s->label = l; + s->node = node; + s->next = NULL; + + /* add it to the symbols list */ + sp = &dt->symbols; + while (*sp) + sp = &((*sp)->next); + *sp = s; + } +} +NODE_WARNING(auto_label_phandles, NULL); + static struct check *check_table[] = { &duplicate_node_names, &duplicate_property_names, &node_name_chars, &node_name_format, &property_name_chars, @@ -670,6 +770,8 @@ &avoid_default_addr_size, &obsolete_chosen_interrupt_controller, + &auto_label_phandles, + &always_fail, }; --- a/Documentation/dt-object-internal.txt 1969-12-31 19:00:00.000000000 -0500 +++ b/Documentation/dt-object-internal.txt 2015-12-01 17:11:59.249242025 -0500 @@ -0,0 +1,301 @@ +Device Tree Dynamic Object format internals +------------------------------------------- + +The Device Tree for most platforms is a static representation of +the hardware capabilities. This is insufficient for many platforms +that need to dynamically insert device tree fragments to the +running kernel's live tree. + +This document explains the the device tree object format and the +modifications made to the device tree compiler, which make it possible. + +1. Simplified Problem Definition +-------------------------------- + +Assume we have a platform which boots using following simplified device tree. + +---- foo.dts ----------------------------------------------------------------- + /* FOO platform */ + / { + compatible = "corp,foo"; + + /* shared resources */ + res: res { + }; + + /* On chip peripherals */ + ocp: ocp { + /* peripherals that are always instantiated */ + peripheral1 { ... }; + } + }; +---- foo.dts ----------------------------------------------------------------- + +We have a number of peripherals that after probing (using some undefined method) +should result in different device tree configuration. + +We cannot boot with this static tree because due to the configuration of the +foo platform there exist multiple conficting peripherals DT fragments. + +So for the bar peripheral we would have this: + +---- foo+bar.dts ------------------------------------------------------------- + /* FOO platform + bar peripheral */ + / { + compatible = "corp,foo"; + + /* shared resources */ + res: res { + }; + + /* On chip peripherals */ + ocp: ocp { + /* peripherals that are always instantiated */ + peripheral1 { ... }; + + /* bar peripheral */ + bar { + compatible = "corp,bar"; + ... /* various properties and child nodes */ + } + } + }; +---- foo+bar.dts ------------------------------------------------------------- + +While for the baz peripheral we would have this: + +---- foo+baz.dts ------------------------------------------------------------- + /* FOO platform + baz peripheral */ + / { + compatible = "corp,foo"; + + /* shared resources */ + res: res { + /* baz resources */ + baz_res: res_baz { ... }; + }; + + /* On chip peripherals */ + ocp: ocp { + /* peripherals that are always instantiated */ + peripheral1 { ... }; + + /* baz peripheral */ + baz { + compatible = "corp,baz"; + /* reference to another point in the tree */ + ref-to-res = <&baz_res>; + ... /* various properties and child nodes */ + } + } + }; +---- foo+baz.dts ------------------------------------------------------------- + +We note that the baz case is more complicated, since the baz peripheral needs to +reference another node in the DT tree. + +2. Device Tree Object Format Requirements +----------------------------------------- + +Since the device tree is used for booting a number of very different hardware +platforms it is imperative that we tread very carefully. + +2.a) No changes to the Device Tree binary format. We cannot modify the tree +format at all and all the information we require should be encoded using device +tree itself. We can add nodes that can be safely ignored by both bootloaders and +the kernel. + +2.b) Changes to the DTS source format should be absolutely minimal, and should +only be needed for the DT fragment definitions, and not the base boot DT. + +2.c) An explicit option should be used to instruct DTC to generate the required +information needed for object resolution. Platforms that don't use the +dynamic object format can safely ignore it. + +2.d) Finally, DT syntax changes should be kept to a minimum. It should be +possible to express everything using the existing DT syntax. + +3. Implementation +----------------- + +The basic unit of addressing in Device Tree is the phandle. Turns out it's +relatively simple to extend the way phandles are generated and referenced +so that it's possible to dynamically convert symbolic references (labels) +to phandle values. + +We can roughly divide the operation into two steps. + +3.a) Compilation of the base board DTS file using the '-@' option +generates a valid DT blob with an added __symbols__ node at the root node, +containing a list of all nodes that are marked with a label. + +Using the foo.dts file above the following node will be generated; + +$ dtc -@ -O dtb -o foo.dtb -b 0 foo.dts +$ fdtdump foo.dtb +... +/ { + ... + res { + ... + linux,phandle = <0x00000001>; + phandle = <0x00000001>; + ... + }; + ocp { + ... + linux,phandle = <0x00000002>; + phandle = <0x00000002>; + ... + }; + __symbols__ { + res="/res"; + ocp="/ocp"; + }; +}; + +Notice that all the nodes that had a label have been recorded, and that +phandles have been generated for them. + +This blob can be used to boot the board normally, the __symbols__ node will +be safely ignored both by the bootloader and the kernel (the only loss will +be a few bytes of memory and disk space). + +3.b) The Device Tree fragments must be compiled with the same option but they +must also have a tag (/plugin/) that allows undefined references to labels +that are not present at compilation time to be recorded so that the runtime +loader can fix them. + +So the bar peripheral's DTS format would be of the form: + +/plugin/; /* allow undefined label references and record them */ +/ { + .... /* various properties for loader use; i.e. part id etc. */ + fragment@0 { + target = <&ocp>; + __overlay__ { + /* bar peripheral */ + bar { + compatible = "corp,bar"; + ... /* various properties and child nodes */ + } + }; + }; +}; + +Note that there's a target property that specifies the location where the +contents of the overlay node will be placed, and it references the label +in the foo.dts file. + +$ dtc -@ -O dtb -o bar.dtbo -b 0 bar.dts +$ fdtdump bar.dtbo +... +/ { + ... /* properties */ + fragment@0 { + target = <0xdeadbeef>; + __overlay__ { + bar { + compatible = "corp,bar"; + ... /* various properties and child nodes */ + } + }; + }; + __fixups__ { + ocp = "/fragment@0:target:0"; + }; +}; + +No __symbols__ has been generated (no label in bar.dts). +Note that the target's ocp label is undefined, so the phandle handle +value is filled with the illegal value '0xdeadbeef', while a __fixups__ +node has been generated, which marks the location in the tree where +the label lookup should store the runtime phandle value of the ocp node. + +The format of the __fixups__ node entry is + +