[SOLVED] Need Help/assistance with VS1003 library

External hardware connected to the STM32 board
Post Reply
teecham
Posts: 6
Joined: Sun Jan 21, 2018 1:31 pm

[SOLVED] Need Help/assistance with VS1003 library

Post by teecham » Sun Jan 21, 2018 3:30 pm

Hi all,
I am trying to make an mp3 player based on serasidis vs1003 library and then on to ili9341 and touch panel based mp3 player. Started off with rogerclark code posted here:
viewtopic.php?f=13&t=142&start=20

when I try to compile the following code (roger's code):

Code: Select all

#include <VS1003_STM.h>
#include <SPI.h>
#include <SD.h>

VS1003 player(PC14, PB10, PA8, PA9, SPIClass(2)); // cs_pin, dcs_pin, dreq_pin, reset_pin

/*
 * VS1003 development board connected by it's header pins the following way:
 *
 * GND  - GND  -
 * XDCS - D6   - PB10
 * DREQ - D7   - PA8
 * XRES - D8   - PA9
 * XCS  - D9   - PC14
 * SCLK - D13  - PA5
 * SI   - D11  - PA7
 * SO   - D12  - PA6
 * GND  - GND  -
 * 5V   - 5V   -
Use normal SPI
VS1003 player(PC14, PB10, PA8, PA9); // cs_pin, dcs_pin, dreq_pin, reset_pin, SPI channel - defaults to SPI

Use SPI 2 
VS1003 player(PC14, PB10, PA8, PA9,SPIClass(2)); // cs_pin, dcs_pin, dreq_pin, reset_pin, use SPI 2

If you have SPI 3
VS1003 player(PC14, PB10, PA8, PA9,SPIClass(3)); // cs_pin, dcs_pin, dreq_pin, reset_pin, use SPI 3
 http://www.stm32duino.com/viewtopic.php?f=13&t=142&start=20
 */

void setup ()
{
  Serial.begin(115200);

//  while (!Serial.available());/// Wait for key entry.. For debugging

  // see if the card is present and can be initialized:
  while (!SD.begin(PA4))
  {
    Serial.println("Card failed, or not present");// don't do anything more:
    delay(100);
  }
  Serial.println("card initialized.");

  player.begin();
  player.modeSwitch(); //Change mode from MIDI to MP3 decoding (Vassilis Serasidis).
  player.setVolume(64);
}

int currentFileNum = 0; // Hack because SD only allows one file handle open at a time :-(
void loop()
{
  playFile("music.mp3");// Lets just play the music ;-)
  
  delay(1000);
  return;
}

#define BUFF_LEN 128

void playFile(char *fileName)
{
  uint8_t buff[BUFF_LEN];
  File dataFile;
  int bytesRead;
  int fileSize;
  int totalBytesRead = 0;

  dataFile = SD.open(fileName);

  if (!dataFile)
  {
    Serial.println("Error opening file");
    return;
  }
  
  Serial.print("Playing "); Serial.println(fileName);
  fileSize = dataFile.size(); // need to know the size of the file

  // loop until end of file
  while (totalBytesRead != fileSize)
  {
    do
    {
      bytesRead = dataFile.read(buff, BUFF_LEN);// try to read a buffers worth
      if (bytesRead == -1) // Oops. SD didnt manage to read anything ....
      {
        delay(10);// Workaround for problem in SD lib.
      }
    } while (bytesRead == -1);// loop around if last read failed


    player.playChunk(buff, bytesRead);
    totalBytesRead += bytesRead;// keep track of how much of the file we've played
  }
  dataFile.close();
}
I keep getting following error:

Code: Select all

C:\Arduino 1.85\hardware\Arduino_STM32\STM32F1\libraries\Serasidis_VS1003B_STM\src\VS1003_STM.cpp: In function 'void DMA1_CH3_Event()':

C:\Arduino 1.85\hardware\Arduino_STM32\STM32F1\libraries\Serasidis_VS1003B_STM\src\VS1003_STM.cpp:112:3: error: 'dma1_ch3_Active' was not declared in this scope

   dma1_ch3_Active = 0;

   ^

Using library Serasidis_VS1003B_STM at version 1.0 in folder: C:\Arduino 1.85\hardware\Arduino_STM32\STM32F1\libraries\Serasidis_VS1003B_STM 
Using library SPI at version 1.0 in folder: C:\Arduino 1.85\hardware\Arduino_STM32\STM32F1\libraries\SPI 
Using library SD at version 1.1.1 in folder: C:\Arduino 1.85\libraries\SD 
exit status 1
Error compiling for board Maple Mini.

Would be nice if guys here could assist me in finding a workaround or fixing the error.

stevestrong
Posts: 2067
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany
Contact:

Re: Need Help/assistance with VS1003 library

Post by stevestrong » Sun Jan 21, 2018 9:06 pm

Try to comment out that line, it does not seem to have any functionality.

Btw, the SPI library evolved a lot since mid 2015.
Maybe you should send a PM to Vassilis, he implemented that library, he could give you support.

User avatar
mrburnette
Posts: 2226
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: Need Help/assistance with VS1003 library

Post by mrburnette » Mon Jan 22, 2018 2:42 am

The "fix" is temporary but does seem to give a clean compile.

- Edit file VS1003_STM.cpp which is located in this path on my Linux System:

Code: Select all

/home/ray/Arduino/hardware/STM32/STM32F1/libraries/Serasidis_VS1003B_STM/src/
Around line 110 edit and comment that section to make it look similar to:

Code: Select all

/* 
mrb 20180121 test
	//

	inline void DMA1_CH3_Event() {
	  dma1_ch3_Active = 0;
	  dma_disable(DMA1, DMA_CH3);
	}
*/
//****************************************************************************/
Save. Compile.
Linking everything together...
"/home/ray/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++" -Og -Wl,--gc-sections -mcpu=cortex-m3 "-T/home/ray/Arduino/hardware/STM32/STM32F1/variants/maple_mini/ld/bootloader_20.ld" "-Wl,-Map,/tmp/arduino_build_184764/hello_STM.ino.map" "-L/home/ray/Arduino/hardware/STM32/STM32F1/variants/maple_mini/ld" -o "/tmp/arduino_build_184764/hello_STM.ino.elf" "-L/tmp/arduino_build_184764" -lm -lgcc -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols -Wl,--start-group "/tmp/arduino_build_184764/sketch/hello_STM.ino.cpp.o" "/tmp/arduino_build_184764/libraries/Serasidis_VS1003B_STM/VS1003_STM.cpp.o" "/tmp/arduino_build_184764/libraries/SPI/SPI.cpp.o" "/tmp/arduino_build_184764/core/wirish/start.S.o" "/tmp/arduino_build_184764/core/wirish/start_c.c.o" "/tmp/arduino_build_184764/core/wirish/syscalls.c.o" "/tmp/arduino_build_184764/core/board.cpp.o" "/tmp/arduino_build_184764/core/wirish/boards.cpp.o" "/tmp/arduino_build_184764/core/wirish/boards_setup.cpp.o" "/tmp/arduino_build_184764/core/core.a" -Wl,--end-group
"/home/ray/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-objcopy" -O binary "/tmp/arduino_build_184764/hello_STM.ino.elf" "/tmp/arduino_build_184764/hello_STM.ino.bin"
Using library Serasidis_VS1003B_STM at version 1.0 in folder: /home/ray/Arduino/hardware/STM32/STM32F1/libraries/Serasidis_VS1003B_STM
Using library SPI at version 1.0 in folder: /home/ray/Arduino/hardware/STM32/STM32F1/libraries/SPI
Sketch uses 18704 bytes (15%) of program storage space. Maximum is 122880 bytes.
Global variables use 3160 bytes (15%) of dynamic memory, leaving 17320 bytes for local variables. Maximum is 20480 bytes.

teecham
Posts: 6
Joined: Sun Jan 21, 2018 1:31 pm

Re: Need Help/assistance with VS1003 library

Post by teecham » Mon Jan 22, 2018 3:20 am

Steve , Ray,

Thank you both I commented out the lines in question the code is compiling now, will try and test it on the hardware.
BTW: I did seem to remember reading it somewhere that DMA is required for SD lib, what relation it has with this one it needs to be looked into. Although I couldn't find use of these particular lines elsewhere in the code.

Will send PM to the author of the lib let see his input on this.

teecham
Posts: 6
Joined: Sun Jan 21, 2018 1:31 pm

Re: Need Help/assistance with VS1003 library

Post by teecham » Mon Jan 22, 2018 2:48 pm

Hmm very strange:

Ray your code compiling verbose output says:

Code: Select all

Sketch uses 18704 bytes (15%) of program storage space. Maximum is 122880 bytes.
Global variables use 3160 bytes (15%) of dynamic memory, leaving 17320 bytes for local variables. Maximum is 20480 bytes.
and mine says:

Code: Select all

Linking everything together...
Using library Serasidis_VS1003B_STM at version 1.0 in folder: C:\Arduino 1.85\hardware\Arduino_STM32\STM32F1\libraries\Serasidis_VS1003B_STM 
Using library SPI at version 1.0 in folder: C:\Arduino 1.85\hardware\Arduino_STM32\STM32F1\libraries\SPI 
Using library SD at version 1.1.1 in folder: C:\Arduino 1.85\libraries\SD 
Sketch uses 24444 bytes (22%) of program storage space. Maximum is 110592 bytes.
Global variables use 4856 bytes (27%) of dynamic memory, leaving 12552 bytes for local variables. Maximum is 17408 bytes.
in Rays case sketch uses 18704 bytes and in my case it uses 24444 bytes? :?: :?: :?:

stevestrong
Posts: 2067
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany
Contact:

Re: Need Help/assistance with VS1003 library

Post by stevestrong » Mon Jan 22, 2018 2:53 pm

Ray's build does not have the SD part.

teecham
Posts: 6
Joined: Sun Jan 21, 2018 1:31 pm

Re: Need Help/assistance with VS1003 library

Post by teecham » Wed Jan 24, 2018 8:40 am

Steve thanks.
noted later that while "ray" was using the "Hello" sketch and I was using "roger's sketch"

stevestrong
Posts: 2067
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany
Contact:

Re: Need Help/assistance with VS1003 library

Post by stevestrong » Wed Jan 24, 2018 3:38 pm

Please mark the thread as solved if it is working now (insert [SOLVED] before your current title by editing the very first post).

Post Reply