电脑系统盘出故障了,重新安装了Ubunt20.04(之前用的是18.04)。日常工作编译基于Rockchip和AM335x系列芯片的内核和U-boot比较多,所以先搭建它们的开发环境(包括并不限依赖的库和常用工具)并记录如下。
注:因为很多命令来自网络或官方文档,所以安装过程中可能重复安装某个工具或软件,无关大雅。
执行如下安装命令:
sudo apt-get update
sudo apt-get install flex -y
sudo apt-get install libssl-dev -y
sudo apt-get install liblz4-tool -y
sudo apt-get install genext2fs -y
sudo apt install byobu vim-gtk inetutils-ping net-tools wget cpio unzip rsync xz-utils -y
sudo apt install curl git tree -y
sudo apt install build-essential -y
sudo apt-get install openssh-server openssh-client -y
=============================================
下面要安装的工具的命令来自于Rockchip的文档:
sudo apt-get install repo git ssh make gcc libssl-dev liblz4-tool \
expect g++ patchelf chrpath gawk texinfo chrpath diffstat binfmt-support \
qemu-user-static live-build bison flex fakeroot cmake gcc-multilib g++-multilib \
unzip device-tree-compiler python-pip ncurses-dev pyelftools -y
直接执行遇到错误了:
…...
Reading state information... Done
Note, selecting 'libncurses-dev' instead of 'ncurses-dev'
Package python-pip is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
python3-pip
E: Unable to locate package repo
E: Package 'python-pip' has no installation candidate
E: Unable to locate package pyelftools
根据错误提示,对于找不到包的暂时不安装,先安装其他的,因此重新执行下面的命令:
sudo apt-get install git ssh make gcc libssl-dev liblz4-tool \
expect g++ patchelf chrpath gawk texinfo chrpath diffstat binfmt-support \
qemu-user-static live-build bison flex fakeroot cmake gcc-multilib g++-multilib \
unzip device-tree-compiler libncurses-dev -y
这次没有发现报错了。
安装npm:
sudo apt install npm
安装 NotePad++:
sudo snap install notepad-plus-plus
error: cannot perform the following tasks:
- 下载 snap "notepad-plus-plus" (367),来自频道 "stable" (Get https://canonical-lgw01.cdn.snapcraftcontent.com/download-origin/canonical-lgw01/155ZvKiCILXt4S5Ro8YZmzKHgNPPedVj_367.snap?interactive=1&token=1655298000_bf2a037c7c2dc6f8139356f186b9517091f016cb: read tcp 192.168.9.192:51620->185.125.190.26:443: read: connection reset by peer)
上面的安装方法失败了,尝试用下面的方法安装NotePad++:
sudo add-apt-repository ppa:notepadqq-team/notepadqq
sudo apt-get update
sudo apt-get install notepadqq
(这里报错日志忘记保存了)这次还是失败了,失败的原因是无法访问相应的源(虽然公司可以访问外网)。
新增阿里源后,再次安装就可以了。
===========================================
新增阿里源方法:https://developer.aliyun.com/article/699524?spm=a2c6h.17698244.wenzhang.5.477c29787wYskb
注:这里完全参考上面的文章来的,仅仅作了小小的改动。
首先查看自己的Ubuntu系统的Codename(别名/代号),这一步很重要,直接导致更新的源是否对系统起效果,查看方法:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.3 LTS
Release: 20.04
Codename: focal
虽然lsb_release输出了想要的东西,但是“No LSB modules are available.”却是标准错误输出。
解决:
sudo apt-get install lsb-core
安装后再次查看:
$ lsb_release -a
LSB Version: core-11.1.0ubuntu2-noarch:security-11.1.0ubuntu2-noarch
Distributor ID: Ubuntu
Description: Ubuntu 20.04.3 LTS
Release: 20.04
Codename: focal
因为我的系统是Ubunt 20.04,所以Codename是focal。
备份系统源:
cd /etc/apt
sudo cp sources.list sources.list_bak
这里为了方便直接以root账号(一般地,即使是个人电脑,都尽量不要切换到root账户执行命令)执行如下命令:
Codename=$( (lsb_release -a) | awk '{print $2}' | tail -n 1 )
echo "\
deb http://mirrors.aliyun.com/ubuntu/ $Codename main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ $Codename-backports main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ $Codename-proposed main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ $Codename-security main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ $Codename-updates main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ $Codename main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ $Codename-backports main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ $Codename-proposed main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ $Codename-security main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ $Codename-updates main multiverse restricted universe ">sources.list.2
然后将sources.list.2里面的内容复制到sources.list的末尾。
最后执行: sudo apt-get update
===========================================
# 前面安装repo失败了,下面继续安装:
先cd到家目录,然后执行:
$ mkdir files
上面新建一个目录的目的是以后下载的安装工具都保存在这里。非必须。
$ cd files/
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/files/repo
$ ls
repo
$ cp repo /usr/local/bin/repo
cp: cannot create regular file '/usr/local/bin/repo': Permission denied
$ sudo cp repo /usr/local/bin/repo
$ sudo chmod a+x /usr/local/bin/repo
测试:
$ repo init
/usr/bin/env: ‘python’: No such file or directory
失败了,提示没有python,但实际上,系统里面已经安装了python2和python3
在/usr/bin/目录下为python2创建软链:
sudo ln -s /usr/bin/python2 /usr/bin/python
再运行 repo init,这次没有报错了。
=============================================
Ubuntu 20.04 上安装 VMware,免破解
系统需要满足以下基本硬件要求:
i) 1.3GHz或更快的64位CPU
ii) 建议至少 4GB RAM 或更大
# 首先安装依赖
sudo apt update
sudo apt install build-essential linux-headers-generic -y
# 然后下载
wget --user-agent="Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0" https://www.vmware.com/go/getplayer-linux
# 最后安装
chmod +x getplayer-linux
sudo ./getplayer-linux --required --eulas-agreed
=============================================
# VMware安装的Windows虚拟机和主机(Ubuntu20.04)共享文件夹
sudo apt-get install samba -y
sudo apt-get install smbclient -y
# 创建共享目录
$ mkdir ~/share
# 使用如下命令打开配置文件,进行编辑samba配置文件
sudo gedit /etc/samba/smb.conf
# 在文件末尾追加如下内容:
[UBUNTU-SHARE]
comment = share
read only = no
locking = no
path = /home/xxx/share
guest ok = yes
# 其中的“path = /home/xxx/share”就是创建的共享目录,一定要是绝对路径!
# 重启服务
sudo systemctl restart smbd.service
# 查看状态是否OK
sudo systemctl status smbd.service
# 最后,需要在虚拟机中设置:点击“Virtual Machine" --> "Virtual Machine settings" --> "Options" --> "Shared folders", 然后在左边添加共享目录即可。
=============================================
AM335x 交叉编译工具安装
$ tar xzf poky-glibc-i686-core-image-sato-cortexa8hf-vfp-neon-toolchain-1.8.1.tar.gz
注:这里的工具是从同事那里直接拷贝的,请自行在网络上搜你的期望的工具。
ls
poky-glibc-i686-core-image-sato-cortexa8hf-vfp-neon-toolchain-1.8.1.sh poky-glibc-i686-core-image-sato-cortexa8hf-vfp-neon-toolchain-1.8.1.tar.gz
$ ./poky-glibc-i686-core-image-sato-cortexa8hf-vfp-neon-toolchain-1.8.1.sh
Enter target directory for SDK (default: /opt/poky/1.8.1):
You are about to install the SDK to "/opt/poky/1.8.1". Proceed[Y/n]?y
[sudo] password for xxx:
Extracting SDK...done
Setting it up...done
SDK has been successfully set up and is ready to be used.
$ ls /opt/poky/1.8.1/
environment-setup-cortexa8hf-vfp-neon-poky-linux-gnueabi site-config-cortexa8hf-vfp-neon-poky-linux-gnueabi sysroots version-cortexa8hf-vfp-neon-poky-linux-gnueabi
$ ls /opt/poky/1.8.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/bin/arm*-gcc
/opt/poky/1.8.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi/usr/bin/arm-poky-linux-gnueabi-gcc
# 编译脚本增加:
source /opt/poky/1.8.1/environment-setup-cortexa8hf-vfp-neon-poky-linux-gnueabi
export CROSS_COMPILE=arm-poky-linux-gnueabi-
到此,在我的机器上尝试编译am335x和RK3399的内核都成功了。如果你遇到错误,可以根据报错提示去解决。
######### 其他说明 #########
# arm-none-eabi:这个是没有操作系统的,自然不可能支持那些跟操作系统关系密切的函数,比如fork(2)。他使用的是newlib这个专用于嵌入式系统的C库。
# arm-none-linux-eabi:用于Linux的,使用Glibc
# arm-poky is the default compiler of yocto in linux for armv7, while gcc-arm is the compiler from gnu for embedded system
# 不同的交叉编译工具配置不同,比如之前编译用的交叉工具为:
# export CROSS_COMPILE=arm-none-linux-gnueabihf-
# export PATH=~/Desktop/latest_sdk/sdk_install/linux-devkit/sysroots/x86_64-arago-linux/usr/bin:$PATH
# Refer to : https://www.cnblogs.com/jzcn/p/14889438.html
# Refer to : https://blog.csdn.net/guodeqiangde/article/details/78239408
错误在所难免,欢迎指正,谢谢!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)