Forum Discussion

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

Using np_pio and other stuff in custom program

Hello,

I've read Philipp Lutz's tutorial and his code for the drivers for altera de2 board. I saw that he used np_pio struct and stuff from other .h, like asm/io.h. I'm a newbie trying to understand how to develop on ucLinux. I want to make a program that uses the same stuff he included in his. How would I do that?

In other words, I've read nios wiki tutorial on making my own program (http://www.nioswiki.com/operatingsystems/uclinux/compilehello) and now I want to do more complex. I made a little program that lights up the red leds in my board using the base address as a pointer initializer, which is a clumsy way to do that. I tried to compile Lutz's stuff but got lots of errors, because nios2-linux-uclibc-gcc includes from opt/nios2/include, when I seemingly need to include from uclinux/nios2-linux/linux-2.6/include.

So, how do I make a program that uses na_* addresses described uclinux/nios2-linux/uClinux-dist/linux-2.6.x/include/asm/nios.h to instiantiate np_pio structs?

2 Replies

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

    This kind of I/O access in user space is not portable at all and thus I'd not do this (other than for primary testing purpose).

    Especially as, soon, we will be able to use the MMU that optionally can be activated with SOPC builder when doing a NIOS design. ( -> http://www.nioswiki.com/linux (http://www.nioswiki.com/linux) ) Here a decent Linux-standard conform access to I/O is necessary. There are many ways to do this: writing a dedicated Kernel driver, that does the (maybe even quite complex) low-level I/O for the user land software (you might take a look at the "piobutton" driver for the altera demo board; linux-2.6/drivers/char/altera_pio_button.c) , using a non-dedicated driver concept like providing an "mmap" view to the I/O addresses for the user land software (see: http://www.nioswiki.com/accessing_hardware..._space_programs (http://www.nioswiki.com/accessing_hardware_registers_from_user_space_programs) ) or using "uio" (which I did not explore yet).

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

    <div class='quotetop'>QUOTE (mschnell @ Aug 20 2009, 04:20 AM) <{post_snapback}> (index.php?act=findpost&pid=23529)</div>

    --- Quote Start ---

    This kind of I/O access in user space is not portable at all and thus I&#39;d not do this (other than for primary testing purpose).

    Especially as, soon, we will be able to use the MMU that optionally can be activated with SOPC builder when doing a NIOS design. Here a decent Linux-standard conform access to I/O is necessary. There are many ways to do this: writing a dedicated Kernel driver, that does the (maybe even quite complex) low-level I/O for the user land software (you might take a look at the "piobutton" driver for the altera demo board; linux-2.6/drivers/char/altera_pio_button.c) , using a non-dedicated driver concept like providing an "mmap" view to the I/O addresses for the user land software (see: http://www.nioswiki.com/accessing_hardware..._space_programs (http://www.nioswiki.com/accessing_hardware_registers_from_user_space_programs) ) or using "uio" (which I did not explore yet).

    -Michael[/b]

    --- Quote End ---

    Thanks for the guidance, Michael. Really helped me out.