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++
12589 Discussions

Tutorial Video: How to boot uClinux on NIOS II Processor with MMU

Altera_Forum
Honored Contributor II
5,014 Views

Hi everyone 

I record a tutorial video about how to boot uclinux on Nios II Processor with MMC 

I used DE2-115 as reference but you can use any board that you like 

Feel free to contact me if you have any problem at: hafezi.mahdi@live.com or use this forum 

 

Link to tutorial video: 

http://www.youtube.com/watch?v=rxlyezof0rs
0 Kudos
31 Replies
Altera_Forum
Honored Contributor II
871 Views

I also upload the .sof and zImage and entire Quartus project files to skydrive and share it to public 

Please check the below link 

 

http://sdrv.ms/11cmauy
0 Kudos
Altera_Forum
Honored Contributor II
871 Views

Thanks!!!! you are awesome!

0 Kudos
Altera_Forum
Honored Contributor II
871 Views

 

--- Quote Start ---  

Hi everyone 

I record a tutorial video about how to boot uclinux on Nios II Processor with MMC 

I used DE2-115 as reference but you can use any board that you like 

Feel free to contact me if you have any problem at: hafezi.mahdi@live.com or use this forum 

 

Link to tutorial video: 

http://www.youtube.com/watch?v=rxlyezof0rs 

--- Quote End ---  

 

 

Hi, 

 

I am using Altera FPGA and new to linux. 

 

i want to know that how i can establish a development environment where i can write 

programming and download the application to linux. 

 

regards 

J S Hyanki
0 Kudos
Altera_Forum
Honored Contributor II
871 Views

 

--- Quote Start ---  

Hi, 

 

I am using Altera FPGA and new to linux. 

 

i want to know that how i can establish a development environment where i can write 

programming and download the application to linux. 

 

regards 

J S Hyanki 

--- Quote End ---  

 

 

Hi 

In the same system that you actually build the Linux for you board you can add the custom programs to the Linux as a package 

Please visit the below link, this tutorial will guide you to create a C program and then compile and add the C program to the Linux that you want to build 

http://www.alterawiki.com/wiki/portingapps 

after the build is completed you can download the Linux on your development board and then execute the C Program that you wrote 

You don't need to know all the Linux stuff at the first place, try to learn the basic commands, that will help you a lot  

 

Best Regards 

Mahdi Hafezi
0 Kudos
Altera_Forum
Honored Contributor II
871 Views

Hi, 

 

In host PC which Linux should i install? 

 

Thanks for your response. 

regards 

J S Hyanki
0 Kudos
Altera_Forum
Honored Contributor II
871 Views

Hi 

Please visit the below link 

http://www.alterawiki.com/wiki/uclinux 

In the "Quartus for Linux" section it's suggested that you install CentOS but i personally install Fedora 14 64-bit
0 Kudos
Altera_Forum
Honored Contributor II
871 Views

Hi Mahdi, 

 

Thank you very much for your video - it is very helpful. 

 

Could you please explain a little bit about how you created your project in Quartus? In the video you had already created it. Did you base on it on some existing design? 

 

Thanks. 

[h=1][/h]
0 Kudos
Altera_Forum
Honored Contributor II
871 Views

 

--- Quote Start ---  

Hi Mahdi, 

 

Thank you very much for your video - it is very helpful. 

 

Could you please explain a little bit about how you created your project in Quartus? In the video you had already created it. Did you base on it on some existing design? 

 

Thanks. 

[h=1][/h] 

--- Quote End ---  

 

 

Glad that the video was helpful 

You can watch the below video for creating simple NIOS II application 

http://www.youtube.com/watch?v=ks7pap5ewrq 

And apply the MMU setting for booting uClinux in MMU enable mode 

All the materials is available in the youtube video description section
0 Kudos
Altera_Forum
Honored Contributor II
871 Views

lordephaistos-1 (http://www.alteraforum.com/forum/member.php?u=55291) thank you for very good instruction. 

I have loaded your sof file and zImage to the board. But there is not support of usb, vga, sd card. 

 

Are there ways to make these functions work?
0 Kudos
Altera_Forum
Honored Contributor II
871 Views

Hi, 

 

 

--- Quote Start ---  

 

I have loaded your sof and zImage files to my board. It works good. But there is not support of vga, usb and sd card. 

I need these functions. Are there ways to make these functions work? 

--- Quote End ---  

 

 

If your board is DE2-115, please visit the page 

 

http://www.alterawiki.com/wiki/linux_with_mmu_on_veek/t-pad (http://www.alterawiki.com/wiki/linux_with_mmu_on_veek/t-pad

 

and refer the section No.8. And if you feel that the Nios2 CPU is slow to execute X window, please visit the page 

 

http://www.alterawiki.com/wiki/nios2_smp_system (http://www.alterawiki.com/wiki/nios2_smp_system

 

:rolleyes:.
0 Kudos
Altera_Forum
Honored Contributor II
871 Views

 

--- Quote Start ---  

Hi, 

 

 

If your board is DE2-115, please visit the page 

 

http://www.alterawiki.com/wiki/linux_with_mmu_on_veek/t-pad 

 

and refer the section No.8. 

--- Quote End ---  

 

 

thank you. 

 

But I have an issue with this instruction. 

 

What i did: 

1) connected my de2-115 board to my PC via "usb blaster" port. 

2) downloaded this http://www.alterawiki.com/wiki/file:d115_selector.tar.gz 

3) in NIOS commend shell 

name@idea-PC /cygdrive/c/altera/13.1 $ quartus_pgm.exe -m jtag -c USB-Blaster -o "p;tPad_Selector.sof" Info: ******************************************************************* Info: Running Quartus II 32-bit Programmer Info: Version 13.1.0 Build 162 10/23/2013 SJ Web Edition Info: Copyright (coffee) 1991-2013 Altera Corporation. All rights reserved. Info: Your use of Altera Corporation's design tools, logic functions Info: and other software and tools, and its AMPP partner logic Info: functions, and any output files from any of the foregoing Info: (including device programming or simulation files), and any Info: associated documentation or information are expressly subject Info: to the terms and conditions of the Altera Program License Info: Subscription Agreement, Altera MegaCore Function License Info: Agreement, or other applicable license agreement, including, Info: without limitation, that your use is for the sole purpose of Info: programming logic devices manufactured by Altera and sold by Info: Altera or its authorized distributors. Please refer to the Info: applicable agreement for further details. Info: Processing started: Fri Mar 14 14:41:44 2014 Info: Command: quartus_pgm -m jtag -c USB-Blaster -o p;tPad_Selector.sof Info (213045): Using programming cable "USB-Blaster " Info (213011): Using programming file tPad_Selector.sof with checksum 0x00BBDF04 for device EP4CE115F29@1 Info (209060): Started Programmer operation at Fri Mar 14 14:41:49 2014 Info (209016): Configuring device index 1 Info (209017): Device 1 contains JTAG ID code 0x020F70DD Info (209007): Configuration succeeded -- 1 device(s) configured Info (209011): Successfully performed operation(s) Info (209061): Ended Programmer operation at Fri Mar 14 14:41:55 2014 Info: Quartus II 32-bit Programmer was successful. 0 errors, 0 warnings Info: Peak virtual memory: 191 megabytes Info: Processing ended: Fri Mar 14 14:41:55 2014 Info: Elapsed time: 00:00:11 Info: Total CPU time (on all processors): 00:00:04  

 

After that I had white screen on my vga monitor. 

 

4)  

name@idea-PC /cygdrive/c/altera/13.1 $ nios2-flash-programmer.exe --epcs --base=0x0a001800 tPad_Selector.flash Using cable "USB-Blaster ", device 1, instance 0x00 Resetting and pausing target processor: OK No EPCS layout data - looking for section Unable to use EPCS device Leaving target processor paused  

 

There is an error: 

No EPCS layout data - looking for section Unable to use EPCS device
0 Kudos
Altera_Forum
Honored Contributor II
871 Views

Hi all, 

 

When you download the 'Application Selector", if you get an error by "nios2-flash-programmer" like 

 

