ports/186646: avr-gcc avr-binutils avr-libc atxmega64d4 support
Bob Frazier
bobf at mrp3.com
Tue Feb 11 10:00:00 UTC 2014
>Number: 186646
>Category: ports
>Synopsis: avr-gcc avr-binutils avr-libc atxmega64d4 support
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Tue Feb 11 10:00:00 UTC 2014
>Closed-Date:
>Last-Modified:
>Originator: Bob Frazier
>Release: RELENG_8
>Organization:
S.F.T. Inc.
>Environment:
FreeBSD BSDSilver.SFT.local 8.4-STABLE FreeBSD 8.4-STABLE #0: Thu Feb 6 19:45:28 PST 2014 root at BSDSilver.SFT.local:/usr/obj/usr/src/sys/GENERIC amd64
>Description:
The devel/avr-gcc, devel/avr-libc, and devel/avr-binutils lack support for the atxmega64d4 processor, which differs significantly enough from other processors that it needs its own header file and startup code.
I have been working for a couple of months with a patched version of this port. I am submitting my patch files which I have tested against the latest versions of the 3 ports, specifically avr-binutils-2.20.1_1, avr-gcc-4.5.1_2, and avr-libc-1.8.0_1,1
Additionally the avr-libc code contains a minor fix for an editing error in avr/power.h and corrects a C++ startup code bug for all ATXMEGA processors (registers were not being preserved before calling the C++ startup/constructor code, and a boot loop was likely to happen).
>How-To-Repeat:
this is a request to add support for the atxmega64d4 processor
>Fix:
apply patches in the attached 'shar' archive, and in the supplementary patch (300kb) that is available at http://mrp3.com/avr.patch2.tgz (it is a tarball containing only the 'avr.patch2.txt' patch file for avr-libc).
The 2 files in avr.patch1.txt and the first 3 files in avr.patch2.txt are to be placed in the 'files' directory in the corresponding port. The final file in avr.patch2.txt' ( 'pkg-plist.patch' ) is a patch file to be applied to avr-libc/pkg-plist [two files are being added to the distribution].
(the avr-libc patch is too large to attach to this problem report, so I made it available on my web site)
once the ports have been re-built using these patches, the atxmega64d4 will be supported by gcc and binutils, and the correct header and startup code will be available.
Patch attached with submission follows:
# This is a shell archive. Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file". Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
# avr-gcc/files/patch-307-gcc-4.5.1-xmegaD4-and-cpp-startup
# avr-binutils/files/patch-412-binutils-2.20.1-atxmegaD4
#
echo x - avr-gcc/files/patch-307-gcc-4.5.1-xmegaD4-and-cpp-startup
sed 's/^X//' >avr-gcc/files/patch-307-gcc-4.5.1-xmegaD4-and-cpp-startup << '2700e6350f5dc8999f39730dee82ab2b'
Xdiff -Naurp gcc/config/avr/avr-devices.c gcc/config/avr/avr-devices.c
X--- gcc/config/avr/avr-devices.c 2014-02-10 22:51:04.000000000 -0800
X+++ gcc/config/avr/avr-devices.c 2014-02-10 23:00:00.000000000 -0800
X@@ -259,6 +259,7 @@ const struct mcu_type_s avr_mcu_types[]
X { "avrxmega4", ARCH_AVRXMEGA4, NULL, 0, 0x2000, "x64d3" },
X { "atxmega64a3", ARCH_AVRXMEGA4, "__AVR_ATxmega64A3__", 0, 0x2000, "x64a3" },
X { "atxmega64d3", ARCH_AVRXMEGA4, "__AVR_ATxmega64D3__", 0, 0x2000, "x64d3" },
X+ { "atxmega64d4", ARCH_AVRXMEGA4, "__AVR_ATxmega64D4__", 0, 0x2000, "x64d4" },
X /* Xmega, > 64K, <= 128K FLASH, > 64K RAM. */
X { "avrxmega5", ARCH_AVRXMEGA5, NULL, 0, 0x2000, "x64a1" },
X { "atxmega64a1", ARCH_AVRXMEGA5, "__AVR_ATxmega64A1__", 0, 0x2000, "x64a1" },
X
Xdiff -Naurp gcc/config/avr/t-avr gcc/config/avr/t-avr
X--- gcc/config/avr/t-avr 2014-02-10 22:51:04.000000000 -0800
X+++ gcc/config/avr/t-avr 2014-02-10 23:00:00.000000000 -0800
X@@ -273,6 +273,7 @@ MULTILIB_MATCHES = \
X mmcu?avrxmega2=mmcu?atxmega32x1 \
X mmcu?avrxmega4=mmcu?atxmega64a3 \
X mmcu?avrxmega4=mmcu?atxmega64d3 \
X+ mmcu?avrxmega4=mmcu?atxmega64d4 \
X mmcu?avrxmega5=mmcu?atxmega64a1 \
X mmcu?avrxmega5=mmcu?atxmega64a1u \
X mmcu?avrxmega6=mmcu?atxmega128a3 \
X
Xdiff -Naurp gcc/config/avr/libgcc.S gcc/config/avr/libgcc.S
X--- gcc/config/avr/libgcc.S 2014-02-10 22:51:04.000000000 -0800
X+++ gcc/config/avr/libgcc.S 2014-02-10 23:00:00.000000000 -0800
X@@ -894,13 +894,31 @@ __do_global_ctors:
X mov_h r31, r29
X mov_l r30, r28
X out __RAMPZ__, r20
X+#if defined (__AVR_XMEGA__)
X+/* before I go and do this for everyone, make sure it's good on XMEGA */
X+/* but I want to save all affected registers for this loop so ctors */
X+/* do not loop infinitely during application startup. Saw on xmega D4 */
X+ push r17
X+ push r16
X+ push r28
X+ push r29
X+ push r20
X+#endif // defined (__AVR_XMEGA__)
X XCALL __tablejump_elpm__
X+#if defined (__AVR_XMEGA__)
X+/* restore registers pushed in added section above */
X+ pop r20
X+ pop r29
X+ pop r28
X+ pop r16
X+ pop r17
X+#endif // defined (__AVR_XMEGA__)
X .L__do_global_ctors_start:
X cpi r28, lo8(__ctors_start)
X cpc r29, r17
X cpc r20, r16
X brne .L__do_global_ctors_loop
X-#else
X+#else // no RAMPZ
X __do_global_ctors:
X ldi r17, hi8(__ctors_start)
X ldi r28, lo8(__ctors_end)
X@@ -945,7 +963,25 @@ __do_global_dtors:
X mov_h r31, r29
X mov_l r30, r28
X out __RAMPZ__, r20
X+#if defined (__AVR_XMEGA__)
X+/* before I go and do this for everyone, make sure it's good on XMEGA */
X+/* but I want to save all affected registers for this loop so ctors */
X+/* do not loop infinitely during application startup. Saw on xmega D4 */
X+ push r17
X+ push r16
X+ push r28
X+ push r29
X+ push r20
X+#endif // defined (__AVR_XMEGA__)
X XCALL __tablejump_elpm__
X+#if defined (__AVR_XMEGA__)
X+/* restore registers pushed in added section above */
X+ pop r20
X+ pop r29
X+ pop r28
X+ pop r16
X+ pop r17
X+#endif // defined (__AVR_XMEGA__)
X .L__do_global_dtors_start:
X cpi r28, lo8(__dtors_end)
X cpc r29, r17
X
2700e6350f5dc8999f39730dee82ab2b
echo x - avr-binutils/files/patch-412-binutils-2.20.1-atxmegaD4
sed 's/^X//' >avr-binutils/files/patch-412-binutils-2.20.1-atxmegaD4 << '753284b9f26eab33c817f941925cefb6'
Xdiff -Naurp binutils/size.c binutils/size.c
X--- binutils/size.c 2014-02-10 23:31:57.000000000 -0800
X+++ binutils/size.c 2014-02-10 23:40:00.000000000 -0800
X@@ -151,6 +151,7 @@ avr_device_t avr[] =
X {"atxmega64a1u", AVR68K, AVR4K, AVR2K},
X {"atxmega64a3", AVR68K, AVR4K, AVR2K},
X {"atxmega64d3", AVR68K, AVR4K, AVR2K},
X+ {"atxmega64d4", AVR68K, AVR4K, AVR2K},
X
X {"at90can64", AVR64K, AVR4K, AVR2K},
X {"at90scr100", AVR64K, AVR4K, AVR2K},
X
Xdiff -Naurp gas/config/tc-avr.c gas/config/tc-avr.c
X--- gas/config/tc-avr.c 2014-02-10 23:31:57.000000000 -0800
X+++ gas/config/tc-avr.c 2014-02-10 23:40:00.000000000 -0800
X@@ -263,6 +263,7 @@ static struct mcu_type_s mcu_types[] =
X {"atxmega32x1", AVR_ISA_XMEGA, bfd_mach_avrxmega2},
X {"atxmega64a3", AVR_ISA_XMEGA, bfd_mach_avrxmega4},
X {"atxmega64d3", AVR_ISA_XMEGA, bfd_mach_avrxmega4},
X+ {"atxmega64d4", AVR_ISA_XMEGA, bfd_mach_avrxmega4},
X {"atxmega64a1", AVR_ISA_XMEGA, bfd_mach_avrxmega5},
X {"atxmega64a1u",AVR_ISA_XMEGA, bfd_mach_avrxmega5},
X {"atxmega128a3", AVR_ISA_XMEGA, bfd_mach_avrxmega6},
X
Xdiff -Naurp gas/doc/c-avr.texi gas/doc/c-avr.texi
X--- gas/doc/c-avr.texi 2014-02-10 23:31:57.000000000 -0800
X+++ gas/doc/c-avr.texi 2014-02-10 23:40:00.000000000 -0800
X@@ -93,7 +93,8 @@ Instruction set avrxmega3 is for the XME
X memory space and greater than 64K data space (MCU types: none).
X
X Instruction set avrxmega4 is for the XMEGA AVR core with up to 64K program
X-memory space and less than 64K data space (MCU types: atxmega64a3, atxmega64d3).
X+memory space and less than 64K data space (MCU types: atxmega64a3, atxmega64d3,
X+atxmega64d4).
X
X Instruction set avrxmega5 is for the XMEGA AVR core with up to 64K program
X memory space and greater than 64K data space (MCU types: atxmega64a1,
X
753284b9f26eab33c817f941925cefb6
exit
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list