CentOS&ubuntu下 IMX6移植Openwrt保姆级教程

IMX6移植Openwrt

  • 一.准备步骤
    • 1.确保所需要的依赖都有
      • centOs
      • ubuntu
    • 2.下载openwrt 19.07
  • 二.编译前准备
    • 1.解压openwrt-openwrt-18.06.zip
    • 2.更改菜单选项
      • (1)选择芯片
      • (2)写入板子内核源码位置
      • (3)更改clibrary
    • 3修改openwrt文件
      • (1)选择target
      • (2)选择linux
      • (3)选择自己的芯片型号
      • (4)打开Makefile
      • (5)修改config
  • 五.编译openwrt
  • 六.编译出现的错误
    • 1.WARNING: your configuration is out of sync. Please run make menuconfig, oldconfig or defconfig!
    • 2.Cannot find appropriate hash command, ensure the provided hash is either a MD5 or SHA256 checksum.
    • 3.xxx make -j1 V=s or make -j1 xxx
    • 4.Parse error at /xxx/openwrt-18.06/openwrt-openwrt-18.06/scripts/kconfig.pl line 137.
    • 5.whether mknod can create fifo without root privileges

一.准备步骤

1.确保所需要的依赖都有

centOs

sudo yum install subversion g++ zlib1g-dev build-essential git python python3 libncurses5-dev gawk gettext unzip file libssl-dev wget libelf-dev ecj fastjar java-propose-classpath asciidoc bzip2 libz-dev libtool

ubuntu

sudo apt-get install subversion g++ zlib1g-dev build-essential git python python3 libncurses5-dev gawk gettext unzip file libssl-dev wget libelf-dev ecj fastjar java-propose-classpath asciidoc bzip2 libz-dev libtool

2.下载openwrt 19.07

https://github.com/openwrt/openwrt/archive/v19.07.2.tar.gz
19.07本人使用后编译成功,各位自行测试什么可行。

二.编译前准备

1.解压openwrt-openwrt-18.06.zip

将压缩文件openwrt-openwrt-18.06.zip复制到你工作目录下
按顺序执行:

unzip openwrt-openwrt-18.06.zip
cd cd openwrt-openwrt-18.06/
./scripts/feeds update -a
./scripts/feeds install -a
make defconfig
make menuconfig

如果没有报错会出现下面的界面
CentOS&ubuntu下 IMX6移植Openwrt保姆级教程_第1张图片

2.更改菜单选项

首先先询问厂家自己所买的板子的内核源码在什么位置。
同时得到这个文件夹所在位置,例如我的:/home/isaiguserver250/ysh/file/openwrt-19.07/IMX/linux

CentOS&ubuntu下 IMX6移植Openwrt保姆级教程_第2张图片

(1)选择芯片

在第一个选项中选择自己的板子芯片,我的是IMX6ULL,但是openwrt默认没有IMX6ULL,我这里选择的是修改Freescale IMX6ULL,后续通过修改可以就可以使用了。
CentOS&ubuntu下 IMX6移植Openwrt保姆级教程_第3张图片
CentOS&ubuntu下 IMX6移植Openwrt保姆级教程_第4张图片

(2)写入板子内核源码位置

需要选择的内容,必须在光标处,先按下空格使得前面[ ]变为[*]然后再按回车
!!!!!!!!!!!!!!!!!!!
未按空格:
CentOS&ubuntu下 IMX6移植Openwrt保姆级教程_第5张图片按了空格:
CentOS&ubuntu下 IMX6移植Openwrt保姆级教程_第6张图片

这点很重要,如果先按空格选中的话,进入选项后会变成这样

CentOS&ubuntu下 IMX6移植Openwrt保姆级教程_第7张图片
进入Advanced configuration options (for developers) —>

CentOS&ubuntu下 IMX6移植Openwrt保姆级教程_第8张图片在光标处回车输入板子核心源码地址
CentOS&ubuntu下 IMX6移植Openwrt保姆级教程_第9张图片

(3)更改clibrary

在Advanced configuration options (for developers) 菜单最下面选择 Toolchain Options
CentOS&ubuntu下 IMX6移植Openwrt保姆级教程_第10张图片在里面的clibrary中选择 use glibc
CentOS&ubuntu下 IMX6移植Openwrt保姆级教程_第11张图片
CentOS&ubuntu下 IMX6移植Openwrt保姆级教程_第12张图片
然后保存 CentOS&ubuntu下 IMX6移植Openwrt保姆级教程_第13张图片

3修改openwrt文件

纲要:修改/openwrt-18.06/openwrt-openwrt-18.06/target/linux/imx6下的Makefile文件,改为

13.CPU_TYPE:=cortex-a7//芯片修改为a7
14.CPU_SUBTYPE:=vfpv3-d16//源Freescale不支持浮点型,但是IMX6ULL要支持浮点型
17.KERNEL_PATCHVER:=4.1//linux内核改为4.1

