Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keystone on CVA6 with Genesys 2 Board include new example #444

Open
niovi opened this issue May 20, 2024 · 5 comments
Open

keystone on CVA6 with Genesys 2 Board include new example #444

niovi opened this issue May 20, 2024 · 5 comments

Comments

@niovi
Copy link

niovi commented May 20, 2024

Hello,
i clone the repository dev-cva6-support.
i run ./fast-setup.sh and then i create a new example the ci(eapp,host like hello example) which has in the eapp only
int main()
{
printf("hello, ci!\n");
return 0;
}
and put add_subdirectory(ci) in CMakeLists.txt.
I try KEYSTONE_PLATFORM=cva6 make and i am getting

keystone-examples 38e0b889ab50ad73 Building
make[6]: *** [ci/CMakeFiles/ci.dir/build.make:99: ci/ci] Error 1
make[5]: *** [CMakeFiles/Makefile2:995: ci/CMakeFiles/ci.dir/all] Error 2
make[4]: *** [CMakeFiles/Makefile2:228: CMakeFiles/examples.dir/rule] Error 2
make[3]: *** [Makefile:124: examples] Error 2
make[2]: *** [package/pkg-generic.mk:293: /home/***/gits/keystone/build-cva664/buildroot.build/build/keystone-examples-38e0b889ab50ad73/.stamp_built] Error 2
make[1]: *** [Makefile:82: _all] Error 2
make: *** [Makefile:90: buildroot] Error 2

i have manage to flash sd card and run keystone on cva6 with Genessys 2 board.
Screenshot from 2024-05-20 16-09-40

but i need to include my example also.
where do i need to make changes beside the examples folder?
Thank you in advance.

@grg-haas
Copy link
Collaborator

Hi @niovi ! Would you be able to copy your build.log file from the build-cva664 directory to here? Unfortunately the provided error trace does not have enough details for me to diagnose this.

@niovi
Copy link
Author

niovi commented May 20, 2024

of course
build.log.tar.gz

Thank you for your response.

@grg-haas
Copy link
Collaborator

Okay, in your build log I see the following lines:

/home/ubi/gits/keystone/build-cva664/buildroot.build/per-package/keystone-examples/host/bin/../lib/gcc/riscv64-buildroot-linux-gnu/11.4.0/../../../../riscv64-buildroot-linux-gnu/bin/ld: warning: cannot find entry symbol _start; defaulting to 00000000000100e8
/home/ubi/gits/keystone/build-cva664/buildroot.build/per-package/keystone-examples/host/bin/../lib/gcc/riscv64-buildroot-linux-gnu/11.4.0/../../../../riscv64-buildroot-linux-gnu/bin/ld: CMakeFiles/ci.dir/eapp/ci.c.o: in function `.L0 ':
ci.c:(.text.startup+0x10): undefined reference to `puts'
collect2: error: ld returned 1 exit status
[ 11%] Linking CXX executable ci-runner
[ 12%] Building CXX object attestation/CMakeFiles/attestor-runner.dir/host/host.cpp.o
make[6]: *** [ci/CMakeFiles/ci.dir/build.make:99: ci/ci] Error 1

This seems to me like you are not linking the standard C libraries to your eapp, which you need to use functions like printf. What does your CMakeLists.txt for your new ci example look like? It should look like the CMakeLists.txt for the hello example (not hello-native).

@niovi
Copy link
Author

niovi commented May 21, 2024

hello again Thank you for your response.
i try to #include <openssl/sha.h>

int main()
{
uint8_t test[32] = {0};
uint8_t test_p[32];
SHA256(test, 32, test_p);
for (int i=0;i<32;i++){
printf("%02X", test[i]);
}
printf("\nhello, ci is here!\n");
return 0;
}

and with CMakeLIsts.txt
set(eapp_bin ci)
set(eapp_src eapp/ci.c)
set(host_bin ci-runner)
set(host_src host/hostn.cpp)
set(package_name "ci.ke")
set(package_script "./ci-runner ci eyrie-rt loader.bin")
set(eyrie_plugins "io_syscall linux_syscall env_setup")

eapp

add_executable(${eapp_bin} ${eapp_src})

target_link_libraries(${eapp_bin}
/home/ubi/rewire/openssl-3.0.1/libcrypto.a
/home/ubi/rewire/openssl-3.0.1/libssl.a)
target_include_directories(${eapp_bin}
PUBLIC /home/ubi/rewire/openssl-3.0.1/include)

host

add_executable(${host_bin} ${host_src})
target_link_libraries(${host_bin} ${KEYSTONE_LIB_HOST} ${KEYSTONE_LIB_EDGE})

add target for Eyrie runtime (see keystone.cmake)

set(eyrie_files_to_copy .options_log eyrie-rt loader.bin)
add_eyrie_runtime(${eapp_bin}-eyrie
${eyrie_plugins}
${eyrie_files_to_copy})

add target for packaging (see keystone.cmake)

add_keystone_package(${eapp_bin}-package
${package_name}
${package_script}
${eyrie_files_to_copy} ${eapp_bin} ${host_bin})

add_dependencies(${eapp_bin}-package ${eapp_bin}-eyrie)

add package to the top-level target

add_dependencies(examples ${eapp_bin}-package)

build.log.tar.gz

and i am getting segmentation fault .

@grg-haas
Copy link
Collaborator

grg-haas commented May 21, 2024

I see very many lines that look like (I chose one arbitrarily):

/home/ubi/gits/keystone/build-cva664/buildroot.build/per-package/keystone-examples/host/bin/../lib/gcc/riscv64-buildroot-linux-gnu/11.4.0/../../../../riscv64-buildroot-linux-gnu/bin/ld: /home/ubi/rewire/openssl-3.0.1/libcrypto.a(libcrypto-lib-v3_akid.o): relocation R_RISCV_HI20 against `a local symbol' can not be used when making a shared object; recompile with -fPIC

One thing that I notice here is that the linker believes you are making a shared object, which we do not support (yet) in Keystone. You may want to explicitly compile your eapp as a static binary, in the same way as in the hello example here. That is, your eapp's CMakeLists.txt should look like:

add_executable(${eapp_bin} ${eapp_src})
target_link_libraries(${eapp_bin} "-static" /home/ubi/rewire/openssl-3.0.1/libcrypto.a /home/ubi/rewire/openssl-3.0.1/libssl.a)
target_include_directories(${eapp_bin} PUBLIC /home/ubi/rewire/openssl-3.0.1/include)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants