2.5. Nuclei Studio NPK Creation and Sharing

Nuclei Studio 2022.04 provides an important feature: using the initial templates provided, developers can easily create their own NPK component packages and contribute them through the platform for other developers to use.

2.5.1. Develop an NPK Component Package

2.5.1.1. Authenticate as a Developer

Before creating an NPK component package, you must first authenticate a developer account to obtain a unique owner ID. This owner ID corresponds to the owner described earlier and makes NPKs easier to manage.

First, log in to Nuclei System Technology’s RVMCU community website. After logging in, go to the Nuclei Studio -> Contribute page, where you can see the authentication button.

image1

Alternatively, visit the authentication page directly and fill in the required information. The suffix of the developer space address corresponding to Developer is your owner ID.

image2

After filling in the required information, submit it. Once the system review is approved, the authentication is complete.

image3

2.5.1.2. Create an NPK Component Package

After completing developer authentication, create a new Nuclei Studio component project by selecting File-> New-> Project-> C/C++-> New Nuclei NPK Project in the menu bar.

image4

For first-time use, log in with a developer account. The login is valid for 7 days; after that, you must log in again. Login requires scanning a QR code with WeChat, as shown in the figure below. After a successful login, the owner drop-down box lists the bound developer accounts; fill in the remaining information. To switch accounts, click login again.

image5

After the developer account is logged in, fill in the project name, project type, and other related information following the project wizard.

image6

When you select a Type for which no corresponding template exists, a prompt appears. Click OK to open the Nuclei Package Management page and download the corresponding Template Package as needed, or click Import in the lower right corner of the figure below to import it yourself.

The following example uses the ssp type template. Suppose your company name is GreenTech, your SoC name is gt25nv, the adapted board is gt25nv_fpga_eval, it uses the N307FD processor (rv32imafdc) configuration with DSP features configured, and it provides three download modes: ilm, flash, and flashxip.

Select ssp for Type: SoC Support Package

image7

When you select a Type with no related template, you are taken to the Nuclei Package Management page. On this page, select version 1.1.0 of tpp-nuclei_sdk, click Download, and close the page after the download is complete.

image8

Click Next, and select the tpp-nuclei_sdk template you just downloaded in Select a Template. The left side shows the template description and a preview of the related files; the right side shows part of the customizable content in the template.

image9

In this example, the company name is GreenTech, the SoC name is gt25nv, the adapted board is gt25nv_fpga_eval, the configuration uses the N307FD processor (rv32imafdc) with DSP features configured, and it provides three download modes: ilm, flash, and flashxip. The result after modification is shown in the figure.

image10

Click Finish to generate the NPK component package. You can then open the directory to view and modify the files and structure as needed, and import the NPK component package after the modification is complete.

Modify the project as needed, then import the NPK component package once the modification is complete.

image11

When importing the SoC package created in the example, a prompt indicates that the dependency sdk-nuclei_sdk is missing. Click OK to open the Nuclei Package Management page, select sdk-nuclei_sdk, and click Download.

image12

image13

After the download is complete and the NPK component package project has been imported successfully, the result is shown in the figure below.

image14

2.5.2. Checking and Troubleshooting NPK Component Packages

2.5.2.1. Checking a Newly Created Package Before Import

Before importing a completed package, you can use the checking tool to verify the validity of the NPK component package and avoid import failures. Its core functions focus on compliance checks of code style, variable naming, function structure, and dependency relationships to ensure code quality.

For details about this tool, see: Package checking tool

2.5.2.2. Handling Package Import Failures

When a package fails to import, you can identify the problem from the relevant logs. This section covers issues such as NPK file format errors and unsatisfied dependencies.

Click View log in the lower right corner of the Package Management page to open a log page that briefly describes the reason for the import failure.

image29

image30

When a message such as “There are file parsing exceptions” appears in the log, check the log file of that day under the <user directory>\nuclei-pack-npk-v2\CFGs\logs\sys\ path for details about the problems in the related NPK files, and make the corresponding corrections.

image31

image32

image33

2.5.2.3. Create a Test Project

To create a project using the imported NPK component package project, select File-> New-> Project-> C/C++-> New Nuclei RISC-V C/C++ Project in the menu bar.

image15

Click Next, and select the SoC and board contained in the package created above.

image16

Click Next, fill in the Project Name, select Simple Helloworld Demo for Project Example, and click Finish to complete the creation of the test project.

image17

2.5.2.4. Build and Debug the Test Project

The project created in the steps above is a test project based on the developer’s NPK component package. The developer can code, debug, run, and perform other operations on it as with a normal project.

Click to select the N307FD project generated in the previous step and build it; the build succeeds. Subsequent steps such as running are omitted here. At this point, an NPK component package has been successfully created and imported for use.

image18

2.5.3. Share an NPK Component Package

2.5.3.1. Sharing an NPK Component Package

After passing the tests, you can share the NPK component package you created. First, export your NPK component package project as a zip package as follows.

Open the NPK component package project, double-click the outermost npk.yml file, and confirm that its Name is ssp-nsdk_gt25nv. Then right-click the NPK component package project, click Export, select Archive File, select the project to export, and specify where to save the exported zip file.

image19

image20

The exported zip package can be shared and contributed through the RVMCU community. Go to the community sharing page, fill in the name, type, description, and other information of the NPK component package to be shared, and upload the zip file you just exported. After the information is submitted and approved by the administrator, the NPK component package is successfully contributed. Other developers can then find your NPK component package on the Nuclei Package Management page of Nuclei Studio and download it for use. The procedure is shown in the figures below.

image21

image22

image23

After the shared NPK component package is approved, open the Nuclei Package Management page in Nuclei Studio and click Refresh. The component package you just shared appears in the list.

image24

2.5.3.2. Upgrade an NPK Component Package

After an NPK component package is shared, if a new version needs to be maintained, you can upgrade the existing NPK component package once creation, testing, and packaging are complete. Go to the Nuclei Studio page, find the component package management entry, open the component package management page, click Upgrade Component Package, and upload the NPK component package following the previous steps. After the review is approved, the component package upgrade is complete.

image25

image26

image27

2.5.4. Using NPK Component Packages in Nuclei Studio

NPK component packages enrich the user experience in Nuclei Studio. With NPK component packages, you can define various project creation workflows and easily share mature projects or components with others.

All contributed NPK packages are managed in NPK Package Management of Nuclei Studio, where users can download, import, delete, and perform other operations on NPKs.

image28