Hallo zusammen,
ich benutze den Teensy 3.2 und möchte diesen mit C Programmieren.
Leider wird dies nicht standardmäßig unterstützt, es gibt aber z.b. hier
eine Beispiel welches Funktionieren sollte:
https://github.com/kcuzner/teensy31-blinky-bare-metal
Ich habe alle benötigten Komponenten Installiert und benutzte NetBeans
IDE und habe alle Dateien eingebunden.
Die Adresse habe ich wie gefordert geändert:
# Select the toolchain by providing a path to the top level
# directory; this will be the folder that holds the
# arm-none-eabi subfolders. On linux, this should be /usr or
/usr/local.
TOOLPATH = C:\4.9 2015q3
# Holds the base path to the teensyduino installation. We point
specifically
# to the teensy3 path since we are only compiling for the teensy 3.0 or
# teensy 3.1. This path contains the *.h, *.c, and *.cpp files that we
need
# in order to initialize the chip. We could write our own and that
could be
# fun, but this makefile will use the ones that come with Teensyduino
for
# efficiency's sake.
#TEENSY3X_BASEPATH = $(HOME)/arduino 1.0.5/hardware/teensy/cores/teensy3
TEENSY3X_BASEPATH = C:\Arduino\hardware\teensy\avr\cores\teensy3
Leider bekomme ich aber nur eine Fehlermeldung das die Dateien nicht
gefunden werden:
cd 'C:\Users\ArbeitUndLos\Desktop\teensy31-blinky-bare-metal-master'
C:\WinAVR\utils\bin\make.exe -f Makefile
Compiling src/blinky.c, writing to obj/blinky.o...
C:\4.9 2015q3/bin/arm-none-eabi-gcc -Wall -fno-common -mcpu=cortex-m4
-mthumb -MMD -O0 -g -IC:\4.9 2015q3/arm-none-eabi/include
-IC:\Arduino\hardware\teensy\avr\cores\teensy3 -Iinclude -I.
-DF_CPU=96000000 -D__MK20DX256__ -DUSB_SERIAL -c src/blinky.c -o
obj/blinky.o > obj/blinky.lst
/usr/bin/sh: C:4.9: command not found
make: *** [obj/blinky.o] Error 127
BUILD FAILED (exit value 2, total time: 105ms)
Ich habe die Windows Pfadstruktur genommen, aber sehe natürlich das er
die Linux Struktur genommen hat. Ich bin mir aber auch nicht so sicher
ob das wirklich das Problem ist!
Über Hilfe wäre ich sehr dankbar
Wieder mal "ino"-Geraffel. :-)
Das inkriminierte Kommando ist:
> C:\4.9 2015q3/bin/arm-none-eabi-gcc -Wall -fno-common -mcpu=cortex-m4
-mthumb -MMD -O0 -g -IC:\4.9 2015q3/arm-none-eabi/include
-IC:\Arduino\hardware\teensy\avr\cores\teensy3 -Iinclude -I.
-DF_CPU=96000000 -D__MK20DX256__ -DUSB_SERIAL -c src/blinky.c -o
obj/blinky.o > obj/blinky.lst
Was von sh mit folgender Meldung quittiert wird:
> /usr/bin/sh: C:4.9: command not found
Korrigiere die Pfadtrenner und wenn Du Leerzeichen in den Pfaden
vermeidest, ersparst Du Dir auch eine Menge Ärger.
ManInNight schrieb:> TOOLPATH = C:\4.9 2015q3
Wer macht denn sowas?
Leerzeichen in Pfadangaben sind praktisch immer eine ganz schlechte
Idee.
> C:\4.9 2015q3/bin/arm-none-eabi-gcc -Wall -fno-common -mcpu=cortex-m4> -mthumb -MMD -O0 -g -IC:\4.9 2015q3/arm-none-eabi/include
denn woher soll denn der arme Compiler wissen, dass das
"2015q3/arm-none-eabi/include" noch zum Pfadteil hier "-IC:\4.9" mit
dazu gehört?
Lass so einen Quatsch.
Wir sind Software Entwickler. Wir haben kein Problem damit, in Pfaden
keine Umlaute oder ungewöhnliche Sonderzeichen oder gar Leerzeichen zu
benutzen. Das sind Dinge für Manager, die sonst morgen nicht mehr das
Verzeichnis finden, in dem sie ihre Power Point Präsentationen abgelegt
haben, wenn der Pfad nicht "Eigene Dokumente\Mänager\Schmier Geld\Jahr
2015\Geheim" lautet.
ManInNight schrieb:> Die Datei gibt es auf aber aber irgendwie hat er die Ordner Struktur> raus genommen?
Das Zeichen für einen Pfadtrenner ist in Linux ein '/' und kein '\'
Ergo im Makefile hier
ändern. Das funktioniert auch auf Windows immer noch.
Microsoft konnte sich wohl nicht entscheiden, ob sie '\' oder doch
lieber '/' benutzen sollen. Also unterstützen sie beides.
Aber mit allen Tools, die aus der Unix Welt kommen, kann es Probleme
geben.
Zumal der "\" ja gemeinhin dazu dient, das nachfolgende Zeichen zu
maskieren. Deswegen müssen Backslashes ebenfalls maskiert werden, und
zwar -- Überraschung -- mit einem weiteren Backslash. Also sollte
entweder
>> Zumal der "\" ja gemeinhin dazu dient, das nachfolgende Zeichen zu> maskieren.
Das gilt aber nicht im Präprozesser bei den Pfadangaben bei einem
#include :-)
cd 'C:\Users\ArbeitUndLos\Desktop\teensy31-blinky-bare-metal-master'
C:\WinAVR\utils\bin\make.exe -f Makefile
Compiling C:/Arduino/hardware/teensy/avr/cores/teensy3/yield.cpp,
writing to obj/yield.o...
C:/arm/bin/arm-none-eabi-gcc -Wall -fno-common -mcpu=cortex-m4 -mthumb
-MMD -O0 -g -IC:/arm/arm-none-eabi/include
-IC:/Arduino/hardware/teensy/avr/cores/teensy3 -Iinclude -I.
-DF_CPU=96000000 -D__MK20DX256__ -DUSB_SERIAL -c
C:/Arduino/hardware/teensy/avr/cores/teensy3/yield.cpp -o obj/yield.o
In file included from
C:/Arduino/hardware/teensy/avr/cores/teensy3/WString.h:29:0,
from
C:/Arduino/hardware/teensy/avr/cores/teensy3/Print.h:38,
from
C:/Arduino/hardware/teensy/avr/cores/teensy3/Stream.h:24,
from
C:/Arduino/hardware/teensy/avr/cores/teensy3/HardwareSerial.h:169,
from
C:/Arduino/hardware/teensy/avr/cores/teensy3/yield.cpp:32:
C:/Arduino/hardware/teensy/avr/cores/teensy3/avr_functions.h:97:104:
error: 'char* utoa(unsigned int, char*, int)' was declared 'extern' and
later 'static' [-fpermissive]
static inline char * utoa(unsigned int val, char *buf, int radix)
__attribute__((always_inline, unused));
^
In file included from c:\arm\arm-none-eabi\include\stdio.h:29:0,
from
C:/Arduino/hardware/teensy/avr/cores/teensy3/Print.h:35,
from
C:/Arduino/hardware/teensy/avr/cores/teensy3/Stream.h:24,
from
C:/Arduino/hardware/teensy/avr/cores/teensy3/HardwareSerial.h:169,
from
C:/Arduino/hardware/teensy/avr/cores/teensy3/yield.cpp:32:
c:\arm\arm-none-eabi\include\stdlib.h:184:8: note: previous declaration
of 'char* utoa(unsigned int, char*, int)'
char * _EXFUN(utoa,(unsigned, char *, int));
^
In file included from
C:/Arduino/hardware/teensy/avr/cores/teensy3/WString.h:29:0,
from
C:/Arduino/hardware/teensy/avr/cores/teensy3/Print.h:38,
from
C:/Arduino/hardware/teensy/avr/cores/teensy3/Stream.h:24,
from
C:/Arduino/hardware/teensy/avr/cores/teensy3/HardwareSerial.h:169,
from
C:/Arduino/hardware/teensy/avr/cores/teensy3/yield.cpp:32:
C:/Arduino/hardware/teensy/avr/cores/teensy3/avr_functions.h:99:95:
error: 'char* itoa(int, char*, int)' was declared 'extern' and later
'static' [-fpermissive]
static inline char * itoa(int val, char *buf, int radix)
__attribute__((always_inline, unused));
^
In file included from c:\arm\arm-none-eabi\include\stdio.h:29:0,
from
C:/Arduino/hardware/teensy/avr/cores/teensy3/Print.h:35,
from
C:/Arduino/hardware/teensy/avr/cores/teensy3/Stream.h:24,
from
C:/Arduino/hardware/teensy/avr/cores/teensy3/HardwareSerial.h:169,
from
C:/Arduino/hardware/teensy/avr/cores/teensy3/yield.cpp:32:
c:\arm\arm-none-eabi\include\stdlib.h:183:8: note: previous declaration
of 'char* itoa(int, char*, int)'
char * _EXFUN(itoa,(int, char *, int));
^
In file included from
C:/Arduino/hardware/teensy/avr/cores/teensy3/Print.h:38:0,
from
C:/Arduino/hardware/teensy/avr/cores/teensy3/Stream.h:24,
from
C:/Arduino/hardware/teensy/avr/cores/teensy3/HardwareSerial.h:169,
from
C:/Arduino/hardware/teensy/avr/cores/teensy3/yield.cpp:32:
C:/Arduino/hardware/teensy/avr/cores/teensy3/WString.h: In constructor
'String::String(double, unsigned char)':
C:/Arduino/hardware/teensy/avr/cores/teensy3/WString.h:67:72: warning:
delegating constructors only available with -std=c++11 or -std=gnu++11
String(double num, unsigned char digits=2) : String((float)num,
digits) {}
^
make: *** [obj/yield.o] Error 1
BUILD FAILED (exit value 2, total time: 393ms)
Ich hab erst gedacht es liegt am Compiler, deswegen habe ich einmal
MinGW versucht leider spuckt er dann aber den selben Fehler aus?
ManInNight schrieb:> Ich hab erst gedacht es liegt am Compiler, deswegen habe ich einmal> MinGW versucht leider spuckt er dann aber den selben Fehler aus?
Ja. Und?
Korrigier ihn
So schwer ist das nicht zu erkennen, was hier das Problem ist
1
C:/Arduino/hardware/teensy/avr/cores/teensy3/avr_functions.h:97:104: error: 'char* utoa(unsigned int, char*, int)' was declared 'extern' and later 'static' [-fpermissive]
2
static inline char * utoa(unsigned int val, char *buf, int radix) __attribute__((always_inline, unused));
es gibt offenbar 2 widersprüchliche Deklarationen der FUnktion utoa. Die
eine stammt aus avr_funtions.h und die andere wird wohl die sein, die
der Compiler aus seinen Standard Headern gezogen hat. Also stdlib.h
Eine der beiden muss weichen.
Na ja. Irgendwie bin ich ja eifersüchtig auf Karl Heinz - wie immer -
nachdem er das mit den Pfadtrennern und Leerzeichen wiederholt, ging das
auf einmal. Ts ts ts. :-)
Aber Fehlermeldungen lesen scheint doch ein grundsätzliches Problem zu
sein. Man muss zugegeben, dass in dem "Zeichenfriedhof" aber erst mal
ein Anfang gefunden werden muss. Der ist recht gut an den Kommandos zu
erkennen. GCC oder ln oder was sonst so aufgerufen wird. Danach gehst
mit Dateipfaden weiter nach denen dann die Fehlermeldungen folgen. Da
muss man in diesem Fall erkennen, dass eine Kaskade vorliegt. Geht aber.
Einfach mal 1 Minute draufstarren und nichts denken.
ok danke, hat etwas gedauert bis ich kapiert hab was da Falsch gelaufen
ist.
Ich hab nochmal ein wenig geschaut und festgestellt das ich alles Falsch
eingebunden habe, daher habe ich es nochmal neu mit der Einbindung von
Arduino.h und einer anderen Makefile versucht:
#
# This makefile started life as the Makefile from teensy-template, found
here:
# https://github.com/apmorton/teensy-template
#
ifeq ($(v),)
export verbose = 0
else
export verbose = 1
endif
ifeq ($(verbose),)
export verbose = 0
endif
ifeq ($(verbose),0)
Q = @
MAKEFLAGS += -s
else
Q =
endif
export Q
# The name of your project (used to name the compiled .hex file)
TARGET = $(notdir $(CURDIR))
# configurable options
OPTIONS = -DF_CPU=96000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH
# options needed by many Arduino libraries to configure for Teensy 3.0
OPTIONS += -D__MK20DX256__ -DARDUINO=105
BUILDDIR = build
ifdef COMSPEC
cygpath-win = $(shell cygpath -w "$1")
else
cygpath-win = $1
endif
#***********************************************************************
*
# Location of Teensyduino utilities, Toolchain, and Arduino Libraries.
# To use this makefile without Arduino, copy the resources from these
# locations and edit the pathnames. The rest of Arduino is not needed.
#***********************************************************************
*
ARDUINO ?=C:/Arduino
# path location for Teensy Loader, teensy_post_compile and teensy_reboot
TOOLS_PATH = $(ARDUINO)/hardware/tools
# path location for Teensy 3 core
CORE_PARENT = $(ARDUINO)/hardware/teensy/avr/cores
CORE_PATH = $(CORE_PARENT)/teensy3
# path location for Arduino libraries
LIBRARY_PARENT = ..
LIBRARY_PATH = $(LIBRARY_PARENT)/libraries
# path location for the arm-none-eabi compiler
COMPILER_PATH = $(TOOLS_PATH)/arm/bin
#***********************************************************************
*
# Settings below this point usually do not need to be edited
#***********************************************************************
*
# CPPFLAGS = compiler options for C and C++
CPPFLAGS = -Wall -Wno-psabi -g -Os -mcpu=cortex-m4 -mthumb -nostdlib
-MMD $(OPTIONS) -Isrc -I$(CORE_PATH)
# compiler options for C++ only
CXXFLAGS = -std=gnu++0x -felide-constructors -fno-exceptions -fno-rtti
# compiler options for C only
CFLAGS =
LDSCRIPT = $(CORE_PATH)/mk20dx256.ld
# linker options
LDFLAGS = -Os -Wl,--gc-sections -mcpu=cortex-m4 -mthumb -T$(LDSCRIPT)
# additional libraries to link
LIBS = -lm
# names for the compiler programs
CC = $(COMPILER_PATH)/arm-none-eabi-gcc
CXX = $(COMPILER_PATH)/arm-none-eabi-g++
OBJCOPY = $(COMPILER_PATH)/arm-none-eabi-objcopy
SIZE = $(COMPILER_PATH)/arm-none-eabi-size
vpath %.c $(LIBRARY_PARENT)
vpath %.cpp $(LIBRARY_PARENT)
vpath %.c $(CORE_PARENT)
vpath %.cpp $(CORE_PARENT)
# automatically create lists of the sources and objects
LC_FILES := $(patsubst $(LIBRARY_PARENT)/%, %, $(wildcard
$(LIBRARY_PATH)/*/*.c))
LCPP_FILES := $(patsubst $(LIBRARY_PARENT)/%, %, $(wildcard
$(LIBRARY_PATH)/*/*.cpp))
TC_FILES := $(patsubst $(CORE_PARENT)/%, %, $(wildcard
$(CORE_PATH)/*.c))
TCPP_FILES := $(patsubst $(CORE_PARENT)/%, %, $(wildcard
$(CORE_PATH)/*.cpp))
C_FILES := $(wildcard src/*.c)
CPP_FILES := $(wildcard src/*.cpp)
INO_FILES := $(wildcard src/*.ino)
# include paths for libraries
L_INC := $(foreach lib,$(filter %/, $(wildcard $(LIBRARY_PATH)/*/)),
-I$(lib))
OBJS_FILES := $(INO_FILES:.ino=.o) $(C_FILES:.c=.o) $(CPP_FILES:.cpp=.o)
$(TC_FILES:.c=.o) $(TCPP_FILES:.cpp=.o) $(LC_FILES:.c=.o)
$(LCPP_FILES:.cpp=.o)
OBJS := $(foreach obj,$(OBJS_FILES), $(BUILDDIR)/$(obj))
all: hex
build: $(TARGET).elf
hex: $(TARGET).hex
post_compile: $(TARGET).hex
$(Q)$(TOOLS_PATH)/teensy_post_compile -file="$(basename $<)"
-path="$(call cygpath-win,$(CURDIR))" -tools="$(TOOLS_PATH)"
reboot:
$(Q)-$(TOOLS_PATH)/teensy_reboot
upload: post_compile reboot
$(BUILDDIR)/%.o: %.c
@echo "[CC]\t$<"
$(Q)mkdir -p "$(dir $@)"
$(Q)$(CC) $(CPPFLAGS) $(CFLAGS) $(L_INC) -o "$@" -c "$<"
$(BUILDDIR)/%.o: %.ino
@echo "[CXX]\t$<"
$(Q)mkdir -p "$(dir $@)"
$(Q)$(CC) $(CPPFLAGS) $(CXXFLAGS) $(L_INC) -o "$@" -c -x c++ -include
Arduino.h "$<"
$(BUILDDIR)/%.o: %.cpp
@echo "[CXX]\t$<"
@mkdir -p "$(dir $@)"
$(Q)$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(L_INC) -o "$@" -c "$<"
$(TARGET).elf: $(OBJS) $(LDSCRIPT)
@echo "[LD]\t$@"
$(Q)$(CC) $(LDFLAGS) -o "$@" -Wl,-Map,$(TARGET).map $(OBJS) $(LIBS)
%.hex: %.elf
@echo "[HEX]\t$@"
$(Q)$(SIZE) "$<"
$(Q)$(OBJCOPY) -O ihex -R .eeprom "$<" "$@"
# compiler generated dependency info
-include $(OBJS:.o=.d)
clean:
@echo Cleaning...
$(Q)rm -rf "$(BUILDDIR)"
$(Q)rm -f "$(TARGET).elf" "$(TARGET).hex" "$(TARGET).map"
Das klappt auch deutlich besser bis leider dieser Fehler auftaucht
$ make
[CC]\tsrc/main.c
c:/arduino/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/4.8.4/../../.
./../arm-none-eabi/bin/ld.exe: warning: cannot find entry symbol
_start; defaulting to 00008000
[CC]\tC:/Arduino/hardware/teensy/avr/cores/teensy3/analog.c
c:/arduino/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/4.8.4/../../.
./../arm-none-eabi/bin/ld.exe: warning: cannot find entry symbol
_start; defaulting to 00008000
C:\cygwin64\tmp\ccQmmT0W.o: In function `analogRead':
C:/Arduino/hardware/teensy/avr/cores/teensy3/analog.c:453: undefined
reference to `yield'
C:/Arduino/hardware/teensy/avr/cores/teensy3/analog.c:484: undefined
reference to `yield'
collect2.exe: error: ld returned 1 exit status
make: *** [build/teensy3/analog.o] Error 1
Leider bin ich nicht so sicher was er da von mir will zum einen scheint
er die Funktion yield() in analog.h nicht zu kennen aber ich verstehe
den Fehler mit ld.exe leider überhaupt nicht.
um den Teensy3 in C ohne das ..ino-Zeugs zu programmieren, würde ich
mich lieber an das hier halten. Das ist zwar auch überwiegend
zusammengeklaut, kommt aber komplett ohne die ino-includes aus.
Die Struktur ist für Linux, compiliert aber ohne Änderungen (die
arm-none-eabi- toolchain muß natürlich im Pfad sein) auch auf cygwin und
Mac OS X.