No EPCS layout data - looking for section [EPCS-010216] 

 

, please refer the page 

 

http://www.alteraforum.com/forum/showthread.php?t=20576 (http://www.alteraforum.com/forum/showthread.php?t=20576

 

or 

 

http://www.altera.com/literature/ug/ug_nios2_flash_programmer.pdf (http://www.altera.com/literature/ug/ug_nios2_flash_programmer.pdf

 

the section "A. Non-Standard Flash Memories" at pp.23 

 

Kazu
0 Kudos
Altera_Forum
Honored Contributor II
871 Views

Kazuyasu, thank you. I solve my problem by adding the following information to "nios2-flash-override.txt"  

(for me it is located in "C:\altera\13.1\nios2eds\bin" ) 

# EPCS64N (lead-free) sector_size = 65536 sector_count = 128  

 

 

But I have another question: 

How can i compile programms for this linux? 

I tried these instructions: 

http://www.alterawiki.com/wiki/binarytoolchain 

http://www.alterawiki.com/wiki/compile_hello 

 

I compile programm in this way: 

nios2-linux-uclibc-gcc hello.c -o hello -elf2flt 

 

Then i have a binary file. But when i try to run it on DE2-115 it gives me error like this: 

syntax error: unexpected "("
0 Kudos
Altera_Forum
Honored Contributor II
871 Views

Hi, 

 

 

--- Quote Start ---  

 

But I have another question: 

How can i compile programms for this linux? 

I tried these instructions: 

http://www.alterawiki.com/wiki/binarytoolchain 

http://www.alterawiki.com/wiki/compile_hello 

 

I compile programm in this way: 

nios2-linux-uclibc-gcc hello.c -o hello -elf2flt 

 

Then i have a binary file. But when i try to run it on DE2-115 it gives me error like this: 

syntax error: unexpected "("  

--- Quote End ---  

 

 

The welcome message is 'uClinux' , but the kernel is a "genuine" linux kernel which is using MMU. So you need the toolchain which supports those. 

Please refer 

 

http://www.rocketboards.org/foswiki/documentation/niosiilinuxusermanual 

 

or somewhere. 

I'm using the next version. 

 

kazu-Latitude-E5500:~$ nios2-wrs-linux-gnu-gcc --version nios2-wrs-linux-gnu-gcc (Wind River Linux Sourcery G++ 4.1-176) 4.1.2 Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 

 

Kazu
0 Kudos
Altera_Forum
Honored Contributor II
871 Views

 

--- Quote Start ---  

 

The welcome message is 'uClinux' , but the kernel is a "genuine" linux kernel which is using MMU. So you need the toolchain which supports those. 

Please refer 

 

http://www.rocketboards.org/foswiki/documentation/niosiilinuxusermanual 

 

--- Quote End ---  

 

 

Thank you. It works. 

I downloaded compiller from https://sourcery.mentor.com/gnutoolchain/subscription42545 

and I use this command to compile my programms: 

nios2-linux-gnu-gcc main.c  

 

 

I have one more question: 

DE2-115 has leds, buttons etc. 

Can i control them from linux?
0 Kudos
Altera_Forum
Honored Contributor II
871 Views

Hi, 

 

 

--- Quote Start ---  

 

DE2-115 has leds, buttons etc. 

Can i control them from linux? 

--- Quote End ---  

 

 

I've connected almost all DE2-115's peripheral devices including KEY[3..0] (KEY[0] is abused for the system reset), SW[17..0], LEDR[17..0], LEDG[8..0] and LCD, etc. except Ethernet 1, SRAM, Video decoder and IDE 40pins GPIO. But drivers are not included, so you can't use them from the linux side now. 

If you have strong request, I will implement those drivers, but I can't imagine the those usage except for X'mas illuminations:confused:. 

What is your purpose for? 

 

Kazu
0 Kudos
Altera_Forum
Honored Contributor II
871 Views

 

--- Quote Start ---  

Hi, 

 

I've connected almost all DE2-115's peripheral devices including KEY[3..0] (KEY[0] is abused for the system reset), SW[17..0], LEDR[17..0], LEDG[8..0] and LCD, etc. except Ethernet 1, SRAM, Video decoder and IDE 40pins GPIO. But drivers are not included, so you can't use them from the linux side now. 

If you have strong request, I will implement those drivers, but I can't imagine the those usage except for X'mas illuminations:confused:. 

What is your purpose for? 

 

Kazu 

--- Quote End ---  

 

 

Thanks. 

It is for study purposes. 

 

I opened "DE2_115_NIOS_HOST_MOUSE_VGA.qar" in Qsys and found base addresses: 

pio_green_led: BASE = 0x0000_00a0, END = 0x0000_00af pio_red_led: BASE = 0x0000_00b0, END = 0x0000_00bf pio_button: BASE = 0x0000_00d0, END = 0x0000_00df lcd: BASE = 0x0000_00e0, END = 0x0000_00ef  

Is it correct addresses? 

Qsys shows that this harware linked via "Avalon Memory Mapped Slave". 

Can you give me examples of working with It (for example how to switch on/off leds, use button, e.t.c.)?
0 Kudos
Altera_Forum
Honored Contributor II
871 Views

There is also an issue with eth0 interface. It works only in half duplex mode even when i write "ethtool -s eth0 autoneg off speed 100 duplex full ".

0 Kudos
Altera_Forum
Honored Contributor II
871 Views

Hi, 

 

 

--- Quote Start ---  

 

pio_green_led: BASE = 0x0000_00a0, END = 0x0000_00af pio_red_led: BASE = 0x0000_00b0, END = 0x0000_00bf pio_button: BASE = 0x0000_00d0, END = 0x0000_00df lcd: BASE = 0x0000_00e0, END = 0x0000_00ef  

Is it correct addresses? 

 

--- Quote End ---  

 

 

These peripherals are connected to the Nios2 CPU via a "clock bridge". So the correct physical addresses are 

 

pio_green_led: BASE = 0x0800_00a0, END = 0x0800_00af pio_red_led: BASE = 0x0800_00b0, END = 0x0800_00bf pio_button: BASE = 0x0800_00d0, END = 0x0800_00df lcd: BASE = 0x0800_00e0, END = 0x0800_00ef

 

 

--- Quote Start ---  

 

Can you give me examples of working with It (for example how to switch on/off leds, use button, e.t.c.)? 

 

--- Quote End ---  

 

 

These peripherals are connected via Altera's PIO IP cores, so you can control those only by reading and writing their registers. But to do so in your Linux system, you need appropriate drivers. 

 

 

--- Quote Start ---  

There is also an issue with eth0 interface. It works only in half duplex mode even when i write "ethtool -s eth0 autoneg off speed 100 duplex full ". 

--- Quote End ---  

 

 

Maybe it's your PC side problem. Please check that your PC's phy is set in autonegotiation mode. 

 

Kazu
0 Kudos
Altera_Forum
Honored Contributor II
740 Views

Thanks. 

 

 

--- Quote Start ---  

 

These peripherals are connected to the Nios2 CPU via a "clock bridge". So the correct physical addresses are 

pio_green_led: BASE = 0x0800_00a0, END = 0x0800_00af pio_red_led: BASE = 0x0800_00b0, END = 0x0800_00bf pio_button: BASE = 0x0800_00d0, END = 0x0800_00df lcd: BASE = 0x0800_00e0, END = 0x0800_00ef

These peripherals are connected via Altera's PIO IP cores, so you can control those only by reading and writing their registers. But to do so in your Linux system, you need appropriate drivers. 

 

--- Quote End ---  

 

 

Can i use "mmap" for getting access to this hardware from userspace? 

Are there any examples to use Altera's PIO IP cores? 

 

 

--- Quote Start ---  

 

Maybe it's your PC side problem. Please check that your PC's phy is set in autonegotiation mode. 

 

--- Quote End ---  

 

 

I connected it to the router and it showed that it works in half duplex mode. 

Ok. I will try to connect it directly to PC.
0 Kudos
Reply