Compyling arduino code for different uController

Hi. Im stuck on this problem, i've written and compiled some code for a Adafruit Feather M0 WiFi uController, the code basically reads data from force sensors and an IMU device, and sends it to my computer via WiFi UDP. The "problem" i am facing now, is that those boards are in shortage and i would like to run my code on another uController, specifically the olimex esp32-poe-iso board (one i currently have, but would also like to run the code on other uControllers, preferably one that is smaller in size). I cant for the life of me get the code to verify without errors for that board. So not being a complete beginner with arduino, and not being an expert either, what are my options? Change the code to accomodate the different uController?
Thanks for any help and suggestions.
Cheers
David

Please post examples of the errors that you are getting along with a small but complete sketch that causes the errors

First error:
C:\Users\david\Documents\Arduino\libraries\WiFi101\src\WiFiMDNSResponder.cpp:24:26: fatal error: avr/pgmspace.h: No such file or directory
compilation terminated.
exit status 1
Error compiling for board OLIMEX ESP32-PoE-ISO.

"Fixed" this error by erasing the "avr/" in the "#include <avr/pgmspace.h>" statement in "..\Documents\Arduino\libraries\WiFi101\src\WiFiMDNSResponder.cpp" file.

Second error:

C:\Users\david\Documents\Arduino\libraries\WiFi101\src\WiFi.cpp: In member function 'int WiFiClass::init()':
C:\Users\david\Documents\Arduino\libraries\WiFi101\src\WiFi.cpp:300:46: error: invalid conversion from 'void ()(uint8_t*, uint32_t) {aka void ()(unsigned char, unsigned int)}' to 'tpfAppResolveCb {aka void ()(unsigned char, long unsigned int)}' [-fpermissive]*

  • registerSocketCallback(socket_cb, resolve_cb);*
  •                                          ^*
    

In file included from C:\Users\david\Documents\Arduino\libraries\WiFi101\src\utility/WiFiSocket.h:24:0,

  •             from C:\Users\david\Documents\Arduino\libraries\WiFi101\src\WiFi.cpp:36:*
    

C:\Users\david\Documents\Arduino\libraries\WiFi101\src/socket/include/socket.h:1047:14: note: initializing argument 2 of 'void registerSocketCallback(tpfAppSocketCb, tpfAppResolveCb)'

  • NMI_API void registerSocketCallback(tpfAppSocketCb socket_cb, tpfAppResolveCb resolve_cb);*
  •          ^*
    

C:\Users\david\Documents\Arduino\libraries\WiFi101\src\WiFi.cpp: At global scope:
C:\Users\david\Documents\Arduino\libraries\WiFi101\src\WiFi.cpp:1124:10: error: prototype for 'uint32_t WiFiClass::getTime()' does not match any in class 'WiFiClass'

  • uint32_t WiFiClass::getTime()*
  •      ^*
    

In file included from C:\Users\david\Documents\Arduino\libraries\WiFi101\src\WiFi.cpp:38:0:
C:\Users\david\Documents\Arduino\libraries\WiFi101\src\WiFi101.h:157:16: error: candidate is: long unsigned int WiFiClass::getTime()

  • unsigned long getTime();*
  •            ^*
    

exit status 1
Error compiling for board OLIMEX ESP32-PoE-ISO.

This is where i am stuck now. The errors don't point to any errors in the actual code..do you still need the code?

Cheers

I'd code for FreeRTOS on any ESP32 and all other supported controllers.

Why? Arent esp32 boards already running a version of FreeRTOS?

They run whatever you flash to them.

Right, therefore my suggestion. For running Arduino code also the Arduino framework for FreeRTOS is required which you have to provide or tweak to the target board. Original RTOS tasks run without that framework.

Broadly speaking, the "trick" is to study the board.txt/platform.txt file and identify the environmental variables unique to that board. You can then use conditional statements inside your sketch to manipulate your code.
See for a better explanation

See: https://forum.arduino.cc/t/howto-anatomy-of-the-boards-txt-file-for-custom-boards/154989

As for freeRTOS, if you are using this core:
https://github.com/espressif/arduino-esp32
then freeRTOS is configured automatically.

I highly recommend Kolban's free ESP32 book

Ray

Added:
My zip includes my take on using both cores of ESP32
DualCore.zip (2.2 KB)

The output should be as shown:

/*
  20210519
  Windows 10 Pro 64-bit
  ArduinoIDE 2.0.0-beta.6

  Sketch uses 204950 bytes (15%) of program storage space. Maximum is 1310720 bytes.
  Global variables use 13424 bytes (4%) of dynamic memory, leaving 314256 bytes for local variables. Maximum is 327680 bytes.

--------------------------
Compilation complete.
esptool.py v3.0-dev
Serial port COM6
Connecting........____
Chip is ESP32-D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, Coding Scheme None
Crystal is 40MHz
MAC: 30:ae:a4:38:44:b4
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 8192 bytes to 47...
Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.0 seconds (effective 6553.6 kbit/s)...
Hash of data verified.
Compressed 18656 bytes to 12053...
Writing at 0x00001000... (100 %)
Wrote 18656 bytes (12053 compressed) at 0x00001000 in 0.1 seconds (effective 1081.5 kbit/s)...
Hash of data verified.
Compressed 205072 bytes to 106472...
Writing at 0x00010000... (14 %)
Writing at 0x00014000... (28 %)
Writing at 0x00018000... (42 %)
Writing at 0x0001c000... (57 %)
Writing at 0x00020000... (71 %)
Writing at 0x00024000... (85 %)
Writing at 0x00028000... (100 %)
Wrote 205072 bytes (106472 compressed) at 0x00010000 in 1.7 seconds (effective 952.2 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 128...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (128 compressed) at 0x00008000 in 0.0 seconds (effective 1365.3 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

--------------------------
upload complete.
*/


This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.