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

Compiling difference between Arduino IDE and Platformio #506

Closed
ivankravets opened this issue Feb 10, 2016 · 17 comments
Closed

Compiling difference between Arduino IDE and Platformio #506

ivankravets opened this issue Feb 10, 2016 · 17 comments
Assignees
Labels
Milestone

Comments

@ivankravets
Copy link
Member

Moved from platformio/platformio-atom-ide#38

First, let me say thank you for this incredible Atom plugin!!! It majorly improves my dev time compared with the Arduino IDE!
I successfully compiled and uploaded a few programs for Arduino Due, but I ran into one bug.
The following program compiles, uploads and works with the Arduino IDE:

char myBuffer[5] = {' ', ' ', ' ', ' ', ' '};
void setup() {}

void loop() {
  SerialUSB.println(fillMyBuffer());
  delay(1000);
}

char* fillMyBuffer() {
  for (int i = 0; i < 5; i++) {
    myBuffer[i] = 'A';
  }
  return myBuffer;
}

Using Atom + Platformio, I get the following build error:
error: 'fillMyBuffer' was not declared in this scope

Here's what's on the build panel:

Executing: platformio run 
[02/10/16 12:25:42] Processing dueUSB (platform: atmelsam, board: dueUSB, framework: arduino)

[02/10/16 12:25:42] Processing dueUSB (platform: atmelsam, board: dueUSB, framework: arduino)

arm-none-eabi-g++ -o .pioenvs\dueUSB\src\tmp_ino_to.o -c -fno-rtti -fno-exceptions -g -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m3 -nostdlib -DF_CPU=84000000L -DUSBCON -DUSB_MANUFACTURER="PlatformIO" -Dprintf=iprintf -D__SAM3X8E__ -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM -DUSB_VID=0x2341 -DUSB_PID=0x003e "-DUSB_PRODUCT=\"Arduino Due\"" -DARDUINO=10606 -DPLATFORMIO=020804 -I.pioenvs\dueUSB\FrameworkArduino -I.pioenvs\dueUSB\FrameworkCMSISInc -I.pioenvs\dueUSB\FrameworkLibSam -I.pioenvs\dueUSB\FrameworkLibSam\include -I.pioenvs\dueUSB\FrameworkDeviceInc -I.pioenvs\dueUSB\FrameworkDeviceInc\3x8e\include -I.pioenvs\dueUSB\FrameworkArduinoVariant src\tmp_ino_to.cpp
arm-none-eabi-g++ -o .pioenvs\dueUSB\src\tmp_ino_to.o -c -fno-rtti -fno-exceptions -g -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m3 -nostdlib -DF_CPU=84000000L -DUSBCON -DUSB_MANUFACTURER="PlatformIO" -Dprintf=iprintf -D__SAM3X8E__ -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM -DUSB_VID=0x2341 -DUSB_PID=0x003e "-DUSB_PRODUCT=\"Arduino Due\"" -DARDUINO=10606 -DPLATFORMIO=020804 -I.pioenvs\dueUSB\FrameworkArduino -I.pioenvs\dueUSB\FrameworkCMSISInc -I.pioenvs\dueUSB\FrameworkLibSam -I.pioenvs\dueUSB\FrameworkLibSam\include -I.pioenvs\dueUSB\FrameworkDeviceInc -I.pioenvs\dueUSB\FrameworkDeviceInc\3x8e\include -I.pioenvs\dueUSB\FrameworkArduinoVariant src\tmp_ino_to.cpp
AtomTest.ino: In function 'void loop()':
AtomTest.ino:7:32: error: 'fillMyBuffer' was not declared in this scope
AtomTest.ino: In function 'void loop()':
AtomTest.ino:7:32: error: 'fillMyBuffer' was not declared in this scope
scons: *** [.pioenvs\dueUSB\src\tmp_ino_to.o] Error 1
 [ ERROR ] Took 2.92 seconds 
scons: *** [.pioenvs\dueUSB\src\tmp_ino_to.o] Error 1
 [ ERROR ] Took 2.88 seconds 

Thanks again!

@ivankravets ivankravets self-assigned this Feb 10, 2016
@ivankravets ivankravets added this to the 2.8.4 milestone Feb 10, 2016
@mbariola
Copy link

Hello, I seem to have the same problem on Windows 10 64-bit, just installed platformio IDE 1.2.1 core 3.2.1 with clang & python 2.7, all is updated.

What can I provide / how to troubleshoot? Compilation works perfectly fine on Arduino IDE.

Error: C:/Users/Massi/Dropbox/Arduino, RPi, Adafruit/test/m0_mudra_bleuart_v1.1/m0_mudra_bleuart_v1.1/m0_mudra_bleuart_v1.1.ino:168:51: error: 'isUSBOn' was not declared in this scope

Many thanks

@mbariola
Copy link

Moving methods loop() and setup() at the very end of the .ino file, after all accessory methods, seems to have resolved the issue. Still, a discrepancy between Arduino IDE and Platformio. I suspect it's some build flag re. forward reference but cannot find where to look for it ...

@ivankravets
Copy link
Member Author

@mbariola Could you provide INO file to reproduce this issue? It looks that INO to CPP converter doesn't work correctly in your case. Thanks.

@mbariola
Copy link

@ivankravets sure, is there a way to send it privately to you? it is a project I want to develop commercially and so I'd like to not attach it publicly here

@ivankravets
Copy link
Member Author

Of course, please send to me@ikravets.com. I'll not share it.

@mbariola
Copy link

Thanks @ivankravets , just sent.

@ivankravets
Copy link
Member Author

@mbariola Thanks a lot for provided demo project. Our INO to CPP is VERY STRICT. See

Please remove spaces/tabs before bool isUSBOn().

@ivankravets
Copy link
Member Author

@mbariola Please note that I deleted your email and all tracks related to your project.

@mbariola
Copy link

mbariola commented Dec 26, 2016

@ivankravets so it was a spurious space character? wow, I'd have never guessed (nor found) that. I removed it and all compiles. Thanks for your troubleshooting, confidentiality and quick answer. Now I know what to look for if it ever pops up again. cheers!

@ivankravets
Copy link
Member Author

@mbariola yes, we don't catch spaces before types of prototypes. It will break general regular expression.

A few recommendations to your project:

  1. Please remove lib_dir from [platformio] section in platformio.ini
  2. Use PlatformIO's Library Manager and lib_deps option

@mbariola
Copy link

ok, I can't say I comprehend the why of what you suggest me to do as I picked platformio just 3 days ago and had used arduino.cc's manager to not change too much in one go, but I'll clone the project to be sure and follow your instructions. it'll help me in familiarizing with the platform. thanks!

@mbariola
Copy link

OK, done, took just a few minutes and properly separating general libs such as the adafruit bluetooth one from the project specific ones such as BluefruitConfig.h. Thanks!

@ivankravets
Copy link
Member Author

Happy coding with PlatformIO! 😊

@ivankravets
Copy link
Member Author

@mbariola would be thankful for a star 🌟

@mbariola
Copy link

gladly, how would I do it? star your profile .. this issue .. the project ...?

@ivankravets
Copy link
Member Author

star ... the project

Yes, please use "🌟 Star" button above.

@mbariola
Copy link

Done! Cheers :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants