Core2 Factory Test



  • Hello,
    I got some challenges with the Core2 Factory Test:

    • If Core2 init started, it didn't detect the four I2C-devices. If I inserted a call of
      "scani2caddr" before "checkI2cAddr" every thing worked fine.
    • In the main view there are five icons on the bottom. On the far left is an image icon. If I touch the image icon, all five icons disappear and nothing else happens. Is this normal?
      I didn't find a video with using this misterious image icon.


  • Hello @sheepDog

    the M5Core2 library initialises two i2c instances (Wire and Wire1) using the same pins (21 and 22) and that leads to collisions. Have a look at the following pull-request which changes the pins for Wire making Wire1 work.

    https://github.com/m5stack/M5Core2/pull/3/files

    As for the far left icon: I think if you insert an SD card with pictures on it you'll be able to view them through that icon. I have not tried that myself though so I might be wrong.

    Cheers
    Felix



  • Without modifying the M5Core2 library, I found a bit of "magic" that fixes the factory test sketch, although I cannot explain exactly why it works!
    In Core2_Factory_test.ino, at line 439 you will find checkI2cAddr(). This is the function which is failing.
    If you insert a begin/end transmission before the do loop, it works.
    Considering Felix's comments, I suppose this somehow invokes a reinitialization of the I2C interface. Or something.
    I was experimenting, trying to see if I could scan the bus at this point in the code. It turned out I could, and the problem was fixed as a side effect.
    I reduced it to the minimum code needed, shown below.
    Fixing the library is the right way to go, but I assume there will be a flurry of library updates at some point soon, and your changes may be lost.

    int checkI2cAddr()
    {
        // HACKHACK: It fails unless I do this. Can be any address. PFM.
        Wire.beginTransmission(1);
        Wire.endTransmission();
        
        uint8_t count = 0;
        i2cDevice_t *lastptr = &i2cParentptr;
        do{
            lastptr = lastptr->nextPtr;
            ...
    

    I hope this helps.



  • Hi guys

    @vkichline : interesting. I guess your hack makes Wire releasing the clock and data lines and that allows Wire1 to work properly.

    Another way to fix the issue (I think, not tested) without touching the libraries could be the following change in Core2_Factory_test.ino:

    current code:

    M5.begin(true, true, true, true);
    

    modified code:

    M5.begin(true, true, true, false);
    

    with the last parameter set to false Wire doesn't get initialised and Wire1 should work properly.

    But yes, I fully agree, the issue should be properly resolved in the libraries. Hopefully we'll see those issues cleared up soon.

    Felix



  • Hi guys,

    thank you very much for your great help.

    I used my time to analyse the code and the image icon started

       drawJPEGImageFromSDCard(SD,"/image")
    

    and this procedure read all JPG-Files in the subdirectory "image".
    It is like a slideshow and it worked fine.

    I like to post an issue in github to solve the problem with I2C, but there
    was issue 25



  • In another thread, it became clear that the most appropriate fix for this issue in the factory test code is:
    On lines 446 and 447, in the function checkI2cAddr():
    Change one instance of Wire. to Wire1. one each of the two lines.

            Wire.beginTransmission( lastptr->addr );
            if ( Wire.endTransmission() == 0 )
    

    ...becomes:

            Wire1.beginTransmission( lastptr->addr );
            if ( Wire1.endTransmission() == 0 )