Skip to content

Conversation

@benediktibk
Copy link
Contributor

The configuration procedure for the FPGA iCE40 requires a leading and trailing clocks phase, which is currently implemented through additional SPI transfers before and after the actual FPGA image. Unfortunately, this also modifies the CS line, which therefore leads to a waveform which doesn't adhere to the specification.
This PR changes this behavior to ensure compliance with the iCE40 datasheet during the configuration.

Leading clocks phase before:
image

Leading clocks phase after:
image

@benediktibk benediktibk force-pushed the fix/ice40_spi_load_mode branch 2 times, most recently from e2a22a2 to 6087d6b Compare November 11, 2024 08:46
@benediktibk benediktibk marked this pull request as ready for review November 11, 2024 09:12
@zephyrbot zephyrbot added the area: FPGA Field-Programmable Gate Array (FPGA) label Nov 11, 2024
@benediktibk
Copy link
Contributor Author

I am fairly confident that the CI failure is not caused by this PR:

 +++++ Finished test 'line_splitting.Should Split Lines' in 14.90 seconds with status failed
      ╔═
      ║ InvalidOperationException: Terminal tester failed!
      ║ 
      ║ Full report:
      ║ ([host: 11/11/2024 8:59:51 AM, virt:       0] Attached to UART event: success)
      ║ [host: 11/11/2024 8:59:51 AM, virt:       0] *** Booting Zephyr OS build v4.0.0-rc3-1-g6087d6b23838 ***
      ║ ([host: 11/11/2024 8:59:51 AM, virt: 0.03305] Next line event: success)
      ║ [host: 11/11/2024 8:59:51 AM, virt:      15] 
      ║ [host: 11/11/2024 8:59:51 AM, virt:      15] abc
      ║ [host: 11/11/2024 8:59:51 AM, virt:      15] getline: ;
      ║ [host: 11/11/2024 8:59:51 AM, virt:      15] getline: abc;
      ║ ([host: 11/11/2024 8:59:51 AM, virt:    15.1] Line containing >>getline: abc;<< event: success)
      ║ [host: 11/11/2024 8:59:51 AM, virt:      15] 
      ║ [host: 11/11/2024 8:59:51 AM, virt:      15] 
      ║ [host: 11/11/2024 8:59:51 AM, virt:      15] getline: ;
      ║ [host: 11/11/2024 8:59:51 AM, virt:      15] getline: ;
      ║  [[no newline]]
      ║ ([host: 11/11/2024 8:59:59 AM, virt:  8018.2] Line containing regex >>^abc$<< event: failure)
      ╚═
Suite /__w/zephyr/zephyr/tests/drivers/console/line_splitting/line_splitting.robot failed in 15.98 seconds.

The datasheet of the iCE40 specifies that there should be a leading and
trailing clocks phase during its configuration with SPI. Due to the
limitations of the SPI interface, and probably also due to a lock of
support for such a feature for instance in the STM32 SPI peripheral,
this is achieved with additional SPI transfers before and after the
actual image. Unfortunately, this by default also affects the slave
select GPIO, which has to stay high during these phases.
This fixes this behaviour via not passing the slave select GPIO
to the SPI driver and manipulating this GPIO manually.

Signed-off-by: Benedikt Schmidt <[email protected]>
@benediktibk benediktibk force-pushed the fix/ice40_spi_load_mode branch from d5e9250 to 197f817 Compare November 20, 2024 20:12
@benediktibk
Copy link
Contributor Author

Replaced memset for CS gpio with a cs.gpio.port = NULL, according to the comment of @tbursztyka.

@nashif nashif merged commit b0a1ddd into zephyrproject-rtos:main Nov 22, 2024
23 checks passed
@benediktibk benediktibk deleted the fix/ice40_spi_load_mode branch November 22, 2024 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: FPGA Field-Programmable Gate Array (FPGA)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants