Menu Close

RISC-V Software IDE, Freedom Studio(2)Create a New C Project

This article mainly introduces how to use freedom studio to create a new experimental project from scratch.

Related reference articles:

RISC-V teaching plan

1. Create a new Freedom Studio project

  • To create a new project, click the File menu and select New -> C Project

Figure 1 New construction

 

  • Select C Managed Build (if the dialog box does not pop up, you can ignore it), click next, as shown in Figure 2.

 

Figure 2 Select template

 

  • As shown in Figure 2, fill in the project name as run_led
  • Select the project type as Hello World Risc-v C Project
  • Click next

 

Figure 3 Select project type

 

  • Set the source directory to be empty, as shown in Figure 4
  • Click next

 

Figure 4 Project basic settings

 

  • Select Configurations are set by default and do not change, as shown in Figure 5
  • Click next

 

Figure 5 Selecting the setup options to use

 

  • Select the toolchain path, which is located in the FreedomStudio software installation directory, as shown in Figure 6
  • Click Finish

 

Figure 6 Toolchain settings

 

  • Select Open Perspective

 

Figure 7 Open View

 

  • The run_led project file is created, as shown in Figure 8

 

Figure 8 run_led project

  • Copy some files to the run_led project

Copy the assembly file run_led.S , Scripts file sys.lds and cfg file test_dbg.cfg to the run_led project folder

Figure 9 Copy the file to the run_led project folder

  • Refresh project

Right-click the run_led project in the project list and select Refresh

After refreshing, you can see the newly added files, as shown in Figure 11

 

Figure 10 Refresh project

 

Figure 11 Project list

 

  • Project property settings

Right-click the run_led project in the project list and select Properties

 

Figure 12 Setting the project

 

  • Expand C/C++Build in the settings window , click to select settings to set

Make related settings in the Tool Settings list on the right side of the window , as shown in Figure 13

 

Figure 13 Project Settings Window

 

  • The relevant setting changes in the Target Processor window are shown in Figure 14

After setting, click Apply (If you don’t click Apply, the settings will be easily lost.)

 

Figure 14 Target processor settings

  • The related setting changes in the Optimization window are shown in Figure 15

After setting, click Apply

 

Figure 15 Optimization settings

 

  • The relevant setting changes in the Debugging window are shown in Figure 16

After setting, click Apply

 

Figure 16 Debug settings

 

  • GNU RISC-V Cross C Compiler compiler list under

The relevant setting changes in the Miscellaneous window are shown in Figure 17. Fill in -fno-builtin-printf at the Other compiler flags

After setting, click Apply

 

Figure 17 Compilation settings

 

  • Linker  linker settings

The relevant settings in the General window are changed as shown in Figures 18 and 19

Click the Add Script File icon to add the sys.lds file

After setting, click Apply

Figure 18 Adding the sys.lds file

 

Figure 19 Add linker script

 

 

  • The relevant settings in the Miscellaneous window are changed as shown in Figure 20

Enter -t -nostdinc at other linker flags

After setting, click Apply

 

Figure 20 Linker settings

 

  • The relevant settings in the Flash Image->General window are changed as shown in Figure 21

After setting, click Apply

Click Apply and Close to save and close the settings

 

Figure 21 Output file format settings

  • project compilation

Right-click on the run_led project and click Build Project in the pop-up menu , as shown in Figure 22. The following results appear in the console window, indicating that the project was compiled successfully, as shown in Figure 23

Figure 22 Compile the project

 

Figure 23 console shows successful compilation

Note: If the compilation fails, it is recommended to check whether the project settings are consistent with the example

If you need to recompile, you should right-click the run_led project file and click clean project. After cleaning, click Build Project to recompile, as shown in Figure 24

 

Figure 24 clean project

 

Posted in FPGA, RISC-V, RISC-V Textbook, Textbook and Training Project

Related Articles

Leave a Reply

Your email address will not be published.

Leave the field below empty!