1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
This works with new USE=ada toolchain overlay from 5.4 up and the newer
crossdev, however, crossdev-99999999 still wants to put the cross overlay
in the wrong place. The --ov-output swicth does create the overlay but
then crossdev fails to look there. Apparently using the (deprecated)
PORTDIR_OVERLAY env var is the best way...
Note these also work (up through cortex-M4, not tested with avr yet)
with USE=ada for cross/embedded gnat. For non-glibc/bare-metal
(currently armv7m with newlib) you should also add "--disable-libada"
to EXTRA_ECONF.
Note you may need to play with USE flags and set your system linker to
bfd first if gold is default.
This worked for arm:
USE="-graphite hardened -fortran -jit" \
EXTRA_ECONF="--with-arch=armv7-a --with-tune=cortex-a9 \
--with-float-abi=hard --with-fpu=vfpv3-d16" \
crossdev -v -t armv7a-hardfloat-linux-gnueabi --ex-gdb
as of 10/06/2017 with:
gcc 6.4.0/5.4.0
binutils 2.29.1/2.28.1
glibc 2.25-r5
linux-headers 4.13
To go back slightly to match previous headers, and add some USE flags:
(remember to disable other overlays first)
PORTDIR_OVERLAY="/usr/local/armv7-a /var/lib/layman/ada" \
USE="ada -graphite hardened -fortran -go -jit multitarget -openmp -vtv" \
EXTRA_ECONF="--with-arch=armv7-a --with-tune=cortex-a9 --with-float-abi=hard --with-fpu=vfpv3-d16" \
crossdev --g 5.4.0-r4 --b 2.28.1 --k 4.10 --l 2.24-r4 \
-t armv7a-hardfloat-linux-gnueabi --ex-gdb -v
For gcc 4.9.4 try:
PORTDIR_OVERLAY="/usr/local/armv7-a" \
USE="-graphite -hardened -fortran -go -jit multitarget -openmp -vtv" \
EXTRA_ECONF="--with-arch=armv7-a --with-tune=cortex-a9 --with-float-abi=hard --with-fpu=vfpv3-d16" \
crossdev --g 4.9.4-r1 --b 2.28.1 \
-t armv7a-hardfloat-linux-gnueabi --ex-gdb -v
This worked for arm64:
crossdev -v -t aarch64-unknown-linux-gnu --ex-gdb
This worked for cortex-M4:
Change the tuning to match your cpu; you need s4 for c++ and ada
(you may also want to relax the hardened flags).
USE="hardened multitarget lzma multilib -openmp -fortran -jit" \
EXTRA_ECONF="--disable-multilib --disable-libsanitizer \
--with-arch=armv7e-m --with-tune=cortex-m4 --with-float-abi=hard \
--with-fpu=fpv4-sp-d16 --with-mode=thumb" \
crossdev -t armv7m-hardfloat-eabi -s4 --ex-gdb \
--show-fail-log --ov-output /usr/local/cortex-m4
For Arduino IDE we need multilib for multiple cortex-M cpus (and most
don't have FPUs except cortex-M4). Note the overlays are for Ada support
and local newlib package.
PORTDIR_OVERLAY="/usr/local/cortex-m3 /usr/local/portage /var/lib/layman/ada" \
USE="ada hardened multitarget lzma multilib -nls -openmp -fortran -jit -sanitize -vtv" \
crossdev --g 6.4.0 -s4 -t armv7m-hardfloat-eabi \
--genv 'EXTRA_ECONF="--with-newlib --disable-libada --with-arch=armv7e-m --with-tune=cortex-m4 --with-float-abi=hard --with-fpu=fpv4-sp-d16 --with-mode=thumb --with-abi=aapcs-linux --enable-libstdcxx-time=no --with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm" \
INHIBIT_LIBC_CFLAGS="-DUSE_TM_CLONE_REGISTRY=0"' \
--lenv 'USE="newlib-nano"' \
--benv 'USE='multitarget'' --ex-gdb --show-fail-log
This works for avr:
Note that, except for pie, hardened and sanitizer can be enabled,
but should be disabled if anything doesn't look right. Also note
that graphite appears to optimize the arduino sketch loops away,
so you probably don't want that...
And arduino/other newer builds seem to require c++ and even -flto (which
also means it needs gold linker and plugins, maybe a manual step now...
So binutils and gcc need USE=cxx along with stage4 to build the right stuff.
Lastly note you should not need anything older than 4.9.4 and 2.29.1 for
current arduino IDE use. If you switch to older binutils after installing
current avr toolchain you'll need to make a manual symlink for ldscripts.
PORTDIR_OVERLAY="/usr/local/portage/cross-avr" \
USE="cxx -graphite -hardened multitarget lzma multilib -sanitize -nls -openmp -pie -fortran -jit -vtv" \
EXTRA_ECONF="--enable-libstdcxx-time=no" \
crossdev --g 6.4.0 -t avr -s4 --ex-gdb --show-fail-log -v
This works for avr and older gcc / binutils:
Note gcc 4.8.4 is broken wrt avr-libc, at least it fails mmcu compat test
for "standard" arduino cpus (notably uno and mega) so does not install the
required crtm*.o files.
PORTDIR_OVERLAY="/usr/local/portage/cross-avr" \
USE="cxx -graphite -hardened multitarget lzma multilib -nls -openmp nopie nossp -sanitize -fortran -jit -vtv" \
EXTRA_ECONF="--enable-libstdcxx-time=no" \
crossdev --g 4.9.4-r1 --b 2.25.1-r1 -t avr -s4 \
--ex-gdb --show-fail-log -v
Hardened mipsel with musl, for that Onion thing (mips abi is a guess)
Note: cross-musl gets contaminated with host cflags/ldflags so you need
to pass -march and -mtune to match your tatget:
PORTDIR_OVERLAY="/usr/local/mips32r2" \
USE="-graphite hardened multitarget -multilib -vtv -openmp -jit -fortran -sanitize" \
EXTRA_ECONF="--with-mips-plt --with-arch=mips32r2 --with-tune=24kec" \
crossdev -t mipsel-unknown-linux-musl --abis "o32" \
--lenv 'CFLAGS="-march=mips32r2 -mtune=24kec -O2 -pipe" CXXFLAGS="${CFLAGS}" LDFLAGS="${CFLAGS}"' \
-v -b --without-headers --ex-gdb
|