0%

OrangePi-3B 折腾笔记(五)—— 统一编译环境

编译环境

  • 主板: OrangePi-3b
  • 芯片: RK3566
  • 环境: Debian(12-x86_64) + Docker(Debian:12)

内容说明

搞了这么久,U-BootKernelRootFS 这三大件基本已经搞出来了,接下来的目标就是适配各种特殊硬件。

比如我给这个香橙派配了一个屏幕,使用 MIPI 接口的。目前还是点不亮的,接下来就是来适配这个。

这一篇文章主要是记录一下之前使用到的编译环境,方便今后快速调用。

镜像脚本

FROM debian:12

RUN \
sed -e 's|deb.debian.org|mirrors.tuna.tsinghua.edu.cn|g' -i.bak /etc/apt/sources.list.d/debian.sources && \
apt update && \
apt install -y sudo wget curl vim bash-completion git && \
apt clean &&  rm -rf /var/lib/apt/lists/*

RUN \
apt update && \
# toolchain
apt install -y make gcc gcc-arm-linux-gnueabi gcc-aarch64-linux-gnu && \
# make menuconfig
apt install -y libncurses-dev && \
# u-boot
apt install -y bc bison flex swig libssl-dev python3 python3-dev python3-setuptools python3-pyelftools python3-cryptography && \
# u-boot rockchip
apt install -y device-tree-compiler && \
ln -s /bin/python3 /bin/python2 && \
ln -s /bin/python3 /bin/python && \
# kernel
apt install -y flex bison bc libssl-dev cpio && \
# kernel rockchip
apt install -y u-boot-tools && \
# rootfs
apt install -y debootstrap binfmt-support qemu-user-static u-boot-tools initramfs-tools android-sdk-libsparse-utils e2fsprogs file fdisk gdisk parted && \
\
apt clean &&  rm -rf /var/lib/apt/lists/*

ENV TZ=Asia/Shanghai
RUN \
useradd --create-home --uid 1000 --groups sudo --shell /bin/bash user && \
echo "user:password" | chpasswd  && \
ln -snf /usr/share/zoneinfo/${TZ} /etc/localtime && \
echo "${TZ}" > /etc/timezone

USER user
WORKDIR /home/user/
RUN \
echo "alias ll='ls -lh -F --color=auto --time-style=long-iso'" >> ~/.bash_aliases && \
echo "alias la='ls -lhA -F --color=auto --time-style=long-iso'" >> ~/.bash_aliases && \
echo "alias lt='ls -lht -F --color=auto --time-style=long-iso'" >> ~/.bash_aliases && \
echo "alias lat='ls -lhAt -F --color=auto --time-style=long-iso'" >> ~/.bash_aliases

镜像编译

docker build . -t linux-build

镜像使用

docker run -ti --rm \
    \
    -v ~/projects/rkbin/:/projects/rkbin/ \
    -v ~/projects/u-boot/:/projects/u-boot/ \
    \
    -v ~/projects/kernel/:/projects/kernel/ \
    \
    --privileged \
    -v ~/projects/rootfs-build/:/projects/buildfs/ \
    \
    linux-build bash