Hello,
I just got myself an Arduino board. I'm somewhat experienced in programming AVR in C but didn't want to go through the hassle of assembling a circuit. Plus, this board already brings USB which would be a bit hard to implement (without proper soldering equipment).
But, after having a look at the Arduino development language, I find it... basic. We have no access to interrupt routines for the timers, etc, etc... So I'm wondering if it is possible to use an external compiler to program and make and .hex file and then use avrdude to download it to the board.
So far I've been trying Codevision to make a simple led blink program. No timers, just two for cycles to make a delay between 0 and 1 on the pin.
I got the avrdude to download the hex file, but the program seems like it isn't running at all. Any ideas or considerations to the way my program is written? Are there any registers that I shouldn't change during execution or will the bootloader simply not work with code generated outside Arduino IDE?
Thanks in advance, Carlos
Using Arduino bootloader with code from a C compiler
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
-
- Posts: 3
- Joined: Sat Feb 28, 2009 10:59 am
- westfw
- Posts: 2008
- Joined: Fri Apr 27, 2007 1:01 pm
Re: Using Arduino bootloader with code from a C compiler
Don't be fooled by the "simplified documentation" that is mostly aimed at beginners. The Arduino development language IS gcc/g++ (a full C/C++ compiler) with a bit of library and runtime environment attached to it. You have access to "all that stuff" (although you might have trouble overriding the ISRs that the environment already uses.) See the Hacking page on the arduino site for some of the details.But, after having a look at the Arduino development language, I find it... basic. We have no access to interrupt routines for the timers, etc, etc...
I don't see why the arduino (chip side) bootloader wouldn't load other code. The bootloader has no run-time involvement with anything, and simply jumps to the reset vector of the downloaded sketch to start it. The end of the arduino build process looks like this; is it compatible with what you're doing?
Code: Select all
avr-gcc -Os -Wl,--gc-sections -mmcu=atmega168 -o test_perf.elf [LIST-OF-.O-FILES] -lm
avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 test_perf.elf test_perf.eep
avr-objcopy -O ihex -R .eeprom test_perf.elf test_perf.hex
-
- Posts: 3
- Joined: Sat Feb 28, 2009 10:59 am
Re: Using Arduino bootloader with code from a C compiler
Hey,
thanks for the reply. I did had a deeper look at the documentation and there are ways to bypass a lot of things. But of course would take some time and luck not to get stuck at some Arduino detail that I missed or found no documentation to.
Like I said I'm not using AVR gcc. I did had a go at it, but could not get it to compile. Even using the Mfile application to create the makefiles, etc, etc... And since I was a bit on the anxious side to see the arduino running code build in an external compiler, I used CodeVision where I have quite some more experience to make a simple led blink.
So I can't see the end of the build.
I used a command line avrdude command to download it and it seemed to work fine. It was actually the one from one of this website's pages.
Thanks for the help, Carlos
thanks for the reply. I did had a deeper look at the documentation and there are ways to bypass a lot of things. But of course would take some time and luck not to get stuck at some Arduino detail that I missed or found no documentation to.
Like I said I'm not using AVR gcc. I did had a go at it, but could not get it to compile. Even using the Mfile application to create the makefiles, etc, etc... And since I was a bit on the anxious side to see the arduino running code build in an external compiler, I used CodeVision where I have quite some more experience to make a simple led blink.
So I can't see the end of the build.
I used a command line avrdude command to download it and it seemed to work fine. It was actually the one from one of this website's pages.
Thanks for the help, Carlos
- westfw
- Posts: 2008
- Joined: Fri Apr 27, 2007 1:01 pm
Re: Using Arduino bootloader with code from a C compiler
Did you get your program working or not? In your first message you said it downloaded ok but didn't seem to run, and I can't tell from the wording of the second message whether you have it working now or not.
The "build" log I sent was actually from an arduino IDE compile - you get to see the log if you set
"build-verbose=true" off in your arduino preferences.txt file. I was hoping there might be some clue there about differences from your CodeVision there (but it looks like rather standard starts-at-0 code for the AVR...)
if you're using Mac or Windows, the Arduino install includes a full set of avr-gcc binaries and libraries,
off in <arduino-install-dir>/hardware/tools/avr/bin/
The "build" log I sent was actually from an arduino IDE compile - you get to see the log if you set
"build-verbose=true" off in your arduino preferences.txt file. I was hoping there might be some clue there about differences from your CodeVision there (but it looks like rather standard starts-at-0 code for the AVR...)
if you're using Mac or Windows, the Arduino install includes a full set of avr-gcc binaries and libraries,
off in <arduino-install-dir>/hardware/tools/avr/bin/
Code: Select all
BillW-MacOSX-2<1070> ll /Downloads/arduino-0013/hardware/tools/avr/bin/
avarice avr-gcc-4.3.0 avr-man avrdude
avr-addr2line avr-gcc-select avr-nm ice-gdb
avr-ar avr-gccbug avr-objcopy ice-insight
avr-as avr-gcov avr-objdump kill-avarice
avr-c++ avr-gdb avr-project libusb-config
avr-c++filt avr-gdbtui avr-ranlib make
avr-cpp avr-gprof avr-readelf simulavr
avr-g++ avr-help avr-size simulavr-disp
avr-gcc avr-info avr-strings simulavr-vcd
avr-gcc-3.4.6 avr-ld avr-strip start-avarice
-
- Posts: 1645
- Joined: Sat Nov 10, 2007 12:59 am
Re: Using Arduino bootloader with code from a C compiler
at the bottom of this page using the bootloader with avrdude is discussed. but you seem to have found that already.
Please be positive and constructive with your questions and comments.