OS X instructions
ryansuchocki opened this issue · comments
I know that people have successfully compiled microscheme on OS X. It would be great if someone with a Mac could comment on the availability of the required tools (avr-gcc, avrdude), test whether microscheme invokes them properly, and generally provide some OS X specific instructions.
First step in the build section of your README appears to run without issues.
But when I run make build
I am getting:
boris% make build
gcc -ggdb -o microscheme src/*.c
src/main.c:81:13: warning: implicit declaration of function 'isprint' is invalid
in C99 [-Wimplicit-function-declaration]
else if (isprint (optopt))
^
src/main.c:205:3: warning: implicit declaration of function
'codegen_emitModelHeader' is invalid in C99
[-Wimplicit-function-declaration]
codegen_emitModelHeader(model, outputFile);
^
src/main.c:206:3: warning: implicit declaration of function
'codegen_emitPreamble' is invalid in C99 [-Wimplicit-function-declaration]
codegen_emitPreamble(outputFile, numUsedGlobals);
^
src/main.c:209:3: warning: implicit declaration of function 'codegen_emit' is
invalid in C99 [-Wimplicit-function-declaration]
codegen_emit(ASTroot, 0, outputFile, model, NULL, opt_ag...
^
src/main.c:212:3: warning: implicit declaration of function
'codegen_emitPostamble' is invalid in C99
[-Wimplicit-function-declaration]
codegen_emitPostamble(outputFile);
^
5 warnings generated.
src/parser.c:499:21: warning: implicit declaration of function 'freeEnvironment'
is invalid in C99 [-Wimplicit-function-declaration]
if (tree->closure) freeEnvironment(tree->closure);
^
1 warning generated.
src/scoper.c:47:8: warning: implicit declaration of function 'getBindingIndex'
is invalid in C99 [-Wimplicit-function-declaration]
if (getBindingIndex(expr->variable, currentEnvir...
^
1 warning generated.
I notice that these are all warnings, does it mean the build is fine?
If I do the next line I see no issues:
boris% ./microscheme examples/BLINK.ms
Microscheme 0.8, (C) Ryan Suchocki
>> Treeshaker: After 4 rounds: 84 globals purged! 22 bytes will be reserved.
>> 18 lines compiled OK
>> Finished.
But if I run:
boris% ./microscheme -m UNO -d /dev/tty.usbmodem1421 -auc examples/BLINK.ms
Microscheme 0.8, (C) Ryan Suchocki
>> Treeshaker: After 4 rounds: 84 globals purged! 22 bytes will be reserved.
>> 18 lines compiled OK
>> Assembling...
>> Uploading...
zsh: abort ./microscheme -m UNO -d /dev/tty.usbmodem1421 -auc examples/BLINK.ms
I tried it with admin rights, but all that happens is that very last line doesn't appear (so it looks like everything is fine). Except that everything shows up instantly, but clearly nothing is uploaded to the device. (The port is correct, I verified)
Tested it with both an UNO and a Leonardo board.
Here is all that I had to do currently, though I am aware that it isn't working:
Get avrdude
with Homebrew
brew install avrdude
Then I installed the latest Crosspack (to get AVR-GCC)
Then I followed your building instructions in the README.
Hi Boris.
Could you pull the latest version, and try this again? The warnings should have gone.
If the uploading is still broken, try compiling with "-au" rather than "-auc", and report whether any files are generated in the examples directory?
No warnings on make build
of the new version.
Still doesn't upload with -au
or -auc
(sudo or no sudo)
boris% sudo ./microscheme -m LEO -d /dev/tty.usbmodem1421 -au examples/BLINK.ms
Microscheme 0.8, (C) Ryan Suchocki
>> Treeshaker: After 4 rounds: 83 globals purged! 22 bytes will be reserved.
>> 18 lines compiled OK
>> Assembling...
>> Uploading...
The above output all appears near instantly
There are:
BLINK.elf
BLINK.hex
BLINK.ms
BLINK.s
In the examples folder, looks like .elf .s .hex were generated. Anything else that I can send you, or anything else I can test with?
(Running OSX 10.10)
Run:
avrdude -p -V atmega328p -c arduino -P /dev/tty.usbmodem1421 -b 115200 -D -U flash:w:examples/BLINK.hex:i
In the same terminal, and paste the whole output?
Hmm getting an odd message:
avrdude: no programmer has been specified on the command line or the config file
Specify a programmer using the -c option and try again
even though the -c option is specified?
Output of avrdude -c ?
?
boris% avrdude -c ?
zsh: no matches found: ?
tried without the ?
just in case typo and it just gives me the main avrdude
list of commands.
avrdude -v
:
boris% avrdude -v
avrdude: Version 6.1, compiled on Jan 6 2015 at 17:21:39
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "/usr/local/Cellar/avrdude/6.1/etc/avrdude.conf"
User configuration file is "/Users/boriskourt/.avrduderc"
User configuration file does not exist or is not a regular file, skipping
avrdude: no programmer has been specified on the command line or the config file
Specify a programmer using the -c option and try again
avrdude -c ?
should list the available programmers, but maybe zsh does something special with ?
.
Anyway, there's an error in the command. (Sorry!) It should be:
avrdude -V -p atmega328p -c arduino -P /dev/tty.usbmodem1421 -b 115200 -D -U flash:w:examples/BLINK.hex:i
zsh interpreted ?
as its own command (wasn't aware of this)
Here is avrdude -c \?
escaped:
Valid programmers are:
2232HIO = FT2232H based generic programmer
4232h = FT4232H based generic programmer
arduino = Arduino
arduino-ft232r = Arduino: FT232R connected to ISP
atmelice = Atmel-ICE (ARM/AVR) in JTAG mode
atmelice_dw = Atmel-ICE (ARM/AVR) in debugWIRE mode
atmelice_isp = Atmel-ICE (ARM/AVR) in ISP mode
atmelice_pdi = Atmel-ICE (ARM/AVR) in PDI mode
avr109 = Atmel AppNote AVR109 Boot Loader
avr910 = Atmel Low Cost Serial Programmer
avr911 = Atmel AppNote AVR911 AVROSP
avrftdi = FT2232D based generic programmer
avrisp = Atmel AVR ISP
avrisp2 = Atmel AVR ISP mkII
avrispmkII = Atmel AVR ISP mkII
avrispv2 = Atmel AVR ISP V2
buspirate = The Bus Pirate
buspirate_bb = The Bus Pirate (bitbang interface, supports TPI)
butterfly = Atmel Butterfly Development Board
butterfly_mk = Mikrokopter.de Butterfly
bwmega = BitWizard ftdi_atmega builtin programmer
C232HM = FT232H based module from FTDI and Glyn.com.au
c2n232i = serial port banging, reset=dtr sck=!rts mosi=!txd miso=!cts
dasa = serial port banging, reset=rts sck=dtr mosi=txd miso=cts
dasa3 = serial port banging, reset=!dtr sck=rts mosi=txd miso=cts
diecimila = alias for arduino-ft232r
dragon_dw = Atmel AVR Dragon in debugWire mode
dragon_hvsp = Atmel AVR Dragon in HVSP mode
dragon_isp = Atmel AVR Dragon in ISP mode
dragon_jtag = Atmel AVR Dragon in JTAG mode
dragon_pdi = Atmel AVR Dragon in PDI mode
dragon_pp = Atmel AVR Dragon in PP mode
flip1 = FLIP USB DFU protocol version 1 (doc7618)
flip2 = FLIP USB DFU protocol version 2 (AVR4023)
ft232r = FT232R Synchronous BitBang
ft245r = FT245R Synchronous BitBang
jtag1 = Atmel JTAG ICE (mkI)
jtag1slow = Atmel JTAG ICE (mkI)
jtag2 = Atmel JTAG ICE mkII
jtag2avr32 = Atmel JTAG ICE mkII im AVR32 mode
jtag2dw = Atmel JTAG ICE mkII in debugWire mode
jtag2fast = Atmel JTAG ICE mkII
jtag2isp = Atmel JTAG ICE mkII in ISP mode
jtag2pdi = Atmel JTAG ICE mkII PDI mode
jtag2slow = Atmel JTAG ICE mkII
jtag3 = Atmel AVR JTAGICE3 in JTAG mode
jtag3dw = Atmel AVR JTAGICE3 in debugWIRE mode
jtag3isp = Atmel AVR JTAGICE3 in ISP mode
jtag3pdi = Atmel AVR JTAGICE3 in PDI mode
jtagkey = Amontec JTAGKey, JTAGKey-Tiny and JTAGKey2
jtagmkI = Atmel JTAG ICE (mkI)
jtagmkII = Atmel JTAG ICE mkII
jtagmkII_avr32 = Atmel JTAG ICE mkII im AVR32 mode
lm3s811 = Luminary Micro LM3S811 Eval Board (Rev. A)
mib510 = Crossbow MIB510 programming board
mkbutterfly = Mikrokopter.de Butterfly
nibobee = NIBObee
o-link = O-Link, OpenJTAG from www.100ask.net
openmoko = Openmoko debug board (v3)
pavr = Jason Kyle's pAVR Serial Programmer
pickit2 = MicroChip's PICkit2 Programmer
ponyser = design ponyprog serial, reset=!txd sck=rts mosi=dtr miso=cts
siprog = Lancos SI-Prog <http://www.lancos.com/siprogsch.html>
stk500 = Atmel STK500
stk500hvsp = Atmel STK500 V2 in high-voltage serial programming mode
stk500pp = Atmel STK500 V2 in parallel programming mode
stk500v1 = Atmel STK500 Version 1.x firmware
stk500v2 = Atmel STK500 Version 2.x firmware
stk600 = Atmel STK600
stk600hvsp = Atmel STK600 in high-voltage serial programming mode
stk600pp = Atmel STK600 in parallel programming mode
UM232H = FT232H based module from FTDI and Glyn.com.au
usbasp = USBasp, http://www.fischl.de/usbasp/
usbasp-clone = Any usbasp clone with correct VID/PID
usbtiny = USBtiny simple USB programmer, http://www.ladyada.net/make/usbtinyisp/
wiring = Wiring
xplainedpro = Atmel AVR XplainedPro in JTAG mode
boris% avrdude -V -p atmega328p -c arduino -P /dev/tty.usbmodem1421 -b 115200 -D -U flash:w:examples/BLINK.hex:i
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x3c
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x3c
... etc ...
avrdude done. Thank you.
Did a test with standard Arduino, its responsive. But I have seen this error before.
Which model are you using now?
Leonardo (R3 I think)
Could you try with an UNO?
boris% avrdude -V -p atmega328p -c arduino -P /dev/tty.usbmodem1421 -b 115200 -D -U flash:w:examples/BLINK.hex:i
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.00s
avrdude: Device signature = 0x1e950f
avrdude: reading input file "examples/BLINK.hex"
avrdude: writing flash (2338 bytes):
Writing | ################################################## | 100% 0.40s
avrdude: 2338 bytes of flash written
avrdude: safemode: Fuses OK (E:00, H:00, L:00)
avrdude done. Thank you.
Is this meant to blink on pin 13?
Yes. Does it?
No sorry should have said it didn't. Tested with standard Arduino blink and the LED does work on this UNO.
I think that's trying to upload the version assembled for the LEO, to the UNO.
Try:
./microscheme -m UNO -a examples/BLINK.ms
and then:
avrdude -V -p atmega328p -c arduino -P /dev/tty.usbmodem1421 -b 115200 -D -U flash:w:examples/BLINK.hex:i
Ah sorry about that, that worked! Edit: Whats next though :)
Excellent. Does it all work together?
./microscheme -m UNO -d /dev/tty.usbmodem1421 -au examples/BLINK.ms
p.s., pull again
Sadly no luck, same issue as the first time:
Microscheme 0.8, (C) Ryan Suchocki
>> Treeshaker: After 4 rounds: 83 globals purged! 22 bytes will be reserved.
>> 18 lines compiled OK
>> Assembling...
>> Uploading...
Happens instantly and nothing uploads. (tested with a different program already uploaded and it didn't overwrite)
Pull and try now?
That worked :)
Microscheme 0.8, (C) Ryan Suchocki
>> Treeshaker: After 4 rounds: 83 globals purged! 22 bytes will be reserved.
>> 18 lines compiled OK
>> Assembling...
>> Uploading...
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.00s
avrdude: Device signature = 0x1e950f
avrdude: reading input file "examples/BLINK.hex"
avrdude: writing flash (2110 bytes):
Writing | ################################################## | 100% 0.35s
avrdude: 2110 bytes of flash written
avrdude: safemode: Fuses OK (E:00, H:00, L:00)
avrdude done. Thank you.
>> Finished.
Fantastic.
The problem was an internal buffer set too small. It never came up before because "/dev/tty.usbmodem1421" is longer than any linux device path!
Have fun! :)
Yeah nice! Should I add this to the README or make a wiki page? (With the what the prereqs were)
Also any idea on what to do about the Leonardo? Still experiences the same timeouts even when compiled and set to LEO
This is because of the LEO's (actually, the ATMega 32u4's) advanced USB capabilities, the way it is reset before uploading new code is slightly complicated.
For now, just reset it manually (short GND and RST pins). This puts it in a programmable mode for about 10 seconds. (watch /dev because the device path should change when it is programmable.)
Alright thank you.
I have many different types of Arduino on hand (both official and not official), what is proper way to add support for them and test it?
I'll start a new issue.