Use SPI from DTS in MCUBOOT

Hello,

in my application I use SPI communication to control my display. For that I have configured the pins for spi4 in the dts and all works fine.

&spi4 {
    status = "okay";
    pinctrl-0 = <&spi4_default>;
    pinctrl-names = "default";
    cs-gpios = <&gpio0 11 GPIO_ACTIVE_LOW>;
    lcdspi: lcdspi@0{
        compatible="vnd,spi-device";
        reg =<0>;
        spi-max-frequency=<15000000>;
    };
};

Now I would like to access the display already from wihtin the mcuboot. Basically to display a potential firmware update progress.

I created a patch for the mcuboot in the Nordic SDK that tries to get the SPI device as I do in the application.

static const spi_operation_t lcdCtrl_ms_ch1_operation = SPI_WORD_SET(8) | SPI_OP_MODE_MASTER;
static const struct spi_dt_spec lcdCtrl_ms_ch1_dev = SPI_DT_SPEC_GET(DT_NODELABEL(lcdspi), lcdCtrl_ms_ch1_operation, 0);

int main()
{
  lcdCtrl_mu8_DataBuffer[0] = MAGIC_DATA;
  lcdCtrl_ms_tx_buf.buf = lcdCtrl_mu8_DataBuffer;
  lcdCtrl_ms_tx_buf.len = 1;
  gpio_pin_set_dt(&lcdCtrl_Pin_dc, 0); /* COMMAND MODE */
  spi_transceive_dt(&lcdCtrl_ms_ch1_dev, &lcdCtrl_ms_tx_set, &lcdCtrl_ms_rx_set);
}

I also added the CONFIG_SPI=y to the mcuboot.conf.

Unfortunately when I build it the linker gives me the following error:

c:/ncs/toolchains/b620d30767/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: app/libapp.a(lcdCtrl_mcuboot.c.obj): in function `z_impl_s
pi_transceive':
C:/ncs/v2.9.0/zephyr/include/zephyr/drivers/spi.h:773: undefined reference to `__device_dts_ord_134'
c:/ncs/toolchains/b620d30767/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: app/libapp.a(lcdCtrl_mcuboot.c.obj):(.rodata.lcdCtrl_ms_ch
1_dev+0x0): undefined reference to `__device_dts_ord_134'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

Can anyone assist me with this?

Thanks, Tom

Parents
  • Hello Tom,

    Please check the .config file in build/mcuboot/zephyr/ to confirm that CONFIG_SPI actually ended up being enabled for the bootloader. You may also want to double check that there aren't any warnings in the build log above the linker error.

    Best regards,

    Vidar

  • Hello Vidar,

    thanks for oyur reply. I am certain that CONFIG_SPI=y is set. Find attached the generated autoconf.h and devicetree_generated.h from the 'build\mcuboot\zephyr\include\generated\zephyr' directory.

    4744.autoconf.h 0844.devicetree_generated.h

    But you are right about a previous warning:

    CMake Warning at C:/ncs/v2.9.0/zephyr/CMakeLists.txt:952 (message):
      No SOURCES given to Zephyr library: drivers__spi
    
      Excluding target from build.
    
    
    CMake Warning at C:/ncs/v2.9.0/zephyr/CMakeLists.txt:952 (message):
      No SOURCES given to Zephyr library: ..__nrf__subsys__fw_info
    
      Excluding target from build.

    Am I missing an additional configuration entry?

    BR, Tom

Reply
  • Hello Vidar,

    thanks for oyur reply. I am certain that CONFIG_SPI=y is set. Find attached the generated autoconf.h and devicetree_generated.h from the 'build\mcuboot\zephyr\include\generated\zephyr' directory.

    4744.autoconf.h 0844.devicetree_generated.h

    But you are right about a previous warning:

    CMake Warning at C:/ncs/v2.9.0/zephyr/CMakeLists.txt:952 (message):
      No SOURCES given to Zephyr library: drivers__spi
    
      Excluding target from build.
    
    
    CMake Warning at C:/ncs/v2.9.0/zephyr/CMakeLists.txt:952 (message):
      No SOURCES given to Zephyr library: ..__nrf__subsys__fw_info
    
      Excluding target from build.

    Am I missing an additional configuration entry?

    BR, Tom

Children
Related