Skip to content

embedded:io/spi fails to link on ESP8266 with non-RGB565LE display formats #1591

@HipsterBrown

Description

@HipsterBrown

Build environment: macOS
Moddable SDK version: 7.0.0
Target device: Moddable Three

Description
Including $(MODDABLE)/modules/io/manifest.json in a project targeting any ESP8266 board whose display format is not RGB565LE (e.g. Moddable Three, which uses Gray256) produces a linker error for the undefined symbol modSPITxSwap16.

Steps to Reproduce

  1. Create a project whose manifest.json includes $(MODDABLE)/modules/io/manifest.json
  2. Build for esp8266/moddable_three: mcconfig -d -m -p esp8266/moddable_three
  3. See linker error:
  modules/io/spi/esp/spi.c: undefined reference to `modSPITxSwap16'
  collect2: error: ld returned 1 exit status

Expected behavior
The project links and flashes successfully.

Images
N/A

Other information
modules/io/spi/esp/spi.c calls modSPITxSwap16 unconditionally when spi->transform is set. However, in modules/pins/spi/esp/modSPI.c the function is only compiled when kCommodettoBitmapFormat == kCommodettoBitmapRGB565LE. On Moddable Three the format is Gray256, so the symbol is never emitted and the link fails.

Suggested fix — guard the call in spi.c with the same #if already used in modSPI.c, falling through to the plain modSPITx on non-RGB565LE targets:

// modules/io/spi/esp/spi.c  xs_spi_write
#if kCommodettoBitmapFormat == kCommodettoBitmapRGB565LE
      if (spi->transform)
              modSPITxSwap16(&spi->config, (uint8_t *)data, (uint16_t)count);
      else
#endif
              modSPITx(&spi->config, (uint8_t *)data, (uint16_t)count);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions