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

[BUG] ESP32C6 Slave Driver Issue #13238

Closed
1 task done
FelipeMdeO opened this issue Aug 30, 2024 · 9 comments · Fixed by #14420
Closed
1 task done

[BUG] ESP32C6 Slave Driver Issue #13238

FelipeMdeO opened this issue Aug 30, 2024 · 9 comments · Fixed by #14420
Labels
Arch: risc-v Issues related to the RISC-V (32-bit or 64-bit) architecture Area: Drivers Drivers issues OS: Linux Issues related to Linux (building system, etc) Type: Bug Something isn't working

Comments

@FelipeMdeO
Copy link
Contributor

FelipeMdeO commented Aug 30, 2024

Description / Steps to reproduce the issue

Hello All,

I am trying to use 2 esp32c6 devkit m, one as master and one as slave.
Slave spi cannot work. I tried solve it by myself but I can't. Please @fdcavalcanti, @tmedicci , can you take a look?

I did custom app with open and read cmds, master doesn't receive data. I am using master branch. SPI 2, without DMA.
Please, look image below:
image

spi_slave_hal_get_rcv_bitlen should be called after spi_slave_hal_storage_result, we aren't doing it so transfer_size always will be 0.

I changed spi_slave_hal_get_rcv_bitlen position, but I faced other issues. I can give more details when you ask for.
Just to FYI, to advance in my solution I need change esp_hal (I know, it is not a good idea, I did it only for testing), I opened a thread in esp-idf forum to try understand better hal.
espressif/esp-idf#14462

On which OS does this issue occur?

[Linux]

What is the version of your OS?

Ubuntu 24

NuttX Version

master

Issue Architecture

[risc-v]

Issue Area

[Drivers]

Verification

  • I have verified before submitting the report.
@FelipeMdeO FelipeMdeO added the Type: Bug Something isn't working label Aug 30, 2024
@github-actions github-actions bot added Area: Drivers Drivers issues OS: Linux Issues related to Linux (building system, etc) Arch: risc-v Issues related to the RISC-V (32-bit or 64-bit) architecture labels Aug 30, 2024
@fdcavalcanti
Copy link
Contributor

Hi Felipe. Can you share the app you've written to test it?

@FelipeMdeO
Copy link
Contributor Author

Sure @fdcavalcanti.

`int main(int argc, FAR char *argv[])
{

  int fd;
  int ret;
  uint8_t buffer[128];

  while(1)
  {
    fd = open("/dev/spislv2", O_RDONLY | O_WRONLY );
    if (fd < 0)
    {
        printf("Failed to open %s\n", "/dev/spislv2");
        return -1;
    }
    printf(" Trying to Read: \n");
    
    ret = read(fd, buffer, 30);
    for (int i = 0 ; i < ret; i++)
      {
        printf("%02X ", buffer[i]);
      }
    printf("\n");
    usleep(1000000);
    close(fd);
    usleep(2000000);
  }


  return 0;
}`

You can use my .config also:
config.zip

@fdcavalcanti
Copy link
Contributor

@FelipeMdeO please do this on the slave device:

  • Remove the open and close commands from the while loop. Just open once and let it print stuff
  • Enable DEBUG_FEATURES, DEBUG_ASSERTIONS_EXPRESSION and DEBUG_ASSERTIONS_FILENAME on Debug Options menu
  • Enable SPI Slave support on SPI Driver Support menu and also on SPI Configuration

Run that program and check if the system fails. If it does, send here the log.

@FelipeMdeO
Copy link
Contributor Author

Hello @fdcavalcanti, sorry for the delay.

I am with same behavior. I will put details here:
Master >
image

Slave >
image

nsh> hello
spi_slave_open: filep: 0x4080a980
spislave_bind: ctrlr=0x40804bf4 dev=0x40809b28 mode=0 nbits=8
spi_slave_select: sdev: 0x40809b28 CS: free
spi_slave_cmddata: sdev: 0x40809b28 CMD: command
spislave_initialize: ctrlr=0x40804bf4
spi_slave_select: sdev: 0x40809b28 CS: select
spislave_prepare_next_tx: TX buffer empty! Disabling TX for next transaction
spi_slave_select: sdev: 0x40809b28 CS: free
spi_slave_read: filep=0x4080a22c buffer=0x4080a9e0 buflen=30
 Trying to Read: 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
 Trying to Read: 
