乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      zynq[3] bootstrap Ubuntu | hhuysqt

       奔跑的瓦力 2019-10-09

      Ubuntu、Debian之類的不同的發(fā)行版,其實(shí)就是不同的rootfs。Debian系的發(fā)行版有個(gè)工具叫debootstrap,可以從那里下載最小的根文件系統(tǒng)。Arch相應(yīng)的工具則是packstrap

      下完根文件系統(tǒng)之后chroot進(jìn)去進(jìn)行相應(yīng)的配置,為了chroot到一個(gè)ARM的rootfs,我們需要用qemu-arm-static。進(jìn)去之后apt-get你想要安裝的東西。配完了之后燒進(jìn)sd卡,通過(guò)內(nèi)核參數(shù)root=xxxx告訴內(nèi)核要掛載哪個(gè)rootfs,即可啟動(dòng)了。

      要制作一個(gè)叉叉派的鏡像都是這樣的套路:bootstrap一個(gè)最小系統(tǒng),安裝內(nèi)核模塊,安裝必要的應(yīng)用程序,然后安裝不同的桌面環(huán)境,最后打包。于是就制作出各種水果派的n多鏡像,像Ubuntu core、Ubuntu mate、xubuntu、lubuntu、Debian,Arch等等,應(yīng)有盡有。。

      然而這些大型發(fā)行版的“最小系統(tǒng)”都相當(dāng)?shù)拇?,幾百兆的樣子,而我們的EBAZ4205只有128M的nand flash,所以只好從sd卡啟動(dòng)才能維持得了生活。

      準(zhǔn)備工作

      我們先在一臺(tái)Ubuntu主機(jī)上安裝qemu-user-staticdebootstrap,然后繼續(xù)。后文一些命令如果沒(méi)有安裝,隨時(shí)apt-get一下。

      準(zhǔn)備鏡像文件

      我們dd一個(gè)3.7G的空白鏡像,這樣可以燒錄進(jìn)一個(gè)標(biāo)明4G的SD卡。姑且叫它ubuntu1804.img吧:

      dd if=/dev/zero of=ubuntu1804.img bs=1M count=3500
      

      然后我們將它掛載為loop設(shè)備:

      sudo losetup -f --show ubuntu1804.img
      

      如果你之前沒(méi)有掛過(guò)別的回環(huán)設(shè)備的話,一般它會(huì)掛在/dev/loop0。

      然后我們給它分區(qū)??梢杂脠D形界面的工具如gparted,也可以用命令行工具如parted、fdisk等。比方說(shuō)我們用fdisk。

      sudo fdisk /dev/loop0
      

      n來(lái)添加新分區(qū)。順著它的指示走下去即可。

      文件系統(tǒng) 大小
      啟動(dòng)分區(qū) vfat 256MB就夠了
      文件系統(tǒng) ext4 3.2G

      同步這些分區(qū)。這樣會(huì)在/dev/mapper/下面生成對(duì)應(yīng)的節(jié)點(diǎn):

      sudo kpartx -av /dev/loop0
      

      格式化它們:

      sudo mkfs.vfat /dev/mapper/loop0p1
      sudo mkfs.ext4 /dev/mapper/loop0p2
      

      掛載它們:

      mkdir boot rootfs
      sudo mount /dev/mapper/loop0p1 boot
      sudo mount /dev/mapper/loop0p2 rootfs
      

      uboot和設(shè)備樹(shù)改動(dòng)

      我們要修改uboot環(huán)境變量,讓它從SD卡里面讀取內(nèi)核和設(shè)備樹(shù)。不過(guò)zc702工程的默認(rèn)啟動(dòng)設(shè)備就是sd卡,我們只需要留意sdboot這個(gè)環(huán)境變量以及各種地址就好了:

      -    "kernel_load_address=0x2080000\0" +    "kernel_load_address=0x8000\0" ...
      -    "devicetree_image=devicetree.dtb\0"    -    "devicetree_load_address=0x2000000\0"    +    "devicetree_image=zynq-zc702.dtb\0"    +    "devicetree_load_address=0x0\0"    ...
           "sdboot=if mmcinfo; then " -        "run uenvboot; "          "echo Copying Linux from SD to RAM... && "          "load mmc 0 ${kernel_load_address} ${kernel_image} && "          "load mmc 0 ${devicetree_load_address} ${devicetree_image} && " -        "load mmc 0 ${ramdisk_load_address} ${ramdisk_image} && " -        "bootm ${kernel_load_address} ${ramdisk_load_address} ${devicetree_load_address}; " +        "bootm ${kernel_load_address} - ${devicetree_load_address}; "      "fi\0" 

      我們還要修改設(shè)備樹(shù),添加啟動(dòng)參數(shù),讓內(nèi)核掛載Ubuntu文件系統(tǒng)。其中rootwait這個(gè)參數(shù)表示需要等待根文件系統(tǒng)的掛載,不然內(nèi)核啟動(dòng)很快,一看還沒(méi)有掛上文件系統(tǒng)就會(huì)kernel panic了:

           chosen {
      -        bootargs = "";
      +        bootargs = "root=/dev/mmcblk0p2 rw rootwait";
               stdout-path = "serial0:115200n8";
           };
      

      BOOT.binuImage、zynq-zc702.dtb放進(jìn)啟動(dòng)分區(qū)。

      安裝最小系統(tǒng)

      接著就可以愉快地debootstrap了。不過(guò)可惜的是,國(guó)內(nèi)Ubuntu源都沒(méi)有同步armhf的port,只有x86的,所以只能用官方源了。

      sudo debootstrap --arch=armhf --foreign bionic ./rootfs
      

      但是國(guó)內(nèi)的Debian就同步了arm的分支,比方說(shuō)清華源:

      sudo debootstrap --arch=armhf --foreign stretch ./rootfs https://mirrors.tuna./debian/
      

      等一段時(shí)間下完基本系統(tǒng),然后拷貝qemu進(jìn)去:

      sudo cp -av /usr/bin/qemu-arm-static rootfs/usr/bin/
      

      還需要拷貝resolv.conf,以便聯(lián)網(wǎng):

      sudo cp /run/systemd/resolve/stub-resolv.conf rootfs/etc/resolv.conf
      

      然后chroot進(jìn)去:

      sudo chroot ./rootfs
      

      在里面進(jìn)行second-stage

      # chroot環(huán)境下面:
      export LANG=C
      /debootstrap/debootstrap --second-stage
      

      安裝完成之后,補(bǔ)全/etc/apt/source.list

      deb http://ports./ubuntu-ports bionic main restricted universe multiverse
      deb http://ports./ubuntu-ports bionic-security main restricted universe multiverse
      deb http://ports./ubuntu-ports bionic-updates main restricted universe multiverse
      deb http://ports./ubuntu-ports bionic-proposed main restricted universe multiverse
      deb http://ports./ubuntu-ports bionic-backports main restricted universe multiverse
      deb-src http://ports./ubuntu-ports bionic main restricted universe multiverse
      deb-src http://ports./ubuntu-ports bionic-security main restricted universe multiverse
      deb-src http://ports./ubuntu-ports bionic-updates main restricted universe multiverse
      deb-src http://ports./ubuntu-ports bionic-proposed main restricted universe multiverse
      deb-src http://ports./ubuntu-ports bionic-backports main restricted universe multiverse
      

      然后裝一些基本的軟件:

      apt-get update
      apt-get install sudo ifupdown net-tools ethtool udev wireless-tools iputils-ping resolvconf wget apt-utils wpasupplicant vim git gcc build-essential openssh-server
      

      新建用戶,就叫它ubuntu吧,密碼也是ubuntu:

      useradd -G sudo -m -s /bin/bash ubuntu
      echo ubuntu:ubuntu | chpasswd
      

      更改root密碼:

      passwd root
      

      設(shè)置主機(jī)名為armhf

      echo armhf > /etc/hostname
      

      設(shè)置網(wǎng)絡(luò),改/etc/network/interfaces文件:

      auto lo
      iface lo inet loopback
      
      allow-hotplug eth0
      iface eth0 inet dhcp
      

      終端配色:將/home/ubuntu/.bashrc里面的force_color_prompt=yes注釋刪掉即可。

      設(shè)置默認(rèn)掛載目錄:改/etc/fstab,將啟動(dòng)分區(qū)掛載到/boot目錄上:

      /dev/mmcblk0p1 /boot vfat defaults 0 0
      

      如果沒(méi)什么別的想要配置的話,就可以exit退出了。

      注意,因?yàn)閄ilinx的內(nèi)核配置默認(rèn)將所有驅(qū)動(dòng)都直接編譯進(jìn)內(nèi)核,所以不需要將模塊安裝到文件系統(tǒng)中,就一個(gè)放在啟動(dòng)分區(qū)的內(nèi)核就夠了。

      燒錄SD卡

      我們將鏡像文件卸載:

      sudo umount ./boot
      sudo umount ./rootfs
      sudo kpartx -d /dev/loop0
      sudo losetup -d /dev/loop0
      

      我們看到這個(gè)鏡像文件有3.7G那么大,但是世界上它占用的磁盤(pán)空間沒(méi)那么大,它是個(gè)sparse file,將它打包壓縮之后就沒(méi)看上去那么大了。可以用ls -s來(lái)看到它實(shí)際上多大:

      $ ls -sh ubuntu1804.img 
      1.2G ubuntu1804.img
      

      現(xiàn)在我們直接將這個(gè)文件dd到一張SD卡里面:

      dd if=ubuntu1804.img of=/dev/sd某
      

      如果你的SD卡不只有4G,那么可以通過(guò)像gparted、parted、fdisk等等的分區(qū)工具將第二個(gè)分區(qū)拉大,然后resize2fs重新設(shè)置分區(qū)大小。gparted一般會(huì)自動(dòng)幫你resize2fs。

      上機(jī)測(cè)試

      可以從串口看到完整的啟動(dòng)過(guò)程:uboot、kernel、systemd,然后是login:

      U-Boot 2018.01 (Apr 24 2019 - 00:24:09 +0800) Xilinx Zynq ZC702
      
      Model: Zynq ZC702 Development Board
      Board: Xilinx Zynq
      Silicon: v3.1
      I2C:   ready
      DRAM:  ECC disabled 256 MiB
      NAND:  128 MiB
      
      ...
      
      ## Booting kernel from Legacy Image at 00008000 ...
        Image Name:   Linux-4.19.0-xilinx
        Image Type:   ARM Linux Kernel Image (uncompressed)
        Data Size:    4322424 Bytes = 4.1 MiB
        Load Address: 00008000
        Entry Point:  00008000
        Verifying Checksum ... OK
      ## Flattened Device Tree blob at 00000000
        Booting using the fdt blob at 0x000000
        Loading Kernel Image ... OK
        Loading Device Tree to 0eafd000, end 0eb037a6 ... OK
      
      Starting kernel ...
      
      Booting Linux on physical CPU 0x0
      Linux version 4.19.0-xilinx (hyq@ict) (gcc version 6.2.1 20161114 (Linaro GCC Snapshot 6.2-2016.11))
      #19 SMP PREEMPT Wed Apr 24 21:55:25 CST 2019
      CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=18c5387d
      CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
      OF: fdt: Machine model: Xilinx ZC702 board
      
      ...
      
      VFS: Mounted root (ext4 filesystem) on device 179:2.
      devtmpfs: mounted
      Freeing unused kernel memory: 1024K
      Run /sbin/init as init process
      random: fast init done
      systemd[1]: System time before build time, advancing clock.
      systemd[1]: Failed to insert module 'autofs4': No such file or directory
      systemd[1]: systemd 237 running in system mode. (+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT
      +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN -PCRE2
      default-hierarchy=hybrid)
      systemd[1]: Detected architecture arm.
      
      Welcome to Ubuntu 18.04 LTS!
      
      systemd[1]: Set hostname to <armhf>.
      systemd[1]: File /lib/systemd/system/systemd-journald.service:36 configures an IP firewall (IPAddress
      Deny=any), but the local system does not support BPF/cgroup based firewalling.
      systemd[1]: Proceeding WITHOUT firewalling in effect! (This warning is only shown for the first loade
      d unit using IP firewalling.)
      random: systemd: uninitialized urandom read (16 bytes read)
      systemd[1]: Reached target Swap.
      [  OK  ] Reached target Swap.
      
      ...
      
      [  OK  ] Started resolvconf-pull-resolved.service.
      
      Ubuntu 18.04 LTS armhf ttyPS0
      
      armhf login: ubuntu
      Password:
      Last login: Fri Apr 26 17:35:14 UTC 2019 on ttyPS0
      Welcome to Ubuntu 18.04 LTS (GNU/Linux 4.19.0-xilinx armv7l)
      
      * Documentation:  https://help.
      * Management:     https://landscape.
      * Support:        https:///advantage
      
      ubuntu@armhf:~$ 
      

      跑個(gè)screenfetch來(lái)看看:

      sf
      sf
      gcc
      gcc

      gcc真的能用。。但是真是慢。。

      參考資料

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多