OpTEE + Android in Hikey960


#43

Just that. Go to the kernel/linaro/hisilicon folder and run the device/linaro/l-loader/cc script from there.


#44
../scripts/gcc-version.sh: line 25: aarch64-linux-android-gcc: command not found
../scripts/gcc-version.sh: line 26: aarch64-linux-android-gcc: command not found
make[1]: aarch64-linux-android-gcc: Command not found
make[1]: aarch64-linux-android-gcc: Command not found

I have aarch64-linux-android-gcc but I think there is a version problem. How can I change this? I can not find it.

Secondly, it has “ANDROID_BUILD_TOP not found problem” line 67 in cc file. I changed $(ANDROID_BUILD_TOP) as ${ANDROID_BUILD_TOP} then problem is solved.


#45

Did you run . ./build/envsetup.sh first before running cc?


#46

Also, I fixed ANDROID_BUILD_TOP problem, so please update l-loader.

cd device/linaro/l-loader
repo sync .
cd ../../../kernel/linaro/hisilicon
make ARCH=arm64 distclean
../../../device/linaro/l-loader/cc

If cc doesn’t run due to permission error, make sure you set it to be an executable, i.e. chmod +x cc.


#47

This is my aarch64-linux-android-gcc version. Yours should be the same since it’s part of the aosp source code.

$ aarch64-linux-android-gcc --version
real-aarch64-linux-android-gcc (GCC) 4.9.x 20150123 (prerelease)
Copyright (C) 2014 Free Software Foundation, Inc.

#48

I updated l-loader. I could run make TARGET_BUILD_UEFI=true TARGET_TEE_IS_OPTEE=true via sudo. So, I think I need to sudo command while I am working../../../device/linaro/l-loader/cc despite cc is executable. What do you think about is this problem?

This is my aarch64-linux-android-gcc version:

aarch64-linux-android-gcc (GCC) 4.9.x 20150123 (prerelease)
Copyright (C) 2014 Free Software Foundation, Inc.

But, error is same: command not found. (I used . ./build/envsetup.sh). I am working on solving this problem.


#49

I don’t use sudo for make and cc. Sounds like something off with the system.

What is the output of uname -a?

From which folder did you run aarch64-linux-android-gcc?

Run echo $PATH. Among the folders listed, is there one that contains aarch64-linux-android-gcc?


#50

Linux martin 4.4.0-98-generic #121~14.04.1-Ubuntu SMP Wed Oct 11 11:54:55 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

/home/martin/Android/Sdk/ndk-bundle/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin

/home/martin/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/martin/Android/Sdk/ndk-bundle/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin:/home/martin/optee_android_manifest/device/linaro/gcc-linaro-5.4.1-2017.05-x86_64_aarch64-linux-gnu/bin:/home/martin/optee_android_manifest/device/linaro/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin


#51

Problem is solved. root does not show aarch64-linux-android-gcc. Now it is compiling. But, I dont understand why make TARGET_BUILD_UEFI=true TARGET_TEE_IS_OPTEE=true doesn’t run without sudo.


#52

What’s the error with make without sudo?


#53

We talked about : OpTEE + Android in Hikey960


#54
$ ld -v
GNU ld (GNU Binutils for Ubuntu) 2.24

What is your binutils version?
Edit: I think problem is this. I can not use binutils 2.27 in toolchain


#55

We talked about : OpTEE + Android in Hikey960

No, we didn’t really talked about it. The system sends out notification only when a new post is made, not when one is edited, so if the edit is not trivial, as in your case above, it might be better to make a new post instead, else I wouldn’t know of your updates.

I re-installed Ubuntu as 14.04.5. I did everything step by step. I used linaro toolchain. But, Error is same.

I’m not sure about the cross toolchains that come with Ubuntu 14.04. It might be ok. The linaro ones I suggested earlier above are wrong! Sorry about that! They shouldn’t have worked. Not sure why my previous built was successful. See https://github.com/ARM-software/tf-issues/issues/401 for details, especially https://github.com/ARM-software/tf-issues/issues/401#issuecomment-316450010. Have you seen this (or a similar thread) and is this why you’re asking about the binutils version? In any case, you need to check the cross compilers binutils version, e.g. aarch64-linux-gnu-ld, not the native (ld) one, but for linaro toolchain, the version might not give you enough info due to backporting.

I’ve also updated the makefile to use linaro gcc 7 instead, so below commands should work.

cd <aosp main>
repo sync device/linaro/hikey
make TARGET_BUILD_UEFI=true TARGET_TEE_IS_OPTEE=true #no sudo!

Again, the makefile automatically downloads and uses the toolchain so you shouldn’t have to download manually.

I solved the problem. make TARGET_BUILD_UEFI=true TARGET_TEE_IS_OPTEE=true command needs root priviliges.

I don’t think this is a result of the build needing root privileges. Rather that as a result of sudo, you’re now using a different toolchain that doesn’t trigger the build error. Also, using sudo might possibly make the images not work properly due to file permissions, so not recommended.

I believe everything should now be ok with the build instructions. Please make sure you don’t have any toolchains that you’ve downloaded manually[1] in your $PATH that might interfere with the build, and try again without sudo.

[1] The ones installed with apt-get and the ones downloaded in /home/martin/Android/Sdk/ndk-bundle. The android toolchains should already be in /home/martin/optee_android_manifest/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin so you shouldn’t need the others.


#56
2017-11-10 10:18:59 (5,56 MB/s) - ‘gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf.tar.xz.1’ saved [88614724/88614724]

tar: gcc-linaro-7.1.1-2017.08-x86_64_aarch64-linux-gnu.tar.xz: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
Makefile:34: recipe for target '/home/martin/optee_android_manifest/device/linaro/gcc-linaro-7.1.1-2017.08-x86_64_aarch64-linux-gnu' failed
make: *** [/home/martin/optee_android_manifest/device/linaro/gcc-linaro-7.1.1-2017.08-x86_64_aarch64-linux-gnu] Error 2

#57

Sorry, typo.

cd <aosp main>
repo sync device/linaro/hikey
rm -f device/linaro/gcc-linaro-*.tar.xz
make TARGET_BUILD_UEFI=true TARGET_TEE_IS_OPTEE=true #no sudo!

#58
[  1% 1389/76662] target  C: e2fsdroid_stati...e2fsprogs/contrib/android/basefs_allocator.c
In file included from external/e2fsprogs/contrib/android/basefs_allocator.c:3:
In file included from external/e2fsprogs/contrib/android/basefs_allocator.h:5:
In file included from external/e2fsprogs/lib/ext2fs/ext2fs.h:71:
external/e2fsprogs/lib/ext2fs/ext2_types.h:30:9: warning: '__bitwise' macro redefined [-Wmacro-redefined]
#define __bitwise
        ^
bionic/libc/kernel/uapi/linux/types.h:25:9: note: previous definition is here
#define __bitwise __bitwise__
        ^
1 warning generated.
[  1% 1392/76662] target  C: e2fsdroid_stati...= external/e2fsprogs/contrib/android/perms.c
In file included from external/e2fsprogs/contrib/android/perms.c:4:
In file included from external/e2fsprogs/contrib/android/perms.h:5:
In file included from external/e2fsprogs/lib/ext2fs/ext2fs.h:71:
external/e2fsprogs/lib/ext2fs/ext2_types.h:30:9: warning: '__bitwise' macro redefined [-Wmacro-redefined]
#define __bitwise
        ^
bionic/libc/kernel/uapi/linux/types.h:25:9: note: previous definition is here
#define __bitwise __bitwise__
        ^
1 warning generated.
ninja: build stopped: subcommand failed.
10:55:36 ninja failed with: exit status 1

#### failed to build some targets (01:47 (mm:ss)) ####

#59

Please, ignore above log.

Connecting to releases.linaro.org (releases.linaro.org)|52.77.230.32|:80... connected.
HTTP request sent, awaiting response... 404 NOT FOUND
2017-11-10 10:55:03 ERROR 404: NOT FOUND.

Makefile:34: recipe for target '/home/martin/optee_android_manifest/device/linaro/gcc-linaro-7.1.1-2017.08-x86_64_aarch64-linux-gnu' failed
make: *** [/home/martin/optee_android_manifest/device/linaro/gcc-linaro-7.1.1-2017.08-x86_64_aarch64-linux-gnu] Error 8

#60

Sorry, please try again using latest instructions above.


#64

In the following error, there is a directory which name is RELEASE_GCC49. But, I have RELEASE_GCC5 in this path.
Do I have to modify MakeFile as “_GCC5” in directory “/home/martin/optee_android_manifest/device/linaro/hikey/bootloader/”?

------------------------------------------------------------
                                       Hikey960 RELEASE	pass
------------------------------------------------------------
pass	1
fail	0
cd /home/martin/optee_android_manifest/device/linaro/l-loader && \
	ln -sf /home/martin/optee_android_manifest/device/linaro/edk2/Build/HiKey960/RELEASE_GCC49/FV/bl1.bin && \
	ln -sf /home/martin/optee_android_manifest/device/linaro/edk2/Build/HiKey960/RELEASE_GCC49/FV/BL33_AP_UEFI.fd && \
	python gen_loader_hikey960.py -o l-loader.bin --img_bl1=bl1.bin --img_ns_bl1u=BL33_AP_UEFI.fd && \
	cp l-loader.bin /home/martin/optee_android_manifest/out/dist/ && \
	cp l-loader.bin /home/martin/optee_android_manifest/device/linaro/hikey/installer/hikey960/
+-----------------------------------------------------------+
 Input Images:
     bl1:                           bl1.bin
     ns_bl1u:                          BL33_AP_UEFI.fd
 Ouput Image:                       l-loader.bin
+-----------------------------------------------------------+

Traceback (most recent call last):
  File "gen_loader_hikey960.py", line 129, in <module>
    main(sys.argv[1:])
  File "gen_loader_hikey960.py", line 124, in main
    loader.create(img_bl1, img_ns_bl1u, output_img)
  File "gen_loader_hikey960.py", line 92, in create
    self.add(0, img_bl1)
  File "gen_loader_hikey960.py", line 32, in add
    fsize = os.path.getsize(fname)
  File "/usr/lib/python2.7/genericpath.py", line 49, in getsize
    return os.stat(filename).st_size
OSError: [Errno 2] No such file or directory: 'bl1.bin'
make: *** [/home/martin/optee_android_manifest/out/dist/l-loader.bin] Error 1
make: Leaving directory `/home/martin/optee_android_manifest/device/linaro/hikey/bootloader'
[  2% 2268/76660] target  C++: libv8src <= external/v8/src/builtins/builtins-handler.cc
ninja: build stopped: subcommand failed.
09:10:16 ninja failed with: exit status 1

#65

Sorry but i’m not feeling well. Can we pick this back up next week?