Hello, as the FreeBSD user I decided to give avra a try.
It was necessary to add some patches to the assembler and
one dubious change to amforth, but it works very well,
and even .hex files are the same when produced by avra
and the Atmel tool.
I have posted patches to the newest avra (trunk, they might
work with 1.3.0 release) on Sourceforge:
3044547 Error:: ldi can only use a high register (r16 - r31)
https://sourceforge.net/tracker/?func=detail&aid=3044547&group_id=55499&atid=477233
3044545 movw y, z causes Error:: No register associated with y and z
https://sourceforge.net/tracker/?func=detail&aid=3044545&group_id=55499&atid=477233
3044541 .ifndef does not work (Can't redefine constant, use .SET)
https://sourceforge.net/tracker/?func=detail&aid=3044541&group_id=55499&atid=477233
As per suggestion I am using Atmel include files taked from the latest
AVR Studio (I place them in /usr/local/libdata/avra and modify avr-build.xml
accordingly).
The only (trivial) issue left is that avra checks all code ranges
produced by the assembler and complains if overlap occurs.
Atmel assembler does not care and happily produces two lines
in HEX file for the same range.
This happens when the serial rx or tx via IRQ is enabled,
core/devices/atmega328p/device.asm produces:
.org $024
rcall isr ; USART Rx Complete
.org $026
rcall isr ; USART, Data Register Empty
and core/drivers/usart-isr-[rt]x.asm produce:
.org URXCaddr (or .org UDREaddr)
jmp_ usart_rx_isr
I have enclosed a silly patch (irq.patch) that encloses them
info .ifdefs to avoid producing overlapping assembly.
I am not sure this is the right way to handle it, though.
Enclosed please find also patches to solve flash size
exceeded problem when producing .hex files for arduino.
One question by the way: At amforth_interpreter (0x3800 in case of
328p) we start the inner interpreter (label DO_DODOES).
Wouldn't that make sense to to have an additional "jmp_ amforthstart"
there as well? This would probably allow booting Amforth independent
of the BOOTRST fuse setting.
And finally, there is a patch attached for ant files to
call avra. I am flashing one Arduino board (ATmega 328p
Duemilanove) with another one (ATmega168 Freeduino) via
In-circuit Serial Programming.
--Marcin
Index: core/devices/atmega328p/device.asm
===================================================================
--- core/devices/atmega328p/device.asm (wersja 911)
+++ core/devices/atmega328p/device.asm (kopia robocza)
@@ -96,10 +96,14 @@
rcall isr ; Timer/Couner0 Overflow
.org $022
rcall isr ; SPI Serial Transfer Complete
+.ifndef usart-rx-isr
.org $024
rcall isr ; USART Rx Complete
+.endif
+.ifndef usart-tx-isr
.org $026
rcall isr ; USART, Data Register Empty
+.endif
.org $028
rcall isr ; USART Tx Complete
.org $02A
Index: core/devices/atmega168/device.asm
===================================================================
--- core/devices/atmega168/device.asm (wersja 911)
+++ core/devices/atmega168/device.asm (kopia robocza)
@@ -96,10 +96,14 @@
rcall isr ; Timer/Couner0 Overflow
.org $022
rcall isr ; SPI Serial Transfer Complete
+.ifndef usart-rx-isr
.org $024
rcall isr ; USART Rx Complete
+.endif
+.ifndef usart-tx-isr
.org $026
rcall isr ; USART, Data Register Empty
+.endif
.org $028
rcall isr ; USART Tx Complete
.org $02A
Index: core/dict_usart.inc
===================================================================
--- core/dict_usart.inc (wersja 911)
+++ core/dict_usart.inc (kopia robocza)
@@ -1,12 +1,17 @@
+.ifdef usart-rx-isr
.include "drivers/usart-isr-rx.asm"
.include "words/usart-rx-isr.asm"
-;.include "words/usart-rx-poll.asm"
+.else
+.include "words/usart-rx-poll.asm"
+.endif
; use either interrupt transmit
-;.include "drivers/usart-isr-tx.asm"
-;.include "words/usart-tx-isr.asm"
-; or use the poll transmit
+.ifdef usart-tx-isr
+.include "drivers/usart-isr-tx.asm"
+.include "words/usart-tx-isr.asm"
+.else
.include "words/usart-tx-poll.asm"
+.endif
.include "words/usart.asm"
Index: appl/arduino/dict_appl_core.inc
===================================================================
--- appl/arduino/dict_appl_core.inc (wersja 911)
+++ appl/arduino/dict_appl_core.inc (kopia robocza)
@@ -6,29 +6,6 @@
.include "words/istore_nrww.asm"
.include "words/ifetch.asm"
-.include "dict_minimum.inc"
-
-.include "words/d-2star.asm"
-.include "words/d-plus.asm"
-.include "words/d-minus.asm"
-.include "words/d-invert.asm"
-.include "words/udot.asm"
-.include "words/dot-s.asm"
-
-.include "words/dotstring.asm"
-.include "words/squote.asm"
-
-.include "words/words.asm"
-
-.include "words/edefer.asm"
-.include "words/rdefer.asm"
-.include "words/is.asm"
-
-.include "words/applturnkey.asm"
-.include "words/int-store.asm"
-.include "words/1ms.asm"
-.include "words/ms.asm"
-
-.include "dict_compiler.inc"
-.include "words/show-wordlist.asm"
-.include "device.inc"
\ No newline at end of file
+.include "words/wdr.asm"
+.include "words/sleep.asm"
+.include "words/spirw.asm"
Index: appl/arduino/dict_appl.inc
===================================================================
--- appl/arduino/dict_appl.inc (wersja 911)
+++ appl/arduino/dict_appl.inc (kopia robocza)
@@ -2,3 +2,31 @@
; they may be moved to the core dictionary if needed
.include "dict_usart.inc"
+.include "dict_minimum.inc"
+.include "words/d-2star.asm"
+.include "words/d-plus.asm"
+.include "words/d-minus.asm"
+.include "words/d-invert.asm"
+.include "words/udot.asm"
+.include "words/dot-s.asm"
+
+.include "words/dotstring.asm"
+.include "words/squote.asm"
+
+.include "words/words.asm"
+
+.include "words/edefer.asm"
+.include "words/rdefer.asm"
+.include "words/is.asm"
+
+.include "words/applturnkey.asm"
+.include "words/int-store.asm"
+.include "words/1ms.asm"
+.include "words/ms.asm"
+
+.include "dict_compiler.inc"
+.include "words/show-wordlist.asm"
+.include "device.inc"
+
+.include "dict_vm.inc"
Index: appl/arduino/build.xml
===================================================================
--- appl/arduino/build.xml (wersja 911)
+++ appl/arduino/build.xml (kopia robocza)
@@ -3,7 +3,7 @@
<import file="../avr-build.xml"/>
<target name="mega.hex" description="Hexfiles for Arduino Mega Board
www.arduino.cc">
- <avrasm2 projectname="mega" mcu="atmega1280"/>
+ <avra projectname="mega" mcu="atmega1280"/>
</target>
<target name="mega" depends="mega.hex" description="Arduino Mega Board
www.arduino.cc">
@@ -17,7 +17,7 @@
</target>
<target name="sanguino.hex" description="Hexfiles for Sanguino Board
sanguino.cc">
- <avrasm2 projectname="sanguino" mcu="atmega644p"/>
+ <avra projectname="sanguino" mcu="atmega644p"/>
</target>
<target name="sanguino" depends="sanguino.hex" description="Sangiono
Board sanguino.cc">
@@ -31,27 +31,30 @@
</target>
<target name="duemilanove.hex" description="Hexfiles for Arduino
Duemilanove Board www.arduino.cc">
- <avrasm2 projectname="duemilanove" mcu="atmega328p"/>
+ <avra projectname="duemilanove" mcu="atmega328p"/>
</target>
<target name="duemilanove" depends="duemilanove.hex"
description="Arduino Duemilanove Board www.arduino.cc">
<echo>Uploading Hexfiles to Arduino Duemilanove</echo>
<avrdude
- type="avrisp2"
+ type="avrisp"
mcu="m328p"
+ programmer="arduino"
+ port="/dev/cuaU1"
flashfile="duemilanove.hex"
eepromfile="duemilanove.eep.hex"
/>
</target>
<target name="diecimila.hex" description="Hexfiles for Arduino
Diecimila Board www.arduino.cc">
- <avrasm2 projectname="diecimila" mcu="atmega168"/>
+ <avra projectname="diecimila" mcu="atmega168"/>
</target>
<target name="diecimila" depends="diecimila.hex" description="Arduino
Diecimila Board www.arduino.cc">
<echo>Uploading Hexfiles to Arduino Diecimila</echo>
<avrdude
- type="avrisp2"
+ type="avrisp"
mcu="m168"
+ port="/dev/cuaU0"
flashfile="diecimila.hex"
eepromfile="diecimila.eep.hex"
/>
Index: appl/avr-build.xml
===================================================================
--- appl/avr-build.xml (wersja 911)
+++ appl/avr-build.xml (kopia robocza)
@@ -17,14 +17,16 @@
</target>
<macrodef name="avra">
- <attribute name="binary" default="avra" />
- <attribute name="includes" default="../../Atmel/Appnotes" />
+ <attribute name="binary"
default="/usr/obj//usr/home/saper/sw/avra/src/avra" />
+ <attribute name="includes" default="/usr/local/libdata/avra" />
<attribute name="projectname" default="undefined"/>
+ <attribute name="mcu" default="undefined"/>
<attribute name="amforth.core" default="../../core"/>
<sequential>
<exec executable="@{binary}" spawn="false" failonerror="true">
<arg line="-I @{includes}"/>
<arg line="-I @{amforth.core}"/>
+ <arg line="-I @{amforth.core}/devices/@{mcu}"/>
<arg line="--listmac"/>
<arg line="-l @{projectname}.lst"/>
<arg line="-m @{projectname}.map"/>
@@ -61,6 +63,7 @@
<attribute name="binary" default="avrdude" />
<attribute name="type" default="avr910"/>
<attribute name="port" default="${avr.programm...@{type}port}" />
+ <attribute name="speed" default="${avr.programm...@{type}speed}"
/>
<attribute name="programmer" default="${avr.programm...@{type}}" />
<attribute name="mcu" default="m8"/>
@@ -71,6 +74,7 @@
<arg line="-c @{programmer}"/>
<arg line="-p @{mcu}"/>
<arg line="-P @{port}"/>
+ <arg line="-b @{speed}"/>
<arg line="-e"/>
<arg line="-U flash:w:@{flashfile}"/>
<arg line="-U eeprom:w:@{eepromfile}"/>
Index: appl/programmer.properties
===================================================================
--- appl/programmer.properties (wersja 911)
+++ appl/programmer.properties (kopia robocza)
@@ -13,3 +13,7 @@
avr.programmer.jtag1=jtag1
avr.programmer.jtag1port=/dev/ttyUSB2
+
+avr.programmer.avrispport=/dev/cuaU0
+avr.programmer.avrispspeed=19200
+avr.programmer.avrisp=avrisp
------------------------------------------------------------------------------
This SF.net email is sponsored by
Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev
_______________________________________________
Amforth-devel mailing list
Amforth-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amforth-devel