guild icon
Toit
#GPIO pin in use; how to debug this?
Thread channel in help
Oliver M
Oliver M 06/20/2024 05:22 PM
I'm trying to connect to an ublox neo-6m via uart; I've soldered the wires from pins 20 and 21 of my ESP32 C3 to the RX and TX terminals on the gps board (crossed, so RX -> TX and TX -> RX). When I try to run a minimal program, it bails out with an "already in use exception". How can I find out what's going wrong?

Program:

import gpio import uart import ublox-gnss RX ::= 20 TX ::= 21 main: port := uart.Port --rx=gpio.Pin RX // <--- this is line 10 --tx=gpio.Pin TX --baud-rate=9600 task:: reader := port.in while line := reader.read-line: print "Received: $line"
Error:
****************************************************************************** Decoding by `jag`, device has version <2.0.0-alpha.158> ****************************************************************************** EXCEPTION error. ALREADY_IN_USE 0: gpio-use_ <sdk>/gpio/pin.toit:394:3 1: Pin <sdk>/gpio/pin.toit:131:17 2: main gps.toit:10:10 ****************************************************************************** [jaguar] ERROR: program 112446b3-9c37-933d-895c-0408ccd4026d stopped - exit code 1
floitsch
floitsch 06/20/2024 06:59 PM
I don't see anything special about pin 20/21. Is there any other program running on the device that could have opened the pin (and maybe not closed it)?
Oliver M
Oliver M 06/20/2024 07:12 PM
No, that program is the only thing running on it. It has an RGB LED attached to pins 5, 6, and 7, but that is not used atm.
floitsch
floitsch 06/20/2024 07:31 PM
Could you triple check with jag container list ?
I looked through the sources, and unless I missed something, this error indicates that something has the pin opened.
floitsch
floitsch 06/20/2024 07:33 PM
Wait.
floitsch
floitsch 06/20/2024 07:33 PM
I see it now.
floitsch
floitsch 06/20/2024 07:35 PM
Found it.
It's a bug on our side.
We apply the ESP32 pin pool to the ESP32C3, and the ESP32 doesn't have any pin 20: https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/peripherals/gpio.html
floitsch
floitsch 06/20/2024 07:35 PM
Fixing now.
floitsch
floitsch 06/20/2024 08:11 PM
I uploaded a PR and triggered a build for the esp32c3. Here is the updated envelope.
https://drive.google.com/file/d/1c9j0bb9Kg5BZFmlQr0PkHswC4emQO4XF/view?usp=sharing

You should be able to flash it with jag flash --chip esp32c3 ./firmware-esp32c3.envelope.
You would need to unzip it first: gunzip ./firmware-esp32c3.envelope.gz. (Make sure not to extract the envelope itself. Some tools recognize that it is an AR file and then extract that as well).
Oliver M
Oliver M 06/20/2024 08:20 PM
Thanks, will try that tomorrow!
floitsch
floitsch 06/20/2024 08:24 PM
We will hopefully make a release very soon too.
Thanks for reporting.
Oliver M
Oliver M 06/20/2024 08:46 PM
No problem, I was just puzzled!
Oliver M
Oliver M 06/21/2024 08:06 AM
@floitsch it works -- thank you very much for diagnosing/fixing it so quickly!
floitsch
floitsch 06/21/2024 08:07 AM
Great!
We will release the fix as soon as possible.
14 messages in total