本人在 MacOS 下针对开发板 v3.31-c 上 yodaos 编译时遇到的问题及解释

编译环境:

MacOS + Vagrant + VirtualBox + ubuntu 16.04

注意事项及说明:

  1. USB Type-C 与 Wifi 2.4G 有干扰(可能导致 Wifi 无法连接,或者无法传输数据),所以相关的无线设备要么留远点,要么自行想办法错开。
  2. 编译发生报错,使用 make -j1 V=s 查看具体报错内容。
  3. 编译时的文件系统需要支持文件名大小写区分,那么我们在 磁盘工具 生成的 虚拟磁盘 中操作。
  4. 勿在默认的 /vagrant 目录下进行编译,该情况会导致 ln 失败。
  5. 既便换用 nfs 方式挂载,也会导致 install 失败。
  6. 辛苦拉下来的 .repo 不能白瞎了,那么在 VirtualBox 生成的 虚拟磁盘 ,并格式化为 ext 文件系统,然后软链接 /vagrant 目录中的 .repo 文件到新的文件系统中进行编译。( .repo 中使用的基本都是软链接,理论上不存在 install 操作)

附件及内容:

files.zip

Vagrant 启动脚本(vm_up.sh):

#/bin/bash

VBoxManage setproperty machinefolder /Volumes/SeagateBackup/VirtualBox\ VMs vagrant up VBoxManage setproperty machinefolder default

自动格式化磁盘脚本(auto_fdisk.sh):

本人有改动,使用前自选考虑风险。

#/bin/bash
#########################################
#Function:    auto fdisk
#Usage:       bash auto_fdisk.sh
#Author:      Customer service department
#Company:     Alibaba Cloud Computing
#Version:     3.0
#########################################

count=0 tmp1=/tmp/.tmp1 tmp2=/tmp/.tmp2 >$tmp1 >$tmp2 fstab_file=/etc/fstab

#check lock file ,one time only let the script run one time LOCKfile=/tmp/.$(basename $0) if [ -f "$LOCKfile" ] then echo -e "\033[1;40;31mThe script is already exist,please next time to run this script.\033[0m" exit else echo -e "\033[40;32mStep 1.No lock file,begin to create lock file and continue.\033[40;37m" touch $LOCKfile fi

#check user if [ $(id -u) != "0" ] then echo -e "\033[1;40;31mError: You must be root to run this script, please use root to install this script.\033[0m" rm -rf $LOCKfile exit 1 fi

#check disk partition check_disk() { >$LOCKfile device_list=$(fdisk -l|grep “Disk”|grep “/dev”|awk ‘{print $2}’|awk -F: ‘{print $1}’|grep “sdc”) for i in echo $device_list do device_count=$(fdisk -l $i|grep “$i”|awk ‘{print $2}’|awk -F: ‘{print $1}’|wc -l) echo if [ $device_count -lt 2 ] then now_mount=$(df -h) if echo $now_mount|grep -w “$i” >/dev/null 2>&1 then echo -e “\033[40;32mThe $i disk is mounted.\033[40;37m” else echo $i >>$LOCKfile echo “You have a free disk,Now will fdisk it and mount it.” fi fi done disk_list=$(cat $LOCKfile) if [ “X$disk_list” = “X” ] then echo -e “\033[1;40;31mNo free disk need to be fdisk.Exit script.\033[0m” rm -rf $LOCKfile exit 0 else echo -e “\033[40;32mThis system have free disk :\033[40;37m” for i in echo $disk_list do echo “$i” count=$((count+1)) done fi }

#fdisk ,formating and create the file system fdisk_fun() { fdisk -S 56 $1 << EOF n p 1

wq EOF

sleep 5 mkfs.ext4 ${1}1 }

#make directory make_dir() { echo -e “\033[40;32mStep 4.Begin to make directory\033[40;37m” now_dir_count=$(ls /|grep “diskdata*”|awk -F “data” ‘{print $2}’|sort -n|tail -1) if [ “X$now_dir_count” = “X” ] then for j in seq $count do echo “/diskdata$j” >>$tmp1 mkdir /diskdata$j done else for j in seq $count do k=$((now_dir_count+j)) echo “/diskdata$k” >>$tmp1 mkdir /diskdata$k done fi }

#config /etc/fstab and mount device main() { for i in echo $disk_list do echo -e "\033[40;32mStep 3.Begin to fdisk free disk.\033[40;37m" fdisk_fun $i echo "${i}1" >>$tmp2 done make_dir >$LOCKfile paste $tmp2 $tmp1 >$LOCKfile echo -e "\033[40;32mStep 5.Begin to write configuration to /etc/fstab and mount device.\033[40;37m" while read a b do if grep -v ^# $fstab_file|grep ${a} >/dev/null then sed -i "s=${a}*=#&=" $fstab_file fi echo "${a} $b ext4 defaults 0 0" >>$fstab_file done <$LOCKfile mount -a }

#=========start script=========== echo -e "\033[40;32mStep 2.Begin to check free disk.\033[40;37m" check_disk main df -h rm -rf $LOCKfile $tmp1 $tmp2

Vagrant 配置(Vagrantfile):

# -*- mode: ruby -*-
# vi: set ft=ruby :

All Vagrant configuration is done below. The "2" in Vagrant.configure

configures the configuration version (we support older styles for

backwards compatibility). Please don’t change it unless you know what

you’re doing.

Vagrant.configure("2") do |config|

The most common configuration options are documented and commented below.

For a complete reference, please see the online documentation at

https://docs.vagrantup.com.

Every Vagrant development environment requires a box. You can search for

boxes at https://vagrantcloud.com/search.

config.vm.box = "ubuntu/xenial64"

Disable automatic box update checking. If you disable this, then

boxes will only be checked for updates when the user runs

vagrant box outdated. This is not recommended.

config.vm.box_check_update = false

if Vagrant.has_plugin?("vagrant-proxyconf")

config.proxy.http = "http://10.0.0.1:8080/"

config.proxy.https = "http://10.0.0.1:8080"

config.proxy.no_proxy = "localhost,127.0.0.1,.example.com"

end

Create a forwarded port mapping which allows access to a specific port

within the machine from a port on the host machine. In the example below,

accessing "localhost:8080" will access port 80 on the guest machine.

NOTE: This will enable public access to the opened port

config.vm.network "forwarded_port", guest: 80, host: 8080

Create a forwarded port mapping which allows access to a specific port

within the machine from a port on the host machine and only allow access

via 127.0.0.1 to disable public access

config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"

Create a private network, which allows host-only access to the machine

using a specific IP.

config.vm.network "private_network", ip: "192.168.33.101"

Create a public network, which generally matched to bridged network.

Bridged networks make the machine appear as another physical device on

your network.

config.vm.network "public_network"

Share an additional folder to the guest VM. The first argument is

the path on the host to the actual folder. The second argument is

the path on the guest to mount the folder. And the optional third

argument is a set of non-required options.

config.vm.synced_folder "…/data", "/vagrant_data"

config.vm.synced_folder “.”, “/data”, type: “nfs”, :nfs => true, :mount_options => [‘nfsvers=3’, “dmode=777”,“fmode=777”]

config.vm.synced_folder ".", "/vagrant", type: "nfs", nfs: true

config.vm.synced_folder ".", "/vagrant", type: "nfs",

:bsd__nfs_options => ["no_root_squash"]

:nfs => {

:map_uid => 501,

:map_gid => 20

}

Provider-specific configuration so you can fine-tune various

backing providers for Vagrant. These expose provider-specific options.

Example for VirtualBox:

config.vm.provider "virtualbox" do |vb| # Set VirtualBox Machine name vb.name = "Rokid-OpenAI"

# Display the VirtualBox GUI when booting the machine
vb.gui = false

# Customize the amount of memory on the VM:
vb.memory = &quot;4096&quot;

# vb.customize [&quot;setproperty&quot;, &quot;machinefolder&quot;, &quot;/Volumes/rokid-openai/.vagrant/vm&quot;]

# Get disk path
line = `VBoxManage list systemproperties | grep &quot;Default machine folder&quot;`
vb_machine_folder = line.split(':')[1].strip()
extra_disk = File.join(vb_machine_folder, vb.name, 'extra_disk.vdi')

# Create and attach disk
unless File.exist?(extra_disk)
  vb.customize ['createhd', '--filename', extra_disk, '--format', 'VDI', '--size', 64 * 1024]
end
vb.customize ['storageattach', :id, '--storagectl', 'SCSI', '--port', 2, '--device', 0, '--type', 'hdd', '--medium', extra_disk]

# vb.customize [&quot;setextradata&quot;, :id, &quot;machinefolder&quot;, &quot;/Volumes/rokid-openai/.vagrant/vm&quot;]
vb.customize [&quot;setextradata&quot;, :id, &quot;VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root&quot;, &quot;1&quot;]
vb.customize [&quot;setextradata&quot;, :id, &quot;VBoxInternal2/SharedFoldersEnableSymlinksCreate/vagrant&quot;, &quot;1&quot;]

end

View the documentation for the provider you are using for more

information on available options.

Enable provisioning with a shell script. Additional provisioners such as

Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the

documentation for more information about their specific syntax and use.

config.vm.provision "shell", path: "auto_fdisk.sh" config.vm.provision "shell", inline: <<-SHELL sed -i "s!http://archive.ubuntu.com/ubuntu!http://mirrors.aliyun.com/ubuntu!g" /etc/apt/sources.list apt-get update apt-get install -y repo apt-get install -y build-essential subversion libncurses5-dev zlib1g-dev gawk gcc-multilib flex git-core gettext libssl-dev unzip texinfo apt-get install -y device-tree-compiler apt-get install -y gcc-4.7-arm-linux-gnueabihf apt-get install -y libusb-1.0-0-dev SHELL end

1赞