Forum Discussion
Altera_Forum
Honored Contributor
9 years agoHi Kazu,
There are two kinds of Linux kernel. One is using MMU and I sometimes call it 'genuine Linux'. Another can be executed in a small CPU which has no MMU and it's called 'uClinux'. uClinux has excellent features e.g. it does not require much memories, but also it has some disadvantages e.g. we can't use 'bash' on it. If you are using Nios's MMU, it's OK. no problem.
So you are using the Linux with MMU, you should use the tools in the folder 'nios2-linux-toolchain-mmu-***'. Then I think I'm using uclinux with MMU. Thanks for the explanation. --- Quote Start --- Maybe, you are misunderstanding the feature of operating systems. The functions 'alt_up_char_buffer_***' are Altera's library functions and you can't use those in your Linux system. Moreover, you can't access the registers directly from the user-land. So If you execute the code
//Switches
a = IORD(SWITCHES_BASE,0);
the kernel will evoke a fault and stop your application. Kazu --- Quote End --- Then I must be misunderstood it. I'm actually totally new to Linux system and started to learn it recently. I thought that Altera's library fuctions can apply directly in linux system too. Besides, I found this in a reference but I'm still not very sure how to use it to access IO ports.
To access IO ports, we can define them as memory pointer access (uncached). Nios2-Linux does
not lock access to the memory like normal Linux distros, so it is not a problem :
(*(volatile unsigned *)(port)) //for read, replace port with the hardware address
(*(volatile unsigned *)(port))=(d) //for write, replace port with the hardware address
To maintain the IORD and IOWR standard, which is used in Nios II systems, these macros can be
defined at the beginning of the source code to ease portability :
# define IORD(address,offset) (*(volatile unsigned *)(((address)|0x80000000)+4*(offset)))
# define IOWR(address,offset,value) (*(volatile unsigned *)(((address)|0x80000000)+4*(offset)))=(value) May I know is there any reference that can help me to understand more in programming DE2-115 in linux system? like some sample coding to display some words in LCD,or control the LEDs and so on. Because I find it hard to find a good reference for that. Really thanks a lot for your help. Best Regards, Jun Mun