Failed to include "QSPIFBlockDevice.h" and "SPIFBlockDevice.h" in MbedOS 6

Hi,

I would like to implement functions to read, write and erase the external 4MB NOR flash memory, W25Q32, on the NuMaker-IoT-M487 development board.
My compile tool is “Mbed CLI2” and I used MbedOS in docker.

First I imported a new MbedOS-6 project, followed the codes of this example and then config my “mbed_app.json” file as the following.

"NUMAKER_IOT_M487": {
    "target.components_add": ["QSPIF"],
    "qspif.QSPI_IO0":"PC_0",
    "qspif.QSPI_IO1":"PC_1",
    "qspif.QSPI_IO2":"PC_5",
    "qspif.QSPI_IO3":"PC_4",
    "qspif.QSPI_SCK":"PC_2",
    "qspif.QSPI_CSN":"PC_3"
},

But I always received this error message:

I tried to add “NUMAKER_IOT_M487” in the “mbed_lib.jon” of “COMPONENT_QSPIF” and tried to config the “CMakerLists.txt” file as the following:

target_link_libraries(${APP_TARGET}
    PRIVATE
        mbed-os
        mbed-netsocket
        mbed-cellular
        mbed-events
        mbed-storage-blockdevice
        mbed-storage-filesystem
        mbed-drivers
        mbed-connectiviy
)

Furthermore, I also tried two example, “mbed-os-example-sd-driver” and “mbed-os-example-filesystem” and both of them didn’t work on NuMaker-IoT-M487 board.
But I found that if I select other devices then the project can be compiled successfully.

These questions confused me:

  1. How to include the library properly in MbedOS6?
  2. Why different device have different result of compilation?
  3. How to use “QSPIBlockDevice” and “SPIBlockDevice”?

Do anyone have related experience can share with me?
I will really appreciate for suggestions.

Hello,

I am sure you need also QSPI for QSPIFBD. Just add also setting bellow to your mbed_app.json

   "target.device_has_add": ["QSPI"]

The configuration system - Program setup | Mbed OS 6 Documentation

That is caused by settings in targets.json by Nuvoton. Other manufacturers or specific boards could have different settings for various reasons.

I hope you found your answers

BR, Jan

1 Like

Hello @JohnnyK ,

Thank your very much for your reply.

I followed your suggestion and tried with the SPIFBlockDevice library, and then the project work properly now.
In the SPI test project, I used SPIFBlockDevice library as an external library or there would be the errors.

After SPIFBlockDevice, I tried to include and use QSPIFBlockDevice library in the same way I configed SPIFBlockDevice library.
But QSPIFBlockDevice library still can’t be used and the following are the error messages

In file included from /workspace/MbedOfficial/mbed-os-6-example-SPI_API/main.cpp:16:
/workspace/MbedOfficial/mbed-os-6-example-SPI_API/include/QSPIFBlockDevice.h:266:5: error: 'qspi_status_t' does not name a type; did you mean 'osStatus_t'?
  266 |     qspi_status_t _qspi_send_program_command(mbed::qspi_inst_t prog_instruction, const void *buffer,
      |     ^~~~~~~~~~~~~
      |     osStatus_t
/workspace/MbedOfficial/mbed-os-6-example-SPI_API/include/QSPIFBlockDevice.h:270:5: error: 'qspi_status_t' does not name a type; did you mean 'osStatus_t'?
  270 |     qspi_status_t _qspi_send_read_command(mbed::qspi_inst_t read_instruction, void *buffer, mbed::bd_addr_t addr, mbed::bd_size_t size);
      |     ^~~~~~~~~~~~~
      |     osStatus_t
In file included from /workspace/MbedOfficial/mbed-os-6-example-SPI_API/main.cpp:16:
/workspace/MbedOfficial/mbed-os-6-example-SPI_API/include/QSPIFBlockDevice.h:273:5: error: 'qspi_status_t' does not name a type; did you mean 'osStatus_t'?
  273 |     qspi_status_t _qspi_send_erase_command(mbed::qspi_inst_t erase_instruction, mbed::bd_addr_t addr, mbed::bd_size_t size);
      |     ^~~~~~~~~~~~~
      |     osStatus_t
/workspace/MbedOfficial/mbed-os-6-example-SPI_API/include/QSPIFBlockDevice.h:276:5: error: 'qspi_status_t' does not name a type; did you mean 'osStatus_t'?
  276 |     qspi_status_t _qspi_send_general_command(mbed::qspi_inst_t instruction_int, mbed::bd_addr_t addr, const char *tx_buffer,
      |     ^~~~~~~~~~~~~
      |     osStatus_t
/workspace/MbedOfficial/mbed-os-6-example-SPI_API/include/QSPIFBlockDevice.h:285:5: error: 'qspi_status_t' does not name a type; did you mean 'osStatus_t'?
  285 |     qspi_status_t _qspi_read_status_registers(uint8_t *reg_buffer);
      |     ^~~~~~~~~~~~~
      |     osStatus_t
/workspace/MbedOfficial/mbed-os-6-example-SPI_API/include/QSPIFBlockDevice.h:288:5: error: 'qspi_status_t' does not name a type; did you mean 'osStatus_t'?
  288 |     qspi_status_t _qspi_write_status_registers(uint8_t *reg_buffer);
      |     ^~~~~~~~~~~~~
      |     osStatus_t
/workspace/MbedOfficial/mbed-os-6-example-SPI_API/include/QSPIFBlockDevice.h:291:5: error: 'qspi_status_t' does not name a type; did you mean 'osStatus_t'?
  291 |     qspi_status_t _qspi_set_frequency(int freq);
      |     ^~~~~~~~~~~~~
      |     osStatus_t
/workspace/MbedOfficial/mbed-os-6-example-SPI_API/include/QSPIFBlockDevice.h:294:5: error: 'qspi_status_t' does not name a type; did you mean 'osStatus_t'?
  294 |     qspi_status_t _qspi_update_4byte_ext_addr_reg(mbed::bd_addr_t addr);
      |     ^~~~~~~~~~~~~
      |     osStatus_t
/workspace/MbedOfficial/mbed-os-6-example-SPI_API/include/QSPIFBlockDevice.h:344:11: error: 'QSPI' in namespace 'mbed' does not name a type; did you mean 'SPI'?
  344 |     mbed::QSPI _qspi;
      |           ^~~~
      |           SPI
/workspace/MbedOfficial/mbed-os-6-example-SPI_API/include/QSPIFBlockDevice.h:361:11: error: 'qspi_inst_t' in namespace 'mbed' does not name a type
  361 |     mbed::qspi_inst_t _read_instruction;
      |           ^~~~~~~~~~~
/workspace/MbedOfficial/mbed-os-6-example-SPI_API/include/QSPIFBlockDevice.h:365:11: error: 'qspi_inst_t' in namespace 'mbed' does not name a type
  365 |     mbed::qspi_inst_t _write_status_reg_2_inst;
      |           ^~~~~~~~~~~
/workspace/MbedOfficial/mbed-os-6-example-SPI_API/include/QSPIFBlockDevice.h:366:11: error: 'qspi_inst_t' in namespace 'mbed' does not name a type
  366 |     mbed::qspi_inst_t _read_status_reg_2_inst; // If three registers, this instruction reads the latter two
      |           ^~~~~~~~~~~
/workspace/MbedOfficial/mbed-os-6-example-SPI_API/include/QSPIFBlockDevice.h:371:11: error: 'qspi_inst_t' in namespace 'mbed' does not name a type
  371 |     mbed::qspi_inst_t _4byte_msb_reg_write_inst;
      |           ^~~~~~~~~~~
/workspace/MbedOfficial/mbed-os-6-example-SPI_API/include/QSPIFBlockDevice.h:392:5: error: 'qspi_bus_width_t' does not name a type
  392 |     qspi_bus_width_t _inst_width; //Bus width for Instruction phase
      |     ^~~~~~~~~~~~~~~~
/workspace/MbedOfficial/mbed-os-6-example-SPI_API/include/QSPIFBlockDevice.h:393:5: error: 'qspi_bus_width_t' does not name a type
  393 |     qspi_bus_width_t _address_width; //Bus width for Address phase
      |     ^~~~~~~~~~~~~~~~
/workspace/MbedOfficial/mbed-os-6-example-SPI_API/include/QSPIFBlockDevice.h:394:5: error: 'qspi_address_size_t' does not name a type
  394 |     qspi_address_size_t _address_size; //Number of bits for address
      |     ^~~~~~~~~~~~~~~~~~~
/workspace/MbedOfficial/mbed-os-6-example-SPI_API/include/QSPIFBlockDevice.h:395:5: error: 'qspi_alt_size_t' does not name a type
  395 |     qspi_alt_size_t _alt_size; //Number of bits for alt
      |     ^~~~~~~~~~~~~~~
/workspace/MbedOfficial/mbed-os-6-example-SPI_API/include/QSPIFBlockDevice.h:398:5: error: 'qspi_bus_width_t' does not name a type
  398 |     qspi_bus_width_t _data_width; //Bus width for Data phase

I am confused that why SPIFBlockDevice library works but QSPIFBlockDevice library not and they are both based on BlockDevice.

SPIFBlockDevice library is enough for my project, and I will attach the link of repository about the SPIFBlockDevice library configuration when I finish it.

Thank you once again for your help!

Best regards,
Raven