OPTEE with Rasberry Pi 3B

OP-TEE Build for Rasberry Pi 3B

Gommaro 2019. 9. 3. 18:18

1. Ubuntu apt-get lock error 발생시 조치

$ sudo rm /var/lib/apt/lists/lock

$ sudo rm /var/cache/apt/archives/lock

$ sudo rm /var/lib/dpkg/lock

$ sudo apt-get clean

$ sudo apt-get update

$ sudo dpkg --configure -a

   

 

2. OPTEE Setup

- 전체 과정은 https://optee.readthedocs.io/en/latest/building/index.html 참고(기존 링크 변경됨.)

 

 

3. Prerequire package installation

https://optee.readthedocs.io/building/prerequisites.html#prerequisites

 

$ 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-crypto python3-pyelftools python-serial \
        unzip uuid-dev xdg-utils xterm xz-utils zlib1g-dev

 

 

4. Repo setup

$ sudo apt-get install repo

 

 

5. Check xml file for rasberry pi

https://github.com/OP-TEE/manifest

 

 

 

6. Get source from Git server

TARGET : rpi3.xml

BRANCH : OPTEE v.3.0 이하는 rpi3_stable.xml, 3.1 이상은 3.x.0 형식

$ mkdir -p  <optee-project>
$ cd  <optee-project>
$ repo init -u https://github.com/OP-TEE/manifest.git -m ${TARGET}.xml [-b ${BRANCH}]

   => repo init -u https://github.com/OP-TEE/manifest.git -m rpi3.xml -b 3.6.0
$ repo sync -j4 --no-clone-bundle

만약 git config를 해주지 않았다면 git config user.name과 user.email 선행 설정 필요.

 

 

7. Toolchain build

$ cd <optee-project>/build
$ make -j2 toolchains

 

 

8. Source build

$ make -j2 

 

 

9. Build 전 수정사항

1) UART enable

RPI3의 경우 BT와 UART0, Mini UART를 할당해서 BT가 Enable되면 UART로 로그가 나오지 않음.

이를 위해 아래 내용 수정

$ vi <optee-project>/build/rpi3/firmware/config.txt

맨 마지막 항에 아래 구문 추가

dtoverlay=pi3-disable-bt 

 

2) check-bin-arch 수정

최초 빌드에는 괜찮은데, 한번 빌드 된 뒤에 Rebuild 수행시 binary architecture checking 과정에서 bootcode.bin, start.elf 등 Broadcom release binary에 대해 64bit 용이 아니라고 에러가 발생.

부팅시 32Bit으로 부팅하고, Trusted firmware와 U boot이 올라가면서 64bit으로 변경해주기 때문에 해당 과정은 불필요.

따라서 주석 처리함.

$ vi <optee-project>/buildroot/support/scripts/check-bin-arch

 

    # Architecture is correct
    if test "${arch}" = "${arch_name}" ; then
        continue
    fi  

    printf 'ERROR: architecture for "%s" is "%s", should be "%s"\n' \
           "${f}" "${arch}" "${arch_name}"
    continue
#exitcode=1
done < <( sed -r -e "/^${package},\.(.+)$/!d; s//\1/;" ${pkg_list} )