[okl4-developer] about elf and arm-linux-ld

Gabi Voiculescu b304_a at yahoo.com
Thu Apr 3 03:25:16 EST 2008


Hi.

I have been doing some progress on my OKL4 but I don't have the KDB debugger up and running yet on my pl011 uart. I have to say that interrupts and the timer might hold bugs, so bringing up the serial only is safer.

I have some questions in bold. Some aren't OKL4 specific but I hope you can give me some pointers.

I have done a bare metal program that works with ARMCC, but I want to test it with GCC.  For that I used arm-linux-... toolchain from the NICTA site. 

I have to say that my goal is to obtain a binary file, for later conversion to run in my boot (Boot Monitor) program. So far the entry point is not the one I want for the simple C code detailed below.

My initials attempt failed because I did not provide an entry point in the image and the default one (when I generate a.out) does not work for my boot loader.

I made a simple head.s (to give __start  code into my program)  but I have problems with the linker:
$arm-linux-as -o head.o head.s
$ arm-linux-ld -o con.elf con.o head.o
arm-linux-ld: ERROR: head.o uses hardware FP, whereas con.elf uses software FP
arm-linux-ld: failed to merge target specific data of file head.o


or with objcopy:
arm-linux-gcc -o con.o console.c  head.s
arm-linux-objcopy -O binary con.o con.bin

which does not work

Is there a way not to build my own linker configuration file taking as example the ones in: /opt/nicta/tools/gcc-3.4.4-glibc-2.3.5/arm-linux/arm-linux/lib/ldscripts/ ?

Can you tell me what is the right procedure?

Can you tell me more clearly what arguments (flags, options) you feed into ld from build.py and toolchains.py and what you leave as default?

Can you  tell me where do I modify the build scripts to change what is generated in elfweaver.xml? 

Can you tell me how the information in elfweaver.xml is fed into the linker? I can't find the actual python line that does this.

Gabi


The code is something like:

-------------------------console.c ------------------------------------------------
#define UART0_BASE      0x1010C000
//typedef  uint32_t word_t;

typedef unsigned int uint32_t;
typedef  uint32_t word_t;
#define NULL 0

//#define CONNFIG_KDB_CONS
/*****************************************************************************
 *   Local Defines
 *****************************************************************************/
//#if 1//defined(CONFIG_KDB_CONS)  /* up to end of file */
#define SERIAL_NAME     "serial"

// Register  Bit Definitions
#define LCR_H_WLEN(value) ((value & 0x3) << 5)    // Serail work lenght
#define LCR_H_STP2 (1UL << 3)            // 2 Stop bits

#define CR_RXE (1UL << 9)    // Rx Enable
#define CR_TXE (1UL << 8)    // Tx Enable
#define CR_URTEN (1UL << 0)    // Uart Enable
 
#define FR_TXFF (1UL << 5)    // Tx Fifo Full
#define FR_BUSY    (1UL << 3)    // Tx Busy
#define FR_RXFE    (1UL << 4)    // Rx Fifo Empty





struct serial_board {
    word_t dr;        /* data register tx/rx */
    word_t rsr;        /* receive status register / ecr */
    word_t pad1[4];     /* unused */
    word_t fr;         /* flag register */
    word_t pad2;    /* unused */
    word_t ilpr;
    word_t ibrd;    /* integer baud rate */
    word_t fbrd;    /* fractional baud rate */
    word_t lcr_h;    /* line control register */
    word_t cr;        /* control register */
    word_t ifls;    /* interrupt fifo level select map */
    word_t imsc;    /* interrupt mask set/clear */
    word_t ris;        /* raw interrupt status */
    word_t mis;        /* masked interupt status */
    word_t icr;        /*  interrupt clear register */
    word_t dmacr;    /* dma control register */
};




/*****************************************************************************
 *   Global variables - compiled just when CONFIG_KDB_CONS defined
 *****************************************************************************/ 
static volatile struct serial_board * serial_regs = NULL;




/*****************************************************************************
 *   Function declaration - compiled just when CONFIG_KDB_CONS defined
 *****************************************************************************/ 
 
 /****************************************************************************
 *
 *    Serial console  support
 *
 ****************************************************************************/
static void putc_serial( char c )
{
    if ( serial_regs )
    {
        while ( serial_regs->fr & FR_TXFF ); // loop while Tx Fifo Full

        serial_regs->dr = c;
        if ( c == '\n' )
            putc_serial( '\r' );
    }
}

static signed char getc_serial( char block )
{
    if ( serial_regs )
    {
        if ( serial_regs->fr & FR_RXFE ) // if Rx Fifo Empty
        {
            if  (!block)
                return (signed char) (-1);

            while ( serial_regs->fr & FR_RXFE );  // loop while Rx Fifo Empty
        }
        return serial_regs->dr & 0xFF;
    }
    return 0;
}


// #if defined(CONFIG_KDB_BREAKIN)
// void kdebug_check_breakin (void)

// {
//     if (getc_serial(false) == 27)  //check for escape character
//         enter_kdebug("breakin");
// }
// #endif


/*
 * This is required to provide serial_regs and kdb_consoles[0]
 */
static void init(void)
{
//     kdb_consoles[0].putc = putc_serial;
//      
     serial_regs = (struct serial_board*)(UART0_BASE);
    
    /*Disable Uart prior to programming*/
    serial_regs->cr = 0;
    
    /*Set Baud Rate to 38,400 baud*/
    serial_regs->ibrd = 39;
    serial_regs->fbrd = 4;
    
    /*Disable Fifos, 8 data bits, no parity, 2 stop bits, disabled*/
    serial_regs->lcr_h = LCR_H_WLEN(0x3) ;//| LCR_H_STP2;
    
    /*Clear any/all pending interrupts*/
    serial_regs->icr = 0x7ff;
    
    /*Mask all interrupts*/
    serial_regs->imsc = 0x7ff;
    
    /*Disable Transmit/Receive DMA*/
    serial_regs->dmacr = 0;
     
    /*Clear error status, if any*/
    serial_regs->rsr = 0;
    
    /*-No hardware flow control, loopback disabled
    Enable Receive, Transmit and Uart*/
     serial_regs->cr = CR_RXE|CR_TXE|CR_URTEN;
}

/****************************************************************************
 *
 *    Console registration
 *
 ****************************************************************************/

// kdb_console_t kdb_consoles[] = {
//     { SERIAL_NAME, init, putc_serial, getc_serial},
//     KDB_NULL_CONSOLE
// };

// word_t kdb_current_console = 0;



void main (void)
{
     signed char data=0;

    init();

    {
         printf("%x: %x\n", ptr, (int) *ptr);
        ptr++;
    }*/
    putc_serial('I');
    putc_serial('n');
    putc_serial('i');
    putc_serial('t');
    putc_serial('2');
    putc_serial('\n');
//    printf("blah\n");
    putc_serial('I');
    putc_serial('n');
    putc_serial('i');
    putc_serial('t');
    putc_serial('3');
    putc_serial('\n');
    
    while(1)
    {
//         data32 = HW_REG(BRD_BASE, BRD_100HZ);
//         data32 = (data32 >> 3) & 0xFF;
//         HW_REG(BRD_BASE, BRD_LED) =  data32;
        data=getc_serial(0);        
        if (data != -1) putc_serial(data);
    }
}

------------------------------- head.s -------------------------
    .extern main
    
    .global _start
    .align
    
    
    ldr sp, =_stack_top
    bl main
    
    b .
    
_stack_bottom:
    .word 1024
    
_stack_top:
    .word 4
       
---------------------------------
You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.okl4.org/pipermail/developer/attachments/20080402/f824943d/attachment.htm 


More information about the Developer mailing list