Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
20 years ago

How can i handle the pio in uclinux?

I have upload the kernal and filesystem to flash,and the kernal runs very well.Then i build the example 'hello world',it runs very well too.

Now i want to handle the PIO in uclinux,like 'hello led' in nios IDE,i make an application project ,but i can't use the API that ALTERA have provided, like IOWR_ALTERA_AVALON_PIO_DATA(LED_BASE, led).How can i do with it.

On the other hand,can any one tell me where can i download the nios-elf-tools(cross compile tool)in the linux.

Thanks.

5 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    originally posted by wgoossens@Dec 14 2005, 06:41 PM

    you can best use the inl outl or inb outb macro's in linux for accessing the gpio.

    for the crosscompiler you can look for marc&#39;s one but i believe hissite is down at the moment http://forum.niosforum.com/work2/style_emoticons/<#emo_dir#>/sad.gif

    <div align='right'><{post_snapback}> (index.php?act=findpost&pid=11537)

    --- quote end ---

    --- Quote End ---

    Thanks!

    Can you tell me more about inl outl .....
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    try:# man inl

    or# man outl

    ....

    it basicaly reads a long (inl) or a byte (inb) from the port you pass as an argument or writes a long (outl) or a byte (outb).

    for example:

    outb(inb(GPIO1),GPIO2);

    where GPIO1 and GPIO2 are defined as base-addresses of your GPIO components.

    reads a byte from the base address of one GPIO and outputs this no a second GPIO.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    In the header file...../bin/eclipse/plugins/com.microtronix.nios2linux.kernel_1.4.0/linux-2.6.x/include/asm-nios2nommu/io.h

    There are # define writew(b,addr)

    ({

    __asm__ __volatile__(

    "sthio %0, 0(%1)"

    : : "r"(http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/cool.gif , "r" (addr));

    })

    and other application like this.But in my Application Project,when i use writew or other application that has defined in the io.h,there are error undefined reference to `writew&#39;,I have include the header file like this# <asm/io.h>.Can anyone tell me why.

    Thanks. http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/sad.gif
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    > there are error undefined reference to `writew&#39;,I have include the header file like

    > this# <asm/io.h>.Can anyone tell me why.

    __KERNEL__ must be defined. If you define this for an application, you&#39;ll likely pull in

    other definitions that will cause compile-time problems. I recommend you copy the

    macros you need into a header file in your application source tree. It&#39;ll probably save

    you some headaches.

    Regards,

    --Scott