How to add W25Q80 flash to my board?

Hello. 

I try to connect SPI memory W25Q80 to nRF52840DK (in the future it will be my own board) but I have problem with device tree. I modified original files (nRF52840dk_nRF52840) but still I can't build project. 

dts file:

	aliases {
		led0 = &led0;
		led1 = &led1;
		led2 = &led2;
		led3 = &led3;
		pwm-led0 = &pwm_led0;
		in0 = &input0;
		in1 = &input1;
		in2 = &input2;
		in3 = &input3;
		bootloader-led0 = &led0;
		mcuboot-button0 = &input0;
		mcuboot-led0 = &led0;
		watchdog0 = &wdt0;
		//spi-flash0 = &mx25r64;
		spi-flash0 = &w25q80;
	};
	
	&qspi {
	status = "disabled";
	pinctrl-0 = <&qspi_default>;
	pinctrl-1 = <&qspi_sleep>;
	pinctrl-names = "default", "sleep";
	// mx25r64: mx25r6435f@0 {
	// 	compatible = "nordic,qspi-nor";
	// 	reg = <0>;
	// 	/* MX25R64 supports only pp and pp4io */
	// 	writeoc = "pp4io";
	// 	/* MX25R64 supports all readoc options */
	// 	readoc = "read4io";
	// 	sck-frequency = <8000000>;
	// 	jedec-id = [c2 28 17];
	// 	sfdp-bfp = [
	// 		e5 20 f1 ff  ff ff ff 03  44 eb 08 6b  08 3b 04 bb
	// 		ee ff ff ff  ff ff 00 ff  ff ff 00 ff  0c 20 0f 52
	// 		10 d8 00 ff  23 72 f5 00  82 ed 04 cc  44 83 68 44
	// 		30 b0 30 b0  f7 c4 d5 5c  00 be 29 ff  f0 d0 ff ff
	// 	];
	// 	size = <67108864>;
	// 	has-dpd;
	// 	t-enter-dpd = <10000>;
	// 	t-exit-dpd = <35000>;
	// };
};

&spi3 {
	compatible = "nordic,nrf-spim";
	status = "okay";
	cs-gpios = <&gpio1 14 GPIO_ACTIVE_LOW>; 
	pinctrl-0 = <&spi3_default>;
	pinctrl-1 = <&spi3_sleep>;
	pinctrl-names = "default", "sleep";

	w25q80: w25q80@0 {
		compatible = "jedec,spi-nor";
		reg = <0>;
		spi-max-frequency = <8000000>;
		jedec-id = [EF 40 14];
		size = <1048576>;
	};
};
 

Implementation in my W25Q80.c file:

const struct device *ex_flash_device = DEVICE_DT_GET(DT_ALIAS(spi-flash0));
I wanted to use "zephyr/samples/drivers/spi_flash" example from Zephyr repo, is it good choice for this type of memory?
Best regards
PW
  • Hello,

    As a starting point, I recommend you follow the Nordic Developer Academy chapter about SPI communication and see the exercise on interfacing a TFT screen. The steps you should follow are:

    Enable the SPI and GPIO drivers. Create an overlay file for your board in the boards directory, connecting the SPI memory to the appropriate GPIO pins on the nRF2840DK; refer to this page.

    I recommend referring to this sample from Zephyr.

    Kind Regards,

    Abhijith

  • After many tries I builded separate project and flash is working. But it still doesn't work in my main project :(. My main project has MCUBoot and FOTA (which is working fine). 

    My terminal info: (sorry, but I couldn't paste it in another way) 

    [1/6] Linking C executable zephyr\zephyr_pre0.elf
    FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map
    cmd.exe /C "cd . && C:\ncs\toolchains\c57af46cb7\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -gdwarf-4 zephyr/CMakeFiles/zephyr_pre0.dir/misc/empty_file.c.obj -o zephyr\zephyr_pre0.elf -fuse-ld=bfd -T zephyr/linker_zephyr_pre0.cmd -Wl,-Map=C:/ncs/v2.5.0/zephyr/samples/bluetooth/beacon_relay/build/mcuboot/zephyr/zephyr_pre0.map -Wl,--whole-archive app/libapp.a zephyr/libzephyr.a zephyr/arch/common/libarch__common.a zephyr/arch/arch/arm/core/aarch32/libarch__arm__core__aarch32.a zephyr/arch/arch/arm/core/aarch32/cortex_m/libarch__arm__core__aarch32__cortex_m.a zephyr/arch/arch/arm/core/aarch32/mpu/libarch__arm__core__aarch32__mpu.a zephyr/lib/libc/minimal/liblib__libc__minimal.a zephyr/lib/libc/common/liblib__libc__common.a zephyr/soc/soc/arm/common/cortex_m/libsoc__arm__common__cortex_m.a zephyr/soc/soc/arm/nordic_nrf/nrf52/libsoc__arm__nordic_nrf__nrf52.a zephyr/drivers/clock_control/libdrivers__clock_control.a zephyr/drivers/flash/libdrivers__flash.a zephyr/drivers/gpio/libdrivers__gpio.a zephyr/drivers/pinctrl/libdrivers__pinctrl.a zephyr/drivers/timer/libdrivers__timer.a modules/nrf/lib/fprotect/lib..__nrf__lib__fprotect.a modules/nrf/lib/fatal_error/lib..__nrf__lib__fatal_error.a modules/nrf/drivers/hw_cc310/lib..__nrf__drivers__hw_cc310.a modules/mcuboot/boot/bootutil/zephyr/libmcuboot_util.a modules/hal_nordic/nrfx/libmodules__hal_nordic__nrfx.a -Wl,--no-whole-archive zephyr/kernel/libkernel.a zephyr/CMakeFiles/offsets.dir/./arch/arm/core/offsets/offsets.c.obj -L"c:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/thumb/v7e-m+fp/hard" -LC:/ncs/v2.5.0/zephyr/samples/bluetooth/beacon_relay/build/mcuboot/zephyr -lgcc zephyr/arch/common/libisr_tables.a -mcpu=cortex-m4 -mthumb -mabi=aapcs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mfp16-format=ieee -Wl,--gc-sections -Wl,--build-id=none -Wl,--sort-common=descending -Wl,--sort-section=alignment -Wl,-u,_OffsetAbsSyms -Wl,-u,_ConfigAbsSyms -nostdlib -static -Wl,-X -Wl,-N -Wl,--orphan-handling=warn -Wl,-no-pie C:/ncs/v2.5.0/nrfxlib/crypto/nrf_cc310_platform/lib/cortex-m4/hard-float/no-interrupts/libnrf_cc310_platform_0.9.18.a C:/ncs/v2.5.0/nrfxlib/crypto/nrf_cc310_bl/lib/cortex-m4/hard-float/no-interrupts/libnrf_cc310_bl_0.9.12.a && cmd.exe /C "cd /D C:\ncs\v2.5.0\zephyr\samples\bluetooth\beacon_relay\build\mcuboot\zephyr && C:\ncs\toolchains\c57af46cb7\opt\bin\cmake.exe -E true""
    c:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: zephyr/drivers/flash/libdrivers__flash.a(spi_nor.c.obj):(.rodata.spi_nor_config_0+0x0): undefined reference to `__device_dts_ord_119'
    collect2.exe: error: ld returned 1 exit status
    ninja: build stopped: subcommand failed.
    [188/207] Building C object zephyr/drivers/spi/CMakeFiles/drivers__spi.dir/spi_nrfx_spim.c.obj
    FAILED: modules/mcuboot/mcuboot_subimage-prefix/src/mcuboot_subimage-stamp/mcuboot_subimage-build mcuboot/zephyr/zephyr.hex mcuboot/zephyr/zephyr.elf
    cmd.exe /C "cd /D C:\ncs\v2.5.0\zephyr\samples\bluetooth\beacon_relay\build\mcuboot && C:\ncs\toolchains\c57af46cb7\opt\bin\cmake.exe --build . --"
    [191/207] Linking C static library zephyr\subsys\bluetooth\host\libsubsys__bluetooth__host.a
    ninja: build stopped: subcommand failed.
    FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\c57af46cb7\opt\bin\cmake.EXE' --build 'c:\ncs\v2.5.0\zephyr\samples\bluetooth\beacon_relay\build'

    Is it possible that flash settings make this issue?

    # Flash
    CONFIG_FLASH=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_FLASH_MAP=y
    CONFIG_NVS=y
    CONFIG_DISABLE_FLASH_PATCH=y
    
    CONFIG_MPU_ALLOW_FLASH_WRITE=y
    CONFIG_ZCBOR=y

    Best regards

    PW

  • Problem solved. I added child_image/mcuboot.conf file to my project and multithreading config inside.

    CONFIG_MULTITHREADING=y

    Best regards

    PW

  • Hello,

    I am glad to hear that your issue has been resolved.

    Kind Regards,

    Abhijith

Related