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

How to build applications

Altera_Forum
Honored Contributor II
1,720 Views

How do you generate a makefile with the "Create Make Target" and "build make target" 

functions? 

 

Every time I try it I get: 

 

make -k dhrystone  

make: *** No rule to make target `dhrystone' 

 

The reference guide is worthless in this area.
0 Kudos
14 Replies
Altera_Forum
Honored Contributor II
460 Views

I must confess you have me confused, I haven't looked too hard but am quite familiar with the Nios II IDE and I could not find the "Create make target" and "build make target" options you refer to. I think by far the easiest route for you is to follow the software tutorial which can be found as follows Help->Welcome select Nios II IDE and then select the Software Development Tutorial. It should not take you long and you should then be able to build download and debug your application

0 Kudos
Altera_Forum
Honored Contributor II
460 Views

I solved that problem by asking one of our software engineers whop has worked with linux before.  

The solution that the reference manual failed to cover is: 

 

You must create a file called "makefile". Then place the following into it: 

 

include Rules.mak 

 

dhrystone: dhrystone.exe 

 

 

dhry21a.o: dhry21a.c  

dhry21b.o: dhry21b.c  

timers_b.o: timers_b.c 

 

 

 

 

dhrystone.bin: dhry21a.o dhry21b.o timers_b.o 

$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS) 

dhrystone.elf : dhrystone.bin 

$(LD) -T $(LINKSCRIPT) -Ur -o $@ $< 

 

 

As i said, whomever wrote the reference guide is incompetent. I would have never figured this out on my own. who ever wrote  

it needs to rewrite it from the perspective of the user has never seen linux before and every step needs to be spelled out in intricate detail. As it sits now, it looks like Xilinx microblaze is going to win the project. Their stuff worked the first time out of the box, Altera hasn&#39;t. This isn&#39;t suprising, in my 12 years of hardware design Altera has always been difficult to work with. Xilinx usually works the first time.  

 

BTW, the &#39;create make target&#39; and &#39;build make target&#39; can be found by right clicking on the application project name and looking down to the bottom of the drop down menu that appears. 

 

My latest problem is the reference guide instructions for using the compact flash don&#39;t work. 

 

Specifically the linux configurator DOES NOT have anything called "e2fs support" anywhere. 

 

Additionally when I add IDE support I get an error stating &#39;na_ ide_..." is undefined. (or words to that effect). Since the manual states this is needed to use the flash card, obviously the writer of the manual dropped the ball again. See page 31 of the Ref guide. 

 

I&#39;m using the "full featured" version of the processor on Altera&#39;s Stratix demo board. 

 

Thanks and sorry for the ranting, 

 

John K.
0 Kudos
Altera_Forum
Honored Contributor II
460 Views

John, 

 

Can you elaborate on a few points to assist in improving the docs? 

 

Specifically -- 

1. Which document(s) are you referring to? 

2. Which exact set of tools are you using? I see you mention Linux several times -- does this mean uClinux from our partner Microtronix? (Sorry if I am getting things confused -- soon our tools will all support running on Linux, as in developing on one&#39;s PC running Linux, and that adds the need to be more specific for us). 

3. By IDE support do you mean the "Nios II IDE" (where you compile/debug) or IDE interface, as in compact flash/hard drive support? I am guessing from your last question you&#39;re trying to get an IDE interface working with uClinux, but I just want to be sure.  

 

Please realize that there is a line to be drawn where our Altera-specific tools (which I agree must be well-documented if we are to succeed) overlap onto other tools used by the industry. For example &#39;make&#39; - there are entire books (and websites) written on &#39;make&#39; and providing examples. If you&#39;d like I&#39;d be happy to locate some websites and/or literature references and post them here. 

 

If there are specific areas of our docs that you find lacking please post the title and page# s and we&#39;ll take an honest look. 

 

As far as Microblaze -- if you have better luck with it then I suggest you use the product that makes most sense in terms of economics, robustness, and ease of use. Its been our experience that we outperform our competitors (in the admittedly fledgling FPGA-based-processor league) in terms of quality substantially, but if your experience differs we sincerely appreciate feedback telling us where we can improve ourselves. 

 

Please note that I work for Altera so if your problems are on the uClinux side I can&#39;t help too much, but I can alert the relevant people of your problems; they frequent this forum too and assist on the linux-related forums.. on the other hand if your issues are with Altera docs I can have those issues looked at here.
0 Kudos
Altera_Forum
Honored Contributor II
460 Views

John, 

 

Please note that I don&#39;t work for Altera or Microtronix, so I&#39;ll be direct: 

 

> The solution that the reference manual failed to cover is: 

> You must create a file called "makefile". Then place the following into it: 

> include Rules.mak 

 

From page 16, Nios II Linux Reference Guide: 

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

creating a makefile 

Every Nios II Linux Application project should have a top-level Makefile. Each Makefile should include the Rules.mak file in order to take advantage of the automatic rules that are provided for building the Nios II Linux executable files. While it is not necessary to use the Rules.mak file, it is definitely recommended.[/b] 

--- Quote End ---  

 

> Specifically the linux configurator DOES NOT have anything called "e2fs support" anywhere. 

 

From page 31, Nios II Linux Reference Guide: 

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

creating an extended 2 filesystem on a compactflash card 

This section will guide you through the process of creating an Extended 2 Filesystem (ext2fs) on a CompactFlash card that can be mounted in read-write mode.[/b] 

--- Quote End ---  

 

Correct. The specific bullet you are apparently referring to is a typo ... it should be "ext2fs". And support for ext2fs is ... the first option under the "File systems" menu: "Second extended fs support". 

 

> Additionally when I add IDE support I get an error stating &#39;na_ ide_..." is undefined. (or words 

> to that effect). 

 

From page 10, Nios II Linux Reference Guide: 

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

The current default kernel configuration is meant for use with the example linux target hardware cores found in …altera/kits/nios2/examples/verilog/<board>/linux. failure to do so will cause errors during the compile process when symbols cannot be found. A typical example would be enabling IDE support when there is no Compact Flash support in the target hardware.[/b] 

--- Quote End ---  

 

> the writer of the manual dropped the ball again 

 

Indeed. 

 

> Thanks and sorry for the ranting 

 

Perhaps just a bad hair day ;-) 

 

Regards, 

--Scott
0 Kudos
Altera_Forum
Honored Contributor II
460 Views

I&#39;m using Nios 2 v1.0 with the Microtronix uClinux kernel on the Altera Stratix board. 

 

Actually this all started when I agreed to evaluate the Nios 2 processor and compare my results to a Xilinx Chip running uClinux also. The idea was to run a dhrystone test with the same OS on each. The results should be obvious which one was faster. Also device utilization and Megacore vs Coregen IP costs are relevant as well as price.  

 

The first problem occured when the software form Altera wouldn&#39;t allow uClinux to install. Research on the forum revealed I needed to obtain Nios 2 V1.0, install, then install uCLinux and then install the svc pack to upgrade to Nois 2 v1.01. Since I didn&#39;t have a copy of v1.0 I was stuck for several days. This was due to a support engineer at Altera telling me the eval version on the forum wouldn&#39;t work. Well after several days of waiting for Nios 1.0 to arrive from Altera and reading the posts on the forum, I realized the engineer didn&#39;t know what he was talking about. The version here will work. 

 

So I did the installation at my house first. I then attempted to compile and load the kernel & file system. I immediately started receiving the error "inttypes.h : no such file or directory". This was being called by line 3 in gen_crc32table.c  

 

When running the configure kernel program the option CRC32 functions was disabled. So I was unable to select Y or N. The only option was &#39;---&#39;. This was accomplished by following the directions as stated in the quick start guide. I tried for several evenings to fix this problem. Finally I deleted Nios from my machine and made sure all directories related to it were deleted. I then reinstalled and that problem seemed to go away. This was after other attempts to solve the problem. 

 

Next when I followed the quick start guide again and created the file system ( which went smoothly) I discovered the upload process didn&#39;t work. I still haven&#39;t figured that one out. I&#39;ve since taken the board back to work and it compiles and downloads properly. i don&#39;t understand why, I&#39;m using Win 2000 on both machines, and have the same environment variables.  

 

Now for the latest issue. My idea is to set up the compact flash card as a drive and download applications to it using FTP. This way I can download and run the dhrystone program. 

 

I&#39;m still working on this as I&#39;ve posted above. 

 

Maybe some of this should be as an appendix or here on the forum. Either would work. It would have saved me days of research if it had. Maybe a mini FAQ could be started with things like commands used in the SOPC builder, linux commands and their arguments, what scripts are being called and when... 

 

Page 18 of the Linux manual needs to be revamped completely. Expound a little more on how these are set up. It is a critical issue. I ultimately cut and pasted out of rules.mak into makefile to compile the .c code from the dhrystone directory. That took several hours of trial and error. Of course I don&#39;t know what all the parameters mean, an explanation of the more common ones would definitely help. A better example to use would be to describe how to compile the c code instead of just linking the object files. Some of the examples don&#39;t have .o files. 

 

I think adding these details will shorten the learning curve for the next beginner with linux. 

 

If you know of web sites that have info on operation of linux/unix and other details,please post them. Centralizing the details would help a lot. 

 

I really want to get this project working. Whatever processor has the best performance/price ratio is what we&#39;ll go with. However as I said, the xilinx test was completed in 3-4 evenings.  

 

John K.
0 Kudos
Altera_Forum
Honored Contributor II
460 Views

Thank you everyone for helping out. I would&#39;ve stepped in earlier but the first msg in the thread didn&#39;t contain any indications that it was a Linux issue so I moved on. 

 

Mr. jdkirby... I&#39;m one of the co-authors of the Getting Started Guide and the Reference Guide (I also wear other hats but that&#39;s irrelevant at this point in time). I&#39;m sorry if our documentation hasn&#39;t addressed the problems you&#39;re encountering to your satisfaction. Your suggestion about a FAQ and Appendix are good ideas, and I must admit, you&#39;re not the first person to suggest it. If you have any other suggestions/recommendations, please feel free to send it my way. 

 

With regards to additional help. I&#39;m always willing to at the very least look at a problem although I cannot always guarantee that I can respond in a timely fashion. I do try but I have other responsibilities at work. 

 

The quickest way to get my attention is to ensure that the word Linux appears somewhere in the title or body of the first message. Follow that up with what you&#39;re trying to do and any specific error messages that you&#39;re getting. That will give me an idea of where the problem might be. 

 

Letting me know that you&#39;re still working on trying to FTP to a compact flash card really ties up my hands because I can&#39;t even begin to imagine where the problem might be. Is the network up and running? Did you install ftpd into your target filesystem? Are you receiving and "invalid password" error message? Or is the connection just being refused? Maybe the permissions haven&#39;t been set properly? etc... 

 

I do want to help, like I try to help others on this board. But I need more information.
0 Kudos
Altera_Forum
Honored Contributor II
460 Views

"A typical example would be enabling IDE support when there is no Compact Flash support in the target hardware." 

 

So where is "Compact Flash support in the target hardware" located at? 

 

 

Is it under "ATA/ATAPI/MFM/RLL support" ? 

 

BTW, that item is checked along with "Enhanced IDE/MFM/RLL disk/cdrom/tape/floppy support" and 

"Other IDE chipset support" along with "Altera CF (IDE mode) interface (Avalon Bus) support". 

 

Unless I&#39;m missing another check box, I&#39;d say Compact Flash support IS active in hardware. 

 

Under file systems, "Second extended fs support" is checked along with "ROM file system support". 

 

So why do I get this error: 

 

/cygdrive/c/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.kernel_0.1.5/linux-2.6.x/drivers/ide/ide.c:218: error: `na_ide_ide&#39; undeclared (first use in this function) 

/cygdrive/c/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.kernel_0.1.5/linux-2.6.x/drivers/ide/ide.c:218: error: (Each undeclared identifier is reported only once 

/cygdrive/c/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.kernel_0.1.5/linux-2.6.x/drivers/ide/ide.c:218: error: for each function it appears in.) 

make[3]: *** [drivers/ide/ide.o] Error 1 

make[2]: *** [drivers/ide] Error 2 

make[1]: *** [drivers] Error 2 

make: *** [all] Error 2 

 

John K.
0 Kudos
Altera_Forum
Honored Contributor II
460 Views

Which hardware design are you using? 

 

If the hardware design that you&#39;re compiling the kernel against doesn&#39;t have a CompactFlash SOPC component, then IDE support cannot be built in. So yes, you would need to turn off the ATA/ATAPI/MFM/RLL support from within the kernel configuration tool. 

 

If you&#39;re using one of Altera&#39;s development board&#39;s (say the 1s10, 1s10ES, or the 1s40), there is a linux hardware design that you can use the provides all the basic functionality of the standard_32 hardware design + compact flash support. 

 

The linux designs can be found in 

 

.../altera/kits/nios2/examples/verilog/<whatever board you&#39;re using>/linux 

 

Selecting the PTF file from the above mentioned directory while creating a new kernel project will allow you to use the default options in the kernel. So the steps you would need to take are: 

 

