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

Failed to compile msc_sd example #416

Open
vanbwodonk opened this issue May 1, 2024 · 0 comments
Open

Failed to compile msc_sd example #416

vanbwodonk opened this issue May 1, 2024 · 0 comments
Labels
Bug Something isn't working

Comments

@vanbwodonk
Copy link
Contributor

Operating System

Linux

Arduino IDE version

1.8.19

Board

Raspberry pi pico

ArduinoCore version

arduino-pico core 3.8.0

TinyUSB Library version

3.1.3

Sketch as ATTACHED TXT

/*********************************************************************
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!

MIT license, check LICENSE for more information
Copyright (c) 2019 Ha Thach for Adafruit Industries
All text above, and the splash screen below must be included in
any redistribution
*********************************************************************/

/* This example expose SD card as mass storage using

  • default SD Library
    */

#include "SD.h"
#include "Adafruit_TinyUSB.h"
#include "SdFat.h"

const int chipSelect = 10;

Adafruit_USBD_MSC usb_msc;

Sd2Card card;
SdVolume volume;

// the setup function runs once when you press reset or power the board
void setup()
{
// Set disk vendor id, product id and revision with string up to 8, 16, 4 characters respectively
usb_msc.setID("Adafruit", "SD Card", "1.0");

// Set read write callback
usb_msc.setReadWriteCallback(msc_read_cb, msc_write_cb, msc_flush_cb);

// Still initialize MSC but tell usb stack that MSC is not ready to read/write
// If we don't initialize, board will be enumerated as CDC only
usb_msc.setUnitReady(false);
usb_msc.begin();

Serial.begin(115200);
//while ( !Serial ) delay(10); // wait for native usb

Serial.println("Adafruit TinyUSB Mass Storage SD Card example");

Serial.println("\nInitializing SD card...");

if ( !card.init(SPI_HALF_SPEED, chipSelect) )
{
Serial.println("initialization failed. Things to check:");
Serial.println("* is a card inserted?");
Serial.println("* is your wiring correct?");
Serial.println("* did you change the chipSelect pin to match your shield or module?");
while (1) delay(1);
}

// Now we will try to open the 'volume'/'partition' - it should be FAT16 or FAT32
if (!volume.init(card)) {
Serial.println("Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card");
while (1) delay(1);
}

uint32_t block_count = volume.blocksPerCluster()*volume.clusterCount();

Serial.print("Volume size (MB): ");
Serial.println((block_count/2) / 1024);

// Set disk size, SD block size is always 512
usb_msc.setCapacity(block_count, 512);

// MSC is ready for read/write
usb_msc.setUnitReady(true);
}

void loop()
{
// nothing to do
}

// Callback invoked when received READ10 command.
// Copy disk's data to buffer (up to bufsize) and
// return number of copied bytes (must be multiple of block size)
int32_t msc_read_cb (uint32_t lba, void* buffer, uint32_t bufsize)
{
(void) bufsize;
return card.readBlock(lba, (uint8_t*) buffer) ? 512 : -1;
}

// Callback invoked when received WRITE10 command.
// Process data in buffer to disk's storage and
// return number of written bytes (must be multiple of block size)
int32_t msc_write_cb (uint32_t lba, uint8_t* buffer, uint32_t bufsize)
{
(void) bufsize;
return card.writeBlock(lba, buffer) ? 512 : -1;
}

// Callback invoked when WRITE10 command is completed (status received and accepted by host).
// used to flush any pending cache.
void msc_flush_cb (void)
{
// nothing to do
}

Compiled Log as ATTACHED TXT

In file included from /home/drw/.arduino15/packages/rp2040/hardware/rp2040/3.8.0/libraries/SD/src/SD.h:24,
from /home/drw/Arduino/msc_sd/msc_sd.ino:16:
/home/drw/.arduino15/packages/rp2040/hardware/rp2040/3.8.0/libraries/SDFS/src/SDFS.h: In member function 'virtual int sdfs::SDFSFileImpl::availableForWrite()':
/home/drw/.arduino15/packages/rp2040/hardware/rp2040/3.8.0/libraries/SDFS/src/SDFS.h:279:31: error: 'using element_type = class File32' {aka 'class File32'} has no member named 'availableSpaceForWrite'; did you mean 'availableForWrite'?
279 | return _opened ? fd->availableSpaceForWrite() : 0;
| ^~~~~~~~~~~~~~~~~~~~~~
| availableForWrite
/home/drw/Arduino/msc_sd/msc_sd.ino: At global scope:
msc_sd:24:1: error: 'Sd2Card' does not name a type; did you mean 'SdCard'?
24 | Sd2Card card;
| ^~~~~~~
| SdCard
msc_sd:25:1: error: 'SdVolume' does not name a type; did you mean 'FsVolume'?
25 | SdVolume volume;
| ^~~~~~~~
| FsVolume
/home/drw/Arduino/msc_sd/msc_sd.ino: In function 'void setup()':
msc_sd:48:9: error: 'card' was not declared in this scope
48 | if ( !card.init(SPI_HALF_SPEED, chipSelect) )
| ^~~~
msc_sd:58:8: error: 'volume' was not declared in this scope; did you mean 'FsVolume'?
58 | if (!volume.init(card)) {
| ^~~~~~
| FsVolume
msc_sd:58:20: error: 'card' was not declared in this scope
58 | if (!volume.init(card)) {
| ^~~~
msc_sd:63:26: error: 'volume' was not declared in this scope; did you mean 'FsVolume'?
63 | uint32_t block_count = volume.blocksPerCluster()volume.clusterCount();
| ^~~~~~
| FsVolume
/home/drw/Arduino/msc_sd/msc_sd.ino: In function 'int32_t msc_read_cb(uint32_t, void
, uint32_t)':
msc_sd:86:10: error: 'card' was not declared in this scope
86 | return card.readBlock(lba, (uint8_t*) buffer) ? 512 : -1;
| ^~~~
/home/drw/Arduino/msc_sd/msc_sd.ino: In function 'int32_t msc_write_cb(uint32_t, uint8_t*, uint32_t)':
msc_sd:95:10: error: 'card' was not declared in this scope
95 | return card.writeBlock(lba, buffer) ? 512 : -1;
| ^~~~
Multiple libraries were found for "SdFat.h"
Used: /home/drw/Arduino/libraries/SdFat
-_Adafruit_Fork

What happened ?

Sd2Card and SdVolume not include in library. Already download and include adafruit fork sdfat.

How to reproduce ?

  1. Open File > Examples > Adafruit TinyUSB Library > DualRole > msc_file_explorer
  2. Download and include Adafruit SdFat library
  3. Build

Debug Log

No response

Screenshots

No response

@vanbwodonk vanbwodonk added the Bug Something isn't working label May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant