[En-Nut-Discussion] Programs compiled under Linux do not work

Harald Kipp harald.kipp at egnite.de
Mon Oct 28 13:25:07 CET 2002


Raphael,

Just stumbled over a similar problem.

One of this is an include file problem
(avr-libc) in conjunction with supporting two
different compilers and CPUs.

I attached an updated compiler.h.

Shame on me. I currently have installed some
old stuff, taken from

http://www.chaos-web.de/avr/

This is completely unofficial, experimental and
outdated, but works with ATmega103 and 128 on
Redhat 7.3.

Harald
-------------- next part --------------
#ifndef _COMPILER_H_
#define _COMPILER_H_

#ifdef __IMAGECRAFT__

#include <macros.h>
#include <eeprom.h>

#ifndef CONST
#define CONST
#endif

#ifndef INLINE
#define INLINE
#endif

#define __bss_end   _bss_end

#define __attribute__(x)  

#define PSTR(p)     (p)
#define PRG_RDB(p)  (*p)

#define prog_char const char

#define memcpy_P(dst, src, size)    \
{                                   \
    u_short _i;                     \
    u_char *d = dst;                \
    const u_char *s = src;          \
    for(_i = 0; _i < size; _i++)    \
        *d++ = *s++ ;               \
}

/* FIXME */
#define strcasecmp(s1, s2)  strcmp(s1, s2)
/* FIXME */
#define strncasecmp(s1, s2, n)  strncmp(s1, s2, n)

#define BV(x)       BIT(x)

#define cli()           CLI()
#define sei()           SEI()
#define cbi(reg, bit)   (reg &= ~BIT(bit))
#define sbi(reg, bit)   (reg |= BIT(bit))


#define loop_until_bit_is_set(reg, bit) while((reg & BIT(bit)) == 0)

#define bit_is_clear(reg, bit)  ((reg & BIT(bit)) == 0)
#define bit_is_set(reg, bit)    ((reg & BIT(bit)) != 0)

/* FIXME */
#define parity_even_bit(x)  (0)

/* FIXME */
#define SIGNAL(x)   void x(void)  

#define outp(val, reg)  (reg = val)
#define inp(reg)        (reg)

#ifdef _MCU_enhanced

#include <iom128.h>
#define __AVR_ATmega128__
#ifndef RAMEND
#define RAMEND  0x10FF

#ifndef UDR
#define UDR     UDR0
#define UBRR    UBRR0L
#define USR     UCSR0A
#define UCR     UCSR0B
#define EICR    EICRB
#define RXC     RXC0
#define UDRE    UDRE0
#define FE      FE0
#define OVR     DOR0
#define RXCIE   RXCIE0
#define TXCIE   TXCIE0
#define RXEN    RXEN0
#define TXEN    TXEN0
#endif

#endif
#ifndef SRW
#define SRW  6
#endif

#else   /* ATmega103 */

#include <iom103.h>

#endif

//#define eeprom_read_block(dst, addr, size)  EEPROMReadBytes(addr, (void *)dst, size)
//#define eeprom_wb(addr, src)                EEPROMWriteBytes(addr, (void *)src, 1)

#define eeprom_read_block(dst, addr, size)  EEPROMReadBytes(addr, dst, size)
#define eeprom_wb(addr, src)                EEPROMWriteBytes(addr, &src, 1)

#else   /* GCC -------------------------------------------------------------- */

#define CONST   const
#define INLINE  inline

#ifdef USE_LOW_LEVEL
#include <io.h>
#include <interrupt.h>
#include <sig-avr.h>
#endif

#ifndef __SFR_OFFSET
#define __SFR_OFFSET    0
#endif

#endif  /* GCC */



extern void * __bss_end;

#ifdef __AVR_ATmega128__
#define RAMSTART    ((void *)0x100)
#else
#define RAMSTART    ((void *)0x60)
#endif

#endif



More information about the En-Nut-Discussion mailing list