Building mainline kernel in RPi 3

Luis de Bethencourt luisbg at osg.samsung.com
Sat Oct 22 04:36:23 PDT 2016


On 21/10/16 17:00, Eric Anholt wrote:
> Luis de Bethencourt <luisbg at osg.samsung.com> writes:
> 
>> Hi all,
>>
>> Sorry if this has been asked before but I couldn't find it in the archive of the
>> mailing list.
>>
>> With Raspberry Pi 3 support now in 4.8, I want to run mainline on mine.
>> All the instructions I've found are old and based on RPi2. [0] I've tried this
>> with no success and I also tried a simpler method which I use in other embedded
>> platforms, which ideally should work:
>>
>> $ ARCH=arm64 CROSS_COMPILE="aarch64-linux-gnu-" make defconfig
>> $ ./scripts/config --enable CONFIG_ARCH_BCM2835
>> $ ARCH=arm64 CROSS_COMPILE="aarch64-linux-gnu-" make -j 4
>>
>> $ cp -rv arch/arm64/boot/Image /media/boot/kernel-new.img
>> $ cp -rv arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b.dtb /media/boot/
>>
>> $ echo "kernel=kernel-new.img" > /media/luisbg/boot/config.txt
>> $ echo "device_tree=bcm2837-rpi-3-b.dtb" > /media/luisbg/boot/config.txt
>>
>>
>> Can anybody recommend me a resource or a list of steps to follow to do this?
>>
>> It would be really cool to use the RPi3 for "on the road" kernel development, it
>> is much more convenient to use for this than devices that need to plugged to the
>> wall like the ODROID XU4 which I currently use.
> 
> You're going to want the defconfig bits from
> https://github.com/anholt/linux/commits/bcm2835-defconfig-64-next
> 
> Also, the defconfig is thoroughly based on modules, so you'll need to
> install them, and may need an initrd.  initrds are a pain to set up for
> cross compiling, so you might just grep .config for 2835 and RASPBERRYPI
> and build in as many of those as you can.
> 

Thanks Eric! That's great.

Right now to get things moving and having a RPi to play with I was running
the rpi-4.9 branch from https://github.com/raspberrypi/linux.git

With this and the defconfig in your branch I can figure out how to follow
linux-next (or latest -rc tag), which is my goal setup for kernel development.
Will report back.

In case other people in a similar situation find this thread, I'm adding here
the steps to use that raspberrypi repo. It is easy:
(Based on Raspbian, so the SD card has two partitions, one with /boot and one
with the rest of the system, /)
----------------------------------------------------------------------------
Get kernel fork repo
$ git clone https://github.com/raspberrypi/linux
$ cd linux
$ git checkout -b rpi-4.9 origin/rpi-4.9.y

Plug SD card and Build
$ KERNEL=kernel7
$ SD_ROOT=/media/root/
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bcm2709_defconfig
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage modules dtbs -j4
$ sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
       INSTALL_MOD_PATH=$SD_ROOT/ modules_install

Copy necessary files
$ SD_BOOT=/media/boot
$ sudo scripts/mkknlimg arch/arm/boot/zImage $SD_BOOT/$KERNEL.img
$ sudo cp arch/arm/boot/dts/*.dtb $SD_BOOT/
$ sudo cp arch/arm/boot/dts/overlays/*.dtb* $SD_BOOT/overlays/

Umount and plug SD card on RPi
----------------------------------------------------------------------------

Thanks,
Luis



PD: It never ceases to amaze me when people leading the work on a project take
time to answer questions from newcomers. Much appreciated, let me know if I
can help.

*virtual highfive*



More information about the linux-rpi-kernel mailing list