Will your Makefile work with Serial.print?If yes, any idea why my Makefile fails with Serial.print?

Oliver

Yes, the serial works.No, not really. I suspect the linking is wrong. I tried modifying your makefile but with no luck. It also gave me linker warnings on a more complicated sketch. Eventually I made a shell script which mimicked the IDE output. After confirming it worked, I turned it into a makefile. The next step is to replace the sequential ar invocation with creating core.a in a single step, but I suspect this might be the cause of the serial port not working.

I've been wrestling with this Makefile for some time now and (finally found that-fpack-structwreaks havoc with register structs.

What I think happens is that -fpack-struct removes padding/alignment spaces in structs.Especially for hardware register structs (e.g. see CMSIS/Device/ATMEL/sam3xa/include/component/component_pmc.h ) this means the register addresses inside the struct may get shifted downward while the actual hardware register addresses remain the same.The program then writes to / reads from wrong register locations.

E.g. during init(), which is called before setup(), a write to a wrong PMC->CKGR_MOR location makes the program stall. SystemInit() hangs here in my case.

Having this flag enabled also breaks the Timer Counters and I'm reasonable sure it will wreak havoc in other places (Serial?), too.

Conclusion:Remove the "-fpack-struct" compiler flag (The Arduino ide doesn't use it either.)

Hi,I modified Paul's Makefile to make it run on Windows. Maybe this is of some interest to someone else.I don't see how to make it work for both Unix and Windows...What I like most is that it is way faster then Arduino's IDE, since it compiles only files in need of that.Have fun,Achim