kernel.org - notro/rpi-build GitHub Wiki

The vanilla Linux kernel has some support for the Raspberry Pi, but several drivers are still missing.
There is USB and networking support since 3.14.

The upstream kernel is developed to work with the U-Boot bootloader.

The default config bcm2835_defconfig doesn't have MODULES support. Everything is built into the kernel proper (zImage).

Performance

I did some simple performance tests:

  • Disk writing is horrible: 700kB/s
  • Network/USB is slower: 3MB/s vs. 4MB/s

Disk performance test

Read

SD card BCM2708 BCM2835
SanDisk Extreme 45MB/s 16GB 18.5 MB/s 15.3 MB/s
SanDisk Ultra 30MB/s 8GB 18.7 MB/s 14.8 MB/s
SanDisk Class4 4GB 17.6 MB/s 15.2 MB/s

Write

SD card BCM2708 BCM2835
SanDisk Extreme 45MB/s 16GB 18.3 MB/s 658 kB/s
SanDisk Ultra 30MB/s 8GB 17.6 MB/s 707 kB/s
SanDisk Class4 4GB 6.8 MB/s 713 kB/s
Details

Method: http://elinux.org/RPi_SD_cards#Performance

SD-card: SanDisk Ultra 30MB/s 8GB

BCM2708

$ zgrep ARCH_BCM2 /proc/config.gz
CONFIG_ARCH_BCM2708=y
$ sync; time dd if=/dev/zero of=~/test.tmp bs=500K count=1024; time sync
1024+0 records in
1024+0 records out
524288000 bytes (524 MB) copied, 29.8352 s, 17.6 MB/s

real    0m29.851s
user    0m0.000s
sys     0m11.150s

real    0m5.031s
user    0m0.000s
sys     0m0.140s
$ dd if=~/test.tmp of=/dev/null bs=500K count=1024
1024+0 records in
1024+0 records out
524288000 bytes (524 MB) copied, 28.0806 s, 18.7 MB/s
$ rm ~/test.tmp
$ uname -a
Linux raspberrypi 3.12.21+ #689 PREEMPT Wed Jun 11 21:45:12 BST 2014 armv6l GNU/Linux

BCM2835

$ zgrep ARCH_BCM2 /proc/config.gz
CONFIG_ARCH_BCM2835=y
$ sync; time dd if=/dev/zero of=~/test.tmp bs=500K count=1024; time sync
1024+0 records in
1024+0 records out
524288000 bytes (524 MB) copied, 741.876 s, 707 kB/s

real    12m42.016s
user    0m0.050s
sys     0m54.440s

real    1m53.376s
user    0m0.010s
sys     0m0.010s
$ dd if=~/test.tmp of=/dev/null bs=500K count=1024
1024+0 records in
1024+0 records out
524288000 bytes (524 MB) copied, 35.5302 s, 14.8 MB/s
$ rm ~/test.tmp
$ uname -a
Linux raspberrypi 3.15.0 #1 Wed Jun 11 20:03:03 UTC 2014 armv6l GNU/Linux

Write:
CPU: mmcqd/0:50-98%
SSH session is sluggish.

Read:
CPU: 98% idle
SSH session responsive.

Network throughput

Server:

$ nc -l 1122

BCM2708

$ dd if=/dev/zero bs=256M count=1 | nc 192.168.10.92 1122
268435456 bytes (268 MB) copied, 64.6543 s, 4.2 MB/s
$ uname -a
Linux raspberrypi 3.12.21+ #689 PREEMPT Wed Jun 11 21:45:12 BST 2014 armv6l GNU/Linux

BCM2835

$ dd if=/dev/zero bs=256M count=1 | nc 192.168.10.92 1122
268435456 bytes (268 MB) copied, 86.4303 s, 3.1 MB/s
$ uname -a
Linux raspberrypi 3.15.0 #1 Wed Jun 11 20:03:03 UTC 2014 armv6l GNU/Linux

bcmrpi_defconfig

Here's a hack I tried combining bcm2835_defconfig with with the modules in bcmrpi_defconfig and adding patches by Lubomir Rintel.
It builds and boots, but I haven't done any more testing.

Update:
Lubomir Rintel (22-06-2014 email)

As the work on common mailbox framework progressed, I've updated the driver to work with v7 of it (I've also ported the cpufreq and vchiq drivers, ...

https://github.com/hackerspace/rpi-linux/commits/lr-vchiq-new-mailbox

Rakefile

require 'stdlib/base'
require 'stdlib/linux'

def merge_kernel_config(fn, skip)
  changes = {}
  diff = `diff -u #{workdir 'linux/.config'} #{fn}; /bin/true`.strip
  diff.each_line do |line|
    m = line.match(/^\+\# (\w+) is not set$/)
    if m
      changes[m[1]] = 'n'
      next
    end
    m = line.match(/^(.)(\w+)=(.*)$/)
    next if m.nil?
    next unless m[1] == '+'
    # skip these
    next if m[2] =~ skip
    changes[m[2]] = m[3]
  end
  changes.each_pair do |k,v|
    if v == 'n'
      sh "cd #{workdir 'linux'} && scripts/config --disable #{k}"
    else
      sh "cd #{workdir 'linux'} && scripts/config --set-val #{k} #{v}"
    end
  end
  sh make 'oldconfig', "yes \"\" | "
end


# https://github.com/hackerspace/rpi-linux/commits/lr-usb
package :hspace => :kernel_org do
  # WIP: mailbox: Add Broadcom BCM2835 mailbox driver
  download 'https://github.com/hackerspace/rpi-linux/commit/e9449e7fa704c96b3281fdc5ef055e9afa04e9d4.patch', 'bcm2835-ipc-dts.patch', 'WIP: bcm2835: Add Broadcom BCM2835 mailbox to the device tree'
  patch 'bcm2835-ipc-dts.patch'
  download 'https://github.com/hackerspace/rpi-linux/commit/1b604c5be9d23cac4607b7d57f4ef7f6ad2a0c49.patch', 'bcm2835-ipc.patch', 'WIP: mailbox: Add Broadcom BCM2835 mailbox driver'
  patch 'bcm2835-ipc.patch', '--fuzz=3'
  config ['MAILBOX', 'BCM2835_MBOX'], :enable

  # WIP: bcm2835: Add Broadcom BCM2835 thermal sensor to the device tree
  download 'https://github.com/hackerspace/rpi-linux/commit/9f970c3117c7b749db6b5fa83d8ac50d9b0f7fa4.patch', 'bcm2835-thermal-dts.patch', 'WIP: bcm2835: Add Broadcom BCM2835 thermal sensor to the device tree'
  patch 'bcm2835-thermal-dts.patch'
  # WIP: thermal: Add Broadcom BCM2835 thermal sensor driver
  download 'https://github.com/hackerspace/rpi-linux/commit/98d8cf7dbb86f74104781d8c13167d8067ab3422.patch', 'bcm2835-thermal.patch', 'WIP: thermal: Add Broadcom BCM2835 thermal sensor driver'
  patch 'bcm2835-thermal.patch', '--fuzz=3'
  config ['THERMAL', 'THERMAL_BCM2835'], :enable

  # WIP: fb: Add Broadcom BCM2835 framebuffer driver
  download 'https://github.com/hackerspace/rpi-linux/commit/303d5e59a3000a44e4845f8dd73b0d764728803f.patch', 'bcm2835fb-dts.patch', 'WIP: bcm2835: Add Broadcom BCM2835 framebuffer to the device tree'
  patch 'bcm2835fb-dts.patch'
  download 'https://github.com/hackerspace/rpi-linux/commit/f9ce7e496563964f37f346a816af59fbf4b327f4.patch', 'bcm2835fb.patch', 'WIP: fb: Add Broadcom BCM2835 framebuffer driver'
  patch 'bcm2835fb.patch'
  config ['FB', 'FRAMEBUFFER_CONSOLE', 'FB_BCM2835'], :enable

  # WIP: bcm2835: Increase DMA Coherent Pool size to 4M (VCHIQ needs this.)
  # https://github.com/hackerspace/rpi-linux/commit/ba73eacd849bb8cf44e047d2b6197cc7351fada7
  # that patch won't apply, so make one that does:
  p = <<EOM
--- a/arch/arm/mach-bcm2835/bcm2835.c
+++ b/arch/arm/mach-bcm2835/bcm2835.c
@@ -19,6 +19,7 @@
 #include <linux/of_address.h>
 #include <linux/of_platform.h>
 #include <linux/clk/bcm2835.h>
+#include <linux/dma-mapping.h>
 
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
@@ -124,6 +125,11 @@ static void __init bcm2835_init(void)
 	}
 }
 
