Repository navigation
Description
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
popcornmix commentedon Sep 21, 2013
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.
notro commentedon Sep 23, 2013
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 source changes
I got this error (using U-boot) before changing arch/arm/mach-bcm2708/bcm2708.c:
arch/arm/mach-bcm2708/bcm2708.c
arch/arm/boot/dts/bcm2708.dts
Fimware boot without disable_commandline_tags
/boot/config.txt
Kernel messages
/proc/device-tree
Fimware boot with disable_commandline_tags=1
/boot/config.txt
Kernel messages
U-boot
Built from git.denx.de/u-boot-arm.git
/proc/device-tree
popcornmix commentedon Sep 23, 2013
You want these settings:
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
P33M commentedon Sep 23, 2013
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)
popcornmix commentedon Sep 24, 2013
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).
notro commentedon Sep 24, 2013
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
Added to arch/arm/boot/dts/bcm2835-rpi-b.dts
Build
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
https://gist.github.com/notro/6687398
torvalds/linux
https://gist.github.com/notro/6687345
P33M commentedon Sep 24, 2013
@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.
popcornmix commentedon Sep 24, 2013
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.
notro commentedon Sep 25, 2013
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 0is 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
Relevant source code snippets
arch/arm/kernel/head-common.S
source/init/main.c
arch/arm/kernel/setup.c
arch/arm/kernel/setup.c
arch/arm/kernel/devtree.c
arch/arm/kernel/atags_parse.c
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()
setup_machine_tags()
P33M commentedon Sep 25, 2013
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?
notro commentedon Sep 25, 2013
Yes, I have a serial console and CONFIG_EARLY_PRINTK=y.
notro commentedon Sep 25, 2013
I used zImage instead of Image and that gave me
notro commentedon Sep 26, 2013
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:
This is what the kernel receives and does:
Anything in particular I should look into ?
notro commentedon Sep 26, 2013
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
notro commentedon Sep 26, 2013
By the way, this is zImage memory without DT
compared to U-boot with DT
63 remaining items
notro commentedon Feb 26, 2014
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.
cleverca22 commentedon Mar 3, 2014
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
notro commentedon Mar 3, 2014
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
powerpc/crypto/crc32c-vpmsum: Fix missing preempt_disable()
powerpc/crypto/crc32c-vpmsum: Fix missing preempt_disable()
powerpc/crypto/crc32c-vpmsum: Fix missing preempt_disable()
ALSA: pcm: fix snd_pcm_link() lockdep splat
ALSA: pcm: fix snd_pcm_link() lockdep splat
ALSA: pcm: fix snd_pcm_link() lockdep splat
ALSA: pcm: fix snd_pcm_link() lockdep splat
HID: apple: fix key translations where multiple quirks attempt to tra…
HID: apple: fix key translations where multiple quirks attempt to tra…
CEC service: firmware: only kill interface when the last client has d…
HID: apple: fix key translations where multiple quirks attempt to tra…