Architecture aarch64 ubuntu20 root file system with ros robot operating system

1. Build the basic operating system

       1. Download the smallest ubuntu20 file system       

        wget http://cdimage.ubuntu.com/ubuntu-base/releases/20.04/release/ubuntu-base-20.04.5-base-arm64.tar.gz
        mkdir rootfs
        tar -xpf ubuntu-base-20.04.5-base -arm64.tar.gz -C rootfs
       2. Install qemu tools
        sudo apt-get install qemu-user-static
        cd rootfs
        cp /usr/bin/qemu-aarch64-static usr/bin/
        3. Configure DNS
        cp -b /etc /resolv.conf etc/resolv.conf
        4. Enter the basic system
        cd .. # Exit to the rootfs directory

        ./ch-mount.sh -m rootfs/

#!/bin/bash

function 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 chroot ${2}
}

function umnt() {
  echo "UNMOUNTING"
  sudo umount ${2}proc
  sudo umount ${2}sys
  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


       5.安装升级系统软件
        apt update
        apt upgrade
        apt install usbutils network-manager sudo fdisk vim nano openssh-server iputils-ping wget curl iproute2 dialog locales kmod zip unzip u-boot-tools initramfs-tools tcpdump statserial cutecom cpufrequtils modemmanager
        apt install wpasupplicant udhcpc htop pciutils
        apt install rsyslog udev dbus  systemd openssh-client dosfstools parted  git  sysstat less man
        apt install ubuntu-desktop-minimal
        apt install usbutils
        apt install apt-file usbutils openssh-server sudo fdisk vim iputils-ping wget curl iproute2        dialog locales kmod zip unzip cpufrequtils tcpdump statserial
        apt install wpasupplicant udhcpc  pciutils
        apt install rsyslog udev dbus  systemd openssh-client dosfstools parted  git  sysstat vim

        6. Install lxde light desktop
        apt install lxde
        apt-file update

        7.安装ROS1和ROS2
        sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
        1.ROS1:
        curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
        apt install ros-noetic-desktop-full
        mv /opt/ros ros-noetic
        2.ROS 2 :
        sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
        echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
        source ~/.bashrc
        echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(source /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
        source /opt/ros/foxy/setup.bash
        echo " source / opt/ros/foxy/setup.bash" >> ~/.bashrc
        apt install ros-foxy-desktop
        mv /opt/ros/ros-foxy
        3. To view the version of ros,
        first enter roscore in the terminal
        to open a new terminal, and then enter, rosparam list
        and enter rosparam get /rosdistro to get the version

2. Basic system configuration

        1. Add sudo user
        useradd -m fire -g sudo -s /bin/bash -d /home/fire
        passwd fire
        fire666

        2. Then there is the default non-sleep and password-free login

        gnome-terminal embedded in gnome-menu
        automatic login
        /etc/gdm3/custom.conf
        AutomaticLoginEnable=True
        AutomaticLogin=gaussian

        3. The solution to the problem of disappearing of the Ubuntu network setting wired         is to change [false] to [true]
        in /etc/NetworkManager/NetworkManager.conf , and then click [Save] on the upper right to exit the text editor.         touch /etc/NetworkManager/conf.d/10-globally-managed-devices.conf         service network-manager restart


       4. Delete deb packages that are no longer needed in the system
        sudo apt autoremove

        rm -rf  /root/.bash_history

        5. Package file system

         exit

        ./ch-mount.sh -u rootfs/

        tar -cvf ../rootfs.tar *

3. Make rootfs.img

        cd ..
        dd if=/dev/zero of=rootfs.img bs=2K count=3M
        mkfs.ext4 rootfs.img
        mount rootfs.img rootfs
        tar -xvf rootfs.tar -C rootfs

        If there is a kernel driver compiled as a module
        cp -rf lib/modules/ rootfs/lib/
        umount rootfs
        e2fsck -p -f rootfs.img
        resize2fs -M rootfs.img

Guess you like

Origin blog.csdn.net/yangwenchao1983/article/details/131760793