参考链接:https://blog.csdn.net/weixin_30699955/article/details/95149298?utm_medium=distribute.pc_feed_404.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase&depth_1-utm_source=distribute.pc_feed_404.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecas
安装vmwaretool:先点击虚拟机的安装VNwaretool,然后将压缩文件复制到home目录下解压:
sudo tar -xzf VMwareTools-10.0.0-2977863.tar.gz
sudo ./vmware-install.pl
sudo apt-get remove vim-common #更新vi编辑器
sudo apt-get install vim
sudo apt-get install git
安装vscode(以后驱动编写用):
下载:https://code.visualstudio.com/docs/?dv=linux64_deb
sudo dpkg -i code_1.47.3-1595520028_amd64.deb
输入code命令即可启动VScode程序
下载链接:https://releases.linaro.org/components/toolchain/binaries/latest-7/aarch64-linux-gnu/
#安装交叉编译器:
sudo mkdir /usr/local/arm
sudo cp gcc-linaro-7.5.0-2019.12-i686_aarch64-linux-gnu.tar /usr/local/arm/ -f
sudo tar -vxf gcc-linaro-7.5.0-2019.12-i686_aarch64-linux-gnu.tar
sudo vi /etc/profile
#复制这行到文本最后一行:export PATH=$PATH:/usr/local/arm/gcc-linaro-7.5.0-2019.12-i686_aarch64-linux-gnu/bin
#安装依赖库:
sudo apt-get install lsb-core lib32stdc++6
git clone https://github.com/ARM-software/arm-trusted-firmware.git
git clone https://github.com/rockchip-linux/rkbin.git -b stable-4.4-rk3399-linux
git clone https://github.com/rockchip-linux/rkdeveloptool.git
sudo apt-get install libudev-dev libusb-1.0-0-dev dh-autoreconf
autoreconf -i
./configure
make
sudo make install
参考链接:
rkdeveloptool官方教程:http://opensource.rock-chips.com/wiki_Rkdeveloptool
系统分区地址表:可通过gdisk命令对分区做相应的设置
sudo git clone https://github.com/rockchip-linux/u-boot.git -b stable-4.4-rk3399-linux #下载u-boot源码
cd u-boot #进入u-boot
sudo apt install python-pip
pip install pyelftools
make clean #清理工程
#这里使用的firefly的开发板,所以选择firefly-rk3399_defconfi
make firefly-rk3399_defconfig ARCH=arm CROSS_COMPILE=aarch64-linux-gnu- #编译生成.config文件,注意arch为arm而非arm64。
make ARCH=arm CROSS_COMPILE=aarch64-linux-gnu- # 编译源码
#将/rkbin/bin/rk33/rk3399_ddr_800MHz_v1.24.bin复制到u-boot目录下
cd ..
cp ./rkbin/bin/rk33/rk3399_ddr_800MHz_v1.24.bin ./u-boot/
cp ./rkbin/bin/rk33/rk3399_miniloader_v1.19.bin ./u-boot/
cd u-boot
tools/mkimage -n rk3399 -T rksd -d rk3399_ddr_800MHz_v1.24.bin idbloader.img
cat rk3399_miniloader_v1.19.bin >> idbloader.img
cd ..
cd rkbin
./tools/boot_merger ./RKBOOT/RK3399MINIALL.ini
cd rkbin
./tools/trust_merger ./RKTRUST/RK3399TRUST.ini
cd u-boot #进入u-boot目录
tools/loaderimage --pack --uboot u-boot.bin uboot.img
将RK3399的OTG接口与电脑相连,并使其进入Loader模式或则maskrom模式。
cp ./rkbin/trust.img ./u-boot/
cd u-boot
sudo rkdeveloptool db rk3399_loader_v1.24.126.bin
sudo rkdeveloptool ul rk3399_loader_v1.24.126.bin
sudo rkdeveloptool wl 0x4000 uboot.img
sudo rkdeveloptool wl 0x6000 trust.img
sudo rkdeveloptool rd
将内存卡插入读卡器,将读卡器插上电脑。
cp ./rkbin/trust.img ./u-boot/
cd u-boot
sudo dd if=idbloader.img of=/dev/sdb seek=64
sudo dd if=uboot.img of=/dev/sdb seek=16384
sudo dd if=trust.img of=/dev/sdb seek=24576
参考链接:
官方教程:http://opensource.rock-chips.com/wiki_Boot_option
Linux的GPT分区表:http://opensource.rock-chips.com/wiki_Partitions
#下载源码:
sudo git clone https://github.com/rockchip-linux/kernel.git -b stable-4.4-rk3399-linux
sudo apt-get install libssl-dev
sudo apt-get install genext2fs
将源码arch/arm64/boot/dts/rockchip/rk3399-linux.dtsi中的
chosen {
bootargs = "earlycon=uart8250,mmio32,0xff1a0000 swiotlb=1 console=ttyFIQ0 rw root=PARTUUID=614e0000-0000 rootfstype=ext4 rootwait";
};
修改为
chosen {
bootargs = "earlycon=uart8250,mmio32,0xff1a0000 swiotlb=1 console=ttyFIQ0 rw root=PARTUUID=B921B045-1D rootfstype=ext4 rootwait";
};
make clean
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- rockchip_linux_defconfig
#编译内核,这个过程需要很久,而且期间电脑较卡
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j2
mkdir boot
cp arch/arm64/boot/dts/rockchip/rk3399-firefly-linux.dtb boot/rk3399.dtb
cp arch/arm64/boot/Image boot/
mkdir boot/extlinux
vi boot/extlinux/extlinux.conf
#在文档中写如:
label rockchip-kernel-4.4
kernel /Image
fdt /rk3399.dtb
append earlycon=uart8250,mmio32,0xff1a0000 root=PARTUUID=B921B045-1D rootwait rootfstype=ext4 init=/sbin/init
#执行下面命令生成boot_rk3399.img
genext2fs -b 32768 -B $((32*1024*1024/32768)) -d boot/ -i 8192 -U boot_rk3399.img
烧写内核:
sudo dd if=boot_rk3399.img of=/dev/sdb seek=32768
sync
启动u-boot进入命令模式:
gpt write mmc 0 $partitions #此处根据启动方式修改0或1
gpt verify mmc 0 $partitions
参考链接:
官方教程:http://opensource.rock-chips.com/wiki_Rockchip_Kernel
Linux内核官方源码:https://www.kernel.org/
瑞芯微内核官方源码:https://github.com/rockchip-linux/kernel
GPT分区表(需要墙):https://en.wikipedia.org/wiki/GUID_Partition_Table
#下载源码:在此网页http://cdimage.ubuntu.com/ubuntu-base/releases/16.04.6/release/下载 ubuntu-base-16.04.6-base-arm64.tar.gz
mkdir raw-rootfs
sudo tar -xpf ubuntu-base-16.04.6-base-arm64.tar.gz -C raw-rootfs/
sudo apt-get install qemu-user-static
sudo cp /usr/bin/qemu-aarch64-static ./raw-rootfs/usr/bin/
sudo cp /etc/resolv.conf raw-rootfs/etc/resolv.conf
修改源./raw-rootfs/etc/apt/sources.list为:
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-security main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-updates main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-backports main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-security main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-updates main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-backports main multiverse restricted universe
编写挂载脚本:
touch mount.sh
sudo chmod +x mount.sh
#!/bin/bash
mnt() {
echo "MOUNTING"
sudo mount -t proc /proc ${2}proc
sudo mount -t sysfs /sys ${2}sys
sudo mount -o bind /dev ${2}dev
sudo mount -o bind /dev/pts ${2}dev/pts
sudo chroot ${2}
}
umnt() {
echo "UNMOUNTING"
sudo umount ${2}proc
sudo umount ${2}sys
sudo umount ${2}dev/pts
sudo umount ${2}dev
}
if [ "$1" == "-m" ] && [ -n "$2" ] ;
then
mnt $1 $2
elif [ "$1" == "-u" ] && [ -n "$2" ];
then
umnt $1 $2
else
echo ""
echo "Either 1'st, 2'nd or both parameters were missing"
echo ""
echo "1'st parameter can be one of these: -m(mount) OR -u(umount)"
echo "2'nd parameter is the full path of rootfs directory(with trailing '/')"
echo ""
echo "For example: ch-mount -m /media/sdcard/"
echo ""
echo 1st parameter : ${1}
echo 2nd parameter : ${2}
fi
挂载系统:
source mount.sh -m raw-rootfs/
卸载系统:首先退出系统
exit
source mount.sh -u raw-rootfs/
挂载系统后:
source mount.sh -m raw-rootfs/
apt upgrade
apt install sudo language-pack-en-base ssh net-tools ethtool ifupdown iputils-ping htop vim kmod network-manager xorg make udhcpc gcc g++ sudo
安装ftp服务:
sudo apt-get install vsftpd
sudo vi /etc/vsftpd.conf
local_enable=YES
write_enable=YES
sudo /etc/init.d/vsftpd restart
用户设置:
chmod +w /etc/sudoers #在root用户下添加权限
vi /etc/sudoers
添加用户:
useradd -s '/bin/bash' -m -G adm,sudo tgm
passwd tgm #给新用户设置密码
passwd root #给root用户设置密码
exit
source mount.sh -u raw-rootfs/
制作根文件系统映像:
dd if=/dev/zero of=linuxroot.img bs=1M count=1024 #根据自己的根文件系统大小分配
sudo mkfs.ext4 linuxroot.img
mkdir rootfs
sudo mount linuxroot.img rootfs/
sudo cp -rfp raw-rootfs/* rootfs/
sudo umount rootfs/
e2fsck -p -f linuxroot.img
resize2fs -M linuxroot.img
烧录根文件系统:
sudo dd if=linuxroot.img of=/dev/sdb seek=262144
在系统正确加载后执行扩展文件系统命令:
sudo resize2fs /dev/sdb5
参考链接:
参考博客教程:https://blog.csdn.net/sements/article/details/105240490?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-5.nonecase&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-5.nonecase
Ubuntu官方源码:http://cdimage.ubuntu.com/ubuntu-base/releases/16.04.6/release/
u-boot:
内核: