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

Build for "micro" board fails #40

Closed
YarekTyshchenko opened this Issue Dec 24, 2014 · 27 comments

Comments

Projects
None yet
3 participants
@YarekTyshchenko

YarekTyshchenko commented Dec 24, 2014

Trying to build the blink example for Micro board, Arduino Micro (atmega32u4) fails to compile.
Its trying to include a header file for the pins from a folder that wouldn't exist there.
I tried to debug it a little myself, i've put in leonardo's pin definitions into the file that its looking for but it spat out some more errors: http://pastie.org/pastes/9797760/text?key=yntqzqdbbyytpepq2gdrxg

MacBook-Pro:Tubeclock yarek$ platformio run
Processing arduino_micro environment:
avr-gcc -o .pioenvs/arduino_micro/src/main.o -c -g -Os -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO_ARCH_AVR -DARDUINO=158 -DARDUINO_AVR_MICRO -DUSB_VID=0x2341 -DUSB_PID=0x8037 "-DUSB_PRODUCT=Arduino Micro" -I.pioenvs/arduino_micro/FrameworkArduino -I.pioenvs/arduino_micro/FrameworkArduinoVariant .pioenvs/arduino_micro/src/main.c
In file included from .pioenvs/arduino_micro/FrameworkArduino/Arduino.h:247:0,
                 from .pioenvs/arduino_micro/src/main.c:1:
.pioenvs/arduino_micro/FrameworkArduinoVariant/pins_arduino.h:25:38: fatal error: ../leonardo/pins_arduino.h: No such file or directory
 #include "../leonardo/pins_arduino.h"
                                      ^
compilation terminated.
scons: *** [.pioenvs/arduino_micro/src/main.o] Error 1

@ivankravets ivankravets added the bug label Dec 24, 2014

@ivankravets ivankravets added this to the 0.10.0 milestone Dec 24, 2014

@ivankravets ivankravets self-assigned this Dec 24, 2014

@ivankravets

This comment has been minimized.

Member

ivankravets commented Dec 24, 2014

but it spat out some more errors

Can you look to the issue #35 and read my comment #35 (comment)

@ivankravets

This comment has been minimized.

Member

ivankravets commented Dec 24, 2014

Rename your main.c to main.cpp or to main.ino.

@YarekTyshchenko

This comment has been minimized.

YarekTyshchenko commented Dec 24, 2014

Tried both, same error, its looking for "../leonardo/pins_arduino.h" which isn't anywhere in .pioenvs

@ivankravets

This comment has been minimized.

Member

ivankravets commented Dec 24, 2014

Give me your platformio.ini. Thanks.

@ivankravets

This comment has been minimized.

Member

ivankravets commented Dec 24, 2014

Opssss.... Sorry. I see it. Give me a few minutes, I will re-upload new Arduino-Framework package.

@YarekTyshchenko

This comment has been minimized.

YarekTyshchenko commented Dec 24, 2014

I should say that it compiles perfectly well if I switch the board to uno.

[env:arduino_micro]
platform = atmelavr
framework = arduino
board = micro
upload_port = /dev/tty.usbmodem621

using main.* from the platformio blink example

@ivankravets

This comment has been minimized.

Member

ivankravets commented Dec 24, 2014

It's problem with "relative includes" in the Arduino source code. I've just added to my TODO and will fix it directly in PlatformIO builder later. As for now, I'm going to make a temporary fix for it. I will report here.

@ivankravets

This comment has been minimized.

Member

ivankravets commented Dec 24, 2014

Please update your packages:

$ platformio update

It should work now.

@YarekTyshchenko

This comment has been minimized.

YarekTyshchenko commented Dec 24, 2014

Almost

MacBook-Pro:Tubeclock yarek$ platformio run
Processing arduino_micro environment:
avr-g++ -o .pioenvs/arduino_micro/FrameworkArduino/USBCore.o -c -fno-exceptions -g -Os -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO_ARCH_AVR -DARDUINO=158 -DARDUINO_AVR_MICRO -DUSB_VID=0x2341 -DUSB_PID=0x8037 "-DUSB_PRODUCT=Arduino Micro" -I.pioenvs/arduino_micro/FrameworkArduino -I.pioenvs/arduino_micro/FrameworkArduinoVariant .pioenvs/arduino_micro/FrameworkArduino/USBCore.cpp
<command-line>:0:13: error: 'Arduino' was not declared in this scope
.pioenvs/arduino_micro/FrameworkArduino/USBCore.cpp:55:37: note: in expansion of macro 'USB_PRODUCT'
 const u8 STRING_PRODUCT[] PROGMEM = USB_PRODUCT;
                                     ^
