[bug] ESP32SPI sends garbage data to display on 9-bit SPI
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- arduino, cpp
- Área
- embedded-iot
Línea de trabajo
Start by reading Arduino_ESP32SPI's beginWrite(), writeRepeat(), and flush_data_buf() implementations, along with the linked ESP-IDF documentation on transactions whose sizes are not multiples of 8 bits. Check the open pull request before starting; done means 9-bit SPI communication no longer sends trailing garbage and the display can initialize and show output.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Currently, the ESP32SPI databus cannot properly communicate with a display through 9-bit SPI, not even initialize it.
Since the ESP32 SPI driver sends data byte by byte, any message that does not make up a multiple of bytes gets padded with "random bits" as the official docs says. So in the flush function, pushing any amount of bits (consists of 9-bit commands) may include garbage data at the end to make up a full byte, breaking the communication.
If the amount of bits pushed is limited to multiple of 8, with some other additional changes (because flushing now may not leave the buffer empty), the communication would work and the display could display something.
my current changes
void Arduino_ESP32SPI::beginWrite()
{
// _data_buf_bit_idx = 0;
// _buffer[0] = 0;
...
}
void Arduino_ESP32SPI::writeRepeat(uint16_t p, uint32_t len)
{
...
if (_dc == GFX_NOT_DEFINED) // 9-bit SPI
{
for (uint32_t i = 0; i < len; i++) {
write16(p);
}
return; // TEMPORARY FIX
...
}
void Arduino_ESP32SPI::flush_data_buf()
{
if (_data_buf_bit_idx % 8 != 0) return;
uint16_t bytes = _data_buf_bit_idx / 8; // total bytes to flush, NOT including leftovers
// uint32_t len = (_data_buf_bit_idx + 31) / 32;
uint32_t len = (bytes + 3) / 4;
for (uint32_t i = 0; i < len; i++)
{
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
_spi->dev->data_buf[i].val = _buffer32[i];
#else
_spi->dev->data_buf[i] = _buffer32[i];
#endif
}
POLL(bytes * 8 - 1);
uint16_t leftover_bits = _data_buf_bit_idx - bytes * 8;
_buffer[0] = _buffer[bytes];
_data_buf_bit_idx = leftover_bits;
// _data_buf_bit_idx = 0;
}
The better solution, I think, is padding flushes with no-op commands (9 zeros i believe) until the data is a multiple of bytes. At maximum, only 7 commands would be padded. This doesn't leave part of existing commands in the buffer after flushing, and the assumption that the buffer would be empty after flushing wouldn't be broken as well.
I'd love to create a PR for that if wanted, since I'm working with this 3-wire SPI display module myself already.
Thanks for the amazing library, and wish you a nice 2026 :)
- Lenguaje dominante
- C
- Estrellas
- 1.1k
- Forks
- 249
- Merge medio
- 1 d 21 h
- PR fusionados (30 d)
- 2
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de moononournation/Arduino_GFX
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
moononournation/Arduino_GFX#826 · 1 comentario ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 50/100
moononournation/Arduino_GFX#827 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 52/100
moononournation/Arduino_GFX#825 · 6 comentarios ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
moononournation/Arduino_GFX#715 · 11 comentarios ·
Todos los issues de moononournation/Arduino_GFX
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
new issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
llvm/llvm-project#245835 ·
Los mantenedores suelen responder en 1 día
-
needs-triage
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
InauguralSystems/EigenScript#2537 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Fix a typo in H5Centry.cPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
taosdata/TDengine#35812 · 1 reacción ·
Los mantenedores suelen responder en 1 día