栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

ubuntu 下jetson nano编译内核及系统烧录-超详细

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

ubuntu 下jetson nano编译内核及系统烧录-超详细

一、内核编译

jetson nano 的内核编译踩了不少坑,记录一下:

步骤如下:

1.下载交叉编译工具

这里的网址来自官网,可以会更新,如果下载不了,需要去官网下载。

/home$ wget http://releases.linaro.org/components/toolchain/binaries/7.3-2018.05/aarch64-linux-gnu/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz

2.解压工具

可以放在其他位置,我放在home目录下:

/home$ tar -xvf gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz

3.下载源码

这里的网址来自官网,可以会更新,如果下载不了,需要去官网下载。

/home$ wget https://developer.download.nvidia.cn/embedded/L4T/r32_Release_v7.1/Sources/T210/public_sources.tbz2

4.解压源码

/home$ sudo tar -xjf public_sources.tbz2

5.进入源码目录

/home$ cd Linux_for_Tegra/source/public/

6.解压kernel

/home/Linux_for_Tegra/source/public$ tar -xjf kernel_src.tbz2

7.安装工具

/home/Linux_for_Tegra/source/public$ sudo apt install build-essential bc

8.设置内核输出目录

这里我把内核输出目录设置在了home下的kernel_out

/home/Linux_for_Tegra/source/public$ TEGRA_KERNEL_OUT=/home/kernel_out

9.设置交叉编译工具的环境变量

/home/Linux_for_Tegra/source/public$ export CROSS_COMPILE=/home/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-

10.设置环境变量

这一步必须加

/home/Linux_for_Tegra/source/public$ export LOCALVERSION=-tegra

11.进入内核目录

/home/Linux_for_Tegra/source/public$ cd kernel/kernel-4.9/

12.新建内核输出目录

/home/Linux_for_Tegra/source/public/kernel/kernel-4.9$ mkdir -p $TEGRA_KERNEL_OUT

13.生成config文件

/home/Linux_for_Tegra/source/public/kernel/kernel-4.9$ make ARCH=arm64 O=$TEGRA_KERNEL_OUT tegra_defconfig

14.编译内核

/home/Linux_for_Tegra/source/public/kernel/kernel-4.9$ make ARCH=arm64 O=$TEGRA_KERNEL_OUT

内核编译完成以后会在设置的输出目录下生成Image文件TEGRA_KERNEL_OUT/arch/arm64/boot/Image

以及DTB

TEGRA_KERNEL_OUT/arch/arm64/boot/dts/

注意:遇到的坑! 在ubuntu下,如果在解压或者编译的时候提示没有权限,然后如果使用sudo指令,就会在最后一步14,提示编译错误!错误的log如下:LSE atomics not supported by binutils
arch/arm64/Makefile:49: LSE atomics not supported by binutils
  CHK     include/config/kernel.release
  Using /home/Linux_for_Tegra/source/public/kernel/kernel-4.9 as source for kernel
  GEN     ./Makefile
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CC      kernel/bounds.s
gcc: error: unrecognized command line option ‘-mlittle-endian’; did you mean ‘-fconvert=little-endian’?
/home/Linux_for_Tegra/source/public/kernel/kernel-4.9/./Kbuild:20: recipe for target 'kernel/bounds.s' failed
make[2]: *** [kernel/bounds.s] Error 1
/home/Linux_for_Tegra/source/public/kernel/kernel-4.9/Makefile:1167: recipe for target 'prepare0' failed
make[1]: *** [prepare0] Error 2
make[1]: Leaving directory '/home/kernel_out'
Makefile:171: recipe for target 'sub-make' failed
make: *** [sub-make] Error 2

这是因为使用sudo没有root权限所致,所以在以上步骤的时候,需要获取root权限后操作,并且严格按照上面操作,需要添加sudo的地方添加,没有的地方不要加!!!

我在官网提交的以及官方的回复:

LSE atomics not supported by binutils - Jetson Nano - NVIDIA Developer Forums

另外,如果使用ubuntu远程登录默认root是不开放的,需要手动开放root登录:

1.设置密码

sudo passwd root

2.修改文件

sudo vi /etc/ssh/sshd_config 

,找到 #Authentication,将 PermitRootLogin 参数修改为 yes。如果 PermitRootLogin 参数被注释,请去掉首行的注释符号(#)如果没有就手动添加。如下图所示:
 

找到 #Authentication,将 PasswordAuthentication 参数修改为 yes。如下图所示:若 sshd_config 配置文件中无此配置项,则添加 PasswordAuthentication yes 项即可。

 退出保存。

然后重启ssh服务:

sudo service ssh restart
 二、根文件系统及烧录 1.下载示例文件系统和驱动包

进入home目录:cd ~

下载文件:

root@VM-12-5-ubuntu:~# wget https://developer.download.nvidia.cn/embedded/L4T/r32_Release_v7.1/T210/Tegra_Linux_Sample-Root-Filesystem_R32.7.1_aarch64.tbz2​​​​​​

下载: L4TDriver Package

root@VM-12-5-ubuntu:~# wget https://developer.download.nvidia.cn/embedded/L4T/r32_Release_v7.1/T210/Jetson-210_Linux_R32.7.1_aarch64.tbz2

2. 解压驱动包

root@VM-12-5-ubuntu:~# tar -xjf Jetson-210_Linux_R32.7.1_aarch64.tbz2

解压出来会有一个文件名字为 Linux_for_Tgera的文件夹;

3.进入rootfs目录

root@VM-12-5-ubuntu:~# cd Linux_for_Tgera/rootfs

这时roofs是空的。

4.将示例文件系统解压

root@VM-12-5-ubuntu:~/Linux_for_Tegra/rootfs# sudo tar -jxpf ../../Tegra_Linux_Sample-Root-Filesystem_R32.7.1_aarch64.tbz2

现在rootfs已经装好了文件系统。

5.运行脚本


root@VM-12-5-ubuntu:~/Linux_for_Tegra/rootfs# cd ..
root@VM-12-5-ubuntu:~/Linux_for_Tegra# sudo ./apply_binaries.sh

运行apply_binary .sh脚本将NVIDIA用户空间库复制到目标文件系统中。

注意,这里有可能出现ERROR qemu not found! 的问题,需要安装一下工具:

sudo apt-get install qemu-user-static

6.替换Image文件


root@VM-12-5-ubuntu:~/Linux_for_Tegra# cp /home/kernel_out/arch/arm64/boot/Image kernel/Image


7.替换DTB文件

root@VM-12-5-ubuntu:~/Linux_for_Tegra# cp -r /home/kernel_out/arch/arm64/boot/dts/ kernel/dtb/

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/880742.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号