(1) Create a new kernel project 

(2) select a PTF file from the directory I mentioned above 

(3) Configure the kernel (taking all default options) 

(4) Build the kernel 

(5) Upload the kernel. 

 

Let me know if the above steps don&#39;t work.
0 Kudos
Altera_Forum
Honored Contributor II
460 Views

"Letting me know that you&#39;re still working on trying to FTP to a compact flash card really ties up my hands because I can&#39;t even begin to imagine where the problem might be. Is the network up and running? Did you install ftpd into your target filesystem? Are you receiving and "invalid password" error message? Or is the connection just being refused? Maybe the permissions haven&#39;t been set properly? etc..." 

 

I think I&#39;ve solved the compilation problem. The following needs to be added to the kernel requirements section on p31: 

 

Right click on your kernel name in the Navigator window, select properties, select Nios 2 kernel in the window that pops up, make sure the SOPC builder system has "linux_1s10.ptf" selected. Failure to do this will cause the build to fail. 

 

This solved the compile issue, now when I select vmlinux.bin and select upload the following appears: 

 

 

------------------------------------------------ 

Microtronix Linux Extensions 

Version 1.1, Built Wed Jul 7 12:46pm EST 2004 

------------------------------------------------ 

Expected integer value for option &#39;location&#39; 

Value was: &#39;null&#39; 

