Application Development

Overview

Here will describe how to develop an Nuclei SDK application.

To develop a Nuclei SDK application from scratch, you can do the following steps:

  1. Create a directory to place your application code.

  2. Create Makefile in the new created directory, the minimal Makefile should look like this

    1
    2
    3
    4
    5
    6
    7
    8
    9
     TARGET = your_target_name
    
     NUCLEI_SDK_ROOT = path/to/your_nuclei_sdk_root
    
     SRCDIRS = .
    
     INCDIRS = .
    
     include $(NUCLEI_SDK_ROOT)/Build/Makefile.base
    
  3. Copy or create your application code in new created directory.

    Note

    • If you just want to SoC related resource, you can include header file nuclei_sdk_soc.h in your application code.

    • If you just want to SoC and Board related resource, you can include header file nuclei_sdk_hal.h in your application code.

    • For simplity, we recomment you to use nuclei_sdk_hal.h header file

  4. Follow Build System based on Makefile to change your application Makefile.

Add Extra Source Code

If you want to add extra source code, you can use these makefile variables:

To add all the source code in directories, recursive search is not supported.
  • SRCDIRS: Add C/CPP/ASM source code located in the directories defined by this variable.

  • C_SRCDIRS: Add C only source code located in the directories defined by this variable.

  • CXX_SRCDIRS: Add CPP only source code located in the directories defined by this variable.

  • ASM_SRCDIRS: Add ASM only source code located in the directories defined by this variable.

To add only selected source code in directory
  • C_SRCS: Add C only source code files defined by this variable.

  • CXX_SRCS: Add CPP only source code files defined by this variable.

  • ASM_SRCS: Add ASM only source code files defined by this variable.

Add Extra Include Directory

If you want to add extra include directories, you can use these makefile variables:

  • INCDIRS: Include the directories defined by this variable for C/ASM/CPP code during compiling.

  • C_INCDIRS: Include the directories defined by this variable for C only code during compiling.

  • CXX_INCDIRS: Include the directories defined by this variable for CPP only code during compiling.

  • ASM_INCDIRS: Include the directories defined by this variable for ASM only code during compiling.

Add Extra Build Options

If you want to add extra build options, you can use these makefile variables:

  • COMMON_FLAGS: This will add compiling flags for C/CPP/ASM source code.

  • CFLAGS: This will add compiling flags for C source code.

  • CXXFLAGS: This will add compiling flags for CPP source code.

  • ASMFLAGS: This will add compiling flags for ASM source code.

  • LDFLAGS: This will add linker flags when linking.

  • LDLIBS: This will add extra libraries need to be linked.

  • LIBDIRS: This will add extra library directories to be searched by linker.

Optimize For Code Size

If you want to optimize your application for code size, you set COMMON_FLAGS in your application Makefile like this:

COMMON_FLAGS := -Os

If you want to optimize code size even more, you use this link time optimization(LTO) as below:

COMMON_FLAGS := -Os -flto

see demo_eclic for example usage of optimize for code size.

For more details about gcc optimization, please refer to Options That Control Optimization in GCC.

Set Default Make Options

Set Default Global Make Options For Nuclei SDK

If you want to change the global Make options for the Nuclei SDK, you can add the Makefile.global.

Set Local Make Options For Your Application

If you want to change the application level Make options, you can add the Makefile.local.