同时将此目录下的config改为ieconfig-4.1

详细步骤:
在openwrt目录下:

(1)选择target

CentOS&ubuntu下 IMX6移植Openwrt保姆级教程_第14张图片

(2)选择linux

CentOS&ubuntu下 IMX6移植Openwrt保姆级教程_第15张图片

(3)选择自己的芯片型号

及 “2.更改菜单选项(1)选择芯片”中选择的芯片型号
CentOS&ubuntu下 IMX6移植Openwrt保姆级教程_第16张图片

(4)打开Makefile

CentOS&ubuntu下 IMX6移植Openwrt保姆级教程_第17张图片如图修改Makefile
CentOS&ubuntu下 IMX6移植Openwrt保姆级教程_第18张图片修改内容如下:

13.CPU_TYPE:=cortex-a7//芯片修改为a7
14.CPU_SUBTYPE:=vfpv3-d16//源Freescale不支持浮点型,但是IMX6ULL要支持浮点型
17.KERNEL_PATCHVER:=4.1//linux内核改为4.1

(5)修改config

将原来的config-4.1.14改为config-4.1
CentOS&ubuntu下 IMX6移植Openwrt保姆级教程_第19张图片

五.编译openwrt

在openwrt的位置输入命令:

make -j1 V=s 

编译过程大概需要三四个小时
但是如果命令改为:

make -j4 V=s 

意思是同时编译4条命令,这将会缩短大量时间,同时也给处理器带来负担,各位量力而行。

六.编译出现的错误

1.WARNING: your configuration is out of sync. Please run make menuconfig, oldconfig or defconfig!

**CentOS&ubuntu下 IMX6移植Openwrt保姆级教程_第20张图片解决方法:

 1. make defconfig
 2. make oldconfig 

/******************************************************************************************************/

2.Cannot find appropriate hash command, ensure the provided hash is either a MD5 or SHA256 checksum.

