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

Build unknown mraa platform #21

Open
kleysoncastro opened this issue Jan 18, 2024 · 2 comments
Open

Build unknown mraa platform #21

kleysoncastro opened this issue Jan 18, 2024 · 2 comments

Comments

@kleysoncastro
Copy link

When the lib mraa is installed with apt it receives this MRAA version (v2.1.0-22-gb24cd50) on the Radxa ROCK Pi S.

  • When done using buildroot, the version looks like this. Version 2022.02.1 on Unknown platform

code

#include <iostream>
#include <mraa.hpp>

int main() {
    // Inicializar o barramento I2C
    mraa::I2c i2c(0);  // O número 0 refere-se ao barramento I2C 0

    // Verificar se o barramento I2C foi inicializado corretamente
    if (!i2c.address(0x0A)) {
        std::cerr << "Erro ao inicializar o barramento I2C" << std::endl;
        return 1;
    }

    // Ler um byte do dispositivo no endereço 0x0A
    uint8_t dataRead;
    if (i2c.read(&dataRead, 1) != mraa::SUCCESS) {
        std::cerr << "Erro ao ler do dispositivo I2C" << std::endl;
        return 1;
    }

    std::cout << "Valor lido: " << static_cast<int>(dataRead) << std::endl;

    return 0;
}
  • The code above runs normally in the debian version, in the version with buildroot I have this error
# ./i2c-list 
terminate called after throwing an instance of 'std::invalid_argument'
  what():  Invalid i2c bus
Aborted

Using, it ok

# i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- 0a -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

I don't know if it's appropriate to open an issue here, but I would like to compile this mraa lib to run on my image. can you help me ?

@haelyons
Copy link
Contributor

There could be a couple reasons for this; have you checked that upstream mraa supports ROCK Pi S, and are you using the default mraa package in Buildroot?

Are you using the default mraa package within Buildroot? I had this issue when cross-compiling a custom mraa version and it was due to the correct headers not being installed.

@kleysoncastro
Copy link
Author

There could be a couple reasons for this; have you checked that upstream mraa supports ROCK Pi S, and are you using the default mraa package in Buildroot?

Are you using the default mraa package within Buildroot? I had this issue when cross-compiling a custom mraa version and it was due to the correct headers not being installed.

Yes, it is buildroot's own mraa lib.
If you look carefully in the buildroot/package/mrra directory
there is a *.pach correction that is to correct an import of a global variable.
1 Taking this into account, one of the ways to build mrra for RK03308 is to fork mraa on radxa's github, and apply the patch.
2 you can fork the radxa mrra lib and in the buildroot/package/mrra/mraa.mk directory change the flag #MRAA_SITE = $(call github,eclipse,mraa,v$(MRAA_VERSION)) to MRAA_SITE = https://github.com/kleysoncastro/mraa/archive/refs/tags.
of this "source" farm, you need to tag it in the lib,
but you can copy this line (MRAA_SITE = https://github.com/kleysoncastro/mraa/archive/refs/tags), then buildroot will do it in my repo. Hope this helps.

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