Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MCUBoot using W25Q SPI Flash not working (use of Zephyr semaphore) #10028

Closed
Olivier-ProGlove opened this issue Sep 17, 2018 · 2 comments
Closed
Labels
bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug

Comments

@Olivier-ProGlove
Copy link
Contributor

spi_flash_w25qxxdv still uses Zephyr semaphore kernel while MCUBoot uses CONFIG_MULTITHREADING=n. As discussed in various Github issues #8368, #9808 problems might exist when using Zephyr kernel API with CONFIG_MULTITHREADING=n.

When W25Q SPI Flash initializes itself, it checks if the Flash ID matches the expected one. To do that it sends a command through SPI using spi_transceive().

All/Most SPI drivers use spi_context.h that uses Zephyr semaphore API.

Instructions to duplicate the issue on nRF52840 PCA10056 (but the issue could in theory be duplicated on any board that their SPI driver uses spi_context.h such as the following SPI drivers: DW, Intel, STM32, Nordic) and there is no need of W25Q SPI Flash as the crash occurs before any SPI transmission:

  • Add to boot/zephyr/prj.conf
CONFIG_SPI=y
CONFIG_SPI_0=y
CONFIG_SPI_NRFX=y

CONFIG_FLASH=y
CONFIG_SPI_FLASH_W25QXXDV=y
CONFIG_SPI_FLASH_W25QXXDV_SPI_NAME="SPI_0"
CONFIG_SPI_FLASH_W25QXXDV_SPI_SLAVE=0

# Required by Zephyr v1.13 but must be removed for head of Zephyr (DTS is used instead):
CONFIG_SPI_0_NRF_SCK_PIN=13
CONFIG_SPI_0_NRF_MOSI_PIN=15
CONFIG_SPI_0_NRF_MISO_PIN=17
CONFIG_SPI_0_IRQ_PRI=3

It crashes with:

***** USAGE FAULT *****
  Illegal load of EXC_RETURN into PC
***** Hardware exception *****
Current thread ID = 0x00000000
Faulting instruction address = 0xf7ffeb04

I suspect it is due to the semaphore not being initialized but before investigating the issue myself I would like to know the decision for MCUBoot regarding CONFIG_MULTITHREADING=n.

@nashif nashif added bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug labels Sep 17, 2018
@nashif
Copy link
Member

nashif commented Jan 11, 2019

You should be using multi-threading

@nashif nashif closed this as completed Jan 11, 2019
@amcewen
Copy link

amcewen commented Jun 2, 2023

In case anyone else ends up here when trying to debug getting W25Q SPI flash working with Zephyr, adding CONFIG_MULTITHREADING=y in the MCUBOOT prj.conf (along with the CONFIG_SPI_NOR=y, CONFIG_SPI=y and CONFIG_PM_OVERRIDE_EXTERNAL_DRIVER_CHECK=y options) seems to do the trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug
Projects
None yet
Development

No branches or pull requests

3 participants