Difference between revisions of "RPi Upstreaming"

From eLinux.org
Jump to: navigation, search
m (Fixed Stephen's name (I insist to miswrite it), minor corrections and enhancements.)
(update for current merges)
 
(41 intermediate revisions by 9 users not shown)
Line 1: Line 1:
{{Template:RPi_Software}}
+
== MOVED: Building an Upstream Kernel for Raspberry Pi ==
  
== Building an Upstream Kernel for you Raspberry Pi ==
+
Please see [[RPi_Upstream_Kernel_Compilation]] or [https://github.com/anholt/linux/wiki/Raspberry-Pi-development-environment Raspberry-Pi-development-environment] instead.
  
'''First word of advice:''' Have you visited the [[RPi_Kernel_Compilation]] page? If you did not, read at least the Roadmap section.
+
== Contact ==
  
This page describes how to compile an upstream or mainline kernel for the Raspberry Pi. It is mainly useful for upstream kernel maintainers/developers, or distribution kernel package maintainers.
+
You can find us in #raspberrypi-kernel @ Freenode IRC.
  
As of 20140211, all of UART (serial), SD card, HDMI (via simple-framebuffer), and USB should work. Not all SD cards will work (it may depend on the transfer modes the card supports, and timing tolerances). Not all USB devices will work (it may depend on the type of transfer, interrupt/control/bulk, the device uses, etc.)
+
== Documentation ==
  
If something in this page doesn't make sense to you, pay a visit to [[RPi_Kernel_Compilation]], [[RPi_Upstream_Kernel_Compilation]] and [[RPi_U-Boot]] articles.
+
[http://www.raspberrypi.org/wp-content/uploads/2012/02/BCM2835-ARM-Peripherals.pdf BCM2835 ARM Peripherals Reference Manual [PDF<nowiki>]</nowiki>]
  
As a quickstart, this procedure will build a monolithic kernel, without modules, and good for a start. Build a sucessful image first, and then start your adventures with your crafted kernel.
+
[https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2836/QA7_rev3.4.pdf BCM2836 New ARM-local control registers [PDF<nowiki>]</nowiki>]]
  
=== Preparing the environment ===
+
[http://github.com/raspberrypi/firmware/wiki/Mailbox-property-interface VideoCore Mailbox Interface]
First of all, get the toolchain for cross compile your kernel:
 
  
$ cd /usr/src
+
== Status ==
$ git clone git://github.com/raspberrypi/tools.git --depth=1
 
  
Also, fetch Stephen Warren's u-boot branch (we will need it, because the default bootloader won't be of help):
+
{| class="wikitable"
 +
|-
 +
!  Component  !!    Status      !!  Assigned To  !!          Comments
 +
|-
 +
| RPi3 GPIO expander || [https://github.com/anholt/linux/commit/bc8dd6a272f0eda801ee24e91bcb8a36c92f4f12 WIP] || anholt
 +
|-
 +
| MMC DMA      || Downstream only ||  || drivers/mmc/host/sdhci-iproc.c
 +
|-
 +
| thermal      || reviewed for 4.9 || anholt || [https://www.spinics.net/lists/arm-kernel/msg566217.html]
 +
|-
 +
| cpufreq      || [http://lists.infradead.org/pipermail/linux-rpi-kernel/2015-October/002402.html in review] || lkundrak  || Current implementation RPi-only
 +
|-
 +
| PWM analog audio || mzoran || [https://www.spinics.net/lists/alsa-devel/msg60674.html]
 +
|}
  
$ git clone git://github.com/swarren/u-boot.git --depth=1
+
== Done ==
 
+
{| class="wikitable"
And now, get the mainline source:
+
|-
 
+
!  Component  !! Version !!          Comments
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git --depth=1
+
|-
 
+
| SDHOST MMC    || 4.12 || everything but the last DT bits in 4.12.
Define the following environment variable:
+
|-
 
+
| Camera        || 4.11 ||
$ export KERNEL_SRC=/usr/src/linux ; export CCPREFIX=/usr/src/tools/arm-bcm2708/arm-bcm2708-linux-gnueabi/bin/arm-bcm2708-linux-gnueabi-
+
|-
 
+
| VCHI          || 4.9 || driver now in staging, needs porting to 64-bit (WIP by Electron752)
=== Building your kernel ===
+
|-
'''Pro tip:''' Don't forget to prefix the make commands with the <tt>ARCH</tt> and <tt>CROSS_COMPILE</tt> prefixes. If you forget to use it and start a make command, it will probably result on a build failure. If you forgot and ran a make, do a make clean and start over.
+
| RPi3 (64-bit) || 4.9 ||
And now, let's prepare the Linux build recipe:
+
|-
 
+
| one-shot DMA || 4.7 ||
$ cd linux
+
|-
$ ARCH=arm CROSS_COMPILE=${CCPREFIX} make bcm2835_defconfig
+
| UART1        || 4.6 ||
 
+
|-
If you are building a Linux version which does not contains [http://lists.infradead.org/pipermail/linux-rpi-kernel/2014-September/000960.html this patch] (which is true at least up to 3.17), then you will have to manually select the USB controller, otherwise the USB ports (and networking!) will not work. Here is how to fix it. Enter the menuconfig
+
| SPI1/2        || 4.6 ||
 
+
|-
  $ ARCH=arm CROSS_COMPILE=${CCPREFIX} make menuconfig
+
| RPi2          || 4.5 ||
 
+
|-
And then navigate to <tt>Device Drivers  --->  USB support  ---> DesignWare USB2 DRD Core Support</tt> and check both <tt>Host only mode</tt> '''and''' <tt>DWC2 Platform</tt>.
+
| GPU (DRM)    || 4.7 ||
 
+
|-
Leave the menuconfig, save the new <tt>.config</tt> and then build the kernel:
+
| Power        || 4.5 || Current implementation RPi-only, requires current firmware for full functionality
 
+
|-
$ ARCH=arm CROSS_COMPILE=${CCPREFIX} chrt -i 0 make -j 8
+
| Framebuffer  || Deprecated, use DRM instead ||
 
+
|-
Your build was sucessful? Great. Leve it alone for a while.
+
| mailbox      || 4.4 ||
 
+
|-
=== Building your bootloader ===
+
| clocks-aux    || 4.5 || drivers/clk/bcm/clk-bcm2835-aux.c
As of 20140918, a upstream kernel image can't be booted using the default bootloader. And that's why we need the Stephen Warren's das u-Boot. Let's build it:
+
|-
 
+
| clocks-audio || 4.4 || drivers/clk/bcm/clk-bcm2835.c
$ cd ../u-boot
+
|-
$ git checkout -b rpi_dev origin/rpi_dev
+
| Clock Source || Done || drivers/clocksource/bcm2835_timer.c
$ ARCH=arm CROSS_COMPILE=${CCPREFIX} chrt -i 0 make rpi_b_config
+
|-
  $ ARCH=arm CROSS_COMPILE=${CCPREFIX} chrt -i 0 make -j 8
+
| DMA          || Done || drivers/dma/bcm2835-dma.c - less FIQ sup't
 
+
|-
Right, leave it alone. And now, let's setup the cmdline boot.
+
| I2C          || Done || drivers/i2c/busses/i2c-bcm2835.c
 
+
|-
  $ cd tools
+
| IRQ          || Done || drivers/irqchip/irq-bcm2835.c
 
+
|-
And create the file <tt>boot.scr</tt> with the following content:
+
| I2S (Audio)   || Done || sound/soc/bcm/bcm2835-i2s.c
 
+
|-
mmc dev 0
+
| Pinctrl      || Done || drivers/pinctrl/pinctrl-bcm2835.c
fatload mmc 0:1 ${kernel_addr_r} zImage
+
|-
fatload mmc 0:1 ${fdt_addr_r} ${fdtfile}
+
| Random NG    || Done || drivers/char/hw_random/bcm2835-rng.c
setenv fdtfile bcm2835-rpi-b.dtb
+
|-
setenv bootargs earlyprintk console=tty0 console=ttyAMA0 root=/dev/mmcblk0p2 rootwait
+
| SPI          || Done || drivers/spi/spi-bcm2835.c
bootz ${kernel_addr_r} - ${fdt_addr_r}
+
|-
 
+
| Watchdog      || Done || drivers/watchdog/bcm2835_wdt.c
'''Pro tip:''' I've found that u-boot doesn't play nicely with long cmdlines. Avoid cluttering it. Otherwise it will print a quick setenv failure and your boot will fail.
+
|-
 
+
| LEDs          || Done || arch/arm/boot/dts/bcm2835-*
And now, compile your cmdline:
+
|-
 
+
| Serial        || Done || drivers/tty/serial/amba-pl011.c
$ ./mkimage -A arm -O linux -T script -C none -n boot.scr -d boot.scr boot.scr.uimg
+
|}
 
 
=== Putting it all together ===
 
And now, it's time to set up your SD card. This procedure assumes that your SD card is at <tt>/media/boot</tt>.
 
 
 
First, let's save the current content to a backup directory (and empty the root directory):
 
 
 
$ export SD=/media/boot
 
$ mkdir $SD/backup
 
$ mv $SD/* $SD/backup
 
 
 
That's right, keep it empty. And now, let's populate with the fresh stuff.
 
 
 
Fetch a new firmware set from https://github.com/raspberrypi/firmware/tree/master/boot and save it to your <tt>$SD</tt>
 
 
 
And finally:
 
 
 
$ cd /usr/src
 
$ cp u-boot/u-boot.bin $SD/kernel.img
 
$ cp kernel/arch/arm/boot/zImage kernel/arch/arm/boot/dts/bcm2835-rpi-b.dtb u-boot/tools/boot.scr.uimg $SD
 
 
 
And you are done. Good luck!
 
 
 
{{Template:Raspberry Pi}}
 
[[Category:RaspberryPi]]
 
[[Category:Linux-kernel]]
 

Latest revision as of 17:23, 17 March 2017

MOVED: Building an Upstream Kernel for Raspberry Pi

Please see RPi_Upstream_Kernel_Compilation or Raspberry-Pi-development-environment instead.

Contact

You can find us in #raspberrypi-kernel @ Freenode IRC.

Documentation

BCM2835 ARM Peripherals Reference Manual [PDF]

BCM2836 New ARM-local control registers [PDF]]

VideoCore Mailbox Interface

Status

Component Status Assigned To Comments
RPi3 GPIO expander WIP anholt
MMC DMA Downstream only drivers/mmc/host/sdhci-iproc.c
thermal reviewed for 4.9 anholt [1]
cpufreq in review lkundrak Current implementation RPi-only
PWM analog audio mzoran [2]

Done

Component Version Comments
SDHOST MMC 4.12 everything but the last DT bits in 4.12.
Camera 4.11
VCHI 4.9 driver now in staging, needs porting to 64-bit (WIP by Electron752)
RPi3 (64-bit) 4.9
one-shot DMA 4.7
UART1 4.6
SPI1/2 4.6
RPi2 4.5
GPU (DRM) 4.7
Power 4.5 Current implementation RPi-only, requires current firmware for full functionality
Framebuffer Deprecated, use DRM instead
mailbox 4.4
clocks-aux 4.5 drivers/clk/bcm/clk-bcm2835-aux.c
clocks-audio 4.4 drivers/clk/bcm/clk-bcm2835.c
Clock Source Done drivers/clocksource/bcm2835_timer.c
DMA Done drivers/dma/bcm2835-dma.c - less FIQ sup't
I2C Done drivers/i2c/busses/i2c-bcm2835.c
IRQ Done drivers/irqchip/irq-bcm2835.c
I2S (Audio) Done sound/soc/bcm/bcm2835-i2s.c
Pinctrl Done drivers/pinctrl/pinctrl-bcm2835.c
Random NG Done drivers/char/hw_random/bcm2835-rng.c
SPI Done drivers/spi/spi-bcm2835.c
Watchdog Done drivers/watchdog/bcm2835_wdt.c
LEDs Done arch/arm/boot/dts/bcm2835-*
Serial Done drivers/tty/serial/amba-pl011.c