编译linux内核

1.配置交叉编译环境

下载linaro

cd ~

wget https://releases.linaro.org/archive/14.04/components/toolchain/binaries/gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux.tar.bz2

tar xjf gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux.tar.xz
sudo mkdir /usr/local/arm

sudo cp gcc-linaro-****arm-linux-gnueabihf.tar.xz /usr/local/arm/ -f

sudo tar -vxf gcc-linaro-***arm-linux-gnueabihf.tar.xz

 

 

修改环境变量

sudo vi /etc/profile 

export PATH=$PATH:/usr/local/arm/gcc-linaro****arm-linux-gnueabihf/bin 

 

在使用交叉编译器之前还需要安装一下其它的库

sudo apt-get install lsb-core lib32stdc++6

 

验证

arm-linux-gnueabihf-gcc -v

 

2.build uboot

git clone http://github.com/altera-opensource/u-boot-socfpga

cd u-boot-socfpga

git checkout -b test_branc

make

make mrproper
//删除所有的编译生成文件、内核配置文件.config和backup,与make clean不同的是,clean会保留内核配置文件.config。第一次编译使用make mrproper
make socfpga_cyclone5_config

make

 

 

 出现这种问题:

sudo apt-get install libncurses5-dev libncursesw5-dev

sudo apt-get install bison

sudo apt-get install flex

最后make

 

 

 

export CROSS_COMPILE=arm-linux-gnueabihf-
export ARCH=arm

 

 

 

vim arch/arm/config.mk

  

64行左右:

############# old ##############

else
archprepare: checkgcc6
endif

checkgcc6:
    @if test "$(call cc-name)" = "gcc" -a \
            "$(call cc-version)" -lt "0600"; then \
        echo '*** Your GCC is older than 6.0 and is not supported'; \
        false; \
    fi
############# old ##############

改为:

########### new ###############
#else
#archprepare: checkgcc6
endif

#checkgcc6:
#    @if test "$(call cc-name)" = "gcc" -a \
#            "$(call cc-version)" -lt "0600"; then \
#        echo '*** Your GCC is older than 6.0 and is not supported'; \
#        false; \
#    fi
########### new ###############

但是还是不行,去https://www.linaro.org/downloads/下载6.0以上的版本。

 

export CROSS_COMPILE=~/gcc-linaro-6.4.1-2017.08-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-

 

make,也不知道完成了没有!!!

 

 反正生成了

FileDescription
u-boot U-boot ELF file
u-boot.bin U-boot binary file
u-boot.img U-boot image file

 

 

 

2.编译内核

 

git clone https://github.com/altera-opensource/linux-socfpga

cd linux-socfpga
git checkout -b test_branch
export CROSS_COMPILE=~/gcc-linaro-6.4.1-2017.08-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-
export ARCH=arm

make socfpga_defconfig

make zImage -j4

 

生成文件

FileDescription
vmlinux Linux Kernel ELF file
arch/arm/boot/zImage Linux Kernel image

 

3.编译设备树

make dtbs

 

 

posted @ 2020-12-01 17:52  11YS  阅读(188)  评论(0)    收藏  举报