Table of Contents
Use the build root tool to make RV1126 IMG firmware
Use the build root tool to package the executable file you compiled into the firmware (img file)
Introduce two common methods
Method 1:
Place the compiled executable file in the buildroot/board/rockchip/rv1126_rv1109/fs-overlay-sysv/etc/init.d directory of the sdk, and compile and package it all.
For example, here I have put the compiled executable file test-app in the directory
- Next, just need to re-compile the entire firmware
The command to compile firmware is
- After compiling. You will see test-app, this executable file, in the /etc/init.d directory on the board end.
Then you can run it, or copy it to another directory and run it.
This method is the simplest and most recommended
Method 2:
Follow the SDK compilation rules and add your own program to buildroot.
1) Add test.c file
In the source code directory, create your own APP folder with the following command:
$mkdir app/mytest
The running results are shown in the figure below:
You can create your own APP program in the mytest directory. Here I will create a test code of test.c, example
The code is as follows
Still, in the mytest directory, create a Makefile that compiles the test.c program. The sample code is as follows:
The creation result is completed as shown in the figure below:
2) Add to menu config
When configuring the buildroot package, everyone needs to enable it on the graphical configuration interface, so our
The APP also needs to generate an option. Under the source code of the SDK package, open the “buildroot/package/Config.in” file.
Jump to the last “endmenu” and add the following sample code (note: it must be before the last endmenu of this file
Add to). The code looks like this:
The result of the addition is shown below:
No.2061 OK, it’s used in itsource Cited”package/mytest/Config.in” file, so we need to create
To create this file, the command is as follows:
$mkdir buildroot/package/mytest/
After creating the directory (mytest is the name of the package package under buildroot), we need to create the mytest directory
“Config.in” file, the content is as follows:
The result of the addition is shown below:
- APP version and compilation rules
In the previous section, we have added APP to the configuration options. At this time, buildroot still does not know how to
Download, extract, compile, etc., we need to add a configuration file to tell buildroot how to operate, and we need to create “buildroot/
package/mytest/mytest.mk”, the name must be mytest.mk. Copy the following sample code to mytest.mk
Sample code mytest.mk code
This file tells buildroot how to compile, download, copy, etc. All capitalized macros start with “MYTEST”
The header is determined based on the name of our package.
In line 1, the variable at the end of _VERSION is the source code version.
In line 2, the variable at the end of _SITE is the address of the source code download.
In line 3, the variable at the end of _SITE_METHOD is the source code download method, and local means local download.
Lines 4 and 10~12 automatically execute the installation and copy the files that our mytest can run into the bin directory.
Line 6, the variables at the end of _BUILD_CMDS will be executed when the buildroot framework is compiled, and are used to add M to the source code.
akefile passes compilation options and linkage options and calls the source code’s Makefile.
Lines 14~16 give permissions to the file.
Line 18, this function will build the entire .mk file into a script.
Enter
buildroot/output/rockchip_rv1126_rv1109_spi_nand
Execute make menuconfig
turn onmytest
After the configuration is completed, we can test whether our mytest can be compiled, in buildroot/output/rockchip_rv1126_rv1109_spi_nand
To test in the directory, the command is as follows:
$make mytest
The running results are shown in the figure below: