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

Documentation : cross compilation for arm #46

Open
arthurlutz opened this issue Feb 25, 2024 · 41 comments
Open

Documentation : cross compilation for arm #46

arthurlutz opened this issue Feb 25, 2024 · 41 comments

Comments

@arthurlutz
Copy link
Contributor

First of all great project, I'm quite new to the embedded graphics stack and this project compiles and works out of the box on my laptop so that's great and very promising.

Any chances of giving some indications on how to cross compile this for an arm device ?

My use case is the following : I want to try it out on an ereader that only has framebuffer : https://linux-sunxi.org/Bookeen_Cybook_Muse ... right now I can compile https://github.com/allepet/nolim-ebook-sdk for it but am not sure I can build upon that and would rather have a framework such as LVGL to build upon.

@arthurlutz
Copy link
Contributor Author

cmake newbie, I tried adding :

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_C_COMPILER /usr/bin/arm-linux-gnueabi-gcc)
set(CMAKE_CXX_COMPILER /usr/bin/arm-linux-gnueabi-g++)

to CMakeLists.txt, but that fails in a loop :

You have changed variables that require your cache to be deleted.
Configure will be re-run and you may have to reset some variables.
The following variables have changed:
CMAKE_C_COMPILER= /usr/bin/cc
CMAKE_CXX_COMPILER= /usr/bin/c++

@kisvegabor
Copy link
Member

Happy that you like LVGL so far.

I'm not a CMake expert either, but found that these help:

  • Adding the compiler ID like this
set(CMAKE_C_COMPILER arm-linux-gnueabi-gcc)
set(CMAKE_CXX_COMPILER arm-linux-gnueabi-g++)
set(CMAKE_C_COMPILER_ID GNU)  #Add these
set(CMAKE_CXX_COMPILER_ID GNU)

Seemingly the problem is that the nested CMake files are resetting the CMAKE_C/CXX_COMPILER variables resulting in infinite reconfiguration.

After these changes it still doesn't compile for me, but I hope it's only due to my hacky cross compile environment.

@arthurlutz
Copy link
Contributor Author

@kisvegabor thanks for taking a look at this ! It seems to work :

make
[snip]
[ 99%] Linking C static library liblvgl_examples.a
[ 99%] Built target lvgl_examples
[ 99%] Building C object CMakeFiles/main.dir/main.c.o
[ 99%] Building C object CMakeFiles/main.dir/mouse_cursor_icon.c.o
[100%] Linking CXX executable /home/arthur/local/lv_port_linux_frame_buffer/bin/main
[100%] Built target main

❯ file ../bin/main 
../bin/main: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.3, BuildID[sha1]=655f609c2e15c6a3e9329a5c1bc4e14837d93394, for GNU/Linux 3.2.0, not stripped

Unfortunately I have to wait a week to try it out on the target machine which I don't have at hand.

@arthurlutz
Copy link
Contributor Author

Got round to testing it on the device, but it fails to run since it is dynamically linked to a libc6 version that is not the target device :

# ./lvgl_framebuffer 
./lvgl_framebuffer: /lib/libc.so.6: version `GLIBC_2.38' not found (required by ./lvgl_framebuffer)
./lvgl_framebuffer: /lib/libc.so.6: version `GLIBC_2.32' not found (required by ./lvgl_framebuffer)
./lvgl_framebuffer: /lib/libc.so.6: version `GLIBC_2.34' not found (required by ./lvgl_framebuffer)
./lvgl_framebuffer: /lib/libm.so.6: version `GLIBC_2.29' not found (required by ./lvgl_framebuffer)
./lvgl_framebuffer: /lib/libm.so.6: version `GLIBC_2.27' not found (required by ./lvgl_framebuffer)
./lvgl_framebuffer: /lib/libm.so.6: version `GLIBC_2.38' not found (required by ./lvgl_framebuffer)
./lvgl_framebuffer: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by ./lvgl_framebuffer)
./lvgl_framebuffer: /usr/lib/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by ./lvgl_framebuffer)
./lvgl_framebuffer: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by ./lvgl_framebuffer)

I now have to see if I can figure out static linking, using musl or linking to the older libc6 that is present on the system :

# /lib/libc.so.6
GNU C Library (Sourcery G++ Lite 2010.09-50) stable release version 2.11.1, by Roland McGrath et al.
Copyright (C) 2009 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.
Compiled by GNU CC version 4.5.1.
Compiled on a Linux >>2.6.24-26-server<< system on 2010-11-07.
Available extensions:
	crypt add-on version 2.1 by Michael Glad and others
	GNU Libidn by Simon Josefsson
	Native POSIX Threads Library by Ulrich Drepper et al
	Support for some architectures added on, not maintained in glibc core.
	BIND-8.2.3-T5B
For bug reporting instructions, please see:
<https://support.codesourcery.com/GNUToolchain/>.

any pointers welcome !

@kisvegabor
Copy link
Member

cc @XuNeo @liamHowatt @HanesSciarrone
Do you have any idea for this?

@XuNeo
Copy link

XuNeo commented Mar 12, 2024

I'm not sure of how to fix it, but seems you need to tell CMAKE where's the SYSROOT. You can copy out the rootfs from board.

See https://stackoverflow.com/questions/73591889/cross-compiling-with-cmake-picking-up-host-rather-than-target-definitions

If any more issues, I would search for how to cross compile for raspberry-pi. It should give lots of guides.

@HanesSciarrone
Copy link

Hi @arthurlutz, I hope you are ok.

I can't say exactly what could be the reason for this error, but maybe the problem could be the GLIBC version mismatch between target and host (build machine). Could you run the ldd --version command on target and host to compare the GLIBC used?

@liamHowatt
Copy link

@arthurlutz I think the version of libc that the binary tries to link may be based on the version of the toolchain it was compiled with. I'm not sure how old the Linux on your e-reader is but it may be from the Linux 3.0 that the wiki links. It says to use toolchain version 4.9.4 for v3.4 kernels. I struggled to navigate that Linaro artifact file server but this SO answer has the link to a 4.9.3 toolchain :P

Try compiling your LVGL test with a 4.* version of arm-linux-gnueabihf-gcc and see if it's happy with the libc currently on your e-reader.

@arthurlutz
Copy link
Contributor Author

@HanesSciarrone I am well thank you for asking. Hope you are well too.

Ideed I am trying to cross-compile with a different libc6 on the target system :

on the build :

❯ /usr/lib/x86_64-linux-gnu/libc.so.6 -v
GNU C Library (Ubuntu GLIBC 2.39-0ubuntu2) stable release version 2.39.
Copyright (C) 2024 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.
Compiled by GNU CC version 13.2.0.
libc ABIs: UNIQUE IFUNC ABSOLUTE
Minimum supported kernel: 3.2.0
For bug reporting instructions, please see:
<https://bugs.launchpad.net/ubuntu/+source/glibc/+bugs>.
❯ ldd --version
ldd (Ubuntu GLIBC 2.39-0ubuntu2) 2.39
Copyright (C) 2024 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.
Written by Roland McGrath and Ulrich Drepper.

on the target :

# ldd --version
-sh: ldd: not found
# /lib/libc.so.6 --version
GNU C Library (Sourcery G++ Lite 2010.09-50) stable release version 2.11.1, by Roland McGrath et al.
Copyright (C) 2009 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.
Compiled by GNU CC version 4.5.1.
Compiled on a Linux >>2.6.24-26-server<< system on 2010-11-07.
Available extensions:
	crypt add-on version 2.1 by Michael Glad and others
	GNU Libidn by Simon Josefsson
	Native POSIX Threads Library by Ulrich Drepper et al
	Support for some architectures added on, not maintained in glibc core.
	BIND-8.2.3-T5B
For bug reporting instructions, please see:
<https://support.codesourcery.com/GNUToolchain/>.

@arthurlutz
Copy link
Contributor Author

@liamHowatt great tips, thanks so much for looking into this!

Unfortunately I can get it to compile :

