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

ESP32 new version S2 S3 C3 #25

Open
forty76 opened this issue May 21, 2024 · 15 comments
Open

ESP32 new version S2 S3 C3 #25

forty76 opened this issue May 21, 2024 · 15 comments

Comments

@forty76
Copy link

forty76 commented May 21, 2024

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

@ttlappalainen
Copy link
Owner

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

@unxs0
Copy link

unxs0 commented Jun 12, 2024

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

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

@ttlappalainen
Copy link
Owner

Do you need it personally or commercially? Why S3?

@unxs0
Copy link

unxs0 commented Jun 18, 2024 via email

@ibravo
Copy link

ibravo commented Jun 19, 2024

+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.

@skarlsson
Copy link

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

@ieb
Copy link

ieb commented Nov 13, 2024

@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.

@ttlappalainen
Copy link
Owner

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
Copy link
Owner

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.

@skarlsson
Copy link

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
Copy link

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

@ieb
Copy link

ieb commented Nov 15, 2024

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.

@skarlsson
Copy link

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

@ieb
Copy link

ieb commented Nov 16, 2024

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
Copy link

ieb commented Nov 18, 2024

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.

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

6 participants