Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12603 Discussions

How can I use macro outl in nios2 uclinux?

Altera_Forum
Honored Contributor II
1,497 Views

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.
0 Kudos
7 Replies
Altera_Forum
Honored Contributor II
397 Views

 

--- 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__
0 Kudos
Altera_Forum
Honored Contributor II
397 Views

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); 

 

 

}
0 Kudos
Altera_Forum
Honored Contributor II
397 Views

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!!
0 Kudos
Altera_Forum
Honored Contributor II
397 Views

hi, zzh 

 

did u copy the include files to your project ? 

 

or specify the whole path http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/biggrin.gif
0 Kudos
Altera_Forum
Honored Contributor II
397 Views

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

well, it is just an idea...
0 Kudos
Altera_Forum
Honored Contributor II
397 Views

copy & paste the macros from asm/io.h of course.

0 Kudos
Altera_Forum
Honored Contributor II
397 Views

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.
0 Kudos
Reply