❯ make -j
[  1%] Building CXX object lvgl/CMakeFiles/lvgl_thorvg.dir/src/libs/thorvg/tvgAnimation.cpp.o
[  1%] Building CXX object lvgl/CMakeFiles/lvgl_thorvg.dir/src/libs/thorvg/tvgBezier.cpp.o
[  1%] Building CXX object lvgl/CMakeFiles/lvgl_thorvg.dir/src/libs/thorvg/tvgCapi.cpp.o
[  1%] Building CXX object lvgl/CMakeFiles/lvgl_thorvg.dir/src/libs/thorvg/tvgCompressor.cpp.o
[  1%] Building CXX object lvgl/CMakeFiles/lvgl_thorvg.dir/src/libs/thorvg/tvgInitializer.cpp.o
[  1%] Building CXX object lvgl/CMakeFiles/lvgl_thorvg.dir/src/libs/thorvg/tvgFill.cpp.o
arm-linux-gnueabihf-g++: error: unrecognized command line option '-std=gnu++17'
arm-linux-gnueabihf-g++: error: unrecognized command line option '-std=gnu++17'
arm-linux-gnueabihf-g++: error: unrecognized command line option '-std=gnu++17'
[  1%] Building CXX object lvgl/CMakeFiles/lvgl_thorvg.dir/src/libs/thorvg/tvgCanvas.cpp.o
make[2]: *** [lvgl/CMakeFiles/lvgl_thorvg.dir/build.make:76: lvgl/CMakeFiles/lvgl_thorvg.dir/src/libs/thorvg/tvgAnimation.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [lvgl/CMakeFiles/lvgl_thorvg.dir/build.make:90: lvgl/CMakeFiles/lvgl_thorvg.dir/src/libs/thorvg/tvgBezier.cpp.o] Error 1
make[2]: *** [lvgl/CMakeFiles/lvgl_thorvg.dir/build.make:118: lvgl/CMakeFiles/lvgl_thorvg.dir/src/libs/thorvg/tvgCapi.cpp.o] Error 1
arm-linux-gnueabihf-g++: error: unrecognized command line option '-std=gnu++17'
arm-linux-gnueabihf-g++: error: unrecognized command line option '-std=gnu++17'
[  2%] Building CXX object lvgl/CMakeFiles/lvgl_thorvg.dir/src/libs/thorvg/tvgLoader.cpp.o
arm-linux-gnueabihf-g++: error: unrecognized command line option '-std=gnu++17'
[  2%] Building CXX object lvgl/CMakeFiles/lvgl_thorvg.dir/src/libs/thorvg/tvgMath.cpp.o
[  2%] Building CXX object lvgl/CMakeFiles/lvgl_thorvg.dir/src/libs/thorvg/tvgPicture.cpp.o
[  2%] Building CXX object lvgl/CMakeFiles/lvgl_thorvg.dir/src/libs/thorvg/tvgPaint.cpp.o
arm-linux-gnueabihf-g++: error: unrecognized command line option '-std=gnu++17'
make[2]: *** [lvgl/CMakeFiles/lvgl_thorvg.dir/build.make:132: lvgl/CMakeFiles/lvgl_thorvg.dir/src/libs/thorvg/tvgCompressor.cpp.o] Error 1
make[2]: *** [lvgl/CMakeFiles/lvgl_thorvg.dir/build.make:146: lvgl/CMakeFiles/lvgl_thorvg.dir/src/libs/thorvg/tvgFill.cpp.o] Error 1
arm-linux-gnueabihf-g++: error: unrecognized command line option '-std=gnu++17'
make[2]: *** [lvgl/CMakeFiles/lvgl_thorvg.dir/build.make:160: lvgl/CMakeFiles/lvgl_thorvg.dir/src/libs/thorvg/tvgInitializer.cpp.o] Error 1
make[2]: *** [lvgl/CMakeFiles/lvgl_thorvg.dir/build.make:104: lvgl/CMakeFiles/lvgl_thorvg.dir/src/libs/thorvg/tvgCanvas.cpp.o] Error 1
make[2]: *** [lvgl/CMakeFiles/lvgl_thorvg.dir/build.make:174: lvgl/CMakeFiles/lvgl_thorvg.dir/src/libs/thorvg/tvgLoader.cpp.o] Error 1
arm-linux-gnueabihf-g++: error: unrecognized command line option '-std=gnu++17'
make[2]: *** [lvgl/CMakeFiles/lvgl_thorvg.dir/build.make:188: lvgl/CMakeFiles/lvgl_thorvg.dir/src/libs/thorvg/tvgMath.cpp.o] Error 1
arm-linux-gnueabihf-g++: error: unrecognized command line option '-std=gnu++17'
make[2]: *** [lvgl/CMakeFiles/lvgl_thorvg.dir/build.make:216: lvgl/CMakeFiles/lvgl_thorvg.dir/src/libs/thorvg/tvgPicture.cpp.o] Error 1
arm-linux-gnueabihf-g++: error: unrecognized command line option '-std=gnu++17'
make[2]: *** [lvgl/CMakeFiles/lvgl_thorvg.dir/build.make:202: lvgl/CMakeFiles/lvgl_thorvg.dir/src/libs/thorvg/tvgPaint.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:188: lvgl/CMakeFiles/lvgl_thorvg.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 46%] Built target lvgl
make: *** [Makefile:136: all] Error 2

would you have an idea on what I need to change to fix this ? Maybe I can test out the binary produced by your compilation ?

@liamHowatt
Copy link

@arthurlutz

C++17 didn't exist when that compiler was released so it doesn't support the flag -std=gnu++17. If you're not using thorvg then you can just not compile it in your CMakeLists.txt.

Remove lvgl::thorvg from this line.
https://github.com/lvgl/lv_port_linux_frame_buffer/blob/dccc6a1ca48372aa993dbea7a8e17dec6f42df6a/CMakeLists.txt#L15

And then also change this 1 to a 0.
https://github.com/lvgl/lv_port_linux_frame_buffer/blob/dccc6a1ca48372aa993dbea7a8e17dec6f42df6a/lv_conf.h#L696

By doing these things and using yours and kisvegabor's tweaks I was able to get it to compile with the v4 toolchain. Sorry, I hadn't tried to actually compile it until now :P

Fingers crossed the glibc versions match! 🤞️

I think XuNeo's suggestion was a good idea if this fails to execute again.

@HanesSciarrone
Copy link

Hi @arthurlutz, thanks for the wish.

The command output you ran confirms that the problem is the GLIBC used in the toolchain between the Build system and the target so, the issue is here.

The chance of fixing the problem with the liamHowatt suggestion is quite high. But, if it doesn't work you need to download the version of the toolchain used in the target, this information is here:

/lib/libc.so.6 --version
GNU C Library (Sourcery G++ Lite 2010.09-50) stable release version 2.11.1, by Roland McGrath et al.
Copyright (C) 2009 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.
Compiled by GNU CC version 4.5.1.
Compiled on a Linux >>2.6.24-26-server<< system on 2010-11-07.
Available extensions:
	crypt add-on version 2.1 by Michael Glad and others
	GNU Libidn by Simon Josefsson
	Native POSIX Threads Library by Ulrich Drepper et al
	Support for some architectures added on, not maintained in glibc core.
	BIND-8.2.3-T5B
For bug reporting instructions, please see:
<https://support.codesourcery.com/GNUToolchain/>.

The toolchain version is GNU CC version 4.5.1. About the sysroot in general the toolchain comes with it. I would like to suggest you @arthurlutz that instead of installing the toolchain on your build system you untzip the Linaro tar in some folder and modify the CMake toolchain file to point to the folder.

@HanesSciarrone
Copy link

I'll try to find toolchain version 4.5.1 while testing @liamHowatt 's solution. Please @arthurlutz, let us know if the solution works.

@arthurlutz
Copy link
Contributor Author

arthurlutz commented Mar 18, 2024

Hi thanks a lot again for being so thorough with helping me out with this.

The changes suggested don't seem to remove all thorvg from the make files, I still get the same errors, here is my diff :

❯ git diff
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d91b196..a1a89ab 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,13 @@
 cmake_minimum_required(VERSION 3.10)
 project(lvgl)
 
+set(CMAKE_SYSTEM_NAME Linux)
+set(CMAKE_SYSTEM_PROCESSOR arm)
+set(CMAKE_C_COMPILER /home/arthur/local/gcc-linaro-4.9-2015.02-3-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc)
+set(CMAKE_CXX_COMPILER /home/arthur/local/gcc-linaro-4.9-2015.02-3-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++)
+
+
+
 set(CMAKE_C_STANDARD 99)#C99 # lvgl officially support C99 and above
 set(CMAKE_CXX_STANDARD 17)#C17
 set(CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -12,6 +19,6 @@ target_include_directories(lvgl PUBLIC ${PROJECT_SOURCE_DIR})
 
 add_executable(main main.c mouse_cursor_icon.c)
 
-target_link_libraries(main lvgl lvgl::examples lvgl::demos lvgl::thorvg ${SDL2_LIBRARIES} m pthread)
+target_link_libraries(main lvgl lvgl::examples lvgl::demos ${SDL2_LIBRARIES} m pthread)
 add_custom_target (run COMMAND ${EXECUTABLE_OUTPUT_PATH}/main DEPENDS main)
 
diff --git a/lv_conf.h b/lv_conf.h
index 822b2a3..2e93e4e 100644
--- a/lv_conf.h
+++ b/lv_conf.h
@@ -693,7 +693,7 @@
 #define LV_USE_VECTOR_GRAPHIC  1
 
 /* Enable ThorVG (vector graphics library) from the src/libs folder */
-#define LV_USE_THORVG_INTERNAL 1
+#define LV_USE_THORVG_INTERNAL 0
 
 /* Enable ThorVG by assuming that its installed and linked to the project */
 #define LV_USE_THORVG_EXTERNAL 0
diff --git a/lvgl b/lvgl
--- a/lvgl
+++ b/lvgl
@@ -1 +1 @@
-Subproject commit 5c9a0cc017dd23b2103dbc6b88fb155193020187
+Subproject commit 5c9a0cc017dd23b2103dbc6b88fb155193020187-dirty

(I can push a fork if that's easier to follow/review)

in build :

❯ rgrep thorvg * 
[snip]
lvgl/CMakeFiles/lvgl_thorvg.dir/DependInfo.cmake:  "/home/arthur/local/lv_port_linux_frame_buffer/lvgl/src/libs/thorvg/tvgXmlParser.cpp" "lvgl/CMakeFiles/lvgl_thorvg.dir/src/libs/thorvg/tvgXmlParser.cpp.o" "gcc" "lvgl/CMakeFiles/lvgl_thorvg.dir/src/libs/thorvg/tvgXmlParser.cpp.o.d"
lvgl/CMakeFiles/lvgl_thorvg.dir/DependInfo.cmake:  "/home/arthur/local/lv_port_linux_frame_buffer/lvgl/src/others/vg_lite_tvg/vg_lite_tvg.cpp" "lvgl/CMakeFiles/lvgl_thorvg.dir/src/others/vg_lite_tvg/vg_lite_tvg.cpp.o" "gcc" "lvgl/CMakeFiles/lvgl_thorvg.dir/src/others/vg_lite_tvg/vg_lite_tvg.cpp.o.d"
Makefile:# Target rules for targets named lvgl_thorvg
Makefile:lvgl_thorvg: cmake_check_build_system
Makefile:	$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 lvgl_thorvg
Makefile:.PHONY : lvgl_thorvg
Makefile:lvgl_thorvg/fast:
Makefile:	$(MAKE) $(MAKESILENT) -f lvgl/CMakeFiles/lvgl_thorvg.dir/build.make lvgl/CMakeFiles/lvgl_thorvg.dir/build
Makefile:.PHONY : lvgl_thorvg/fast
Makefile:	@echo "... lvgl_thorvg"

❯ rgrep thorvg * | wc -l
1241

@XuNeo
Copy link

XuNeo commented Mar 18, 2024

The changes suggested don't seem to remove all thorvg from the make files, I still get the same errors, here is my diff :

Looks like you need LV_CONF_BUILD_DISABLE_THORVG_INTERNAL to completely remove it from CMake. Changing macros to 0 only disables the file content.

https://github.com/lvgl/lvgl/blob/master/env_support/cmake/custom.cmake#L47-L52

@arthurlutz
Copy link
Contributor Author

Interesting, in which file do I have to insert that ?

@XuNeo
Copy link

XuNeo commented Mar 18, 2024

It should be passed in from cmake.
cmake -Bbuild -GNinja -DLV_CONF_BUILD_DISABLE_THORVG_INTERNAL=1 This is what I used.

@liamHowatt
Copy link

My build worked without that flag because I ran make main instead of make so that only the dependencies of the executable "main" would be built. My bad.

@arthurlutz
Copy link
Contributor Author

@liamHowatt that works ! I get to compile a main binary. But... I can't execute it :

# mv main lvgl
# file ./lvgl 
./lvgl: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, not stripped
# ./lvgl 
-sh: ./lvgl: not found
# ./lvgl --verbose
-sh: ./lvgl: not found
# ./lvgl --debug
-sh: ./lvgl: not found

Do you know how I can debug this ?

@XuNeo thanks for the suggestion but that didn't filter out thorvg. But I learned that I can compile it with ninja instead of make... that's interesting.

@XuNeo
Copy link

XuNeo commented Mar 18, 2024

You may try chmod +x lvgl firstly.

@arthurlutz
Copy link
Contributor Author

Tried that, it didn't change the output.

@HanesSciarrone
Copy link

Hi @arthurlutz, I hope you are ok,

Could you share with us the output of the ls -al command where you have the binary file on your build systems? It's strange that the binary after compilation doesn't have execute permission.

@arthurlutz
Copy link
Contributor Author

# ls -alh lvgl 
-rwxr-xr-x    1 root     root        1.2M Jan  1 06:54 lvgl
# file lvgl 
lvgl: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, not stripped
# md5sum lvgl 
e45c3a4a1434f9620268bdd61a864f40  lvgl
# head lvgl 
ELF(�
|||��PPPDDQ�td/lib/ld-linux-armhf.so.3GNUGNUN���3�u#)�]m�ەn��%*$ )'&	"(
                                                                         %
[snip]

@HanesSciarrone
Copy link

The output appears to be from the SBC rather than the workstation. Is it possible? In any case, we can see that you have execution permissions. 😕

@arthurlutz
Copy link
Contributor Author

Yes, the not found error is when running on the target system. Not on the build station.

@HanesSciarrone
Copy link

Yes, I know that the not found error is when running on the target system. I was referring to the output of the ls -al command. 😅

@arthurlutz
Copy link
Contributor Author

I can confirm the ls -al command was run on the target system.

@HanesSciarrone
Copy link

@arthurlutz

I would like to try something. First of all I would like to know if you are using this Toolchain as cross-compiler: 4.9.4 linaro toolchain.

Also, I would like to ask you if you can share with us a link of your repository with the changes you made so far in a branch.

@liamHowatt
Copy link

@arthurlutz

The shell on the target is missing some of the nice things that come with standard ".bashrc" configs. It seems that you cannot launch an executable without specifying the full path to the executable. I was able to reproduce the problem like so

liam@liam-Precision-3520:~$ ./a.out          # executable runs fine
foobar
liam@liam-Precision-3520:~$ bash --norc      # start a shell without configs -- similar to your target's shell.
bash-5.0$ ./foobar                           # "no such file or directory"
bash: ./foobar: No such file or directory    # even though it should work.
bash-5.0$ $PWD/a.out                         # specify the full path to the
foobar                                       # executable in this limited
bash-5.0$                                    # target shell.

Try running the executable like this:

$PWD/lvgl

@arthurlutz
Copy link
Contributor Author

@HanesSciarrone I can confirm I'm using that toolchain (at least I think I have configured it to use it, and the information from file seems to confirm that...)

@liamHowatt I thought of that too, and had tried the full path. Same result. I'm really curious as to where this not found is coming from. I'd love to launch it with strace but that's a tool that is not present. Tried switching to ash, same result. Tried to move to a different mount point, same result.

@liamHowatt
Copy link

liamHowatt commented Mar 18, 2024

@arthurlutz is it a read-only filesystem? It's not uncommon to have most/all of the rootfs be read-only in embedded Linux. Try ./main if the original main executable was flashed the the device. The mv should have failed but it seems to have created a file lvgl that's "not real", still visible with ls. When you power cycle is the file called main again? If you need a writable temporary RAM directory, run mktemp -d and mv the executable there.

@arthurlutz
Copy link
Contributor Author

Parts of the file system are mounted as ro, but for some tests I remounted it to rw. Do you think it's possible that the -sh: ./lvgl: not found is coming from not being able to write somewhere ?

I have a number of binaries that I manage to copy to that device and execute without this problem (some compiled golang, but also some compiled rust and compiled C as mentioned at the beginning of the issue).

@liamHowatt
Copy link

liamHowatt commented Mar 19, 2024

@arthurlutz Please try running ldd lvgl on the target.

@arthurlutz
Copy link
Contributor Author

@liamHowatt unfortunately ldd is not present on the target. (I could look into cross compiling it if you think that's useful)

@liamHowatt
Copy link

@arthurlutz Hmm, any chance gdbserver is installed on the target?

@liamHowatt
Copy link

@arthurlutz

Do you think it's possible that the -sh: ./lvgl: not found is coming from not being able to write somewhere ?

At first I thought that message was coming from the shell saying the file doesn't exist, but I think it is coming from from the executable.

See if you can get one of these on your target

  • strace
  • ldd
  • gdb (Not gdbserver as I originally said. There's more than enough RAM for gdb)

@HanesSciarrone
Copy link

Hi @liamHowatt

I'm not sure if the gdb command will work if the executable doesn't have the debug symbols. And the ldd command isn't available in the target as @arthurlutz said.

@arthurlutz
Copy link
Contributor Author

Nope, sorry :

# strace
-sh: strace: not found
# ldd
-sh: ldd: not found
# gdb
-sh: gdb: not found
# fcd /
-sh: fcd: not found
# cd /
# find . | grep strace
# find . | grep ldd
# find . | grep gdb
# 

Can I compile the binary with some debug prints ?

@liamHowatt
Copy link

It's tricky because the message being printed for no strace, ldd, gdb, etc. -- -sh: strace: not found is the same as -sh: ./lvgl: not found which suggests lvgl really does not exist. Maybe try putting lvgl in /usr/bin assuming that path is rw and run lvgl with no path.

I'm not sure if the gdb command will work if the executable doesn't have the debug symbols.

Agreed @HanesSciarrone, I was thinking we could break at syscalls (catch syscall) or library loads (catch load) without line info https://sourceware.org/gdb/current/onlinedocs/gdb.html/Set-Catchpoints.html. strace would be better for this.

@arthurlutz
Copy link
Contributor Author

# mount -o remount,rw /
# mv lvgl /bin/
# /bin/lvgl 
-sh: /bin/lvgl: not found
# echo $PATH
/bin:/sbin:/usr/bin:/usr/sbin:/usr/bin/X11:/usr/local/bin

Oh, and here is some info about the shell :

# which sh
/bin/sh
# file /bin/sh
/bin/sh: symbolic link to `busybox'
# file /bin/busybox 
/bin/busybox: setuid ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, stripped
# busybox 
BusyBox v1.18.3 (2016-09-05 12:26:14 CEST) multi-call binary.

(this feels like an escape game 🤣, thanks for playing with me)

@liamHowatt
Copy link

liamHowatt commented Mar 21, 2024

Do me a favor and run df -Th. I want to see what type of filesystem / is. If it's squashfs or something the rw remount could never be writable since it's a compressed filesystem image. Also try invoking lvgl as just lvgl without the /bin/ for good measure.

# df -Th
Filesystem     Type      Size  Used Avail Use% Mounted on
...
/dev/sdaX      this       XXG   XXG   XXG  XX% /
...

(interested in the this field)

(this feels like an escape game 🤣, thanks for playing with me)

It really does XD

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

5 participants