Daisy Seed Arduino development in VSCode?

Hi!
Coming from Arduino, and just bought my first Daisy Seed. Im used to Arduino and the IDE. However, I would like to use VS Code instead, but maybe not ready to do the full transition to C++. I would like to continue code Arduino style, but not in Arduino IDE. I’ve seen examples of ppl using VSCode + PlatformIO to program the Daisy Seed. But whatever I try, I can’t get it to work. The guides/howtos/videos are quite limited in detail, so my question is this:

Are there any good/simple instructions on how to get VS Code to work with Daisy Seed and the Arduino framework?

Thanks!

Hello Olle!

Ok, I didn’t have PlatformIO setup BUT I’ll set it up and get it working with DaisyDuino right now.

Please note that I juuuuust did this so there might be some unnessary steps and such, but I was able to get it working. I’ll do a more detailed tutorial on this in the future. Thank you for bringing it up!
If anyone with more experience using PlatformIO+DaisyDuino, please feel free to provide feedback. Thanks so much!

I do think it flashes faster than the Arduino IDE :slight_smile:

Ok, let’s get this working!


First, open up VS Code and install “PlatformIO IDE” in the “Extensions”.

After restarting VS Code, click on the ant/alien icon on the left.

“Create New Project” and click on “+ Project” and call it “DaisyBlink” or etc and arbitrary select “ST STM32“F0308DISCOVERY”. And then select “Arduino” as Framework. Click “Finish”.

I don’t know if you have to install STM32Cube but I recommend doing it just in case. I had it installed already.

After creating a new project, VS Code should automatically open up platform.ini. Please replace what’s already there with the following:

[env:electrosmith_daisy]
platform = ststm32
board = electrosmith_daisy
framework = arduino
; ----------
; Everything(?) below this needs to be added to use DaisyDuino in PlatformIO.
; Setting up a new project or importing from Arduino does not add any of this.
; ----------
lib_deps = 
    electro-smith/DaisyDuino@^1.5.2
    Wire 

build_flags = 
    ; -w                            ; optional - to suppress redundant definition warnings
    -D HAL_SDRAM_MODULE_ENABLED     ; required? build fails without this one
    ; These flags enable serial monitor over USB UART
    -D USBD_USE_CDC                 ; Define USB Communications Device Class (for serial I/O)
    -D USBCON                       ; Enable USB connection in Arduino (?)
; This is not documented on PlatformIO website but
; enables the DFU firmware upload (over USB)
upload_protocol = dfu

Thank you Nick (@infrasonicaudio) for this!! I referenced this post.

Open main.cpp in “src”, and copy and paste:

#include <Arduino.h>

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(1000);                      // wait for a second
  digitalWrite(LED_BUILTIN, LOW);   // turn the LED off by making the voltage LOW
  delay(1000);                      // wait for a second
}

Click on the checkmark icon on the top right and click “build”. Put Daisy into bootloader mode. And then click “Upload”. And the onboard LED should blink!!

Don’t worry about these “errors”.

dfu-util: Error during download get_status
*** [upload] Error 74

Let’s test audio…
Choose audio example of your choice. Since I have a Pod, I chose the oscillator example:

#include <Arduino.h>

// Title: oscillator
// Description: Control a sine wave freq with a knob
// Hardware: Daisy Seed
// Author: Ben Sergentanis
// Breadboard
// https://raw.githubusercontent.com/electro-smith/DaisyExamples/master/seed/Osc/resources/Osc_bb.png
// Schematic:
// https://raw.githubusercontent.com/electro-smith/DaisyExamples/master/seed/Osc/resources/Osc_schem.png

#include "DaisyDuino.h"

DaisyHardware hw;

size_t num_channels;

static Oscillator osc;

float pitchknob;

void MyCallback(float **in, float **out, size_t size) {
  // Convert Pitchknob MIDI Note Number to frequency
  osc.SetFreq(mtof(pitchknob));
  for (size_t i = 0; i < size; i++) {
    float sig = osc.Process();

    for (size_t chn = 0; chn < num_channels; chn++) {
      out[chn][i] = sig;
    }
  }
}

void setup() {
  float sample_rate;
  // Initialize for Daisy pod at 48kHz
  hw = DAISY.init(DAISY_SEED, AUDIO_SR_48K);
  num_channels = hw.num_channels;
  sample_rate = DAISY.get_samplerate();

  osc.Init(sample_rate);
  osc.SetFreq(440);
  osc.SetAmp(0.5);
  osc.SetWaveform(osc.WAVE_TRI);

  DAISY.begin(MyCallback);
}

void loop() { pitchknob = 24.0 + ((analogRead(A0) / 1023.0) * 60.0); }

“Build” and then “Upload” and it’s beeping!!

Let me know if you have any questions!!

1 Like

Sorry to bring back such an old thread, but I’m having trouble with this process. I followed the instructions listed above, but when I run the build task I get an error about a missing header file: fatal error: variant_DAISY_SEED.h: No such file or directory (the full error is below, error 1)

I turned on verbose compilation in the arduino IDE and I can see that it seems to be passing -I to include the directory -I/Users/Eli/Library/Arduino15/packages/STMicroelectronics/hardware/stm32/2.8.1/variants/STM32H7xx/H742I(G-I)K_H743I(G-I)K_H750IBK_H753IIK .

I tried adding a -I flag to include the same directory in my platformio.ini’s build_flags section, but it seems to be mad about the parenthesis. (see error2 below) I’ve tried using \ and " to escape the parenthesis, but no luck. Any suggestions? Is there a step I’ve missed?

Thanks!
Eli

error 1:

*  Executing task: platformio run --environment electrosmith_daisy 

Processing electrosmith_daisy (platform: ststm32; board: electrosmith_daisy; framework: arduino)
----------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/electrosmith_daisy.html
PLATFORM: ST STM32 (17.6.0) > Electrosmith Daisy
HARDWARE: STM32H750IBK6 400MHz, 512KB RAM, 128KB Flash
DEBUG: Current (blackmagic) External (blackmagic, cmsis-dap, jlink, stlink)
PACKAGES: 
 - framework-arduinoststm32 @ 4.20801.240815 (2.8.1) 
 - framework-cmsis @ 2.50900.0 (5.9.0) 
 - tool-dfuutil @ 1.11.0 
 - toolchain-gccarmnoneeabi @ 1.120301.0 (12.3.1)
Warning! Cannot find linker script for the current target!

LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 15 compatible libraries
Scanning dependencies...
Dependency Graph
|-- DaisyDuino @ 1.6.0
|-- Wire @ 1.0.0
Building in release mode
Compiling .pio/build/electrosmith_daisy/USBDevice/src/USBSerial.cpp.o
Compiling .pio/build/electrosmith_daisy/USBDevice/src/cdc/cdc_queue.c.o
Compiling .pio/build/electrosmith_daisy/USBDevice/src/cdc/usbd_cdc.c.o
Compiling .pio/build/electrosmith_daisy/USBDevice/src/cdc/usbd_cdc_if.c.o
Compiling .pio/build/electrosmith_daisy/USBDevice/src/usb_device_core.c.o
Compiling .pio/build/electrosmith_daisy/USBDevice/src/usb_device_ctlreq.c.o
Compiling .pio/build/electrosmith_daisy/USBDevice/src/usb_device_ioreq.c.o
<command-line>: fatal error: variant_DAISY_SEED.h: No such file or directory

error2:

Processing electrosmith_daisy (platform: ststm32; board: electrosmith_daisy; framework: arduino)
----------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/electrosmith_daisy.html
PLATFORM: ST STM32 (17.6.0) > Electrosmith Daisy
HARDWARE: STM32H750IBK6 400MHz, 512KB RAM, 128KB Flash
DEBUG: Current (blackmagic) External (blackmagic, cmsis-dap, jlink, stlink)
PACKAGES: 
 - framework-arduinoststm32 @ 4.20801.240815 (2.8.1) 
 - framework-cmsis @ 2.50900.0 (5.9.0) 
 - tool-dfuutil @ 1.11.0 
 - toolchain-gccarmnoneeabi @ 1.120301.0 (12.3.1)
Warning! Cannot find linker script for the current target!

LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 15 compatible libraries
Scanning dependencies...
Dependency Graph
|-- DaisyDuino @ 1.6.0
|-- Wire @ 1.0.0
Building in release mode
Compiling .pio/build/electrosmith_daisy/USBDevice/src/USBSerial.cpp.o
sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `arm-none-eabi-g++ -o ".pio/build/electrosmith_daisy/USBDevice/src/USBSerial.cpp.o" -c -std=gnu++17 -fno-threadsafe-statics -fno-rtti -fno-exceptions -fno-use-cxa-atexit -mcpu=cortex-m7 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -Os -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -DPLATFORMIO=60116 -DSTM32H7 -DSTM32H7xx -DSTM32H750xx -DHAL_SDRAM_MODULE_ENABLED -DUSBD_USE_CDC -DUSBCON -DSTM32H750xx -DSTM32H7xx -DARDUINO=10808 -DARDUINO_ARCH_STM32 -DNDEBUG -DARDUINO_DAISY_SEED -DBOARD_NAME=\"DAISY_SEED\" -DHAL_UART_MODULE_ENABLED -DUSE_HAL_DRIVER -DUSE_FULL_LL_DRIVER -DVARIANT_H=\"variant_DAISY_SEED.h\" -DCUSTOM_PERIPHERAL_PINS -DVECT_TAB_OFFSET=0x0 -DHAL_PCD_MODULE_ENABLED -I/Users/Eli/Library/Arduino15/packages/STMicroelectronics/hardware/stm32/2.8.1/variants/STM32H7xx/H742I(G-I)K_H743I(G-I)K_H750IBK_H753IIK -I/Users/Eli/.platformio/packages/framework-arduinoststm32/cores/arduino/avr -I/Users/Eli/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32 -I/Users/Eli/.platformio/packages/framework-arduinoststm32/libraries/SrcWrapper/inc -I/Users/Eli/.platformio/packages/framework-arduinoststm32/libraries/SrcWrapper/inc/LL -I/Users/Eli/.platformio/packages/framework-arduinoststm32/libraries/USBDevice/inc -I/Users/Eli/.platformio/packages/framework-arduinoststm32/libraries/VirtIO/inc -I/Users/Eli/.platformio/packages/framework-arduinoststm32/system/Drivers/STM32H7xx_HAL_Driver/Inc -I/Users/Eli/.platformio/packages/framework-arduinoststm32/system/Drivers/STM32H7xx_HAL_Driver/Src -I/Users/Eli/.platformio/packages/framework-arduinoststm32/system/STM32H7xx -I/Users/Eli/.platformio/packages/framework-arduinoststm32/system/Middlewares/ST/STM32_USB_Device_Library/Core/Inc -I/Users/Eli/.platformio/packages/framework-arduinoststm32/system/Middlewares/ST/STM32_USB_Device_Library/Core/Src -I/Users/Eli/.platformio/packages/framework-arduinoststm32/system/Middlewares/OpenAMP -I/Users/Eli/.platformio/packages/framework-arduinoststm32/system/Middlewares/OpenAMP/open-amp/lib/include -I/Users/Eli/.platformio/packages/framework-arduinoststm32/system/Middlewares/OpenAMP/libmetal/lib/include -I/Users/Eli/.platformio/packages/framework-arduinoststm32/system/Middlewares/OpenAMP/virtual_driver -I/Users/Eli/.platformio/packages/framework-cmsis/CMSIS/Core/Include -I/Users/Eli/.platformio/packages/framework-arduinoststm32/system/Drivers/CMSIS/Device/ST/STM32H7xx/Include -I/Users/Eli/.platformio/packages/framework-arduinoststm32/system/Drivers/CMSIS/Device/ST/STM32H7xx/Source/Templates/gcc -I/Users/Eli/.platformio/packages/framework-cmsis/CMSIS/DSP/Include -I/Users/Eli/.platformio/packages/framework-cmsis/CMSIS/DSP/PrivateInclude -I/Users/Eli/.platformio/packages/framework-arduinoststm32/cores/arduino -I/Users/Eli/.platformio/packages/framework-arduinoststm32/variants/STM32H7xx/H742I\(G-I\)\(K-T\)_H743I\(G-I\)\(K-T\)_H750IB\(K-T\)_H753II\(K-T\) "/Users/Eli/.platformio/packages/framework-arduinoststm32/libraries/USBDevice/src/USBSerial.cpp"'
Compiling .pio/build/electrosmith_daisy/USBDevice/src/cdc/cdc_queue.c.o
*** [.pio/build/electrosmith_daisy/USBDevice/src/USBSerial.cpp.o] Error 2
sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `arm-none-eabi-gcc -o ".pio/build/electrosmith_daisy/USBDevice/src/cdc/cdc_queue.c.o" -c -std=gnu17 -mcpu=cortex-m7 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -Os -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -DPLATFORMIO=60116 -DSTM32H7 -DSTM32H7xx -DSTM32H750xx -DHAL_SDRAM_MODULE_ENABLED -DUSBD_USE_CDC -DUSBCON -DSTM32H750xx -DSTM32H7xx -DARDUINO=10808 -DARDUINO_ARCH_STM32 -DNDEBUG -DARDUINO_DAISY_SEED -DBOARD_NAME=\"DAISY_SEED\" -DHAL_UART_MODULE_ENABLED -DUSE_HAL_DRIVER -DUSE_FULL_LL_DRIVER -DVARIANT_H=\"variant_DAISY_SEED.h\" -DCUSTOM_PERIPHERAL_PINS -DVECT_TAB_OFFSET=0x0 -DHAL_PCD_MODULE_ENABLED -I/Users/Eli/Library/Arduino15/packages/STMicroelectronics/hardware/stm32/2.8.1/variants/STM32H7xx/H742I(G-I)K_H743I(G-I)K_H750IBK_H753IIK -I/Users/Eli/.platformio/packages/framework-arduinoststm32/cores/arduino/avr -I/Users/Eli/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32 -I/Users/Eli/.platformio/packages/framework-arduinoststm32/libraries/SrcWrapper/inc -I/Users/Eli/.platformio/packages/framework-arduinoststm32/libraries/SrcWrapper/inc/LL -I/Users/Eli/.platformio/packages/framework-arduinoststm32/libraries/USBDevice/inc -I/Users/Eli/.platformio/packages/framework-arduinoststm32/libraries/VirtIO/inc -I/Users/Eli/.platformio/packages/framework-arduinoststm32/system/Drivers/STM32H7xx_HAL_Driver/Inc -I/Users/Eli/.platformio/packages/framework-arduinoststm32/system/Drivers/STM32H7xx_HAL_Driver/Src -I/Users/Eli/.platformio/packages/framework-arduinoststm32/system/STM32H7xx -I/Users/Eli/.platformio/packages/framework-arduinoststm32/system/Middlewares/ST/STM32_USB_Device_Library/Core/Inc -I/Users/Eli/.platformio/packages/framework-arduinoststm32/system/Middlewares/ST/STM32_USB_Device_Library/Core/Src -I/Users/Eli/.platformio/packages/framework-arduinoststm32/system/Middlewares/OpenAMP -I/Users/Eli/.platformio/packages/framework-arduinoststm32/system/Middlewares/OpenAMP/open-amp/lib/include -I/Users/Eli/.platformio/packages/framework-arduinoststm32/system/Middlewares/OpenAMP/libmetal/lib/include -I/Users/Eli/.platformio/packages/framework-arduinoststm32/system/Middlewares/OpenAMP/virtual_driver -I/Users/Eli/.platformio/packages/framework-cmsis/CMSIS/Core/Include -I/Users/Eli/.platformio/packages/framework-arduinoststm32/system/Drivers/CMSIS/Device/ST/STM32H7xx/Include -I/Users/Eli/.platformio/packages/framework-arduinoststm32/system/Drivers/CMSIS/Device/ST/STM32H7xx/Source/Templates/gcc -I/Users/Eli/.platformio/packages/framework-cmsis/CMSIS/DSP/Include -I/Users/Eli/.platformio/packages/framework-cmsis/CMSIS/DSP/PrivateInclude -I/Users/Eli/.platformio/packages/framework-arduinoststm32/cores/arduino -I/Users/Eli/.platformio/packages/framework-arduinoststm32/variants/STM32H7xx/H742I\(G-I\)\(K-T\)_H743I\(G-I\)\(K-T\)_H750IB\(K-T\)_H753II\(K-T\) "/Users/Eli/.platformio/packages/framework-arduinoststm32/libraries/USBDevice/src/cdc/cdc_queue.c"'
*** [.pio/build/electrosmith_daisy/USBDevice/src/cdc/cdc_queue.c.o] Error 2
=============================================================== [FAILED] Took 1.19 seconds ===============================================================

Hey :slight_smile:

I am running into the same issue, did anyone figure this?


Verbose mode can be enabled via -v, --verbose option
CONFIGURATION: Redirecting...
PLATFORM: ST STM32 (17.5.0+sha.17152f5) > Electrosmith Daisy
HARDWARE: STM32H750IBK6 400MHz, 512KB RAM, 7.75MB Flash
DEBUG: Current (blackmagic) External (blackmagic, cmsis-dap, jlink, stlink)
PACKAGES:

  • framework-arduinoststm32 @ 4.20801.240815 (2.8.1)
  • framework-cmsis @ 2.50900.0 (5.9.0)
  • tool-dfuutil @ 1.11.0
  • toolchain-gccarmnoneeabi @ 1.120301.0 (12.3.1)
    LDF: Library Dependency Finder → Library Dependency Finder (LDF) — PlatformIO latest documentation
    LDF Modes: Finder ~ chain, Compatibility ~ soft
    Found 16 compatible libraries
    Scanning dependencies…
    Dependency Graph
    |-- U8g2 @ 2.36.2
    |-- DaisyDuino @ 1.7.0+sha.88d6e69
    Building in release mode
    Compiling .pio/build/midi/SrcWrapper/src/HAL/stm32yyxx_hal.c.o
    Compiling .pio/build/midi/SrcWrapper/src/HAL/stm32yyxx_hal_adc.c.o
    Compiling .pio/build/midi/SrcWrapper/src/HAL/stm32yyxx_hal_adc_ex.c.o
    : fatal error: variant_DAISY_SEED.h: No such file or directory

  • Looking for variant_DAISY_SEED.h dependency? Check our library registry!
  • CLI > platformio lib search “header:variant_DAISY_SEED.h”
  • Web > PlatformIO Registry

compilation terminated.
Compiling .pio/build/midi/SrcWrapper/src/HAL/stm32yyxx_hal_can.c.o
*** [.pio/build/midi/SrcWrapper/src/HAL/stm32yyxx_hal.c.o] Error 1
: fatal error: variant_DAISY_SEED.h: No such file or directory

thanks,

Andrew

I wonder if there might be a bug in platformio’s daisy board definition file? it says

"variant": "STM32H7xx/H742I(G-I)(K-T)_H743I(G-I)(K-T)_H750IB(K-T)_H753II(K-T)"

but on my machine, the variant_DAISY_SEED.h file is in STM32H7xx/H742I(G-I)K_H743I(G-I)K_H750IBK_H753IIK , NOT STM32H7xx/H742I(G-I)(K-T)_H743I(G-I)(K-T)_H750IB(K-T)_H753II(K-T).

I changdc the electrosmith_daisy.json file on my local machine be STM32H7xx/H742I(G-I)K_H743I(G-I)K_H750IBK_H753IIK. It compiles, but I haven’t tested it yet.

Hi @eli1

Thanks so much for the response. A friend was able to get it going by Pinning the version STM32 version, it seems their update had broken this.

platform = ststm32@17.4.0

It is now building properly :smiley:

Cheers,

Andrew

I submitted a PR to platform io with the change to electrosmith_daisy.json and they accepted it. I hope that’s right. :person_shrugging: So, you’ll probably be able to un-pin it when the new version comes out, if you want.