CentOS&ubuntu下 IMX6移植Openwrt保姆级教程_第21张图片
root$ make -j1 V=s
make[1]: Entering directory /home/isaiguserver250/ysh/file/openwrt-19.07.2' make[2]: Entering directory/home/isaiguserver250/ysh/file/openwrt-19.07.2’
mkdir -p /home/isaiguserver250/ysh/file/openwrt-19.07.2/staging_dir/target-arm_cortex-a7+vfpv3-d16_glibc_eabi
cd /home/isaiguserver250/ysh/file/openwrt-19.07.2/staging_dir/target-arm_cortex-a7+vfpv3-d16_glibc_eabi
mkdir -p bin lib include stamp
mkdir -p /home/isaiguserver250/ysh/file/openwrt-19.07.2/build_dir/target-arm_cortex-a7+vfpv3-d16_glibc_eabi/stamp
touch /home/isaiguserver250/ysh/file/openwrt-19.07.2/staging_dir/target-arm_cortex-a7+vfpv3-d16_glibc_eabi/.prepared
make[3]: Entering directory /home/isaiguserver250/ysh/file/openwrt-19.07.2/toolchain/gdb' make[3]: Nothing to be done forcompile’.
make[3]: Leaving directory /home/isaiguserver250/ysh/file/openwrt-19.07.2/toolchain/gdb' time: toolchain/gdb/compile#0.00#0.00#0.00 make[3]: Entering directory/home/isaiguserver250/ysh/file/openwrt-19.07.2/toolchain/binutils’
make[3]: Nothing to be done for compile'. make[3]: Leaving directory/home/isaiguserver250/ysh/file/openwrt-19.07.2/toolchain/binutils’
time: toolchain/binutils/compile#0.00#0.00#0.01
make[3]: Entering directory /home/isaiguserver250/ysh/file/openwrt-19.07.2/toolchain/gcc/minimal' make[3]: Nothing to be done forcompile’.
make[3]: Leaving directory /home/isaiguserver250/ysh/file/openwrt-19.07.2/toolchain/gcc/minimal' time: toolchain/gcc/minimal/compile#0.00#0.00#0.01 make[3]: Entering directory/home/isaiguserver250/ysh/file/openwrt-19.07.2/toolchain/kernel-headers’
mkdir -p /home/isaiguserver250/ysh/file/openwrt-19.07.2/dl
SHELL= flock /home/isaiguserver250/ysh/file/openwrt-19.07.2/tmp/.linux-4.1.tar.xz.flock -c ’ /home/isaiguserver250/ysh/file/openwrt-19.07.2/scripts/download.pl “/home/isaiguserver250/ysh/file/openwrt-19.07.2/dl” “linux-4.1.tar.xz” “x” “” “@KERNEL/linux/kernel/v4.x” ’
Cannot find appropriate hash command, ensure the provided hash is either a MD5 or SHA256 checksum.
make[3]: *** [/home/isaiguserver250/ysh/file/openwrt-19.07.2/dl/linux-4.1.tar.xz] Error 255
make[3]: Leaving directory /home/isaiguserver250/ysh/file/openwrt-19.07.2/toolchain/kernel-headers' time: toolchain/kernel-headers/compile#0.02#0.01#0.04 make[2]: *** [toolchain/kernel-headers/compile] Error 2 make[2]: Leaving directory/home/isaiguserver250/ysh/file/openwrt-19.07.2’
make[1]: *** [/home/isaiguserver250/ysh/file/openwrt-19.07.2/staging_dir/toolchain-arm_cortex-a7+vfpv3-d16_gcc-7.5.0_glibc_eabi/stamp/.toolchain_compile] Error 2
make[1]: Leaving directory `/home/isaiguserver250/ysh/file/openwrt-19.07.2’
make: *** [world] 错误 2
原因:
没有hash,直接跳过就好。
解决方法:
编译命令改为:

make -j1 V=s PKG_HASH=skip

/******************************************************************************************************/

3.xxx make -j1 V=s or make -j1 xxx

具体问题忘记了
解决方法:

make -j1 V=s

/******************************************************************************************************/

4.Parse error at /xxx/openwrt-18.06/openwrt-openwrt-18.06/scripts/kconfig.pl line 137.

time: target/linux/prereq#0.06#0.03#0.13
make[1]: Entering directory /home/isaiguserver250/ysh/file/openwrt-18.06/openwrt-openwrt-18.06' make[2]: Entering directory/home/isaiguserver250/ysh/file/openwrt-18.06/openwrt-openwrt-18.06’
make[3]: Entering directory /home/isaiguserver250/ysh/file/openwrt-18.06/openwrt-openwrt-18.06/target/linux' make[4]: Entering directory/home/isaiguserver250/ysh/file/openwrt-18.06/openwrt-openwrt-18.06/target/linux/imx6’
rm -f /home/isaiguserver250/ysh/file/openwrt-18.06/openwrt-openwrt-18.06/build_dir/target-arm_cortex-a7+vfpv3-d16_glibc_eabi/linux-imx6/linux-4.1/localversion
/home/isaiguserver250/ysh/file/openwrt-18.06/openwrt-openwrt-18.06/scripts/kconfig.pl > /home/isaiguserver250/ysh/file/openwrt-18.06/openwrt-openwrt-18.06/build_dir/target-arm_cortex-a7+vfpv3-d16_glibc_eabi/linux-imx6/linux-4.1/.config.target
Parse error at /home/isaiguserver250/ysh/file/openwrt-18.06/openwrt-openwrt-18.06/scripts/kconfig.pl line 137.
make[4]: *** [/home/isaiguserver250/ysh/file/openwrt-18.06/openwrt-openwrt-18.06/build_dir/target-arm_cortex-a7+vfpv3-d16_glibc_eabi/linux-imx6/linux-4.1/.configured] Error 255
make[4]: Leaving directory /home/isaiguserver250/ysh/file/openwrt-18.06/openwrt-openwrt-18.06/target/linux/imx6' make[3]: *** [compile] Error 2 make[3]: Leaving directory/home/isaiguserver250/ysh/file/openwrt-18.06/openwrt-openwrt-18.06/target/linux’
time: target/linux/compile#0.03#0.05#0.08
make[2]: *** [target/linux/compile] Error 2
make[2]: Leaving directory /home/isaiguserver250/ysh/file/openwrt-18.06/openwrt-openwrt-18.06' make[1]: *** [/home/isaiguserver250/ysh/file/openwrt-18.06/openwrt-openwrt-18.06/staging_dir/target-arm_cortex-a7+vfpv3-d16_glibc_eabi/stamp/.target_compile] Error 2 make[1]: Leaving directory/home/isaiguserver250/ysh/file/openwrt-18.06/openwrt-openwrt-18.06’
make: *** [world] 错误 2
CentOS&ubuntu下 IMX6移植Openwrt保姆级教程_第22张图片
原因:
内核不同
解决方法:
/home/isaiguserver250/ysh/file/openwrt-18.06/openwrt-openwrt-18.06/target/linux/imx6
下的config文件命名与同目录下的Makefile规定的linux内核版本不同,详细查看目录 下的二.编译前准备(4)打开Makefile (5)修改config
/******************************************************************************************************/

5.whether mknod can create fifo without root privileges

you should not run configure as root (set FORCE_UNSAFE_CONFIGURE=1 in environment…
原因:
环境变量问题
解决方法:
在命令行输入:

exprot FORCE_UNSAFE_CONFIGURE=1
export FORCE=1

若还是不成功
编译命令改为:

make FORCE_UNSAFE_CONFIGURE=1-j1 V=s PKG_HASH=skip

/******************************************************************************************************/

你可能感兴趣的:(内核移植,linux,内核,ubuntu,centos,openwrt)