Uemu复现

Eutopia's Blog

Posted by Eutopia on December 18, 2023

uEmu复现

1. 环境

Ubuntu 20.04(最好分配大于20G存储空间,否则可能不够用)

gitee链接:https://gitee.com/cpdt/uEmu.git

virtualbox

2. 步骤

  1. 克隆下载uEmu

    git clone https://gitee.com/cpdt/uEmu.git
    
  2. 使用vagrant Installation方式复现(不推荐,感觉和直接源码安装没区别,还要多出安装虚拟机的步骤,虚拟机套虚拟机。。。还容易崩溃。。。),安装virtualbox

    sudo apt install vagrant
    sudo apt install virtualbox
    
  3. 启动虚拟机

    vagrant up
    

    需要等几分钟,第一次会下载ubuntu镜像,这里放一个清华源镜像,添加到vagrantfile里:

     config.vm.box_url = 'https://mirrors.tuna.tsinghua.edu.cn/ubuntu-cloud-images/focal/20231207/focal-server-cloudimg-amd64-vagrant.box'
    

    再次vagrant up。没有报错,正常界面如下

    image-20231219094453267

    再输入命令登入即可

    vagrant ssh
    

    接下来进行源码编译安装,其中git-repo建议用清华源下载

    export uEmuDIR=/home/user/uEmu 
    sudo apt-get install git-repo   
    cd $uEmuDIR
    repo init -u https://github.com/MCUSec/manifest.git -b uEmu
    repo sync
    

    其中 init -u https://github.com/MCUSec/manifest.git -b uEmu语句可能会报错,需要将python改为python3.

    image-20231219095415829

    sudo rm /usr/bin/python
    sudo ln -s /usr/bin/python3 /usr/bin/python 
    

    接下来编译uEmu,官方给的创建文件夹命令是sudo,但是会导致make时权限不足,所以不需要加sudo,编译耗时大概在1小时左右。。。

    $ mkdir $uEmuDIR/build
    $ cd $uEmuDIR/build
    $ make -f $uEmuDIR/Makefile && make -f $uEmuDIR/Makefile install
    # Go make some coffee or do whatever you want, this will take some time (approx. 60 mins on a 4-core machine)
    

    在make阶段解压tar文件时会出现虚拟机崩溃的现象,尝试增大内存以及处理器数量,成功解决。(建议设置大一点,否则后面也有可能卡死),另外发现虚拟机内编译时用的包是ubuntu18.04版本的,所以想要直接源码安装的可以考虑使用ubuntu18.04虚拟机。

    image-20231219101217730

    中间报错

    import distro ModuleNotFoundError: No module named 'distro'".  Stop.
    apt install python3-distro
    
    /home/vagrant/uEmu/build/opt/bin/clang: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
    
    # 安装ncurses库
    sudo apt-get install libncurses5
    
    /home/vagrant/uEmu/build/llvm-10.0.0.src/tools/gold/gold-plugin.cpp:34:10: fatal error: 'plugin-api.h' file not found
    
    sudo apt-get install binutils-dev
    

    找不到libelf/libelf.h

    # 安装库
    sudo apt-get install libelf-dev
    

    找不到glib.h 找到报错文件目录下CMakeList.txt添加glib-2.0的目录

    include_directories(${catkin_INCLUDE_DIRS}
     /usr/lib/aarch64-linux-gnu/glib-2.0/include
     /usr/include/glib-2.0
    )
    

    configure文件Permission Denied

    #修改文件权限即可
    chmod +x ./configure
    

    /usr/include/gtk-2.0/gtk/gtktypeutils.h:236:1: error: ‘GTypeDebugFlags’ is deprecated [-Werror=deprecated-declarations]

    应该是版本不对应,不知道怎么改,废了。