adafruit / adafruit/Adafruit_CircuitPython_ESP32SPI

SPI lock not aquired

Open
#171 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
102
Forks
71
Avg merge
2d 1h
Merged PRs (30d)
1

Description

## Problem
`adafruit_esp32spi.py` throws the below RuntimeError

```
Traceback (most recent call last):
File "code.py", line 21, in
File "helpers.py", line 120, in handle_weather
File "helpers.py", line 113, in get_weather
File "helpers.py", line 73, in safe_requests_get
File "adafruit_requests.py", line 818, in get
File "adafruit_requests.py", line 664, in request
File "adafruit_requests.py", line 532, in _get_socket
File "adafruit_esp32spi/adafruit_esp32spi_socket.py", line 75, in connect
File "adafruit_esp32spi/adafruit_esp32spi.py", line 806, in socket_connect
File "adafruit_esp32spi/adafruit_esp32spi.py", line 708, in socket_open
File "adafruit_esp32spi/adafruit_esp32spi.py", line 332, in _send_command_get_response
File "adafruit_esp32spi/adafruit_esp32spi.py", line 315, in _wait_response_cmd
File "adafruit_esp32spi/adafruit_esp32spi.py", line 282, in _check_data
File "adafruit_esp32spi/adafruit_esp32spi.py", line 256, in _read_byte
RuntimeError: Function requires lock
```

## How to reproduce

1. Play a sound file _from an sd card_ (via SPI) with `audioio.AudioOut`
2. Without waiting for it to finish, use `adafruit_requests` (which uses `adafruit_esp32spi/adafruit_esp32spi_socket`)

Inspecting the error, I would guess that `_read_byte` should be acquiring a lock on the SPI bus, which is being used to play audio (with DMA if I had to guess).

## Hardware Config
```
Adafruit CircuitPython 7.3.1 on 2022-06-22; Adafruit PyPortal Titano with samd51j20
Board ID:pyportal_titano
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with adafruit_esp32spi/adafruit_esp32spi.py, especially _read_byte, _check_data, _wait_response_cmd, and _send_command_get_response, then trace the socket_open path shown in the traceback. Reproduce the audio-over-SPI and adafruit_requests interaction on the PyPortal Titano configuration; done means the request no longer raises RuntimeError: Function requires lock.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
embedded-iot, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.