NMEA2000_esp32 icon indicating copy to clipboard operation
NMEA2000_esp32 copied to clipboard

ESP32 new version S2 S3 C3

Open forty76 opened this issue 1 year ago • 22 comments

Hello, thank you for your fantastic libraries

Unfortunately Arduino detects several errors when using the new ESP32 (S2,S3,C3). I'm currently trying sergei/NMEA2000_esp32_twai (https://github.com/sergei/NMEA2000_esp32_twai)

You could implement the right libraries for the various devices in the NMEA2000_CAN.h file.

#elif USE_N2K_CAN == USE_N2K_ESP32_CAN #if CONFIG_IDF_TARGET_ESP32S2 #include <NMEA2000_esp32_twai.h> tNMEA2000 &NMEA2000=(new NMEA2000_esp32_twai()); #elif CONFIG_IDF_TARGET_ESP32S3 #include <NMEA2000_esp32_twai.h> tNMEA2000 &NMEA2000=(new NMEA2000_esp32_twai()); #elif CONFIG_IDF_TARGET_ESP32 #include <NMEA2000_esp32.h> tNMEA2000 &NMEA2000=*(new tNMEA2000_esp32()); #else #error "Unrecognized ESP." #endif

forty76 avatar May 21 '24 19:05 forty76

I won't, since it does not use properly my library.

ttlappalainen avatar May 22 '24 03:05 ttlappalainen

I won't, since it does not use properly my library.

Can we crowd fund the work needed to get esp32-s3 support?

unxs0 avatar Jun 12 '24 20:06 unxs0

Do you need it personally or commercially? Why S3?

ttlappalainen avatar Jun 17 '24 04:06 ttlappalainen

Hi Timo!

The few manufacturers of low cost boat usable AMOLED displays only use this MCU for products and/or on their development kit boards.

They are DWO and their client LilyGo.

https://www.lilygo.cc/products/t4-s3 (https://www.lilygo.cc/products/t4-s3)

https://www.dwo.net.cn/pr.jsp?pp=0_316_1-1 (https://www.dwo.net.cn/pr.jsp?pp=0_316_1-1)

Plus the only good quality low cost easy to use graphics library LVGL adds extra problems, interfering in some way with TWAI on the Expressif S3. This is possibly due to some error in the Espxx lib that at least compiles and runs (fails after some time when LVGL controls SPI) with your excellent NMEA2000 library.

It is for an open source boating mini multifunction display project. And of course it should be completely libre software part of your esp32 extensión.

Cheers, Gary

June 17, 2024 1:59 AM, "Timo Lappalainen" @.*** @.@.>)> wrote: Do you need it personally or commercially? Why S3?

Reply to this email directly, view it on GitHub (https://github.com/ttlappalainen/NMEA2000_esp32/issues/25#issuecomment-2172241019), or unsubscribe (https://github.com/notifications/unsubscribe-auth/AELSHMQNHLXOHY7F634ZL2LZHZUKLAVCNFSM6AAAAABICGOVRGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNZSGI2DCMBRHE). You are receiving this because you commented.Message ID: @.***>

unxs0 avatar Jun 18 '24 12:06 unxs0

+1 for adding support to the Lilygo T Display S3 board. These are great boards that have an attached screen, thus able to display the data on the same board, making it great for a small footprint device. I'm also using it for personal use, to attach to the NMEA2k network and display the results in the little screen.

ibravo avatar Jun 19 '24 13:06 ibravo

I hacked together something that you can steal or take some inspiration from. https://github.com/skarlsson/NMEA2000_twai. I used it successfully (last week) for 3 devices esp32, esp32s3 and espc3 (olimex card and xiao) using esp idf 5.x

skarlsson avatar Oct 23 '24 11:10 skarlsson

@ttlappalainen does https://github.com/skarlsson/NMEA2000_twai conform to how you would expect support for ESP32 C3,S3 with the twai library support to look ?

It seems more direct and simpler than over variants that have been shared in PRs and issues here, but looks quite different from the original ESP32 version as it uses the twai driver methods. (ie -ISR replaced by twai queues, + a task)

The only problem I have found so far is https://github.com/skarlsson/NMEA2000_twai/blob/main/NMEA2000_esp32.cpp#L94C3-L99C23 fails to compile and had to be replaced by

                  twai_message_t message = {
                      .flags = 0x01,
                      .identifier = id,
                      .data_length_code = static_cast<uint8_t>(len > 8 ? 8 : len),
                      .data = {0}
                  };

probably due to a missing compiler flag in the defaults. Cant see why, the code matches the header file.

error was

                .pio/libdeps/esp32-c3/NMEA2000_twai/NMEA2000_esp32.cpp:126:5: error: designator order for field 'twai_message_t::<unnamed union>::<unnamed struct>::rtr' does not match declaration order in 'twai_message_t'

@skarlsson I will do a PR with the change and details on my setup.

I am targeting esp32-C3 from waveshare and ebay for the firmware for https://github.com/ieb/NMEA2000_Booklet. Why ESP32-C3 ? Because the pcb looks more elegant than the version using a ESP32 Wroom, and I needed to integrate a JDB BMS. Might regret that and revert.

ieb avatar Nov 13 '24 08:11 ieb

You could also check this https://github.com/offspring/NMEA2000_esp32/tree/add-esp32s3 . I have not yet had time to test it and do merge.

ttlappalainen avatar Nov 13 '24 11:11 ttlappalainen

Forgot to mention that twai is not in old framework version. So dependencies may be tested according to framework version not just by ESP32 model.

ttlappalainen avatar Nov 13 '24 11:11 ttlappalainen

I'm not aware of any differences in 5.x version for twai but I have been running 5.3. Also on many other places I've resorted to C++ style init - not C. ie twai_message_t message = {}; and then assigning individual members - so maybe this is the way here as well. for the record - I was hoping @ttlappalainen would pick this up since I've been jumping in and out of can related things over the years but never stayed for maintenance.

skarlsson avatar Nov 13 '24 11:11 skarlsson

@ieb you pullrequest worked for me so I merged it. And it was likely a compiler thing due to the unusual union / struct thing.

skarlsson avatar Nov 13 '24 19:11 skarlsson

You could also check this https://github.com/offspring/NMEA2000_esp32/tree/add-esp32s3

Tried this one, but I am using a C3 not a S3. Also tried to create a C3 header file for that, but all sorts of data structures were different or missing which is why I went for the twai version from @skarlsson which looked cleaner. I have that loaded and running on a bare board, just getting a pcb cut to test with a driver on a bus. Will report back.

ieb avatar Nov 15 '24 17:11 ieb

I'm not aware of any differences in 5.x version for twai but I have been running 5.3. Also on many other places I've resorted to C++ style init - not C. ie twai_message_t message = {}; and then assigning individual members - so maybe this is the way here as well. for the record - I was hoping @ttlappalainen would pick this up since I've been jumping in and out of can related things over the years but never stayed for maintenance. Btw, I also tried a xiao esp32c6 - works as well. Those actually have two can controllers - but have not tried dual

skarlsson avatar Nov 15 '24 17:11 skarlsson

The code from @skarlsson works good, no problems on one of the cheap ebay esp32C3 modules. It correctly recognises when the bus driver (TJ1050@5v with r divider on rx) is disconnected and communicates with a older ESP32 on the same bus simulating most of the messages on a Raymarine SeatalkNG bus, as would be expected. No issues seen. pcb worked fine first time. Heap seems completely stable. Will leave running for a few days to see if I can make it panic.

ieb avatar Nov 16 '24 15:11 ieb

Ran for > 24h with no failures or painics, although the esp32C3 is single core so race conditions are less likely. Seems to be stable for me.

ieb avatar Nov 18 '24 08:11 ieb

I'm trying to use @skarlsson version, but I get compile errors, specifically: In file included from src/NMEA2000_esp32.cpp:1: src/NMEA2000_esp32.h:47:5: error: 'twai_handle_t' does not name a type; did you mean 'twai_mode_t'?

I'm using PlatformIO and espressif 32 framework 6.4.0.

Any ideas?

titio72 avatar Jan 06 '25 08:01 titio72

I'm not using platformio - just esp-idf. I assume you mean esp-idf 5.4 - I just bumped to that version and it compiles fine. Also, twai_handle_t was introduced in 5.2 so you might be running an old version

skarlsson avatar Jan 06 '25 09:01 skarlsson

@skarlsson I guess the difference is that I'm using Arduino rather than esp-idf.

titio72 avatar Jan 06 '25 10:01 titio72

hello everybody,

is it possible to runit with ARDUINO IDE ?

Oscarwaterski avatar Mar 04 '25 08:03 Oscarwaterski

Hi Oscar,

I have used the library for multiple project successfully in the Arduino IDE v 1.8.19 up to appr a year ago for ESP32 and M5Stack projects. No experiences with the S2 S3 en C3 chips but I would expect them to work fine too.

Best regards, GWS

On Tue, Mar 4, 2025 at 9:14 AM Oscarwaterski @.***> wrote:

hello everybody,

is it possible to runit with ARDUINO IDE ?

— Reply to this email directly, view it on GitHub https://github.com/ttlappalainen/NMEA2000_esp32/issues/25#issuecomment-2696582319, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABYGPNJ3BTUGSUK5Y6CLE432SVOFLAVCNFSM6AAAAABICGOVRGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMOJWGU4DEMZRHE . You are receiving this because you are subscribed to this thread.Message ID: @.***> [image: Oscarwaterski]Oscarwaterski left a comment (ttlappalainen/NMEA2000_esp32#25) https://github.com/ttlappalainen/NMEA2000_esp32/issues/25#issuecomment-2696582319

hello everybody,

is it possible to runit with ARDUINO IDE ?

— Reply to this email directly, view it on GitHub https://github.com/ttlappalainen/NMEA2000_esp32/issues/25#issuecomment-2696582319, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABYGPNJ3BTUGSUK5Y6CLE432SVOFLAVCNFSM6AAAAABICGOVRGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMOJWGU4DEMZRHE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

GWS65 avatar Mar 05 '25 22:03 GWS65

Hi @ttlappalainen

You could also check this https://github.com/offspring/NMEA2000_esp32/tree/add-esp32s3

Just want to let you know, that this code ist working perfectly fine for me.

I am using a Seeed Studio XIAO ESP32s3 board with PlatformIO and Arduino Framework.

Here is my platformio.ini [env:seeed_xiao_esp32s3] platform = https://github.com/platformio/platform-espressif32.git board = seeed_xiao_esp32s3 framework = arduino monitor_speed = 115200 debug_tool = esp-prog debug_init_break = tbreak stetup

This Arduino-Framework uses ESP-IDF Version: v4.4.7.

Thanks for the excellent work.

matthias-mw avatar Mar 09 '25 19:03 matthias-mw