Cannot build Hikey Fw from source


#1

im trying to follow the instructions in the link https://github.com/Linaro/documentation/blob/master/Reference-Platform/RPOfficial/ConsumerEdition/HiKey/BuildSourceBL.md and have not had any success building the firmware.

I’m having two issues. Firstly, since the compiler/toolchain is gcc 5.3 as mentioned in the link shown above, uefi_build.sh failed with error “Warning: [GCC5] not defined” and “No toolchain available for build”. I fixed this for forcing uefi_build.sh to set TOOLCHAIN=GCC49 and got past this issue.
The next issue that im not able to get past is /bin/sh: 1: aarch64-linux-gnu-gcc: not found.

I have checked and rechecked that the tool chain is in my path. Are there any packages that i need or am i missing something else ?

hikeyfw$ echo $PATH
~/Desktop/Work/gcc/arm-tc:~/Desktop/Work/gcc/arm64-tc:~/Desktop/Work/gcc/arm-tc/bin:~/Desktop/Work/gcc/arm64-tc/bin:~/Desktop/Work/gcc/arm-tc/bin:~/Desktop/Work/gcc/arm64-tc/bin:~/Desktop/Work/gcc/arm-tc/bin:~/Desktop/Work/gcc/arm64-tc/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin


#2

solved 1 problem and got another one. first problem was because /bin/sh was pointing to a different shell(dash) and i was running in a bash shell.
Have a new problem:aarch64-linux-gnu-gcc: error trying to exec ‘cc1’: execvp: No such file or directory

looks like lots of people have had this issue but the solution is not clear.


#3

Thanks for reporting the problem! Can you please try gcc 4.9 for now until we can sort this out?


#4

Or if you insist on using gcc5, then use below temp workaround:


cd ${UEFI_TOOLS_DIR}
git checkout 0ce9cb2a715bebdb6bf5b99ef59df532e655ce88
cd ${EDK2_DIR}
git clean -xfd
${UEFI_TOOLS_DIR}/uefi-build.sh -b RELEASE -a ${ATF_DIR} -s ${OPTEE_DIR} hikey


#5

Thanks for the reply vchong. I had no luck with GCC49 either. Had the same issue. Will try you suggestion with GCC5.


#6

@vchong, tried you suggestion. Same issue still.


#7

Are you using the latest for all repos, except uefi-tools.git?
Did you make sure to git clean the repo first? I had the same issue too until I did that.
If yes to both, then some logs might help.


#8

@vchong, i tried the instructions from https://github.com/Linaro/documentation/blob/master/Reference-Platform/RPOfficial/ConsumerEdition/HiKey/BuildSourceBL.md from scratch and made the change you suggested for uefi-tools. I still see the same issue.
Is that what you mean by latest for all repos ? Im assuming ill get the latest if i clone the repositories as mentioned in the instructions now. note that the link uses the hikey-aosp branch and not master or any other branch.


#9

[Edit] Yes, you will get the latest if you start a clone from scratch now.

I also tested again from scratch using the script below which basically contains instructions copy and pasted from https://github.com/Linaro/documentation/blob/master/Reference-Platform/RPOfficial/ConsumerEdition/HiKey/BuildSourceBL.md, plus the changes suggested for uefi-tools, minus the ‘git clean’ since these are new/clean repos. Note that I also added ‘–depth=1’ to speed up the test. The build is ok. Not sure what the problem is on your end.


#!/bin/bash

git clone --depth=1 -b hikey-aosp https://github.com/96boards-hikey/edk2.git
git clone --depth=1 -b hikey-aosp https://github.com/96boards-hikey/OpenPlatformPkg.git
git clone --depth=1 https://github.com/OP-TEE/optee_os.git
git clone --depth=1 -b hikey https://github.com/96boards-hikey/arm-trusted-firmware.git
git clone --depth=1 https://github.com/96boards-hikey/l-loader.git
git clone git://git.linaro.org/uefi/uefi-tools.git

export AARCH64_TOOLCHAIN=GCC49
export EDK2_DIR=${PWD}/edk2
export OPTEE_DIR=${PWD}/optee_os
export ATF_DIR=${PWD}/arm-trusted-firmware
export UEFI_TOOLS_DIR=${PWD}/uefi-tools

