소스에서 BSP 빌드
Modalix Linux 커널, U-Boot 및 디바이스 트리를 직접 빌드한 다음, 결과물을 보드에 설치합니다. 이 문서의 모든 내용은 공개 저장소를 사용하므로 NDA나 영업 문의가 필요하지 않습니다.
시작하기 전에
-
빌드용 Ubuntu 22.04 호스트.
-
Docker Engine 설치.
-
qemu-user-static설치:sima-user@sima-user-machine:~$ sudo apt install qemu-user-static
빌드한 결과물을 설치하려면, 루트 권한으로 접근할 수 있고 컨테이너에서 네트워크로
연결할 수 있으며 eMMC(mmcblk0으로 인식됨)에서 부팅된 eLxr 이미지 실행 보드도
필요합니다.
빌드 컨테이너 설정
SDK 컨테이너에는 대상 플랫폼용 툴체인, 헤더 및 라이브러리가 들어 있습니다. 아래
Dockerfile을 Dockerfile.modalix로 저장한 다음, 이 파일이 있는 디렉터리에서
이미지를 빌드하십시오. 이 Dockerfile은 릴리스 2.1.0용 SDK를 설정합니다.
Dockerfile.modalix
# Generated Dockerfile for modalix Build:release[2.1.0]
FROM debian:bookworm
# List of additional packages that are to be deployed in SDK sysroot
ARG SDK_PKG_LIST
ENV SDK_PKG_LIST="\
libgrpc-dev,\
protobuf-compiler-grpc,\
python3-pybind11,\
${SDK_PKG_LIST}"
RUN dpkg --add-architecture arm64
RUN dpkg --add-architecture arc
RUN dpkg --add-architecture armhf
RUN apt-get clean && \
apt-get update --allow-releaseinfo-change && \
apt-get install -y wget pip
RUN wget -qO - https://mirror.elxr.dev/elxr/public.gpg | gpg --dearmor -o /etc/apt/trusted.gpg.d/elxr.gpg
RUN wget -qO - https://packages.fluentbit.io/fluentbit.key | gpg --dearmor > /etc/apt/trusted.gpg.d/fluentbit.gpg
RUN wget --no-check-certificate -O - https://repo.sima.ai/elxr/deb/simaai.gpg | gpg --dearmor > /etc/apt/trusted.gpg.d/simaai.gpg
RUN chmod 644 /etc/apt/trusted.gpg.d/elxr.gpg
RUN chmod 644 /etc/apt/trusted.gpg.d/fluentbit.gpg
RUN echo "deb [signed-by=/etc/apt/trusted.gpg.d/elxr.gpg] https://mirror.elxr.dev/elxr aria main" > /etc/apt/sources.list.d/elxr.list
RUN echo "deb [signed-by=/etc/apt/trusted.gpg.d/fluentbit.gpg] https://packages.fluentbit.io/debian/bookworm bookworm main" >> /etc/apt/sources.list.d/elxr.list
RUN echo "deb [trusted=yes] https://repo.sima.ai/elxr/deb/release bookworm non-free #simaai repo" >> /etc/apt/sources.list.d/elxr.list
RUN apt-get update --allow-releaseinfo-change && \
apt-get install -y --no-install-recommends \
python3-apt-ostree \
vim \
make \
cmake \
gcc-aarch64-linux-gnu \
g++-aarch64-linux-gnu \
device-tree-compiler \
bison \
flex \
quilt \
zlib1g-dev \
bzip2 \
bc \
rsync \
kmod \
cpio \
git \
curl \
libssl-dev \
libgnutls28-dev \
openssh-client \
simaai-sdk-tools
RUN echo "Package: *" > /etc/apt/preferences.d/stable.pref
RUN echo "Pin: origin \"repo.sima.ai/elxr\"" >> /etc/apt/preferences.d/stable.pref
RUN echo "Pin-Priority: 999" >> /etc/apt/preferences.d/stable.pref
RUN export RUSTUP_HOME=/opt/toolchain/rust && export CARGO_HOME=/opt/toolchain/rust && \
mkdir -p ${RUSTUP_HOME} && curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > /tmp/rustup.sh && \
chmod 755 /tmp/rustup.sh && /tmp/rustup.sh -y && \
echo "export RUSTUP_HOME=${RUSTUP_HOME}" >> ${CARGO_HOME}/env && \
echo "export CARGO_HOME=${CARGO_HOME}" >> ${CARGO_HOME}/env && \
. ${CARGO_HOME}/env && rm /tmp/rustup.sh
RUN if uname -a | grep -q '#[0-9]*-Ubuntu'; then \
apt-get update --allow-releaseinfo-change; \
--privileged mount -t binfmt_misc binfmt_misc /proc/sys/fs/binfmt_misc || true; \
fi
RUN if [ "x86_64" = "x86_64" ]; then apt update --allow-releaseinfo-change && apt install \
arch-test -y; fi
RUN python3 /opt/bin/simaai_setup_sdk.py modalix 2.1.0 \
\
"${SDK_PKG_LIST}"
RUN echo "source /opt/bin/simaai-init-build-env modalix" >> /root/.bashrc
sima-user@sima-user-machine:~$ docker build -t modalix-sdk --file Dockerfile.modalix .
sysroot에 추가 패키지를 미리 로드하려면 쉼표로 구분한 목록을 전달하십시오.
sima-user@sima-user-machine:~$ docker build --build-arg SDK_PKG_LIST=libzix-dev,vxi-dev -t modalix-sdk --file Dockerfile.modalix .
쓰기 권한이 있는 디렉터리에서 컨테이너를 실행하십시오.
sima-user@sima-user-machine:~$ docker run -it --privileged -v $(pwd):/data -w /data -v /dev:/dev --pid=host modalix-sdk
sysroot는 /opt/toolchain/aarch64/<platform>에 있습니다. 빌드 환경은 실행 시
자동으로 설정됩니다. 직접 설정하려면
source /opt/bin/simaai-init-build-env modalix를 실행하십시오.
커널 빌드
컨테이너 내부에서 다음을 실행합니다.
root@sdk:/data$ git clone https://github.com/SiMa-ai/simaai-linux.git && cd simaai-linux
root@sdk:/data/simaai-linux$ git checkout <kernel-commit>
root@sdk:/data/simaai-linux$ make ARCH=arm64 simaai_modalix_defconfig
root@sdk:/data/simaai-linux$ make all -j8 ARCH=arm64 LOCALVERSION="-modalix" DTC_FLAGS=-@
<kernel-commit>을 릴리스 호환성에 나와 있는 해당
릴리스의 커널 커밋으로 바꾸십시오. master를 빌드하면 최신 릴리스가 빌드되며, 이는
보드의 이미지와 일치하지 않을 수 있습니다.
빌드 결과물은 다음과 같습니다.
| 아티팩트 | 경로 |
|---|---|
| 커널 이미지 | arch/arm64/boot/Image |
| 디바이스 트리 | arch/arm64/boot/dts/simaai/*.dtb |
디바이스 트리 오버레이 빌드(선택 사항)
오버레이 소스(.dtso)를 작성한 다음, 바이너리(.dtbo)로 컴파일합니다.
root@sdk:/data$ dtc -@ -I dts -O dtb -o imx415.dtbo imx415.dtso
커널 트리의 일부 카메라 오버레이처럼 #include를 사용하는 오버레이는 먼저 C 전처리기를
거쳐야 합니다. 커널 트리에서 다음을 실행합니다.
root@sdk:/data/simaai-linux$ aarch64-linux-gnu-cpp -nostdinc -I include -I arch/arm64/boot/dts/simaai/overlays -undef -x assembler-with-cpp my-overlay.dtso | dtc -@ -I dts -O dtb -o my-overlay.dtbo -
U-Boot 빌드
root@sdk:/data$ git clone https://github.com/SiMa-ai/sima-ai-uboot.git && cd sima-ai-uboot
root@sdk:/data/sima-ai-uboot$ git checkout <u-boot-commit>
root@sdk:/data/sima-ai-uboot$ make ARCH=arm64 simaai_modalix_debug_defconfig
root@sdk:/data/sima-ai-uboot$ make all u-boot-initial-env V=1
<u-boot-commit>을 릴리스 호환성에 나와 있는 해당
릴리스의 U-Boot 커밋으로 바꾸십시오. 생성되는 이미지는 u-boot.bin입니다.