DSP Project Configuration
Overview
This section introduces the configuration methods for DSP projects, divided into two parts: basic configuration and advanced configuration:
Basic Configuration: Configuration that must be completed before building the DSP project (adding files, configuring search paths)
Advanced Configuration: Optional performance optimization configurations based on actual requirements
Note
This section is based on the Xplorer GUI operation interface. If you need to use the command line to modify project configuration, you can directly edit the <dsp_sdk>/project/project_dsp/.project file.
Basic Configuration
Basic configuration includes project settings that must be completed before building: adding source code files and configuring search paths.
Add Project Folders or Files
The SDK uses virtual folders to manage project files. When using virtual folders, removing files from the project does not affect the original files on disk, and files are not copied to the project folder.
Assume our application files test1.c and test2.c are stored in a folder named application. Now add these files to the current project:
Right-click on project_dsp, select , enter
applicationas the folder name, check Folder is not located in the file system, and click Finish.
Right-click on the
applicationfolder, select Import, then click in sequence.Browse to the folder path at location 1, select the files to include at location 2, click Advanced and check the option at location 3.
Caution
When adding project files, please be sure to use relative paths. As shown in the figure above, check Create link locations relative to: and set it to PROJECT_LOC.
Command-line configuration method:
If the Xplorer GUI is unavailable, you can directly edit the <dsp_sdk>/project/project_dsp/.project file to add or remove project files:
Add a new virtual folder:
<link> <name>TestFolder</name> <type>2</type> <locationURI>virtual:/virtual</locationURI> </link>
Add files to a virtual folder:
<link> <name>TestFolder/test_file.c</name> <type>1</type> <locationURI>PARENT-2-PROJECT_LOC/testfolder/test_file.c</locationURI> </link>
Add Search Paths
Configure search paths for header files and library files to ensure the compiler can find required dependency files.
Add Header File Search Paths
Go to Build Properties:
In the tab, click the
Addbutton in the upper right corner, then enter the path. It is recommended to use the relative path${workspace_loc}, which refers to<dsp_sdk>/project.
Click the
ApplyandOKbuttons to complete the modification.
Note
Try to avoid header files with the same name. If unavoidable, please use different paths.
Add Library File Search Paths
In Build Properties, select the Libraries tab:
Click the Add icon in the upper right corner. Then enter the path. It is recommended to use the relative path ${workspace_loc}, which refers to
<dsp_sdk>/project. It is recommended to use the $(TARGET_CONFIG) variable to configure library paths for different ABIs.
Click the
ApplyandOKbuttons to complete the modification.
Advanced Configuration
Advanced configuration includes optional performance optimization settings based on actual requirements. After completing the basic configuration, if you need to further optimize the build results, refer to the following content.
Compilation Optimization
Co-processor, -O3, and SIMD compilation options can significantly improve DSP hardware resource utilization. Under high-level optimization, the compiler may adjust code execution order and CPU behavior, so these options are not suitable for all code.
For example, FreeRTOS source files and other ISR handlers cannot use Co-processor or SIMD vector optimization (-LNO:simd and -mcoproc).
Reduce DSP Firmware Size
There may be unused functions in the project code that are compiled together. Although these functions are not called, they are often linked into the executable, wasting Flash and RAM space.
To solve this problem, you can add the following compilation and linking parameters:
Add the compiler
-function-sections,-fdata-sections, and-Osoptions.Add the linker
-Wl,-gc-sectionsoption.
This method may encounter the following warning (can be ignored):
ld: warning: The min-sizing binary cannot be generated if -gc-sections is specified.
At this point, the content of .command and .ipc_table sections cannot be loaded into the firmware because they are not explicitly called. You need to specify the KEEP attribute for these two sections in the linker script
RTK_LSP/ldscripts/elf32xtensa.x:.ipc_table : ALIGN(4) { _ipc_table_start = ABSOLUTE(.); KEEP(*(.ipc_table)) . = ALIGN (4); _ipc_table_end = ABSOLUTE(.); } > psram0_seg :psram0_phdr .command : ALIGN(4) { _command_start = ABSOLUTE(.); KEEP(*(.command)) . = ALIGN (4); _command_end = ABSOLUTE(.); } > psram0_seg :psram0_phdr
Note
This linker script will be automatically overwritten each time the LSP is modified, so you need to manually modify the newly generated script again.
Library Linking Order
When linking static libraries, if there are dependencies between multiple static libraries, you need to pay attention to the linking order of the dependent static libraries, otherwise the symbol cannot be found errors will occur.
For example: liborder2.a depends on liborder1.a, and the final executable test depends on liborder2.a,
then the linking option should be: -lorder2 -lorder1, otherwise some symbols in liborder1.a will be reported as undefined.
Building Example Projects
Building Example Projects
The DSP SDK provides multiple basic examples located in the <dsp_sdk>/example/ directory. The steps to build examples are as follows:
Refer to the Adding Project Folders or Files section to add the entire
<dsp_sdk>/example/example_xxxfolder to the projectUse the above command-line build or Xplorer GUI build method to build the project
Note
For the complete list of DSP SDK basic examples (example_gdma, example_idma, example_idma_nn, etc.), please refer to: DSP SDK Introduction - Example List
Example Build Mechanism
The SDK uses a weak/strong symbol mechanism to switch between different example code:
A weak symbol function
app_example()is defined inproject/project_dsp/main.cEach example folder contains a strong symbol function with the same name
example_xxx/app_example.cDuring compilation, the strong symbol overrides the weak symbol, thereby jumping to the corresponding example code