Is there a PlatformIO Expert in the House?



  • I'm trying to build M5Stack Core2 projects on PlatformIO (on Windows, if it matters.)
    I've been tracking RopG's Fork, so M5Core2 was in my project's lib folder, and things worked fine.
    Now I've moved it to the [user].platformio\lib folder, and I have problems.

    If the M5Stack library is NOT installed, the project compiles and links and this is the Dependency Graph:

    |-- <M5Core2> 0.0.1
    |   |-- <Wire> 1.0.1
    |   |-- <SPIFFS> 1.0
    |   |   |-- <FS> 1.0
    |   |-- <FS> 1.0
    |   |-- <SPI> 1.0
    |   |-- <HTTPClient> 1.2
    |   |   |-- <WiFi> 1.0
    |   |   |-- <WiFiClientSecure> 1.0
    |   |   |   |-- <WiFi> 1.0        
    |   |-- <SD(esp32)> 1.0.5
    |   |   |-- <FS> 1.0
    |   |   |-- <SPI> 1.0
    

    However, if both M5Stack and M5Core2 libraries are installed in [user].platformio\lib, I get this Dependency Graph:

    |-- <M5Core2> 0.0.1
    |   |-- <Wire> 1.0.1
    |   |-- <SPIFFS> 1.0
    |   |   |-- <FS> 1.0
    |   |-- <FS> 1.0
    |   |-- <SPI> 1.0
    |   |-- <HTTPClient> 1.2
    |   |   |-- <WiFi> 1.0
    |   |   |-- <WiFiClientSecure> 1.0    
    |   |   |   |-- <WiFi> 1.0
    |   |-- <M5Stack> 0.3.0
    |   |   |-- <FS> 1.0
    |   |   |-- <SPIFFS> 1.0
    |   |   |   |-- <FS> 1.0
    |   |   |-- <SPI> 1.0
    |   |   |-- <HTTPClient> 1.2
    |   |   |   |-- <WiFi> 1.0
    |   |   |   |-- <WiFiClientSecure> 1.0
    |   |   |   |   |-- <WiFi> 1.0        
    |   |   |-- <Wire> 1.0.1
    |   |   |-- <SD(esp32)> 1.0.5
    |   |   |   |-- <FS> 1.0
    |   |   |   |-- <SPI> 1.0
    |   |-- <SD(esp32)> 1.0.5
    |   |   |-- <FS> 1.0
    |   |   |-- <SPI> 1.0
    

    Everything compiles, but I get innumerable linking errors like:

    .pio\build\m5stack-fire\libb51\libM5Core2.a(M5Core2.cpp.o):(.bss.M5+0x0): multiple definition of `M5'
    .pio\build\m5stack-fire\lib3c8\libM5Stack.a(M5Stack.cpp.o):(.bss.M5+0x0): first defined here
    c:/users/van/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: Warning: size of symbol `M5' changed from 332 in .pio\build\m5stack-fire\lib3c8\libM5Stack.a(M5Stack.cpp.o) to 1856 in .pio\build\m5stack-fire\libb51\libM5Core2.a(M5Core2.cpp.o)
    

    My platformio.ini is plain vanilla:

    [env:m5stack-fire]
    platform = espressif32
    board = m5stack-fire
    framework = arduino
    monitor_speed = 115200
    

    I've tried it with incredibly trivial projects, it's always the same.
    Any suggestions? Is anyone successful at this?



  • Hi Van

    you could try to define two environments and use lib_ignore to only compile one of the two libraries, depending on the selected device:

    [platformio]
    default_envs = m5stack
    ;default_envs = m5core2
    
    [env:m5stack]
    platform = espressif32
    board = m5stack-core-esp32
    framework = arduino
    lib_ignore = M5Core2
    
    [env:m5core2]
    platform = espressif32
    board = m5stack-fire
    framework = arduino
    lib_ignore = M5Stack
    

    Cheers
    Felix



  • @felmue That's a very simple change and works great! Thanks a million!
    Still on the topic of "Is there a Brain Genius in the House?" I have one more PlatformIO question:

    When I compile Core2 programs that allocate lots of memory, they work if built on Arduino but fail at runtime if built on PIO. It seems that Arduino is somehow dynamically aware of the 8MB PSRAM, while PIO is not. I believe PIO uses the board def to select ..\partitions\default_16MB.csv, which seems to limit app0 to 64K. I bet that's it.

    So when I execute a statement like disp.createSprite(320, 240) it works fine if I build with Arduino, but PIO tells the Core2 it doesn't have that much RAM, so it fails. The factory test program likewise won't run if built as an M5Stack-Fire on PIO.

    Does anyone have a definition for an M5Stack-Core2 board and an appropriate partition map for it for PIO?



  • Hi Van

    you're very welcome. I don't have a partition map and so far I didn't need one. For the additional PSRAM I've added these two lines for M5Core2:

    build_flags = 
        -DBOARD_HAS_PSRAM
        -mfix-esp32-psram-cache-issue
    

    (I am not sure if the second line actually is really needed still, but it doesn't seem to hurt.)

    Cheers
    Felix



  • Works like a champ!
    If we ever meet, I will buy you a beer.



  • Hello Van

    sounds like a plan - thank you. Glad to help out.

    Cheers
    Felix

    P.S. I am very sorry for misspelling your name previously (fixed now).