Forum Discussion

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

How to create a simple program that behave like a Nios IDE?

Good Morning

I have NIOS development board and I created a simple NIOS setup with memory and JTAG UART & LED. I already purchased the NIOS license so I have unlimited test time. I also use the Nios II IDE to create a simple hello world and LED blinking function. I can use the IDE to run the program on the physical hardware. This all works.

I want to write a simple program that behave like the IDE where it loads the program to the FPGA and direct the stdout to the JTAG_UART so I can read it back on my laptop.

Can anyone point me to an example or app notes? I think I need to access the USB-blaster but how and what library is out there?

Thank You for your help.

Victor

15 Replies

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

    --- Quote Start ---

    Hi,

    I am trying to convert the Image-download-application from Cygwin env to MSVC env. But IT FAILED!

    I had create the jtag_atlantic.lib & jtag_atlantic.exp file using the guide "Cygwin2MSVC_dll.txt". I manage to follow till the last part and get stucks while compiling the source code under MSVC.

    The error message we get is

    jtag_atlantic.exp : warning LNK4070: /OUT:jtag_atlantic.dll directive in .EXP differs from output filename 'D:\TESTUSBFINALDES1\test\Debug\test.exe'; ignoring directive

    jtag_atlantic.exp : warning LNK4070: /OUT:jtag_atlantic.dll directive in .EXP differs from output filename 'D:\TESTUSBFINALDES1\test\Debug\test.exe'; ignoring directive

    jtag_atlantic.exp : fatal error LNK1310: Exports not supported for pure MSIL image

    I NEED BIG HELP to understanding what wrong with my code.

    Attached is the MSVC code done by me.

    Also, I am a programming NOOB. Please help.

    This is an interesting project. Thanks you for your guide.

    --- Quote End ---

    cooi23,

    I really cannot help you with a linker problem without sitting next to you to determine the issue. However, if you followed the instructions given in Cygwin2MSVC_dll.txt properly, you would have noted that these instructions are for console use only. You cannot execute them inside MSVC environment. IOW, you need to open a command window with a path to the files to execute the conversion properly. You should have no problems converting the Cygwin version of the jtag_atlantic.dll into a MSVC version if you follow these instructions exactly. The Cygwin project code will compile directly under the MSVC environment with the corrrect dll conversion without any modifications. I have verified this. I would start with a simpler project such as the test application to define the problem.

    Regarding using the converted dll in a GUI...

    dlls created with the MSVC lib.exe utility should be called exactly the same whether being called from a GUI application or a console application.

    If you continue to have problems in this area, my suggestion is to look up the specific linker error codes that you are having on www.msdn.com (http://www.msdn.com) to determine what they are telling you.

    However, my bet is that you did not follow the instructions in Cygwin2MSVC_dll.txt exactly, or you started with a corrupted dll. You should be able to find a clean Cygwin version of jtag_atlantic.dll at: C:\altera\90(or whatever version you are using)\quartus\bin... I would copy this into a new folder by itself and using the command line, do the conversion as outlined in the instructions.

    This needs to work first. BTW, do not rename the *.lib or *.exp file anything other than jtag_atlantic.lib or jtag_atlantic.exp. This is imperative. Also, when compiling your code, make the project a Win32 console application to start with. You should be able to directly import the Cygwin code (again, I would start with either the terminal app or the test app, small steps before we take big ones...) into the MSVC project. Also, make sure that the converted dll, exp, and lib files are in your project folder. Again, the instructions make this clear. You also need to tell MSVC that the lib file is a dependent. To do this, place the lib and header file under the "Resource Files" category. The only thing that I have under my "Header File" category is StdAfx.h...

    Another tip that I just thought of...when you open a new Win32 console project, DO NOT SELECT BLANK PROJECT! This will not insert the required MS dependency files that you need to compile and link properly. Start out with a "Hello World" project and modify it by importing the project files into it and adding the lib and header files as prescribed. This should take care of your problem. This is a more of a MS issue than it is a dll issue.

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

    Hi, I am trying to convert the Image-download-application from Cygwin env to MSVC env.

    If we are choosing Windows-console mode in MSVC, the source code manage to compile successful

    However, if we are choosing Windows 32 Application (with GUI), the source code could not compile.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi,

    I am trying to convert the Image-download-application from Cygwin env to MSVC env. But IT FAILED!

    I had create the jtag_atlantic.lib & jtag_atlantic.exp file using the guide "Cygwin2MSVC_dll.txt". I manage to follow till the last part and get stucks while compiling the source code under MSVC.

    The error message we get is

    jtag_atlantic.exp : warning LNK4070: /OUT:jtag_atlantic.dll directive in .EXP differs from output filename 'D:\TESTUSBFINALDES1\test\Debug\test.exe'; ignoring directive

    jtag_atlantic.exp : warning LNK4070: /OUT:jtag_atlantic.dll directive in .EXP differs from output filename 'D:\TESTUSBFINALDES1\test\Debug\test.exe'; ignoring directive

    jtag_atlantic.exp : fatal error LNK1310: Exports not supported for pure MSIL image

    I NEED BIG HELP to understanding what wrong with my code.

    Attached is the MSVC code done by me.

    Also, I am a programming NOOB. Please help.

    This is an interesting project. Thanks you for your guide.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Victor,

    I have some experience in this area as of late. You will need to do these things:

    1. Build a SOPC project with an Avalon MM Tri-State bridge and a CFI (common flash interface) component. You will need this to store the NIOS program and to boot it up after hardware config. There is a tool for this in the NIOS IDE.

    2. Compile hardware and place in serial configuration device (if you have one on the board). If not, I have included an app note for using the PFL (parallel flash loader) to store your hardware bitstream and the NIOS program both in flash.

    3. You will need to write some sort of GUI or console application in your choice of Windows (I assume) development system. I created such an application using sample code posted on the NIOS forum website. I had to recompile the DLL for use with MS Visual Studio because it was created with the dlltool.exe in Cygwin. You don't have to use MS Visual Studio, you can use Cygwin and hack the attached code if you like, but most people are familiar with MSVC. I have also attached a cheat-sheet on how to convert the Cygwin created DLL and convert it to a MSVC dll for implicit calling. There are three (3) software projects that I have included using the jtag_atlantic.dll. One of these downloads images to the board, the other two are useful for learning how to create applications that talk to the jtag uart such as what you are suggesting.

    All of this assumes that you know the functionality of your board such as type of fpga configuration devices, memory, and switch settings, and most importantly, using SOPC Builder to build a NIOS system with peripherals.

    Unfortunately, I know of no one document that can explicitly tell you how to do what you are asking for. You will need to 'kluge' it together yourself using as much of the code that I have included as examples. The image download demo also includes the hardware configuration code. It was compiled recently in v9.1 of Quartus. This should give you a good idea on how a SOPC system is put together as well with the CFI and tri-state bridge components.

    I hope the SW helps.

    Rick