Page 1 of 1

Problems in compiling. Compile for ATMEGA328P (Arduino)

Posted: Mon Mar 23, 2015 2:59 am
by dmdeangelo
Hi guys.
I'm a few days trying to compile examples of ChibiOS to ATMEGA328P (Arduino) and I can not.

I searched this forum, searched the web, searched the documentation, but all I got was getting more confused.

Does anyone know why these errors?

------------------------------------
Compiling chMutex...

Creating C:\Users\diego\Documents\Arduino_Build\chMutex\chMutex.ino.cpp.o...

"C:\Program Files (x86)\Arduino/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=155 -DARDUINO_AVR_UNO -DARDUINO_ARCH_ "-IC:\Users\diego\Documents\Arduino_Build\chMutex" "-IC:\Users\diego\Documents\Arduino\libraries\ChibiOSArduinoMaster\libraries\ChibiOS_AVR\examples\chMutex" "-IC:\Program Files (x86)\Arduino\hardware\tools\avr\avr\include" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\avr-libc" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "C:\Users\diego\Documents\Arduino_Build\chMutex\chMutex.ino.cpp" -o "C:\Users\diego\Documents\Arduino_Build\chMutex\chMutex.ino.cpp.o"

C:\Users\diego\Documents\Arduino_Build\chMutex\chMutex.ino.cpp:8: error: expected constructor, destructor, or type conversion before '(' token
C:\Users\diego\Documents\Arduino_Build\chMutex\chMutex.ino.cpp:11: error: ISO C++ forbids declaration of 'WORKING_AREA' with no type
C:\Users\diego\Documents\Arduino_Build\chMutex\chMutex.ino.cpp:11: error: 'waTh2' was not declared in this scope
C:\Users\diego\Documents\Arduino_Build\chMutex\chMutex.ino.cpp:11: error: initializer expression list treated as compound expression
C:\Users\diego\Documents\Arduino_Build\chMutex\chMutex.ino.cpp:14: error: ISO C++ forbids declaration of 'WORKING_AREA' with no type
C:\Users\diego\Documents\Arduino_Build\chMutex\chMutex.ino.cpp:14: error: redefinition of 'int WORKING_AREA'
C:\Users\diego\Documents\Arduino_Build\chMutex\chMutex.ino.cpp:11: error: 'int WORKING_AREA' previously defined here
C:\Users\diego\Documents\Arduino_Build\chMutex\chMutex.ino.cpp:14: error: 'waTh3' was not declared in this scope
C:\Users\diego\Documents\Arduino_Build\chMutex\chMutex.ino.cpp:18: error: 'msg_t' does not name a type
C:\Users\diego\Documents\Arduino_Build\chMutex\chMutex.ino.cpp: In function 'void notify(const char*, int)':
C:\Users\diego\Documents\Arduino_Build\chMutex\chMutex.ino.cpp:24: error: 'demoMutex' was not declared in this scope
C:\Users\diego\Documents\Arduino_Build\chMutex\chMutex.ino.cpp:24: error: 'chMtxLock' was not declared in this scope
C:\Users\diego\Documents\Arduino_Build\chMutex\chMutex.ino.cpp:32: error: 'chMtxUnlock' was not declared in this scope
C:\Users\diego\Documents\Arduino_Build\chMutex\chMutex.ino.cpp: At global scope:
C:\Users\diego\Documents\Arduino_Build\chMutex\chMutex.ino.cpp:35: error: 'msg_t' does not name a type
C:\Users\diego\Documents\Arduino_Build\chMutex\chMutex.ino.cpp: In function 'void setup()':
C:\Users\diego\Documents\Arduino_Build\chMutex\chMutex.ino.cpp:50: error: 'chBegin' was not declared in this scope
C:\Users\diego\Documents\Arduino_Build\chMutex\chMutex.ino.cpp: In function 'void chSetup()':
C:\Users\diego\Documents\Arduino_Build\chMutex\chMutex.ino.cpp:58: error: 'waTh2' was not declared in this scope
C:\Users\diego\Documents\Arduino_Build\chMutex\chMutex.ino.cpp:58: error: 'NORMALPRIO' was not declared in this scope
C:\Users\diego\Documents\Arduino_Build\chMutex\chMutex.ino.cpp:58: error: 'thdFcn' was not declared in this scope
C:\Users\diego\Documents\Arduino_Build\chMutex\chMutex.ino.cpp:58: error: 'chThdCreateStatic' was not declared in this scope
C:\Users\diego\Documents\Arduino_Build\chMutex\chMutex.ino.cpp:61: error: 'waTh3' was not declared in this scope

[Stino - Error 1]

----------------------------------

My Code...

// Example of mutex to prevent print calls from being scrambled
#include <ch.hpp>

// declare and initialize a mutex for limiting access to threads
MUTEX_DECL(demoMutex);

// data structures and stack for thread 2
static WORKING_AREA(waTh2, 100);

// data structures and stack for thread 3
static WORKING_AREA(waTh3, 100);
//------------------------------------------------------------------------------
void notify(const char* name, int state) {

// wait to enter print region
chMtxLock(&demoMutex);

// only one thread in this region while doing prints
Serial.print(name);
Serial.write(": ");
Serial.println(state);

// exit protected region
chMtxUnlock();
}
//------------------------------------------------------------------------------
msg_t thdFcn(void *args) {
while (true) {
notify((const char*)args, 0);
chThdSleep(1000);
notify((const char*)args, 1);
chThdSleep(1000);
}
}
//------------------------------------------------------------------------------
void setup() {
Serial.begin(9600);
// wait for USB Serial
while (!Serial) {}

// initialize and start ChibiOS
chBegin(chSetup);

// should not return
while(1);
}
//------------------------------------------------------------------------------
void chSetup() {
// schedule thread 2
chThdCreateStatic(waTh2, sizeof(waTh2), NORMALPRIO, thdFcn, (void*)"Th 2");

// schedule thread 3
chThdCreateStatic(waTh3, sizeof(waTh3), NORMALPRIO, thdFcn, (void*)"Th 3");

// main thread is thread 1 at NORMALPRIO
thdFcn((void*)"Th 1");
}
//------------------------------------------------------------------------------
void loop() {/* not used */}

Re: Problems in compiling. Compile for ATMEGA328P (Arduino)

Posted: Mon Mar 23, 2015 9:14 am
by Giovanni
Hi,

You must use GCC not G++.

Giovanni

Re: Problems in compiling. Compile for ATMEGA328P (Arduino)

Posted: Thu May 14, 2015 6:30 pm
by dmdeangelo
Hello Giovanni.

I tried to change the compiler, but failed.
My problem was with the paths.

Thanks for the help and sorry for the delay to thank.


Moises Deangelo