-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Device Tree revisited #627
Comments
Device Tree Overlays (2014-05-28) support in mainline is getting closer:
Comment by Grant Likely on the latest patch version:
When this is in, the BeagleBone capemanager patchset will shrink in size/width and maybe we can use it in some form on the DT enabled Pi. |
Okay, I'm interested in this plan. If you want to submit any kernel PRs that bring us closer to supporting DT, and don't break things for non-DT users, then go ahead. I should be able to provide a test start.elf that fills in the DT as desired. |
I wrote ATAG_CMDLINE a couple of places where it should have been chosen/bootargs, sorry about that. I have fixed it. Bootloader
No other bootloader changes are needed at this time. Kernel config Pull Requests Should I make PR's against rpi-3.15.y? |
Yes, I think PR against rpi-3.15.y makes sense. |
Thanks.
Or I can do the testing if the change is trivial. |
The clocks are added in a different way with the Common Clock Framework, so I'm reworking that. Ref: https://github.com/raspberrypi/linux/blob/rpi-3.15.y/arch/arm/mach-bcm2708/bcm2708.c#L208 New clock setup: https://gist.github.com/notro/b3e5ef5e9a51bb21e4ac
|
CONFIG_ARCH_BCM2708_CHIPIT hasn't been used for years, so feel free to remove it. |
I've added to config.txt
and put the linked zImage and bcm2708-rpi-b.dtb in /boot. Would you expect to get any console output or anything on framebuffer? I get nothing. |
Just to note, I've got an intern working on creating suitable drivers that can be upstreamed in such a way that we get here by starting with the upstream kernel and moving our support across rather than add more hackery to support upstream facilities.... Currently he's working on a new mmc driver for the bcm2835 architecture which doesn't then require sdhci hackery to upstream Gordon |
Do you have a timeline for that and does he/she have previous kernel development experience?
This is good news. My brief testing of that driver (sdhci-bcm2835.c) was disappointing. |
@notro |
I'm sorry, I missed that. Sometimes I don't get e-mail alerts in this thread when new messages comes in. I don't have a HDMI monitor, so I tried it (with U-boot) on my sons monitor, and it worked fine. Back on my desk with serial, I added the config.txt changes and booted. I get output, but it crashes before the framebuffer driver is loaded. This is what I get
Instead of
I have to investigate this further. Full console output: https://gist.github.com/notro/376d63def4bab8c1c8b3 |
This is the ATAG_MEM issue. VC
U-boot
|
Okay I was missing "kernel_address=0x8000". Now I get some boot messages (including the Memory line one) and the panic. |
This seems to be the way U-boot gets the RAM size:
|
@popcornmix early_init_dt_scan_memory() looks to be the place where the kernel picks this up: |
And this seem to be the place where U-boot fills in the memory node: The memory node from /proc
|
@notro, what about bcm2835_wdt and bcm2835-rng? |
@kukabu |
@notro My preferred method is the inverse - the upstream mach already has most of the stuff required for a minimally functional system. We have succeeded in getting a mach-bcm2835 kernel to boot directly off Videocore's setup but with the aforementioned memory trampling. Further investigation required as to why this happens in the DT case but not the normal boot mode case. Some modification of the VC bootloader is required to split it into two distinct behaviours - standard ATAGS boot or multiplatform boot (r1=0xFFFFFFFF, no ATAGS, r2= pointer to dtb). Currently, the bootloader does not support adding nodes - something our intern is working on adding. Given the bootloader limitation of not being able to expand a dtb in-memory, all that's required is additional padding (say 4k) and a 1024 char command-line string. Regarding FIQ support - the mach-bcm2835 armctrl IRQchip needs expanding to write to the FIQ select register. FIQ lines in ARM linux are just IRQ numbers >= FIQ_START. Some sort of refcounting would be required to ensure that the FIQ is not enabled from different sources simultaneously - the hardware can only support a single, nominated IRQ line to promote to the FIQ input. |
Yes to some degree. I see this as working the issue on two fronts, to speed things up and maintain stability. This is my current view of the two fronts: BCM2708 If we make a timeschedule for all the drivers, we can make sure we have only one driver change in a certain period of time. This gives us a high level of change control for many of the drivers, in a short period of time. And by doing the low hanging fruit first, we can get some BCM2708 drivers out of the way quite easily. Another benefit is that any new BCM2835 drivers can be used/tested easily, because we have Device Tree support. And we get this with very little change to ARCH_BCM2708. BCM2835 I propose adding a wiki page to this repo that lists all the arch/core drivers and details the status with regards to upstreaming.
Yes, I understand that. That was my first line of work. Another issue is that the implementation of ARCH_BCM2835 (and tegra) has lead to (been part of) the generation of new API's in the kernel. This slows down the process. Disclaimer: I have done kernel development for only 18 months and haven't sent any patches upstream. This is quite new to me.
Has there been any discussion about using U-boot as bootloader? |
My view is that switching from bcm2708 to bcm2835 is going to be a big step that has potential to break a lot of people's set-ups. It seems logical to make some small steps to bring bcm2708 closer to bcm2835, if they can be done in a harmless way (e.g. #630). I think u-boot should be an option, and we should make it as straightforward as possible to use (e.g. document how to build/use u-boot in official documentation). Whether it should be the default option is another question. I'd imagine it adds a little to boot time, adds another file to sdcard, and involves another step in booting that could fail. The benefits are pretty niche. You can already network/usb boot a root filesystem, so the only advantage is if you also want to network/usb boot the kernel (presumably because you are building your own). That's very much a benefit for <1% of users. Here is a firmware file (a test build with 256M/256M memory split). |
I think the biggest benefit of using a bootloader is that a kernel update that introduces breakage can be recovered from without pluging the SD-card into another host but by simply selecting another kernel image... |
I was thinking about building U-boot for the GPU, so it becomes start.elf
I get Not Found when I try to download. |
u-boot has a lot of arm assembly code and hardware drivers (e.g for USB/network) - it would be far from easy to port to the GPU.
Sorry - try now. |
Ok.
I can confirm that, but I had to add the extended kernel parameters to cmdline.txt to get it all the way. |
I have started a wiki page: https://github.com/raspberrypi/linux/wiki/Upstreaming |
Just to be clear, are you saying that the contents of cmdline.txt get inserted into /chosen/bootargs, but the firmware generated arguments (like dma.dmachans) are missing? |
Correct start.elf
config.txt
cmdline.txt
Kernel messages
|
Okay, that should be fixable... |
Try: which should include extended command line parameters |
That gave me the contents of chosen/bootargs with a lot of spaces
The command line with spaces is 690 characters long. chosen/bootargs in the DT is 791 characters long including trailing spaces. |
I don't know what to suggest. Using your zImage and bcm2708-rpi-b.dtb along with start_dtrev2.elf (renamed to start.elf) I get:
|
I started with a fresh image, and it's working now. I also tried it with 3.15 and the DT patches I'm working on, boots fine here to. |
@popcornmix
How many commits do you want this split into? Here's a suggestion for SPI. 3 commits in one PR.
|
See: raspberrypi/linux#621 kernel: hid: Reduce default mouse polling interval to 60Hz See: http://www.raspberrypi.org/forums/viewtopic.php?t=75365&p=556534#p540272 firmware: gpioman: Add support for configuring gpio from external blob file firmware: Backport latest VCSM firmware: arm_loader: Add extended command line parameters before filling in device tree See: raspberrypi/linux#627 firmware: bplus: Support config option max_usb_current See: http://www.raspberrypi.org/forums/viewtopic.php?f=63&t=81736&start=50#p577877 firmware: bplus: Invert left/right channels for pwm audio on bplus
See: raspberrypi/linux#621 kernel: hid: Reduce default mouse polling interval to 60Hz See: http://www.raspberrypi.org/forums/viewtopic.php?t=75365&p=556534#p540272 firmware: gpioman: Add support for configuring gpio from external blob file firmware: Backport latest VCSM firmware: arm_loader: Add extended command line parameters before filling in device tree See: raspberrypi/linux#627 firmware: bplus: Support config option max_usb_current See: http://www.raspberrypi.org/forums/viewtopic.php?f=63&t=81736&start=50#p577877 firmware: bplus: Invert left/right channels for pwm audio on bplus
DT changes are in latest (rpi-update) firmware. |
This seems to change the cmdline.txt behaviour such that NetBSD can no longer fetch cmdline via the mailbox property interface. Having i.e. the first token appended to a long string of linux stuff (no idea where it comes from) Am I missing something? |
@skrll |
Duh, should have realised the buffer wasn't big enough. Not sure when it happened, but the "new" firmware specific features seem redundant information, i.e. it can all be obtained via the mailbox property interface. Should I just ignore the added info? |
Yes, many options are available through command line, mailbox and device tree. One day they may be removed from command line, when everyone is using a device tree kernel, but that won't be happening soon. |
I have added a separate wiki page for BCM2708 and DT: https://github.com/raspberrypi/linux/wiki/Device-Tree-on-ARCH_BCM2708 Also added a Summary to the Upstreaming page: https://github.com/raspberrypi/linux/wiki/Upstreaming |
raspberrypi/linux:rpi-3.15.y have Device Tree support now. I have built a kernel for those who want to try it:
I have also updated the wiki with some usage info: Device Tree on ARCH_BCM2708 |
See: raspberrypi/linux#621 kernel: hid: Reduce default mouse polling interval to 60Hz See: http://www.raspberrypi.org/forums/viewtopic.php?t=75365&p=556534#p540272 firmware: gpioman: Add support for configuring gpio from external blob file firmware: Backport latest VCSM firmware: arm_loader: Add extended command line parameters before filling in device tree See: raspberrypi/linux#627 firmware: bplus: Support config option max_usb_current See: http://www.raspberrypi.org/forums/viewtopic.php?f=63&t=81736&start=50#p577877 firmware: bplus: Invert left/right channels for pwm audio on bplus
Build system review
I have a proposal for a way to get Device Tree support and move to ARCH_BCM2835.
Steps
Replaces arch/arm/mach-bcm2708/clock.c which is removed
I expand on this further down.
GPIO interrupts is mapped to a virtual bank 3 since we can't use irq-bcm2835 (at least I couldn't get it to work).
bcm2708.dtsi
bcm2708-rpi-b.dts
At this point the kernel boots with Device Tree.
Platform devices can now be added through Device Tree.
Next steps
It provides DT support to the gpio_chip added in bcm2708_gpio
Move SPI/I2C devices to DT
It is also possible to enable i2c-bcm2835 and spi-bcm2835 as well. Testing can begin and maybe we can move to them sooner than later.
At this point SPI and I2C devices can also be added, and pins/GPIOs can be configured (in/out, alt0 etc.) in DT.
Move drivers to DT
Now the rest of the drivers can get DT support and the devices be moved from bcm2708.c to DT
(I have done most of these already in patches lying around)
At this point all devices are added through Device Tree.
Normal ATAG_CMDLINENow the normal ATAG_CMDLINE can be used for chosen/bootargs.Normal chosen/bootargs
Now config.txt can be used for chosen/bootargs if preferred.
Start using dmaengine
Currently most of the drivers manipulate the DMA registers directly.
To remedy this, bcm2708-dmaengine/bcm2835-dma has to get support for slave_sg (I believe this is what is needed).
Then bcm2708_fb, sdhci-bcm2708 and others can start using dmaengine.
Mailbox driver
There is work going on upstream for this (Lubomir Rintel and others).
The Mailbox API isn't settled yet (latest patch version).
Drivers would need to start using this.
FIQ
We need to have FIQ support in ARCH_BCM2835.
I don't know if it is already supported in irq-bcm2835.
Is shortcut the same as FIQ?
At this point, switching to ARCH_BCM2835 should (hopefully) be close at hand.
Some of these steps can of course happen in parallel.
rpi-update
Maybe rpi-update could handle config.txt for Device Tree kernels.
If a .dtb is present
add DT options and use the .dtb
else
remove DT options if present.
VideoCore Bootloader in DT mode
Current behaviour and proposed changes (through a new config option or something similar if needed):
config.txt
ATAG_MEM
This is set to the amount of installed memory, not the part that's available to the CPU.
This requires a /memreserve/ node in DT to keep Linux from using memory it doesn't have.
The value of this node depends on the GPU/CPU memory split value in config.txt.
Changing this to available memory, removes the need for /memreserve/. This is how ARCH_BCM2835 expects it, and U-boot delivers it.
ATAG_CMDLINEchosen/bootargs
This is the contents of cmdline.txt.
Changing this to the extended commandline used in non-DT mode, means no drivers have to be changed when moving to DT.
One caveat with the VC bootloader is that chosen/bootargs has to be prefilled with 1024 characters (COMMAND_LINE_SIZE), since the bootloader isn't equipped to allocate more space in the Device Tree.
The bootloader must have this ability to be able to boot vanilla Linux and pass in cmdline.txt.
libfdt is in use in many projects to provide Device Tree manipulation abilities (Linux, U-boot and others).
Example
I have a working example using a modified U-Boot to get the desired bootloader behaviour.
It sort of covers the steps up to SPI/I2C (it was made before this text was written).
Install
Patches used in this example:
Issue history
The text was updated successfully, but these errors were encountered: