OpTEE + Android in Hikey960

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

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!
[  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)) ####

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

Sorry, please try again using latest instructions above.

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

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

Yes, of course. I hope you’ll get better soon. I’ll re-post it next monday.

@tesmnorth Sorry for the delay and thank you for your patience!

Yes, you’re right about changing GCC49 to GCC5. I’ve made the changes so please do:

cd device/linaro/hikey
repo sync .
cd ../../../
rebuild

Were you able to resolve all the other (3?) issues you’d posted previously but later deleted?

@vchong welcome :). I hope you are well now.

I contined to build after changes. In %90, I took following error.(I couldnt resolve it by myself) But, I deleted it. Because, errors are mixed. sometimes we dont understand errors. So, I want to go step by step with you.

external/optee_test/host/xtest/regression_1000.c:1279: error: undefined reference to 'sdp_basic_test'
external/optee_test/host/xtest/regression_1000.c:1285: error: undefined reference to 'sdp_basic_test'
external/optee_test/host/xtest/regression_1000.c:1291: error: undefined reference to 'sdp_basic_test'
external/optee_test/host/xtest/regression_1000.c:1297: error: undefined reference to 'sdp_basic_test'
external/optee_test/host/xtest/aes_perf.c:277: error: undefined reference to 'allocate_ion_buffer'
external/optee_test/host/xtest/aes_perf.c:292: error: undefined reference to 'allocate_ion_buffer'
external/optee_test/host/xtest/xtest_main.c:100: error: undefined reference to 'sdp_basic_runner_cmd_parser'
clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)
[ 90% 69369/76757] target Strip (mini debug info).../obj/EXECUTABLES/showslab_intermediates/showslab)
ninja: build stopped: subcommand failed.
22:45:12 ninja failed with: exit status 1

#### failed to build some targets (02:45:26 (hh:mm:ss)) ####

I hope you are well now.

Better. Thanks for asking!

I contined to build after changes. In %90, I took following error.(I couldnt resolve it by myself) But, I deleted it. Because, errors are mixed. sometimes we dont understand errors. So, I want to go step by step with you.

Yes, it’s not a good idea to continue building after errors, especially if you’re running parallel builds. Better to check the errors one by one.

Wrt error above, I forgot the kernel doesn’t support SDP so we need to disable it in the build command. Please try again with:

make TARGET_BUILD_UEFI=true TARGET_TEE_IS_OPTEE=true CFG_SECURE_DATA_PATH=n

ok, I am trying again. After flashing to Hikey960, we work on optee errors from xtest output?

yes but let’s cross that bridge when we get there ;s

@vchong Building is ok. While using cc comand, I took this error: ../../../device/linaro/l-loader/cc: 225: ../../../device/linaro/l-loader/cc: abootimg: not found. So, I installed abootimg with sudo apt-get install abootimg
Then, while flashing:
Just waiting with following log:

$ sudo ./flash-all.sh 
android out dir:./../../../../..//out/target/product/hikey960
target reported max download size of 134217728 bytes
sending 'ptable' (24 KB)...

Did you put the board in fastboot/recovery mode first? See https://github.com/96boards-hikey/tools-images-hikey960 and https://github.com/96boards-hikey/tools-images-hikey960/blob/master/build-from-source/README-ATF-UEFI-build-from-source.md.

Like hikey board, you should be able to see the board serial id when running fastboot devices on your PC, before you run the flash-all.sh script.

I think, I need to do everything in two links?

Yes, I see board serial when running fastboot devices.

I need to do everything in two links?

No. Just make sure you have the correct dip switch settings (1 and 3 on, 2 off). The flash-all.sh script is basically just the list of flash commands found in those 2 links.

Yes, I see board serial when running fastboot devices.

In that case you should be able to go ahead and flash images. Maybe try each of the fastboot flash commands at the bottom of flash-all.sh one by one manually first to verify that the fastboot flash command actually works.

If it doesn’t work, you might have to try going through recovery mode, in which case those 2 links above will show you how to run the hikey_idt command for recovery.

$ sudo ./flash-all.sh 
android out dir:./../../../../..//out/target/product/hikey960
target reported max download size of 471859200 bytes
sending 'ptable' (24 KB)...
OKAY [  0.007s]
writing 'ptable'...
OKAY [  0.025s]
finished. total time: 0.032s
target reported max download size of 471859200 bytes
error: cannot load './sec_xloader.img': No such file or directory

target reported max download size of 471859200 bytes
sending 'fastboot' (1056 KB)...
OKAY [  0.034s]
writing 'fastboot'...
OKAY [  0.017s]
finished. total time: 0.051s
target reported max download size of 471859200 bytes
sending 'fip' (1474 KB)...
OKAY [  0.047s]
writing 'fip'...
OKAY [  0.021s]
finished. total time: 0.068s
target reported max download size of 471859200 bytes
sending 'boot' (21504 KB)...
OKAY [  0.587s]
writing 'boot'...
OKAY [  0.143s]
finished. total time: 0.730s
target reported max download size of 471859200 bytes
sending 'cache' (56 KB)...
OKAY [  0.008s]
writing 'cache'...
OKAY [  0.054s]
finished. total time: 0.063s
target reported max download size of 471859200 bytes
sending 'userdata' (4888 KB)...
OKAY [  0.129s]
writing 'userdata'...
OKAY [  1.712s]
finished. total time: 1.841s
target reported max download size of 471859200 bytes
sending sparse 'system' (460796 KB)...
OKAY [ 12.290s]
writing 'system'...
OKAY [  3.318s]
sending sparse 'system' (421200 KB)...
OKAY [ 10.884s]
writing 'system'...
OKAY [  2.667s]
sending sparse 'system' (115176 KB)...
OKAY [  2.992s]
writing 'system'...
OKAY [  0.748s]
finished. total time: 32.900s

I think, there is no sec_xloader.img in building out. But I have hisi-sec_xloader.img

I think, there is no sec_xloader.img in building out. But I have hisi-sec_xloader.img

No, don’t use hisi-sec_xloader.img. It’s old. Please use the one in device/linaro/tools-images-hikey960. Copy it to the installer/hikey960 folder so you can run the script without errors. Thanks.