Using default value: -1 

The bin2flash utility converts any binary data file to a FLASH file that 

can be used by the flash programmer. 

 

usage: bin2flash [--help] [--debug] [--silent] [--flash=designator] 

[--input=file] [--quiet] [--epcs] [--base=addr] [--log=file] 

[--location=addr] [--output=file] [--verbose]  

 

Options may be specified in any order. 

 

--base=<addr> flash base address 

--debug debug mode 

--epcs epcs flash mode 

--flash=<designator> flash device reference designator 

--help print this message 

--input=<file> input Binary file to process 

--location=<addr> design location within the flash 

--log=<file> file for logging progress 

--output=<file> output flash file 

--quiet only print errors 

--silent silent mode - same as quiet 

--verbose lots of interesting information 

 

 

Isn&#39;t linux fun? One problem after another... 

 

John K.
0 Kudos
Altera_Forum
Honored Contributor II
460 Views

Alright. So, now we&#39;re moving along. I understand your frustrated, just a little further along and you&#39;ll have your kernel in place. 

 

The error you&#39;re getting has to do with a bug that was noticed early on in the release and is documented in this forum. Modifying the properties for the kernel project accidently erases the offset value within the configuration file for the project, causing the problem that you see. 

 

The fix hasn&#39;t been released yet but will be soon if all goes well. 

 

To fix the problem for this particular instance: 

 

There&#39;s a file called <project_name>.stf within your project directory. Inside the file, there&#39;s a tag 

 

<location_on_target> 

 

The tag has to be modified to look like this: 

 

<location_on_target offset=&#39;0x0&#39;> 

 

After making the modification, try uploading your kernel again by right-clicking the "build/vmlinux.bin" file and selecting Upload.
0 Kudos
Altera_Forum
Honored Contributor II
460 Views

Well that explains the error I was getting at home.  

 

Now when I insert the flash card the console displays: 

hda: 3SYSTEM SSSCF016MAA. CFA DISK drive 

ide0 at 0x80920900-0x80920907,0x80920938 on irq 5. 

 

So it looks like the hardware is configured properly. 

 

According to the reference guide (p31) I am supposed to enter the command "fdisk /dev/hda" 

 

but I get the response "Unable to open /dev/hda". 

 

Any ideas? 

 

John K
0 Kudos
Altera_Forum
Honored Contributor II
460 Views

I just got your msg, I&#39;ll be looking into it this morning.

0 Kudos
Altera_Forum
Honored Contributor II
460 Views

Hi... I was able to duplicate your error by having the CF card removed while starting up fdisk. Which leaves me to believe that the CF device driver isn&#39;t properly reading your compact flash card. When the driver for the CF card detects a card in the slot, you should see something along the lines of: 

 

hda: SanDisk SDCFB-16, CFA DISK drive 

Using anticipatory io scheduler 

ide0 at 0x80920900-0x80920907,0x80920938 on irq 5 

hda: max request size: 128KiB 

hda: 31360 sectors (16 MB) w/1KiB Cache, CHS=490/2/32 

hda: hda1 

 

The last few lines of text indicate that the driver has been able to read the geometry of the CF card. It also indicates what partitions it can detect (in my case, only 1 primary partition). 

 

My suggestion would be to try another brand of CF card (or at the very least, another CF card) and see if that causes the same problem.  

 

One other issue might have to do with the romfs. Try the following command: 

 

ls -l /dev/hda 

 

It should produce the following output 

 

brw-------  1 root     root       3,   0  Jan  1 1970  /dev/hda
0 Kudos
Altera_Forum
Honored Contributor II
460 Views

One other suggestion: 

 

As I understand it, you&#39;re trying to setup a CF card as a writable filesystem in order to upload your apps for running? 

 

One of my favourite methods of running one-shot apps is to upload to one of the ram filesystems that are currently mounted. 

 

As an example, if you&#39;re using a full filesystem setup, then there should be 2 mounted ext2 filesystems that exist on ramdisks. 

 

# mount rootfs on / type rootfs (rw) /dev/root on / type romfs (ro) /dev/ram0 on /var type ext2 (rw) /dev/ram1 on /tmp type ext2 (rw) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) 

 

Notice the /var and /tmp lines. 

 

I usually perform a chmod 777 on the /tmp directory, connect via FTP using the "nios" and "uClinux" username/password combo, then upload to the /tmp directory. 

 

It&#39;s a quick a dirty way of running apps without rebuilding and reuploading the filesystem. 

 

If you want more info on the above procedure, just let me know.
0 Kudos
Reply