Fix for compilation error when using arduino-esp32 core v3.x

When using arduino-esp32 core v3.x, the edge impulse model compilation fails with errors of the type:

error: either all initializer clauses should be designated or none of them should be
1789 | .channels = input->dims->data[3],

This is because arduino-core v3.x uses a later vesion of the C++ compiler.

in files conv.cpp and depthwise_conv.cpp modify all data_dims_t struct declarations to remove designators, eg change:

    data_dims_t input_dims =  {
                                .width = input_width, .height = input_height,
                                .channels = input->dims->data[3], 1
                              };

to:

    data_dims_t input_dims =  {
                                input_width, input_height,
                                input->dims->data[3], 1
                              };
1 Like

Hi @cammonitor

Thanks for reporting, let me check with the tech team.

fyi @AIWintermuteAI @Arjan

Best

Eoin

Thanks! We will check it out.

hi @cammonitor !
We don’t claim to support arduino-esp32 core v3.x at the moment, as you can see from this comment our Arduino sketches for ESP32 are tested with 2.0.4.

// These sketches are tested with 2.0.4 ESP32 Arduino Core
// https://github.com/espressif/arduino-esp32/releases/tag/2.0.4

I’ll create an issue internally, meanwhile feel free to use the solution you’ve found!

1 Like

Hi @cammonitor thanks for your solution. I’ve been having some issues with the touch sensor on an ESP32-S3 and I’m hoping updating to the latest Arduino library may help it. 3.x is only about 5 months old but it would be nice to get it officially supported by Edge Impulse. Making the changes you suggested appears to be sufficient to completely use edge-impulse-sdk.

As an alternative that more closely aligns with the rest of the code in those files, a better solution may be to designate every value, rather than removing the designations.

The current code looks like this:

    data_dims_t input_dims =  {
                                .width = input_width, .height = input_height,
                                .channels = input->dims->data[3], 1
                              };

And can be replaced with this (adding .extra = ):

    data_dims_t input_dims =  {
                                .width = input_width, .height = input_height,
                                .channels = input->dims->data[3], .extra = 1
                              };

There are a couple of places where neither .channels or .extra are specified, in which case add both. For example the original:

data_dims_t filter_dims = {.width = filter_width, .height = filter_height, 0, 0};

Can be changed to:

data_dims_t filter_dims = {.width = filter_width, .height = filter_height, .channels = 0, .extra = 0};

There are about a dozen places that need updating and then everything seems to work great.

As these changes don’t seem to be directly related to Arduino ESP32 3.x support, rather they’re just good practice, I’d be happy to file a PR for these changes. Is the edge-impulse-sdk source repository public? There are aggregated versions of it on the Edge Impulse GitHub account but I can’t find the canonical respository.

We don’t accept PRs to edge-impulse-sdk (it is public though and repository is called inferencing-sdk) as we mostly have top-down development workflow.
I will make these changes next time ESP NN is updated in SDK (this code is from ESP NN optimized kernels rather than standard tflite micro kernels), which should be quite soon!