Bouni / MateDealer

MateDealer, a open source MDB cashless device implementation
58 stars 37 forks source link

How to upload MateDealer to arduino? #1

Closed asiniy closed 9 years ago

asiniy commented 9 years ago

Hello,

I'm testing mdb to arduino interaction and want to use your code.

First of all, I ran

sudo apt-get install gcc-avr binutils-avr gdb-avr avr-libc avrdude

Secondly, I ran

cd MateDealer && make all

What should I doing next?

Bouni commented 9 years ago

Try make program, that should upload the code to the arduino

Am 11. März 2015 16:15:00 MEZ, schrieb Alex Antonov notifications@github.com:

Hello,

I'm testing mdb to arduino interaction and want to use your code.

First of all, I ran

sudo apt-get install gcc-avr binutils-avr gdb-avr avr-libc avrdude

Secondly, I ran

cd MateDealer && make all

What should I doing next?


Reply to this email directly or view it on GitHub: https://github.com/Bouni/MateDealer/issues/1

asiniy commented 9 years ago

Bouni, I ran make all, this is output:

misha@FF10:~/projects/MateDealer/arduino$ make all

-------- begin --------
avr-gcc (GCC) 4.5.3
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Size before:
main.elf  :
section            size      addr
.data               888   8389120
.text             10044         0
.bss                 69   8390008
.stab              8544         0
.stabstr           3387         0
.debug_aranges      128         0
.debug_pubnames     742         0
.debug_info        4466         0
.debug_abbrev      1246         0
.debug_line        4996         0
.debug_frame        576         0
.debug_str         1506         0
.debug_loc         1924         0
.debug_pubtypes     460         0
Total             38976

Size after:
AVR Memory Usage
----------------
Device: atmega2560

Program:   10932 bytes (4.2% Full)
(.text + .data + .bootloader)

Data:        957 bytes (11.7% Full)
(.data + .bss + .noinit)

Errors: none
-------- end --------
asiniy commented 9 years ago

This command doesn't upload the code to the arduino!

asiniy commented 9 years ago

I've tried make program, but got an infinite timeouts:

misha@FF10:~/projects/MateDealer/arduino$ make program
avrdude -p atmega2560 -P /dev/ttyACM0     -c stk500v2    -U flash:w:main.hex 
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer

avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
asiniy commented 9 years ago

And, BTW, I have arduino uno with atmega328P-PU on the board, so I've tried make all with MCU = atmega328p

misha@FF10:~/projects/MateDealer/arduino$ make program

Compiling: usart.c
avr-gcc -c -mmcu=atmega328p -I. -gdwarf-2   -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=usart.lst  -std=gnu99 -DF_OSC=16000000 -MD -MP -MF .dep/usart.o.d usart.c -o usart.o 
usart.c:25:40: error: ‘UBRR1H’ undeclared here (not in a function)
usart.c:25:49: error: ‘UBRR1L’ undeclared here (not in a function)
usart.c:25:58: error: ‘UCSR1B’ undeclared here (not in a function)
usart.c:25:67: error: ‘UCSR1C’ undeclared here (not in a function)
usart.c: In function ‘USART1_RX_vect’:
usart.c:203:12: error: ‘UDR1’ undeclared (first use in this function)
usart.c:203:12: note: each undeclared identifier is reported only once for each function it appears in
usart.c: In function ‘USART1_UDRE_vect’:
usart.c:261:31: error: ‘TXB81’ undeclared (first use in this function)
usart.c:266:9: error: ‘UDR1’ undeclared (first use in this function)
usart.c:269:20: error: ‘UDRIE1’ undeclared (first use in this function)
make: *** [usart.o] Error 1
asiniy commented 9 years ago

I've copied this question to arduino.stackexchange.com

Bouni commented 9 years ago

You need a mega 2560 to run my code! A uno don't have 2 serial ports!

Am 12. März 2015 19:24:58 MEZ, schrieb Alex Antonov notifications@github.com:

I've copied this question to arduino.stackexchange.com


Reply to this email directly or view it on GitHub: https://github.com/Bouni/MateDealer/issues/1#issuecomment-78556374

asiniy commented 9 years ago

OMG, I see this trouble at stackoverflow!

asiniy commented 9 years ago

I think we can close this issue :)

asiniy commented 9 years ago

Sorry for bothering you...

I've got an arduino mega 2560. I've compile and trying to upload, and get an infinite timeouts... The arduino connected as a /dev/ttyACM0

pi@raspberrypi ~/projects/mdb/MateDealer/arduino $ make clean && make all && make program

-------- begin --------

Cleaning project:
rm -f main.hex
rm -f main.eep
rm -f main.obj
rm -f main.cof
rm -f main.elf
rm -f main.map
rm -f main.obj
rm -f main.a90
rm -f main.sym
rm -f main.lnk
rm -f main.lss
rm -f main.o usart.o mdb.o uplink.o  
rm -f  main.lst usart.lst mdb.lst uplink.lst
rm -f main.s usart.s mdb.s uplink.s
rm -f main.d usart.d mdb.d uplink.d
rm -f .dep/*
Errors: none
-------- end --------

-------- begin --------
avr-gcc (GCC) 4.7.2
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Compiling: main.c
avr-gcc -c -mmcu=atmega2560 -I. -gdwarf-2   -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=main.lst  -std=gnu99 -DF_OSC=16000000 -MD -MP -MF .dep/main.o.d main.c -o main.o 

Compiling: usart.c
avr-gcc -c -mmcu=atmega2560 -I. -gdwarf-2   -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=usart.lst  -std=gnu99 -DF_OSC=16000000 -MD -MP -MF .dep/usart.o.d usart.c -o usart.o 

Compiling: mdb.c
avr-gcc -c -mmcu=atmega2560 -I. -gdwarf-2   -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=mdb.lst  -std=gnu99 -DF_OSC=16000000 -MD -MP -MF .dep/mdb.o.d mdb.c -o mdb.o 

Compiling: uplink.c
avr-gcc -c -mmcu=atmega2560 -I. -gdwarf-2   -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=uplink.lst  -std=gnu99 -DF_OSC=16000000 -MD -MP -MF .dep/uplink.o.d uplink.c -o uplink.o 

Linking: main.elf
avr-gcc -mmcu=atmega2560 -I. -gdwarf-2   -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=main.o  -std=gnu99 -DF_OSC=16000000 -MD -MP -MF .dep/main.elf.d main.o usart.o mdb.o uplink.o   --output main.elf -Wl,-Map=main.map,--cref    -lm

Creating load file for Flash: main.hex
avr-objcopy -O ihex -R .eeprom main.elf main.hex

Creating load file for EEPROM: main.eep
avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" \
--change-section-lma .eeprom=0 -O ihex main.elf main.eep
avr-objcopy: --change-section-lma .eeprom=0x00000000 never used

Creating Extended Listing: main.lss
avr-objdump -h -S main.elf > main.lss

Creating Symbol Table: main.sym
avr-nm -n main.elf > main.sym

Size after:
AVR Memory Usage
----------------
Device: atmega2560

Program:   10126 bytes (3.9% Full)
(.text + .data + .bootloader)

Data:        955 bytes (11.7% Full)
(.data + .bss + .noinit)

Errors: none
-------- end --------

avrdude -p atmega2560 -P /dev/ttyACM0     -c stk500v2    -U flash:w:main.hex 
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer

avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
asiniy commented 9 years ago

solved!

Just need to pass -D flag to compiling