에 가서 LTS 버전을 받는다.

crosstool chain 을 받아서 설정한다. 여기 설정대로 따라한다.

Raspberry Pi


These instructions apply to all models of the Raspberry Pi:
  - the original models A and B,
  - the "enhanced" models A+ and B+,
  - the model B2 (aka Raspberry Pi 2)
  - the model B3 (aka Raspberry Pi 3).

How to build it

Configure Buildroot

There are two RaspberryPi defconfig files in Buildroot, one for each
major variant, which you should base your work on:

For models A, B, A+ or B+:

  $ make raspberrypi_defconfig

For model Zero (model A+ in smaller form factor):

  $ make raspberrypi0_defconfig

For model 2 B:

  $ make raspberrypi2_defconfig

For model 3 B and B+:

  $ make raspberrypi3_defconfig

Build the rootfs

Note: you will need to have access to the network, since Buildroot will
download the packages' sources.

You may now build your rootfs with:

  $ make

(This may take a while, consider getting yourself a coffee ;-) )

Result of the build

After building, you should obtain this tree:

    +-- bcm2708-rpi-b.dtb           [1]
    +-- bcm2708-rpi-b-plus.dtb      [1]
    +-- bcm2709-rpi-2-b.dtb         [1]
    +-- bcm2710-rpi-3-b.dtb         [1]
    +-- bcm2710-rpi-3-b-plus.dtb    [1]
    +-- boot.vfat
    +-- rootfs.ext4
    +-- rpi-firmware/
    |   +-- bootcode.bin
    |   +-- cmdline.txt
    |   +-- config.txt
    |   +-- fixup.dat
    |   +-- start.elf
    |   `-- overlays/               [2]
    +-- sdcard.img
    `-- zImage

[1] Not all of them will be present, depending on the RaspberryPi
    model you are using.

[2] Only for the Raspberry Pi 3 Model (overlay pi3-miniuart-bt is needed
    to enable the RPi3 serial console otherwise occupied by the bluetooth
    chip). Alternative would be to disable the serial console in cmdline.txt
    and /etc/inittab.

How to write the SD card

Once the build process is finished you will have an image called "sdcard.img"
in the output/images/ directory.

Copy the bootable "sdcard.img" onto an SD card with "dd":

  $ sudo dd if=output/images/sdcard.img of=/dev/sdX

Insert the SDcard into your Raspberry Pi, and power it up. Your new system
should come up now and start two consoles: one on the serial port on
the P1 header, one on the HDMI output where you can login using a USB

받은 buildroot 를 압축 푼다.

git init
git add
git commit

내 보드는 3 B 니까 (B+도 같은 옵션을 쓴다.) 아래와 같이 해준다.
make raspberrypi3_defconfig

make -j12

하면 에러난다.

export PERL_MM_OPT=

이거 두개 해주고 나서 다시 make 한다.



출처 :

Kernel build


Kernel building

There are two main methods for building the kernel. You can build locally on a Raspberry Pi, which will take a long time; or you can cross-compile, which is much quicker, but requires more setup.

Local building

On a Raspberry Pi, first install the latest version of Raspbian. Then boot your Pi, plug in Ethernet to give you access to the sources, and log in.

First install Git and the build dependencies:

sudo apt-get install git bc bison flex libssl-dev

Next get the sources, which will take some time:

git clone --depth=1


Choosing sources

The git clone command above will download the current active branch (the one we are building Raspbian images from) without any history. Omitting the --depth=1 will download the entire repository, including the full history of all branches, but this takes much longer and occupies much more storage.

To download a different branch (again with no history), use the --branch option:

git clone --depth=1 --branch rpi-4.18.y

Refer to the original GitHub repository for information about the available branches.

Kernel configuration

Configure the kernel; as well as the default configuration, you may wish to configure your kernel in more detail or apply patches from another source, to add or remove required functionality:

Run the following commands, depending on your Raspberry Pi version.

Raspberry Pi 1, Pi Zero, Pi Zero W, and Compute Module default build configuration

cd linux KERNEL=kernel make bcmrpi_defconfig

Raspberry Pi 2, Pi 3, Pi 3+, and Compute Module 3 default build configuration

cd linux KERNEL=kernel7 make bcm2709_defconfig

Build and install the kernel, modules, and Device Tree blobs; this step takes a longtime:

make -j4 zImage modules dtbs sudo make modules_install sudo cp arch/arm/boot/dts/*.dtb /boot/ sudo cp arch/arm/boot/dts/overlays/*.dtb* /boot/overlays/ sudo cp arch/arm/boot/dts/overlays/README /boot/overlays/ sudo cp arch/arm/boot/zImage /boot/$KERNEL.img

Note: On a Raspberry Pi 2/3, the -j4 flag splits the work between all four cores, speeding up compilation significantly.


First, you will need a suitable Linux cross-compilation host. We tend to use Ubuntu; since Raspbian is also a Debian distribution, it means many aspects are similar, such as the command lines.

You can either do this using VirtualBox (or VMWare) on Windows, or install it directly onto your computer. For reference, you can follow instructions online at Wikihow.

Install toolchain

Use the following command to download the toolchain to the home folder:

git clone ~/tools

Updating the $PATH environment variable makes the system aware of file locations needed for cross-compilation. On a 32-bit host system you can update and reload it using:

echo PATH=\$PATH:~/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin >> ~/.bashrc source ~/.bashrc

If you are on a 64-bit host system, you should use:

echo PATH=\$PATH:~/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin >> ~/.bashrc source ~/.bashrc

Get sources

To download the minimal source tree for the current branch, run:

git clone --depth=1

See Choosing sources above for instructions on how to choose a different branch.

Build sources

To build the sources for cross-compilation, make sure you have the dependencies needed on your machine by executing:

sudo apt-get install git bison flex libssl-dev

If you find you need other things, please submit a pull request to change the documentation.

Enter the following commands to build the sources and Device Tree files:

For Pi 1, Pi Zero, Pi Zero W, or Compute Module:

cd linux KERNEL=kernel make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bcmrpi_defconfig

For Pi 2, Pi 3, Pi 3+, or Compute Module 3:

cd linux KERNEL=kernel7 make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bcm2709_defconfig

Then, for both:

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage modules dtbs

Note: To speed up compilation on multiprocessor systems, and get some improvement on single processor ones, use -j n, where n is the number of processors * 1.5. Alternatively, feel free to experiment and see what works!

Install directly onto the SD card

Having built the kernel, you need to copy it onto your Raspberry Pi and install the modules; this is best done directly using an SD card reader.

First, use lsblk before and after plugging in your SD card to identify it. You should end up with something like this:

sdb sdb1 sdb2

with sdb1 being the FAT (boot) partition, and sdb2 being the ext4 filesystem (root) partition.

If it's a NOOBS card, you should see something like this:

sdb sdb1 sdb2 sdb5 sdb6 sdb7

with sdb6 being the FAT (boot) partition, and sdb7 being the ext4 filesystem (root) partition.

Mount these first, adjusting the partition numbers for NOOBS cards:

mkdir mnt mkdir mnt/fat32 mkdir mnt/ext4 sudo mount /dev/sdb1 mnt/fat32 sudo mount /dev/sdb2 mnt/ext4

Next, install the modules:

sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=mnt/ext4 modules_install

Finally, copy the kernel and Device Tree blobs onto the SD card, making sure to back up your old kernel:

sudo cp mnt/fat32/$KERNEL.img mnt/fat32/$KERNEL-backup.img sudo cp arch/arm/boot/zImage mnt/fat32/$KERNEL.img sudo cp arch/arm/boot/dts/*.dtb mnt/fat32/ sudo cp arch/arm/boot/dts/overlays/*.dtb* mnt/fat32/overlays/ sudo cp arch/arm/boot/dts/overlays/README mnt/fat32/overlays/ sudo umount mnt/fat32 sudo umount mnt/ext4

Another option is to copy the kernel into the same place, but with a different filename - for instance, kernel-myconfig.img - rather than overwriting the kernel.img file. You can then edit the config.txt file to select the kernel that the Pi will boot into:


This has the advantage of keeping your kernel separate from the kernel image managed by the system and any automatic update tools, and allowing you to easily revert to a stock kernel in the event that your kernel cannot boot.

Finally, plug the card into the Pi and boot it!

'Linux > Linux 일반' 카테고리의 다른 글

Raspberry Pi Buildroot  (0) 2019.06.12
yocto 연습  (0) 2019.05.21
dbus로 MPRIS 날려서 VLC 제어해보기  (0) 2019.02.25
linux audio output check  (0) 2019.01.31
Posted by Real_G