EMW3080B_SPI issue on B-U585

In the EMW3080B_SPI::TransmitReceive()/Transmit()/Receive() functions there now appears to be an issue with the receive buffer not being a CacheAlignedBuffer structure pointer in the SPI::transfer() call but so far my C++ knowledge/searching hasn’t lead me to how to fix the following:

[build] C:/Users/tim/Mbed Programs/mbed-ce/hello/mbed-os/connectivity/drivers/wifi/TARGET_STM/COMPONENT_EMW3080B/EMW3080B_SPI.cpp: In member function ‘int32_t EMW3080B_SPI::TransmitReceive(uint8_t*, uint8_t*, uint32_t, uint32_t)’:
[build] C:/Users/tim/Mbed Programs/mbed-ce/hello/mbed-os/connectivity/drivers/wifi/TARGET_STM/COMPONENT_EMW3080B/EMW3080B_SPI.cpp:203:18: error: no matching function for call to ‘EMW3080B_SPI::transfer(const uint8_t*, int, uint8_t*&, int, mbed::Callback<void(int)>, int)’
[build] 203 | SPI::transfer((const uint8_t ) txdata, (int) datalen, rxdata, (int) datalen, callback(this, &EMW3080B_SPI::spi_handler), SPI_EVENT_COMPLETE);
[build] | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build] In file included from C:/Users/tim/Mbed Programs/mbed-ce/hello/mbed-os/mbed.h:66,
[build] from C:/Users/tim/Mbed Programs/mbed-ce/hello/mbed-os/connectivity/drivers/wifi/TARGET_STM/COMPONENT_EMW3080B/EMW3080B_SPI.h:23,
[build] from C:/Users/tim/Mbed Programs/mbed-ce/hello/mbed-os/connectivity/drivers/wifi/TARGET_STM/COMPONENT_EMW3080B/EMW3080B_SPI.cpp:20:
[build] C:/Users/tim/Mbed Programs/mbed-ce/hello/mbed-os/drivers/include/drivers/SPI.h:481:5: note: candidate: 'template typename std::enable_if<std::is_integral<_Tp>::value, int>::type mbed::SPI::transfer(const WordT
, int, mbed::CacheAlignedBuffer&, int, const mbed::event_callback_t&, int)’
[build] 481 | transfer(const WordT tx_buffer, int tx_length, CacheAlignedBuffer &rx_buffer, int rx_length, const event_callback_t &callback, int event = SPI_EVENT_COMPLETE)
[build] | ^~~~~~~~
[build] C:/Users/tim/Mbed Programs/mbed-ce/hello/mbed-os/drivers/include/drivers/SPI.h:481:5: note: template argument deduction/substitution failed:
[build] C:/Users/tim/Mbed Programs/mbed-ce/hello/mbed-os/connectivity/drivers/wifi/TARGET_STM/COMPONENT_EMW3080B/EMW3080B_SPI.cpp:203:18: note: mismatched types ‘mbed::CacheAlignedBuffer’ and 'uint8_t
’ {aka ‘unsigned char*’}
[build] 203 | SPI::transfer((const uint8_t ) txdata, (int) datalen, rxdata, (int) datalen, callback(this, &EMW3080B_SPI::spi_handler), SPI_EVENT_COMPLETE);
[build] | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build] C:/Users/tim/Mbed Programs/mbed-ce/hello/mbed-os/drivers/include/drivers/SPI.h:490:5: note: candidate: 'template typename std::enable_if<std::is_integral<_Tp>::value, int>::type mbed::SPI::transfer(const std::nullptr_t
, int, mbed::CacheAlignedBuffer&, int, const mbed::event_callback_t&, int)’
[build] 490 | transfer(const std::nullptr_t tx_buffer, int tx_length, CacheAlignedBuffer &rx_buffer, int rx_length, const event_callback_t &callback, int event = SPI_EVENT_COMPLETE)
[build] | ^~~~~~~~
[build] C:/Users/tim/Mbed Programs/mbed-ce/hello/mbed-os/drivers/include/drivers/SPI.h:490:5: note: template argument deduction/substitution failed:
[build] C:/Users/tim/Mbed Programs/mbed-ce/hello/mbed-os/connectivity/drivers/wifi/TARGET_STM/COMPONENT_EMW3080B/EMW3080B_SPI.cpp:203:18: note: mismatched types ‘mbed::CacheAlignedBuffer’ and 'uint8_t
’ {aka ‘unsigned char*’}
[build] 203 | SPI::transfer((const uint8_t ) txdata, (int) datalen, rxdata, (int) datalen, callback(this, &EMW3080B_SPI::spi_handler), SPI_EVENT_COMPLETE);
[build] | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build] C:/Users/tim/Mbed Programs/mbed-ce/hello/mbed-os/drivers/include/drivers/SPI.h:497:5: note: candidate: 'template typename std::enable_if<std::is_integral<_Tp>::value, int>::type mbed::SPI::transfer(const WordT
, int, std::nullptr_t*, int, const mbed::event_callback_t&, int)’
[build] 497 | transfer(const WordT tx_buffer, int tx_length, std::nullptr_t rx_buffer, int rx_length, const event_callback_t &callback, int event = SPI_EVENT_COMPLETE)
[build] | ^~~~~~~~
[build] C:/Users/tim/Mbed Programs/mbed-ce/hello/mbed-os/drivers/include/drivers/SPI.h:497:5: note: template argument deduction/substitution failed:
[build] C:/Users/tim/Mbed Programs/mbed-ce/hello/mbed-os/connectivity/drivers/wifi/TARGET_STM/COMPONENT_EMW3080B/EMW3080B_SPI.cpp:203:60: note: cannot convert ‘rxdata’ (type 'uint8_t
’ {aka 'unsigned char
’}) to type ‘std::nullptr_t*’
[build] 203 | SPI::transfer((const uint8_t ) txdata, (int) datalen, rxdata, (int) datalen, callback(this, &EMW3080B_SPI::spi_handler), SPI_EVENT_COMPLETE);
[build] | ^~~~~~
[build] C:/Users/tim/Mbed Programs/mbed-ce/hello/mbed-os/connectivity/drivers/wifi/TARGET_STM/COMPONENT_EMW3080B/EMW3080B_SPI.cpp: In member function 'int32_t EMW3080B_SPI::Transmit(uint8_t
, uint32_t, uint32_t)‘:
[build] C:/Users/tim/Mbed Programs/mbed-ce/hello/mbed-os/connectivity/drivers/wifi/TARGET_STM/COMPONENT_EMW3080B/EMW3080B_SPI.cpp:217:18: error: no matching function for call to ‘EMW3080B_SPI::transfer(const uint8_t*, int, uint8_t*, int, mbed::Callback<void(int)>, int)’
[build] 217 | SPI::transfer((const uint8_t ) txdata, (int) datalen, (uint8_t )NULL, (int) datalen, callback(this, &EMW3080B_SPI::spi_handler), SPI_EVENT_COMPLETE);
[build] | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build] C:/Users/tim/Mbed Programs/mbed-ce/hello/mbed-os/drivers/include/drivers/SPI.h:481:5: note: candidate: 'template typename std::enable_if<std::is_integral<_Tp>::value, int>::type mbed::SPI::transfer(const WordT
, int, mbed::CacheAlignedBuffer&, int, const mbed::event_callback_t&, int)’
[build] 481 | transfer(const WordT tx_buffer, int tx_length, CacheAlignedBuffer &rx_buffer, int rx_length, const event_callback_t &callback, int event = SPI_EVENT_COMPLETE)
[build] | ^~~~~~~~
[build] C:/Users/tim/Mbed Programs/mbed-ce/hello/mbed-os/drivers/include/drivers/SPI.h:481:5: note: template argument deduction/substitution failed:
[build] C:/Users/tim/Mbed Programs/mbed-ce/hello/mbed-os/connectivity/drivers/wifi/TARGET_STM/COMPONENT_EMW3080B/EMW3080B_SPI.cpp:217:18: note: mismatched types ‘mbed::CacheAlignedBuffer’ and 'uint8_t
’ {aka 'unsigned char
’}
[build] 217 | SPI::transfer((const uint8_t ) txdata, (int) datalen, (uint8_t )NULL, (int) datalen, callback(this, &EMW3080B_SPI::spi_handler), SPI_EVENT_COMPLETE);
[build] | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build] C:/Users/tim/Mbed Programs/mbed-ce/hello/mbed-os/drivers/include/drivers/SPI.h:490:5: note: candidate: 'template typename std::enable_if<std::is_integral<_Tp>::value, int>::type mbed::SPI::transfer(const std::nullptr_t
, int, mbed::CacheAlignedBuffer&, int, const mbed::event_callback_t&, int)’
[build] 490 | transfer(const std::nullptr_t tx_buffer, int tx_length, CacheAlignedBuffer &rx_buffer, int rx_length, const event_callback_t &callback, int event = SPI_EVENT_COMPLETE)
[build] | ^~~~~~~~
[build] C:/Users/tim/Mbed Programs/mbed-ce/hello/mbed-os/drivers/include/drivers/SPI.h:490:5: note: template argument deduction/substitution failed:
[build] C:/Users/tim/Mbed Programs/mbed-ce/hello/mbed-os/connectivity/drivers/wifi/TARGET_STM/COMPONENT_EMW3080B/EMW3080B_SPI.cpp:217:18: note: mismatched types ‘mbed::CacheAlignedBuffer’ and 'uint8_t
’ {aka 'unsigned char
’}
[build] 217 | SPI::transfer((const uint8_t ) txdata, (int) datalen, (uint8_t )NULL, (int) datalen, callback(this, &EMW3080B_SPI::spi_handler), SPI_EVENT_COMPLETE);
[build] | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build] C:/Users/tim/Mbed Programs/mbed-ce/hello/mbed-os/drivers/include/drivers/SPI.h:497:5: note: candidate: 'template typename std::enable_if<std::is_integral<_Tp>::value, int>::type mbed::SPI::transfer(const WordT
, int, std::nullptr_t
, int, const mbed::event_callback_t&, int)’
[build] 497 | transfer(const WordT tx_buffer, int tx_length, std::nullptr_t rx_buffer, int rx_length, const event_callback_t &callback, int event = SPI_EVENT_COMPLETE)
[build] | ^~~~~~~~
[build] C:/Users/tim/Mbed Programs/mbed-ce/hello/mbed-os/drivers/include/drivers/SPI.h:497:5: note: template argument deduction/substitution failed:
[build] C:/Users/tim/Mbed Programs/mbed-ce/hello/mbed-os/connectivity/drivers/wifi/TARGET_STM/COMPONENT_EMW3080B/EMW3080B_SPI.cpp:217:60: note: cannot convert ‘0’ (type 'uint8_t
’ {aka 'unsigned char
’}) to type ‘std::nullptr_t*’
[build] 217 | SPI::transfer((const uint8_t ) txdata, (int) datalen, (uint8_t )NULL, (int) datalen, callback(this, &EMW3080B_SPI::spi_handler), SPI_EVENT_COMPLETE);
[build] | ^
[build] C:/Users/tim/Mbed Programs/mbed-ce/hello/mbed-os/connectivity/drivers/wifi/TARGET_STM/COMPONENT_EMW3080B/EMW3080B_SPI.cpp: In member function 'int32_t EMW3080B_SPI::Receive(uint8_t
, uint32_t, uint32_t)':
[build] C:/Users/tim/Mbed Programs/mbed-ce/hello/mbed-os/connectivity/drivers/wifi/TARGET_STM/COMPONENT_EMW3080B/EMW3080B_SPI.cpp:229:18: error: no matching function for call to 'EMW3080B_SPI::transfer(const uint8_t
, int, uint8_t*&, int, mbed::Callback<void(int)>, int)’
[build] 229 | SPI::transfer((const uint8_t ) NULL, (int) datalen, rxdata, (int) datalen, callback(this, &EMW3080B_SPI::spi_handler), SPI_EVENT_COMPLETE);
[build] | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build] C:/Users/tim/Mbed Programs/mbed-ce/hello/mbed-os/drivers/include/drivers/SPI.h:481:5: note: candidate: 'template typename std::enable_if<std::is_integral<_Tp>::value, int>::type mbed::SPI::transfer(const WordT
, int, mbed::CacheAlignedBuffer&, int, const mbed::event_callback_t&, int)’
[build] 481 | transfer(const WordT tx_buffer, int tx_length, CacheAlignedBuffer &rx_buffer, int rx_length, const event_callback_t &callback, int event = SPI_EVENT_COMPLETE)
[build] | ^~~~~~~~
[build] C:/Users/tim/Mbed Programs/mbed-ce/hello/mbed-os/drivers/include/drivers/SPI.h:481:5: note: template argument deduction/substitution failed:
[build] C:/Users/tim/Mbed Programs/mbed-ce/hello/mbed-os/connectivity/drivers/wifi/TARGET_STM/COMPONENT_EMW3080B/EMW3080B_SPI.cpp:229:18: note: mismatched types ‘mbed::CacheAlignedBuffer’ and 'uint8_t
’ {aka ‘unsigned char*’}
[build] 229 | SPI::transfer((const uint8_t ) NULL, (int) datalen, rxdata, (int) datalen, callback(this, &EMW3080B_SPI::spi_handler), SPI_EVENT_COMPLETE);
[build] | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build] C:/Users/tim/Mbed Programs/mbed-ce/hello/mbed-os/drivers/include/drivers/SPI.h:490:5: note: candidate: 'template typename std::enable_if<std::is_integral<_Tp>::value, int>::type mbed::SPI::transfer(const std::nullptr_t
, int, mbed::CacheAlignedBuffer&, int, const mbed::event_callback_t&, int)’
[build] 490 | transfer(const std::nullptr_t tx_buffer, int tx_length, CacheAlignedBuffer &rx_buffer, int rx_length, const event_callback_t &callback, int event = SPI_EVENT_COMPLETE)
[build] | ^~~~~~~~
[build] C:/Users/tim/Mbed Programs/mbed-ce/hello/mbed-os/drivers/include/drivers/SPI.h:490:5: note: template argument deduction/substitution failed:
[build] C:/Users/tim/Mbed Programs/mbed-ce/hello/mbed-os/connectivity/drivers/wifi/TARGET_STM/COMPONENT_EMW3080B/EMW3080B_SPI.cpp:229:18: note: mismatched types ‘mbed::CacheAlignedBuffer’ and 'uint8_t
’ {aka ‘unsigned char*’}
[build] 229 | SPI::transfer((const uint8_t ) NULL, (int) datalen, rxdata, (int) datalen, callback(this, &EMW3080B_SPI::spi_handler), SPI_EVENT_COMPLETE);
[build] | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build] C:/Users/tim/Mbed Programs/mbed-ce/hello/mbed-os/drivers/include/drivers/SPI.h:497:5: note: candidate: 'template typename std::enable_if<std::is_integral<_Tp>::value, int>::type mbed::SPI::transfer(const WordT
, int, std::nullptr_t*, int, const mbed::event_callback_t&, int)’
[build] 497 | transfer(const WordT tx_buffer, int tx_length, std::nullptr_t rx_buffer, int rx_length, const event_callback_t &callback, int event = SPI_EVENT_COMPLETE)
[build] | ^~~~~~~~
[build] C:/Users/tim/Mbed Programs/mbed-ce/hello/mbed-os/drivers/include/drivers/SPI.h:497:5: note: template argument deduction/substitution failed:
[build] C:/Users/tim/Mbed Programs/mbed-ce/hello/mbed-os/connectivity/drivers/wifi/TARGET_STM/COMPONENT_EMW3080B/EMW3080B_SPI.cpp:229:58: note: cannot convert ‘rxdata’ (type 'uint8_t
’ {aka 'unsigned char
’}) to type ‘std::nullptr_t*’
[build] 229 | SPI::transfer((const uint8_t *) NULL, (int) datalen, rxdata, (int) datalen, callback(this, &EMW3080B_SPI::spi_handler), SPI_EVENT_COMPLETE);
[build] | ^~~~~~
[build] ninja: build stopped: subcommand failed.

