From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ricardo Wurmus Subject: Re: avr-gcc Date: Tue, 17 Nov 2015 16:59:12 +0100 Message-ID: <87vb90mxbj.fsf@elephly.net> References: <87wptgmyv1.fsf@elephly.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46663) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZyifC-0005IG-FJ for guix-devel@gnu.org; Tue, 17 Nov 2015 10:59:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zyif9-0002Rn-6t for guix-devel@gnu.org; Tue, 17 Nov 2015 10:59:22 -0500 Received: from sender163-mail.zoho.com ([74.201.84.163]:24026) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zyif8-0002Rd-Tg for guix-devel@gnu.org; Tue, 17 Nov 2015 10:59:19 -0500 In-reply-to: <87wptgmyv1.fsf@elephly.net> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: "guix-devel@gnu.org" Ricardo Wurmus writes: > I’ve been wanting to use microscheme to do fun things with my AVR > microcontrollers. Sadly, I haven’t been able to make the combination of > microscheme, avrdude, and avr-gcc work. [...] > There are multiple copies of “libm.a” and “libc.a” and there’s a > “crtm328p.o” as well somewhere below the “avr/lib/” directory in the > output of the avr-libc package. Even after adding these paths to > LIBRARY_PATH, however, I cannot seem to fix the linker errors above. > Then I realised that LIBRARY_PATH only works for native compilers, and > that I would need to pass flags to the compiler (“-L”, maybe?). > > But this all seems very wrong. How can we fix this elegantly? Does > microscheme’s call to avr-gcc need to be patched to “-L” the avr-libc > path? Or does avr-gcc need fixing? Or something else entirely? I first looked at how to fix this inelegantly. “crtm328p.o” cannot be found no matter what I did, so I copied it from the store to the current directory: ~~~~~~~~~~~~ rekado@banana ~ $ cp /gnu/store/b8p4kkhcly7k5klnrzxmql35d541xhgq-avr-libc-1.8.1/avr/lib/avr5/crtm328p.o . ~~~~~~~~~~~~ Then I discovered microscheme’s “-w” flag which lets me paste stuff to the end of the call to avr-gcc. I abuse it to add the avr-libc lib directory containing “libc.a” and “libm.a”: ~~~~~~~~~~~~ rekado@banana ~ $ microscheme -a -u -m UNO -d /dev/bus/usb/006/004 -w "-L/gnu/store/b8p4kkhcly7k5klnrzxmql35d541xhgq-avr-libc-1.8.1/avr/lib/avr5/" microscheme/examples/BLINK.ms Microscheme 0.9.2, (C) Ryan Suchocki >> Treeshaker: After 4 rounds: 87 globals purged! 22 bytes will be reserved. >> 18 lines compiled OK >> Assembling... >> Uploading... avrdude: ser_open(): can't set attributes for device "/dev/bus/usb/006/004": Inappropriate ioctl for device avrdude done. Thank you. >> Warning: Command may have failed. (Exit code 256) >> Finished. ~~~~~~~~~~~~ Yes! It actually assembled the example! (Uploading fails, of course, because I shouldn’t try to write to a raw USB device. For some reason the AVRISPmkII USB programming device doesn’t appear as a regular serial device, so some more work is needed here.) So, back to the original question: how could we fix this in an elegant manner? This hack will last me for some tests, but it feels really icky. ~~ Ricardo