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

Not able to use pioarduino platform with board arduino nano #124

Closed
kumardeo opened this issue Mar 21, 2025 · 16 comments
Closed

Not able to use pioarduino platform with board arduino nano #124

kumardeo opened this issue Mar 21, 2025 · 16 comments
Labels
Arduino / IDF issue not an issue from pioarduino Board issue wrong / missing Board manifest

Comments

@kumardeo
Copy link

kumardeo commented Mar 21, 2025

Hey, thanks for this project.
I am new to IoT and C++ world (coming from JavaScript).
I need to use Arduino Core v3.*. When I use the following platformio.ini, I get various errors reported by VS Code as well as the code does not compile.

[env:arduino_nano_esp32]
platform = https://github.com/pioarduino/platform-espressif32/releases/download/stable/platform-espressif32.zip
board = arduino_nano_esp32
framework = arduino

I thought I need to use pioarduino IDE extension instead of official PlatformIO IDE in VS Code. Therefore, I uninstalled the official PlatformIO IDE, deleted .platformio folder, installed the pioarduino IDE and let extension setup everything. But, it did not work.
VS Code Intellisense shows the following errors:

Image

expression preceding parentheses of apparent call must have (pointer-to-) function typeC/C++(109)

#define pinMode(pin,mode) pinMode(digitalPinToGPIONumber(pin), mode)
Expands to:
pinMode(digitalPinToGPIONumber(LED_BUILTIN), 0x03)
expression preceding parentheses of apparent call must have (pointer-to-) function typeC/C++(109)

#define digitalWrite(pin,val) digitalWrite(digitalPinToGPIONumber(pin), val)
Expands to:
digitalWrite(digitalPinToGPIONumber(LED_BUILTIN), 0x0)

When I try to compile using the build button, it logs (I have omitted many to keep it short):

# more logs here but I omitted it

/home/deo/.platformio/packages/framework-arduinoespressif32/cores/esp32/Arduino.h:251:21: error: expected primary-expression before '_pin'
  251 | void noTone(uint8_t _pin);
      |                     ^~~~
/home/deo/.platformio/packages/framework-arduinoespressif32/cores/esp32/io_pin_remap.h:20:65: note: in definition of macro 'noTone'
   20 | #define noTone(_pin)              noTone(digitalPinToGPIONumber(_pin))
      |                                                                 ^~~~
src/main.cpp: In function 'void setup()':
/home/deo/.platformio/packages/framework-arduinoespressif32/cores/esp32/io_pin_remap.h:47:49: error: 'pinMode' was not declared in this scope
   47 | #define pinMode(pin, mode)                      pinMode(digitalPinToGPIONumber(pin), mode)
      |                                                 ^~~~~~~
src/main.cpp:6:3: note: in expansion of macro 'pinMode'
    6 |   pinMode(LED_BUILTIN, OUTPUT);
      |   ^~~~~~~
/home/deo/.platformio/packages/framework-arduinoespressif32/cores/esp32/io_pin_remap.h:47:49: note: maximum limit of 1000 namespaces searched for 'pinMode'
   47 | #define pinMode(pin, mode)                      pinMode(digitalPinToGPIONumber(pin), mode)
      |                                                 ^~~~~~~
src/main.cpp:6:3: note: in expansion of macro 'pinMode'
    6 |   pinMode(LED_BUILTIN, OUTPUT);
      |   ^~~~~~~
src/main.cpp: In function 'void loop()':
/home/deo/.platformio/packages/framework-arduinoespressif32/cores/esp32/io_pin_remap.h:46:49: error: 'digitalWrite' was not declared in this scope
   46 | #define digitalWrite(pin, val)                  digitalWrite(digitalPinToGPIONumber(pin), val)
      |                                                 ^~~~~~~~~~~~
src/main.cpp:11:3: note: in expansion of macro 'digitalWrite'
   11 |   digitalWrite(LED_BUILTIN, LOW);
      |   ^~~~~~~~~~~~
/home/deo/.platformio/packages/framework-arduinoespressif32/cores/esp32/io_pin_remap.h:46:49: note: maximum limit of 1000 namespaces searched for 'digitalWrite'
   46 | #define digitalWrite(pin, val)                  digitalWrite(digitalPinToGPIONumber(pin), val)
      |                                                 ^~~~~~~~~~~~
src/main.cpp:11:3: note: in expansion of macro 'digitalWrite'
   11 |   digitalWrite(LED_BUILTIN, LOW);
      |   ^~~~~~~~~~~~
*** [.pio/build/arduino_nano_esp32/src/main.cpp.o] Error 1
*** [.pio/build/arduino_nano_esp32/lib3c7/Matter/Matter.cpp.o] Error 1
===================================================== [FAILED] Took 5.54 seconds =====================================================

 *  The terminal process "platformio 'run'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

It looks like I am not setting up things correctly, what is the correct way to use pioarduino?
Also, do I only need to use pioarduino IDE extension or it is optional?
Do I only need to change platform field in platformio.ini?
What are the requirements?

@sivar2311
Copy link

To get Arduino 3.x all you need to do is to change the platform setting in platformio.ini.

pioarduinoIDE is optional.

@Jason2866
Copy link

Jason2866 commented Mar 21, 2025

Idk if pioarduino is working with the board arduino_nano_esp32. The board is weird since it is different to all other espressif boards. Arduino people decided not to use the uploader esptool.py. The programmed there own uploader utility dfuutil which is old, outdated and unreliable.

Did the implementation of the Arduino nano tool dfuutil without the possibility to test, since i don't have an Arduino nano board and i will not buy one (overpriced).

The errors you have in your logs may not related to pioarduino either. Since the Arduino nano board requires GPIO pin redefinition (again weird design decision) the issues may caused by not working GPIO redefine in the Arduino Source code. Try a other "normal" esp32 dev board to see if the code compiles successfully there.
If this is the case, the Arduino Nano board is not compatible with Arduino Core 3.x.x
Latest official Arduino support is for core 2.0.17. official Arduino info https://docs.arduino.cc/tutorials/nano-esp32/getting-started-nano-esp32/

Arduino crew provides a (very outdated) fork for the board https://github.com/arduino/arduino-esp32

EDIT: Probably this is not working as expected in espressif Arduino core 3.x.x. arduino/arduino-esp32@0a81532

@Jason2866 Jason2866 changed the title Not able to use pioarduino platform Not able to use pioarduino platform with board arduino nano Mar 21, 2025
@kumardeo
Copy link
Author

kumardeo commented Mar 21, 2025

@Jason2866 You are right, I tried selecting another board and it worked, but I have an Arduino Nano ESP32.
Thanks for your reply, looks like I can't use PlatformIO IDE (I really don't like Arduino IDE).

@Jason2866
Copy link

I think you can use the board with pioarduino, just don't use the arduino_nano_esp32 as boards manifest. Use esp32dev as board and just flash it with pioarduino. It will just work.

@kumardeo
Copy link
Author

kumardeo commented Mar 21, 2025

Thanks, I will try that.
I am disappointed about the fact that Arduino is selling an overpriced board and it doesn't support the latest core even if I use Arduino IDE (I need to choose ESP32-S3 Dev board to make it work).
It's really confusing for a beginner like me.

I think, this issue can be closed.

@Jason2866 Jason2866 added Board issue wrong / missing Board manifest Arduino / IDF issue not an issue from pioarduino bug Something isn't working labels Mar 21, 2025
@Jason2866
Copy link

@kumardeo Can you provide an easy example code which fails? I can't promise if i could fix (looks like an Arduino core issue). But i will have a look.

@kumardeo
Copy link
Author

Yes, sure.
You can try any example from https://github.com/espressif/arduino-esp32/tree/master/libraries.
The easiest code would be a blink example:

src/main.cpp

#include <Arduino.h>
#include <Matter.h>

void setup() {
  // put your setup code here, to run once:
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(LED_BUILTIN, LOW);
  delay(200);
  digitalWrite(LED_BUILTIN, HIGH);
  delay(200);
}

platformio.ini

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:arduino_nano_esp32]
platform = https://github.com/pioarduino/platform-espressif32/releases/download/stable/platform-espressif32.zip
board = arduino_nano_esp32
framework = arduino

@TD-er
Copy link

TD-er commented Mar 21, 2025

Is LED_BUILTIN defined here?

@Jason2866
Copy link

Ahh, issue is caused from the weird Arduino decision about there GPIO pin remapping!
The sketch uses standard Hardware GPIO definitions. In the Arduino Nano boards manifest there is Arduino PIN naming activated.

"-DBOARD_HAS_PIN_REMAP",

So it fails, as expected

@Jason2866
Copy link

Jason2866 commented Mar 21, 2025

This setting has to be changed to BOARD_USES_HW_GPIO_NUMBERS https://github.com/espressif/arduino-esp32/blob/6c04a9315309b530120de98321f8d900c151a9b9/variants/arduino_nano_nora/pins_arduino.h#L15
either by changing the boards manifest or in platformio.ini by overwriting the boards manifest entry

The complete code for remapping is here https://github.com/espressif/arduino-esp32/tree/master/variants/arduino_nano_nora

@Jason2866
Copy link

Jason2866 commented Mar 21, 2025

I will change the Nano boards manifest in branch development (change will be in release core Arduino 3.2.0) to do no remapping and use BOARD_USES_HW_GPIO_NUMBERS so the example sketches from espressif Arduino core repo will (hopefully) compile.

All newer espressif code would probably fail when using the Arduino pin remapping. It was a shit decision from the beginning from the Arduino crew to do.

@Jason2866
Copy link

Jason2866 commented Mar 21, 2025

@kumardeo

Try:

[env:arduino_nano_esp32]
platform = https://github.com/pioarduino/platform-espressif32.git#develop
board = arduino_nano_esp32
framework = arduino

have changed in actual develop branch to use HW GPIO numbers for the Nano board.

@Jason2866 Jason2866 removed the bug Something isn't working label Mar 21, 2025
@Jason2866
Copy link

Fixed in branch development

@kumardeo
Copy link
Author

Thanks! It compiles now.
Do I need to use GPIO Pin number instead of Arduino Pin Number?
For example, D8 maps to GPIO 17. Earlier I was using 8 for D8, now I need to use 17. Right?

@Jason2866
Copy link

Yes, use espressif hardware gpio numbers, so 17 is correct

@kumardeo
Copy link
Author

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arduino / IDF issue not an issue from pioarduino Board issue wrong / missing Board manifest
Projects
None yet
Development

No branches or pull requests

4 participants