Forum Discussion

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

Your hardware and uClinux

Hi again,

Adding an Avalon custom hardware and its software driver (either HAL or not) is easy and straightforward. Having said that I mean the standard Nios II IDE project_syslib/system_description/system.h way.

Building a custom system that runs uClinux is also not an issue but haw can I use my Avalon hardware under uClinux?

Thanks for any suggestions,

Piotr.

14 Replies

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

    Hi Ken !

    I want to write a driver in uClinux ( from Microtronix plug-in in NIOS II IDE ), so i need a c example of using iow ( iowrite ) / ior ( ioread )

    Please help me.

    Thank you very much !
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Linux doesn't make use of the IORD and IOWR commands that Altera defines. So you won't find any examples of those.

    What I would recommend would be to take a look at some of the freebie sites with information on how to write device drivers. That's usually a good starting point.

    For instance, I learned how to write my first modular driver using:

    http://lwn.net/articles/driver-porting/ (http://lwn.net/articles/driver-porting/)

    A few mods have to be made to some of the Makefile examples but all in all it worked pretty well.

    A few things to note:

    (1) any type of kernel work (device drivers, making mod's to the kernel, etc). cannot be performed from within Eclipse. It needs to be done from the commandline (Nios II SDK Shell)

    (2) the kernel source code can be found at $KERNEL_PLUGIN/linux-2.6.x

    (3) your kernel build directory can be found at $ECLIPSE_WORKSPACE/<project>/build

    Hope this helps...
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi Ken !

    But, there should be a function to access a hardware on the board ( ie: 4 pins of speaker on the Altera Cyclone 1c12 eval board )

    Please show me if there is

    Thank you very much,

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

    All hardware in any Nios II based system can be accessed via simple memory reads/writes.

    So, for example, if your hardware has registers at 0x00920830, then you can read from the first 4 bytes of your register by using something as simple as:

    int *addr = 0x80920830;

    int reg = *addr;

    Notice that I turned on the high bit for the address of the registers. This bypasses the data cache so that I&#39;m guaranteed to receive current data. Writing is done in the same fashion.

    Since access is so simple, there are no macro&#39;s to read and write from hardware for Linux as far as I know.