linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* Cross compiling : problem linking
@ 2003-10-02 12:56 Toni Van Remortel
  2003-10-02 13:26 ` Toni Van Remortel
  2003-10-02 13:35 ` Wolfgang Denk
  0 siblings, 2 replies; 9+ messages in thread
From: Toni Van Remortel @ 2003-10-02 12:56 UTC (permalink / raw)
  To: linuxppc-embedded


Hi all,

I try to cross compile a small test program for the EP505 board. I use
ELDK as compiler set.

When using this compile command:

ppc_4xx-gcc -O -v -nostdlib -nostartfiles -mno-eabi -fno-exceptions \
-fno-builtin -Wl,-Tscript.ld,-N -o rt_mod rt_mod.c

I get after a while:

/opt/eldk/usr/ppc-linux/bin/ld: cannot open linker script file \
script.ld: Onbekend bestand of map
collect2: ld returned 1 exit status

I don't know what is wrong, but 'script.ld' isn't anywhere on my system.

Side note: I used the compiler set already to cross compile a kernel,
XFree and FLTK, so it works.

Any idea?

PS: the program currently should make a square wave on EBC P1 D1
--
                           Toni Van Remortel
              Wetenschappelijk Medewerker - D-science lab
  Real time Linux for embedded systems: http://linemb.d-sciencelab.com
              Tel: +32 3 205 61 72 - Fax: +32 3 205 61 95
                      E-mail: t.vanremortel@ha.be


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 9+ messages in thread
[parent not found: <1065104646.13376.8.camel@toni>]
* RE: Cross compiling : problem linking
@ 2003-10-02 16:34 Fillod Stephane
  2003-10-02 21:26 ` Wolfgang Denk
  2003-10-03  8:26 ` Toni Van Remortel
  0 siblings, 2 replies; 9+ messages in thread
From: Fillod Stephane @ 2003-10-02 16:34 UTC (permalink / raw)
  To: 'linuxppc-embedded@lists.linuxppc.org'


Note to the list: sorry for the RFC2822

> Do you know the replacement for iopl to work on PowerPC?

There's no such crap on PowerPC. No separate IO bus either.


> Final goal is a kernel module, but now I'm writing a test program in
> user space (standalone, dynamic compiled).

Okay, let's use ESP for once :)

Toni, I don't know what's your "base" address, but it is really odd
(well, both ways :) on a PowerPC system. You should borrow some help
from your D-science lab, or have something like a PPC Linux training.


Wolfgang, you've got my agreement to put the following in the FAQ
if it's not already.


This code is for accessing hardware registers from *userland*.
You need CAP_SYS_RAWIO and /dev/mem permissions.

Basically:
	volatile void *p = ioremap(MY_HARD_REG_ADDR, 4096);
	...
	out_8(p, state ^= 0x1);




#include <stdio.h>
#include <stdlib.h>

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>

#ifdef __PPC__
extern inline void out_8(volatile unsigned char *addr, int val)
{
        __asm__ __volatile__("stb%U0%X0 %1,%0; eieio" : "=m" (*addr) : "r"
(val));
}
#else
extern inline void out_8(volatile unsigned char *addr, int val)
{
        *add = val & 0xff;
}
#endif

extern inline volatile void * ioremap(unsigned long physaddr, unsigned size)
{
    static int axs_mem_fd = -1;
    unsigned long page_addr, ofs_addr, reg, pgmask;
    void* reg_mem = NULL;

    /*
     * looks like mmap wants aligned addresses?
     */
    pgmask = getpagesize()-1;
    page_addr = physaddr & ~pgmask;
    ofs_addr  = physaddr & pgmask;

    /*
     * Don't forget O_SYNC, esp. if address is in RAM region.
     * Note: if you do know you'll access in Read Only mode,
     *    pass O_RDONLY to open, and PROT_READ only to mmap
     */
    if (axs_mem_fd == -1) {
        axs_mem_fd = open("/dev/mem", O_RDWR|O_SYNC);
        if (axs_mem_fd < 0) {
                perror("AXS: can't open /dev/mem");
                return NULL;
        }
    }

    /* memory map */
    reg_mem = mmap(
        (caddr_t)reg_mem,
        size+ofs_addr,
        PROT_READ|PROT_WRITE,
        MAP_SHARED,
        axs_mem_fd,
        page_addr
    );
    if (reg_mem == MAP_FAILED) {
        perror("AXS: mmap error");
        close(axs_mem_fd);
        return NULL;
    }

    reg = (unsigned long )reg_mem + ofs_addr;
    return (volatile void *)reg;
}

extern inline int iounmap(volatile void *start, size_t length)
{
    unsigned long ofs_addr;
    ofs_addr = (unsigned long)start & (getpagesize()-1);

    /* do some cleanup when you're done with it */
    return munmap((void*)start-ofs_addr, length+ofs_addr);
}


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 9+ messages in thread
* RE: Cross compiling : problem linking
@ 2003-10-06 13:09 Fillod Stephane
  0 siblings, 0 replies; 9+ messages in thread
From: Fillod Stephane @ 2003-10-06 13:09 UTC (permalink / raw)
  To: 'linuxppc-embedded@lists.linuxppc.org'


Dear Wolfgang,

> Then you can edit / add to the U-Boot and Linux Guide at
> http://www.denx.de/twiki/bin/view/DULG/WebHome yourself...

It seems like I have no permission to mess with DULG,
so I've added it to PPCEmbedded HOWTO:
 http://www.denx.de/twiki/bin/view/PPCEmbedded/DeviceDrivers

Feel free to move it around as needed.

Regards,
Stephane

PS: still sorry for the RFC2822 and References, should be fixed after xmas.

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2003-10-06 13:09 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-10-02 12:56 Cross compiling : problem linking Toni Van Remortel
2003-10-02 13:26 ` Toni Van Remortel
2003-10-02 13:37   ` Wolfgang Denk
2003-10-02 13:35 ` Wolfgang Denk
     [not found] <1065104646.13376.8.camel@toni>
2003-10-02 15:01 ` Wolfgang Denk
  -- strict thread matches above, loose matches on Subject: below --
2003-10-02 16:34 Fillod Stephane
2003-10-02 21:26 ` Wolfgang Denk
2003-10-03  8:26 ` Toni Van Remortel
2003-10-06 13:09 Fillod Stephane

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).