Skip to main content

How to Compile Raspbian on the Raspbian?

How To Compile Raspbian On The Raspbian?

How to compile Raspbian on the Raspbian?

Introduction

Do you know we can compile Rsapbian on the Raspbian. To make your new Operation System. There are two good tool-chain and Raspbian source code and then you are dreaming to become true. It is very funny. You just need to another SD Card. Firstly, we have to download armv6 tool-chain and extract it. Secondly, [2] we need to download Raspbian source code and extract it. Thirdly, we have to arrange the environment variable to compile it.

Equipment

Operation System: Raspbian (NOOBS v1.3.10)
Armv6 Tool-Chain: gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux
Raspbian Source Code: raspi-linux-3.12.y

Usage

1.. To Extract armv6 Tool-Cahin.

root@raspberrypi:/home/pi/development# tar -xvf gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux.tar.xz
gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux/bin/
gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux/bin/arm-linux-gnueabihf-c++filt
gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux/bin/arm-linux-gnueabihf-c++
gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux/bin/arm-linux-gnueabihf-elfedit
gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux/bin/arm-linux-gnueabihf-objdump
gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux/bin/arm-linux-gnueabihf-as
gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux/bin/arm-linux-gnueabihf-cpp
gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux/bin/arm-linux-gnueabihf-readelf
gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux/bin/arm-linux-gnueabihf-size
gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux/bin/arm-linux-gnueabihf-gcc-ranlib
(… More)

2.. If you realize time stamp in the future, it is a incorrectly. Because Raspberry isn't a battery, so if you are powered off and then it will turn to default. We need to set current date by this command-line (date –set=yyyy-mm-dd). However, Raspberry pi operates in the SD Card and you need to patient waiting long time to extract it.

root@raspberrypi:/home/pi/development/linux# date –set=2015-01-05

root@raspberrypi:/home/pi/development# tar -jxvf -P raspi-linux-3.12.y.tar.bz2
tar: ./linux/.git/hooks/pre-applypatch.sample: time stamp 2014-11-16 05:32:28 is 5760991.968545 s in the future
./linux/.git/index
tar: ./linux/.git/hooks: time stamp 2014-11-16 05:32:28 is 5760991.965893 s in the future
tar: ./linux/.git/index: time stamp 2014-11-16 05:42:31 is 5761590.406329 s in the future
./linux/.git/HEAD
tar: ./linux/.git/HEAD: time stamp 2014-11-16 05:42:25 is 5761584.403213 s in the future
./linux/.git/objects/
./linux/.git/objects/pack/
./linux/.git/objects/pack/pack-f6c5e5ad0d0e1c784e3d471ae2598c55d42713aa.pack
(… More)

3.. Preparing your development environment.

root@raspberrypi:/home/pi/development# cd /linux/
root@raspberrypi:/home/pi/development/linux# cp /proc/config.gz ./
root@raspberrypi:/home/pi/development/linux# ls
arch crypto include kernel net security
block Documentation init lib README sound
config.gz drivers ipc MAINTAINERS REPORTING-BUGS tools
COPYING firmware Kbuild Makefile samples usr
CREDITS fs Kconfig mm scripts virt

root@raspberrypi:/home/pi/development/linux# cp /proc/config.gz ./
root@raspberrypi:/home/pi/development/linux# mv config config.bak
root@raspberrypi:/home/pi/development/linux# gzip -d config.gz
root@raspberrypi:/home/pi/development/linux# mv config .config

To open the .bashrc of your home folder and then edit it. We need to arrange the environment variable. Please add as below into your .bashrc.

export KERNEL_SRC=/home/pi/development/linux
export CCPREFIX=/home/pi/development/gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux/bin/arm-linux-gnueabihf-
export ARM=arm

4.. To compile your Operation System.
root@raspberrypi:/home/pi/development/linux# make
 HOSTCC scripts/basic/fixdep
 HOSTCC scripts/kconfig/conf.o
 SHIPPED scripts/kconfig/zconf.tab.c
 SHIPPED scripts/kconfig/zconf.lex.c
 SHIPPED scripts/kconfig/zconf.hash.c
 HOSTCC scripts/kconfig/zconf.tab.o
 HOSTLD scripts/kconfig/conf
scripts/kconfig/conf --silentoldconfig Kconfig
 CHK   include/config/kernel.release
 UPD   include/config/kernel.release
 WRAP  arch/arm/include/generated/asm/auxvec.h
 WRAP  arch/arm/include/generated/asm/bitsperlong.h
 WRAP  arch/arm/include/generated/asm/cputime.h
 WRAP  arch/arm/include/generated/asm/current.h
 WRAP  arch/arm/include/generated/asm/emergency-restart.h
(… More)
 LINK  vmlinux
 LD   vmlinux.o
 MODPOST vmlinux.o
 GEN   .version
 CHK   include/generated/compile.h
 UPD   include/generated/compile.h
 CC   init/version.o
 LD   init/built-in.o
 KSYM  .tmp_kallsyms1.o
 KSYM  .tmp_kallsyms2.o
 LD   vmlinux
 SORTEX vmlinux
 SYSMAP System.map
 OBJCOPY arch/arm/boot/Image
 Kernel: arch/arm/boot/Image is ready
 AS   arch/arm/boot/compressed/head.o
 GZIP  arch/arm/boot/compressed/piggy.gzip
 AS   arch/arm/boot/compressed/piggy.gzip.o
 CC   arch/arm/boot/compressed/misc.o
 CC   arch/arm/boot/compressed/decompress.o
 CC   arch/arm/boot/compressed/string.o
 SHIPPED arch/arm/boot/compressed/lib1funcs.S
 AS   arch/arm/boot/compressed/lib1funcs.o
 SHIPPED arch/arm/boot/compressed/ashldi3.S
 AS   arch/arm/boot/compressed/ashldi3.o
 LD   arch/arm/boot/compressed/vmlinux
 OBJCOPY arch/arm/boot/zImage
 Kernel: arch/arm/boot/zImage is ready
 Building modules, stage 2.
 MODPOST 1227 modules
(... More)
 H16TOFW firmware/edgeport/boot.fw
 H16TOFW firmware/edgeport/boot2.fw
 H16TOFW firmware/edgeport/down.fw
 H16TOFW firmware/edgeport/down2.fw
 IHEX  firmware/edgeport/down3.bin
 IHEX2FW firmware/whiteheat_loader.fw
 IHEX2FW firmware/whiteheat.fw
 IHEX2FW firmware/keyspan_pda/keyspan_pda.fw
 IHEX2FW firmware/keyspan_pda/xircom_pgs.fw
 IHEX  firmware/cpia2/stv0672_vp4.bin
 IHEX  firmware/yam/1200.bin
 IHEX  firmware/yam/9600.bin
(The End)

5.. To establish Kernel.img.
root@raspberrypi:/home/pi/development/tools-master/mkimage# ./imagetool-uncompressed.py ../../linux/arch/arm/boot/zImage
root@raspberrypi:/home/pi/development/tools-master/mkimage# ls
args-uncompressed.txt first32k.bin        kernel.img mkknlimg
boot-uncompressed.txt imagetool-uncompressed.py knlinfo

6.. To make new modules.
root@raspberrypi:/home/pi/development/# mkdir modules
root@raspberrypi:/home/pi/development/linux# ARCH=arm CROSS_COMPILE=${CCPREFIX} INSTALL_MOD_PATH=/home/pi/development/modules make modules_install
 INSTALL arch/arm/crypto/aes-arm.ko
 INSTALL arch/arm/crypto/sha1-arm.ko
 INSTALL arch/arm/oprofile/oprofile.ko
 INSTALL crypto/arc4.ko
 INSTALL crypto/async_tx/async_memcpy.ko
 INSTALL crypto/async_tx/async_pq.ko
 INSTALL crypto/async_tx/async_raid6_recov.ko
 INSTALL crypto/async_tx/async_tx.ko
 INSTALL crypto/async_tx/async_xor.ko
 INSTALL crypto/authenc.ko
(… more)

7.. To update new kernel.img, modules and firmware.

If you are following the above instructions, you should make two folders, including modules and firmware. The ‘kernel.img’ should replace to overwrite put it in the BOOT partition. In the root partition, there is a folder called 'lib'. You are just overwriting your new modules and firmware put them into the folder. To update your modules and firmware, you should use 'su' or 'sudo' to operate these instructions and then you will avoid permission issues. In my opinion, I suggest removing old modules and firmware folders and then to copy new modules and firmware. That's the best way.

Exception

1.. While you were adding .bashrc, Don't added any space in variable line.

2.. If you encounter to choice, you could press 'enter' key to default. It is just fine.

  • Restart config...
  • ALSA for SoC audio support

