|
NetBurner 3.5.8
PDF Version |
As an alternative to NBEclipse, you can use the command line tools to build your NetBurner projects. In fact, all the example programs are built and tested internally with command line tools. You will find a makefile in each example folder, so any of the examples can be used as a demonstration of how to use command line tools. Windows, Mac and Linux are supported. The command line tools can also be used to invoke the NetBurner tools from the development environment of your choice.
| Command | Description |
|---|---|
| make | Build a project using the makefile in the project directory |
| make -j | Make using multiple cores to speed up the process |
| make load | Build project and load into device |
| make -j load | Build project with multiple cores and load into device |
| make clean | Delete a project's libraries and object files |
There are a number of environment variables that can be set to effect the command line build when you do a make. For example, you can specify the target device IP address in which to download the application with a make -j load.
On the command line, typing "set <variable>" will display the current value. Typing "set <variable>=<value>" will set the environment variable. For example, "set DEVIP" will display the current target IP address. Typing "set DEVIP=10.1.1.1" will set DEVIP to the specified IP address.
| Variable | Description |
|---|---|
| DEVIP | Causes a make with the "load" parameter to download to the specified IP address |
| PLATFORM | Specifies the NetBurner platform to build for |
| NNDK_ROOT | Specifies the location of your NetBurner development tools installation |
| PATH | Specifies folders to search for system binaries, like make and other compiler tools |
For example, to reference a standard NetBurner tools installation on Windows (also see "\nburn\setenv.bat" for an example):
The easiest way to create a new project is to copy an existing one and modify it:
There are many files and folders under the obj folder, including the compiled libraries and object files.
We named our project HelloWorld, but are running SimpleHtml at this point. To customize the project:
The example makefile is shown below:
Changing the NAME from SimpleHtml to HelloWorld will create the image file as HelloWorld.bin (and .s19)
The CPP_SRC is a list of all .cpp files to build. In this case there is only one, but if there were more it would look like:
If you have .c source files you can add them with C_SRC in the same manor.
The html related lines auto-generate a cpp file from the code in the project's html directory.
The final line calls the boilerplate makefile which includes the platform specific make instructions. While you can drill down into the details, this type of makefile structure makes creating projects much easier since you only need to list the source files of your project.
A fully functional application with the web server enables is actually very few lines of code:
This example just initializes the system, starts the web server, prints out some information, and loops forever with a 1 second delay. Changing the AppName to HelloWorld will change the name that shows up in the find and configuration utilities.
There can be instances in which you need to modify a NetBurner system file. This is accomplished using the Overload feature. NBEclipse creates an overload folder automatically, but with command line builds it must be created manually.
Add an overload folder to your project. Then, for the file you want to overload, the filename and path inside the overload folder must exactly match the system file path relative to NNDK_ROOT. For example, to overload the timezones.cpp file located in the \nburn\nbrtos\source folder:
Copy the real system file into that path, then edit the copy. The project's timezones.cpp is used in place of the system one. The same applies to any header, any .cpp, and any web asset under the NNDK root.
Most projects only need to change a #define in nbrtos/include/predef.h. That header is large and changes between NNDK releases, so copying and maintaining the whole file can be complex.
The SDK provides a shortcut. The last line of predef.h is:
nbrtos/include/predef-overload.h ships empty. It exists only so a project can replace it. Create your own copy at <project root>/overload/nbrtos/include/predef-overload.h and put in only the lines you want to change:
Because predef.h includes it last, your definitions get the final word over the SDK defaults, and a later NNDK release cannot silently revert them. Use this method rather than overloading predef.h itself.
If the predef-overload.h hook did not exist, you would copy the whole predef.h to <project root>/overload/nbrtos/include/predef.h and edit it there. That is what earlier releases required, and it is still what you do for every other system file.
constants.h offers the same convenience through constants-overload.h, included near the top of constants.h, and constants-overload-undefs.h, included after the header guard closes.
The wolfSSL settings for each platform are in libraries/include/crypto/platform/<PLATFORM>/user_settings.h. Each of those files includes user_settings-overload.h after all of its settings, and the SDK ships that file empty. Create your own copy at <project root>/overload/libraries/include/crypto/platform/user_settings-overload.h and put in only the lines you want to change:
Switches such as NB_TLS_KEYLOG and the crypto profiles take effect in user_settings_switches.h, which comes after it, so they work from your file too. See TLS Key Logging for a project that uses it.
If a feature has sub-options that predef.h sets inside #ifdef FEATURE, define those sub-options yourself in predef-overload.h. For example, enabling ENABLE_AUTOCERT_REGEN this way also requires defining AUTO_CERT_GEN_CHECK, because predef.h had already skipped its #ifdef ENABLE_AUTOCERT_REGEN block by the time the overload was read. See On-board Cert Generation - Simple.
constants.h behaves the opposite way. It includes constants-overload.h before its #ifndef X / #define X default blocks, so a plain #define there simply wins.
If a system include folder is overloaded, this folder should be added to your project include paths. Right click on the project and select project properties. Under C/C++ Build->Settings, select GNU C++ Compiler->Includes and add the overload include folder. If utilizing C code, then GNU C Compiler->Includes should also be added.
To load an application and start GDB from the command line:
To end the GDB session and leave the target running use detach. To end the GDB session use quit. The GDB command reference is located here: http://www.gnu.org/software/gdb/documentation/.
An GDB session running the SimpleHtml example on a MOD54417 is shown below. The example has been modified to add some variables that do simple counting.
Load the application. Note that the DEVIP environment variable is set to the device's IP address 10.1.1.169. The application will begin execution and wait for GDB to connect.
Start GDB:
Connect to the MOD54417 target on port 2159. This will pause the application at whatever line of code it happens to be on. For simple examples that will typically be the NBRTOS idle task.
At this point you can do whatever type of GDB commands you wish. To set a break point at the i++; at line 29 of main.cpp and use the continue command to execute until the break point is reached:
The list command can be used to view the source code around the breakpoint:
Use next to go to the next line without stepping into a function (the step command steps into a function). GDB commands can typically use just the first letter, in this case n:
To make changes to your code use the detach command do that the application can resume and will be ready for your next code download:
To exit GDB, use the quit command:
To get line numbers and function names from trap memory addresses, you can use addr2line on the command line like this:
addr2line -ifCe Release/YourProject.elf 00001111 11112222
Replace "addr2line" with the path to the appropriate program below, and replace the numbers with memory addresses you want to find.
For ColdFire based platforms, use m68k-elf-addr2line. This is distributed in the \nburn\gcc\bin\\endiskip folder.
For ARM-based platforms, use arm-unknown-eabi-addr2line. This is distributed in the \nburn\gcc\bin\\endiskip folder.