Compile on Wandboard (iMX6) to run on BBB

Hello foxsquirrel,

It feels like I was hijacking the thread so thought I would send you a personal message instead.

I dug out my Wandboard to see what is on it.

kernel: Linux wandboard 4.15.0-rc9-armv7-x0 #1 SMP Mon Jan 22 05:24:45 UTC 2018 armv7l GNU/Linux
rootfs: Debian GNU/Linux 8.10 (jessie)
compiler: gcc version 4.9.2 (Debian 4.9.2-10+deb8u1).

I have 2 different BBB setups.

One that runs an app based on libSDL1.2. It also runs some stuff the uses the PRUs.

kernel: Linux bbb 3.8.13-bone80 #1 SMP Wed Jun 15 17:03:55 UTC 2016 armv7l GNU/Linux
rootfs: Debian GNU/Linux 7.11 (wheezy)
compiler: gcc version 4.6.3 (Debian 4.6.3-14)

This setup is why I originally got the Wandboard. At that time the only image I could find for it was the jessie setup.

The Wandboard and BBB compiler versions were close enough that a simple “Hello World” would work when compiled on the Wandboard and ran on the BBB. But anything more advanced or using libSDL1.2 would crash. I can’t remember the details.

This BBB setup is currently locked to the 3.8.13 kernel and wheezy rootfs due to the PRU stuff. I have not had time to figure out how to update the PRU stuff to a newer kernel.

But, this setup is not really a problem. A full native compile of my app on this setup only takes about 30min.

The other setup I have runs a Qt5 based app:

kernel: Linux bbb 4.9.105-ti-r114 #1 SMP PREEMPT Fri Aug 17 11:05:53 UTC 2018 armv7l GNU/Linux
rootfs: Debian GNU/Linux 9.13 (stretch)
compiler: gcc version 6.3.0 20170516 (Debian 6.3.0-18+deb9u1)

This one is the painful 3+ hour compile.

I have not tried to compile the app on the Wandboard. But I doubt it would work. The compiler versions are way different.

I see there is a Debian 11 rootfs on Debian: Getting Started with the Wandboard - Linux Guides - Electronic Component and Engineering Solution Forum - TechForum │ DigiKey. But I think I would have the same problem with that.

I could possibly update this BBB setup to the latest 11.7 release. But I believe that I would also need to update my app from Qt5 to Qt6. Some of that would be a bit difficult if not impossible. I also have a couple thousand systems in the field that would be quite difficult to update…

Kind of stuck between a rock and a hard place…

Docker comes in handy to do these armhf to armhf cross builds with matching system libraries…

Regards,

I know the term “Docker”. Have no idea what it is…

Regards

Docker is a way to share, build and use distro images… In your case, you want a matching build image for your old BBB wheezy rootfs…

In docker, on your armhf (wandboard)

docker pull debian:wheezy-slim

that’ll pull in this image: https://hub.docker.com/layers/library/debian/wheezy-slim/images/sha256-a3bffe7e1deda097af9da844abc6111337ec5b34a0a9b942a8948deeaa7f575b?context=explore

it’ll have some big issues, like you’ll have to tweak apt to look at archive.debian.net, but it’ll get you very close to the image on the BBB.

Regards,

Robert,

docker is not installed on the wandboard.

I’m thinking about updating the wandboard to the Debian 11 rootfs. Then at least i have a modern rootfs to work with, and possibly docker…

But I’m having trouble figuring out the process from the “Getting Started with the Wanrdboard” link above. This board does not appear to be as simple to update as the BBB.

Is there a more “dummies” version of the process documented anywhere?

Thanks

Oh I retired my fleet of Wandboards, replaced them with 4gb/8gb rpi4’s… debian.org should have a Wandboards image.

https://deb.debian.org/debian/dists/stable/main/installer-armhf/current/images/netboot/SD-card-images/

Follow these steps with the above files,^… InstallingDebianOn/Wandboard - Debian Wiki

This is some SDL2 test code. If you can get the libs installed it should build. I will toss in the cmake, you might have to play with that depending on how everything is installed on the target.

#include <SDL2/SDL.h>
#include <GL/glew.h>
#include <stdio.h>


//This does work
//CMake: target_link_libraries(${PROJECT_NAME} SDL2 GLEW GL)
// Vertex shader source code
//sudo apt install libsdl2-dev libopengl-dev libglew-dev libsdl2-2.0-0
//https://github.com/libsdl-org/SDL.git
//
const char* vertexShaderSource = R"(
    #version 330 core
    layout (location = 0) in vec2 position;
    void main() {
        gl_Position = vec4(position.x, position.y, 0.0, 1.0);
    }
)";

// Fragment shader source code
const char* fragmentShaderSource = R"(
    #version 330 core
    out vec4 FragColor;
    void main() {
        FragColor = vec4(1.0, 0.5, 0.2, 1.0); // Orange color
    }
)";

int main() {
    // Initialize SDL2
    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
        printf("SDL initialization failed: %s\n", SDL_GetError());
        return 1;
    }

    // Create a Wayland window
    SDL_Window* window = SDL_CreateWindow("OpenGL Square",
                                          SDL_WINDOWPOS_UNDEFINED,
                                          SDL_WINDOWPOS_UNDEFINED,
                                          800, 600,
                                          SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);
    if (!window) {
        printf("Window creation failed: %s\n", SDL_GetError());
        return 1;
    }

    // Create an OpenGL context
    SDL_GLContext context = SDL_GL_CreateContext(window);
    if (!context) {
        printf("OpenGL context creation failed: %s\n", SDL_GetError());
        return 1;
    }

    // Initialize GLEW
    glewExperimental = GL_TRUE;
    GLenum glewError = glewInit();
    if (glewError != GLEW_OK) {
        printf("GLEW initialization failed: %s\n", glewGetErrorString(glewError));
        return 1;
    }

    // Compile and link shaders
    GLuint vertexShader, fragmentShader, shaderProgram;
    vertexShader = glCreateShader(GL_VERTEX_SHADER);
    glShaderSource(vertexShader, 1, &vertexShaderSource, NULL);
    glCompileShader(vertexShader);

    fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
    glShaderSource(fragmentShader, 1, &fragmentShaderSource, NULL);
    glCompileShader(fragmentShader);

    shaderProgram = glCreateProgram();
    glAttachShader(shaderProgram, vertexShader);
    glAttachShader(shaderProgram, fragmentShader);
    glLinkProgram(shaderProgram);

    // Define square vertices
    GLfloat vertices[] = {
            -0.5f, -0.5f, // Bottom-left
            0.5f, -0.5f, // Bottom-right
            0.5f,  0.5f, // Top-right
            -0.5f,  0.5f  // Top-left
    };

    // Create VBO and IBO
    GLuint VBO, IBO;
    glGenBuffers(1, &VBO);
    glBindBuffer(GL_ARRAY_BUFFER, VBO);
    glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);

    GLuint indices[] = { 0, 1, 2, 2, 3, 0 };
    glGenBuffers(1, &IBO);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IBO);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);

    // Main loop
    while (1) {
        SDL_Event event;
        while (SDL_PollEvent(&event)) {
            if (event.type == SDL_QUIT)
                goto cleanup;
        }

        // Clear the screen
        glClear(GL_COLOR_BUFFER_BIT);

        // Use shader program
        glUseProgram(shaderProgram);

        // Bind VBO and IBO
        glBindBuffer(GL_ARRAY_BUFFER, VBO);
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IBO);

        // Specify vertex attribute layout
        glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(GLfloat), (void*)0);
        glEnableVertexAttribArray(0);

        // Draw the square
        glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);

        // Swap buffers
        SDL_GL_SwapWindow(window);
    }

    cleanup:
    // Clean up
    glDeleteProgram(shaderProgram);
    glDeleteShader(vertexShader);
    glDeleteShader(fragmentShader);
    glDeleteBuffers(1, &VBO);
    glDeleteBuffers(1, &IBO);

    // Destroy window and quit SDL2
    SDL_GL_DeleteContext(context);
    SDL_DestroyWindow(window);
    SDL_Quit();

    return 0;
}

cmake_minimum_required(VERSION 3.18)
project(sdl2_opengl)

set(CMAKE_CXX_STANDARD 17)

add_executable(sdl2_opengl main.cpp)
target_link_libraries(${PROJECT_NAME} SDL GLEW GL)
# SDL2
#find_package(SDL2 REQUIRED)
#target_link_libraries(${PROJECT_NAME} ${SDL2_LIBRARY})
#target_include_directories(${PROJECT_NAME} PUBLIC ${SDL2_INCLUDE_DIR})

 #OpenGL
find_package(OpenGL REQUIRED)
#target_link_libraries(${PROJECT_NAME} ${OPENGL_gl_LIBRARY})
#target_include_directories(${PROJECT_NAME} PUBLIC ${OPENGL_INCLUDE_DIR})

# GL Extension Wrangler (GLEW)
find_package(GLEW REQUIRED)
#target_link_libraries(${PROJECT_NAME} ${GLEW_LIBRARIES})
#target_include_directories(${PROJECT_NAME} PUBLIC ${GLEW_INCLUDE_DIRS})

foxsquirrel,

Thanks for the sample SDL2 code.

But, I’m not sure that would even run on the BBB, especially with the Debian 7.11 (wheezy) rootfs. The /etc/dogtag of the release I started with is:

$ cat /etc/dogtag
BeagleBoard.org Debian Image 2016-06-15

Was Wayland and OpenGL even around back then?

My SDL1.2 based app runs on the BBB without X. It just boots to a console and runs on directly on the framebuffer.

It’s simple and it works…

I was using opengl back when SGI placed it into public domain back in the 90’s. Did get a BBB up on Weston compositor and systemd and it was slow. I was trying to get the GPU unit to run but that was a lost cause, it was worth a try. Not a big deal we use Nextion HMI, much better than trying build around a graphics package. UART is your friend with that board, no point in burning up cpu time in a graphics loop.

Wayland I don’t know, I was out of the loop when that stuff was created.