Forum Discussion

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

How can I use macro outl in nios2 uclinux?

hi :

I want to use macro( outl(data,address)) access pio directly.

so I include <asm/io.h>.but make fail. The erro information is:undefine ref outl.

But the macro outl is included in <asm/io.h>.

I am so puzzle.

How can I solve it? Thanks a lot.

7 Replies

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

    --- Quote Start ---

    originally posted by alex824@Apr 27 2006, 01:17 PM

    hi :

    i want to use macro( outl(data,address)) access pio directly.

    so i include <asm/io.h>.but make fail. the erro information is:undefine ref outl.

    but the macro outl is included in <asm/io.h>.

    i am so puzzle.

    how can i solve it? thanks a lot.

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

    --- quote end ---

    --- Quote End ---

    add,# define __KERNEL__
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thanks hippo

    I lost the "-" in D__KERNEL__ firster. so I make fail. http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/biggrin.gif

    every one:

    If you do not want to write driver for some simple device. You can use macro

    outl , inl to control the device directly.

    frist add "-D__KERNEL__ " to CFLAGS += in your makefile

    second copy "nios2_system.h" from ~/linux2.6.x/include to your include dir

    follow is my simple code:

    # ifndef __LED_H__# define __LED_H__

    # include <asm/io.h>

    # include "board.h"

    // define constants for LED status# define LED_ALL_OFF 0x00# define LED_ALL_ON 0xFF

    # define MAJ_LED_OFF (inl(LED_CTRL) & 0xFE)# define MAJ_LED_ON (inl(LED_CTRL) | 0x01)

    # define MIN_LED_OFF (inl(LED_CTRL) & 0xFD)# define MIN_LED_ON (inl(LED_CTRL) | 0x02)

    # define ACO_LED_OFF (inl(LED_CTRL) & 0xFB)# define ACO_LED_ON (inl(LED_CTRL) | 0x04)

    void init_led(void);

    # endif

    # ifndef __BOARD_H__# define __BOARD_H__

    // Main clck frequency.# define MCLK 50000000

    // SDRAM area definition.# define SDRAM_BASE 0x01000000# define SDRAM_SIZE 0x01000000 // 16MBytes

    //FALSH area definition# define FLASH_BASE 0x00000000# define FLASH_SIZE 0x00800000 // 8MBytes

    // led Configuration Registers# define LED_CTRL 0x00810850

    # endif

    # include "led.h"# include "board.h"

    void init_led(void)

    {

    outl(LED_ALL_ON, LED_CTRL);

    }

    int main(void)

    {

    //init_msgQ();

    init_led();

    while(1)

    {

    outl(LED_ALL_OFF, LED_CTRL);

    outl(MAJ_LED_ON, LED_CTRL);

    sleep(1);

    outl(MAJ_LED_OFF, LED_CTRL);

    sleep(1);

    outl(MIN_LED_ON, LED_CTRL);

    sleep(1);

    outl(MIN_LED_OFF, LED_CTRL);

    sleep(1);

    outl(ACO_LED_ON, LED_CTRL);

    sleep(1);

    outl(ACO_LED_OFF, LED_CTRL);

    sleep(1);

    }

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

    Hi,

    I use NiosII IDE.

    I add "-D__KERNEL__ " to CFLAGS += in my makefile. cope the nios2_system.h to the project.When build the target, the errors like follows:

    in inclusion d:/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.uClibc_1.4.0/include/linux/config.h:4[d:/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.uClibc_1.4.0/include/linux/linkage.h] mult line 4 May 7, 2006 8:27:23 PM

    linux/autoconf.h: No such file or directory[d:/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.uClibc_1.4.0/include/linux/config.h] mult line 4 May 7, 2006 8:27:23 PM

    nios2_system.h: No such file or directory[d:/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.uClibc_1.4.0/include/asm/nios.h] mult line 4 May 7, 2006 8:27:23 PM

    in inclusion d:/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.uClibc_1.4.0/include/linux/linkage.h:4:[d:/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.uClibc_1.4.0/include/linux/kernel.h] mult line 11 May 7, 2006 8:27:23 PM

    If comment the# includd <asm/io.h>, all the errors like above disappeared .

    What is wrong ? Please give me help?Thank you very much!!
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Copy & Paste does the job, too. You can even use the Altera HAL.

    well, it is just an idea...
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    alex824,

    Can you post a simple project on the wiki, or in the forum for us newbies to follow ?

    A complete course code with suitable makefile (standalone) would be good.

    Thanks.