ALSA for SoC audio support (SND_SOC) [M/n/?] m
 SoC Audio for the Atmel System-on-Chip (SND_ATMEL_SOC) [N/m/?] n
 SoC Audio support for the Broadcom BCM2708 I2S module (SND_BCM2708_SOC_I2S) [M/n/?] m
  Support for HifiBerry DAC (SND_BCM2708_SOC_HIFIBERRY_DAC) [M/n/?] m
  Support for HifiBerry DAC+ (SND_BCM2708_SOC_HIFIBERRY_DACPLUS) [M/n/?] m
  Support for HifiBerry Digi (SND_BCM2708_SOC_HIFIBERRY_DIGI) [M/n/?] m
  Support for the HifiBerry Amp (SND_BCM2708_SOC_HIFIBERRY_AMP) [N/m/?] (NEW)
  Support for RPi-DAC (SND_BCM2708_SOC_RPI_DAC) [M/n/?] m
  Support for IQaudIO-DAC (SND_BCM2708_SOC_IQAUDIO_DAC) [M/n/?] m
 Synopsys I2S Device Driver (SND_DESIGNWARE_I2S) [N/m/?] n
 ASoC Simple sound card support (SND_SIMPLE_CARD) [N/m/?] n

3.. If you encounter to make an error about 'timeconst. h'. Please refer to as below to solve it.
BC kernel/timeconst.h
/bin/sh: 1: bc: not found
/home/pi/development/linux/kernel/Makefile:142: recipe for target 'kernel/timeconst.h' failed
make[1]: `***` [kernel/timeconst.h] Error 127
Makefile:797: recipe for target 'kernel' failed
make: `***` [kernel] Error 2

File name: timeconst.h
/* Automatically generated by kernel/timeconst.pl */
/* Conversion constants for HZ == 100 */

#ifndef KERNEL_TIMECONST_H
#define KERNEL_TIMECONST_H

#include <linux/param.h>
#include <linux/types.h>

#if HZ != 100
#error "kernel/timeconst.h has the wrong HZ value!"
#endif

#define HZ_TO_MSEC_MUL32 U64_C(0xa0000000)
#define HZ_TO_MSEC_ADJ32 U64_C(0x0)
#define HZ_TO_MSEC_SHR32 28
#define HZ_TO_MSEC_NUM U64_C(10)
#define HZ_TO_MSEC_DEN U64_C(1)
#define MSEC_TO_HZ_MUL32 U64_C(0xcccccccd)
#define MSEC_TO_HZ_ADJ32 U64_C(0x733333333)
#define MSEC_TO_HZ_SHR32 35
#define MSEC_TO_HZ_NUM U64_C(1)
#define MSEC_TO_HZ_DEN U64_C(10)
#define HZ_TO_USEC_MUL32 U64_C(0x9c400000)
#define HZ_TO_USEC_ADJ32 U64_C(0x0)
#define HZ_TO_USEC_SHR32 18
#define HZ_TO_USEC_NUM U64_C(10000)
#define HZ_TO_USEC_DEN U64_C(1)
#define USEC_TO_HZ_MUL32 U64_C(0xd1b71759)
#define USEC_TO_HZ_ADJ32 U64_C(0x1fff2e48e8a7)
#define USEC_TO_HZ_SHR32 45
#define USEC_TO_HZ_NUM U64_C(1)
#define USEC_TO_HZ_DEN U64_C(10000)

#endif /* KERNEL_TIMECONST_H */
To save it and put it into kernel folder.

Acknowledge

Thank you (Raspbian) very much for this great operation system.

Popular posts from this blog

Python 日期與時間的處理

Visual Basic 6.0 (VB6) 程式語言案例學習 (10. 條碼列印程式)

寫作:波蘭文學習之旅:1-1. 波蘭文字母與發音(注音版)

Python 日期與時間的處理

Image

Visual Basic 6.0 (VB6) 程式語言案例學習 (10. 條碼列印程式)

Image

寫作:波蘭文學習之旅:1-1. 波蘭文字母與發音(注音版)

Image

數位影像處理:最佳化處理策略之快速消除扭曲演算法

Image

用10種程式語言做影像二值化(Image binarization)

Image

Visual Basic 6.0 (VB6) 程式語言案例學習 (04. 人事考勤管理系統)

Image

Visual Basic .Net (VB.Net) 程式語言案例學習 (06. 題庫測驗系統)

Image

Visual Basic 6.0 (VB6) 程式語言案例學習 (11. 生產線拍照程式)

Image

Visual Basic 6.0 (VB6) 程式語言案例學習 (07. 收據列印程式)

Image

Visual Basic .Net (VB.Net) 程式語言案例學習 (03. 場地預約系統)

Image