+static void __init bcm2835_init_early(void)
+{
+	init_dma_coherent_pool_size(SZ_4M);
+}
+
 static const char * const bcm2835_compat[] = {
 	"brcm,bcm2835",
 	NULL
@@ -134,6 +140,7 @@ DT_MACHINE_START(BCM2835, "BCM2835")
 	.map_io = bcm2835_map_io,
 	.init_irq = bcm2835_init_irq,
 	.init_machine = bcm2835_init,
+	.init_early = bcm2835_init_early,
 	.restart = bcm2835_restart,
 	.dt_compat = bcm2835_compat
 MACHINE_END
EOM
  File.open(workdir('bcm2835.patch'), 'w') { |file| file.write p }
  patch 'bcm2835.patch'

  # WIP: vc04_services: Videocore VCHIQ
  download 'https://github.com/hackerspace/rpi-linux/commit/634ca18f5f0ac80b90f6685624206dfdb956b22c.patch', 'vc04_services.patch', 'WIP: vc04_services: Videocore VCHIQ'
  patch 'vc04_services.patch', '--fuzz=3'
  # INIT_COMPLETION disappeared in 3.13
  p = <<EOM
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
@@ -52,6 +52,10 @@
 #include "vchiq_core.h"
 #include "vchiq_arm.h"
 
+#ifndef INIT_COMPLETION
+#define INIT_COMPLETION(c) reinit_completion(&c)
+#endif
+
 #define DEVICE_NAME "vchiq"
 
 /* Override the default prefix, which would be vchiq_arm (from the filename) */
EOM
  File.open(workdir('vchiq_arm.patch'), 'w') { |file| file.write p }
  patch 'vchiq_arm.patch'
  config 'BCM2835_VCHIQ', :enable

  # WIP: ALSA: Add Broadcom BCM2835 sound driver
  download 'https://github.com/hackerspace/rpi-linux/commit/c2190c938321990e23c8640e015471b9172504bf.patch', 'snd-bcm2835.patch', 'WIP: ALSA: Add Broadcom BCM2835 sound driver'
  patch 'snd-bcm2835.patch', '--fuzz=3'
  config 'SND_BCM2835', :enable
end


release :linux_bcmrpi => [:issue106, :rpi_tools, :rpi_firmware, :uboot_bcm2835, :kernel_org, :hspace] do
  VAR['KERNEL_ORG_VERSION'] ||= '3.14.3'
end

# the first action runs before all prerequisites (this only applies to release actions)
# this, the second action, will run after all the prerequisites have run
release :linux_bcmrpi do
  download 'https://raw.githubusercontent.com/raspberrypi/linux/rpi-3.14.y/arch/arm/configs/bcmrpi_defconfig', 'bcmrpi_defconfig-3.14'
  # this has to be the last of all config actions
  target :config do
    config 'SND_BCM2835', :module
    merge_kernel_config download_dir('bcmrpi_defconfig-3.14'), /BCM2708|BCM2835|CONFIG_ARCH|CONFIG_ZBOOT_ROM|CONFIG_CMDLINE/
  end
end