avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Possible avr-gcc or binutils problem


From: E. Weddington
Subject: Re: [avr-gcc-list] Possible avr-gcc or binutils problem
Date: Wed, 04 Jun 2003 07:55:54 -0600


Nick Downing wrote:

> dear List,
>
> Please can someone provide a bit of newby help?  I am trying to get
> started with avr-gcc but I found a number of rather strange problems.
> First I will include my code and makefiles so that others can duplicate
> the problem I found.  I'll paste directly into here.  Here goes:
>
> ---- cut here ----
> /* hello.h by Nick for Hytech AVR */
>
> int my_putc(char c);
> int my_getc(void);
> int main(void);
>
> ---- cut here ----
> /* hello.c by Nick for Hytech AVR */
>
> #include <stdio.h>
> #include <avr/io.h>
> #include "hello.h"
>
> int my_putc(char c)
>         {
>         while (bit_is_set(UCSRA, UDRE) == 0)
>                 ;
>         UDR = c;
>         return 0;
>         }
>
> int my_getc(void)
>         {
>         if (bit_is_set(UCSRA, RXC) == 0)
>                 return -1;
>         return UDR;
>         }
>
> int main(void)
>         {
>         /* initialise the AVR's built-in UART for 9600 bps */
>         UCSRA = _BV(TXC);
>         UCSRB = _BV(TXEN) | _BV(RXEN);
>         UBRR = 71;
>         /* UBRRH = 0; */ /* = (11059200 / (9600 * 16)) - 1 */
>
> #if 1
>         /* send a demo message to ISPD via the AVR's UART */
>         my_putc('h');
>         my_putc('e');
>         my_putc('l');
>         my_putc('l');
>         my_putc('o');
> #else
>         /* setup the standard input, output and error streams */
>         fdevopen(my_putc, my_getc, 0);
>
>         /* send a demo message to ISPD via the AVR's UART */
>         printf("hello, world\r\n");
> #endif
>
>         /* enter an infinite loop as we can never exit */
>         while (1)
>                 ;
>         }
>
> ---- cut here ----
>
> My compiler is installed from the following set of rpm's:
>
> avr-binutils-2.13.90.030512-1.i386.rpm
> avr-gcc-3.2.90.20030512-1.i386.rpm
> avr-libc-20030512cvs-1.i386.rpm
> avr-libc-docs-20030512cvs-1.i386.rpm
>

It's best to use GCC 3.3 and not 3.2.

>
> The code seems to compile properly, using my "bash" script as follows:
>
> ---- cut here ----
> #!/bin/sh
> avr-gcc -mmcu=at90s4433 -Wl,--oformat,ihex hello.c -o hello.hex
> ---- cut here ----
>
> As you can see, I selected an output format of "Intel Hex" since this is
> the needed format for our programmer tool.  Does anyone know whether the
> switch "--oformat ihex" to "avr-ld" works properly?  Perhaps I should be
> building an "elf" binary and then extracting the code segment as "hex"??
>

That is typical, to build ELF and convert ELF to Intel Hex. For the best way
to do this, look at the two examples that are part of the avr-libc project.
You can look at their makefiles.

>

<snip>

>
>
> I tried WinAVR (versions from 2002 and 2003) and it still produced the
> same .hex output as my Linux system.  So that's not the problem.  At a
> guess it's probably my use of "--oformat ihex" that's causing a problem?
>

If you used WinAVR, then look at the sample makefile that comes with it
(especially a more recent release) on how to build the ELF and convert to
hex.

>
> Thanks in advance,
> cheers,
> Nick
>
> ps.  Does anyone know of an AVR resources page where I could download a
> program similar to the above?  Preferably a working one, unlike mine.
> :)  I found something, but it won't compile because of "__outw_atomic"
> which seems to be deprecated in this version of avr-gcc??  Does anyone
> know why this symbol is now broken?  I want to use it to read the timer!
>
> pps.  I am unsure of how to instruct avr-gcc to put strings and/or
> constants into Flash.  Can someone please advise?  By default, they seem
> to go into SRAM.  I have been unable to verify that they really get
> copied from Flash to SRAM but I would assume this is the reason for the
> "__do_copy_data()" symbol.  Do I have to call this myself?  I was going
> to check this by looking at the "revava" output but it's too confusing.
>

Look in the avr-libc documentation (and FAQ) on how to put strings / const
in flash.

>
> ppps.  Once a string has been defined in Flash (or a constant array),
> how do I set up a pointer into Flash so I can read it?  I would assume
> that any pointer variables (for example "char *p;") would have to be
> declared differently in this case.  Can someone please advise??  Thanks!
>

Again, see the docs.

Eric



reply via email to

[Prev in Thread] Current Thread [Next in Thread]