Open Oquirella opened 2 years ago
This error simply means that the SPI device you are capturing is not available for use.
I would like to take point you to Porting Guide for your Linux. Please do connect if you still have any doubt/issue.
I am using the imx6ul evalution kit with the following devictree: https://github.com/Embedfire/ebf-buster-linux/blob/master/arch/arm/boot/dts/imx6ul-14x14-evk-ecspi.dts
/dev/spidev3.0 is available
Any ideas why it is not working?
Can you please refer this document and try changing the SPI instance to 3
as per SPI Bus instance and Chip select number
.
Any way you could progress ahead @Oquirella ? Do let us know if still face problem.
I get the following message in my logs:
ESP32 peripheral is registered to SPI bus [0],chip select [0], SPI Clock [10]
But i don't get any device when using ifconfig -a:
can0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 NOARP MTU:16 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:10 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) Interrupt:28
can1 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 NOARP MTU:16 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:10 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) Interrupt:29
eth0 Link encap:Ethernet HWaddr 00:04:9F:06:F5:5B BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
eth1 Link encap:Ethernet HWaddr 00:04:9F:06:F5:5A BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
sit0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 NOARP MTU:1480 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Referring to logs shared at https://github.com/espressif/esp-hosted/issues/137#issuecomment-1216394080
Can you please show the dmesg log? First INIT msg is expected to be received in the dmesg.
This is what i get:
[ 19.623324] systemd[1]: Condition check resulted in Create list of static device nodes for the current kernel being skipped. [ 19.647385] systemd[1]: Condition check resulted in File System Check on Root Device being skipped. [ 19.691047] systemd[1]: Starting Journal Service... [ 19.740765] systemd[1]: Starting Load Kernel Modules... [ 19.808714] systemd[1]: Starting Remount Root and Kernel File Systems... [ 19.883707] systemd[1]: Starting udev Coldplug all Devices... [ 19.994655] systemd[1]: Mounted POSIX Message Queue File System. [ 20.048596] systemd[1]: Mounted Kernel Debug File System. [ 20.088762] systemd[1]: Mounted Temporary Directory (/tmp). [ 20.142905] systemd[1]: Started Remount Root and Kernel File Systems. [ 20.173138] ESP32 peripheral is registered to SPI bus [0],chip select [0], SPI Clock [10]
I don't get an INIT msg?
Here is my devicetree:
// SPDX-License-Identifier: (GPL-2.0 OR MIT) // // Copyright (C) 2016 Freescale Semiconductor, Inc.
/dts-v1/;
/ { model = "Freescale i.MX6 ULL 14x14 EVK Board"; compatible = "fsl,imx6ull-14x14-evk", "fsl,imx6ull"; };
&clks { assigned-clocks = <&clks IMX6UL_CLK_PLL3_PFD2>, <&clks IMX6UL_CLK_PLL4_AUDIO_DIV>; assigned-clock-rates = <320000000>, <786432000>; };
&iomuxc { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_additionalgpio>;
pinctrl_ecspi1: ecspi1grp {
fsl,pins = <
MX6UL_PAD_LCD_DATA20__ECSPI1_SCLK 0x10b0
MX6UL_PAD_LCD_DATA21__GPIO3_IO26 0x10b0
MX6UL_PAD_LCD_DATA22__ECSPI1_MOSI 0x10b0
MX6UL_PAD_LCD_DATA23__ECSPI1_MISO 0x10b0
>;
};
pinctrl_additionalgpio: additionalgpios {
fsl,pins = <
MX6UL_PAD_LCD_VSYNC__GPIO3_IO03 0x10b0 /* 67 RST */
MX6UL_PAD_LCD_DATA00__GPIO3_IO05 0x10b0 /* 69 DATA_AREADY */
MX6UL_PAD_LCD_DATA01__GPIO3_IO06 0x10b0 /* 70 HANDSHAKE_PIN */
>;
};
};
&ecspi1 {
#size-cells = <0>;
fsl,spi-num-chipselects = <1>;
cs-gpios = <&gpio3 26 GPIO_ACTIVE_LOW>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_ecspi1>;
status = "okay";
};
&csi { status = "okay"; };
&ov5640 { status = "okay"; };
&lcdif { status = "disabled"; };
/delete-node/ &sim2;
&ecspi1 {
fsl,spi-num-chipselects = <1>; cs-gpios = <&gpio3 26 GPIO_ACTIVE_LOW>; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_ecspi1>; status = "okay"; };
Do in need to change esp_board.bus_num and esp_board.chip_select to 1 according to this device tree?
Nope. You clearly do not have first event from ESP.
First thing first, On loading above stated device tree, can you list your spi device in /dev?
$ ls -lrt /dev/spi*
I don't have a spi device registrered, it is not clear for me if i need to have it or not. I can add it by adding:
spidev0: spi@0 {
reg = <0>;
compatible = "rohm,dh2228fv";
spi-max-frequency = <20000000>;
};
Is this needed?
GPIO pins
root@localhost:~# cat /sys/kernel/debug/gpio gpiochip0: GPIOs 0-31, parent: platform/209c000.gpio, 209c000.gpio: gpio-3 ( |xnur ) in lo ACTIVE LOW gpio-9 ( |regulator-sd1-vmmc ) out lo gpio-19 ( |cd ) in hi IRQ ACTIVE LOW
gpiochip1: GPIOs 32-63, parent: platform/20a0000.gpio, 20a0000.gpio:
gpiochip2: GPIOs 64-95, parent: platform/20a4000.gpio, 20a4000.gpio: gpio-67 ( |sysfs ) in hi gpio-69 ( |SPI_DATA_READY_PIN ) in hi IRQ gpio-70 ( |SPI_HANDSHAKE_PIN ) in hi IRQ gpio-90 ( |spi_imx ) out lo
gpiochip3: GPIOs 96-127, parent: platform/20a8000.gpio, 20a8000.gpio:
gpiochip4: GPIOs 128-159, parent: platform/20ac000.gpio, 20ac000.gpio: gpio-132 ( |headphone detect ) in lo IRQ gpio-135 ( |spi5 CS0 ) out hi ACTIVE LOW gpio-136 ( |? ) out lo gpio-138 ( |mosi ) out hi gpio-139 ( |sck ) out lo
gpiochip5: GPIOs 504-511, parent: spi/spi5.0, 74hc595, can sleep: gpio-507 ( |regulator-can-3v3 ) out hi ACTIVE LOW
It is getting a little distracted. I will try to understand step by step.
/boot
but depends upon your platform).Please comment out any spidev disabler blob (if any added by you) in device tree or overlay
Once reboot, it should load your dtb automatically. If the device tree is correct,
ls -lrt /dev/spi*
should list something.
b. extra GPIOs
Is 1.a step working for you?
I now got the spidev device
root@localhost:~# ls -l /dev/spidev0.0 crw------- 1 root root 153, 0 Sep 20 10:44 /dev/spidev0.0
But i also get this error:
Failed to obtain SPI master handle Failed Init SPI device
Great.
I expected two files like /dev/spidevX.Y
where X
is SPI instance and Y
is chip-select.
If you are unsure about this, no worries, we can get ahead for now.
Now,
b) GPIO configuration
a. Save your Device tree config (dts) in some directory like /home/
User-space tool testing of SPI
a. Test your SPI with spidev or with any user-space library, which will make sure that your SPI is working as expected.
b. Alternatively, TX and RX both messages you should test with ESP chipset's SPI.
You can use https://github.com/espressif/esp-idf/tree/master/examples/peripherals/spi_slave for dummy transfer.
You can also use exact SPI pins for your ESP chipsets. You can find them in spi_slave_api.c
This will make sure your All SPI pins and 'Handshake' are working fine.
Once you verify some back to back Tx & Rx SPI transactions, we will move to next step.
Do not hurry in trying ESP-Hosted directly. Let us get the base platform working first.
I managed to get the ethap0 & ethsta0 interfaces, but when i try to enable them i get the following error:
root@localhost:~# ifconfig ethap0 up ifconfig: SIOCSIFFLAGS: Cannot assign requested address
can you please post dmesg? Is your sta interface up?
what is output of sudo ifconfig -a
? Is there MAC address for interface you intend to bring up?
I am very close.
dmesg:
[56187.838801] Received INIT event from ESP32 peripheral [56187.838831] EVENT: 2 [56187.847831] EVENT: 1 [56187.850072] ESP Reconfigure SPI CLK to 30 MHz [56188.086722] ESP32 peripheral is registered to SPI bus [0],chip select [0], SPI Clock [30] [56188.331843] EVENT: 0 [56188.334081] ESP peripheral capabilities: 0x68 [51534.518133] Bus freq set to 400000000 start... [51534.518574] Bus freq set to 400000000 done! [51537.842456] [51537.842456] Bus freq set to 24000000 start... [51537.842824] Bus freq set to 24000000 done! [51537.878057] [51537.878057] Bus freq set to 400000000 start... [51537.878481] Bus freq set to 400000000 done! [51544.002397] [51544.002397] Bus freq set to 24000000 start... [51544.002767] Bus freq set to 24000000 done! [51544.038028] [51544.038028] Bus freq set to 400000000 start... [51544.038466] Bus freq set to 400000000 done! [51549.122407] [51549.122407] Bus freq set to 24000000 start... [51549.122787] Bus freq set to 24000000 done! [51549.158021] [51549.158021] Bus freq set to 400000000 start... [51549.158449] Bus freq set to 400000000 done!
ifconfig:
ethap0 Link encap:Ethernet HWaddr 00:00:00:00:00:00
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
ethsta0 Link encap:Ethernet HWaddr 00:00:00:00:00:00
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Have you followed https://github.com/espressif/esp-hosted/blob/ESP-Hosted_MCU_Host/docs/Linux_based_host/Getting_started.md and c demo app, https://github.com/espressif/esp-hosted/blob/ESP-Hosted_MCU_Host/docs/common/c_demo.md docs?
If yes, What is the output of
sudo ./test.out get_sta_mac_addr
sudo ./test.out get_ap_scan_list
Oke, i am very close now:
Linux (still problems, any idea why?):
root@localhost:~# esp-hosted get_ap_scan_list Enable heartbeat with duration 20 Control response timed out after 30 sec Response not received Control response timed out after 180 sec Response not received
Requested operation complete Sleeping for some time just to showcase heartbeat
ESP32:
I (2624) slave_ctrl: event ESPInit I (7394) slave_ctrl: HB timer started for 20 sec
I (37394) slave_ctrl: Station mode set in scan handler I (38994) slave_ctrl: Total APs scanned = 3 I (38994) slave_ctrl: Details of AP no 0 I (38994) slave_ctrl: SSID XXX RSSI -57 Channel 6 BSSID 00:b7:71:44:29:60 Auth mode 5
I (39014) slave_ctrl: Details of AP no 1 I (39014) slave_ctrl: SSID XXXX RSSI -57 Channel 6 BSSID 00:b7:71:44:29:61 Auth mode 0
I (39024) slave_ctrl: Details of AP no 2 I (39024) slave_ctrl: SSID iot_devices RSSI -57 Channel 6 BSSID 00:b7:71:44:29:62 Auth mode 3
ResetPin
:
Every loading of esp32 driver should reset the ESP32. (you will see the logs are dumped because of reloading of firmware image). This is equally important to other pins.ESP-Hosted_MCU_Host/host/linux/host_driver/esp32/spi/esp_spi.c
Handshake
: spi_interrupt_handlerData ready
: spi_data_ready_interrupt_handlerIf these functions do not hit,
Try Smaller SPI CLK freq
ESP-Hosted_MCU_Host/host/linux/host_driver/esp32/spi/esp_spi.c
with say 1 (desired small freq in MHz)
(Next) SPI transaction will be triggered by SPI Master(host) once interrupt received over these two lines.Try changing SPI mode at both sides
ESP-Hosted_MCU_Host/host/linux/host_driver/esp32/spi/esp_spi.c
to SPI_MODE_3
ESP-Hosted_MCU_Host/esp/esp_driver/network_adapter/main/spi_slave_api.c
Yes! you are now much close. Your Host->ESP messages are working. Once ESP->Host messages work, your setup is complete.
I added debug messages to spi_interrupt_handler & spi_data_ready_interrupt_handler, i don't get any message. This means the function are not executed.
This is my pin configuration:
root@localhost cat /sys/kernel/debug/gpio gpiochip2: GPIOs 64-95, parent: platform/20a4000.gpio, 20a4000.gpio: gpio-67 ( |sysfs ) in hi gpio-69 ( |SPI_DATA_READY_PIN ) in lo IRQ gpio-70 ( |SPI_HANDSHAKE_PIN ) in hi IRQ
I also tried to change the SPI mode to 3, but nothing worked anymore.
Can you independently test these GPIOs as this would be easier.
Possible reasons:
Possible debugging options:
@Oquirella Any update?
I reconfigured the pins but i still don't get any reponse. I get the HANDSHAKE & DATA READY events:
root@localhost:~# esp-hosted get_ap_scan_list Enable heartbeat with duration 20 [ 192.796974] HAND SHAKE [ 192.799836] DATA READY [ 192.804471] HAND SHAKE [ 192.808280] HAND SHAKE [ 212.695066] DATA READY [ 212.696897] HAND SHAKE [ 212.701082] HAND SHAKE Control response timed out after 30 sec Response not received
Can you please
Have you also tried SPI mode 1 at both places?
SPI mode mismatch can also be tried to understand further. For example, Host at SPI Mode3, and ESP at SPI Mode0. If these combination works, This definitely means timing issues.
Hello @Oquirella, Actually this might need some level of debugging.
ESP-Hosted_MCU_Host/host/linux/host_driver/esp32/spi/esp_spi.c
-> _esp_spi_work esp_spiwork()//WRITE_PERI_REG(GPIO_OUT_W1TC_REG, (1 << gpio_data_ready));
in ESP-Hosted_MCU_Host/esp/esp_driver/network_adapter/main/spi_slave_api.c -> get_next_tx_buffer()
It finally works now, keeping the initial 10MHz did the trick.
But your frequency bumped to 30MHz. So you must be using C3/S2/S3. Is that correct?
I am using S3
It is good to know that it is working for you.
However, 10MHz looks less. Can you further optimize frequency by increasing in 1 MHz step from 10MHz? You can change SPI_CLK_MHZ .
The overall throughput or data rate will be dependent upon the SPI CLK is released from host. ESP32-S3 supports upto 60MHz SPI slave driver clock. We have tested till 30MHz with Raspberry-Pi.
Some of the things to verify:
Hello, everyone. I am getting following logs for dmesg (I am using Raspberry Pi 4 model B with 32 bit Raspberry Pi OS Lite + ESP32_Devkitc_v4 with pre built binaries of spi v0.4 - SPI connection):
[ 94.113919] OF: overlay: WARNING: memory leak will occur if overlay removed, property: /soc/spi@7e204000/spidev@0/status [ 94.243688] Bluetooth: Core ver 2.22 [ 94.243757] NET: Registered PF_BLUETOOTH protocol family [ 94.243763] Bluetooth: HCI device and connection manager initialized [ 94.244099] Bluetooth: HCI socket layer initialized [ 94.244109] Bluetooth: L2CAP socket layer initialized [ 94.244125] Bluetooth: SCO socket layer initialized [ 116.410158] esp32_spi: loading out-of-tree module taints kernel. [ 116.410925] esp_reset, ESP32: Resetpin of Host is 6 [ 116.411147] esp_reset, ESP32: Triggering ESP reset. [ 116.411536] ESP32 peripheral is registered to SPI bus [0],chip select [0], SPI Clock [10] [ 118.822285] Received INIT event from ESP32 peripheral [ 118.822306] EVENT: 2 [ 118.822323] EVENT: 1 [ 118.822337] Unsupported tag in event [ 118.822350] EVENT: 0 [ 118.822364] ESP peripheral capabilities: 0x78 [ 119.575877] Bluetooth: BNEP (Ethernet Emulation) ver 1.3 [ 119.575890] Bluetooth: BNEP filters: protocol multicast [ 119.575902] Bluetooth: BNEP socket layer initialized [ 119.588172] NET: Registered PF_ALG protocol family [ 119.608597] cryptd: max_cpu_qlen set to 1000
I do not know this [ 118.822337] Unsupported tag in event. Also I am not able to establish communication over SPI. It always says timeout & Response not received. Can anyone please help me ?
We can certainly help you @KashyapPatalia . Can you please raise a separate issue for this?
Thanks for the quick response. Sure, let me raise a separate issue for this.
Have you also tried SPI mode 1 at both places?
- SPI mode mismatch can also be tried to understand further. For example, Host at SPI Mode3, and ESP at SPI Mode0. If these combination works, This definitely means timing issues.
How to set spi mode in esp32 side.
I am very close.
dmesg:
[56187.838801] Received INIT event from ESP32 peripheral [56187.838831] EVENT: 2 [56187.847831] EVENT: 1 [56187.850072] ESP Reconfigure SPI CLK to 30 MHz [56188.086722] ESP32 peripheral is registered to SPI bus [0],chip select [0], SPI Clock [30] [56188.331843] EVENT: 0 [56188.334081] ESP peripheral capabilities: 0x68 [51534.518133] Bus freq set to 400000000 start... [51534.518574] Bus freq set to 400000000 done! [51537.842456] [51537.842456] Bus freq set to 24000000 start... [51537.842824] Bus freq set to 24000000 done! [51537.878057] [51537.878057] Bus freq set to 400000000 start... [51537.878481] Bus freq set to 400000000 done! [51544.002397] [51544.002397] Bus freq set to 24000000 start... [51544.002767] Bus freq set to 24000000 done! [51544.038028] [51544.038028] Bus freq set to 400000000 start... [51544.038466] Bus freq set to 400000000 done! [51549.122407] [51549.122407] Bus freq set to 24000000 start... [51549.122787] Bus freq set to 24000000 done! [51549.158021] [51549.158021] Bus freq set to 400000000 start... [51549.158449] Bus freq set to 400000000 done!
ifconfig: ethap0 Link encap:Ethernet HWaddr 00:00:00:00:00:00 BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
ethsta0 Link encap:Ethernet HWaddr 00:00:00:00:00:00 BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
How did you get this INT messages? and what did you do for spidev_disabler in yocto. Please help me
@Oquirella Can you please help to close this issue?
I get the following errors when inserting the module:
[ 648.322010] Failed to obtain SPI master handle [ 648.761621] Failed Init SPI device modprobe: ERROR: could not insert 'esp32_spi': No such device