.pioenvs/arduino_micro/FrameworkArduino/USBCore.cpp: In function 'bool SendDescriptor(Setup&)':
<command-line>:0:13: error: 'Arduino' was not declared in this scope
.pioenvs/arduino_micro/FrameworkArduino/USBCore.cpp:508:59: note: in expansion of macro 'USB_PRODUCT'
    return USB_SendStringDescriptor(STRING_PRODUCT, strlen(USB_PRODUCT));
                                                           ^
scons: *** [.pioenvs/arduino_micro/FrameworkArduino/USBCore.o] Error 1

Commenting out the ifndef bit turns it into this: http://pastie.org/pastes/9797825/text?key=mixsg5pawcxhobjpint5sw

Is it wrong to have lines starting with a hash? Maybe the preprocessor gets confused

@ivankravets

This comment has been minimized.

Member

ivankravets commented Dec 24, 2014

Please share here your main.cpp I will try it tomorrow 😴
😄

@YarekTyshchenko

This comment has been minimized.

YarekTyshchenko commented Dec 24, 2014

#include <Arduino.h>
#ifndef LED_PIN
// Most Arduino boards already have a LED attached to pin 13 on the board itself
#define LED_PIN 13
#endif

void setup() {
  pinMode(LED_PIN, OUTPUT);     // set pin as output
}

void loop() {
  digitalWrite(LED_PIN, HIGH);  // set the LED on
  delay(1000);                  // wait for a second
  digitalWrite(LED_PIN, LOW);   // set the LED off
  delay(1000);                  // wait for a second
}

Thanks for looking into all my complains today, Merry christmas

@ivankravets

This comment has been minimized.

Member

ivankravets commented Dec 24, 2014

Marry Christmas to you too 🎄🎁⛄️

@ivankravets ivankravets added the board label Dec 25, 2014

ivankravets added a commit that referenced this issue Dec 26, 2014

@ivankravets

This comment has been minimized.

Member

ivankravets commented Dec 26, 2014

@yarekt Thanks a lot for this report. I fixed critical bug for Arduino USB boards. I'm going to release hot-fix 0.9.3 tomorrow. Please re-test the latest development branch:

$ pip uninstall platformio
$ pip install https://github.com/ivankravets/platformio/archive/develop.zip
@YarekTyshchenko

This comment has been minimized.

YarekTyshchenko commented Dec 26, 2014

Thanks, that looks like it fixes that, however, I can't seem to upload properly. It might be the avrdude options are wrong for the micro. Avrdude has a nasty habit of locking up my USB port. I'll try to dig up the options that worked for me before

@ivankravets

This comment has been minimized.

Member

ivankravets commented Dec 26, 2014

I see this issue. I know how to fix it. I will work on it tomorrow. Sorry, for the problems and delays :(

@ivankravets ivankravets reopened this Dec 26, 2014

@YarekTyshchenko

This comment has been minimized.

YarekTyshchenko commented Dec 26, 2014

No, no worries. I'm amazed how prolific you are at responding to all the issues. Thanks so much. (You should probably take some time off and enjoy the holidays)

@ivankravets

This comment has been minimized.

Member

ivankravets commented Dec 26, 2014

Thanks ☺️ I can't relax when PlatformIO has opened the issues with "bug" label 😄

If you are interested in this problem please look into https://github.com/arduino/Arduino/blob/master/app/src/processing/app/debug/AvrdudeUploader.java#L82

need to do a little dance for Leonardo and derivatives:

Need to implement a specific "reset" logic for Leonardo & similar Arduino USB devices.

@YarekTyshchenko

This comment has been minimized.

YarekTyshchenko commented Dec 27, 2014

I can see that you've already implemented the use_1200bps_touch flag in boards. I'm not very good at python but I found the way that arduino.cc recommend resetting the boards:

#!/usr/bin/python
# usage: reset_arduino <DEVICE>
# where <DEVICE> is typically some /dev/ttyfoobar
import sys
import serial
ser = serial.Serial()
ser.port=sys.argv[1]
ser.baudrate=1200
ser.open(); ser.close()

Works pretty well as an executable script

@ivankravets

This comment has been minimized.

Member

ivankravets commented Dec 27, 2014

Yes, I added additional information to boards which communicate within avr109 protocol and new boards command. Because your issue depends on issue 11 :)

Your hint isn't 100% solution and will not work in all cases.

I will implement normal device reset with waiting logic. Thins is a main requirement - "waiting" while board will enter in upload mode.

@YarekTyshchenko

This comment has been minimized.

YarekTyshchenko commented Dec 27, 2014

Ah thats true, however, avrdude seems to wait for the right port to be available anyway (for a timeout)

@ivankravets

This comment has been minimized.

Member

ivankravets commented Dec 27, 2014

I promise you that I will fix this issue tomorrow. Sorry for delay :(

@YarekTyshchenko

This comment has been minimized.

YarekTyshchenko commented Dec 27, 2014

Don't worry mate, theres no rush

@ivankravets

This comment has been minimized.

Member

ivankravets commented Dec 27, 2014

Can you contact me by email? Because I don't see your email. Thanks :)

@YarekTyshchenko

This comment has been minimized.

YarekTyshchenko commented Dec 27, 2014

It should be public somewhere yarekt@gmail.com

@ivankravets

This comment has been minimized.

Member

ivankravets commented Dec 28, 2014

Hey @yarekt ,

Can you try the latest dev version?

@YarekTyshchenko

This comment has been minimized.

YarekTyshchenko commented Dec 29, 2014

Works perfectly. Thanks

@hpsaturn

This comment has been minimized.

hpsaturn commented Dec 2, 2018

Hi,
I don't know but I have the same error when try to running on a old Microduino MCookie-Core module, it's a Microduino USB like a Leonardo.

I was running the next commands:
Select board:

pio boards microduino | grep Microduino | grep USB
32u416m               ATMEGA32U4     16MHz     28KB    2.50KB Microduino Core USB (ATmega32U4@16M,5V)

init project:

platformio init --board 32u416m

error:

pio run
Processing 32u416m (platform: atmelavr; board: 32u416m; framework: arduino)
---------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/32u416m.html
PLATFORM: Atmel AVR > Microduino Core USB (ATmega32U4@16M,5V)
HARDWARE: ATMEGA32U4 16MHz 2.50KB RAM (28KB Flash)
Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(soft)
Collected 24 compatible libraries
Scanning dependencies...
No dependencies
Compiling .pioenvs/32u416m/src/main.cpp.o
Compiling .pioenvs/32u416m/FrameworkArduino/CDC.cpp.o
Compiling .pioenvs/32u416m/FrameworkArduino/HardwareSerial.cpp.o
Compiling .pioenvs/32u416m/FrameworkArduino/HardwareSerial0.cpp.o
In file included from src/main.cpp:1:0:
/home/avp/.platformio/packages/framework-arduinoavr/cores/arduino/Arduino.h:257:26: fatal error: pins_arduino.h: No such file or directory

dmesg input:

Dec  2 12:29:34 zenbook kernel: [2042714.805178] usb 2-1: new full-speed USB device number 56 using xhci_hcd
Dec  2 12:29:34 zenbook kernel: [2042714.936045] usb 2-1: New USB device found, idVendor=2341, idProduct=8036
Dec  2 12:29:34 zenbook kernel: [2042714.936053] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
Dec  2 12:29:34 zenbook kernel: [2042714.936058] usb 2-1: Product: Arduino Leonardo
Dec  2 12:29:34 zenbook kernel: [2042714.936062] usb 2-1: Manufacturer: Arduino LLC
Dec  2 12:29:34 zenbook kernel: [2042714.936657] cdc_acm 2-1:1.0: ttyACM0: USB ACM device
Dec  2 12:29:34 zenbook kernel: [2042714.939580] input: Arduino LLC Arduino Leonardo as /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.2/0003:2341:8036.0003/input/input158
Dec  2 12:29:34 zenbook kernel: [2042714.940024] hid-generic 0003:2341:8036.0003: input,hidraw0: USB HID v1.01 Mouse [Arduino LLC Arduino Leonardo] on usb-0000:00:14.0-1/input
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment