3.5 Mapping Firmware Drivers and the Linker Script

At this stage, the drivers and the MIV_RV32 HAL files are not mapped. Therefore, the corresponding header files in the main.c file are unresolved, as shown in the following figure.

Figure 3-13. Unresolved Header Files

To map the drivers and HAL files, perform the following steps:

  1. Right-click MiV_uart_blinky project, and select Properties.
  2. Expand C/C++ Build, and select Settings.
  3. Set the configuration to All Configurations, as shown in the following figure. This setting applies the upcoming tool settings to both release and debug modes.
    Figure 3-14. C/C++ Build Settings
  4. In the Tool Settings tab, expand Target Processor, and ensure to select the following settings.
    • Architecture: RV32I (-march=rv32i*)
    • Integer ABI: ILP32(-mabi=ilp32*)
    • Multiply extension: Enabled
      Figure 3-15. Target Processor Tool Settings
  5. Expand GNU RISC-V Cross C Compiler, and select Includes.
  6. Click the Add icon to add the driver and MIV_RV32 HAL directories, as shown in the following figure.
    Figure 3-16. GNU RISC-V Cross C Compiler Tool Settings
    Important: This application does not require including system paths and other files.
  7. In the Add directory path dialog box, click Workspace, as shown in the following figure.
    Figure 3-17. Add Directory Path Dialog Box
  8. In the Folder selection dialog box, expand MiV_uart_blinky project > drivers, select the CoreGPIO folder, and click OK, as shown in the following figure.
    Figure 3-18. CoreGPIO Folder Selection
  9. In the Add directory path dialog box, click OK.

    The CoreGPIO folder path is added, as shown in the following figure.

    Figure 3-19. Tool Settings Tab with CoreGPIO Path Added
  10. Repeat the preceding steps to add the CoreUARTapb, CoreSPI, hal, MIV_RV32_HAL, and MiV_uart_blinky (ProjName) folder paths.
    The drivers and MIV_RV32_HAL files are successfully mapped, as shown in the following figure.
    Figure 3-20. Tool Settings Tab After Successful Mapping
  11. Select the GNU RISC-V Cross C Linker > General to map the linker script.
  12. Click Add icon as shown in Figure 3-16, and in the Add file path dialog, click Workspace as shown in Figure 3-17.
  13. In the File selection dialog box, expand MiV_uart_blinky and select the linker script, as shown in the following figure.
    Figure 3-21. Selecting the Linker Script
  14. The linker script is mapped as shown in the following figure.
    Figure 3-22. Linker Script Default Mapping
  15. Select the Do not use standard start files (-nostartfiles) option as shown in preceding figure.
  16. Select the GNU RISC-V Cross Create Flash Image > General and set Other Flags to “--change-section-lma *-0x80000000” as shown in the following figure. This excludes the extended linear record in the first line of the hex file.
    Figure 3-23. RISC-V Flash Image Settings
  17. Click Apply and when prompted to rebuild, choose Yes.
  18. Then click Apply and Close.

The firmware drivers and linker script are successfully mapped. Notice that the header files are now resolved in the main.c file.