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/Make Bug? : Cross Compile Fails #52

Open
elminster opened this issue Mar 7, 2024 · 17 comments
Open

Documentation/Make Bug? : Cross Compile Fails #52

elminster opened this issue Mar 7, 2024 · 17 comments

Comments

@elminster
Copy link

Following the instructions for a cross-compile;

Mipsel (Ingenic X2000E) - specific to the K1 SoC

Building for the K1/Max
1. unset SIMULATION && export CROSS_COMPILE=mips-linux-gnu-
2. make wpaclean && make wpaclient
3. make libhvclean && make libhv.a
4. make spdlogclean && make libspdlog.a
5. make clean && make -j$(nproc)
The executable is ./build/bin/guppyscreen

It fails on step 5 with:
skipping incompatible spdlog/build/libspdlog.a

Checking the archives it is not cross compiling libspdlog.a files

file color_sinks.cpp.o
color_sinks.cpp.o: ELF 64-bit LSB relocatable, x86-64, version 1 (GNU/Linux), not stripped

Whereas if I extract and check another archive like libhv.a they look fine

file appletls.o
appletls.o: ELF 32-bit LSB relocatable, MIPS, MIPS32 rel2 version 1 (SYSV), not stripped
@elminster
Copy link
Author

I did get it to compile by adding the following to the spdlog CMakeLists.txt, but have yet to test it

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR mips)
set(tools /tmp/mips-gcc720-glibc229)
set(CMAKE_CXX_COMPILER "${tools}/bin/mips-linux-gnu-c++")
set(CMAKE_AR "${tools}/bin/mips-linux-gnu-ar")

@ajs123
Copy link
Contributor

ajs123 commented Mar 9, 2024

I have the same error. Where in CMakeLists.txt did you place those lines?

@ajs123
Copy link
Contributor

ajs123 commented Mar 9, 2024

I can confirm that the binary runs on the Nebula Pad when compiled this way, with the specified lines at the top.

@ballaswag
Copy link
Owner

spdlog used to be build with their headers only options. I have since changed it to build and link as s static library. To cross compile spdlog, make sure your cross compile toolchain is in your PATH, then export CC and CXX to point a your cross compile toolchain. For example I do the following to build spdlog.a for mipsel:

export CC=mips-linux-gnu-gcc
export CXX=mips-linux-gnu-g++
cd spdlog && rm -rf build && mkdir build && cd build && cmake .. && make -j

@ballaswag
Copy link
Owner

I can confirm that the binary runs on the Nebula Pad when compiled this way, with the specified lines at the top.

The *-smallscreen.tar.gz variable from this repository's releases should work for the nebula pad. See assets here https://github.com/ballaswag/guppyscreen/releases

@elminster
Copy link
Author

elminster commented Mar 10, 2024

Thanks. It did work on the K1c in the way I compiled it above when I tested it, but I will try your method so as not to hack around with cmakefiles when I don't need to.

@ajs123
Copy link
Contributor

ajs123 commented Mar 10, 2024 via email

@ballaswag
Copy link
Owner

For the nebula pad, I export these:

export CROSS_COMPILE=mips-linux-gnu-
export CC=mips-linux-gnu-gcc
export CXX=mips-linux-gnu-g++
export GUPPY_SMALL_SCREEN=1
export EVDEV_CALIBRATE=1

For the K1C, the same build for k1/max should work.

@ajs123
Copy link
Contributor

ajs123 commented Mar 10, 2024

Cross-compile works with unmodified CMake config and the exports of CC and CXX and specified above. Thank you.

However, with GUPPY_SMALL_SCREEN=1, as shown by the two images, icons are scaled but text is not. The first image is from the distributed binary, the second from the recompiled binary. The opening of the log shows

[2024-02-19 08:19:28.955] [guppyscreen] [info] Guppy Screen Version: 0.0.21-beta
[2024-02-19 08:19:28.956] [guppyscreen] [info] DPI: 90
[2024-02-19 08:19:29.034] [guppyscreen] [debug] resolution 480 x 272

so if I'm reading the setup in main.cpp correctly it should be using the smaller font.

IMG_4288
IMG_4289

The new binary is also 5.7 MB instead of the 3.5 MB of the binary from the distribution, which seems like much more than one would expect from a difference in font files - so maybe some other difference.

@ballaswag
Copy link
Owner

You can strip the binary for a smaller executable. With the smallscreen flag it should select the smaller font. Will check my setup later to verify.

@ballaswag
Copy link
Owner

@ajs123 Since you're looking into the small screen version for nebula pad. One thing that'll be useful is the touch input calibration enabled for it. I don't own a nebula pad so I never figured out the min/max x/y for this display. So some users are reporting incorrect touches on their nebula pad. If you're up for it, see if you can figure out the correct min/max x/y for this device.

@ajs123
Copy link
Contributor

ajs123 commented Mar 10, 2024 via email

@ballaswag
Copy link
Owner

Here's the function that handles touch

indev_drv_1.read_cb = evdev_read_calibrated;

You should be able to add logs in there for the touch coordinates. Maybe log the raw coordinates before the calibration is done so you can find min/max then readjust those in the calibration function.

@ajs123
Copy link
Contributor

ajs123 commented Mar 10, 2024 via email

@ballaswag
Copy link
Owner

Thanks for this, I don't have the display to test. You can use the value you discovered and replace the min/max x/y here https://github.com/lvgl/lv_drivers/blob/71830257710f430b6d8d1c324f89f2eab52488f1/indev/evdev.c#L222

Give it a try to see if it's better than the existing release. If so, those are the value we should use for the nebula pad and not the ones hardcoded now.

@ajs123
Copy link
Contributor

ajs123 commented Mar 11, 2024

Cal is done and looks good. I moved it to another Issue thread since this one now has three issues in it. Re the fonts, just to tie up that loose end here, changing both lines as follows has no apparent effect, so the font must be getting set elsewhere.

lv_theme_t * th = height <= 480
      ? lv_theme_default_init(NULL, lv_palette_main(LV_PALETTE_BLUE), lv_palette_main(LV_PALETTE_RED), true, &lv_font_montserrat_10)
      : lv_theme_default_init(NULL, lv_palette_main(LV_PALETTE_BLUE), lv_palette_main(LV_PALETTE_RED), true, &lv_font_montserrat_10);
    lv_disp_set_theme(disp, th);

@pellcorp
Copy link
Contributor

you can also just make a change to the Makefile thus:

diff --git a/Makefile b/Makefile
index 1fce29d..4f78f40 100644
--- a/Makefile
+++ b/Makefile
@@ -102,7 +102,7 @@ libhv.a:
 
 libspdlog.a:
        @mkdir -p $(SPDLOG_DIR)/build
-       @cmake -B $(SPDLOG_DIR)/build -S $(SPDLOG_DIR)/
+       @cmake -B $(SPDLOG_DIR)/build -S $(SPDLOG_DIR)/ -DCMAKE_CXX_COMPILER=$(CXX)
        $(MAKE) -C $(SPDLOG_DIR)/build -j$(nproc)

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

4 participants