2014-06-11 First successful sketch uploaded to Arduino ATmega2560 on NetBSD

From Wikistix
Jump to: navigation, search

After much stuffing around, I've managed to successfully build and upload a relatively complex sketch to by ATmega2560 based Arduino from NetBSD. It uses the EEPROM, LiquidCrystal & Wire system libraries, and DS1307RTC, OneWire & Time local libraries.

There was a few hiccups along the way. First, there's an old bug which causes relocation truncations, especially in libm, due to their use of relative jump/calls. But, I found a workaround which works for my case.

Next, was the fact that the avr-gcc in NetBSD pkgsrc is a relatively unpatched release of 4.5.3. I dug into one issue, using avr-objdump -d, and noticed that a working binary built on a Linux box had a larger interrupt vector table than the binaries I had built on NetBSD. Digging deeper, I managed to come up with the patch that I later found here. That still didn't get a working binary. I then found a suite of gcc patches Atmel have on their site. Ok. Hoping that these had been pulled up into the gcc mainline, and not wanting to try to apply all these to the old gcc, I took a shot at upgrading NetBSD's pkgsrc cross/avr-gcc to something more recent - 4.8.3 - which resulted in a working patch and working avr binaries. Woot!


Misinformation found herein copyright Paul Ripke (aka “stix”) stixpjr@gmail.com.