cd ${UEFI_TOOLS_DIR}
git checkout 0ce9cb2a715bebdb6bf5b99ef59df532e655ce88
cd ${EDK2_DIR}
rmdir OpenPlatformPkg; ln -s ../OpenPlatformPkg
${UEFI_TOOLS_DIR}/uefi-build.sh -b RELEASE -a ${ATF_DIR} -s ${OPTEE_DIR} hikey


> aarch64-linux-gnu-gcc -v
gcc version 5.3.1 20160113 (Linaro GCC 5.3-2016.02)

> arm-linux-gnueabihf-gcc -v
gcc version 5.3.1 20160113 (Linaro GCC 5.3-2016.02)


#10

Got past the aarch64-linux-gnu-gcc: error trying to exec ‘cc1’: execvp: No such file or directory issue. The problem was with the default bashrc on ubuntu xenial. :confused: it skipped the bashrc file entirely if the shell was non interactive and it looks like the build process invokes non interactive shells. All my exports for gcc were at the end of bashrc.
Now im having issues with python crypto and wand.image modules. Hopefully the python issues will be simpler to solve.


#11

Build finished successfully after i installed pip, pycrypto and wand.
@vchong, thanks for the help.


#12

Looks like your problem was with the shell all along and I kept trying to solve the ‘gcc5’ issue, so we were both headed in different directions. Sorry about that and glad you got it working.

The build instructions have been updated by the way for the gcc5 issue. For details see https://github.com/Linaro/documentation/pull/7.


#13

@vchong, thanks again for all the help!


#14

Hi @raghu-ncstate raghu-ncstate, I am new to this and I am getting this error during the build and the build breaks:

{{{
build: : warning: Tool chain [GCC5] is not defined

build.py
: error 4000: Not available
[GCC5] not defined. No toolchain available for build!
}}}

Can you tell me how to get past this issue? or any background will help.
I know this topic was discussed long back. Sorry and thanks in advance.

Best,
Rakshith Patkar


#15

@rakshithpatkar Which url/instructions are you following? Try setting below and rebuild again.

export AARCH64_TOOLCHAIN=GCC5


#16

Sorry. I mean try setting it to GCC49.


#17

@vchong, I am following the instructions in:

Even after setting export AARCH64_TOOLCHAIN=GCC49, I am getting the same error.

Attaching the script i am using:

{{{
#!/bin/sh

BUILD_OPTION=DEBUG

export AARCH64_TOOLCHAIN=GCC49

export UEFI_TOOLS_DIR=${BUILD_PATH}/uefi-tools

export EDK2_DIR=${BUILD_PATH}/edk2

EDK2_OUTPUT_DIR=${EDK2_DIR}/Build/HiKey960/${BUILD_OPTION}_${AARCH64_TOOLCHAIN}

cd ${EDK2_DIR}

Build UEFI & ARM Trust Firmware

${UEFI_TOOLS_DIR}/uefi-build.sh -b ${BUILD_OPTION} -a …/arm-trusted-firmware hikey960

Generate l-loader.bin

cd ${BUILD_PATH}/l-loader

ln -sf ${EDK2_OUTPUT_DIR}/FV/bl1.bin

ln -sf ${EDK2_OUTPUT_DIR}/FV/fip.bin

ln -sf ${EDK2_OUTPUT_DIR}/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
}}}

After setting: export AARCH64_TOOLCHAIN=GCC49

{{{

OK
make[1]: Leaving directory '/home/rakshith/Projects/UEFI-source/edk2/BaseTools/Tests’
make: Leaving directory ‘/home/rakshith/Projects/UEFI-source/edk2/BaseTools’
Target: AARCH64
Build: X64
Building Hikey960 - AARCH64
CROSS_COMPILE="aarch64-linux-gnu-"
hikey960_BUILDFLAGS=’ -D FIRMWARE_VER=9d69f68’
TOOLCHAIN is GCC5
Toolchain prefix: GCC5_AARCH64_PREFIX=aarch64-linux-gnu-
Build environment: Linux-4.4.0-21-generic-x86_64-with-Ubuntu-16.04-xenial
Build start time: 15:25:16, Jul.17 2017

build: : warning: Tool chain [GCC5] is not defined

build.py
: error 4000: Not available
[GCC5] not defined. No toolchain available for build!

  • Failed -
    Build end time: 15:25:17, Jul.17 2017
    Build total time: 00:00:00

                                     Hikey960 DEBUG	fail

pass 0
fail 1
python: can’t open file ‘gen_loader_hikey960.py’: [Errno 2] No such file or directory
rakshith@patkar007:~/Projects/UEFI-source/edk2$
}}}

- Installed gcc version:
{{{
rakshith@patkar007:~/Projects/UEFI-source/edk2$ gcc --version
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
Copyright © 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

rakshith@patkar007:~/Projects/UEFI-source/edk2$
}}}


#18

@rakshithpatkar Do you have a gcc5 toolchain downloaded, installed and added to the PATH variable, before running the commands? E.g.

wget http://releases.linaro.org/components/toolchain/binaries/5.3-2016.02/aarch64-linux-gnu/gcc-linaro-5.3-2016.02-x86_64_aarch64-linux-gnu.tar.xz
wget http://releases.linaro.org/components/toolchain/binaries/5.3-2016.02/arm-linux-gnueabihf/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf.tar.xz
mkdir arm-tc arm64-tc
tar --strip-components=1 -C ${PWD}/arm-tc -xf gcc-linaro-5.3-*arm-linux-gnueabihf.tar.xz
tar --strip-components=1 -C ${PWD}/arm64-tc -xf gcc-linaro-5.3-*aarch64-linux-gnu.tar.xz
export PATH="${PWD}/arm-tc/bin:${PWD}/arm64-tc/bin:$PATH"

Linux on HiKey 960
#19

@vchong, thanks for the reply.

I already have the arm64 toolchain installed and put it in .bashrc file.

$ vim ~/.bashrc

{{{
//snip
export PATH=/home/rakshith/arm64-tc/bin:$PATH
export PATH=/home/rakshith/arm-tc/bin:$PATH
//snip
}}}

Verifying the above:

{{{
rakshith@patkar007:~/Projects/UEFI-source/edk2$ aarch64-linux-gnu-g
aarch64-linux-gnu-g++ aarch64-linux-gnu-gcc-ar aarch64-linux-gnu-gcov aarch64-linux-gnu-gfortran
aarch64-linux-gnu-gcc aarch64-linux-gnu-gcc-nm aarch64-linux-gnu-gcov-tool aarch64-linux-gnu-gprof
aarch64-linux-gnu-gcc-5.3.1 aarch64-linux-gnu-gcc-ranlib aarch64-linux-gnu-gdb
}}}

Still getting the following error:

{{{
//snip

Ran 247 tests in 0.917s

OK
make[1]: Leaving directory '/home/rakshith/Projects/UEFI-source/edk2/BaseTools/Tests’
make: Leaving directory ‘/home/rakshith/Projects/UEFI-source/edk2/BaseTools’
Target: AARCH64
Build: X64
Building Hikey960 - AARCH64
CROSS_COMPILE="aarch64-linux-gnu-"
hikey960_BUILDFLAGS=’ -D FIRMWARE_VER=9d69f68’
TOOLCHAIN is GCC5
Toolchain prefix: GCC5_AARCH64_PREFIX=aarch64-linux-gnu-
Build environment: Linux-4.4.0-21-generic-x86_64-with-Ubuntu-16.04-xenial
Build start time: 11:03:02, Jul.19 2017

build: : warning: Tool chain [GCC5] is not defined

build.py
: error 4000: Not available
[GCC5] not defined. No toolchain available for build!

  • Failed -
    Build end time: 11:03:02, Jul.19 2017
    Build total time: 00:00:00

                                     Hikey960 DEBUG	fail

pass 0
fail 1
python: can’t open file ‘gen_loader_hikey960.py’: [Errno 2] No such file or directory
}}}

I am using the latest cloned repos as source.


#20

How are you cloning the repos? Looks like you might not be on right branches.