From 2711c9910bdb80074bd7d7ddc58f5efd4981e041 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Sat, 14 May 2011 12:25:39 -0400 Subject: [PATCH 01/16] Fixing 300 baud communication for serial. Because UBBR is only 12 bits, we were overflowing it at 300 baud because of the use of the U2X bit. Now we turn off U2X if it would yield a UBBR value that would overflow. Note that this breaks 300 baud communication with the computer on the Uno and Mega 2560 because the 8U2 USB-serial firmware has this same bug (and previously they cancelled each other out). Since, however, it seems more likely that people will need to use 300 baud to communicate with other (legacy) hardware than with the computer, I'm making this change. Issue for 8U2 firmware bug: http://code.google.com/p/arduino/issues/detail?id=542 http://code.google.com/p/arduino/issues/detail?id=522 --- hardware/arduino/cores/arduino/HardwareSerial.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hardware/arduino/cores/arduino/HardwareSerial.cpp b/hardware/arduino/cores/arduino/HardwareSerial.cpp index d6d7b60b8..db6b1490b 100644 --- a/hardware/arduino/cores/arduino/HardwareSerial.cpp +++ b/hardware/arduino/cores/arduino/HardwareSerial.cpp @@ -278,6 +278,8 @@ void HardwareSerial::begin(unsigned long baud) use_u2x = false; } #endif + +try_again: if (use_u2x) { *_ucsra = 1 << _u2x; @@ -286,6 +288,12 @@ void HardwareSerial::begin(unsigned long baud) *_ucsra = 0; baud_setting = (F_CPU / 8 / baud - 1) / 2; } + + if ((baud_setting > 4095) && use_u2x) + { + use_u2x = false; + goto try_again; + } // assign the baud_setting, a.k.a. ubbr (USART Baud Rate Register) *_ubrrh = baud_setting >> 8; From 4805fea3b22bc3c86ebb064982b701e07eaeff08 Mon Sep 17 00:00:00 2001 From: Tom Igoe Date: Sat, 21 May 2011 13:22:43 -0400 Subject: [PATCH 02/16] Moving recent commits to new-extension branch --- .../SerialEvent/SerialEvent.ino | 57 ++++++++ .../DhcpAddressPrinter/DhcpAddressPrinter.ino | 54 ++++++++ .../DhcpChatServer/DhcpChatServer.ino | 80 +++++++++++ .../examples/TwitterClient/TwitterClient.ino | 124 ++++++++++++++++++ .../TwoPortReceive/TwoPortReceive.ino | 78 +++++++++++ 5 files changed, 393 insertions(+) create mode 100644 build/shared/examples/4.Communication/SerialEvent/SerialEvent.ino create mode 100644 libraries/Ethernet/examples/DhcpAddressPrinter/DhcpAddressPrinter.ino create mode 100644 libraries/Ethernet/examples/DhcpChatServer/DhcpChatServer.ino create mode 100644 libraries/Ethernet/examples/TwitterClient/TwitterClient.ino create mode 100644 libraries/SoftwareSerial/examples/TwoPortReceive/TwoPortReceive.ino diff --git a/build/shared/examples/4.Communication/SerialEvent/SerialEvent.ino b/build/shared/examples/4.Communication/SerialEvent/SerialEvent.ino new file mode 100644 index 000000000..2f3f917e5 --- /dev/null +++ b/build/shared/examples/4.Communication/SerialEvent/SerialEvent.ino @@ -0,0 +1,57 @@ +/* + Serial Event example + + When new serial data arrives, this sketch adds it to a String. + When a newline is received, the loop prints the string and + clears it. + + A good test for this is to try it with a GPS receiver + that sends out NMEA 0183 sentences. + + Created 9 May 2011 + by Tom Igoe + + This example code is in the public domain. + + http://www.arduino.cc/en/Tutorial/SerialEvent + + */ + +String inputString = ""; // a string to hold incoming data +boolean stringComplete = false; // whether the string is complete + +void setup() { + // initialize serial: + Serial.begin(9600); + // reserve 200 bytes for the inputString: + inputString.reserve(200); +} + +void loop() { + // print the string when a newline arrives: + if (stringComplete) { + Serial.println(inputString); + // clear the string: + inputString = ""; + stringComplete = false; + } +} + +/* + SerialEvent occurs whenever a new byte comes in the + hardware serial RX. Don't do complex things here, as thge + processor halts the regular program to run this routine: + */ +void serialEvent() { + // get the new byte: + char inChar = (char)Serial.read(); + // add it to the inputString: + inputString += inChar; + // if the incoming character is a newline, set a flag + // so the main loop can do something about it: + if (inChar == '\n') { + stringComplete = true; + } +} + + diff --git a/libraries/Ethernet/examples/DhcpAddressPrinter/DhcpAddressPrinter.ino b/libraries/Ethernet/examples/DhcpAddressPrinter/DhcpAddressPrinter.ino new file mode 100644 index 000000000..8701568c0 --- /dev/null +++ b/libraries/Ethernet/examples/DhcpAddressPrinter/DhcpAddressPrinter.ino @@ -0,0 +1,54 @@ +/* + DHCP-based IP printer + + This sketch uses the DHCP extensions to the Ethernet library + to get an IP address via DHCP and print the address obtained. + using an Arduino Wiznet Ethernet shield. + + Circuit: + * Ethernet shield attached to pins 10, 11, 12, 13 + + created 12 April 2011 + by Tom Igoe + + */ + +#include +#include + +// Enter a MAC address for your controller below. +// Newer Ethernet shields have a MAC address printed on a sticker on the shield +byte mac[] = { + 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 }; + +// Initialize the Ethernet client library +// with the IP address and port of the server +// that you want to connect to (port 80 is default for HTTP): +Client client; + +void setup() { + // start the serial library: + Serial.begin(9600); + // start the Ethernet connection: + Serial.println("Trying to get an IP address using DHCP");z + if (Ethernet.begin(mac) == 0) { + Serial.println("Failed to configure Ethernet using DHCP"); + // no point in carrying on, so do nothing forevermore: + while(true); + } + // print your local IP address: + Serial.print("My IP address: "); + IPAddress myIPAddress = Ethernet.localIP(); + for (byte thisByte = 0; thisByte < 4; thisByte++) { + // print the value of each byte of the IP address: + Serial.print(myIPAddress[thisByte], DEC); + Serial.print("."); + } + Serial.println(); +} + +void loop() { + +} + + diff --git a/libraries/Ethernet/examples/DhcpChatServer/DhcpChatServer.ino b/libraries/Ethernet/examples/DhcpChatServer/DhcpChatServer.ino new file mode 100644 index 000000000..c3e581387 --- /dev/null +++ b/libraries/Ethernet/examples/DhcpChatServer/DhcpChatServer.ino @@ -0,0 +1,80 @@ +/* + DHCP Chat Server + + A simple server that distributes any incoming messages to all + connected clients. To use telnet to your device's IP address and type. + You can see the client's input in the serial monitor as well. + Using an Arduino Wiznet Ethernet shield. + + THis version attempts to get an IP address using DHCP + + Circuit: + * Ethernet shield attached to pins 10, 11, 12, 13 + + created 21 May 2011 + by Tom Igoe + Based on ChatServer example by David A. Mellis + + */ + +#include +#include + +// Enter a MAC address and IP address for your controller below. +// The IP address will be dependent on your local network. +// gateway and subnet are optional: +byte mac[] = { + 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 }; +IPAddress ip(192,168,1, 177); +IPAddress gateway(192,168,1, 1); +IPAddress subnet(255, 255, 0, 0); + +// telnet defaults to port 23 +Server server(23); +boolean gotAMessage = false; // whether or not you got a message from the client yet + +void setup() { + // open the serial port + Serial.begin(9600); + // start the Ethernet connection: + Serial.println("Trying to get an IP address using DHCP"); + if (Ethernet.begin(mac) == 0) { + Serial.println("Failed to configure Ethernet using DHCP"); + // initialize the ethernet device not using DHCP: + Ethernet.begin(mac, ip, gateway, subnet); + } + // print your local IP address: + Serial.print("My IP address: "); + ip = Ethernet.localIP(); + for (byte thisByte = 0; thisByte < 4; thisByte++) { + // print the value of each byte of the IP address: + Serial.print(ip[thisByte], DEC); + Serial.print("."); + } + Serial.println(); + // start listening for clients + server.begin(); + +} + +void loop() { + // wait for a new client: + Client client = server.available(); + + // when the client sends the first byte, say hello: + if (client) { + if (!gotAMessage) { + Serial.println("We have a new client"); + client.println("Hello, client!"); + gotAMessage = true; + } + + // read the bytes incoming from the client: + char thisChar = client.read(); + // echo the bytes back to the client: + server.write(thisChar); + // echo the bytes to the server as well: + Serial.print(thisChar); + } +} + diff --git a/libraries/Ethernet/examples/TwitterClient/TwitterClient.ino b/libraries/Ethernet/examples/TwitterClient/TwitterClient.ino new file mode 100644 index 000000000..399e76bc3 --- /dev/null +++ b/libraries/Ethernet/examples/TwitterClient/TwitterClient.ino @@ -0,0 +1,124 @@ +/* + Twitter Client with Strings + + This sketch connects to Twitter using an Ethernet shield. It parses the XML + returned, and looks for this is a tweet + + You can use the Arduino Ethernet shield, or the Adafruit Ethernet shield, + either one will work, as long as it's got a Wiznet Ethernet module on board. + + This example uses the DHCP routines in the Ethernet library which is part of the + Arduino core from version 1.0 beta 1 + + This example uses the String library, which is part of the Arduino core from + version 0019. + + Circuit: + * Ethernet shield attached to pins 10, 11, 12, 13 + + created 21 May 2011 + by Tom Igoe + + This code is in the public domain. + + */ +#include +#include + + +// Enter a MAC address and IP address for your controller below. +// The IP address will be dependent on your local network: +byte mac[] = { + 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x01 }; +IPAddress ip(192,168,1,20); + +// initialize the library instance: +Client client; + +const int requestInterval = 60000; // delay between requests + +char serverName[] = "api.twitter.com"; // twitter URL + +boolean requested; // whether you've made a request since connecting +long lastAttemptTime = 0; // last time you connected to the server, in milliseconds + +String currentLine = ""; // string to hold the text from server +String tweet = ""; // string to hold the tweet +boolean readingTweet = false; // if you're currently reading the tweet + +void setup() { + // reserve space for the strings: + currentLine.reserve(256); + tweet.reserve(150); + +// initialize serial: + Serial.begin(9600); + // attempt a DHCP connection: + if (!Ethernet.begin(mac)) { + // if DHCP fails, start with a hard-coded address: + Ethernet.begin(mac, ip); + } + // connect to Twitter: + connectToServer(); +} + + + +void loop() +{ + if (client.connected()) { + if (client.available()) { + // read incoming bytes: + char inChar = client.read(); + + // add incoming byte to end of line: + currentLine += inChar; + + // if you get a newline, clear the line: + if (inChar == '\n') { + currentLine = ""; + } + // if the current line ends with , it will + // be followed by the tweet: + if ( currentLine.endsWith("")) { + // tweet is beginning. Clear the tweet string: + readingTweet = true; + tweet = ""; + } + // if you're currently reading the bytes of a tweet, + // add them to the tweet String: + if (readingTweet) { + if (inChar != '<') { + tweet += inChar; + } + else { + // if you got a "<" character, + // you've reached the end of the tweet: + readingTweet = false; + Serial.println(tweet); + // close the connection to the server: + client.stop(); + } + } + } + } + else if (millis() - lastAttemptTime > requestInterval) { + // if you're not connected, and two minutes have passed since + // your last connection, then attempt to connect again: + connectToServer(); + } +} + +void connectToServer() { + // attempt to connect, and wait a millisecond: + Serial.println("connecting to server..."); + if (client.connect(serverName, 80)) { + Serial.println("making HTTP request..."); + // make HTTP GET request to twitter: + client.println("GET /1/statuses/user_timeline.xml?screen_name=arduino&count=1 HTTP/1.1"); + client.println("HOST: api.twitter.com"); + client.println(); + } + // note the time of this connect attempt: + lastAttemptTime = millis(); +} diff --git a/libraries/SoftwareSerial/examples/TwoPortReceive/TwoPortReceive.ino b/libraries/SoftwareSerial/examples/TwoPortReceive/TwoPortReceive.ino new file mode 100644 index 000000000..e870c6fc1 --- /dev/null +++ b/libraries/SoftwareSerial/examples/TwoPortReceive/TwoPortReceive.ino @@ -0,0 +1,78 @@ +/* + Software serial multple serial test + + Receives from the two software serial ports, + sends to the hardware serial port. + + In order to listen on a software port, you call port.listen(). + When using two software serial ports, you have to switch ports + by listen()ing on each one in turn. Pick a logical time to switch + ports, like the end of an expected transmission, or when the + buffer is empty. This example switches ports when there is nothing + more to read from a port + + The circuit: + Two devices which communicate serially are needed. + * First serial device's TX attached to digital pin 2, RX to pin 3 + * Second serial device's TX attached to digital pin 4, RX to pin 5 + + created 18 Apr. 2011 + by Tom Igoe + based on Mikal Hart's twoPortRXExample + + This example code is in the public domain. + + */ + +#include +// software serial #1: TX = digital pin 2, RX = digital pin 3 +SoftwareSerial portOne(2, 3); + +// software serial #2: TX = digital pin 4, RX = digital pin 5 +SoftwareSerial portTwo(4, 5); + +void setup() +{ + // Start the hardware serial port + Serial.begin(9600); + + // Start each software serial port + portOne.begin(9600); + portTwo.begin(9600); +} + +void loop() +{ + // By default, the last intialized port is listening. + // when you want to listen on a port, explicitly select it: + portOne.listen(); + Serial.println("Data from port one:"); + // while there is data coming in, read it + // and send to the hardware serial port: + while (portOne.available() > 0) { + char inByte = portOne.read(); + Serial.write(inByte); + } + + // blank line to separate data from the two ports: + Serial.println(); + + // Now listen on the second port + portTwo.listen(); + // while there is data coming in, read it + // and send to the hardware serial port: + Serial.println("Data from port two:"); + while (portTwo.available() > 0) { + char inByte = portTwo.read(); + Serial.write(inByte); + } + + // blank line to separate data from the two ports: + Serial.println(); +} + + + + + + From 8e8102da7805833dce19003cdc06b5298f60461a Mon Sep 17 00:00:00 2001 From: ricklon Date: Mon, 6 Jun 2011 21:48:12 -0400 Subject: [PATCH 03/16] Added debug mode for macox. Sets the spawn value to false. --- build/build.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build/build.xml b/build/build.xml index d6e00e2bd..c7709c120 100644 --- a/build/build.xml +++ b/build/build.xml @@ -217,6 +217,10 @@ + + + + From 58de95a90522b880928caefcda198320eea5a796 Mon Sep 17 00:00:00 2001 From: ricklon Date: Mon, 6 Jun 2011 21:57:11 -0400 Subject: [PATCH 04/16] Added platforms.txt, and update boards.txt with platform=avr --- hardware/arduino/boards.txt | 33 +++++++++--------- hardware/arduino/platforms.txt | 63 ++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 16 deletions(-) create mode 100755 hardware/arduino/platforms.txt diff --git a/hardware/arduino/boards.txt b/hardware/arduino/boards.txt index 88a71433d..e65953ce6 100644 --- a/hardware/arduino/boards.txt +++ b/hardware/arduino/boards.txt @@ -1,6 +1,7 @@ ############################################################## uno.name=Arduino Uno +uno.platform=avr uno.upload.protocol=stk500 uno.upload.maximum_size=32256 uno.upload.speed=115200 @@ -19,7 +20,7 @@ uno.build.pins=standard ############################################################## atmega328.name=Arduino Duemilanove or Nano w/ ATmega328 - +atmega328.platform=avr atmega328.upload.protocol=stk500 atmega328.upload.maximum_size=30720 atmega328.upload.speed=57600 @@ -40,7 +41,7 @@ atmega328.build.pins=standard ############################################################## diecimila.name=Arduino Diecimila, Duemilanove, or Nano w/ ATmega168 - +diecimila.platform=avr diecimila.upload.protocol=stk500 diecimila.upload.maximum_size=14336 diecimila.upload.speed=19200 @@ -61,7 +62,7 @@ diecimila.build.pins=standard ############################################################## mega2560.name=Arduino Mega 2560 - +mega2560.platform=avr mega2560.upload.protocol=stk500v2 mega2560.upload.maximum_size=258048 mega2560.upload.speed=115200 @@ -82,7 +83,7 @@ mega2560.build.pins=mega ############################################################## mega.name=Arduino Mega (ATmega1280) - +mega.platform=avr mega.upload.protocol=stk500 mega.upload.maximum_size=126976 mega.upload.speed=57600 @@ -103,7 +104,7 @@ mega.build.pins=mega ############################################################## mini.name=Arduino Mini - +mini.platform=avr mini.upload.protocol=stk500 mini.upload.maximum_size=14336 mini.upload.speed=19200 @@ -124,7 +125,7 @@ mini.build.pins=standard ############################################################## fio.name=Arduino Fio - +fio.platform=avr fio.upload.protocol=stk500 fio.upload.maximum_size=30720 fio.upload.speed=57600 @@ -145,7 +146,7 @@ fio.build.pins=standard ############################################################## bt328.name=Arduino BT w/ ATmega328 - +bt328.platform=avr bt328.upload.protocol=stk500 bt328.upload.maximum_size=28672 bt328.upload.speed=19200 @@ -167,7 +168,7 @@ bt328.build.pins=standard ############################################################## bt.name=Arduino BT w/ ATmega168 - +bt.platform=avr bt.upload.protocol=stk500 bt.upload.maximum_size=14336 bt.upload.speed=19200 @@ -189,7 +190,7 @@ bt.build.pins=standard ############################################################## lilypad328.name=LilyPad Arduino w/ ATmega328 - +lilypad328.platform=avr lilypad328.upload.protocol=stk500 lilypad328.upload.maximum_size=30720 lilypad328.upload.speed=57600 @@ -210,7 +211,7 @@ lilypad328.build.pins=standard ############################################################## lilypad.name=LilyPad Arduino w/ ATmega168 - +lilypad.platform=avr lilypad.upload.protocol=stk500 lilypad.upload.maximum_size=14336 lilypad.upload.speed=19200 @@ -231,7 +232,7 @@ lilypad.build.pins=standard ############################################################## pro5v328.name=Arduino Pro or Pro Mini (5V, 16 MHz) w/ ATmega328 - +pro5v328.platform=avr pro5v328.upload.protocol=stk500 pro5v328.upload.maximum_size=30720 pro5v328.upload.speed=57600 @@ -252,7 +253,7 @@ pro5v328.build.pins=standard ############################################################## pro5v.name=Arduino Pro or Pro Mini (5V, 16 MHz) w/ ATmega168 - +pro5v.platform=avr pro5v.upload.protocol=stk500 pro5v.upload.maximum_size=14336 pro5v.upload.speed=19200 @@ -273,7 +274,7 @@ pro5v.build.pins=standard ############################################################## pro328.name=Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega328 - +pro328.platform=avr pro328.upload.protocol=stk500 pro328.upload.maximum_size=30720 pro328.upload.speed=57600 @@ -294,7 +295,7 @@ pro328.build.pins=standard ############################################################## pro.name=Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega168 - +pro.platform=avr pro.upload.protocol=stk500 pro.upload.maximum_size=14336 pro.upload.speed=19200 @@ -315,7 +316,7 @@ pro.build.pins=standard ############################################################## atmega168.name=Arduino NG or older w/ ATmega168 - +atmega168.platform=avr atmega168.upload.protocol=stk500 atmega168.upload.maximum_size=14336 atmega168.upload.speed=19200 @@ -336,7 +337,7 @@ atmega168.build.pins=standard ############################################################## atmega8.name=Arduino NG or older w/ ATmega8 - +atmega8.platform=avr atmega8.upload.protocol=stk500 atmega8.upload.maximum_size=7168 atmega8.upload.speed=19200 diff --git a/hardware/arduino/platforms.txt b/hardware/arduino/platforms.txt new file mode 100755 index 000000000..ce35a3b36 --- /dev/null +++ b/hardware/arduino/platforms.txt @@ -0,0 +1,63 @@ +#########Compiler Recipe################################# +##compile c object files +##Default.recipe, overide if overide exists, these defauls should remain the same, if you need to change them do it as an overide. + +#default.recipe.c.o.pattern={0}{1}::{2}::{3}{4}::-DF_CPU={5}::-D{6}={7}::{8}::{9}::-o::{10} +#default.recipe.cpp.o.pattern={0}{1}::{2}::{3}{4}::-DF_CPU={5}::-D{6}={7}::{8}::{9}::-o::{10} +#default.recipe.ar.pattern={0}{1}::{2}::{3}{4}::{5} +#default.recipe.c.combine.pattern={0}{1}::{2}::{3}{4}::-o::{5}{6}.elf::{7}::{8}::-L{9}::-lm +#default.recipe.objcopy.eep.pattern={0}{1}::{2}::{3}.elf::{4}.eep +#default.recipe.objcopy.hex.pattern={0}{1}::{2}::{3}.elf::{4}.hex + +########avr compile pattern ########## +#avr.recipe.c.o.pattern={0=compiler.path}{1=compiler.c.cmd}{2=compiler.c.flags}{3=compiler.cpudef}{4=build.mcu}-DF_CPU={5=build.f_cpu}-D{7=ARDUINO}={6=Base.REVISION}{7=-I/INCLUDE_PATHS} {8=SOURCE_NAME} -o{9=OBJECT_NAME} +#object name seems to have build path in it. +avr.recipe.c.o.pattern={0}{1}::{2}::{3}{4}::-DF_CPU={5}::-D{6}={7}::{8}::{9}::-o::{10} + + +##compile cc object files +#avr.recipe.cc.o.pattern={0=compiler.path}{1=compiler.cc.cmd}{2=compiler.c.flags}{3=compiler.cpudef}{4=build.mcu}-DF_CPU={5=build.f_cpu}-DARDUINO={6=Base.REVISION}{-7=I/INCLUDE_PATHS} {8=SOURCE_NAME} -o{9=BUILD_PATH}{10=OBJECT_NAME} +avr.recipe.cpp.o.pattern={0}{1}::{2}::{3}{4}::-DF_CPU={5}::-D{6}={7}::{8}::{9}::-o::{10} +##create archives +#avr.recipe.ar.pattern={0=compiler.path}{1=compiler.ar.cmd}{2=compiler.ar.flags}{3=BUILD_PATH}{4=CORE_NAME=core.a}{5=BUILD_PATH}{6=OBJECT_NAME} +avr.recipe.ar.pattern={0}{1}::{2}::{3}{4}::{5} + +##combine gc-sections, archives, and objects +#avr.recipe.c.combine.pattern={0=compiler.path}{1=compiler.c.cmd}{2=compiler.combine.flags}{3=compiler.cpudef}{4=build.mcu} -o {5=BUILD_PATH}{6=SOURCE_NAME}.elf {7=BUILD_PATH}{8=SOURCE_NAME}.o {9=BUILD_PATH}{10=CORE_NAME=core.a} -L{11=BUILD_PATH} -lm +#avr.recipe.c.combine.pattern={0}{1}::{2}::{3}{4}::-o::{5}{6}.elf::{7}{8}::{9}::-L{10}::-lm +avr.recipe.c.combine.pattern={0}{1}::{2}::{3}{4}::-o::{5}{6}.elf::{7}::{8}::-L{9}::-lm + +##create eeprom +#avr.recipe.objcopy.eep.pattern={0=compiler.path}{1=compiler.objcopy.cmd}{2=compiler.objcopy.eep.flags} {3=BUILD_PATH}{4=SOURCE_NAME}.elf {5=BUILD_PATH}{6=SOURCE_NAME}.eep +avr.recipe.objcopy.eep.pattern={0}{1}::{2}::{3}.elf::{4}.eep + +##create hex +#avr.recipe.objcopy.hex.pattern={0=compiler.path}{1=compiler.objcopy.cmd}{2=compiler.objcopy.elf.flags} {3=BUILD_PATH}{4=SOURCE_NAME}.elf {5=BUILD_PATH}{6=SOURCE_NAME}.hex +avr.recipe.objcopy.hex.pattern={0}{1}::{2}::{3}.elf::{4}.hex + + + +######################################################## +avr.name=Arduino +#avr.compiler.path Official default is correct, only need to change this if you want to overide the initial default +#avr.compiler.path={0}/hardware/tools/avr/bin/ +avr.compiler.c.cmd=avr-gcc +avr.compiler.c.flags=::-c::-g::-Os::-w::-ffunction-sections::-fdata-sections +avr.compiler.c.elf.flags=::-Os::-Wl,--gc-sections +avr.compiler.c.elf.cmd=avr-gcc +avr.compiler.S.flags=::-c::-g::-assembler-with-cpp +avr.compiler.cpp.cmd=avr-g++ +avr.compiler.cpp.flags=::-c::-g::-Os::-w::-fno-exceptions::-ffunction-sections::-fdata-sections +avr.compiler.ar.cmd=avr-ar +avr.compiler.ar.flags=rcs +avr.compiler.objcopy.cmd=avr-objcopy +avr.compiler.objcopy.eep.flags=::-O::ihex::-j::.eeprom::--set-section-flags=.eeprom=alloc,load::--no-change-warnings::--change-section-lma::.eeprom=0 +avr.compiler.elf2hex.flags=::-O::ihex::-R::.eeprom +avr.compiler.elf2hex.cmd=avr-objcopy +avr.compiler.ldflags= +avr.compiler.cpudef=-mmcu= +avr.compiler.upload.cmd= +avr.compiler.upload.flags= +avr.library.path=./hardware/arduino/cores/arduino +avr.library.core.path=./libraries + From 41600a22ebb1e6a0ce786ff7b75be70132f429cc Mon Sep 17 00:00:00 2001 From: ricklon Date: Mon, 6 Jun 2011 22:34:12 -0400 Subject: [PATCH 05/16] Added initial changes to the Compiler.java file. --- app/src/processing/app/debug/Compiler.java | 124 +++++++++++++++++++++ 1 file changed, 124 insertions(+) diff --git a/app/src/processing/app/debug/Compiler.java b/app/src/processing/app/debug/Compiler.java index bf972b8ea..24a478482 100644 --- a/app/src/processing/app/debug/Compiler.java +++ b/app/src/processing/app/debug/Compiler.java @@ -229,6 +229,53 @@ public class Compiler implements MessageConsumer { execAsynchronously(commandObjcopy); return true; + /* + + logger.debug("corePaths: " + this.corePath); + + + this.objectFiles = new ArrayList(); + + // 0. include paths for core + all libraries + logger.debug("0. getIncludes"); + this.includePaths = getIncludes(this.corePath); + + // 1. compile the sketch (already in the buildPath) + logger.debug("1. compileSketch"); + compileSketch(avrBasePath, buildPath, includePaths, configPreferences); + + // 2. compile the libraries, outputting .o files to: + // // + //Doesn't really use configPreferences + logger.debug("2. compileLibraries"); + compileLibraries(avrBasePath, buildPath, includePaths, configPreferences); + + // 3. compile the core, outputting .o files to and then + // collecting them into the core.a library file. + logger.debug("3. compileCore"); + compileCore(avrBasePath, buildPath, this.corePath, configPreferences); + + // 4. link it all together into the .elf file + logger.debug("4. compileLink"); + compileLink(avrBasePath, buildPath, this.corePath, includePaths, configPreferences); + + // 5. extract EEPROM data (from EEMEM directive) to .eep file. + logger.debug("5. compileEep"); + compileEep(avrBasePath, buildPath, includePaths, configPreferences); + + // 6. build the .hex file + logger.debug("6. compileHex"); + compileHex(avrBasePath, buildPath, includePaths, configPreferences); + + //done + logger.debug("7. compile done"); + return true; + + + + */ + + } @@ -531,4 +578,81 @@ public class Compiler implements MessageConsumer { return files; } + + + //merge all the preferences file in the correct order of precedence + HashMap mergePreferences(Map Preferences, Map platformPreferences, Map boardPreferences) + { + HashMap _map = new HashMap(); + + Iterator iterator = Preferences.entrySet().iterator(); + + while(iterator.hasNext()) + { + Map.Entry pair = (Map.Entry)iterator.next(); + if (pair.getValue() == null) + { + _map.put(pair.getKey(), ""); + } + else + { + _map.put(pair.getKey(), pair.getValue()); + } + } + + //logger.debug("Done: Preferences"); + + iterator = platformPreferences.entrySet().iterator(); + + while(iterator.hasNext()) + { + Map.Entry pair = (Map.Entry)iterator.next(); + + if (pair.getValue() == null) + { + _map.put(pair.getKey(), ""); + } + else + { + _map.put(pair.getKey(), pair.getValue()); + } + //System.out.println(pair.getKey() + " = " + pair.getValue()); + } + + //System.out.println("Done: platformPreferences"); + iterator = boardPreferences.entrySet().iterator(); + + while(iterator.hasNext()) + { + Map.Entry pair = (Map.Entry)iterator.next(); + + if (pair.getValue() == null) + { + _map.put(pair.getKey(), ""); + } + else + { + _map.put(pair.getKey(), pair.getValue()); + } + //System.out.println(pair.getKey() + " = " + pair.getValue()); + } + //System.out.println("Done: boardPreferences"); + + + return _map; + } + + private static String preparePaths(ArrayList includePaths) { + //getIncludes to String + //logger.debug("Start: Prepare paths"); + String includes = ""; + for (int i = 0; i < includePaths.size(); i++) + { + includes = includes + (" -I" + (String) includePaths.get(i)) + "::"; + } + //logger.debug("Paths prepared: " + includes); + return includes; + } + + } From fa268259a014b9aa0f4b5c503af5f8679dbdd672 Mon Sep 17 00:00:00 2001 From: ricklon Date: Mon, 13 Jun 2011 14:14:22 -0400 Subject: [PATCH 06/16] Majority of non Compiler.java changes made. --- app/src/processing/app/Base.java | 47 +++++++++++++++++++++++- app/src/processing/app/Editor.java | 3 ++ app/src/processing/app/Preferences.java | 18 +++++++++ app/src/processing/app/Sketch.java | 6 ++- app/src/processing/app/debug/Target.java | 33 ++++++++++++++++- 5 files changed, 102 insertions(+), 5 deletions(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 036cb4f5a..b8e6fc03c 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -956,8 +956,20 @@ public class Base { importToLibraryTable = new HashMap(); // Add from the "libraries" subfolder in the Processing directory + //Choose which library to add by chip platform + try { - addLibraries(importMenu, librariesFolder); + //Find the current target. Get the platform, and then select the correct name and core path. + String platformname = this.getBoardPreferences().get("platform"); + String targetname = this.getPlatformPreferences(platformname).get("name"); + String libraryPath = this.getPlatformPreferences(platformname).get("library.core.path"); + + JMenuItem platformItem = new JMenuItem(targetname); + platformItem.setEnabled(false); + importMenu.add(platformItem); + importMenu.addSeparator(); + addLibraries(importMenu, getCoreLibraries(libraryPath)); + } catch (IOException e) { e.printStackTrace(); } @@ -1005,6 +1017,8 @@ public class Base { //System.out.println("Switching to " + target + ":" + board); Preferences.set("target", (String) getValue("target")); Preferences.set("board", (String) getValue("board")); + //Debug: created new imports menu based on board + rebuildImportMenu(activeEditor.importMenu); } }; action.putValue("target", target.getName()); @@ -1518,6 +1532,10 @@ public class Base { return getContentFile("hardware"); } + //Get the core libraries + static public File getCoreLibraries(String path) { + return getContentFile(path); + } static public String getHardwarePath() { return getHardwareFolder().getAbsolutePath(); @@ -1538,7 +1556,32 @@ public class Base { return Base.targetsTable.get(Preferences.get("target")); } - + +static public Map getPlatformPreferences() { + Target target = getTarget(); + //if (target == null) return new LinkedHashMap(); + Map map = target.getPlatforms(); + /* + if (map == null) + { + System.err.println("Error loading platforms preference from Target"); + System.exit(0); + } + */ + //if (map == null) return new LinkedHashMap(); + map = (Map) map.get(Preferences.get("platform")); + //if (map == null) return new LinkedHashMap(); + return map; + } + + //Get a specific platform + static public Map getPlatformPreferences(String platformname) { + Target target = getTarget(); + Map map = target.getPlatforms(); + map = (Map) map.get(platformname); + return map; + } + static public Map getBoardPreferences() { Target target = getTarget(); if (target == null) return new LinkedHashMap(); diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index 33f1fc855..95c531640 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -684,6 +684,9 @@ public class Editor extends JFrame implements RunnerListener { if (boardsMenu == null) { boardsMenu = new JMenu("Board"); base.rebuildBoardsMenu(boardsMenu); + //Debug: rebuild imports + importMenu.removeAll(); + base.rebuildImportMenu(importMenu); } menu.add(boardsMenu); diff --git a/app/src/processing/app/Preferences.java b/app/src/processing/app/Preferences.java index 4dd15c041..f8d5c2762 100644 --- a/app/src/processing/app/Preferences.java +++ b/app/src/processing/app/Preferences.java @@ -776,4 +776,22 @@ public class Preferences { return new SyntaxStyle(color, italic, bold); } + + //get a Map of the Preferences + static public Map getMap() + { + Map globalpreferences = new LinkedHashMap(); + Enumeration e = table.keys(); + + while (e.hasMoreElements()) + { + String key = (String) e.nextElement(); + //System.out.println("Key: " + key + "Val: " + table.get(key)); + String value = (String) table.get(key); + globalpreferences.put(key, value ); + } + + return globalpreferences; + } + } diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index 22e2aa591..f2c919d94 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -1328,10 +1328,14 @@ public class Sketch { // grab the imports from the code just preproc'd importedLibraries = new ArrayList(); - + //Remember to clear library path before building it. + libraryPath = ""; for (String item : preprocessor.getExtraImports()) { File libFolder = (File) Base.importToLibraryTable.get(item); + File libFolder = (File) Base.importToLibraryTable.get(item); + //Debug libraryPath + if (libFolder != null && !importedLibraries.contains(libFolder)) { importedLibraries.add(libFolder); //classPath += Compiler.contentsToClassPath(libFolder); diff --git a/app/src/processing/app/debug/Target.java b/app/src/processing/app/debug/Target.java index 1aa2f81be..c515d2cf3 100644 --- a/app/src/processing/app/debug/Target.java +++ b/app/src/processing/app/debug/Target.java @@ -29,18 +29,21 @@ import java.io.*; import java.util.*; import processing.app.Preferences; +//import processing.app.Base; public class Target { private String name; private File folder; private Map boards; private Map programmers; - + private Map platforms; + public Target(String name, File folder) { this.name = name; this.folder = folder; this.boards = new LinkedHashMap(); this.programmers = new LinkedHashMap(); + this.platforms = new LinkedHashMap(); File boardsFile = new File(folder, "boards.txt"); try { @@ -60,6 +63,28 @@ public class Target { System.err.println("Error loading boards from " + boardsFile + ": " + e); } + File platformsFile = new File(folder,"platforms.txt"); + try + { + if(platformsFile.exists()){ + Map platformPreferences = new LinkedHashMap(); + Preferences.load(new FileInputStream(platformsFile), platformPreferences); + for(Object k : platformPreferences.keySet()) + { + String key=(String) k; + String platform=key.substring(0,key.indexOf('.')); + if (!platforms.containsKey(platform)) platforms.put(platform, new HashMap()); + ((Map) platforms.get(platform)).put(key.substring(key.indexOf('.') + 1),platformPreferences.get(key)); + } + } + } catch (Exception e) { + System.err.println("Error loading platforms from " + + platformsFile + ": " + e); + // System.exit(0); + + } + + File programmersFile = new File(folder, "programmers.txt"); try { if (programmersFile.exists()) { @@ -88,4 +113,8 @@ public class Target { public Map> getProgrammers() { return programmers; } -} \ No newline at end of file + public Map> getPlatforms() { + return platforms; + } + +} From 7cf5b7263f053fc19adb642e45c2cfbc7189c8b9 Mon Sep 17 00:00:00 2001 From: ricklon Date: Mon, 13 Jun 2011 21:23:59 -0400 Subject: [PATCH 07/16] Fixed issues about invalid targets. Menu selection of boards and libraries are now functional. --- app/src/processing/app/Base.java | 84 ++++++++++++++++++++---- app/src/processing/app/Sketch.java | 3 +- app/src/processing/app/debug/Target.java | 4 +- 3 files changed, 76 insertions(+), 15 deletions(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index b8e6fc03c..11cd52e28 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -959,7 +959,7 @@ public class Base { //Choose which library to add by chip platform try { - //Find the current target. Get the platform, and then select the correct name and core path. + //Find the current target. Get the platform, and then select the correct name and core path. String platformname = this.getBoardPreferences().get("platform"); String targetname = this.getPlatformPreferences(platformname).get("name"); String libraryPath = this.getPlatformPreferences(platformname).get("library.core.path"); @@ -1553,11 +1553,20 @@ public class Base { static public Target getTarget() { - return Base.targetsTable.get(Preferences.get("target")); + System.out.println("Base.targetsTable.get(Preferences.get(\"target\"))" + Base.targetsTable.get(Preferences.get("target"))); + System.out.println("Preferences.get(\"target\")" + Preferences.get("target")); + Target target = Base.targetsTable.get(Preferences.get("target")); + if (target == null) { + System.out.println("default target is not in list. Replace with default."); + Preferences.set("target", "arduino"); + target = Base.targetsTable.get(Preferences.get("target")); + } + return target; } static public Map getPlatformPreferences() { + System.out.println("getPlatformPreferences() no arguments: start"); Target target = getTarget(); //if (target == null) return new LinkedHashMap(); Map map = target.getPlatforms(); @@ -1576,22 +1585,73 @@ static public Map getPlatformPreferences() { //Get a specific platform static public Map getPlatformPreferences(String platformname) { + if (platformname == null) { + platformname = Preferences.get("platform"); + + } + System.out.println("getlatformPreferences(String platformname)): start: platformname = " + platformname ); Target target = getTarget(); - Map map = target.getPlatforms(); - map = (Map) map.get(platformname); + if (target == null ) { + System.out.println("get target is null. trouble! "); + } + Map map = target.getPlatforms(); + map = (Map) map.get(platformname); + + //What if null or defaults to nonexisent platform + System.out.println("PlatformName: " + platformname); + if (map == null) + { + System.err.println("Error loading platforms preference from Target"); + System.exit(0); + } + + return map; + } + + static public Map bogusgetBoardPreferences() { + System.out.println("getBoardPrefences method: start"); + Target target = getTarget(); + if (target == null) { + System.out.println("getBoardPrefereces method: target == null"); + return new LinkedHashMap(); + } + Map map = target.getBoards(); + if (map == null) { + System.out.println("getBoardPrefereces method: target.getBoards() == null"); + return new LinkedHashMap(); + } + map = (Map) map.get(Preferences.get("board")); + if (map == null) { + System.out.println("getBoardPrefereces method: Preferences.get(board) == null"); + return new LinkedHashMap(); + } + //Debug iterate the map + Iterator iterator = map.entrySet().iterator(); + while(iterator.hasNext()) + { + Map.Entry pair = (Map.Entry)iterator.next(); + if (pair.getValue() == null) + { + System.out.println("KeyName: " + pair.getKey() + " val: null"); + } + else + { + System.out.println("KeyName: " + pair.getKey() + " val" + pair.getValue()); + } + } + return map; } - static public Map getBoardPreferences() { +static public Map getBoardPreferences() { Target target = getTarget(); - if (target == null) return new LinkedHashMap(); - Map map = target.getBoards(); - if (map == null) return new LinkedHashMap(); - map = (Map) map.get(Preferences.get("board")); - if (map == null) return new LinkedHashMap(); + Map map = new LinkedHashMap(); + if (target != null) { + map = target.getBoards(); + map = (Map) map.get(Preferences.get("board")); + } return map; - } - + } static public File getSketchbookFolder() { return new File(Preferences.get("sketchbook.path")); diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index f2c919d94..499b655a9 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -1331,10 +1331,9 @@ public class Sketch { //Remember to clear library path before building it. libraryPath = ""; for (String item : preprocessor.getExtraImports()) { - File libFolder = (File) Base.importToLibraryTable.get(item); File libFolder = (File) Base.importToLibraryTable.get(item); - //Debug libraryPath + //If needed can Debug libraryPath here if (libFolder != null && !importedLibraries.contains(libFolder)) { importedLibraries.add(libFolder); diff --git a/app/src/processing/app/debug/Target.java b/app/src/processing/app/debug/Target.java index c515d2cf3..649c2827a 100644 --- a/app/src/processing/app/debug/Target.java +++ b/app/src/processing/app/debug/Target.java @@ -39,6 +39,7 @@ public class Target { private Map platforms; public Target(String name, File folder) { + System.out.println("Target: constructor start, name: " + name); this.name = name; this.folder = folder; this.boards = new LinkedHashMap(); @@ -61,6 +62,7 @@ public class Target { } } catch (Exception e) { System.err.println("Error loading boards from " + boardsFile + ": " + e); + } File platformsFile = new File(folder,"platforms.txt"); @@ -80,7 +82,7 @@ public class Target { } catch (Exception e) { System.err.println("Error loading platforms from " + platformsFile + ": " + e); - // System.exit(0); + System.exit(0); } From 5e0ac9c720f292adb93002e604632b4f99f88298 Mon Sep 17 00:00:00 2001 From: ricklon Date: Mon, 13 Jun 2011 22:14:28 -0400 Subject: [PATCH 08/16] Converting the step by step functions to integrate with standard Arduino execAsynchronously(array) --- app/src/processing/app/debug/Compiler.java | 237 ++++++++++++++++++++- 1 file changed, 228 insertions(+), 9 deletions(-) diff --git a/app/src/processing/app/debug/Compiler.java b/app/src/processing/app/debug/Compiler.java index 24a478482..1b19435a8 100644 --- a/app/src/processing/app/debug/Compiler.java +++ b/app/src/processing/app/debug/Compiler.java @@ -32,6 +32,7 @@ import processing.core.*; import java.io.*; import java.util.*; import java.util.zip.*; +import java.text.MessageFormat; public class Compiler implements MessageConsumer { @@ -43,9 +44,22 @@ public class Compiler implements MessageConsumer { Sketch sketch; String buildPath; String primaryClassName; - boolean verbose; + String platform; + String board; + boolean verbose; + RunnerException exception; + + HashMap configPreferences; + HashMap boardPreferences; + HashMap platformPreferences; + + String avrBasePath; + String corePath; + + List objectFiles; + ArrayList includePaths; public Compiler() { } @@ -70,9 +84,47 @@ public class Compiler implements MessageConsumer { // the pms object isn't used for anything but storage MessageStream pms = new MessageStream(this); - String avrBasePath = Base.getAvrBasePath(); Map boardPreferences = Base.getBoardPreferences(); - String core = boardPreferences.get("build.core"); + + //Check for null platform, and use system default if not found + platform = boardPreferences.get("platform"); + if (platform == null) + { + platformPreferences = new HashMap(Base.getPlatformPreferences()); + } + else + { + platformPreferences = new HashMap(Base.getPlatformPreferences(platform)); + } + + + //Put all the global preference configuration into one Master configpreferences + configPreferences = mergePreferences( Preferences.getMap(), platformPreferences, boardPreferences); + avrBasePath = configPreferences.get("compiler.path"); + if (avrBasePath == null) + { + avrBasePath = Base.getAvrBasePath(); + } + else + { + //Put in the system path in the compiler path if available + MessageFormat compileFormat = new MessageFormat(avrBasePath); + String basePath = System.getProperty("user.dir"); + if (Base.isMacOS()) { + //logger.debug("basePath: " + basePath); + basePath += "/Arduino.app/Contents/Resources/Java"; + } + Object[] Args = {basePath}; + avrBasePath = compileFormat.format( Args ); + + } + this.board = configPreferences.get("board"); + if (this.board == "") + { + this.board = "_UNKNOWN"; + } + + String core = configPreferences.get("build.core"); if (core == null) { RunnerException re = new RunnerException("No board selected; please choose a board from the Tools > Board menu."); re.hideStackTrace(); @@ -91,7 +143,7 @@ public class Compiler implements MessageConsumer { corePath = coreFolder.getAbsolutePath(); } - String pins = boardPreferences.get("build.pins"); + String pins = configPreferences.get("build.pins"); String pinsPath = null; if (pins != null) { @@ -111,7 +163,7 @@ public class Compiler implements MessageConsumer { // 0. include paths for core + all libraries - List includePaths = new ArrayList(); + ArrayList includePaths = new ArrayList(); includePaths.add(corePath); if (pinsPath != null) includePaths.add(pinsPath); for (File file : sketch.getImportedLibraries()) { @@ -119,13 +171,15 @@ public class Compiler implements MessageConsumer { } // 1. compile the sketch (already in the buildPath) - + compileSketch(avrBasePath, buildPath, includePaths, configPreferences); +/* objectFiles.addAll( compileFiles(avrBasePath, buildPath, includePaths, findFilesInPath(buildPath, "S", false), findFilesInPath(buildPath, "c", false), findFilesInPath(buildPath, "cpp", false), boardPreferences)); + */ // 2. compile the libraries, outputting .o files to: // @@ -280,9 +334,9 @@ public class Compiler implements MessageConsumer { private List compileFiles(String avrBasePath, - String buildPath, List includePaths, - List sSources, - List cSources, List cppSources, + String buildPath, ArrayList includePaths, + ArrayList sSources, + ArrayList cSources, ArrayList cppSources, Map boardPreferences) throws RunnerException { @@ -580,6 +634,171 @@ public class Compiler implements MessageConsumer { } + // 1. compile the sketch (already in the buildPath) + void compileSketch(String avrBasePath, String buildPath, ArrayList includePaths, HashMap configPreferences) + throws RunnerException + { + //logger.debug("compileSketch: start"); + this.objectFiles.addAll(compileFiles(avrBasePath, buildPath, includePaths, + findFilesInPath(buildPath, "S", false), + findFilesInPath(buildPath, "c", false), + findFilesInPath(buildPath, "cpp", false), + configPreferences)); + } + + // 2. compile the libraries, outputting .o files to: + // // + void compileLibraries (String avrBasePath, String buildPath, ArrayList includePaths, HashMap configPreferences) + throws RunnerException + { + //logger.debug("compileLibraries: start"); + for (File libraryFolder : sketch.getImportedLibraries()) + { + File outputFolder = new File(buildPath, libraryFolder.getName()); + File utilityFolder = new File(libraryFolder, "utility"); + createFolder(outputFolder); + // this library can use includes in its utility/ folder + this.includePaths.add(utilityFolder.getAbsolutePath()); + this.objectFiles.addAll(compileFiles(avrBasePath, + outputFolder.getAbsolutePath(), includePaths, + findFilesInFolder(libraryFolder, "S", false), + findFilesInFolder(libraryFolder, "c", false), + findFilesInFolder(libraryFolder, "cpp", false), + configPreferences)); + outputFolder = new File(outputFolder, "utility"); + createFolder(outputFolder); + this.objectFiles.addAll(compileFiles(avrBasePath, + outputFolder.getAbsolutePath(), includePaths, + findFilesInFolder(utilityFolder, "S", false), + findFilesInFolder(utilityFolder, "c", false), + findFilesInFolder(utilityFolder, "cpp", false), + configPreferences)); + // other libraries should not see this library's utility/ folder + this.includePaths.remove(includePaths.size() - 1); + } + } + + // 3. compile the core, outputting .o files to and then + // collecting them into the core.a library file. + void compileCore (String avrBasePath, String buildPath, String corePath, HashMap configPreferences) + throws RunnerException + { + //logger.debug("compileCore(...) start"); + + ArrayList includePaths = new ArrayList(); + includePaths.add(corePath); //include core path only + String baseCommandString = configPreferences.get("recipe.ar.pattern"); + String commandString = ""; + MessageFormat compileFormat = new MessageFormat(baseCommandString); + + List coreObjectFiles = compileFiles( + avrBasePath, + buildPath, + includePaths, + findFilesInPath(corePath, "S", true), + findFilesInPath(corePath, "c", true), + findFilesInPath(corePath, "cpp", true), + configPreferences); + + for (File file : coreObjectFiles) { + //List commandAR = new ArrayList(baseCommandAR); + //commandAR = commandAR + file.getAbsolutePath(); + + Object[] Args = { + avrBasePath, + configPreferences.get("compiler.ar.cmd"), + configPreferences.get("compiler.ar.flags"), + //corePath, + buildPath + File.separator, + "core.a", + //objectName + file.getAbsolutePath() + }; + commandString = compileFormat.format( Args ); + execAsynchronously(commandString); + } + } + + // 4. link it all together into the .elf file + void compileLink(String avrBasePath, String buildPath, String corePath, ArrayList includePaths, HashMap configPreferences) + throws RunnerException + { + //logger.debug("compileLink: start"); + String baseCommandString = configPreferences.get("recipe.c.combine.pattern"); + String commandString = ""; + MessageFormat compileFormat = new MessageFormat(baseCommandString); + String objectFileList = ""; + + for (File file : objectFiles) { + objectFileList = objectFileList + file.getAbsolutePath() + "::"; + } + + Object[] Args = { + avrBasePath, + configPreferences.get("compiler.c.elf.cmd"), + configPreferences.get("compiler.c.elf.flags"), + configPreferences.get("compiler.cpudef"), + configPreferences.get("build.mcu"), + buildPath + File.separator, + primaryClassName, + objectFileList, + buildPath + File.separator + "core.a", + buildPath, + corePath, + configPreferences.get("ldscript"), + }; + commandString = compileFormat.format( Args ); + execAsynchronously(commandString); + } + + // 5. extract EEPROM data (from EEMEM directive) to .eep file. + void compileEep (String avrBasePath, String buildPath, ArrayList includePaths, HashMap configPreferences) + throws RunnerException + { + //logger.debug("compileEep: start"); + String baseCommandString = configPreferences.get("recipe.objcopy.eep.pattern"); + String commandString = ""; + MessageFormat compileFormat = new MessageFormat(baseCommandString); + String objectFileList = ""; + + Object[] Args = { + avrBasePath, + configPreferences.get("compiler.objcopy.cmd"), + configPreferences.get("compiler.objcopy.eep.flags"), + buildPath + File.separator + primaryClassName, + buildPath + File.separator + primaryClassName + }; + commandString = compileFormat.format( Args ); + + execAsynchronously(commandString); + } + + // 6. build the .hex file + void compileHex (String avrBasePath, String buildPath, ArrayList includePaths, HashMap configPreferences) + throws RunnerException + { + //logger.debug("compileHex: start"); + String baseCommandString = configPreferences.get("recipe.objcopy.hex.pattern"); + String commandString = ""; + MessageFormat compileFormat = new MessageFormat(baseCommandString); + String objectFileList = ""; + + Object[] Args = { + avrBasePath, + configPreferences.get("compiler.elf2hex.cmd"), + configPreferences.get("compiler.elf2hex.flags"), + buildPath + File.separator + primaryClassName, + buildPath + File.separator + primaryClassName + }; + commandString = compileFormat.format( Args ); + + execAsynchronously(commandString); + + } + + + + //merge all the preferences file in the correct order of precedence HashMap mergePreferences(Map Preferences, Map platformPreferences, Map boardPreferences) { From f977f5f3c80153c928df1f3bd45f4221293c1d9a Mon Sep 17 00:00:00 2001 From: ricklon Date: Wed, 15 Jun 2011 19:18:07 -0400 Subject: [PATCH 09/16] Updated preferences.txt to have a default platform=avr --- build/shared/lib/preferences.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/build/shared/lib/preferences.txt b/build/shared/lib/preferences.txt index bca71bfd9..336d94a96 100755 --- a/build/shared/lib/preferences.txt +++ b/build/shared/lib/preferences.txt @@ -239,6 +239,7 @@ run.present.exclusive.macosx = true # ARDUINO PREFERENCES board = uno target = arduino +platform = avr programmer = arduino:avrispmkii From b0556c2e74d78a52a594da74b898317454109d9a Mon Sep 17 00:00:00 2001 From: ricklon Date: Wed, 15 Jun 2011 23:04:38 -0400 Subject: [PATCH 10/16] Changed :: to , for platforms.txt. Also, changes to compile process to support execAsynchronously changed to Stringp[] --- app/src/processing/app/debug/Compiler.java | 141 ++++++++++++++++++--- hardware/arduino/platforms.txt | 38 +++--- 2 files changed, 139 insertions(+), 40 deletions(-) diff --git a/app/src/processing/app/debug/Compiler.java b/app/src/processing/app/debug/Compiler.java index 1b19435a8..a83cd7c9c 100644 --- a/app/src/processing/app/debug/Compiler.java +++ b/app/src/processing/app/debug/Compiler.java @@ -209,7 +209,7 @@ public class Compiler implements MessageConsumer { // 3. compile the core, outputting .o files to and then // collecting them into the core.a library file. - +/* includePaths.clear(); includePaths.add(corePath); // include path for core only if (pinsPath != null) includePaths.add(pinsPath); @@ -231,9 +231,9 @@ public class Compiler implements MessageConsumer { commandAR.add(file.getAbsolutePath()); execAsynchronously(commandAR); } - +*/ // 4. link it all together into the .elf file - +/* List baseCommandLinker = new ArrayList(Arrays.asList(new String[] { avrBasePath + "avr-gcc", "-Os", @@ -260,8 +260,10 @@ public class Compiler implements MessageConsumer { })); List commandObjcopy; +*/ // 5. extract EEPROM data (from EEMEM directive) to .eep file. +/* commandObjcopy = new ArrayList(baseCommandObjcopy); commandObjcopy.add(2, "ihex"); commandObjcopy.set(3, "-j"); @@ -281,6 +283,7 @@ public class Compiler implements MessageConsumer { commandObjcopy.add(buildPath + File.separator + primaryClassName + ".elf"); commandObjcopy.add(buildPath + File.separator + primaryClassName + ".hex"); execAsynchronously(commandObjcopy); +*/ return true; /* @@ -348,7 +351,7 @@ public class Compiler implements MessageConsumer { execAsynchronously(getCommandCompilerS(avrBasePath, includePaths, file.getAbsolutePath(), objectPath, - boardPreferences)); + configPreferences)); } for (File file : cSources) { @@ -357,7 +360,7 @@ public class Compiler implements MessageConsumer { execAsynchronously(getCommandCompilerC(avrBasePath, includePaths, file.getAbsolutePath(), objectPath, - boardPreferences)); + configPreferences)); } for (File file : cppSources) { @@ -366,7 +369,7 @@ public class Compiler implements MessageConsumer { execAsynchronously(getCommandCompilerCPP(avrBasePath, includePaths, file.getAbsolutePath(), objectPath, - boardPreferences)); + configPreferences)); } return objectPaths; @@ -379,9 +382,9 @@ public class Compiler implements MessageConsumer { /** * Either succeeds or throws a RunnerException fit for public consumption. */ - private void execAsynchronously(List commandList) throws RunnerException { - String[] command = new String[commandList.size()]; - commandList.toArray(command); + private void execAsynchronously(String[] command) throws RunnerException { + // String[] command = new String[commandList.size()]; + //commandList.toArray(command); int result = 0; if (verbose || Preferences.getBoolean("build.verbose")) { @@ -504,7 +507,7 @@ public class Compiler implements MessageConsumer { } ///////////////////////////////////////////////////////////////////////////// - +/* static private List getCommandCompilerS(String avrBasePath, List includePaths, String sourceName, String objectName, Map boardPreferences) { List baseCommandCompiler = new ArrayList(Arrays.asList(new String[] { @@ -526,7 +529,39 @@ public class Compiler implements MessageConsumer { return baseCommandCompiler; } +*/ + // /////////////////////////////////////////////////////////////////////////// + static private String[] getCommandCompilerS(String avrBasePath, + ArrayList includePaths, String sourceName, String objectName, + HashMap configPreferences) + { + System.out.println("getCommandCompilerS: start"); + String baseCommandString = configPreferences.get("recipe.cpp.o.pattern"); + MessageFormat compileFormat = new MessageFormat(baseCommandString); + //getIncludes to String + + String includes = preparePaths(includePaths); + Object[] Args = { + avrBasePath, + configPreferences.get("compiler.cpp.cmd"), + configPreferences.get("compiler.S.flags"), + configPreferences.get("compiler.cpudef"), + configPreferences.get("build.mcu"), + configPreferences.get("build.f_cpu"), + configPreferences.get("board"), + Base.REVISION, + includes, + sourceName, + objectName + }; + + String command = compileFormat.format( Args ); + String[] commandArray = command.split(","); + return commandArray; + } + +/* static private List getCommandCompilerC(String avrBasePath, List includePaths, String sourceName, String objectName, Map boardPreferences) { @@ -553,7 +588,38 @@ public class Compiler implements MessageConsumer { return baseCommandCompiler; } + */ + //removed static + private String[] getCommandCompilerC(String avrBasePath, + ArrayList includePaths, String sourceName, String objectName, + HashMap configPreferences) + { + System.out.println("getCommandCompilerC: start"); + String baseCommandString = configPreferences.get("recipe.c.o.pattern"); + MessageFormat compileFormat = new MessageFormat(baseCommandString); + //getIncludes to String + String includes = preparePaths(includePaths); + + Object[] Args = { + avrBasePath, + configPreferences.get("compiler.c.cmd"), + configPreferences.get("compiler.c.flags"), + configPreferences.get("compiler.cpudef"), + configPreferences.get("build.mcu"), + configPreferences.get("build.f_cpu"), + configPreferences.get("board"), + Base.REVISION, + includes, + sourceName, + objectName + }; + + String command = compileFormat.format( Args ); + String[] commandArray = command.split(","); + return commandArray; + } +/* static private List getCommandCompilerCPP(String avrBasePath, List includePaths, String sourceName, String objectName, @@ -582,7 +648,37 @@ public class Compiler implements MessageConsumer { return baseCommandCompilerCPP; } +*/ + static private String[] getCommandCompilerCPP(String avrBasePath, + ArrayList includePaths, String sourceName, String objectName, + HashMap configPreferences) + { + System.out.println("getCommandCompilerCPP: start"); + String baseCommandString = configPreferences.get("recipe.cpp.o.pattern"); + MessageFormat compileFormat = new MessageFormat(baseCommandString); + //getIncludes to String + String includes = preparePaths(includePaths); + + Object[] Args = { + avrBasePath, + configPreferences.get("compiler.cpp.cmd"), + configPreferences.get("compiler.cpp.flags"), + configPreferences.get("compiler.cpudef"), + configPreferences.get("build.mcu"), + configPreferences.get("build.f_cpu"), + configPreferences.get("board"), + Base.REVISION, + includes, + sourceName, + objectName + }; + + String command = compileFormat.format( Args ); + System.out.println("command:" + command); + String[] commandArray = command.split(","); + return commandArray; + } ///////////////////////////////////////////////////////////////////////////// @@ -714,8 +810,12 @@ public class Compiler implements MessageConsumer { //objectName file.getAbsolutePath() }; + commandString = compileFormat.format( Args ); - execAsynchronously(commandString); + String[] commandArray = commandString.split(","); + execAsynchronously(commandArray); + + } } @@ -730,7 +830,7 @@ public class Compiler implements MessageConsumer { String objectFileList = ""; for (File file : objectFiles) { - objectFileList = objectFileList + file.getAbsolutePath() + "::"; + objectFileList = objectFileList + file.getAbsolutePath() + ","; } Object[] Args = { @@ -747,8 +847,8 @@ public class Compiler implements MessageConsumer { corePath, configPreferences.get("ldscript"), }; - commandString = compileFormat.format( Args ); - execAsynchronously(commandString); + String[] commandArray = commandString.split(","); + execAsynchronously(commandArray); } // 5. extract EEPROM data (from EEMEM directive) to .eep file. @@ -769,8 +869,8 @@ public class Compiler implements MessageConsumer { buildPath + File.separator + primaryClassName }; commandString = compileFormat.format( Args ); - - execAsynchronously(commandString); + String[] commandArray = commandString.split(","); + execAsynchronously(commandArray); } // 6. build the .hex file @@ -790,10 +890,9 @@ public class Compiler implements MessageConsumer { buildPath + File.separator + primaryClassName, buildPath + File.separator + primaryClassName }; - commandString = compileFormat.format( Args ); - - execAsynchronously(commandString); - + commandString = compileFormat.format( Args ); + String[] commandArray = commandString.split(","); + execAsynchronously(commandArray); } @@ -867,7 +966,7 @@ public class Compiler implements MessageConsumer { String includes = ""; for (int i = 0; i < includePaths.size(); i++) { - includes = includes + (" -I" + (String) includePaths.get(i)) + "::"; + includes = includes + (" -I" + (String) includePaths.get(i)) + ","; } //logger.debug("Paths prepared: " + includes); return includes; diff --git a/hardware/arduino/platforms.txt b/hardware/arduino/platforms.txt index ce35a3b36..d3a4c1bc4 100755 --- a/hardware/arduino/platforms.txt +++ b/hardware/arduino/platforms.txt @@ -2,38 +2,38 @@ ##compile c object files ##Default.recipe, overide if overide exists, these defauls should remain the same, if you need to change them do it as an overide. -#default.recipe.c.o.pattern={0}{1}::{2}::{3}{4}::-DF_CPU={5}::-D{6}={7}::{8}::{9}::-o::{10} -#default.recipe.cpp.o.pattern={0}{1}::{2}::{3}{4}::-DF_CPU={5}::-D{6}={7}::{8}::{9}::-o::{10} -#default.recipe.ar.pattern={0}{1}::{2}::{3}{4}::{5} -#default.recipe.c.combine.pattern={0}{1}::{2}::{3}{4}::-o::{5}{6}.elf::{7}::{8}::-L{9}::-lm -#default.recipe.objcopy.eep.pattern={0}{1}::{2}::{3}.elf::{4}.eep -#default.recipe.objcopy.hex.pattern={0}{1}::{2}::{3}.elf::{4}.hex +#default.recipe.c.o.pattern={0}{1},{2},{3}{4},-DF_CPU={5},-D{6}={7},{8},{9},-o,{10} +#default.recipe.cpp.o.pattern={0}{1},{2},{3}{4},-DF_CPU={5},-D{6}={7},{8},{9},-o,{10} +#default.recipe.ar.pattern={0}{1},{2},{3}{4},{5} +#default.recipe.c.combine.pattern={0}{1},{2},{3}{4},-o,{5}{6}.elf,{7},{8},-L{9},-lm +#default.recipe.objcopy.eep.pattern={0}{1},{2},{3}.elf,{4}.eep +#default.recipe.objcopy.hex.pattern={0}{1},{2},{3}.elf,{4}.hex ########avr compile pattern ########## #avr.recipe.c.o.pattern={0=compiler.path}{1=compiler.c.cmd}{2=compiler.c.flags}{3=compiler.cpudef}{4=build.mcu}-DF_CPU={5=build.f_cpu}-D{7=ARDUINO}={6=Base.REVISION}{7=-I/INCLUDE_PATHS} {8=SOURCE_NAME} -o{9=OBJECT_NAME} #object name seems to have build path in it. -avr.recipe.c.o.pattern={0}{1}::{2}::{3}{4}::-DF_CPU={5}::-D{6}={7}::{8}::{9}::-o::{10} +avr.recipe.c.o.pattern={0}{1},{2},{3}{4},-DF_CPU={5},-D{6}={7},{8},{9},-o,{10} ##compile cc object files #avr.recipe.cc.o.pattern={0=compiler.path}{1=compiler.cc.cmd}{2=compiler.c.flags}{3=compiler.cpudef}{4=build.mcu}-DF_CPU={5=build.f_cpu}-DARDUINO={6=Base.REVISION}{-7=I/INCLUDE_PATHS} {8=SOURCE_NAME} -o{9=BUILD_PATH}{10=OBJECT_NAME} -avr.recipe.cpp.o.pattern={0}{1}::{2}::{3}{4}::-DF_CPU={5}::-D{6}={7}::{8}::{9}::-o::{10} +avr.recipe.cpp.o.pattern={0}{1},{2},{3}{4},-DF_CPU={5},-D{6}={7},{8},{9},-o,{10} ##create archives #avr.recipe.ar.pattern={0=compiler.path}{1=compiler.ar.cmd}{2=compiler.ar.flags}{3=BUILD_PATH}{4=CORE_NAME=core.a}{5=BUILD_PATH}{6=OBJECT_NAME} -avr.recipe.ar.pattern={0}{1}::{2}::{3}{4}::{5} +avr.recipe.ar.pattern={0}{1},{2},{3}{4},{5} ##combine gc-sections, archives, and objects #avr.recipe.c.combine.pattern={0=compiler.path}{1=compiler.c.cmd}{2=compiler.combine.flags}{3=compiler.cpudef}{4=build.mcu} -o {5=BUILD_PATH}{6=SOURCE_NAME}.elf {7=BUILD_PATH}{8=SOURCE_NAME}.o {9=BUILD_PATH}{10=CORE_NAME=core.a} -L{11=BUILD_PATH} -lm -#avr.recipe.c.combine.pattern={0}{1}::{2}::{3}{4}::-o::{5}{6}.elf::{7}{8}::{9}::-L{10}::-lm -avr.recipe.c.combine.pattern={0}{1}::{2}::{3}{4}::-o::{5}{6}.elf::{7}::{8}::-L{9}::-lm +#avr.recipe.c.combine.pattern={0}{1},{2},{3}{4},-o,{5}{6}.elf,{7}{8},{9},-L{10},-lm +avr.recipe.c.combine.pattern={0}{1},{2},{3}{4},-o,{5}{6}.elf,{7},{8},-L{9},-lm ##create eeprom #avr.recipe.objcopy.eep.pattern={0=compiler.path}{1=compiler.objcopy.cmd}{2=compiler.objcopy.eep.flags} {3=BUILD_PATH}{4=SOURCE_NAME}.elf {5=BUILD_PATH}{6=SOURCE_NAME}.eep -avr.recipe.objcopy.eep.pattern={0}{1}::{2}::{3}.elf::{4}.eep +avr.recipe.objcopy.eep.pattern={0}{1},{2},{3}.elf,{4}.eep ##create hex #avr.recipe.objcopy.hex.pattern={0=compiler.path}{1=compiler.objcopy.cmd}{2=compiler.objcopy.elf.flags} {3=BUILD_PATH}{4=SOURCE_NAME}.elf {5=BUILD_PATH}{6=SOURCE_NAME}.hex -avr.recipe.objcopy.hex.pattern={0}{1}::{2}::{3}.elf::{4}.hex +avr.recipe.objcopy.hex.pattern={0}{1},{2},{3}.elf,{4}.hex @@ -42,17 +42,17 @@ avr.name=Arduino #avr.compiler.path Official default is correct, only need to change this if you want to overide the initial default #avr.compiler.path={0}/hardware/tools/avr/bin/ avr.compiler.c.cmd=avr-gcc -avr.compiler.c.flags=::-c::-g::-Os::-w::-ffunction-sections::-fdata-sections -avr.compiler.c.elf.flags=::-Os::-Wl,--gc-sections +avr.compiler.c.flags=,-c,-g,-Os,-w,-ffunction-sections,-fdata-sections +avr.compiler.c.elf.flags=,-Os,-Wl,--gc-sections avr.compiler.c.elf.cmd=avr-gcc -avr.compiler.S.flags=::-c::-g::-assembler-with-cpp +avr.compiler.S.flags=,-c,-g,-assembler-with-cpp avr.compiler.cpp.cmd=avr-g++ -avr.compiler.cpp.flags=::-c::-g::-Os::-w::-fno-exceptions::-ffunction-sections::-fdata-sections +avr.compiler.cpp.flags=,-c,-g,-Os,-w,-fno-exceptions,-ffunction-sections,-fdata-sections avr.compiler.ar.cmd=avr-ar avr.compiler.ar.flags=rcs avr.compiler.objcopy.cmd=avr-objcopy -avr.compiler.objcopy.eep.flags=::-O::ihex::-j::.eeprom::--set-section-flags=.eeprom=alloc,load::--no-change-warnings::--change-section-lma::.eeprom=0 -avr.compiler.elf2hex.flags=::-O::ihex::-R::.eeprom +avr.compiler.objcopy.eep.flags=,-O,ihex,-j,.eeprom,--set-section-flags=.eeprom=alloc,load,--no-change-warnings,--change-section-lma,.eeprom=0 +avr.compiler.elf2hex.flags=,-O,ihex,-R,.eeprom avr.compiler.elf2hex.cmd=avr-objcopy avr.compiler.ldflags= avr.compiler.cpudef=-mmcu= From 72c4404c6d92c06aad2c43bf841fedbcb17c9822 Mon Sep 17 00:00:00 2001 From: ricklon Date: Thu, 16 Jun 2011 20:36:39 -0400 Subject: [PATCH 11/16] Fixed compile process up to step 4. asyncExec cannot have null argmuments from the array. --- app/src/processing/app/debug/Compiler.java | 132 +++++++++++++++------ 1 file changed, 94 insertions(+), 38 deletions(-) diff --git a/app/src/processing/app/debug/Compiler.java b/app/src/processing/app/debug/Compiler.java index a83cd7c9c..2ae80145b 100644 --- a/app/src/processing/app/debug/Compiler.java +++ b/app/src/processing/app/debug/Compiler.java @@ -97,16 +97,19 @@ public class Compiler implements MessageConsumer { platformPreferences = new HashMap(Base.getPlatformPreferences(platform)); } - + System.out.println("////////////////////////////compiler.java is doing stuff/////////////////"); //Put all the global preference configuration into one Master configpreferences configPreferences = mergePreferences( Preferences.getMap(), platformPreferences, boardPreferences); avrBasePath = configPreferences.get("compiler.path"); if (avrBasePath == null) { avrBasePath = Base.getAvrBasePath(); + System.out.println("avrBasePath: " + avrBasePath); } else { + System.out.println("avrBasePath:exists: " + avrBasePath); + //Put in the system path in the compiler path if available MessageFormat compileFormat = new MessageFormat(avrBasePath); String basePath = System.getProperty("user.dir"); @@ -116,6 +119,8 @@ public class Compiler implements MessageConsumer { } Object[] Args = {basePath}; avrBasePath = compileFormat.format( Args ); + System.out.println("avrBasePath:new: " + avrBasePath); + } this.board = configPreferences.get("board"); @@ -159,7 +164,7 @@ public class Compiler implements MessageConsumer { } } - List objectFiles = new ArrayList(); + objectFiles = new ArrayList(); // 0. include paths for core + all libraries @@ -171,6 +176,7 @@ public class Compiler implements MessageConsumer { } // 1. compile the sketch (already in the buildPath) + System.out.println("1. compileSketch"); compileSketch(avrBasePath, buildPath, includePaths, configPreferences); /* objectFiles.addAll( @@ -182,6 +188,12 @@ public class Compiler implements MessageConsumer { */ // 2. compile the libraries, outputting .o files to: // + // 2. compile the libraries, outputting .o files to: + // // + //Doesn't really use configPreferences + System.out.println("2. compileLibraries"); + compileLibraries(avrBasePath, buildPath, includePaths, configPreferences); +/* for (File libraryFolder : sketch.getImportedLibraries()) { File outputFolder = new File(buildPath, libraryFolder.getName()); @@ -206,9 +218,15 @@ public class Compiler implements MessageConsumer { // other libraries should not see this library's utility/ folder includePaths.remove(includePaths.size() - 1); } +*/ // 3. compile the core, outputting .o files to and then // collecting them into the core.a library file. + System.out.println("3. compileCore"); + System.out.println("corePath: " + corePath); + compileCore(avrBasePath, buildPath, corePath, pins, pinsPath, configPreferences); + + /* includePaths.clear(); includePaths.add(corePath); // include path for core only @@ -233,6 +251,9 @@ public class Compiler implements MessageConsumer { } */ // 4. link it all together into the .elf file + System.out.println("4. compileLink"); + compileLink(avrBasePath, buildPath, corePath, includePaths, configPreferences); + /* List baseCommandLinker = new ArrayList(Arrays.asList(new String[] { avrBasePath + "avr-gcc", @@ -263,6 +284,9 @@ public class Compiler implements MessageConsumer { */ // 5. extract EEPROM data (from EEMEM directive) to .eep file. + System.out.println("5. compileEep"); + compileEep(avrBasePath, buildPath, includePaths, configPreferences); + /* commandObjcopy = new ArrayList(baseCommandObjcopy); commandObjcopy.add(2, "ihex"); @@ -275,8 +299,13 @@ public class Compiler implements MessageConsumer { commandObjcopy.add(buildPath + File.separator + primaryClassName + ".elf"); commandObjcopy.add(buildPath + File.separator + primaryClassName + ".eep"); execAsynchronously(commandObjcopy); +*/ // 6. build the .hex file + System.out.println("6. compileHex"); + compileHex(avrBasePath, buildPath, includePaths, configPreferences); + +/* commandObjcopy = new ArrayList(baseCommandObjcopy); commandObjcopy.add(2, "ihex"); commandObjcopy.add(".eeprom"); // remove eeprom data @@ -383,8 +412,17 @@ public class Compiler implements MessageConsumer { * Either succeeds or throws a RunnerException fit for public consumption. */ private void execAsynchronously(String[] command) throws RunnerException { - // String[] command = new String[commandList.size()]; - //commandList.toArray(command); + + //eliminate any empty array entries + List stringList = new ArrayList(); + for(String string : command) { + string = string.trim(); + if(string != null && string.length() > 0) { + stringList.add(string); + } + } + command = stringList.toArray(new String[stringList.size()]); + int result = 0; if (verbose || Preferences.getBoolean("build.verbose")) { @@ -443,6 +481,7 @@ public class Compiler implements MessageConsumer { re.hideStackTrace(); throw re; } + System.out.println("execAsync: Done."); } @@ -675,8 +714,15 @@ public class Compiler implements MessageConsumer { }; String command = compileFormat.format( Args ); - System.out.println("command:" + command); String[] commandArray = command.split(","); + + /* + System.out.println("command:" + command); + for (int ii = 0; ii < commandArray.length; ii++) + { + System.out.println("'" + commandArray[ii] + "'"); + } + */ return commandArray; } @@ -706,6 +752,7 @@ public class Compiler implements MessageConsumer { static public ArrayList findFilesInPath(String path, String extension, boolean recurse) { + System.out.println("findFilesInPath: " + path); return findFilesInFolder(new File(path), extension, recurse); } @@ -747,46 +794,49 @@ public class Compiler implements MessageConsumer { void compileLibraries (String avrBasePath, String buildPath, ArrayList includePaths, HashMap configPreferences) throws RunnerException { - //logger.debug("compileLibraries: start"); - for (File libraryFolder : sketch.getImportedLibraries()) - { - File outputFolder = new File(buildPath, libraryFolder.getName()); - File utilityFolder = new File(libraryFolder, "utility"); - createFolder(outputFolder); - // this library can use includes in its utility/ folder - this.includePaths.add(utilityFolder.getAbsolutePath()); - this.objectFiles.addAll(compileFiles(avrBasePath, - outputFolder.getAbsolutePath(), includePaths, - findFilesInFolder(libraryFolder, "S", false), - findFilesInFolder(libraryFolder, "c", false), - findFilesInFolder(libraryFolder, "cpp", false), - configPreferences)); - outputFolder = new File(outputFolder, "utility"); - createFolder(outputFolder); - this.objectFiles.addAll(compileFiles(avrBasePath, - outputFolder.getAbsolutePath(), includePaths, - findFilesInFolder(utilityFolder, "S", false), - findFilesInFolder(utilityFolder, "c", false), - findFilesInFolder(utilityFolder, "cpp", false), - configPreferences)); - // other libraries should not see this library's utility/ folder - this.includePaths.remove(includePaths.size() - 1); - } - } + System.out.println("compileLibraries: start"); + + for (File libraryFolder : sketch.getImportedLibraries()) { + System.out.println("libraryFolder: " + libraryFolder); + File outputFolder = new File(buildPath, libraryFolder.getName()); + File utilityFolder = new File(libraryFolder, "utility"); + createFolder(outputFolder); + // this library can use includes in its utility/ folder + includePaths.add(utilityFolder.getAbsolutePath()); + objectFiles.addAll( + compileFiles(avrBasePath, outputFolder.getAbsolutePath(), includePaths, + findFilesInFolder(libraryFolder, "S", false), + findFilesInFolder(libraryFolder, "c", false), + findFilesInFolder(libraryFolder, "cpp", false), + boardPreferences)); + outputFolder = new File(outputFolder, "utility"); + createFolder(outputFolder); + objectFiles.addAll( + compileFiles(avrBasePath, outputFolder.getAbsolutePath(), includePaths, + findFilesInFolder(utilityFolder, "S", false), + findFilesInFolder(utilityFolder, "c", false), + findFilesInFolder(utilityFolder, "cpp", false), + boardPreferences)); + // other libraries should not see this library's utility/ folder + includePaths.remove(includePaths.size() - 1); + } + } // 3. compile the core, outputting .o files to and then // collecting them into the core.a library file. - void compileCore (String avrBasePath, String buildPath, String corePath, HashMap configPreferences) + void compileCore (String avrBasePath, String buildPath, String corePath, String pins, String pinsPath, HashMap configPreferences) throws RunnerException { - //logger.debug("compileCore(...) start"); + System.out.println("compileCore(...) start"); ArrayList includePaths = new ArrayList(); includePaths.add(corePath); //include core path only + if (pinsPath != null) includePaths.add(pinsPath); + String baseCommandString = configPreferences.get("recipe.ar.pattern"); String commandString = ""; MessageFormat compileFormat = new MessageFormat(baseCommandString); - + System.out.println("corePath: " + corePath); List coreObjectFiles = compileFiles( avrBasePath, buildPath, @@ -810,6 +860,7 @@ public class Compiler implements MessageConsumer { //objectName file.getAbsolutePath() }; + System.out.println("compileCore(...) substitute"); commandString = compileFormat.format( Args ); String[] commandArray = commandString.split(","); @@ -823,8 +874,9 @@ public class Compiler implements MessageConsumer { void compileLink(String avrBasePath, String buildPath, String corePath, ArrayList includePaths, HashMap configPreferences) throws RunnerException { - //logger.debug("compileLink: start"); + System.out.println("compileLink: start"); String baseCommandString = configPreferences.get("recipe.c.combine.pattern"); + System.out.println("baseCommandstring: " + baseCommandString); String commandString = ""; MessageFormat compileFormat = new MessageFormat(baseCommandString); String objectFileList = ""; @@ -832,6 +884,7 @@ public class Compiler implements MessageConsumer { for (File file : objectFiles) { objectFileList = objectFileList + file.getAbsolutePath() + ","; } + System.out.println("objectFileList: " + objectFileList); Object[] Args = { avrBasePath, @@ -848,6 +901,12 @@ public class Compiler implements MessageConsumer { configPreferences.get("ldscript"), }; String[] commandArray = commandString.split(","); + System.out.println("commandString: " + commandString); + for (int ii = 0; ii < commandArray.length; ii++) + { + System.out.println("'" + commandArray[ii] + "'"); + } + System.out.println("4. compileLink:prexec"); execAsynchronously(commandArray); } @@ -894,9 +953,6 @@ public class Compiler implements MessageConsumer { String[] commandArray = commandString.split(","); execAsynchronously(commandArray); } - - - //merge all the preferences file in the correct order of precedence HashMap mergePreferences(Map Preferences, Map platformPreferences, Map boardPreferences) From a57f35fb5114e7721785c5c6ee0c7ada3712ad32 Mon Sep 17 00:00:00 2001 From: ricklon Date: Thu, 16 Jun 2011 23:17:08 -0400 Subject: [PATCH 12/16] Fixed the missing line for messageformat args. --- app/src/processing/app/debug/Compiler.java | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/processing/app/debug/Compiler.java b/app/src/processing/app/debug/Compiler.java index 2ae80145b..72e176576 100644 --- a/app/src/processing/app/debug/Compiler.java +++ b/app/src/processing/app/debug/Compiler.java @@ -900,6 +900,7 @@ public class Compiler implements MessageConsumer { corePath, configPreferences.get("ldscript"), }; + commandString = compileFormat.format( Args ); String[] commandArray = commandString.split(","); System.out.println("commandString: " + commandString); for (int ii = 0; ii < commandArray.length; ii++) From 67c9dfc6679ff231076afcb0546ffc5190179420 Mon Sep 17 00:00:00 2001 From: ricklon Date: Fri, 17 Jun 2011 00:54:58 -0400 Subject: [PATCH 13/16] A bit of cleanup. Delimeter not figured out yet. --- app/src/processing/app/debug/Compiler.java | 25 +++++--------- hardware/arduino/platforms.txt | 40 +++++++++++----------- 2 files changed, 29 insertions(+), 36 deletions(-) diff --git a/app/src/processing/app/debug/Compiler.java b/app/src/processing/app/debug/Compiler.java index 72e176576..a31837bcf 100644 --- a/app/src/processing/app/debug/Compiler.java +++ b/app/src/processing/app/debug/Compiler.java @@ -596,7 +596,7 @@ public class Compiler implements MessageConsumer { }; String command = compileFormat.format( Args ); - String[] commandArray = command.split(","); + String[] commandArray = command.split("\|"); return commandArray; } @@ -655,7 +655,7 @@ public class Compiler implements MessageConsumer { }; String command = compileFormat.format( Args ); - String[] commandArray = command.split(","); + String[] commandArray = command.split("\|"); return commandArray; } /* @@ -714,7 +714,7 @@ public class Compiler implements MessageConsumer { }; String command = compileFormat.format( Args ); - String[] commandArray = command.split(","); + String[] commandArray = command.split("\|"); /* System.out.println("command:" + command); @@ -863,7 +863,7 @@ public class Compiler implements MessageConsumer { System.out.println("compileCore(...) substitute"); commandString = compileFormat.format( Args ); - String[] commandArray = commandString.split(","); + String[] commandArray = commandString.split("\|"); execAsynchronously(commandArray); @@ -876,13 +876,12 @@ public class Compiler implements MessageConsumer { { System.out.println("compileLink: start"); String baseCommandString = configPreferences.get("recipe.c.combine.pattern"); - System.out.println("baseCommandstring: " + baseCommandString); String commandString = ""; MessageFormat compileFormat = new MessageFormat(baseCommandString); String objectFileList = ""; for (File file : objectFiles) { - objectFileList = objectFileList + file.getAbsolutePath() + ","; + objectFileList = objectFileList + file.getAbsolutePath() + "\|"; } System.out.println("objectFileList: " + objectFileList); @@ -901,13 +900,7 @@ public class Compiler implements MessageConsumer { configPreferences.get("ldscript"), }; commandString = compileFormat.format( Args ); - String[] commandArray = commandString.split(","); - System.out.println("commandString: " + commandString); - for (int ii = 0; ii < commandArray.length; ii++) - { - System.out.println("'" + commandArray[ii] + "'"); - } - System.out.println("4. compileLink:prexec"); + String[] commandArray = commandString.split("\|"); execAsynchronously(commandArray); } @@ -929,7 +922,7 @@ public class Compiler implements MessageConsumer { buildPath + File.separator + primaryClassName }; commandString = compileFormat.format( Args ); - String[] commandArray = commandString.split(","); + String[] commandArray = commandString.split("\|"); execAsynchronously(commandArray); } @@ -951,7 +944,7 @@ public class Compiler implements MessageConsumer { buildPath + File.separator + primaryClassName }; commandString = compileFormat.format( Args ); - String[] commandArray = commandString.split(","); + String[] commandArray = commandString.split("\|"); execAsynchronously(commandArray); } @@ -1023,7 +1016,7 @@ public class Compiler implements MessageConsumer { String includes = ""; for (int i = 0; i < includePaths.size(); i++) { - includes = includes + (" -I" + (String) includePaths.get(i)) + ","; + includes = includes + (" -I" + (String) includePaths.get(i)) + "\|"; } //logger.debug("Paths prepared: " + includes); return includes; diff --git a/hardware/arduino/platforms.txt b/hardware/arduino/platforms.txt index d3a4c1bc4..3f1d2eb7d 100755 --- a/hardware/arduino/platforms.txt +++ b/hardware/arduino/platforms.txt @@ -2,38 +2,38 @@ ##compile c object files ##Default.recipe, overide if overide exists, these defauls should remain the same, if you need to change them do it as an overide. -#default.recipe.c.o.pattern={0}{1},{2},{3}{4},-DF_CPU={5},-D{6}={7},{8},{9},-o,{10} -#default.recipe.cpp.o.pattern={0}{1},{2},{3}{4},-DF_CPU={5},-D{6}={7},{8},{9},-o,{10} -#default.recipe.ar.pattern={0}{1},{2},{3}{4},{5} -#default.recipe.c.combine.pattern={0}{1},{2},{3}{4},-o,{5}{6}.elf,{7},{8},-L{9},-lm -#default.recipe.objcopy.eep.pattern={0}{1},{2},{3}.elf,{4}.eep -#default.recipe.objcopy.hex.pattern={0}{1},{2},{3}.elf,{4}.hex +#default.recipe.c.o.pattern={0}{1}|{2}|{3}{4}|-DF_CPU={5}|-D{6}={7}|{8}|{9}|-o|{10} +#default.recipe.cpp.o.pattern={0}{1}|{2}|{3}{4}|-DF_CPU={5}|-D{6}={7}|{8}|{9}|-o|{10} +#default.recipe.ar.pattern={0}{1}|{2}|{3}{4}|{5} +#default.recipe.c.combine.pattern={0}{1}|{2}|{3}{4}|-o|{5}{6}.elf|{7}|{8}|-L{9}|-lm +#default.recipe.objcopy.eep.pattern={0}{1}|{2}|{3}.elf|{4}.eep +#default.recipe.objcopy.hex.pattern={0}{1}|{2}|{3}.elf|{4}.hex ########avr compile pattern ########## #avr.recipe.c.o.pattern={0=compiler.path}{1=compiler.c.cmd}{2=compiler.c.flags}{3=compiler.cpudef}{4=build.mcu}-DF_CPU={5=build.f_cpu}-D{7=ARDUINO}={6=Base.REVISION}{7=-I/INCLUDE_PATHS} {8=SOURCE_NAME} -o{9=OBJECT_NAME} #object name seems to have build path in it. -avr.recipe.c.o.pattern={0}{1},{2},{3}{4},-DF_CPU={5},-D{6}={7},{8},{9},-o,{10} +avr.recipe.c.o.pattern={0}{1}|{2}|{3}{4}|-DF_CPU={5}|-D{6}={7}|{8}|{9}|-o|{10} ##compile cc object files #avr.recipe.cc.o.pattern={0=compiler.path}{1=compiler.cc.cmd}{2=compiler.c.flags}{3=compiler.cpudef}{4=build.mcu}-DF_CPU={5=build.f_cpu}-DARDUINO={6=Base.REVISION}{-7=I/INCLUDE_PATHS} {8=SOURCE_NAME} -o{9=BUILD_PATH}{10=OBJECT_NAME} -avr.recipe.cpp.o.pattern={0}{1},{2},{3}{4},-DF_CPU={5},-D{6}={7},{8},{9},-o,{10} +avr.recipe.cpp.o.pattern={0}{1}|{2}|{3}{4}|-DF_CPU={5}|-D{6}={7}|{8}|{9}|-o|{10} ##create archives #avr.recipe.ar.pattern={0=compiler.path}{1=compiler.ar.cmd}{2=compiler.ar.flags}{3=BUILD_PATH}{4=CORE_NAME=core.a}{5=BUILD_PATH}{6=OBJECT_NAME} -avr.recipe.ar.pattern={0}{1},{2},{3}{4},{5} +avr.recipe.ar.pattern={0}{1}|{2}|{3}{4}|{5} -##combine gc-sections, archives, and objects +##combine gc-sections| archives, and objects #avr.recipe.c.combine.pattern={0=compiler.path}{1=compiler.c.cmd}{2=compiler.combine.flags}{3=compiler.cpudef}{4=build.mcu} -o {5=BUILD_PATH}{6=SOURCE_NAME}.elf {7=BUILD_PATH}{8=SOURCE_NAME}.o {9=BUILD_PATH}{10=CORE_NAME=core.a} -L{11=BUILD_PATH} -lm -#avr.recipe.c.combine.pattern={0}{1},{2},{3}{4},-o,{5}{6}.elf,{7}{8},{9},-L{10},-lm -avr.recipe.c.combine.pattern={0}{1},{2},{3}{4},-o,{5}{6}.elf,{7},{8},-L{9},-lm +#avr.recipe.c.combine.pattern={0}{1}|{2}|{3}{4}|-o|{5}{6}.elf|{7}{8}|{9}|-L{10}|-lm +avr.recipe.c.combine.pattern={0}{1}|{2}|{3}{4}|-o|{5}{6}.elf|{7}|{8}|-L{9}|-lm ##create eeprom #avr.recipe.objcopy.eep.pattern={0=compiler.path}{1=compiler.objcopy.cmd}{2=compiler.objcopy.eep.flags} {3=BUILD_PATH}{4=SOURCE_NAME}.elf {5=BUILD_PATH}{6=SOURCE_NAME}.eep -avr.recipe.objcopy.eep.pattern={0}{1},{2},{3}.elf,{4}.eep +avr.recipe.objcopy.eep.pattern={0}{1}|{2}|{3}.elf|{4}.eep ##create hex #avr.recipe.objcopy.hex.pattern={0=compiler.path}{1=compiler.objcopy.cmd}{2=compiler.objcopy.elf.flags} {3=BUILD_PATH}{4=SOURCE_NAME}.elf {5=BUILD_PATH}{6=SOURCE_NAME}.hex -avr.recipe.objcopy.hex.pattern={0}{1},{2},{3}.elf,{4}.hex +avr.recipe.objcopy.hex.pattern={0}{1}|{2}|{3}.elf|{4}.hex @@ -42,17 +42,17 @@ avr.name=Arduino #avr.compiler.path Official default is correct, only need to change this if you want to overide the initial default #avr.compiler.path={0}/hardware/tools/avr/bin/ avr.compiler.c.cmd=avr-gcc -avr.compiler.c.flags=,-c,-g,-Os,-w,-ffunction-sections,-fdata-sections -avr.compiler.c.elf.flags=,-Os,-Wl,--gc-sections +avr.compiler.c.flags=|-c|-g|-Os|-w|-ffunction-sections|-fdata-sections +avr.compiler.c.elf.flags=|-Os|-Wl|--gc-sections avr.compiler.c.elf.cmd=avr-gcc -avr.compiler.S.flags=,-c,-g,-assembler-with-cpp +avr.compiler.S.flags=|-c|-g|-assembler-with-cpp avr.compiler.cpp.cmd=avr-g++ -avr.compiler.cpp.flags=,-c,-g,-Os,-w,-fno-exceptions,-ffunction-sections,-fdata-sections +avr.compiler.cpp.flags=|-c|-g|-Os|-w|-fno-exceptions|-ffunction-sections|-fdata-sections avr.compiler.ar.cmd=avr-ar avr.compiler.ar.flags=rcs avr.compiler.objcopy.cmd=avr-objcopy -avr.compiler.objcopy.eep.flags=,-O,ihex,-j,.eeprom,--set-section-flags=.eeprom=alloc,load,--no-change-warnings,--change-section-lma,.eeprom=0 -avr.compiler.elf2hex.flags=,-O,ihex,-R,.eeprom +avr.compiler.objcopy.eep.flags=|-O|ihex|-j|.eeprom|--set-section-flags=.eeprom=alloc|load|--no-change-warnings|--change-section-lma|.eeprom=0 +avr.compiler.elf2hex.flags=|-O|ihex|-R|.eeprom avr.compiler.elf2hex.cmd=avr-objcopy avr.compiler.ldflags= avr.compiler.cpudef=-mmcu= From aa01546b5599db1079aa29c25429dbe2f4ef93d5 Mon Sep 17 00:00:00 2001 From: ricklon Date: Fri, 17 Jun 2011 22:12:21 -0400 Subject: [PATCH 14/16] Switched to a nonconflicting delimeter |. Compile process is working. Need to make sure that it matches 1.0 process exactly. --- app/src/processing/app/debug/Compiler.java | 18 +++++++++--------- hardware/arduino/platforms.txt | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/src/processing/app/debug/Compiler.java b/app/src/processing/app/debug/Compiler.java index a31837bcf..96cbfe7a4 100644 --- a/app/src/processing/app/debug/Compiler.java +++ b/app/src/processing/app/debug/Compiler.java @@ -596,7 +596,7 @@ public class Compiler implements MessageConsumer { }; String command = compileFormat.format( Args ); - String[] commandArray = command.split("\|"); + String[] commandArray = command.split("\\|"); return commandArray; } @@ -655,7 +655,7 @@ public class Compiler implements MessageConsumer { }; String command = compileFormat.format( Args ); - String[] commandArray = command.split("\|"); + String[] commandArray = command.split("\\|"); return commandArray; } /* @@ -714,7 +714,7 @@ public class Compiler implements MessageConsumer { }; String command = compileFormat.format( Args ); - String[] commandArray = command.split("\|"); + String[] commandArray = command.split("\\|"); /* System.out.println("command:" + command); @@ -863,7 +863,7 @@ public class Compiler implements MessageConsumer { System.out.println("compileCore(...) substitute"); commandString = compileFormat.format( Args ); - String[] commandArray = commandString.split("\|"); + String[] commandArray = commandString.split("\\|"); execAsynchronously(commandArray); @@ -881,7 +881,7 @@ public class Compiler implements MessageConsumer { String objectFileList = ""; for (File file : objectFiles) { - objectFileList = objectFileList + file.getAbsolutePath() + "\|"; + objectFileList = objectFileList + file.getAbsolutePath() + "|"; } System.out.println("objectFileList: " + objectFileList); @@ -900,7 +900,7 @@ public class Compiler implements MessageConsumer { configPreferences.get("ldscript"), }; commandString = compileFormat.format( Args ); - String[] commandArray = commandString.split("\|"); + String[] commandArray = commandString.split("\\|"); execAsynchronously(commandArray); } @@ -922,7 +922,7 @@ public class Compiler implements MessageConsumer { buildPath + File.separator + primaryClassName }; commandString = compileFormat.format( Args ); - String[] commandArray = commandString.split("\|"); + String[] commandArray = commandString.split("\\|"); execAsynchronously(commandArray); } @@ -944,7 +944,7 @@ public class Compiler implements MessageConsumer { buildPath + File.separator + primaryClassName }; commandString = compileFormat.format( Args ); - String[] commandArray = commandString.split("\|"); + String[] commandArray = commandString.split("\\|"); execAsynchronously(commandArray); } @@ -1016,7 +1016,7 @@ public class Compiler implements MessageConsumer { String includes = ""; for (int i = 0; i < includePaths.size(); i++) { - includes = includes + (" -I" + (String) includePaths.get(i)) + "\|"; + includes = includes + (" -I" + (String) includePaths.get(i)) + "|"; } //logger.debug("Paths prepared: " + includes); return includes; diff --git a/hardware/arduino/platforms.txt b/hardware/arduino/platforms.txt index 3f1d2eb7d..dbb3a4086 100755 --- a/hardware/arduino/platforms.txt +++ b/hardware/arduino/platforms.txt @@ -51,7 +51,7 @@ avr.compiler.cpp.flags=|-c|-g|-Os|-w|-fno-exceptions|-ffunction-sections|-fdata- avr.compiler.ar.cmd=avr-ar avr.compiler.ar.flags=rcs avr.compiler.objcopy.cmd=avr-objcopy -avr.compiler.objcopy.eep.flags=|-O|ihex|-j|.eeprom|--set-section-flags=.eeprom=alloc|load|--no-change-warnings|--change-section-lma|.eeprom=0 +avr.compiler.objcopy.eep.flags=|-O|ihex|-j|.eeprom|--set-section-flags=.eeprom=alloc,load|--no-change-warnings|--change-section-lma|.eeprom=0 avr.compiler.elf2hex.flags=|-O|ihex|-R|.eeprom avr.compiler.elf2hex.cmd=avr-objcopy avr.compiler.ldflags= From 43a11be3c9ea51a4260ce80506f1040d68318ab4 Mon Sep 17 00:00:00 2001 From: ricklon Date: Sat, 18 Jun 2011 23:44:32 -0400 Subject: [PATCH 15/16] Cleaned up some of the code. Need to focus getting the 1.0 code compilation changes double checked. --- app/src/processing/app/debug/Compiler.java | 60 ++-------------------- 1 file changed, 3 insertions(+), 57 deletions(-) diff --git a/app/src/processing/app/debug/Compiler.java b/app/src/processing/app/debug/Compiler.java index 96cbfe7a4..8665f72d8 100644 --- a/app/src/processing/app/debug/Compiler.java +++ b/app/src/processing/app/debug/Compiler.java @@ -178,21 +178,14 @@ public class Compiler implements MessageConsumer { // 1. compile the sketch (already in the buildPath) System.out.println("1. compileSketch"); compileSketch(avrBasePath, buildPath, includePaths, configPreferences); -/* - objectFiles.addAll( - compileFiles(avrBasePath, buildPath, includePaths, - findFilesInPath(buildPath, "S", false), - findFilesInPath(buildPath, "c", false), - findFilesInPath(buildPath, "cpp", false), - boardPreferences)); - */ + // 2. compile the libraries, outputting .o files to: // // 2. compile the libraries, outputting .o files to: // // //Doesn't really use configPreferences - System.out.println("2. compileLibraries"); - compileLibraries(avrBasePath, buildPath, includePaths, configPreferences); + System.out.println("2. compileLibraries"); + compileLibraries(avrBasePath, buildPath, includePaths, configPreferences); /* for (File libraryFolder : sketch.getImportedLibraries()) { @@ -315,53 +308,6 @@ public class Compiler implements MessageConsumer { */ return true; - /* - - logger.debug("corePaths: " + this.corePath); - - - this.objectFiles = new ArrayList(); - - // 0. include paths for core + all libraries - logger.debug("0. getIncludes"); - this.includePaths = getIncludes(this.corePath); - - // 1. compile the sketch (already in the buildPath) - logger.debug("1. compileSketch"); - compileSketch(avrBasePath, buildPath, includePaths, configPreferences); - - // 2. compile the libraries, outputting .o files to: - // // - //Doesn't really use configPreferences - logger.debug("2. compileLibraries"); - compileLibraries(avrBasePath, buildPath, includePaths, configPreferences); - - // 3. compile the core, outputting .o files to and then - // collecting them into the core.a library file. - logger.debug("3. compileCore"); - compileCore(avrBasePath, buildPath, this.corePath, configPreferences); - - // 4. link it all together into the .elf file - logger.debug("4. compileLink"); - compileLink(avrBasePath, buildPath, this.corePath, includePaths, configPreferences); - - // 5. extract EEPROM data (from EEMEM directive) to .eep file. - logger.debug("5. compileEep"); - compileEep(avrBasePath, buildPath, includePaths, configPreferences); - - // 6. build the .hex file - logger.debug("6. compileHex"); - compileHex(avrBasePath, buildPath, includePaths, configPreferences); - - //done - logger.debug("7. compile done"); - return true; - - - - */ - - } From dacfa8622316708af0cafb7dee5e965fedac7d64 Mon Sep 17 00:00:00 2001 From: ricklon Date: Wed, 22 Jun 2011 21:20:45 -0600 Subject: [PATCH 16/16] Addtional debuggin. Trying to find the pins compile issue. --- app/src/processing/app/debug/Compiler.java | 55 ++++++++++------------ build/shared/lib/preferences.txt | 1 + hardware/arduino/platforms.txt | 1 + 3 files changed, 27 insertions(+), 30 deletions(-) diff --git a/app/src/processing/app/debug/Compiler.java b/app/src/processing/app/debug/Compiler.java index 8665f72d8..cdae52013 100644 --- a/app/src/processing/app/debug/Compiler.java +++ b/app/src/processing/app/debug/Compiler.java @@ -80,10 +80,10 @@ public class Compiler implements MessageConsumer { this.buildPath = buildPath; this.primaryClassName = primaryClassName; this.verbose = verbose; + objectFiles = new ArrayList(); // the pms object isn't used for anything but storage MessageStream pms = new MessageStream(this); - Map boardPreferences = Base.getBoardPreferences(); //Check for null platform, and use system default if not found @@ -164,7 +164,6 @@ public class Compiler implements MessageConsumer { } } - objectFiles = new ArrayList(); // 0. include paths for core + all libraries @@ -279,33 +278,10 @@ public class Compiler implements MessageConsumer { // 5. extract EEPROM data (from EEMEM directive) to .eep file. System.out.println("5. compileEep"); compileEep(avrBasePath, buildPath, includePaths, configPreferences); - -/* - commandObjcopy = new ArrayList(baseCommandObjcopy); - commandObjcopy.add(2, "ihex"); - commandObjcopy.set(3, "-j"); - commandObjcopy.add(".eeprom"); - commandObjcopy.add("--set-section-flags=.eeprom=alloc,load"); - commandObjcopy.add("--no-change-warnings"); - commandObjcopy.add("--change-section-lma"); - commandObjcopy.add(".eeprom=0"); - commandObjcopy.add(buildPath + File.separator + primaryClassName + ".elf"); - commandObjcopy.add(buildPath + File.separator + primaryClassName + ".eep"); - execAsynchronously(commandObjcopy); -*/ // 6. build the .hex file System.out.println("6. compileHex"); - compileHex(avrBasePath, buildPath, includePaths, configPreferences); - -/* - commandObjcopy = new ArrayList(baseCommandObjcopy); - commandObjcopy.add(2, "ihex"); - commandObjcopy.add(".eeprom"); // remove eeprom data - commandObjcopy.add(buildPath + File.separator + primaryClassName + ".elf"); - commandObjcopy.add(buildPath + File.separator + primaryClassName + ".hex"); - execAsynchronously(commandObjcopy); -*/ + compileHex(avrBasePath, buildPath, includePaths, configPreferences); return true; } @@ -534,7 +510,7 @@ public class Compiler implements MessageConsumer { configPreferences.get("compiler.cpudef"), configPreferences.get("build.mcu"), configPreferences.get("build.f_cpu"), - configPreferences.get("board"), + configPreferences.get("software"), Base.REVISION, includes, sourceName, @@ -593,7 +569,7 @@ public class Compiler implements MessageConsumer { configPreferences.get("compiler.cpudef"), configPreferences.get("build.mcu"), configPreferences.get("build.f_cpu"), - configPreferences.get("board"), + configPreferences.get("software"), Base.REVISION, includes, sourceName, @@ -652,7 +628,7 @@ public class Compiler implements MessageConsumer { configPreferences.get("compiler.cpudef"), configPreferences.get("build.mcu"), configPreferences.get("build.f_cpu"), - configPreferences.get("board"), + configPreferences.get("software"), Base.REVISION, includes, sourceName, @@ -727,6 +703,12 @@ public class Compiler implements MessageConsumer { void compileSketch(String avrBasePath, String buildPath, ArrayList includePaths, HashMap configPreferences) throws RunnerException { + System.out.println("compileSketch: start"); + System.out.println("includePaths: "); + for (int i = 0; i < includePaths.size(); i++) { + System.out.println("-I" + (String) includePaths.get(i)); + } + //logger.debug("compileSketch: start"); this.objectFiles.addAll(compileFiles(avrBasePath, buildPath, includePaths, findFilesInPath(buildPath, "S", false), @@ -741,7 +723,7 @@ public class Compiler implements MessageConsumer { throws RunnerException { System.out.println("compileLibraries: start"); - + for (File libraryFolder : sketch.getImportedLibraries()) { System.out.println("libraryFolder: " + libraryFolder); File outputFolder = new File(buildPath, libraryFolder.getName()); @@ -749,6 +731,13 @@ public class Compiler implements MessageConsumer { createFolder(outputFolder); // this library can use includes in its utility/ folder includePaths.add(utilityFolder.getAbsolutePath()); + //debug includePaths + System.out.println("includePaths: "); + for (int i = 0; i < includePaths.size(); i++) { + System.out.println("-I" + (String) includePaths.get(i)); + } + + objectFiles.addAll( compileFiles(avrBasePath, outputFolder.getAbsolutePath(), includePaths, findFilesInFolder(libraryFolder, "S", false), @@ -778,6 +767,12 @@ public class Compiler implements MessageConsumer { ArrayList includePaths = new ArrayList(); includePaths.add(corePath); //include core path only if (pinsPath != null) includePaths.add(pinsPath); + + //debug includePaths + System.out.println("includePaths: "); + for (int i = 0; i < includePaths.size(); i++) { + System.out.println("-I" + (String) includePaths.get(i)); + } String baseCommandString = configPreferences.get("recipe.ar.pattern"); String commandString = ""; diff --git a/build/shared/lib/preferences.txt b/build/shared/lib/preferences.txt index 336d94a96..c1d370cfe 100755 --- a/build/shared/lib/preferences.txt +++ b/build/shared/lib/preferences.txt @@ -240,6 +240,7 @@ run.present.exclusive.macosx = true board = uno target = arduino platform = avr +software=ARDUINO programmer = arduino:avrispmkii diff --git a/hardware/arduino/platforms.txt b/hardware/arduino/platforms.txt index dbb3a4086..d946b8274 100755 --- a/hardware/arduino/platforms.txt +++ b/hardware/arduino/platforms.txt @@ -58,6 +58,7 @@ avr.compiler.ldflags= avr.compiler.cpudef=-mmcu= avr.compiler.upload.cmd= avr.compiler.upload.flags= +avr.compiler.define=-DARDUINO= avr.library.path=./hardware/arduino/cores/arduino avr.library.core.path=./libraries