Go Down

Topic: Windows command line build (Read 42967 times) previous topic - next topic

dabono

Yup, I played around with this quite a bit last night.  I also hit the __cxa_pure_virtual problem, but decided to get some sleep (sometimes this hobby is too much like my day job  ;)).

Thanks for posting the solution - I'll check out the reference to understand what's causing it.  I wonder if tweaking the avr-gcc / avr-g++ command line options might fix that?

-David

aerodyno

Cool. I managed to get what I want working, but the scripts are pretty custom to what I'm doing now.  If the main scripts posted on the website will get updated, I'll help out with that.

toddfun

I finally got the command line to work from windows!!!!

Here are all the steps to make it work.

1) My avrdude.exe was crashing because I had an old winavr path in my windows environment "PATH" variable which had an old version of avrdude.exe; so I just removed that from my path. I guess my winavr will not work but I can set that up again some other day.

2) I downloaded the new Arduino 19

3) I followed the install steps at arduino playground WindowsCommandLine:

   a) I put the three new downloaded text files in this path on my box:

C:\Documents and Settings\Admin\My Documents\Electronics\Arduino\Arduino command line

   b) I edited these two files before renaming them to as *.bat files:
IN agetpref.txt
Change:
set arduino_runtime=!arduino_path!\hardware\cores\arduino
to:
set arduino_runtime=!arduino_path!\hardware\arduino\cores\arduino

IN abuild.txt
change:
set abuild_include_paths_root=!arduino_path!\hardware\libraries
to:
set abuild_include_paths_root=!arduino_path!\libraries

change:
for /D %%d in ("!arduino_path!\hardware\libraries\*.*") do (
to:
for /D %%d in ("!arduino_path!\libraries\*.*") do (

4) My COM port for my Arduino was seen as COM7 and I went into the windows device manager and changed the baud rate to 56700 (I'm not sure you have to do this but I wanted everything set to 56700 baud so I did).

5) I used these values for my new windows environment variables.

FIRST NOTE: I have the Arduino Duemilanove.  If your board is different you will have to alter the ARDUINO_MCU environment variable.

SECOND NOTE: The ARDUINO_PROGRAMMER = stk500v1 is very important!

     a) I added this to the front of my windows "PATH" environment variable:

C:\Documents and Settings\Admin\My Documents\Electronics\Arduino\Arduino command line\;

b)      Other environment variables added per the wiki instruction:

ARDUINO_PATH=C:\Documents and Settings\Admin\My Documents\Electronics\Arduino\Arduino IDE-0019

ARDUINO_MCU=atmega328p

ARDUINO_PROGRAMMER=stk500v1

ARDUINO_FCPU=16000000

ARDUINO_COMPORT=COM7

ARDUINO_BURNRATE=57600

6) I opened a command line window and changed to the folder that has my blink sketch example.

cd C:\Documents and Settings\Admin\My Documents\Electronics\Arduino\My Projects\Duemilanove_ATmega328\Blink

7) Type this to compile and upload the sketch to the Arduino board:

abuild Blink.pde

a)      It first compiles the sketch in the obj sub-folder then asked if you want to upload
b)      I type 'u' for upload and I DID NOT push the rest button on the Arduino; it seemed to send the reset command over the USB cable via the COM driver.

That's it, it worked for me.  

Below is what I seen in the command window after the upload was complete.


abuild.bat: Successfully built .\obj\Blink.pde.rom
abuild.bat: Successfully built .\obj\Blink.pde.hex
  text    data     bss     dec     hex filename
     0    1298       0    1298     512 .\obj\Blink.pde.hex

[Remember to reset your board right before uploading.]
Enter the first character of your choice...
Upload, Quit? u

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e950f
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
        To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file ".\obj\Blink.pde.hex"
avrdude: input file .\obj\Blink.pde.hex auto detected as Intel Hex
avrdude: writing flash (1298 bytes):

Writing | ################################################## | 100% 0.67s

avrdude: 1298 bytes of flash written
avrdude: verifying flash memory against .\obj\Blink.pde.hex:
avrdude: load data flash data from input file .\obj\Blink.pde.hex:
avrdude: input file .\obj\Blink.pde.hex auto detected as Intel Hex
avrdude: input file .\obj\Blink.pde.hex contains 1298 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.59s

avrdude: verifying ...
avrdude: 1298 bytes of flash verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

aupload.bat:  exiting with return code 0

markphelan

David (dab),

Could you please post another link for the batch files if they differ to those on the playground page? I'm not able to compile my code though it builds and uploads fine in the IDE.

toddfun

The files are the same. Just follow the instruction on the playgound page then follow my instructions to change the bat files with a text editor like notepad.  Should work if you follow all the instruction and make my changes to the bat files.  I didn't change anything else.

markphelan

OK, I worked it out.

I had to add declarations for all my functions in to the .pde file, much like the script adds the include for Wprogram.h

I then also had to add an additional function:

Code: [Select]
extern "C" void __cxa_pure_virtual() { while (1); }

which is needed by some of the other libraries. Perhaps the batch file should also include this as it's not going to use up a huge amount of codespace. If I include this function and compile with the IDE it returns an error.

The problem I now have is that this is building EVERY library (ethernet, onewire, lcd, servo, etc) and my compiled .hex file is 47K!

It seems like there's a lot more going on "behind the scenes" within the IDE prior to the compilation, and it's only building libraries that are mentioned in the code. I'm not sure if it's possible for the batch file to check for "includes" and then only compile with those libraries.

Mart

Is there a final set of files available that work with 19 or 20?

Go Up