adafruit / Adafruit_TinyUSB_Arduino

Arduino library for TinyUSB
MIT License
476 stars 127 forks source link

'Sd2Card' does not name a type (msc_sd example) #383

Closed orichienal closed 7 months ago

orichienal commented 7 months ago

Operating System

Windows 10

Arduino IDE version

1.8.19

Board

LOLIN S3 pro

ArduinoCore version

Arduino AVR Boards 1.8.6, esp32 2.0.14

TinyUSB Library version

3.0.0

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

include "SD.h"

include "Adafruit_TinyUSB.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 C:\arduino-1.8.19-esp32c\arduino-1.8.19\portable\sketchbook\libraries\Adafruit_TinyUSB_Library\src/Adafruit_TinyUSB.h:68, from C:\arduino-1.8.19-esp32c\arduino-1.8.19\portable\sketchbook\libraries\Adafruit_TinyUSB_Library\examples\MassStorage\msc_sd\msc_sd.ino:17: C:\arduino-1.8.19-esp32c\arduino-1.8.19\portable\sketchbook\libraries\Adafruit_TinyUSB_Library\src/arduino/video/Adafruit_USBD_Video.h:41:15: error: 'tusb_desc_video_control_camera_terminal_t' has not been declared addTerminal(tusb_desc_video_control_camera_terminal_t const camera_terminal); ^~~~~~~~~ C:\arduino-1.8.19-esp32c\arduino-1.8.19\portable\sketchbook\libraries\Adafruit_TinyUSB_Library\src/arduino/video/Adafruit_USBD_Video.h:43:15: error: 'tusb_desc_video_control_output_terminal_t' has not been declared addTerminal(tusb_desc_video_control_output_terminal_t const output_terminal); ^~~~~~~~~ C:\arduino-1.8.19-esp32c\arduino-1.8.19\portable\sketchbook\libraries\Adafruit_TinyUSB_Library\src/arduino/video/Adafruit_USBD_Video.h:43:3: error: 'bool Adafruit_USBD_Video::addTerminal(const int)' cannot be overloaded with 'bool Adafruit_USBD_Video::addTerminal(const int)' addTerminal(tusb_desc_video_control_output_terminal_t const output_terminal); ^~~ C:\arduino-1.8.19-esp32c\arduino-1.8.19\portable\sketchbook\libraries\Adafruit_TinyUSB_Library\src/arduino/video/Adafruit_USBD_Video.h:41:3: note: previous declaration 'bool Adafruit_USBD_Video::addTerminal(const int)' addTerminal(tusb_desc_video_control_camera_terminal_t const camera_terminal); ^~~ C:\arduino-1.8.19-esp32c\arduino-1.8.19\portable\sketchbook\libraries\Adafruit_TinyUSB_Library\src/arduino/video/Adafruit_USBD_Video.h:49:18: error: 'tusb_desc_video_format_uncompressed_t' has not been declared bool addFormat(tusb_desc_video_format_uncompressed_t const format); ^~~~~~~~~ C:\arduino-1.8.19-esp32c\arduino-1.8.19\portable\sketchbook\libraries\Adafruit_TinyUSB_Library\src/arduino/video/Adafruit_USBD_Video.h:50:17: error: 'tusb_desc_video_frame_uncompressed_continuous_t' has not been declared bool addFrame(tusb_desc_video_frame_uncompressed_continuous_t const frame); ^~~~~~~~~~~ C:\arduino-1.8.19-esp32c\arduino-1.8.19\portable\sketchbook\libraries\Adafruit_TinyUSB_Library\src/arduino/video/Adafruit_USBD_Video.h:52:20: error: 'tusb_desc_video_streaming_color_matching_t' has not been declared addColorMatching(tusb_desc_video_streaming_color_matching_t const color); ^~~~~~~~~~ C:\arduino-1.8.19-esp32c\arduino-1.8.19\portable\sketchbook\libraries\Adafruit_TinyUSB_Library\src/arduino/video/Adafruit_USBD_Video.h:61:3: error: 'tusb_desc_video_control_camera_terminal_t' does not name a type; did you mean 'tusb_desc_cs_video_ctl_itf_hdr_t'? tusb_desc_video_control_camera_terminal_t _camera_terminal; ^~~~~~~~~ tusb_desc_cs_video_ctl_itf_hdr_t C:\arduino-1.8.19-esp32c\arduino-1.8.19\portable\sketchbook\libraries\Adafruit_TinyUSB_Library\src/arduino/video/Adafruit_USBD_Video.h:62:3: error: 'tusb_desc_video_control_output_terminal_t' does not name a type; did you mean 'audio_desc_output_terminal_t'? tusb_desc_video_control_output_terminal_t _output_terminal; ^~~~~~~~~ audio_desc_output_terminal_t C:\arduino-1.8.19-esp32c\arduino-1.8.19\portable\sketchbook\libraries\Adafruit_TinyUSB_Library\src/arduino/video/Adafruit_USBD_Video.h:66:5: error: 'tusb_desc_video_format_uncompressed_t' does not name a type; did you mean 'tusb_desc_cs_video_frm_uncompressed_t'? tusb_desc_video_format_uncompressed_t uncompressed; ^~~~~~~~~ tusb_desc_cs_video_frm_uncompressed_t C:\arduino-1.8.19-esp32c\arduino-1.8.19\portable\sketchbook\libraries\Adafruit_TinyUSB_Library\src/arduino/video/Adafruit_USBD_Video.h:67:5: error: 'tusb_desc_video_format_mjpeg_t' does not name a type; did you mean 'tusb_desc_cs_video_frm_mjpeg_t'? tusb_desc_video_format_mjpeg_t mjpeg; ^~~~~~~~~~ tusb_desc_cs_video_frm_mjpeg_t C:\arduino-1.8.19-esp32c\arduino-1.8.19\portable\sketchbook\libraries\Adafruit_TinyUSB_Library\src/arduino/video/Adafruit_USBD_Video.h:71:5: error: 'tusb_desc_video_frame_uncompressed_continuous_t' does not name a type; did you mean 'tusb_desc_cs_video_frm_uncompressed_t'? tusb_desc_video_frame_uncompressed_continuous_t uncompressed_cont; ^~~~~~~~~~~ tusb_desc_cs_video_frm_uncompressed_t C:\arduino-1.8.19-esp32c\arduino-1.8.19\portable\sketchbook\libraries\Adafruit_TinyUSB_Library\src/arduino/video/Adafruit_USBD_Video.h:72:5: error: 'tusb_desc_video_frame_mjpeg_continuous_t' does not name a type; did you mean 'tusb_desc_cs_video_frm_mjpeg_t'? tusb_desc_video_frame_mjpeg_continuous_t mjpeg; ^~~~~~~~~~~~ tusb_desc_cs_video_frm_mjpeg_t C:\arduino-1.8.19-esp32c\arduino-1.8.19\portable\sketchbook\libraries\Adafruit_TinyUSB_Library\src/arduino/video/Adafruit_USBD_Video.h:75:3: error: 'tusb_desc_video_streaming_color_matching_t' does not name a type; did you mean 'tusb_desc_cs_video_stm_itf_out_hdr_t'? tusb_desc_video_streaming_color_matching_t _color_matching; ^~~~~~~~~~ tusb_desc_cs_video_stm_itf_out_hdr_t msc_sd:23:1: error: 'Sd2Card' does not name a type Sd2Card card; ^~~ msc_sd:24:1: error: 'SdVolume' does not name a type SdVolume volume; ^~~~ C:\arduino-1.8.19-esp32c\arduino-1.8.19\portable\sketchbook\libraries\Adafruit_TinyUSB_Library\examples\MassStorage\msc_sd\msc_sd.ino: In function 'void setup()': msc_sd:47:9: error: 'card' was not declared in this scope if ( !card.init(SPI_HALF_SPEED, chipSelect) ) ^~~~ C:\arduino-1.8.19-esp32c\arduino-1.8.19\portable\sketchbook\libraries\Adafruit_TinyUSB_Library\examples\MassStorage\msc_sd\msc_sd.ino:47:9: note: suggested alternative: 'word' if ( !card.init(SPI_HALF_SPEED, chipSelect) ) ^~~~ word msc_sd:47:19: error: 'SPI_HALF_SPEED' was not declared in this scope if ( !card.init(SPI_HALF_SPEED, chipSelect) ) ^~~~~~ C:\arduino-1.8.19-esp32c\arduino-1.8.19\portable\sketchbook\libraries\Adafruit_TinyUSB_Library\examples\MassStorage\msc_sd\msc_sd.ino:47:19: note: suggested alternative: 'ETH_STATE_SPEED' if ( !card.init(SPI_HALF_SPEED, chipSelect) ) ^~~~~~ ETH_STATE_SPEED msc_sd:57:8: error: 'volume' was not declared in this scope if (!volume.init(card)) { ^~ C:\arduino-1.8.19-esp32c\arduino-1.8.19\portable\sketchbook\libraries\Adafruit_TinyUSB_Library\examples\MassStorage\msc_sd\msc_sd.ino:57:8: note: suggested alternative: '_glue' if (!volume.init(card)) { ^~ _glue msc_sd:57:20: error: 'card' was not declared in this scope if (!volume.init(card)) { ^~~~ C:\arduino-1.8.19-esp32c\arduino-1.8.19\portable\sketchbook\libraries\Adafruit_TinyUSB_Library\examples\MassStorage\msc_sd\msc_sd.ino:57:20: note: suggested alternative: 'word' if (!volume.init(card)) { ^~~~ word msc_sd:62:26: error: 'volume' was not declared in this scope uint32_t block_count = volume.blocksPerCluster()volume.clusterCount(); ^~ C:\arduino-1.8.19-esp32c\arduino-1.8.19\portable\sketchbook\libraries\Adafruit_TinyUSB_Library\examples\MassStorage\msc_sd\msc_sd.ino:62:26: note: suggested alternative: '_glue' uint32_t block_count = volume.blocksPerCluster()volume.clusterCount(); ^~ _glue C:\arduino-1.8.19-esp32c\arduino-1.8.19\portable\sketchbook\libraries\Adafruit_TinyUSB_Library\examples\MassStorage\msc_sd\msc_sd.ino: In function 'int32_t msc_read_cb(uint32_t, void, uint32_t)': msc_sd:85:10: error: 'card' was not declared in this scope return card.readBlock(lba, (uint8_t) buffer) ? 512 : -1; ^~~~ C:\arduino-1.8.19-esp32c\arduino-1.8.19\portable\sketchbook\libraries\Adafruit_TinyUSB_Library\examples\MassStorage\msc_sd\msc_sd.ino:85:10: note: suggested alternative: 'word' return card.readBlock(lba, (uint8_t) buffer) ? 512 : -1; ^~~~ word C:\arduino-1.8.19-esp32c\arduino-1.8.19\portable\sketchbook\libraries\Adafruit_TinyUSB_Library\examples\MassStorage\msc_sd\msc_sd.ino: In function 'int32_t msc_write_cb(uint32_t, uint8_t, uint32_t)': msc_sd:94:10: error: 'card' was not declared in this scope return card.writeBlock(lba, buffer) ? 512 : -1; ^~~~ C:\arduino-1.8.19-esp32c\arduino-1.8.19\portable\sketchbook\libraries\Adafruit_TinyUSB_Library\examples\MassStorage\msc_sd\msc_sd.ino:94:10: note: suggested alternative: 'word' return card.writeBlock(lba, buffer) ? 512 : -1; ^~~~ word Multiple libraries were found for "SD.h" Used: C:\arduino-1.8.19-esp32c\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14\libraries\SD Not used: C:\arduino-1.8.19-esp32c\arduino-1.8.19\libraries\SD exit status 1 'Sd2Card' does not name a type

What happened ?

can't verify/compile

How to reproduce ?

  1. Verify

Debug Log

No response

Screenshots

No response

hathach commented 7 months ago

should be fixed by #388