Device not found with device_get_binding

Hi,

I'm trying to mount two spi flash device on spi0, but can't found the second one(device_get_binding() return NULL).

The two device has compatible ("jedec,spi-nor") mean they has spi-nor flash driver.

My main functions like this:

 

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#define FLASH_DEVICE_0 "DEVICE_LABEL_0"
#define FLASH_DEVICE_1 "DEVICE_LABEL_1"
static void device_0(void) {
const struct device *flash_dev = device_get_binding(FLASH_DEVICE_0);
if (!flash_dev) {
LOG_INF("SPI flash driver %s was not found!", __func__);
return;
}
LOG_INF("Get %s.", __func__);
}
static void device_1(void) {
const struct device *flash_dev = device_get_binding(FLASH_DEVICE_1);
if (!flash_dev) {
LOG_INF("SPI flash driver %s was not found!", __func__);
return;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

And i add app.overlay to my project. Because of no actual device was connected, i just make MISO to GND, so jedec-id is zero.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
&spi0 {
compatible = "nordic,nrf-spi";
status = "okay";
pinctrl-0 = <&spi_default>;
pinctrl-1 = <&spi_sleep>;
pinctrl-names = "default", "sleep";
cs-gpios = <&gpio0 28 GPIO_ACTIVE_LOW>, <&gpio0 30 GPIO_ACTIVE_LOW>;
DEVICE_0:DEVICE_0@0 {
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <8000000>;
label = "DEVICE_LABEL_0";
jedec-id = [ 00 00 00 ];
size = < 0x8000000 >;
};
DEVICE_1:DEVICE_1@1 {
compatible = "jedec,spi-nor";
reg = <1>;
spi-max-frequency = <8000000>;
label = "DEVICE_LABEL_1";
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

After download zephyr.hex to nRF52840, the RTT View shows as follow:

Fullscreen
1
2
3
4
5
*** Booting Zephyr OS build v3.0.99-ncs1 ***
[00:00:00.331,207] <inf> multi_spi: Hello
[00:00:00.331,237] <inf> multi_spi: Get device_0.
[00:00:00.331,268] <inf> multi_spi: SPI flash driver device_1 was not found!
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

It is shows that "device 0" can found but "device 1" can NOT found. I debug it and see  z_impl_device_get_binding() has a device named "device 0", but no device named "device 1".

"device 1" can be only found when i was deleted "device 0" on the app.overlay file.

what does i missing?