spi_slave_read: filep=0x4080a22c buffer=0x4080a9e0 buflen=30
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
spi_slave_select: sdev: 0x40809b28 CS: select
spislave_prepare_next_tx: TX buffer empty! Disabling TX for next transaction
spi_slave_select: sdev: 0x40809b28 CS: free
spi_slave_select: sdev: 0x40809b28 CS: select
spislave_prepare_next_tx: TX buffer empty! Disabling TX for next transaction
spi_slave_select: sdev: 0x40809b28 CS: free
spi_slave_select: sdev: 0x40809b28 CS: select
spislave_prepare_next_tx: TX buffer empty! Disabling TX for next transaction
spi_slave_select: sdev: 0x40809b28 CS: free
spi_slave_select: sdev: 0x40809b28 CS: select
spislave_prepare_next_tx: TX buffer empty! Disabling TX for next transaction
spi_slave_select: sdev: 0x40809b28 CS: free
 Trying to Read: 
spi_slave_read: filep=0x4080a22c buffer=0x4080a9e0 buflen=30
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
spi_slave_select: sdev: 0x40809b28 CS: select
spislave_prepare_next_tx: TX buffer empty! Disabling TX for next transaction
spi_slave_select: sdev: 0x40809b28 CS: free
spi_slave_select: sdev: 0x40809b28 CS: select
spislave_prepare_next_tx: TX buffer empty! Disabling TX for next transaction
spi_slave_select: sdev: 0x40809b28 CS: free
spi_slave_select: sdev: 0x40809b28 CS: select
spislave_prepare_next_tx: TX buffer empty! Disabling TX for next transaction
spi_slave_select: sdev: 0x40809b28 CS: free
spi_slave_select: sdev: 0x40809b28 CS: select
spislave_prepare_next_tx: TX buffer empty! Disabling TX for next transaction
spi_slave_select: sdev: 0x40809b28 CS: free
 Trying to Read: 
spi_slave_read: filep=0x4080a22c buffer=0x4080a9e0 buflen=30
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 

Are you able to do it work in your side?

@fdcavalcanti
Copy link
Contributor

Ok, thanks.
I'll look into it.

@fdcavalcanti
Copy link
Contributor

@FelipeMdeO I've reviewed it and noticed two issues:

  • There's an issue with the HAL item you mentioned, I also couldn't retrieve data from it.
  • There's also an issue on the NuttX SPI Slave driver that was changed in commit dcb8188, preventing the while loop to enter. I forced some values on the rx_buffer and could make it work.

I can't dig deeper at the moment, but will get back to it when possible.

@FelipeMdeO
Copy link
Contributor Author

Hello @fdcavalcanti.

I am trying solve spi slave communication and I made some progress. However I am stucked in other issue, maybe you can help me.

The CS pin was configure to generate IRQ in Rising edge:

image

But I am getting IRQ in both edges. I solved this locally but I believe the final solution should be changing the HAL

I changed spislave_cs_interrupt to get more prints:

image

Look whats happen:

image

@tmedicci Can you help us looking better about this IRQ?

@tmedicci
Copy link
Contributor

tmedicci commented Sep 19, 2024

Hello @fdcavalcanti.

I am trying solve spi slave communication and I made some progress. However I am stucked in other issue, maybe you can help me.

The CS pin was configure to generate IRQ in Rising edge:

image

But I am getting IRQ in both edges. I solved this locally but I believe the final solution should be changing the HAL

I changed spislave_cs_interrupt to get more prints:

image

Look whats happen:

image

@tmedicci Can you help us looking better about this IRQ?

Hi @FelipeMdeO , I didn't get what is the local solution (and what would be the proposed HAL solution). Can you better explain how you made it work locally?

@FelipeMdeO
Copy link
Contributor Author

Hello @tmedicci,

I am fixing driver step by step in my local machine, it isn't finished and need be improved.
If you want, I can share with you my repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arch: risc-v Issues related to the RISC-V (32-bit or 64-bit) architecture Area: Drivers Drivers issues OS: Linux Issues related to Linux (building system, etc) Type: Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants