marklysze / Magic-Pocket-Control-ESP32

Blackmagic Design Camera Control for ESP32 devices (feat. LILYGO T-Display-S3, M5Stack M5CoreS3, M5Stack Basic, M5Stack M5StickC Plus, Freenove ESP32-S3-WROOM
GNU General Public License v3.0
18 stars 4 forks source link

Compiling for m5stickc plus2 #3

Open islisis opened 1 month ago

islisis commented 1 month ago

I am new to ESP32, and am trying to compile for a m5stickc plus2 on vs code linux. I first needed to edit main-m5stick-c.cpp with "#define USING_M5GFX 0" to fix "Error: token "=" is not valid in preprocessor expressions".

After that, it will then build but with warnings such as:

'void memcpy(void, const void*, size_t)' reading 8 bytes from a region of size 4 [-Wstringop-overflow=]

I have attached the output at the end of this post.

I tried uploading, and received a checksum error. The next attempt to upload was successful, however nothing comes on the m5stickc plus2 display. On reset, the serial terminal reads:

rst:0x10 (RTCWDT_RTC_RESET),boot:0x1W (SP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:2 load:0x3fff0030,len:1184 load:0x40078000,len:13232 load:0x40080400,len:3028 entry 0x400805e4

and stops.

As I said, I am new to this platform and will slowly try to understand the possible causes. I will start by trying to use the M5StickCPlus2.h header file and library. However, if you have any ideas what is required I would be very grateful for any response!


In file included from src/CCU/CCUEncodingFunctions.h:5, from src/CCU/CCUEncodingFunctions.cpp:1: In static member function 'static std::vector CCUUtility::ToByteArrayFromArray(T, size_t) [with T = short int]', inlined from 'static CCUPacketTypes::Command CCUEncodingFunctions::CreateVideoWhiteBalanceCommand(short int, short int)' at src/CCU/CCUEncodingFunctions.cpp:13:98: src/CCU/CCUUtility.h:47:15: warning: 'void memcpy(void, const void, size_t)' reading 8 bytes from a region of size 4 [-Wstringop-overflow=] memcpy(result.data(), byteArray, length * sizeof(T));


In static member function 'static std::vector<unsigned char> CCUUtility::ToByteArrayFromArray(T*, size_t) [with T = short int]',
    inlined from 'static CCUPacketTypes::Command CCUEncodingFunctions::CreateRecordingFormatCommand(CCUPacketTypes::RecordingFormatData)' at src/CCU/CCUEncodingFunctions.cpp:75:88:
src/CCU/CCUUtility.h:47:15: warning: 'void* memcpy(void*, const void*, size_t)' reading 20 bytes from a region of size 10 [-Wstringop-overflow=]
         memcpy(result.data(), byteArray, length * sizeof(T));
         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Compiling .pio/build/m5stick-c/src/main/main-m5stick-c.cpp.o
In static member function 'static std::vector<unsigned char> CCUUtility::ToByteArrayFromArray(T*, size_t) [with T = short int]',
    inlined from 'static CCUPacketTypes::Command CCUEncodingFunctions::CreateInt16Command(short int, CCUPacketTypes::Category, byte)' at src/CCU/CCUEncodingFunctions.cpp:196:98:
src/CCU/CCUUtility.h:47:15: warning: 'void* memcpy(void*, const void*, size_t)' reading 8 bytes from a region of size 4 [-Wstringop-overflow=]
         memcpy(result.data(), byteArray, length * sizeof(T));
islisis commented 1 month ago

Seems like the black screen is caused by a change in plus2 initialisation, so I modified the mstickcplus library TFT_eSPI class instead and got a quick build working attached to serial. I will post again when the patch is tweaked and connection tested.

marklysze commented 1 month ago

Nice work @islisis! Look forward to seeing how you go...

islisis commented 1 month ago

OK I may not change this for a while so I'll post the quick fix here. The power hold when disconnected from USB fix is in my fork.

https://github.com/islisis/Magic-Pocket-Control-ESP32

The TFT_eSPI LCD pin fix is made to /.pio/libdeps/m5stick-c/M5StickCPlus/src/utility/In_eSPI_Setup.h after the M5StickCPlus library is installed.

/* existing definitions from plus

define TFT_MOSI 15

define TFT_SCLK 13

define TFT_CS 5 // Chip select line for TFT display on Shield

define TFT_DC 23 // Data/command line for TFT on Shield

define TFT_RST 18 // Reset line for TFT is handled by seesaw!

*/

// plus and plus2

define TFT_MOSI 15

define TFT_SCLK 13

define TFT_CS 5 // Chip select line for TFT display on Shield

// plus2

define TFT_DC 14 // Data/command line for TFT on Shield

define TFT_RST 12 // Reset line for TFT is handled by seesaw!

define TFT_BL 27 // LED back-light (required for M5Stack)

define TFT_BACKLIGHT_ON HIGH // Level to turn ON back-light (HIGH or LOW)

I have a feeling the M5StickCPlus library/inherited TFT_eSPI class will be deprecated, so future builds could move to M5unified

Great work and thank-you ;)