美文网首页
ubuntu14.04 编译OPTEE for 树莓派

ubuntu14.04 编译OPTEE for 树莓派

作者: Hiro_Wang | 来源:发表于2020-01-14 21:59 被阅读0次

ubuntu 14.04
内核版本4.4.0-31,闲话两句
不知道是不是因为墙的问题,尝试了不同的ubuntu16/18版本+optee版本,最后使用ubuntu14+optee3.1才第一次跑通,各种缺文件,自行测试最新版吧
virtual-machine:~$ uname -a
Linux ... chine 4.4.0-31-generic #50~14.04.1-Ubuntu SMP Wed Jul 13 01:07:32 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

$ sudo apt-get install vim curl git -y

# 修改源 可选
$ vim /etc/apt/sources.list
# 玄学参考:使用的**自带源** 然后设置终端的代理

-------
$ sudo apt-get clean && sudo apt-get update && sudo apt-get upgrade -y
$ vim ~/.bashrc

# 这里使用的是宿主机(MACOS)的SSR 
------
alias proxy="export ALL_PROXY=socks5://x.x.x.x:1086"
alias unproxy="unset ALL_PROXY"
alias checkip="curl myip.ipip.net"
------
$ source ~/.bashrc
# checkip检查是否出Q
# 玄学参考:SSR设置成全局模式

配置

# optee 3.1 版
$ sudo apt-get install git android-tools-adb android-tools-fastboot autoconf automake bc bison build-essential cscope curl flex ftp-upload gdisk libattr1-dev libc6:i386 libcap-dev libfdt-dev libftdi-dev libglib2.0-dev libhidapi-dev libncurses5-dev libpixman-1-dev libssl-dev libstdc++6:i386 libtool libz1:i386 make mtools netcat python-crypto python-serial python-wand unzip uuid-dev xdg-utils xterm xz-utils zlib1g-dev ccache minicom -y
# 最新版是这些
sudo apt-get install android-tools-adb android-tools-fastboot autoconf automake bc bison build-essential ccache cscope curl device-tree-compiler expect flex ftp-upload gdisk iasl libattr1-dev libc6:i386 libcap-dev libfdt-dev libftdi-dev libglib2.0-dev libhidapi-dev libncurses5-dev libpixman-1-dev libssl-dev libstdc++6:i386 libtool libz1:i386 make mtools netcat python-pyelftools python3-pyelftools python-crypto python3-crypto python-serial python3-serial rsync unzip uuid-dev xdg-utils xterm xz-utils zlib1g-dev -y

# 安装repo
$ mkdir ~/bin
$ PATH=~/bin:$PATH
$ cd ~/bin
$ curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o repo
$ chmod a+x repo
$ git config --global user.name "yourname"
$ git config --global user.email "youremail"

Sync and make

$ mkdir -p $HOME/devel/optee
$ cd $HOME/devel/optee
$ repo init -u https://github.com/OP-TEE/manifest.git -m rpi3.xml -b 3.1.0 
# --repo-url=https://mirrors.tuna.tsinghua.edu.cn/git/git-repo
# 可选,init失败时加到3.1.0 后面
$ repo sync

$ cd build
$ make toolchains

$ make

可选:下载toolchains失败时

$ gedit /optee/build/toolchain.mk
# 粗看一下很好理解,组合成下载URL手动下载,然后解压
# https://releases.linaro.org/components/toolchain/binaries/6.2-2016.11/arm-linux-gnueabihf/${AARCH32_GCC_VERSION}.tar.xz
# gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf替代${AARCH32_GCC_VERSION}就是文件路径
$ mkdir -p aarch32 && mkdir -p xxx && mkdir -p xxx ... # AARCH32_PATH中的文件夹名称
$ tar xf xxx.tar.xz -C aarch32xxx --strip-components=1; &&  tar xf ...

常见错误

xz: (stdin): Unexpected end of input tar: Unexpected EOF in archive tar: Unexpected EOF in archive tar: Error is not recoverable: exiting now toolchain.mk:39: recipe for target 'aarch64' failed make: *** [aarch64] Error 2
# 由于make toolchains下载失败,上面方法手动下载就行

#先安装pycryptodomex
----------------
ImportError: No module named 'Cryptodome'
ta/arch/arm/link.mk:100: recipe for target 'out/arm/ta/avb/023f8f1a-292a-432b-8fc4-de8471358067.ta' failed
make[1]: *** [out/arm/ta/avb/023f8f1a-292a-432b-8fc4-de8471358067.ta] Error 1
make[1]: Leaving directory '/home/osboxes/devel/optee/optee_os'
common.mk:380: recipe for target 'optee-os-common' failed
make: *** [optee-os-common] Error 2
---------------
$ sudo apt-get install pip3
$ pip3 install pycryptodomex

error.GitError: Cannot initialize work tree for u-boot/u-boot.git

"make[1]: *** [out/arm/core/ldelf_hex.c] Error 1"

bash: line 1: scripts/kconfig/merge_config.sh: No such file or directory

# 这些貌似都是缺失文件,需要重新同步整个项目

树莓派

# 查看TF卡所在的盘符
$ sudo fdisk -l
# 查看下是否已经自动挂载
$ df -hl
# 弹出TF卡所在的盘符
$ umount /dev/sdx1
# 格式化后的SD卡会是/dev/sdx, sdx1这种先格式化一下

$ make img-help 
#会根据当前环境的变更,直接复制运行

$ fdisk /dev/sdx   # where sdx is the name of your sd-card
p             # prints partition table
d             # repeat until all partitions are deleted
n             # create a new partition
p             # create primary
1             # make it the first partition
<enter>       # use the default sector
+32M          # create a boot partition with 32MB of space
n             # create rootfs partition
p
2
<enter>
<enter>       # fill the remaining disk, adjust size to fit your needs
t             # change partition type
1             # select first partition
e             # use type 'e' (FAT16)
a             # make partition bootable
1             # select first partition
p             # double check everything looks right
w             # write partition table to disk.
# 上面的顺序操作,最后会有一个sdx1和sdx2,sdx1p1这种先格

run the following as root
    mkfs.vfat -F16 -n BOOT /dev/sdx1
    mkdir -p /media/boot
    mount /dev/sdx1 /media/boot
    cd /media
    gunzip -cd /home/hiro/devel/optee/build/../gen_rootfs/filesystem.cpio.gz | sudo cpio -idmv "boot/*"
    umount boot

run the following as root
    mkfs.ext4 -L rootfs /dev/sdx2
    mkdir -p /media/rootfs
    mount /dev/sdx2 /media/rootfs
    cd rootfs
    gunzip -cd /home/hiro/devel/optee/build/../gen_rootfs/filesystem.cpio.gz | sudo cpio -idmv
    rm -rf /media/rootfs/boot/*
   $ cd .. && umount rootfs

相关文章

网友评论

      本文标题:ubuntu14.04 编译OPTEE for 树莓派

      本文链接:https://www.haomeiwen.com/subject/xuczactx.html