Mollayo / SAMD_InternalFlash

A library for storing data in the internal flash of the SAMD21/SAMD51 MCU with the FatFS file system.
2 stars 1 forks source link

Can' compile example on Seeeduino XIAO & QT Py #1

Open FedericoBusero opened 1 year ago

FedericoBusero commented 1 year ago

I tried all kinds of combinations of versions to let the example compile on Seeeduino XIAO and QT PY, but I didn't succeed. Of course I have set it on "USB Stack: TinyUSB"

Can you give the version numbers for which the library has been designed for on a) Seeeduino XIAO and b) QT Py. Can you give for each of them:

Thanks!

Mollayo commented 1 year ago

What compilation error do you get ?

Mollayo commented 1 year ago

I have just compiled myself and I am facing the following compilation error:

SAMD_Internal_Flash_with_USB_Mass_Storage:19:39: error: cannot declare variable 'flashTransport' to be of abstract type 'Adafruit_FlashTransport_InternalFlash' 19 | Adafruit_FlashTransport_InternalFlash flashTransport(&my_internal_storage); | ^~~~~~ In file included from /home/fred/Arduino/libraries/SAMD_InternalFlash/src/SAMD_InternalFlash.h:28, from /home/fred/Arduino/SAMD_Internal_Flash_with_USB_Mass_Storage/SAMD_Internal_Flash_with_USB_Mass_Storage.ino:8: /home/fred/Arduino/libraries/SAMD_InternalFlash/src/Adafruit_FlashTransport_InternalFlash.h:36:7: note: because the following virtual functions are pure within 'Adafruit_FlashTransport_InternalFlash': 36 | class Adafruit_FlashTransport_InternalFlash : public Adafruit_FlashTransport { | ^~~~~~~~~ In file included from /home/fred/Arduino/libraries/SAMD_InternalFlash/src/Adafruit_FlashTransport_InternalFlash.h:31, from /home/fred/Arduino/libraries/SAMD_InternalFlash/src/SAMD_InternalFlash.h:28, from /home/fred/Arduino/SAMD_Internal_Flash_with_USB_Mass_Storage/SAMD_Internal_Flash_with_USB_Mass_Storage.ino:8: /home/fred/Arduino/libraries/Adafruit_SPIFlash/src/Adafruit_FlashTransport.h:71:16: note: 'virtual void Adafruit_FlashTransport::end()' 71 | virtual void end(void) = 0; | ^~~ Multiple libraries were found for "Adafruit_TinyUSB.h" Used: /home/fred/Arduino/libraries/Adafruit_TinyUSB_Library Not used: /home/fred/.arduino15/packages/adafruit/hardware/samd/1.7.11/libraries/Adafruit_TinyUSB_Arduino Not used: /home/fred/Arduino/libraries/Adafruit_TinyUSB_Arduino Multiple libraries were found for "Adafruit_ZeroDMA.h" Used: /home/fred/.arduino15/packages/adafruit/hardware/samd/1.7.11/libraries/Adafruit_ZeroDMA Not used: /home/fred/Arduino/libraries/Adafruit_Zero_DMA_Library exit status 1 cannot declare variable 'flashTransport' to be of abstract type 'Adafruit_FlashTransport_InternalFlash'

Adafruit has made some changes to its library for InternalFlash. I will correct the error and update mine.

Mollayo commented 1 year ago

I have updated the library. It should compile again with the Adafruit board. Once the firmware has been uploaded, the SAMD disk should be formated using Windows or Ubuntu before use.

However, it does not compile using the Seeeduino board. There are some compilation errors between the Adafruit_TinyUSB and Seeeduino package. But you can use the Adafruit board for most of the Seeeduino devices with a SAMD microcontroller. For instance, the firmware for the Seeeduino XIAO can be generated using the Adafruit QT Py M0. These two boards use the same microcontroller.

Mollayo commented 1 year ago

Let me know if you have any other problem.

FedericoBusero commented 1 year ago

Thank you very much for your quick fix. I can indeed confirm that it now works on QT PY using SPIFlash library version 4.0.0.

Thanks again, this really helps!

Mollayo commented 1 year ago

Ok. I will modify the README file according to your comments. Concerning the SdFat library, I have found that the access of the MCU to the internal flash such as here: https://github.com/Mollayo/SAMD_InternalFlash/blob/19863b0b301108d54027920b03c7fcb163f9721b/examples/Internal_Flash_with_USB_Mass_Storage/Internal_Flash_with_USB_Mass_Storage.ino#L121 does not work with SdFat version 2.2.1 but works with version 1.5.1. I do not know if you are experiencing the same isuue.

FedericoBusero commented 1 year ago

I currently can´t test, but I see other examples use FatFile or File as type of root.

FedericoBusero commented 1 year ago

Your code does compile, and USB Mass storage functionality works on

But have a look at my example file https://github.com/FedericoBusero/USB_MassStorage_Flash/blob/main/USB_MassStorage_Flash.ino which does work on the same chips&versions including the serial port control functions.

It also works on ESP32-S2 using

Mollayo commented 1 year ago

I cannot test your code now. But when I tried few weeks back the SAMD_InternalFlash library with TinyUSB library version 0.10.5 and SdFat 1.51, it worked with no problem; the MCU could open and read the files. This is not the case with the lastest version of the TinyUSB library and the SdFat library. I will investigate this problem next week.

FedericoBusero commented 1 year ago

You are right: in SdFat - Adafruit fork version 1.5.1 it indeed does work. I tried all kinds of little changes (compared with my working code), but I couldn't get your code to work in SdFat - Adafruit fork version 2.2.1:

But in all cases, it hangs in the "listing files" code. I have no idea

Mollayo commented 1 year ago

I managed to make it working with the latest version of the Adafruit_SPIFlash library: https://github.com/adafruit/Adafruit_SPIFlash/releases/tag/4.1.0

You need to get this library from Github because the version which is available in the Arduibo IDE is 4.0.0. Also, you need to restart the Arduino IDE to take into account this new version.

Other libraries that are required:

Mollayo commented 1 year ago

@FedericoBusero Did you try to update the Adafruit_SPIFlash library as I explained above ? Could you make the SAMD_InternalFlash code working ?

FedericoBusero commented 1 year ago

I tried on QT Py using SPiFlash github version, TinyUSB 1.17.0:

I tried on Seeduino XIAO SAMD21 using SPiFlash github version, TinyUSB 0.10.5 with identical results:

Mollayo commented 1 year ago

Thank you for your feedback. I was actually using the ItsyBitsy M4 for testing and it worked with no problem.

I could reproduce your error with the Seeeduino XIAO. Actually, the writting of files does not seems to work. I have to investigate this problem. It might be related to some bugs in the Adafruit_SPIFlash library.

Mollayo commented 1 year ago

Actually, it looks like it's a problem related to the cache which is not correctly flushed.