|
From: | Georg-Johann Lay |
Subject: | Re: [avr-gcc-list] avr-gcc and char strings |
Date: | Mon, 15 Dec 2014 19:58:52 +0100 |
User-agent: | Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 |
Am 12/03/2014 10:11 PM, schrieb Andreas Höschler:
Hi all, I am close to tearing my hair out. After having established the avr tool chain I tried out a very simple C-program (see below) on an SainSmart Mega2560 board programmed into the chip by making use of /Applications/Arduino.app//Contents/Resources/Java/hardware/tools/avr/bin/avrdude: [code using .[ro]data] This program produces the following output ... ÿÿÿÿÿÿÿÿÿÿÿÿÿÿABC ÿÿÿÿÿÿÿÿÿÿÿÿÿÿABC ÿÿÿÿÿÿÿÿÿÿÿÿÿÿABC ... telling me that sending single chars works but sending strings fails (does not seem to have anything to do with the serial communication but rather be some kind of memory management problem!??). To be sure the problem is not caused by my own gcc build I changed my Makefile to
FYI, What counts are the command options that are passed to the compiler in the and; just Makefile variables / snippets might not be enough for others to help you (except you are having problems with make).
# AVR-GCC Makefile PROJECT=toggle_led SOURCES=main.c HEADERS= CC=/Applications/Arduino.app//Contents/Resources/Java/hardware/tools/avr/bin/avr-gcc OBJCOPY=avr-objcopy MMCU=atmega2560 CFLAGS=-mmcu=$(MMCU) -Wall -O2 -I /usr/local/avr/include
Adding this include path should never ever be needed. If you toolchain installation does not work without it, that installation is broken and the right approach is to get a working distribution of the toolchain.
You can even mess up you builds by specifying include path or library path that appear correct to you but actually are not. The compiler(driver) always knows its own paths. Sometimes tools like Code::Blocks that try to be smarter than they actually are and will add such paths. Make sure you IDE or whatever generated this Makefile is sane in this respect.
$(PROJECT).hex: $(PROJECT).out $(OBJCOPY) -j .text -O ihex $(PROJECT).out $(PROJECT).hex
You are using data from input section .data* resp. .rodata* (namely by string literal "Hello world!!") which in turn is initialized at startup time from flash. Hence you may also include .data when building your executable.
Johann
[Prev in Thread] | Current Thread | [Next in Thread] |