工作需要ubuntu2004的chroot开发环境,故这里记录搭建ubuntu2004的chroot环境。
如下:
mkdir iso && mount ubuntu-20.04.6-desktop-amd64.iso iso/ unsquashfs iso/casper/filesystem.squashfs umount iso && rm -rf iso
为了能够chroot的一些编译工作正常,更真实的模拟实际环境,这里需要和linux启动一致,挂载必要的文件系统如下:
vim 1-chroot #!/bin/bash CHROOT_DIR=/root/sdk/chroot/squashfs-root [ ! -d ${CHROOT_DIR} ] && exit cd ${CHROOT_DIR} mountpoint -q ./proc || mount -t proc proc ./proc mountpoint -q ./sys || mount -t sysfs sysfs ./sys mountpoint -q ./dev || mount -t devtmpfs devtmpfs ./dev mountpoint -q ./dev/pts || mount -t devpts devpts ./dev/pts chroot .
为了能够全局使用,可以放在/usr/local/sbin/下面
mv 1-chroot /usr/local/sbin/
到这里,chroot环境已经基本成型,下面需要针对这个chroot环境做一些易用的改动。
配置源之前先设置dns,这里是chroot环境,所以直接修改resolv.conf文件,这里以114为例
nameserver 114.114.114.114
然后修改源地址为国内,修改文件/etc/apt/sources.list如下
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted deb http://mirrors.aliyun.com/ubuntu/ focal universe deb http://mirrors.aliyun.com/ubuntu/ focal-updates universe deb http://mirrors.aliyun.com/ubuntu/ focal multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-updates multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted deb http://mirrors.aliyun.com/ubuntu/ focal-security universe deb http://mirrors.aliyun.com/ubuntu/ focal-security multiverse
最后update一下即可
为了避免reboot和一些低级操作,这里需要处理一下(在特殊情况下会生效),故如下
vim /etc/profile.d/chroot.sh hint_reboot(){ info="Forbidden reboot!" echo -e "\033[31m${info}\033[0m" } hint_poweroff(){ info="Forbidden poweroff!" echo -e "\033[31m${info}\033[0m" } hint_halt(){ info="Forbidden halt!" echo -e "\033[31m${info}\033[0m" } alias reboot='hint_reboot' alias poweroff='hint_poweroff' alias halt='hint_halt'
为了提示自己是在chroot环境中,修改bashrc如下:
vim /root/.bashrc # 1.修改TERM为xterm-color TERM=xterm-color cd source /etc/profile.d/chroot.sh # 2.修改\h为chroot 54 if [ "$color_prompt" = yes ]; then 55 # PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' 56 PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@chroot\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' 57 else 58 PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' 59 fi ......
基础开发环境包安装
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 ncurses-dev rsync gdb-multiarch \ openocd qemu-system-arm cargo doxygen apt-get install libgucharmap-2-90-dev bzip2 expat gpgv2 \ cpp-aarch64-linux-gnu libgmp-dev libmpc-dev bc python-is-python3 \ python2 libsqlite3-dev esmtp codespell python-ply mutt tig u-boot-tools \ meson ninja-build u-boot-tools build-essential devscripts breeze-dev \ debhelper extra-cmake-modules libcap-dev libxcb-composite0-dev \ libdrm-dev libgbm-dev libxcb-cursor-dev libxcb-damage0-dev \ libxcb-glx0-dev libxcb-randr0-dev libxcb-util-dev # 可能出现图形化服务器选择lightdm/gdm apt-get install libtool qtmultimedia5-dev \ libdbusmenu-qt5-dev libfcitx-qt5-dev libfcitx5-qt-dev \ libgsettings-qt-dev libkf5bluezqt-dev libkf5networkmanagerqt-dev \ liblightdm-qt5-3-dev libpolkit-qt5-1-dev libpoppler-qt5-dev \ libqt5charts5-dev libqt5opengl5-dev libqt5sensors5-dev \ libqt5svg5-dev libqt5texttospeech5-dev libqt5virtualkeyboard5-dev \ libqt5waylandclient5-dev libqt5webchannel5-dev libqt5webkit5-dev \ libqt5x11extras5-dev libqt5xdg-dev libqt5xdgiconloader-dev \ libqtav-dev libqtav-private-dev qt5-default qtbase5-dev \ qtbase5-dev-tools qtbase5-private-dev qtchooser \ qtconnectivity5-dev qtdeclarative5-dev qtdeclarative5-dev-tools \ qtdeclarative5-private-dev qtlocation5-dev qtmultimedia5-dev \ qtpositioning5-dev qtquickcontrols2-5-dev qtscript5-dev \ qttools5-dev qttools5-dev-tools qtwayland5-dev-tools \ qtwebengine5-dev qtwebengine5-private-dev libkdecorations2-dev \ libkf5xmlgui-dev libkf5crash-dev kscreenlocker-dev kinit-dev pkg-kde-tools
umount dev/pts dev proc sysfs && cd ..
tar cvzf ubuntu-2004-develop.tar.gz squashfs-root/
至此获得ubuntu-2004-develop.tar.gz是可用于x86的ubuntu2004的chroot
docker import ubuntu-2004-develop.tar.gz x86-ubuntu2004-dev:v1
这样docker内也能正常使用此环境
自己购买了RK3588S的firefly的开发板,这里记录firefly板子的sdk编译方法。
https://wiki.t-firefly.com/zh_CN/ROC-RK3588S-PC/linux_compile.html#huo-qu-sdk
firefly的gitlab仓库地址如下
repo init --no-clone-bundle --repo-url https://gitlab.com/firefly-linux/git-repo.git -u https://gitlab.com/firefly-linux/manifests.git -b master -m rk3588_linux_release.xml
这里拉取在我的环境会报错,主要如下
import importlib
str object has no attribute decode
然后继续运行,会出现如上错误,这里错误是没办法decode,
根据百度搜索可知,去掉git_config.py内的decode函数即可。
firefly的repo推荐使用python2 通过提示可知道,repo推荐你去使用python2,这里修改python为python2即可
ln -sf /usr/bin/python2 /usr/bin/python
跟着文档走,直接如下命令同步即可
.repo/repo/repo sync -c --no-tags
.repo/repo/repo start firefly --all
后续可以使用以下命令更新 SDK:
.repo/repo/repo sync -c --no-tags
这里默认分支用tag: rk3588/linux_release_v1.1.1d。需要主动切一下
注意uboot的make.sh,这里如果默认的CROSS_COMPILSE_ARM64变量有问题需要根据实际情况修改,如果没问题就无需修改 注意:编译uboot需要rkbin仓库,如没有rkbin仓库,则编译会因为无法编译miniloader而失败
-CROSS_COMPILE_ARM64=../prebuilts/gcc/linux-x86/aarch64/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- +# CROSS_COMPILE_ARM64=../prebuilts/gcc/linux-x86/aarch64/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- +CROSS_COMPILE_ARM64=YOUR_PATH/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
编译命令如下
make rk3588_defconfig firefly-linux.config && ./make.sh
编译完成之后,会生成如下文件
uboot.img rk3588_spl_loader_v1.11.112.bin
uboot通常不打开pcie的phy识别usb3.0,这里默认打开即可
diff --git a/configs/firefly-linux.config b/configs/firefly-linux.config index 503356b..3003d81 100644 --- a/configs/firefly-linux.config +++ b/configs/firefly-linux.config @@ -4,3 +4,4 @@ CONFIG_SPL_GPIO_SUPPORT=n CONFIG_DM_PCA953X=y CONFIG_SPL_FIT_IMAGE_KB=4096 CONFIG_CHECK_VERSION_CHOOSE_DTB=y +CONFIG_PHY_ROCKCHIP_NANENG_COMBOPHY=y
firefly的日志比较烦人,可以去掉
diff --git a/drivers/power/regulator/fixed.c b/drivers/power/regulator/fixed.c index 50d75c6..172eb56 100644 --- a/drivers/power/regulator/fixed.c +++ b/drivers/power/regulator/fixed.c @@ -108,7 +108,7 @@ static int fixed_regulator_set_enable(struct udevice *dev, bool enable) struct fixed_regulator_platdata *dev_pdata = dev_get_platdata(dev); int ret; - printf("Firefly %s: dev='%s', enable=%d, delay=%d, has_gpio=%d\n", __func__, + debug("%s: dev='%s', enable=%d, delay=%d, has_gpio=%d\n", __func__, dev->name, enable, dev_pdata->startup_delay_us, dm_gpio_is_valid(&dev_pdata->gpio)); /* Enable GPIO is optional */
uboot提示Bus usb@xxxxxxxx: usb maximum-speed not found 比较奇怪,可以显示指明usb3为super speed,其实默认就是super speed。感觉不舒服的可以去掉(强迫症)
diff --git a/arch/arm64/boot/dts/rockchip/rk3588-firefly-port.dtsi b/arch/arm64/boot/dts/rockchip/rk3588-firefly-port.dtsi index dc1afd6..523353b 100644 --- a/arch/arm64/boot/dts/rockchip/rk3588-firefly-port.dtsi +++ b/arch/arm64/boot/dts/rockchip/rk3588-firefly-port.dtsi @@ -315,4 +315,5 @@ &usbdrd_dwc3_0 { dr_mode = "otg"; status = "okay"; + maximum-speed = "super-speed"; }; diff --git a/arch/arm64/boot/dts/rockchip/roc-rk3588s-pc.dtsi b/arch/arm64/boot/dts/rockchip/roc-rk3588s-pc.dtsi index 40a6986..e49f5fa 100644 --- a/arch/arm64/boot/dts/rockchip/roc-rk3588s-pc.dtsi +++ b/arch/arm64/boot/dts/rockchip/roc-rk3588s-pc.dtsi @@ -221,6 +221,7 @@ &usbhost_dwc3_0 { status = "okay"; dr_mode = "host"; + maximum-speed = "super-speed"; }; &vcc5v0_host { @@ -228,7 +229,7 @@ /delete-property/ regulator-min-microvolt; /delete-property/ regulator-max-microvolt; reset-delay-us = <200000>; - startup-delay-us = <1200000>; + //startup-delay-us = <1200000>; regulator-boot-on; gpio = <&gpio1 RK_PB6 GPIO_ACTIVE_HIGH>; pinctrl-names = "default";
uboot阶段开机慢,这里regulator这里上电故意停了1.2S,去掉也不影响
diff --git a/arch/arm64/boot/dts/rockchip/roc-rk3588s-pc.dtsi b/arch/arm64/boot/dts/rockchip/roc-rk3588s-pc.dtsi index 40a6986..e49f5fa 100644 --- a/arch/arm64/boot/dts/rockchip/roc-rk3588s-pc.dtsi +++ b/arch/arm64/boot/dts/rockchip/roc-rk3588s-pc.dtsi &vcc5v0_host { @@ -228,7 +229,7 @@ /delete-property/ regulator-min-microvolt; /delete-property/ regulator-max-microvolt; reset-delay-us = <200000>; - startup-delay-us = <1200000>; + //startup-delay-us = <1200000>; regulator-boot-on; gpio = <&gpio1 RK_PB6 GPIO_ACTIVE_HIGH>; pinctrl-names = "default";
编译内核主要选择好了设备树和配置即可,rk3588s-roc-ps-v1.0的配置如下
export ARCH=arm64 export CROSS_COMPILE=aarch64-linux-gnu- make rockchip_linux_defconfig rk3588_linux.config firefly-linux.config make roc-rk3588s-pc-mipi101-M101014-BE45-A1.img -j8
值得注意的是,我的开发板并不需要mipi dsi显示和csi摄像头,所以设备树需要更换一下。