• Linux内核打实时补丁preempt_rt


     

     补丁下载

    内核代码

    root@Ubuntu-riscv64:/usr/src/linux-5.14# head Makefile 
    # SPDX-License-Identifier: GPL-2.0
    VERSION = 5
    PATCHLEVEL = 14
    SUBLEVEL = 0
    EXTRAVERSION =
    NAME = Opossums on Parade
    http://ftp.ntu.edu.tw/pub/linux/kernel/projects/rt/5.14/
     
     
     
    at Makefile  | head
    # SPDX-License-Identifier: GPL-2.0
    VERSION = 5
    PATCHLEVEL = 14
    SUBLEVEL = 0
    EXTRAVERSION =
    NAME = Opossums on Parade

    tar -xvf patches-5.14.2-rt21.tar.xz

    root@Ubuntu-riscv64:~# uname -a
    Linux Ubuntu-riscv64 5.14.0-rt21 #1 SMP PREEMPT Thu Oct 14 10:27:33 CST 2021 riscv64 riscv64 riscv64 GNU/Linux
    root@Ubuntu-riscv64:/usr/src/linux-5.14# cat include/config/kernel.release
    5.14.0-rt21
    root@Ubuntu-riscv64:/usr/src/linux-5.14# 

    打补丁

    由于解压出来补丁有200多个patch, 在内核目录下借用脚本合并补丁

    linux-5.14$ ls patches/series 
    patches/series
    linux-5.14$ ls patches/series 
    patches/series
    cat patch.sh 
    #!/bin/sh
    cat ./patches/series | while read line
    do
                patch -p1 < ./patches/$line
    done

    交叉编译

    交叉编译
    make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- menuconfig
    make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- -j
    cat include/config/kernel.release
    5.14.0-rt21
    0

     

    0

     

    linux-5.14$ ls arch/riscv/boot/ -al
    total 26624
    drwxrwxr-x  3 ubuntu ubuntu     4096 Oct 14 10:29 .
    drwxrwxr-x 10 ubuntu ubuntu     4096 Oct 14 10:27 ..
    drwxrwxr-x  5 ubuntu ubuntu     4096 Aug 30 06:04 dts
    -rw-rw-r--  1 ubuntu ubuntu       83 Aug 30 06:04 .gitignore
    -rwxrwxr-x  1 ubuntu ubuntu 27421184 Oct 14 10:29 Image
    -rw-rw-r--  1 ubuntu ubuntu      151 Oct 14 10:29 .Image.cmd
    -rw-rw-r--  1 ubuntu ubuntu  8707892 Oct 14 10:29 Image.gz
    -rw-rw-r--  1 ubuntu ubuntu      101 Oct 14 10:29 .Image.gz.cmd
    -rw-rw-r--  1 ubuntu ubuntu     1561 Aug 30 06:04 install.sh
    -rw-rw-r--  1 ubuntu ubuntu      206 Aug 30 06:04 loader.lds.S
    -rw-rw-r--  1 ubuntu ubuntu      143 Aug 30 06:04 loader.S
    -rw-rw-r--  1 ubuntu ubuntu     1852 Aug 30 06:04 Makefile

    Generating Kernel modules

    linux-5.14$ make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu-  modules_install INSTALL_MOD_PATH=./modules_install
     INSTALL modules_install/lib/modules/5.14.0-rt21/kernel/sound/usb/line6/snd-usb-podhd.ko
      INSTALL modules_install/lib/modules/5.14.0-rt21/kernel/sound/usb/line6/snd-usb-toneport.ko
      INSTALL modules_install/lib/modules/5.14.0-rt21/kernel/sound/usb/line6/snd-usb-variax.ko
      INSTALL modules_install/lib/modules/5.14.0-rt21/kernel/sound/usb/misc/snd-ua101.ko
      DEPMOD  ./modules_install/lib/modules/5.14.0-rt21
    tar -cvf  5.14.0-rt21.tar  modules_install/lib/modules/5.14.0-rt21

     buildroot

    git clone https://gitee.com/mirrors/buildroot.git
    Cloning into 'buildroot'...
    remote: Enumerating objects: 556, done.
     make qemu_riscv64_virt_defconfig
    mkdir -p /root/buildroot-2021.08.1/output/build/buildroot-config/lxdialog
    PKG_CONFIG_PATH="" make CC="/usr/bin/gcc" HOSTCC="/usr/bin/gcc" \
    make menuconfig
    mkdir -p /root/buildroot-2021.08.1/output/build/buildroot-config/lxdialog

    make -j 128

    modules are missing:

    
    

    ExtUtils::MakeMaker

     

    yum install -y perl-ExtUtils-MakeMaker

    configure: error: you should not run configure as root (set FORCE_UNSAFE_CONFIGURE=1 in environment to bypass this check)
    See `config.log' for more details
    make: *** [/root/buildroot-2021.08.1/output/build/host-tar-1.34/.stamp_configured] Error 1
    [root@centos7 buildroot-2021.08.1]# export FORCE_UNSAFE_CONFIGURE=1
    [root@centos7 buildroot-2021.08.1]# make -j 128

    生成

    ln -snf /root/buildroot /output/host/riscv64-buildroot-linux-uclibc/sysroot /root/buildroot-2021.08.1/output/staging
    >>>   Executing post-image script board/qemu/post-image.sh
    You have new mail in /var/spool/mail/root
    [root@centos7 buildroot-]# 
    [root@centos7 buildroot-]# ls buildroot-/output/
    ls: cannot access buildroot-/output/: No such file or directory
    [root@centos7 buildroot ]# ls output/images/
    fw_dynamic.bin  fw_dynamic.elf  fw_jump.bin  fw_jump.elf  rootfs.ext2  rootfs.tar  start-qemu.sh
    [root@centos7 buildroot-]# file output/images/rootfs.ext2 
    output/images/rootfs.ext2: Linux rev 1.0 ext2 filesystem data, UUID=f782840d-9251-495d-b646-32800af3ca12 (large files)
    [root@centos7 buildroot ]# file output/images/rootfs.tar 
    output/images/rootfs.tar: POSIX tar archive
    [root@centos7 buildroot-]# 

    sd卡

    root@ :~# ls data1/
    boot.scr.uimg                       Image_git_GPIO_initramfs_rebuil  Image_l2.gz        sifive_5.14.gz
    extlinux                            Image.gz                         Image_nol2.gz      System Volume Information
    hifive-unleashed-a00-microsemi.dtb  Image_hotplug_initramfs          Image_only_git.gz
    
     
    ls data2
    bin  boot  dev  etc  home  lib  lost+found  media  mnt  proc  run  sbin  sys  tmp  usr  var

     留下lost+found

    ~/data2# rm -rf bin  boot  dev  etc  home  lib media  mnt  proc  run  sbin  sys  tmp  usr  var
    ls
    lost+found
    ~/data2# ls
    lost+found  rootfs.tar
    tar xvf rootfs.tar 
    ~/data2# ls
    bin  etc  lib64    lost+found  mnt  proc  rootfs.tar  sbin  tmp  var
    dev  lib  linuxrc  media       opt  root  run         sys   usr
    cat data1/extlinux/extlinux.conf 
    default OpenEmbedded
    label OpenEmbedded-SiFive-HiFive-Unleashed
       kernel /sifive_5.14.gz
       fdt /hifive-unleashed-a00-microsemi.dtb
    append root=/dev/mmcblk0p4 rootfstype=ext4 rootwait console=ttySIF0,115200 earlycon=sbi

     启动

    deleting routers
    [   13.578454] random: mktemp: uninitialized urandom read (6 bytes read)
    adding dns 192.168.8.17
    adding dns 192.168.8.18
    OK
    
    Welcome to Buildroot
    buildroot login: root
    # ls
    # pwd
    /root
    # ls -al
    total 12
    drwx------    2 root     root          4096 Jan  1 00:01 .
    drwxr-xr-x   18 root     root          4096 Oct 14  2021 ..
    -rw-------    1 root     root            14 Jan  1 00:01 .ash_history
    # uname -a
    Linux buildroot 5.14.0-rt21 #1 SMP PREEMPT Thu Oct 14 10:27:33 CST 2021 riscv64 GNU/Linux
    # 

     采用buildroot构建的系统不能使用 yum apt等

    # apt-get  -y install lrzsz
    -sh: apt-get: not found
    # cat /etc/os-release 
    NAME=Buildroot
    VERSION=2021.08.1
    ID=buildroot
    VERSION_ID=2021.08.1
    PRETTY_NAME="Buildroot 2021.08.1"
    # 

    RISC-V Ubuntu Rootfs from scratch

    As the root filesystem, you can choose between downloading a pre-built Debian or Ubuntu or build the rootfs yourself.

    The pre-built Debian tarball can be downloaded with: wget -O rootfs.tar.bz2 https://github.com/carlosedp/riscv-bringup/releases/download/v1.0/debian-sid-riscv64-rootfs-20200108.tar.bz2.

    The pre-built Ubuntu Focal tarball can be downloaded with: wget -O rootfs.tar.bz2 https://github.com/carlosedp/riscv-bringup/releases/download/v1.0/UbuntuFocal-riscv64-rootfs.tar.gz.

    If you want to build a Debian rootfs from scratch, check this guide.

    阿里镜像下载

    基本镜像(debian-base) http://mirrors.aliyun.com/thead/images/riscv64-ice/debian-rootfs.ext4.gz 59MB
    开发镜像 (debian-dev) http://mirrors.aliyun.com/thead/images/riscv64-ice/debian-dev-rootfs.ext4.gz 197MB
    xfce 桌面(debian-desktop) http://mirrors.aliyun.com/thead/images/riscv64-ice/debian-desktop-rootfs.ext4.gz
    Installing new version of config file /etc/xdg/virt-builder/repos.d/libguestfs.conf ...
    Setting up libguestfs-xfs:arm64 (1:1.44.1-1ubuntu3) ...
    Processing triggers for initramfs-tools (0.130ubuntu3.8) ...
    update-initramfs: Generating /boot/initrd.img-5.5.19-050519-generic
    Warning: couldn't identify filesystem type for fsck hook, ignoring.
    Processing triggers for libc-bin (2.33-0ubuntu5) ...
    W: APT had planned for dpkg to do more than it reported back (21 vs 25).
       Affected packages: udev:arm64
    root@cloud:~/risc_ubuntu# dpkg -l |grep uuid 
    ii  libuuid1:arm64                             2.36.1-7ubuntu2                         arm64        Universally Unique ID library
    ii  uuid-dev:arm64                             2.36.1-7ubuntu2                         arm64        Universally Unique ID library - headers and static libraries
    ii  uuid-runtime                               2.31.1-0.4ubuntu3.3                     arm64        runtime components for the Universally Unique ID library
    root@cloud:~/risc_ubuntu# 
    安装libuuid库
    libuuid是一个跨平台的开源的uuid操作库。一般的机器上默认是没有,先安装一下。
    
    执行:sudo apt-get install uuid-dev
    
    然后再执行:sudo apt-get -f install 就成功了
    root@cloud:~/risc_ubuntu# chroot temp-rootfs /bin/bash
    groups: cannot find name for group ID 0
    I have no name!@cloud:/# 
    I have no name!@cloud:/# ls
    bin  boot  debootstrap  dev  etc  home  lib  proc  root  run  sbin  sys  tmp  usr  var
    I have no name!@cloud:/#
    /debootstrap/debootstrap --second-stage
    apt-get install --no-install-recommends -y util-linux haveged openssh-server systemd kmod initramfs-tools conntrack ebtables ethtool iproute2 iptables mount socat ifupdown iputils-ping vim dhcpcd5 neofetch sudo chrony
    > LABEL=rootfs/ext4user_xattr,errors=remount-ro01
    > EOF^C
    I have no name!@cloud:/# cat >/etc/fstab <<EOF
    > LABEL=rootfs / ext4 user_xattr,errors=remount-ro 0 1
    > EOF
    I have no name!@cloud:/# echo "Ubuntu-riscv64" > /etc/hostname
    I have no name!@cloud:/# echo "root:riscv" | chpasswd
    I have no name!@cloud:/# sed -i "s/#PermitRootLogin.*/PermitRootLogin yes/g" /etc/ssh/sshd_config
    I have no name!@cloud:/# rm -rf /var/cache/apt/
    I have no name!@cloud:/# exit
    exit
    root@cloud:~/risc_ubuntu# 

    总结

    # Install pre-reqs
    sudo apt install debootstrap qemu qemu-user-static binfmt-support dpkg-cross --no-install-recommends
    
    # Generate minimal bootstrap rootfs
    sudo debootstrap --arch=riscv64 --foreign hirsute ./temp-rootfs http://ports.ubuntu.com/ubuntu-ports
    
    # chroot to it and finish debootstrap
    sudo chroot temp-rootfs /bin/bash
    
    /debootstrap/debootstrap --second-stage
    
    # Add package sources
    cat >/etc/apt/sources.list <<EOF
    deb http://ports.ubuntu.com/ubuntu-ports hirsute main restricted
    
    deb http://ports.ubuntu.com/ubuntu-ports hirsute-updates main restricted
    
    deb http://ports.ubuntu.com/ubuntu-ports hirsute universe
    deb http://ports.ubuntu.com/ubuntu-ports hirsute-updates universe
    
    deb http://ports.ubuntu.com/ubuntu-ports hirsute multiverse
    deb http://ports.ubuntu.com/ubuntu-ports hirsute-updates multiverse
    
    deb http://ports.ubuntu.com/ubuntu-ports hirsute-backports main restricted universe multiverse
    
    deb http://ports.ubuntu.com/ubuntu-ports hirsute-security main restricted
    deb http://ports.ubuntu.com/ubuntu-ports hirsute-security universe
    deb http://ports.ubuntu.com/ubuntu-ports hirsute-security multiverse
    EOF
    
    # Install essential packages
    apt-get update
    apt-get install --no-install-recommends -y util-linux haveged openssh-server systemd kmod initramfs-tools conntrack ebtables ethtool iproute2 iptables mount socat ifupdown iputils-ping vim dhcpcd5 neofetch sudo chrony
    
    # Create base config files
    mkdir -p /etc/network
    cat >>/etc/network/interfaces <<EOF
    auto lo
    iface lo inet loopback
    
    auto eth0
    iface eth0 inet dhcp
    EOF
    
    cat >/etc/resolv.conf <<EOF
    nameserver 1.1.1.1
    nameserver 8.8.8.8
    EOF
    
    cat >/etc/fstab <<EOF
    LABEL=rootfs / ext4 user_xattr,errors=remount-ro 0 1
    EOF
    
    echo "Ubuntu-riscv64" > /etc/hostname
    
    # Disable some services on Qemu, 这两步不需要
    #ln -s /dev/null /etc/systemd/network/99-default.link
    #ln -sf /dev/null /etc/systemd/system/serial-getty@hvc0.service
    
    # Set root passwd
    echo "root:riscv" | chpasswd
    
    sed -i "s/#PermitRootLogin.*/PermitRootLogin yes/g" /etc/ssh/sshd_config
    
    # Clean APT cache and debootstrap dirs
    rm -rf /var/cache/apt/
    
    # Exit chroot
    exit
    sudo tar -cSf Ubuntu-Hippo-rootfs.tar -C temp-rootfs .
    gzip Ubuntu-Hippo-rootfs.tar
    rm -rf temp-rootfs

    登陆

    root@Ubuntu-riscv64:~# 
    root@Ubuntu-riscv64:~# 
    root@Ubuntu-riscv64:~# 
    root@Ubuntu-riscv64:~# ls
    root@Ubuntu-riscv64:~# 
    root@Ubuntu-riscv64:~# ls /r
    ls: cannot access '/r': No such file or directory
    root@Ubuntu-riscv64:~# ls /
    bin   dev  home  lost+found  mnt  proc  run   srv  tmp  var
    boot  etc  lib   media       opt  root  sbin  sys  usr
    root@Ubuntu-riscv64:~# 
    root@Ubuntu-riscv64:~# uname -a
    Linux Ubuntu-riscv64 5.14.0-rt21 #1 SMP PREEMPT Thu Oct 14 10:27:33 CST 2021 riscv64 riscv64 riscv64 GNU/Linux
    root@Ubuntu-riscv64:~# 

    Read-only file system

    root@Ubuntu-riscv64:~# touch txt.txt
    touch: cannot touch 'txt.txt': Read-only file system
    root@Ubuntu-riscv64:/# touch txt.txt
    touch: cannot touch 'txt.txt': Read-only file system
    root@Ubuntu-riscv64:/# mount -o remount,rw /
    mount: /: can't find LABEL=rootfs.
    root@Ubuntu-riscv64:/# touch txt.txt        
    touch: cannot touch 'txt.txt': Read-only file system
    root@Ubuntu-riscv64:/#  blkid
    /dev/mmcblk0p3: SEC_TYPE="msdos" LABEL_FATBOOT="boot" LABEL="boot" UUID="48B8-EE4D" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="boot" PARTUUID="eb771f44-4547-416d-82f5-619de5c0ffae"
    /dev/mmcblk0p4: LABEL="root" UUID="eede8079-01cd-46d1-995f-50185ef3888d" BLOCK_SIZE="4096" TYPE="ext4" PARTLABEL="root" PARTUUID="88cd64c7-cd99-4d8a-a833-2d3441319154"
    /dev/mtdblock0: PTUUID="05a48cfd-119d-59c4-8c6a-d76e8de6a289" PTTYPE="gpt"
    /dev/mmcblk0p1: PARTLABEL="primary" PARTUUID="5a8d762e-3f43-44ef-8afa-f1b71512b988"
    /dev/mmcblk0p2: PARTLABEL="primary" PARTUUID="306f5864-1122-4f55-9b04-9b1149f6568e"
    root@Ubuntu-riscv64:/# 
    LABEL="root,label错误了
    更改
    /etc/fstab 
     
    root@Ubuntu-riscv64:~# touch txt.txt
    root@Ubuntu-riscv64:~# cat /etc/fstab 
    LABEL=root /  ext4 noatime,lazytime,rw 0 1
    root@Ubuntu-riscv64:~# 
     

    可以rw的build rootfs

    cat etc/fstab 
    # <file system> <mount pt>      <type>  <options>       <dump>  <pass>
    /dev/root       /               ext2    rw,noauto       0       1
    proc            /proc           proc    defaults        0       0
    devpts          /dev/pts        devpts  defaults,gid=5,mode=620,ptmxmode=0666   0       0
    tmpfs           /dev/shm        tmpfs   mode=0777       0       0
    tmpfs           /tmp            tmpfs   mode=1777       0       0
    tmpfs           /run            tmpfs   mode=0755,nosuid,nodev  0       0
    sysfs           /sys            sysfs   defaults        0       0

    Key exchange failed.

    No compatible key exchange method. The server supports these methods: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256

    KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1

    yum -y install gcc automake autoconf libtool make

     You don't have enough free space in /var/cache/apt/archives/

    解决办法:

    清除所有已下载的过期安装包

    sudo apt-get autoclean

    清除所有已下载的安装包

    sudo apt-get clean

    虚拟机环境下Ubuntu主机硬盘较小,清理缓存仍空间不足。
    解决办法:在虚拟机软件中增加Ubuntu主机硬盘空间,并在Ubuntu Disks中增大实际使用的硬盘大小。

    root@Ubuntu-riscv64:/# df -lh
    Filesystem      Size  Used Avail Use% Mounted on
    /dev/root       6.3G  5.9G   16M 100% /
    tmpfs           3.9G     0  3.9G   0% /dev/shm
    tmpfs           1.6G  1.4M  1.6G   1% /run
    tmpfs           5.0M     0  5.0M   0% /run/lock
    tmpfs           4.0M     0  4.0M   0% /sys/fs/cgroup
    tmpfs           796M     0  796M   0% /run/user/0

    W: Download is performed unsandboxed as root as file '/var/cache/apt/archives/partial/perl-base_5.32.1-3ubuntu2.1_riscv64.deb' couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied)

    chmod 755 / 解决它。
    root@Ubuntu-riscv64:~# chmod 755 /
    root@Ubuntu-riscv64:~#

    修改/dev/shm的大小

    root@Ubuntu-riscv64:~# df -lh
    Filesystem      Size  Used Avail Use% Mounted on
    /dev/root       6.3G  5.0G  990M  84% /
    tmpfs           3.9G     0  3.9G   0% /dev/shm
    tmpfs           1.6G  1.4M  1.6G   1% /run
    tmpfs           5.0M     0  5.0M   0% /run/lock
    tmpfs           4.0M     0  4.0M   0% /sys/fs/cgroup
    tmpfs           796M     0  796M   0% /run/user/0

    修改/etc/fstab的这行

    root@Ubuntu-riscv64:~# cat /etc/fstab 
    LABEL=root /  ext4 noatime,lazytime,rw 0 1
    none      /dev/shm        tmpfs   defaults,size=1024M        0 0
    root@Ubuntu-riscv64:~# mount -o remount /dev/shm
    root@Ubuntu-riscv64:~# df -lh
    Filesystem      Size  Used Avail Use% Mounted on
    /dev/root       6.3G  5.0G  990M  84% /
    tmpfs           1.0G     0  1.0G   0% /dev/shm
    tmpfs           1.6G  1.4M  1.6G   1% /run
    tmpfs           5.0M     0  5.0M   0% /run/lock
    tmpfs           4.0M     0  4.0M   0% /sys/fs/cgroup
    tmpfs           796M     0  796M   0% /run/user/0
    root@Ubuntu-riscv64:~# df -lh
    Filesystem      Size  Used Avail Use% Mounted on
    /dev/root       6.3G  5.0G  990M  84% /
    tmpfs           1.0G     0  1.0G   0% /dev/shm
    tmpfs           1.6G  1.4M  1.6G   1% /run
    tmpfs           5.0M     0  5.0M   0% /run/lock
    tmpfs           4.0M     0  4.0M   0% /sys/fs/cgroup
    tmpfs           796M     0  796M   0% /run/user/0
    root@Ubuntu-riscv64:~# 
    root@Ubuntu-riscv64:/usr/src/linux-5.14# mount -o remount /run
    root@Ubuntu-riscv64:/usr/src/linux-5.14# df -lh
    Filesystem      Size  Used Avail Use% Mounted on
    /dev/root       6.3G  5.3G  703M  89% /
    tmpfs           256M     0  256M   0% /dev/shm
    tmpfs           256M  1.4M  255M   1% /run
    tmpfs           5.0M     0  5.0M   0% /run/lock
    tmpfs           4.0M     0  4.0M   0% /sys/fs/cgroup
    tmpfs           796M     0  796M   0% /run/user/0
    root@Ubuntu-riscv64:/usr/src/linux-5.14# cat /etc/fstab 
    LABEL=root /  ext4 noatime,lazytime,rw 0 1
    none      /dev/shm        tmpfs   defaults,size=256M        0 0
    none      /run        tmpfs   defaults,size=256M        0 0
    root@Ubuntu-riscv64:/usr/src/linux-5.14# 

      scripts/basic/fixdep: Exec format error

    root@Ubuntu-riscv64:/usr/src/linux-5.14# make scripts
      SYNC    include/config/auto.conf.cmd
      HOSTCC  scripts/kconfig/conf.o
    /bin/sh: 1: scripts/basic/fixdep: Exec format error
    make[2]: *** [scripts/Makefile.host:112: scripts/kconfig/conf.o] Error 126
    make[2]: *** Deleting file 'scripts/kconfig/conf.o'
    make[1]: *** [Makefile:625: syncconfig] Error 2
    Makefile:712: include/config/auto.conf.cmd: No such file or directory
    make: *** [Makefile:735: include/config/auto.conf.cmd] Error 2

    include/config/kernel.release

    root@Ubuntu-riscv64:/usr/src/linux-5.14# find ./ -name kernel.release
    root@Ubuntu-riscv64:/usr/src/linux-5.14# make include/config/kernel.release
      SYNC    include/config/auto.conf.cmd
      HOSTCC  scripts/kconfig/conf.o
      HOSTLD  scripts/kconfig/conf
      UPD     include/config/kernel.release
    root@Ubuntu-riscv64:/usr/src/linux-5.14# find ./ -name kernel.release
    ./include/config/kernel.release
    root@Ubuntu-riscv64:/usr/src/linux-5.14# 

    make asm-generic

    Re: Question about "asm/rwonce.h: No such file or directory"
    root@Ubuntu-riscv64:/usr/src/linux-5.14# make asm-generic
      WRAP    arch/riscv/include/generated/asm/early_ioremap.h
      WRAP    arch/riscv/include/generated/asm/extable.h
      WRAP    arch/riscv/include/generated/asm/flat.h
      WRAP    arch/riscv/include/generated/asm/kvm_para.h
      WRAP    arch/riscv/include/generated/asm/user.h
      WRAP    arch/riscv/include/generated/asm/vmlinux.lds.h
      WRAP    arch/riscv/include/generated/asm/bugs.h
      WRAP    arch/riscv/include/generated/asm/checksum.h
      WRAP    arch/riscv/include/generated/asm/compat.h
      WRAP    arch/riscv/include/generated/asm/device.h
      WRAP    arch/riscv/include/generated/asm/div64.h
      WRAP    arch/riscv/include/generated/asm/dma-mapping.h
      WRAP    arch/riscv/include/generated/asm/dma.h
      WRAP    arch/riscv/include/generated/asm/emergency-restart.h
      WRAP    arch/riscv/include/generated/asm/exec.h
      WRAP    arch/riscv/include/generated/asm/fb.h
      WRAP    arch/riscv/include/generated/asm/hardirq.h
      WRAP    arch/riscv/include/generated/asm/hw_irq.h
      WRAP    arch/riscv/include/generated/asm/irq_regs.h
      WRAP    arch/riscv/include/generated/asm/kmap_size.h
      WRAP    arch/riscv/include/generated/asm/local.h
      WRAP    arch/riscv/include/generated/asm/local64.h
      WRAP    arch/riscv/include/generated/asm/msi.h
      WRAP    arch/riscv/include/generated/asm/percpu.h
      WRAP    arch/riscv/include/generated/asm/preempt.h
      WRAP    arch/riscv/include/generated/asm/serial.h
      WRAP    arch/riscv/include/generated/asm/shmparam.h
      WRAP    arch/riscv/include/generated/asm/simd.h
      WRAP    arch/riscv/include/generated/asm/softirq_stack.h
      WRAP    arch/riscv/include/generated/asm/topology.h
      WRAP    arch/riscv/include/generated/asm/trace_clock.h
      WRAP    arch/riscv/include/generated/asm/unaligned.h
      WRAP    arch/riscv/include/generated/asm/vga.h
      WRAP    arch/riscv/include/generated/asm/xor.h
    root@Ubuntu-riscv64:/usr/src/linux-5.14# make asm-generic
      WRAP    arch/riscv/include/generated/asm/rwonce.h

    generated/bounds.h: No such file or directory

    ./include/linux/page-flags-layout.h:6:10: fatal error: generated/bounds.h: No such file or directory
        6 | #include <generated/bounds.h>

    原因:bounds.h是在编译内核时生成的,类似于编译产生的.o文件,如果你运行

    "make clean" or "make distclean",这个文件就会被清除掉(详情查看内核Makefile)。因此,如果再利用此内核源码编译内核模块,如果有涉及bounds.h,就会出现找不到该文件的错误。

    解决:独立内核目录之外编译模块时,要确保makefile文件中所定义的内核源代码树已经make过一遍,且没有make  clean。这样就不会清除生成的bound.h头文件,这个文件是生成模块必须的。

    或者"make prepare"

    这样就会重新生成bounds.h,搞定了!

    root@Ubuntu-riscv64:/usr/src/linux-5.14# make prepare
      UPD     include/generated/timeconst.h
      CC      arch/riscv/kernel/asm-offsets.s
      UPD     include/generated/asm-offsets.h
      CALL    scripts/checksyscalls.sh
      CALL    scripts/atomic/check-atomics.sh
    
    root@Ubuntu-riscv64:/usr/src/linux-5.14# find ./ -name bounds.h
    ./include/generated/bounds.h
    root@Ubuntu-riscv64:/usr/src/linux-5.14# 

    No rule to make target 'scripts/module.lds

    root@Ubuntu-riscv64:/usr/src/linux-5.14# make modules_prepare
      CALL    scripts/checksyscalls.sh
      CALL    scripts/atomic/check-atomics.sh
      LDS     scripts/module.lds
    root@Ubuntu-riscv64:/usr/src/linux-5.14# find ./ -name module.lds
    ./scripts/module.lds

    modules_install: missing 'System.map' file. Skipping depmod.

    ERROR: could not fstatat(/lib/modules/5.14.0-rt21, modules.dep): No such file or directory

    Warning: modules_install: missing 'System.map' file. Skipping depmod.
    make[1]: Leaving directory '/usr/src/linux-5.14'
    depmod -A
    depmod: ERROR: could not fstatat(/lib/modules/5.14.0-rt21, modules.dep): No such file or directory
    depmod: WARNING: could not open modules.order at /lib/modules/5.14.0-rt21: No such file or directory
    depmod: WARNING: could not open modules.builtin at /lib/modules/5.14.0-rt21: No such file or directory

    root@Ubuntu-riscv64: # ls /lib/modules/5.14.0-rt21/modules.
    modules.alias              modules.builtin.bin        modules.devname            modules.symbols.bin
    modules.alias.bin          modules.dep                modules.softdep            
    modules.builtin.alias.bin  modules.dep.bin            modules.symbols            
    root@Ubuntu-riscv64:~ # ls /lib/modules/5.14.0-rt21/modules.de
    modules.dep      modules.dep.bin  modules.devname  
    root@Ubuntu-riscv64:~ # ls /lib/modules/5.14.0-rt21/modules.de
    ls /lib/modules/5.14.0-rt21/modules.*
    /lib/modules/5.14.0-rt21/modules.alias              /lib/modules/5.14.0-rt21/modules.dep.bin
    /lib/modules/5.14.0-rt21/modules.alias.bin          /lib/modules/5.14.0-rt21/modules.devname
    /lib/modules/5.14.0-rt21/modules.builtin.alias.bin  /lib/modules/5.14.0-rt21/modules.softdep
    /lib/modules/5.14.0-rt21/modules.builtin.bin        /lib/modules/5.14.0-rt21/modules.symbols
    /lib/modules/5.14.0-rt21/modules.dep                /lib/modules/5.14.0-rt21/modules.symbols.bin
    ls  /lib/modules/`uname -r`
              modules.builtin.alias.bin  modules.dep.bin  modules.symbols
    modules.alias      modules.builtin.bin        modules.devname  modules.symbols.bin
    modules.alias.bin  modules.dep                modules.softdep

     运行
    cd  /lib/modules/`uname -r` && depmod -a

    root@Ubuntu-riscv64:/lib/modules/5.14.0-rt21#  depmod -a
    depmod: WARNING: could not open modules.order at /lib/modules/5.14.0-rt21: No such file or directory
    depmod: WARNING: could not open modules.builtin at /lib/modules/5.14.0-rt21: No such file or directory

     CONFIG_LTO

    Due to recent bug fixes in the toolchain, it's recommended to use clang
    5.0 or later, and GNU gold from binutils 2.27 or later, although older
    versions may also work depending on your kernel configuration. Here are
    the steps for compiling arm64 defconfig with LTO, assuming LLVMgold.so is
    in LD_LIBRARY_PATH and the rest of the toolchain is in PATH:
    
      $ make ARCH=arm64 defconfig
      $ ./scripts/config -e LTO_CLANG
      $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- CC=clang

     ls ./arch/riscv/include/asm/

    RISC-V Ubuntu Rootfs from scratch

    Generating Kernel modules

    Flashing to the SD Card

    Creating disk image

    Linux内核打实时补丁preempt_rt

    RISC-V ICE EVB 开发板 linux环境下烧写更新开发板镜像

  • 相关阅读:
    今天是元旦啊
    [待解决]python 函数加括号和不加括号的区别
    Jupyter Notebook的快捷键列表误操作发现的新大陆
    Series选择和过滤
    做鸢尾花切片练习中的'&'问题:(&,|)和(and,or)
    报错合集
    关于随机数种子seed的问题尽量使用numpy下的seed
    pandas创建Series序列/hashable
    在jupyter notebook中插入截图
    xml反序列化时,如何生成与之对应的类文件
  • 原文地址:https://www.cnblogs.com/dream397/p/15405600.html
Copyright © 2020-2023  润新知