Skip to content

Need help with Device Tree #381

Closed
Closed

Description

@notro

I'm trying to get Device Tree working, but has failed in my attempts so far.
I have seen that it's reported working with U-boot, but I'm distributing my kernel with rpi-update, so I would like this to work without U-boot. Is it even possible?
I tried adding all config.txt parameters from https://github.com/raspberrypi/linux/wiki/How-to-boot-using-device-tree, but then it wouldn't boot. So I only use the device_tree* parameters.

I'm using the next firmware with the rpi-3.10.y branch from raspberrypi/linux and use the device tree test data.

Added to kernel config

Boot options  --->
  [*] Flattened Device Tree support

Device Drivers  --->  Device Tree and Open Firmware support  --->
  [*] Support for device tree in /proc
  [*] Device Tree Runtime self tests

bcm2708.dts

/dts-v1/;
/include/ "testcases/tests.dtsi"

Compile device tree

./linux/scripts/dtc/dtc linux/arch/arm/boot/dts/bcm2708.dts -O dtb -o bcm2708.dtb

Added to /boot/config.txt

device_tree=bcm2708.dtb
device_tree_address=0x100

Kernel boot messages

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Initializing cgroup subsys cpuacct
[    0.000000] Linux version 3.10.12+ (pi@raspi1) (gcc version 4.7.1 20120402 (prerelease) (crosstool-NG 1.15.2) ) #1 Fri Sep 20 22:51:32 CEST 2013
[    0.000000] CPU: ARMv6-compatible processor [410fb767] revision 7 (ARMv7), cr=00c5387d
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
[    0.000000] Machine: BCM2708
[    0.000000] cma: CMA: reserved 16 MiB at 1b000000
[    0.000000] Memory policy: ECC disabled, Data cache writeback
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 113792
[    0.000000] Kernel command line: dma.dmachans=0x7f35 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2708.boardrev=0xe bcm2708.serial=0x4939788f smsc95xx.macaddr=B8:27:EB:39:78:8F sdhci-bcm2708.emmc_clock_freq=100000000 vc_mem.mem_base=0x1ec00000 vc_mem.mem_size=0x20000000  dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
[    0.000000] PID hash table entries: 2048 (order: 1, 8192 bytes)
[    0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
[    0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
[    0.000000] Memory: 448MB = 448MB total
[    0.000000] Memory: 430684k/430684k available, 28068k reserved, 0K highmem
[    0.000000] Virtual kernel memory layout:
[    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
[    0.000000]     fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
[    0.000000]     vmalloc : 0xdc800000 - 0xff000000   ( 552 MB)
[    0.000000]     lowmem  : 0xc0000000 - 0xdc000000   ( 448 MB)
[    0.000000]     modules : 0xbf000000 - 0xc0000000   (  16 MB)
[    0.000000]       .text : 0xc0008000 - 0xc0614cf4   (6196 kB)
[    0.000000]       .init : 0xc0615000 - 0xc0659aa0   ( 275 kB)
[    0.000000]       .data : 0xc065a000 - 0xc069d968   ( 271 kB)
[    0.000000]        .bss : 0xc069d968 - 0xc076e968   ( 836 kB)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1


[    2.558239] ### dt-test ### No testcase data in device tree; not running tests

Nothing in proc

pi@raspberrypi:~$ ls -l /proc/device-tree/
total 0

Why?
I want to use Device Tree to configure some framebuffer drivers I'm working on, not the base drivers.

Framebuffer drivers: https://github.com/notro/fbtft
rpi-update distributed kernel: https://github.com/notro/rpi-firmware

Activity

  1. popcornmix commented on Sep 21, 2013

    @popcornmix
    Collaborator

    Read:
    #24
    first. As far as I know, the firmware populating the device tree was largely working, but there is probably a bug remaining. If you can dump the device tree recieved by the kernel and spot any discrepancies then I expect I can fix the firmware.

  2. notro commented on Sep 23, 2013

    @notro
    ContributorAuthor

    I have tested three scenarios:

    Firmware boot without disable_commandline_tags
    The kernel boots, but the Device Tree test case is not found.
    The kernel command line does not reflect the one in bcm2708.dtb
    Nothing in /proc/device-tree

    Firmware boot with disable_commandline_tags=1
    Nothing happens

    U-boot
    Device Tree tests is passed
    /proc/device-tree is populated

    Am I doing something wrong in the Firmware boot case?

    I also tried setting config.txt: device_tree= to a nonextisting file, but no error message.

    Additional kernel config changes

    Kernel hacking  ---> 
        [*] Kernel low-level debugging functions (read help!)
            Kernel low-level debugging port (Broadcom BCM2708 UART0 (PL011))  --->
                (X) Broadcom BCM2708 UART0 (PL011)
        [*] Early printk
    

    Kernel source changes

    I got this error (using U-boot) before changing arch/arm/mach-bcm2708/bcm2708.c:

    Starting kernel ...
    
    Uncompressing Linux... done, booting the kernel.
    
    Error: unrecognized/unsupported device tree compatible list:
    [ 'brcm,bcm2708' ]
    
    Available machine support:
    
    ID (hex)        NAME
    00000c42        BCM2708
    
    Please check your kernel config and/or bootloader.
    

    arch/arm/mach-bcm2708/bcm2708.c

    diff --git a/arch/arm/mach-bcm2708/bcm2708.c b/arch/arm/mach-bcm2708/bcm2708.c
    index 5662c1a..40d7ef1 100644
    --- a/arch/arm/mach-bcm2708/bcm2708.c
    +++ b/arch/arm/mach-bcm2708/bcm2708.c
    @@ -900,6 +903,11 @@ static void __init board_reserve(void)
     #endif
     }
    
    +static const char * const bcm2708_compat[] = {
    +       "brcm,bcm2708",
    +       NULL
    +};
    +
     MACHINE_START(BCM2708, "BCM2708")
         /* Maintainer: Broadcom Europe Ltd. */
            .map_io = bcm2708_map_io,
    @@ -909,6 +917,7 @@ MACHINE_START(BCM2708, "BCM2708")
            .init_early = bcm2708_init_early,
            .reserve = board_reserve,
            .restart        = bcm2708_restart,
    +       .dt_compat = bcm2708_compat,
     MACHINE_END
    
     module_param(boardrev, uint, 0644);
    

    arch/arm/boot/dts/bcm2708.dts

    /dts-v1/;
    /include/ "bcm2835.dtsi"
    
    / {
        compatible = "brcm,bcm2708";
        model = "BCM2708";
    
        memory {
            reg = <0 0x10000000>;
        };
    
        chosen {
            bootargs = "earlyprintk loglevel=8 dma.dmachans=0x7f35 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2708.boardrev=0xe bcm2708.serial=0x4939788f smsc95xx.macaddr=B8:27:EB:39:78:8F sdhci-bcm2708.emmc_clock_freq=100000000 vc_mem.mem_base=0x1ec00000 vc_mem.mem_size=0x20000000  dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait";
        };
    
        soc {
        };
    };
    
    /include/ "testcases/tests.dtsi"
    

    Fimware boot without disable_commandline_tags

    /boot/config.txt

    device_tree=bcm2708.dtb
    #disable_commandline_tags=1
    

    Kernel messages

    [    0.000000] Booting Linux on physical CPU 0x0
    [    0.000000] Initializing cgroup subsys cpu
    [    0.000000] Initializing cgroup subsys cpuacct
    [    0.000000] Linux version 3.10.12+ (pi@raspi1) (gcc version 4.7.1 20120402 (prerelease) (crosstool-NG 1.15.2) ) #3 Mon Sep 23 19:44:32 CEST 2013
    [    0.000000] CPU: ARMv6-compatible processor [410fb767] revision 7 (ARMv7), cr=00c5387d
    [    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
    [    0.000000] Machine: BCM2708
    [    0.000000] cma: CMA: reserved 16 MiB at 1b000000
    [    0.000000] Memory policy: ECC disabled, Data cache writeback
    [    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 113792
    [    0.000000] Kernel command line: dma.dmachans=0x7f35 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2708.boardrev=0xe bcm2708.serial=0x4939788f smsc95xx.macaddr=B8:27:EB:39:78:8F sdhci-bcm2708.emmc_clock_freq=100000000 vc_mem.mem_base=0x1ec00000 vc_mem.mem_size=0x20000000  dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
    
    
    [    2.567583] ### dt-test ### No testcase data in device tree; not running tests
    
    øø
    Debian GNU/Linux 7 raspberrypi ttyAMA0
    
    raspberrypi login:
    
    

    /proc/device-tree

    pi@raspberrypi:~$ ls -l /proc/device-tree/
    total 0
    

    Fimware boot with disable_commandline_tags=1

    /boot/config.txt

    device_tree=bcm2708.dtb
    disable_commandline_tags=1
    

    Kernel messages

    nothing happens
    

    U-boot

    Built from git.denx.de/u-boot-arm.git

    
    U-Boot 2013.10-rc2-15890-gad31ff6 (Sep 22 2013 - 15:12:08)
    
    DRAM:  448 MiB
    WARNING: Caches not enabled
    MMC:   bcm2835_sdhci: 0
    Using default environment
    
    In:    serial
    Out:   lcd
    Err:   lcd
    Hit any key to stop autoboot:  0
    mmc0 is current device
    reading boot.scr.uimg
    ** Unable to read file boot.scr.uimg **
    
    U-Boot> fatload ${devtype} ${devnum}:1 ${kernel_addr_r} /uImage.img
    reading /uImage.img
    3301280 bytes read in 524 ms (6 MiB/s)
    
    U-Boot> fatload ${devtype} ${devnum}:1 ${fdt_addr_r} /bcm2708.dtb
    reading /bcm2708.dtb
    3411 bytes read in 14 ms (237.3 KiB/s)
    
    U-Boot> bootm ${kernel_addr_r} - ${fdt_addr_r}
    ## Booting kernel from Legacy Image at 01000000 ...
       Image Name:   Linux-3.10.12+
       Image Type:   ARM Linux Kernel Image (uncompressed)
       Data Size:    3301216 Bytes = 3.1 MiB
       Load Address: 00008000
       Entry Point:  00008000
       Verifying Checksum ... OK
    ## Flattened Device Tree blob at 02000000
       Booting using the fdt blob at 0x2000000
       Loading Kernel Image ... OK
       Loading Device Tree to 1bb8a000, end 1bb8dd52 ... OK
    
    Starting kernel ...
    
    Uncompressing Linux... done, booting the kernel.
    [    0.000000] Booting Linux on physical CPU 0x0
    [    0.000000] Initializing cgroup subsys cpu
    [    0.000000] Initializing cgroup subsys cpuacct
    [    0.000000] Linux version 3.10.12+ (pi@raspi1) (gcc version 4.7.1 20120402 (prerelease) (crosstool-NG 1.15.2) ) #3 Mon Sep 23 19:44:32 CEST 2013
    [    0.000000] CPU: ARMv6-compatible processor [410fb767] revision 7 (ARMv7), cr=00c5387d
    [    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
    [    0.000000] Machine: BCM2708, model: BCM2708
    [    0.000000] bootconsole [earlycon0] enabled
    [    0.000000] cma: CMA: reserved 16 MiB at 1a800000
    [    0.000000] Memory policy: ECC disabled, Data cache writeback
    [    0.000000] On node 0 totalpages: 114688
    [    0.000000] free_area_init_node: node 0, pgdat c069af8c, node_mem_map c0771000
    [    0.000000]   Normal zone: 896 pages used for memmap
    [    0.000000]   Normal zone: 0 pages reserved
    [    0.000000]   Normal zone: 114688 pages, LIFO batch:31
    [    0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
    [    0.000000] pcpu-alloc: [0] 0
    [    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 113792
    [    0.000000] Kernel command line: earlyprintk loglevel=8 dma.dmachans=0x7f35 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2708.boardrev=0xe bcm2708.serial=0x4939788f smsc95xx.macaddr=B8:27:EB:39:78:8F sdhci-bcm2708.emmc_clock_freq=100000000 vc_mem.mem_base=0x1ec00000 vc_mem.mem_size=0x20000000  dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
    [    0.000000] PID hash table entries: 2048 (order: 1, 8192 bytes)
    [    0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
    [    0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
    [    0.000000] Memory: 448MB = 448MB total
    [    0.000000] Memory: 430668k/430668k available, 28084k reserved, 0K highmem
    [    0.000000] Virtual kernel memory layout:
    [    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    [    0.000000]     fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
    [    0.000000]     vmalloc : 0xdc800000 - 0xff000000   ( 552 MB)
    [    0.000000]     lowmem  : 0xc0000000 - 0xdc000000   ( 448 MB)
    [    0.000000]     modules : 0xbf000000 - 0xc0000000   (  16 MB)
    [    0.000000]       .text : 0xc0008000 - 0xc0616d5c   (6204 kB)
    [    0.000000]       .init : 0xc0617000 - 0xc065bbac   ( 275 kB)
    [    0.000000]       .data : 0xc065c000 - 0xc069f988   ( 271 kB)
    [    0.000000]        .bss : 0xc069f988 - 0xc0770988   ( 836 kB)
    [    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
    [    0.000000] NR_IRQS:330
    [    0.000000] sched_clock: 32 bits at 1000kHz, resolution 1000ns, wraps every 4294967ms
    [    0.000000] Switching to timer-based delay loop
    [    0.000000] Console: colour dummy device 80x30
    [    0.000000] console [tty1] enabled, bootconsole disabled
    [    0.000000] Booting Linux on physical CPU 0x0
    [    0.000000] Initializing cgroup subsys cpu
    [    0.000000] Initializing cgroup subsys cpuacct
    [    0.000000] Linux version 3.10.12+ (pi@raspi1) (gcc version 4.7.1 20120402 (prerelease) (crosstool-NG 1.15.2) ) #3 Mon Sep 23 19:44:32 CEST 2013
    [    0.000000] CPU: ARMv6-compatible processor [410fb767] revision 7 (ARMv7), cr=00c5387d
    [    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
    [    0.000000] Machine: BCM2708, model: BCM2708
    [    0.000000] bootconsole [earlycon0] enabled
    [    0.000000] cma: CMA: reserved 16 MiB at 1a800000
    [    0.000000] Memory policy: ECC disabled, Data cache writeback
    [    0.000000] On node 0 totalpages: 114688
    [    0.000000] free_area_init_node: node 0, pgdat c069af8c, node_mem_map c0771000
    [    0.000000]   Normal zone: 896 pages used for memmap
    [    0.000000]   Normal zone: 0 pages reserved
    [    0.000000]   Normal zone: 114688 pages, LIFO batch:31
    [    0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
    [    0.000000] pcpu-alloc: [0] 0
    [    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 113792
    [    0.000000] Kernel command line: earlyprintk loglevel=8 dma.dmachans=0x7f35 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2708.boardrev=0xe bcm2708.serial=0x4939788f smsc95xx.macaddr=B8:27:EB:39:78:8F sdhci-bcm2708.emmc_clock_freq=100000000 vc_mem.mem_base=0x1ec00000 vc_mem.mem_size=0x20000000  dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
    
    
    [    2.654689] ### dt-test ### start of selftest - you will see error messages
    [    2.663315] ### dt-test ### pass drivers/of/selftest.c:40
    [    2.670273] ### dt-test ### pass drivers/of/selftest.c:93
    [    2.677175] ### dt-test ### pass drivers/of/selftest.c:93
    [    2.684015] ### dt-test ### pass drivers/of/selftest.c:93
    [    2.690753] ### dt-test ### pass drivers/of/selftest.c:93
    [    2.697457] ### dt-test ### pass drivers/of/selftest.c:93
    [    2.704124] ### dt-test ### pass drivers/of/selftest.c:93
    [    2.710688] ### dt-test ### pass drivers/of/selftest.c:93
    [    2.717214] ### dt-test ### pass drivers/of/selftest.c:93
    [    2.723694] ### dt-test ### pass drivers/of/selftest.c:99
    [    2.730083] ### dt-test ### pass drivers/of/selftest.c:102
    [    2.736548] /testcase-data/phandle-tests/consumer-a: could not get #phandle-cells-missing for /testcase-data/phandle-tests/provider1
    [    2.750460] ### dt-test ### pass drivers/of/selftest.c:107
    [    2.757026] /testcase-data/phandle-tests/consumer-a: could not get #phandle-cells-missing for /testcase-data/phandle-tests/provider1
    [    2.771091] ### dt-test ### pass drivers/of/selftest.c:110
    [    2.777603] /testcase-data/phandle-tests/consumer-a: could not find phandle
    [    2.785657] ### dt-test ### pass drivers/of/selftest.c:115
    [    2.792230] /testcase-data/phandle-tests/consumer-a: could not find phandle
    [    2.800264] ### dt-test ### pass drivers/of/selftest.c:118
    [    2.806856] /testcase-data/phandle-tests/consumer-a: arguments longer than property
    [    2.816840] ### dt-test ### pass drivers/of/selftest.c:123
    [    2.823648] /testcase-data/phandle-tests/consumer-a: arguments longer than property
    [    2.834053] ### dt-test ### pass drivers/of/selftest.c:126
    [    2.841082] ### dt-test ### start
    [    2.845917] ### dt-test ### pass drivers/of/selftest.c:142
    [    2.852990] ### dt-test ### pass drivers/of/selftest.c:144
    [    2.860031] ### dt-test ### pass drivers/of/selftest.c:146
    [    2.867089] ### dt-test ### pass drivers/of/selftest.c:148
    [    2.874098] ### dt-test ### pass drivers/of/selftest.c:150
    [    2.881063] ### dt-test ### pass drivers/of/selftest.c:152
    [    2.887933] ### dt-test ### pass drivers/of/selftest.c:154
    [    2.894747] ### dt-test ### end of selftest - PASS
    
    
    [   10.255991] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
    [   10.634122] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
    øø
    Debian GNU/Linux 7 raspberrypi ttyAMA0
    
    raspberrypi login:
    
    

    /proc/device-tree

    pi@raspberrypi:~$ ls -l /proc/device-tree/
    total 0
    -r--r--r--  1 root root  4 Sep 23 19:19 #address-cells
    dr-xr-xr-x  2 root root  0 Sep 23 19:19 aliases
    dr-xr-xr-x  2 root root  0 Sep 23 19:19 chosen
    dr-xr-xr-x  5 root root  0 Sep 23 19:19 clocks
    -r--r--r--  1 root root 13 Sep 23 19:19 compatible
    dr-xr-xr-x  2 root root  0 Sep 23 19:19 framebuffer
    -r--r--r--  1 root root  4 Sep 23 19:19 interrupt-parent
    dr-xr-xr-x  2 root root  0 Sep 23 19:19 memory
    -r--r--r--  1 root root  8 Sep 23 19:19 model
    -r--r--r--  1 root root  1 Sep 23 19:19 name
    -r--r--r--  1 root root  4 Sep 23 19:19 #size-cells
    dr-xr-xr-x 12 root root  0 Sep 23 19:19 soc
    dr-xr-xr-x  3 root root  0 Sep 23 19:19 testcase-data
    
  3. popcornmix commented on Sep 23, 2013

    @popcornmix
    Collaborator

    You want these settings:

    device_tree=bcm2835.dtb
    device_tree_address=0x100
    kernel_address=0x8000
    disable_commandline_tags=1
    

    Do you have a uart attached?
    With these settings and a stock kernel, I can see uart output.
    It's not very happy due to the mising atags/command line but it shows the kernel is booting with disable_commandline_tags enabled.

    http://pastebin.com/Bi28A5jw

  4. P33M commented on Sep 23, 2013

    @P33M
    Contributor

    I'm going to interject a bit here:

    If you have a multi-platform enabled kernel, it will always panic because the machine ID passed in r1 is the 2708 machine ID. Multi-platform relies on the correct device tree being passed in r2 by the bootloader, thus the kernel expects the machine ID to be 0xFFFFFFFF if a specific arch hasn't been compiled in.

    For reference: http://lwn.net/Articles/496400/

    (I think the 2835 mainline port has actually been converted to multi-platform, therefore won't boot unless you use U-boot)

  5. popcornmix commented on Sep 24, 2013

    @popcornmix
    Collaborator

    So would a config.txt option (e.g. linux_machine_id=0xffffffff) be useful (it will find it's way into r2 on kernel boot).

  6. notro commented on Sep 24, 2013

    @notro
    ContributorAuthor

    I haven't been able to replicate what you did. Which kernel is the 'stock kernel' ?

    I have tested raspberrypi/linux:3.10.y and torvalds/linux.

    Image: 2013-09-10-wheezy-raspbian

    config.txt

    device_tree=bcm2835-rpi-b.dtb
    device_tree_address=0x100
    kernel_address=0x8000
    disable_commandline_tags=1
    

    Added to arch/arm/boot/dts/bcm2835-rpi-b.dts

        chosen {
            bootargs = "dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait";
        };
    

    Build

    make mrproper
    make bcm2835_defconfig
    make -j4
    

    Copy:
    arch/arm/boot/Image -> /boot/kernel.img
    arch/arm/boot/dts/bcm2835-rpi-b.dtb -> /boot/bcm2835-rpi-b.dtb

    raspberrypi/linux 3.10.y

    [    0.000000] Linux version 3.10.12+ (pi@raspi1) (gcc version 4.7.1 20120402 (prerelease) (crosstool-NG 1.15.2) ) #1 Tue Sep 24 09:27:00 CEST 2013
    [    0.000000] CPU: ARMv6-compatible processor [410fb767] revision 7 (ARMv7), cr=00c5387d
    [    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
    [    0.000000] Machine: BCM2835, model: Raspberry Pi Model B
    
    [    0.706014] VFP support v0.3: implementor 41 architecture 1 part 20 variant b rev 5
    ø[    0.715692] Waiting for root device /dev/mmcblk0p2...
    [    0.756968] mmc0: new SDHC card at address e624
    [    0.762077] mmcblk0: mmc0:e624 SU16G 14.8 GiB
    [    0.769401]  mmcblk0: p1 p2
    [   10.837267] mmc0: Timeout waiting for hardware interrupt - cmd18.
    [   10.843613] mmcblk0: error -110 sending stop command, original cmd response 0x900, card status 0x900
    [   10.852787] mmcblk0: error -110 transferring data, sector 122882, nr 2, cmd response 0x900, card status 0x0
    [   10.862551] mmcblk0: retrying using single block read
    [   20.877265] mmc0: Timeout waiting for hardware interrupt - cmd18.
    [   30.897265] mmc0: Timeout waiting for hardware interrupt - cmd12.
    [   40.917279] mmc0: Timeout waiting for hardware interrupt - cmd13.
    [   40.923507] mmcblk0: error -110 sending status command, retrying
    [   50.957278] mmc0: Timeout waiting for hardware interrupt - cmd13.
    [   50.963500] mmcblk0: error -110 sending status command, retrying
    

    https://gist.github.com/notro/6687398

    torvalds/linux

    [    0.000000] Linux version 3.12.0-rc1 (pi@raspi1) (gcc version 4.7.1 20120402 (prerelease) (crosstool-NG 1.15.2) ) #2 Tue Sep 24 00:46:31 CEST 2013
    [    0.000000] CPU: ARMv6-compatible processor [410fb767] revision 7 (ARMv7), cr=00c5387d
    [    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
    [    0.000000] Machine: BCM2835, model: Raspberry Pi Model B
    
    [info] Skipping font and keymap setup (handled by console-setup).
    [ ok ] Setting up console font and keymap...done.
    [ ok ] Setting up X socket directories... /tmp/.X11-unix /tmp/.ICE-unix.
    INIT: PANIC: segmentation violation! sleeping for 30 seconds.
    INIT: PANIC: segmentation violation! sleeping for 30 seconds.
    

    https://gist.github.com/notro/6687345

  7. P33M commented on Sep 24, 2013

    @P33M
    Contributor

    @popcornmix

    It would be useful in the long term for "generic" multiarch kernels to boot on the Pi. Basically a kernel compiled for an ARM1176 / ARMv6 processor (and had necessary device drivers built-in) would run on anything that provided it with a device tree with enough compatible devices. r1 needs to be 0xfffffff in these cases, indicating that the bootloader has passed through a devicetree describing the machine, rather than r1 being one of the set-in-stone machine IDs.

    In the short term, it would allow for building multiarch kernels with a pi-specific DTB appended to the kernel zImage. This is useful for getting the dtb correct in the first place before pushing it across to videocore which (in theory) can then magically determine if we are running on a model A / B / rev1 / rev2 and pass the necessary stuff across (ram size in particular).

    r2 still ends up as a pointer to ATAGS, but the kernel basically ignores ATAGS if a device tree tag is present.

  8. popcornmix commented on Sep 24, 2013

    @popcornmix
    Collaborator

    My kernel is from "sudo BRANCH=next rpi-update".
    It is a non-device tree kernel. I've never attempted to run with bcm2835_defconfig.

    I was just suggesting that the there is enough life in the kernel boot with the device tree config.txt options to get some debug infomation out (e.g. with printk through uart).

    If you can perhaps dump the raw binary device tree data when booting from uboot and when booting direct, we might see where the problem is.

  9. notro commented on Sep 25, 2013

    @notro
    ContributorAuthor

    With a Device Tree enabled kernel and disable_commandline_tags=1 (and the other lines), I get nothing on the console after reset.
    Removing that line, it boots fine using atags.
    Booting with U-boot and Device Tree works fine.

    Since not even Booting Linux on physical CPU 0 is displayed, the problem seems to be before start_kernel() is called, since a non Device Tree kernel boots with disable_commandline_tags=1.
    I don't know assembly, so I'm lost here.

    config.txt

    device_tree=bcm2835-rpi-b.dtb
    device_tree_address=0x100
    kernel_address=0x8000
    disable_commandline_tags=1
    

    Relevant source code snippets

    arch/arm/kernel/head-common.S

    /*
     * The following fragment of code is executed with the MMU on in MMU mode,
     * and uses absolute addresses; this is not position independent.
     *
     *  r0  = cp#15 control register
     *  r1  = machine ID
     *  r2  = atags/dtb pointer
     *  r9  = processor ID
     */
    [...]
    
        b       start_kernel
    [...]
        .long   __atags_pointer                 @ r6
    [...]
    

    source/init/main.c

    asmlinkage void __init start_kernel(void)
    {
        char * command_line;
        extern const struct kernel_param __start___param[], __stop___param[];
    
        /*
         * Need to run as early as possible, to initialize the
         * lockdep hash:
         */
        lockdep_init();
        smp_setup_processor_id();
    [...]
        setup_arch(&command_line);
    [...]
    }
    

    arch/arm/kernel/setup.c

    void __init smp_setup_processor_id(void)
    {
    [...]
        printk(KERN_INFO "Booting Linux on physical CPU 0x%x\n", mpidr);
    }
    

    arch/arm/kernel/setup.c

    void __init setup_arch(char **cmdline_p)
    {
    
        struct machine_desc *mdesc;
    
        setup_processor();
        mdesc = setup_machine_fdt(__atags_pointer);
        if (!mdesc)
            mdesc = setup_machine_tags(__atags_pointer, __machine_arch_type);
    [...]
    }
    

    arch/arm/kernel/devtree.c

    /**
     * setup_machine_fdt - Machine setup when an dtb was passed to the kernel
     * @dt_phys: physical address of dt blob
     *
     * If a dtb was passed to the kernel in r2, then use it to choose the
     * correct machine_desc and to setup the system.
     */
    struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys)
    {
        struct boot_param_header *devtree;
    [...]
        if (!dt_phys)
            return NULL;
    
        devtree = phys_to_virt(dt_phys);
    
        /* check device tree validity */
        if (be32_to_cpu(devtree->magic) != OF_DT_HEADER)
            return NULL;
    [...]
        pr_info("Machine: %s, model: %s\n", mdesc_best->name, model);
    [...]
    }
    

    arch/arm/kernel/atags_parse.c

    struct machine_desc * __init setup_machine_tags(phys_addr_t __atags_pointer,
                                                    unsigned int machine_nr)
    {
    [...]
        for_each_machine_desc(p)
            if (machine_nr == p->nr) {
                printk("Machine: %s\n", p->name);
                mdesc = p;
                break;
            }
    [...]
    }
    

    Sidenote:
    It is possible to see in the kernel messages whether the kernel detects a Device Tree or not.
    When a Device Tree is detected, it also prints out model.

    setup_machine_fdt()

    pr_info("Machine: %s, model: %s\n", mdesc_best->name, model);
    

    setup_machine_tags()

    printk("Machine: %s\n", p->name);
    
  10. P33M commented on Sep 25, 2013

    @P33M
    Contributor

    If you have early_printk, then the first set of console messages will be printed to the serial console ONLY. Are you connected to the gpio uart?

  11. notro commented on Sep 25, 2013

    @notro
    ContributorAuthor

    Yes, I have a serial console and CONFIG_EARLY_PRINTK=y.

  12. notro commented on Sep 25, 2013

    @notro
    ContributorAuthor

    I used zImage instead of Image and that gave me

    Uncompressing Linux... done, booting the kernel.
    
  13. notro commented on Sep 26, 2013

    @notro
    ContributorAuthor

    I was wrong in my assumption that start_kernel() wasn't called.
    Using early_print's I can see more.

    I can see that the firmware alters the memory node from 256 to 512MB:
    This is what the .dtb file has:

        memory {
            reg = <0 0x10000000>;
        };
    

    This is what the kernel receives and does:

    data: 0 20 2000000 1000000,
    early_init_dt_add_memory_arch(base=0x0, size=0x20000000)
    

    Anything in particular I should look into ?

    Uncompressing Linux... done, booting the kernel.
    start_kernel()
    setup_machine_fdt(dt_phys=0x100)
        Machine: BCM2708, model: Raspberry Pi Model B
    early_init_dt_scan_chosen()
        search "chosen", depth: 0, uname:
    early_init_dt_scan_chosen()
        search "chosen", depth: 1, uname: chosen
        Command line is: dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
        early_init_dt_scan_chosen returned 1
    early_init_dt_scan_root()
        dt_root_size_cells = 1
        dt_root_addr_cells = 1
        early_init_dt_scan_root returned 1
    early_init_dt_scan_memory()
    early_init_dt_scan_memory()
    early_init_dt_scan_memory()
    early_init_dt_scan_memory()
        memory scan node memory, reg size 8, data: 0 20 2000000 1000000,
    early_init_dt_add_memory_arch(base=0x0, size=0x20000000)
    early_init_dt_scan_memory()
    early_init_dt_scan_memory()
    early_init_dt_scan_memory()
    early_init_dt_scan_memory()
    early_init_dt_scan_memory()
    early_init_dt_scan_memory()
    early_init_dt_scan_memory()
    early_init_dt_scan_memory()
    early_init_dt_scan_memory()
    early_init_dt_scan_memory()
    early_init_dt_scan_memory()
    early_init_dt_scan_memory()
    early_init_dt_scan_memory()
    early_init_dt_scan_memory()
    early_init_dt_scan_memory()
    early_init_dt_scan_memory()
    early_init_dt_scan_memory()
    early_init_dt_scan_memory()
    early_init_dt_scan_memory()
    early_init_dt_scan_memory()
    early_init_dt_scan_memory()
    early_init_dt_scan_memory()
    early_init_dt_scan_memory()
    early_init_dt_scan_memory()
        early_init_dt_scan_memory returned 0
    Kernel command line: dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
    rest_init()
    cpu_startup_entry()
    cpu_idle_loop()
    
    
  14. notro commented on Sep 26, 2013

    @notro
    ContributorAuthor

    I have found a way to make zImage boot. U-boot sets the memory size to 0x1C000000 and the firmware sets it to 0x20000000.
    Forcing size=0x1C000000 in drivers/of/fdt.c, makes zImage boot also.

    Here is a kernel output diff without forcing the size:
    https://gist.github.com/notro/6712488

  15. notro commented on Sep 26, 2013

    @notro
    ContributorAuthor

    By the way, this is zImage memory without DT

    [    0.000000] Memory: 448MB = 448MB total
    [    0.000000] Memory: 430716k/430716k available, 28036k reserved, 0K highmem
    

    compared to U-boot with DT

    [    0.000000] Memory: 448MB = 448MB total
    [    0.000000] Memory: 430708k/430708k available, 28044k reserved, 0K highmem
    
  16. 63 remaining items

  17. notro commented on Feb 26, 2014

    @notro
    ContributorAuthor

    I have a solution to my original problem: How to load devices from Device Tree for some video drivers.

    The solution is a builtin module that can load a Device Tree from /lib/firmware.
    I also have a pinctrl module (copied from pinctrl-bcm2835.c).
    https://github.com/notro/fdt_loader
    https://github.com/notro/fdt_loader/wiki

    I went this route because of all the problems I faced getting full DT support.
    fdt_loader hasn't been tested much yet, as the drivers that will use it is still in the design phase.

    fdt_loader has to be builtin to get DT alias support, since of_alias_scan() is not exported.

  18. cleverca22 commented on Mar 3, 2014

    @cleverca22

    that sounds like it may be one way to solve the MPR121 issues i had

    the driver expects the element->keyboard mapping to be under platform_data, which currently must be compiled into a shim driver that simply says 'this hardware is present on the platform, here is the key mapping'

    basically, exactly what DT is meant to replace
    but the issue i ran into, is that the kernel cant spawn an i2c slave driver without first having the entire i2c bus present in the DT

  19. notro commented on Mar 3, 2014

    @notro
    ContributorAuthor

    You can use i2c-bcm2835.c instead, which has DT support.
    Just hack Kconfig to depend on ARCH_BCM2708 so you can enable it: http://lxr.free-electrons.com/source/drivers/i2c/busses/Kconfig?v=3.10;a=arm#L334

    This patch is probably relevant for your use case: http://lists.infradead.org/pipermail/linux-rpi-kernel/2013-November/000744.html

    Or as I did with spi-bcm2708, add DT support to i2c-bcm2708 and use the fdt_loader argument: remove-pdevs=bcm2708_i2c.0 to remove the device added in arch/arm/mach-bcm2708/bcm2708.c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions