Building Anushi's firmware

Hi, all.

I’m trying to build the Anushri firmware. I have checked out the goods from, including the two submodules. However, building with CrossPack-AVR-20130212 doesn’t go so well. After adjusting makefiles to include -D_PROG_TYPES_COMPAT_ because of changes in pgmspace.h and adding a few consts for things that ended up in program memory (info available on request), building blows up with

/usr/local/CrossPack-AVR/bin/avr-g++ -c -mmcu=atmega328p -I. -g -Os -w -Wall -DF_CPU=20000000 -D_PROG_TYPES_COMPAT_ -fdata-sections -ffunction-sections -fshort-enums -fno-move-loop-invariants -DDISABLE_DEFAULT_UART_RX_ISR -DATMEGA328P -DSERIAL_RX_0 -mcall-prologues -fno-exceptions anu/ -o build/anu/voice_controller.o
/var/folders/qs/zxz36bx56k79tcymjrzpt_wh0000gn/T//cceS6rm2.s: Assembler messages:
/var/folders/qs/zxz36bx56k79tcymjrzpt_wh0000gn/T//cceS6rm2.s:1842: Error: register number above 15 required

It looks like g++ is generating bogus instructions like

andi r14, 240

Any ideas? I’ll poke more in the coming days (I have not yet combed CrossPack’s release notes, for example) but thought I’d ask.


Ouch! I have never seen messages like that. Could you downgrade to an older version?

Yeah, downgrading is likely to be no problem. Which do you know works, so I can do an effective binary search? Fixing codegen bugs in gcc is not what I had in mind! :slight_smile:

I work with 20100115. Newer versions have the new PROGMEM defines, I’m eventually going to fix that but you’ve figured it out anyway.

Thanks. 20100115 compiles the firmware just fine; I haven’t tried it out yet as I didn’t bring the programming header outside Anushri’s case (oops!).

From a quick look at the voice_controller.s produced, the compiler in 20130212 has something fishy going on with its register allocator and/or handling of inline assembler. avrlib/op.h contains, starting at line 281,

static inline uint8_t U8ShiftLeft4(uint8_t a) {
uint8_t result;
“mov %0, %1” “\
“swap %0” “\
“andi %0, 240” “\
: “=r” (result)
: “a” (a)
return result;

With 20100115 this expands to

mov r22, r22 ; result, instrument
swap r22 ; result
andi r22, 240 ; result

but 20130212 yields

mov r14, r22 ; tmp88, instrument
swap r14 ; tmp88
andi r14, 240 ; tmp88

More exploration later!

Wow the code in the above has terrible formatting! Pretend that it doesn’t.