Nuclei-Software / nuclei-linux-sdk

Nuclei RISC-V Linux Software Development Kit
Apache License 2.0
38 stars 9 forks source link

Build error optee_os/core/tee.bin Unknown e_machine "243" when try to build optee option #11

Closed sichunqin closed 11 months ago

sichunqin commented 12 months ago

I follow https://github.com/Nuclei-Software/nuclei-linux-sdk/tree/feature/optee_5.10_wg/optee#optee-%E8%AF%B4%E6%98%8E to build linux SDK with optee_5.10_wg branch, and get the following error after run make SOC=evalsoc CORE=ux900fd BOOT_MODE=sd freeloader command:

 GEN     /mnt/fileroot2/sichun.qin/code/github/nuclei-linux-sdk/work/evalsoc/optee/optee_os/core/tee.bin
Unknown e_machine "243"
core/arch/riscv/kernel/link.mk:127: recipe for target '/mnt/fileroot2/sichun.qin/code/github/nuclei-linux-sdk/work/evalsoc/optee/optee_os/core/tee.bin' failed
fanghuaqi commented 12 months ago

Hello, could you check your submodule is updated and no changes are made, we forget to push some code to this repo, now all are pushed, you can try

git fetch
git submodule init
git submodule update
sichunqin commented 12 months ago

Thanks, but still not work. I am wondering the error is related to pyelftools version. I am using 0.23, and I see the risc-v support is added to pyelftools since Feb. 2023. I have no privilege to upgrade my dev machine python library, and I will try to find another machine to verify the issue.

sichunqin commented 12 months ago

0.27 works well. I think >=0.27 would work as well.

fanghuaqi commented 11 months ago

Thanks @sichunqin for your reporting.

According to optee requirement, these tools are required, https://optee.readthedocs.io/en/latest/building/prerequisites.html

pyelftools is a requirement, you can install it via pip3 tools, see https://pypi.org/project/pyelftools/

I will close this issue, since you have fixed it.

fanghuaqi commented 11 months ago

Unknown e_machine "243"

This is EM_RISCV as described here https://github.com/eliben/pyelftools/blob/9ffa0b515b9a24495e81b36fcc698c2376af27de/elftools/elf/enums.py#L257

fanghuaqi commented 11 months ago
Traceback (most recent call last):
  File "scripts/pem_to_pub_c.py", line 71, in <module>
    main()
  File "scripts/pem_to_pub_c.py", line 24, in main
    from cryptography.hazmat.backends import default_backend
ModuleNotFoundError: No module named 'cryptography'
make[1]: *** [mk/subdir.mk:185: /home/nuclei/nuclei-linux-sdk/work/evalsoc/optee/optee_os/core/ta_pub_key.c] Error 1
make[1]: Leaving directory '/home/nuclei/nuclei-linux-sdk/optee/optee_os'
make: *** [Makefile:474: optee_os] Error 2
nuclei@8bfe7bdac196:~/nuclei-linux-sdk$ pip3 install cryptography
Collecting cryptography
***
Can't find elftools module. Probably it is not installed on your system.
You can install this module with

$ apt install python3-pyelftools

if you are using Ubuntu. Or try to search for "pyelftools" or "elftools" in
your package manager if you are using some other distribution.
***

Traceback (most recent call last):
  File "scripts/gen_ldelf_hex.py", line 13, in <module>
    from elftools.elf.elffile import ELFFile
ModuleNotFoundError: No module named 'elftools'
make[1]: *** [mk/subdir.mk:185: /home/nuclei/nuclei-linux-sdk/work/evalsoc/optee/optee_os/core/ldelf_hex.c] Error 1
make[1]: Leaving directory '/home/nuclei/nuclei-linux-sdk/optee/optee_os'
make: *** [Makefile:474: optee_os] Error 2
nuclei@8bfe7bdac196:~/nuclei-linux-sdk$ pip3 install pyelftools
Collecting pyelftools

Need to install pyelftools and cryptography python3 pip packages.

pip3 install -U pyelftools cryptography