How to Build Debian This procedure describes how to create a Debian SD Card image for LEC-PX30 with Industrial I-Pi SMARC. The version of Debian used is 10 (buster). Recommended HardwareTo setup the build environment for Debian image creation, a Linux host with the following configuration is recommended. A host machine with adequate processing power and disk space is ideal as the packages can run several GBs in size and the build can take a lot of time. Intel Core-i7 processor (>= 4 cores) 8 GB RAM 1 TB disk space High speed network connectivity OS: Ubuntu 16.04 LTS/Ubuntu 18.04 LTS Update apt repositories list on your host machine. $ sudo apt update Install kernel and u-boot dependencies. $ sudo apt-get install git-core gnupg flex bison gperf build-essential zip curlzlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-devx11proto-core-dev libx11-dev lib32z1-dev ccache libgl1-mesa-dev libxml2-utilsxsltproc unzip device-tree-compiler liblz4-tool libssl-dev Install buildroot dependencies. $ sudo apt-get install libfile-which-perl sed make binutils gcc g++ bash patch gzipbzip2 perl tar cpio python unzip rsync file bc libmpc3 git repo texinfo pkg-config cmaketree texinfo Getting StartedThe procedure below replaces the buildroot rootfs with the Debian one. Step 1: Create a Debian root file system. Step 2: Generate Buildroot SD Card Image. Step 3: Flash Buildroot SD card image to the prepared SD card by using SD Firmware Tool. Step 4: Replace the buidroot rootfs image with Debian’s one on BuildRoot SD Card image. These steps are detailed below. Step 1: Preparing Debian Root File System Create a new working directory and change directory into it. $ mkdir $HOME/px30$ cd $HOME/px30 Create a rootfs directory. $ mkdir rootfs Install debootsrap and it’s dependencies. $ sudo apt install debootstrap binfmt-support qemu-user-static $ sudo debootstrap --arch=arm64 --include=sudo,net-tools,isc-dhcp-client --foreign buster rootfs Add required apt repositories to sources.list. $ sudo bash -c "printf 'deb http://deb.debian.org/debian buster main contrib non-free\ndeb-src http://deb.debian.org/debian buster main contrib non-free\n\ndeb http://deb.debian.org/debian-security buster/updates main contrib non-free\ndeb-src http://deb.debian.org/debian-security buster/updates main contrib non-free\n\ndeb http://deb.debian.org/debian buster-updates main contrib non-free\ndeb-src http://deb.debian.org/debian buster-updates main contrib non-free\n\ndeb http://deb.debian.org/debian buster-backports main contrib non-free\ndeb-src http://deb.debian.org/debian buster-backports main contrib non-free\n' > rootfs/etc/apt/sources.list" Configure the Rootfs Add host name to /etc/hostname Here is an example. $ sudo bash -c "echo 'adlink' > rootfs/etc/hostname" Add host entry in /etc/hosts $ sudo bash -c "printf '127.0.0.1\tlocalhost\n127.0.1.1\tadlink\n\n' > rootfs/etc/hosts" $ sudo bash -c "echo 'root::0:0:root:/root:/bin/bash' > rootfs/etc/passwd" Prepare QEMU $ sudo wget https://github.com/multiarch/qemu-user-static/releases/download/v4.2.0-6/qemu-aarch64-static -O rootfs/usr/bin/qemu-aarch64-static$ sudo chmod +x rootfs/usr/bin/qemu-aarch64-static Get your network ready $ sudo cp /etc/resolv.conf rootfs/etc/ Mount the proc sys dev file systems $ for f in proc sys dev dev/pts; do sudo mount --bind /$f rootfs/$f; done Change root. $ sudo chroot rootfs /bin/bash Add user name $ /debootstrap/debootstrap --second-stage$ apt install sudo net-tools isc-dhcp-client$ adduser px30 (provide new password and name for the user in the prompt)$ usermod -a -G sudo px30 Install the required tools or utilities $ apt update$ apt install vim git sudo net-tools ifupdown kmod iputils-ping man wget bash-completion alsa-utils apt-utils usbutils i2c-tools netplan.io vnc4server lm-sensors build-essential cmake can-utils mesa-utils blueman locales Configure locales You will be prompted through GUI menu to make certain selections such as those for date/time/region. Please make the appropriate selections and proceed. $ dpkg-reconfigure locales Install xfce desktop $ apt install task-xfce-desktop Exit from chroot $ sync$ exit Add I/O Drivers to Rootfs- Ethernet & CAN Bus Create a directory to copy the Ethernet and CAN kernel modules $ sudo mkdir $HOME/px30/rootfs/home/px30/rockchip_test Please click here to download and copy smsc9500.ko, smscusbnet.ko and mcp25xxfd.ko kernel modules into rockchip_test folder from host PC. $ sudo cp <your_path>/*.ko $HOME/px30/rootfs/home/px30/rockchip_test/ - Audio Please click here to download asound.state file and copy to /var/lib/alsa/ $ sudo cp asound.state $HOME/px30/rootfs/var/lib/alsa/ - WiFi/Bluetooth Download the rtl_bt.zip file from here and extract. Copy the rtl_bt folder which has Bluetooth firmware to file system. $ sudo mkdir $HOME/px30/lib/firmware$ sudo cp -r rtl_bt/ $HOME/px30/lib/firmware Unmount the mounted fie systems. $ for f in proc sys dev/pts dev; do sudo umount rootfs/$f; done Remove emulator and resolv.conf file. $ sudo rm rootfs/usr/bin/qemu-aarch64-static rootfs/etc/resolv.conf - IMX219 cameraDownload the imx219_camera.tar file from here and extract and copy the binaries, applications and libraries to respective folders: $ mkdir $HOME/camera$ tar -xvf imx219_camera.tar -C $HOME/camera/$ sudo cp -r $HOME/camera/usr/ $HOME/px30/rootfs/$ sudo cp -r $HOME/camera/etc $HOME/px30/rootfs/$ sudo rm $HOME/px30/rootfs/lib/aarch64-linux-gnu/libm.so.6$ sudo cp $HOME/camera/libm.so.6 $HOME/px30/rootfs/lib/aarch64-linux-gnu/ - Enable I/O Interfaces Please click here to download and copy Load.sh file to the rockchip_testfolder. Note: It is shell script to insert modules on every reboot $ sudo cp Load.sh $HOME/px30/rootfs/home/adlink/rockchip_test/Load.sh Give execute permissions to script. $ sudo chmod +x $HOME/px30/rootfs/home/adlink/rockchip_test/Load.sh Please click here to download and copy rc.local to temp/etc/ $ sudo cp rc.local $HOME/px30/rootfs/etc/ Give executable permissions. $ sudo chmod +x $HOME/px30/rootfs/etc/rc.local - Adding MRAA Download the adlink-mraa-master.tar file from here and extract and copy the binaries, applications and libraries to respective folders: $ mkdir $HOME/mraa$ sudo mkdir $HOME/px30/rootfs/usr/lib/pkgconfig$ tar -xvf adlink-mraa-master.tar -C $HOME/mraa/$ sudo cp -r $HOME/mraa/usr/bin/* $HOME/px30/rootfs/usr/bin/$ sudo cp -r $HOME/mraa/usr/include/* $HOME/px30/rootfs/usr/include/$ sudo cp -r $HOME/mraa/usr/lib/libmraa.so* $HOME/px30/rootfs/usr/lib/$ sudo cp -r $HOME/mraa/usr/lib/pkgconfig/mraa.pc $HOME/px30/rootfs/usr/lib/pkgconfig/$ sudo cp -r $HOME/mraa/usr/share/* $HOME/px30/rootfs/usr/share/ - Adding libMALI Download Debian_libMALI_Integration.zip file from here and extract libMALI files to rootfs: $ cd $HOME$ unzip Debian_libMALI_Integration.zip$ cd $HOME/Debian_libMALI_Integration$ sudo tar -axf xserver.tar.xz -C $HOME/px30/rootfs/$ sudo tar -axf libmali.tar.xz -C $HOME/px30/rootfs/$ sudo tar -axf librga.tar.xz -C $HOME/px30/rootfs/$ sudo tar -axf glmark2-es2.tar.xz -C $HOME/px30/rootfs/ Step 2: Generating Buildroot SD Card ImageDownload LEC-PX30 Buildroot SDK and extract it. Note: Use iPIsmarc-es2 branch and root for creating custom images for SD card. Use git branch command under px30_buildroot/kernel to check the branch version. Change directory to px30_buildroot. $ cd px30_buildroot Run build script. $ sudo ./build.sh After you run “./build.sh”, a menuconfig screen will appear as shown below. Select “Exit” as shown below. If you dont see the menuconfig screen, install ncurses$ yum install ncurses-devel ncurses The image will be generated as “update.img” under rockdev folder and will be used in SD Card. Step 3: Flashing Buildroot Image to SD CardFlash image (generated in step 2) to the prepared SD card by using SD Firmware Tool (this tool is executed in Windows environment). Note: Before going to flash image to SD card, format it. The size should be at least 8 Gb. Download the Rufus tool from (https://filehippo.com/download_rufus/) Use Rufus to prepare a bootable SD card. Run Rufus as a administrator. A warning appears which says all the data will be erased in SD card, click yes to continue the image is sucessfully booted into SD Card Step 4: Replacing Buildroot Rootfs with Debian RootfsAfter finishing step 3, get your SD card to connect to the development Linux host PC . Unmount the mounted partitions $ sudo umount /dev/sdc* Note: In our case, ‘/dev/sdc ‘ is SD card device name Run GParted by using command line $ sudo gparted Note: GParted is a free partition editor for graphically managing your disk partitions. Please check this link. Select SD card as highlighted in above corner in below picture Select partition 9 and give right click, then select delete Save the changes and select apply After changes are applied, select close. Select the root fs partition and select resize option above. Partition 8 (/dev/sdc8) is the rootfs partition in below picture. Increase the size and select Resize/Move option Save the changes and select apply Close GParted and eject SD card. Also connect your SD Card to the development Linux host PC. Run lsblk command to get the path for mounted rootfs partition. Remove the existing contents as this file system is the default build root file system. $ sudo rm -rf <mount_path>/*$ sync For example, the required partition is sdc8 here with path /media/nhcpc20011/ac09cb0f-0d9b-4441-902c-bf48b1f10127/ Run the following commands to copy the contents of the Debian rootfs.img to the SD card. $ sudo cp -rfp $HOME/px30/rootfs/* <mount_path>/$ sync Eject the SD card. You can directly insert SD card and power on the system to boot using the SD card. After boot, login to px30 user using password set in adduser command.