~Welcome to the world of soft-core CPU with infinite possibilities~

        Click here for Mr. Asai's introduction and serial titles

  


If you have any questions, please contact Mr. Asai at the address below.

   


Introduction

Last time, I explained software development tools and debugging methods. This time, with the cooperation of Mr. Fukushima of Tokyo Keiki Kogyo Co., Ltd., who has a track record of writing about Nios® II in DesignWave magazine published by CQ Publishing Co., Ltd., we will explain how to develop software for Nios II.


Software development environment for Nios II

CPU vendors provide not only hardware but also software development environments, making it easy for anyone to develop software. The Nios II is no exception, with a software development tool called Nios II EDS. The tools include Nios II IDE (Eclipse-based IDE), Nios II Command Shell, nios2-elf-gcc (GNU compiler for Nios II), and more.


Table 1 shows a methodology for developing software for Nios II. The tools provided by Altera can be roughly divided into three methods for software development. By using different tools according to the system to be designed, development can proceed efficiently. Each method is explained below.


Table 1 Software development method for Nios II

Development method

Flexibility

Advanced control

Required knowledge

Development man-hours*

Nios II IDE + HAL

low

small

Nios II IDE (non-HAL)

During ~

During ~

Command Shell + nios2-elf-gcc(makefile)

high

Big

*For new development


Nios II IDE + HAL

As explained earlier, unlike commercial microcomputers, peripheral modules can be freely designed for CPU-equipped FPGAs, so it is necessary to create initialization programs, device drivers, etc., according to each. (https://www.macnica.co.jp/softcore_cpu_3.html: “Software Design” section)

Nios II EDS, a software development tool provided by Altera, has a HAL (Hardware Abstraction Layer) for peripheral modules provided by SOPC Builder (currently Qsys). It automatically reads information such as address maps and interrupts, and generates the necessary header files and device drivers.

When adding a software project for Nios II with Nios II EDS, select “Nios II C/C++Application”. If you select this, you need to create a new System Library or specify an existing Library. When you create a new System Library, the necessary drivers, interrupt handlers, initialization programs, etc. are incorporated from the prepared HAL. An application project and a system library project are generated as shown in Figure 1.


Figure 1 Nios II C/C++ Application Project Generation Example


In this way, CPU users can focus on application development, which can significantly shorten the process. On the other hand, since the software close to the hardware becomes a black Box, it may be difficult to deal with in more advanced usage.


Nios II IDE (non-HAL)

Some CPU users may want to use their own tuned device drivers or reuse existing design assets. Nios II EDS can also develop software that does not use HAL. Altera's document (Nios II Software Developer's Handbook) also has a description of non-HAL device drivers. However, in this case, it is necessary to prepare software equivalent to HAL on your own, and creating header files, linker script files, etc. is a laborious task. For those who are unfamiliar with creating these but do not want to use HAL, I will explain how to easily create a template in the second half.


Command Shell + nios2-elf-gcc

The Nios II EDS also provides a command shell (formerly called the SDK Shell). You can use this command shell to directly execute "nios2-elf-gcc" or prepare a Makefile and execute "Make". This is how software development was done before the IDE was provided.

You might say, "Now that you have an IDE, why don't you develop command-based software now?" I think that there may be cases where there is no need to go through the trouble of creating an executable binary that does not require GUI-based work. In fact, it may be easier to execute "Make" on the command line rather than forcibly embedding it into the IDE, such as Linux, which is provided by the distribution.


I've written several times before about using the vendor-provided tools in the recommended way until you get used to them, and then reading the relevant documentation and taking up the challenge once you've gotten used to them. The same is true this time.


Next, we will explain the actual development procedure using the standard Hello_world as a sample.



→ next page

~Software Development Procedure~



Click here for introduction and serial titles of Mr. Asai