Oops, looks like I broke this with a recent Mbed CE change. Taking a look…

Here, can you try this branch? Fix issues with new async SPI changes that broke compiling for B_U585I_IOT2A by multiplemonomials · Pull Request #204 · mbed-ce/mbed-os · GitHub

Hopefully that will get wifi working – it would be great if you could test it as I do not have a B_U585I_IOT2A to test with.

fwiw, there is an upside to this change as well: Once I fix mbed-ce#196 and get DMA SPI working on STM32U5, this driver can now be switched to use DMA. That will make it run at a much faster SPI clock and use significantly less background CPU!

Ok, that was embarrassingly simple. I just had run across the use the ‘&’ operator in a function declaration not long after your quick reply, many thanks from an (older ;^) C programmer. It now compiles and the EMW3080B SPI appears to be working with a local AP scan.

The reason it took so long to get back to you is I ran into 2 other issues porting from mbed-os v6.17.

  • The octal printf format specifier %o appears to not be recognized and created a hard fault that took a while to track down. I have the “std” printf configured in mbed_app.json.
  • lfs on the B-U585 discovery board’s OSPI flash appears to work fine but a simple change to lfsv2 has problems. Re-formatting returns 0 and a view of the resulting filesystem gives ‘.’ and ‘…’. Initializing a kvstore returns success but the ‘kvstore’ directory is not created. Creating a file or directory of a name other than exactly 2 characters either seems to randomly truncate the name or reduce the file system to the original ‘.’ and ‘…’ entries. Rebooting and remounting the filesystem returns -2 which is ‘no directory entry’

If any of this sparks anything, let me know. I have worked around the octal format and reverted to lfs for now till I have more time to dig further.

Wow that is weird… kinda sounds like something at the OSPI layer or the block device layer is having issues. I’m not an LFS or OSPI expert so I don’t think I know any more than you do about this one.

So you’re saying that LFS v2 used to work on the older version of Mbed CE? Might be interesting to try and roll back and see where the issue started happening.

I’m was leaning toward something in lfsv2 since lfs doesn’t seem to have any issues. Could even be something in the setup parameters. I checked and as far as I know the latest mbed-ce and mbed-os use the same lfsv2 code version 2.2. Maybe something changed below that only affects lfsv2. Like I said, the only change I make from working to not workings is:

#include “LittleFileSystem.h”
LittleFileSysytem fs(“fs”);

to

#include “LittleFileSystem2.h”
LittleFileSysytem2 fs(“fs”);

you know, it’s actually kinda messed up that Mbed doesn’t have any automated tests for LFS v1 or v2. It should be easy to test using a RAM block device!

I tried lfs2 on a HeapBlockDevice and it seems to work. So, possibly the OSPIF device driver. Still can’t rule out a bug between lfs2 and ospif since lfs seems to work. More info but not a lot smarter…