Skip to content

SOLUTION to -1 pin assignment causing apps wont start #6737

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

Closed
1 task done
Tracked by #178
tsctrl opened this issue May 13, 2022 · 10 comments
Closed
1 task done
Tracked by #178

SOLUTION to -1 pin assignment causing apps wont start #6737

tsctrl opened this issue May 13, 2022 · 10 comments
Assignees
Labels
Area: Peripherals API Relates to peripheral's APIs. Resolution: Expired More info wasn't provided
Milestone

Comments

@tsctrl
Copy link

tsctrl commented May 13, 2022

Board

ESP32 Dev Module

Device Description

Devkit

Hardware Configuration

Any SPI, I2c MODULES

Version

v2.0.3

IDE Name

IDF Component, Arduino IDE

Operating System

Windows 10

Flash frequency

40MHz

PSRAM enabled

yes

Upload speed

115200

Description

-1 pin assignment causing apps wont start:
In the Arduino world an I/O pin number of -1 is OK to signify to a function that a pin allocation is not wanted, Lots of existing arduino library written this way. Recent update causing apps wont start with repeated error as below:

[715][E][esp32-hal-gpio.c:95] __pinMode(): Invalid pin selected
E (285) gpio: gpio_set_level(226): GPIO output gpio_num error
E (285) gpio: gpio_set_level(226): GPIO output gpio_num error
E (285) gpio: gpio_set_level(226): GPIO output gpio_num error
E (285) gpio: gpio_set_level(226): GPIO output gpio_num error
E (285) gpio: gpio_set_level(226): GPIO output gpio_num error
E (285) gpio: gpio_set_level(226): GPIO output gpio_num error

Would like to know the solution regarding this issue. This issue has been raised/mentioned in multiple esp arduino library.
Thanks!

Sketch

Assign any arduino library begin method in setup() with -1 pin assignment:

example:
SPI.begin(-1,-1,-1,-1)

Debug Message

as in description.

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@tsctrl tsctrl added the Status: Awaiting triage Issue is waiting for triage label May 13, 2022
@me-no-dev
Copy link
Member

And what is the expected result if you call SPI.begin(-1,-1,-1,-1) or Wire.begin(-1, -1) and which are those libraries? If you do not want to change the default pins, why not just call SPI.begin() or Wire.begin()?

@tsctrl
Copy link
Author

tsctrl commented May 14, 2022

understood, we have to define and properly check those pin is suitable for assignment before initialize the io.
initially adding pinMode(PULLUP, -1) is acceptable but now throwing those error. which need additional check before setting those mode. no other option.

i am ok, close this if there is no other optional such as new NOTUSE pin definition to be use in other library as indication the pin and peripheral are not in use to replace the -1.

thanks!

@tsctrl
Copy link
Author

tsctrl commented May 14, 2022

drawback on this error is,

for custom pin mapping in such way CLASS.begin can have multiple parameters to set.
such as CLASS.begin(pina,pinb,pinc,pind) or CLASS.begin(pina)

we could not use CLASS.begin(pina,pinb,-1,-1) in case the pin is need to be set to default or not in use.
But since now it is returning error. we have to define CLASS.begin based on if the pin is set as below:

if(pina,pinb,pinc,pind)
CLASS.begin(pina,pinb,pinc,pind)
else if(!pinc,!pind)
CLASS.begin(pina,pinb)
endif

instead of just:
CLASS.begin(pina,pinb,pinc,pind)

without and conditional check

@tsctrl
Copy link
Author

tsctrl commented May 15, 2022

another valid scenario is when we have to use EN instead of GPIO when we dont want to use the pin. previously we set this pin to -1.
then what pin to set now?
@me-no-dev here is the library:
https://github.com/adafruit/Adafruit-ST7735-Library/blob/c2b3a2c0970988b1c65e8fd0e14a23e96e95b662/Adafruit_ST7735.cpp#L12

@P-R-O-C-H-Y P-R-O-C-H-Y added the Area: Peripherals API Relates to peripheral's APIs. label May 16, 2022
@me-no-dev
Copy link
Member

Some pins do accept -1. Maybe only SDA/SCL and SCK/MISO/MOSI do not?

@SuGlider PTAL

@SuGlider SuGlider self-assigned this May 18, 2022
@Bodmer
Copy link

Bodmer commented May 26, 2022

I am starting to get issues raised for this -1 pin problem. Ideally digital pin ref -1 should be ignored and treated as a null pin.

It is a shame that perfectly good libraries that are unlikely to be updated for a problem with single board package will be unusable with the ESP32 :-(

Can the error messages be turned off by default in the Arduino IDE please?

@P-R-O-C-H-Y
Copy link
Member

Hi @tsctrl,

from reading this issue I am not sure if I got the point of it.
You can use either:

  • SPI.begin() - default pins used
  • SPI.begin(-1,-1,-1,-1) - default pins used
  • SPI.begin(pina,pinb,-1,-1) - will use pina and pinb + set default pins for rest

The library you sent, there is this option for setting -1 to unused the pin only for some specific pin, not for all.
Can you please explain it a bit more please?
@Bodmer Can you send the lib you have problem with? :)

@SuGlider SuGlider mentioned this issue Aug 21, 2022
1 task
@VojtechBartoska
Copy link
Contributor

Any updates on this guys?

@SuGlider
Copy link
Collaborator

SuGlider commented Aug 24, 2022

I think that PR #7161 also addresses this issue. It would be good to create some Use Cases and then verify the different ways to run SPI.begin()

@P-R-O-C-H-Y P-R-O-C-H-Y added Resolution: Awaiting response Waiting for response of author and removed Status: Awaiting triage Issue is waiting for triage labels Sep 5, 2022
@VojtechBartoska VojtechBartoska moved this from Under investigation to In Review in Arduino ESP32 Core Project Roadmap Sep 5, 2022
@VojtechBartoska VojtechBartoska modified the milestones: 2.0.5, 2.1.0 Sep 19, 2022
@P-R-O-C-H-Y
Copy link
Member

@tsctrl Closing this due to no answer for a long time. Feel free to reopen if needed :)

Repository owner moved this from In Review to Done in Arduino ESP32 Core Project Roadmap Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Peripherals API Relates to peripheral's APIs. Resolution: Expired More info wasn't provided
Projects
Development

No branches or pull requests

6 participants