Software development procedure

The software development procedure using the “Nios II IDE + HAL” is described in detail in the tutorial provided by Altera.

 

Software development procedure in Nios II IDE (non-HAL)

This section introduces how to use the initialization program and header files generated by the “Nios II IDE + HAL” method. Figure 2 shows the development flow.

 

Figure 2 Development flow in Nios II IDE (non-HAL)

 

First, use the “Nios II IDE + HAL” method to generate a project using the “hello_world” application template. “hello_world_0” and “hello_world_0_sysllib” projects are generated. Execute “Build Project” as it is. "crt0.o" is generated in the "hello_world_0_syslib/Debug" folder, and "system.h" and "generated.x" are generated in the "hello_world_0_syslib/Debug/system_description" folder.

 

In addition, the linker script generated here has Program Memory and Stack Memory set to "sdram", so if you want to change it, change the settings in "System Library Properties" before building, or directly use the linker script file Please rewrite.

 

Next, select “Managed Make C Project” from “File ⇒ New ⇒ Project” to create an empty project. Copy here the initialization program object file (crt0.o), header file (system.h), and linker script file (generated.x) from the hello_world_0_syslib project.

Finally, add source files such as applications and device drivers. The Makefile is automatically generated, so if you run the build, an executable binary file will be generated. Note that the project created here does not include interrupt handlers or hardware initialization processing, so be careful when you actually run it. If necessary, it is also possible to divert from HAL.

 

Software development procedure with Command Shell + nios2-elf-gcc

Here, we will explain Makefile sample, build method, and debug method for the source code created by “Nios II IDE (non-HAL)”. Figure 3 shows the software development flow.

 

Figure 3 Development flow with Command Shell + nios2-elf-gcc

 

First, create a folder to manage as a project. It is called “Nios2_make_app” here. Copy or create the necessary source code here.

Next, prepare a “Makefile”. If the application is not very large, it is possible to build it by adding options to "nios2-elf-gcc" on the command line, but here we will introduce how to use the Makefile.

Figure 4 shows a Makefile description example.

 

Figure 4 Makefile description example

 

Finally, start a command shell, make the “Nios2_make_app” folder current, and execute “make”. An executable binary is created.

 

Figure 5 Make execution result

 

Here's how to debug. The GNU development environment for Nios II also includes GDB, a command line, and Insight Debugger, a GUI debugger.

When using GDB or Insight, run the gdbstub program on the target side and connect via the JTAG-Debug module.

 

Execute "nios2-gdb-server.exe" with a port number option on the command shell to make the target wait for connection. In this state, start another command shell and execute "nios2-elf-insightexe" to start Insight Debugger. Start the “Target Selection” screen from “File ⇒ Target Setting” and set as follows.

・target: “Remote/TCP”

・Hostname: “localhost”

・Port: Port number specified in nios2-gdb-server.exe

 

Click the Run button to download the executable binary and stop the program at the beginning of the main program.

The Insight Debugger allows you to run and stop, set breakpoints, step into/step over, register and memory dumps, mix source code and assembler views. Easy source level debugging.

 

Figure 6 Insight Debugger

 

in conclusion

In this article, I will explain how to develop software using an integrated development environment. I think you can see that there are various methods, but we recommend that you actually try using it once.

Soft-core CPUs are designed to meet various needs, from logic to tool support, so making good use of them is the real pleasure of users.

Please experience the soft-core CPU + FPGA that "can realize a user-oriented SoC (System On Chip) from a single minimum order".

 

In the next installment, I plan to explain "OS installation example using Command Shell + nios2-elf-gcc method".