Skip to content

Building emb6 with SCons

Phuong Nguyen edited this page Mar 30, 2016 · 10 revisions

emb6 SCons script structure

Building emb6 stack is done via a set of SCons script files.

root
|-- SConstruct                                  (1)
|-- SConscript                                  (2)
|-- targets.scons                               (3)
|-- demo
|   |-- <app_name>
|       |-- client
|       |   |-- SConscript                      (4)
|       |
|       `-- server
|           |-- SConscript                      (5)
|
|-- emb6
|   |-- SConscript                              (6)
|
|-- target
    |-- arch
    |   |-- <arch_name>
    |       |-- <mcu_name>
    |           |-- <vendor_name>
    |               |-- SConscript              (7)
    |               `-- toolchain
    |                   |-- <compiler_name>
    |                       |-- SConsript       (8)
    |-- bsp
         |-- bsp.scons                          (9)
         `-- <platform_name>
             |-- SConscript                     (10)

SConstruct (1)

The Sconstruct file is the main input file that SCons reads to control the build. In emb6, the SConstruct file is responsible for organizing environment variables which are then fed to main SConscript for building processes.

SConscripts

The SConscript files are used to share different types of environment variables.

  • Main SConscript (2): handles compiling, creating different outputs, and cleaning process.
  • Application variables (4)(5): define application-specific symbols and set of directories where C files necessary for the application can be found.
  • emb6 submodule variables (6): specify location of C files of each emb6 submodule.
  • Microprocessor variables (7)(8): define name of toolchain-specific programming tools (i.e. Assembly Compiler, C Compiler, Linker), and generic compiling and linking options.
  • Platform variables (10): provide descriptions of microprocessor and radio transceiver to use, and platform-specific symbols for compiling and linking process.

targets.scons (3)

This file contains list of target-specific configurations which define following parameters:

  • Unique configuration identifier
  • Description of applications that the configuration uses
  • Description of platform for which the configuration is built

bsp.scons (9)

This file contains list of platform descriptions with following attributes:

  • Unique platform identifier
  • Platform configuration options such as MAC address, modulation scheme for the transceiver.

Add support for a new platform (MCU combined with RF)

SCons simplifies configuration procedure of the building process. It holds true also when a new platform needs to be added to the emb6 building system. Following SCons files shall be updated in corresponding to their functionality mentioned earlier.

  • targets.scons (3)
  • Microprocessor-specific SConscript (7)(8)
  • bsp.scons (9)

Example for running CoAP server demo application on SiLab EFM32 Gecko paired with transceiver Atmel AT86RF212B

Step 1: Create a new platform under bsp folder. Supporting a new platform shall start with creating a new folder under root/target/bsp, which provides platform-specific configuration for emb6 stack. Name of the new folder shall specify MCU and RF of the platform, for example "efm32gecko_212b" in this case.

root
|-- target
    |-- bsp
         `-- efm32gecko_212b

Step 2: Create platform-specific SConscript. This SConscript is under the platform folder created in step 1. Here descriptions of MCU, transceiver, startup file, linker file, and other optional symbol definitions shall be provided. It is recommended to follow structure of existing sample SConsripts under directory root/target/bsp/ as following in this scenario:

brd_conf = {
# Micro Controller Unit description (HEAD/arch/<arch>/<mcu_fam>/<vendor> folder)
    'arch'          : 'arm',
    'family'        : 'cm3',
    'vendor'        : 'silabs',
    'cpu'           : 'efm32lg',
    'toolchain'     : 'GCC',

# Device driver description (HEAD/target/mcu folder)
    'mcu'           : 'efm32lg990f256',

# Transceiver source description (HEAD/target/if folder)
    'if'            : 'at86rf212b',

    'startupfile': 'GCC/startup_efm32lg.S',
    'scriptfile' : 'GCC/efm32lg.ld'
}

std_conf = {
# C code global defined symbols
    'CPPDEFINES' : [
            'EXTINT_CALLBACK_MODE=true',
            'RTC_COUNT_ASYNC=true',
            'IF_AT86RF212B',
            'EFM32LG990F256',
            'BOARD_EFM32STK3600',
            '_PACK_STRUCT_END=',
    ],

# GCC flags
    'CFLAGS' : [
    ],

# LINKER flags
    'LINKFLAGS' : [
            '--entry=ResetISR',
    ]
}

board_conf = {'brd' : brd_conf, 'std' : std_conf}
Return('board_conf')

Step 3: Extend bsp.scons script. A BSP configuration description should be added to the bsp.scons script. Like name of the platform folder, identifier of BSP shall also specify MCU and RF of the platform. MAC Address attribute specifies last 2 bytes of MAC address assigned to the transceiver. txrx, mode attributes specifies respectively desired transmit power, sensitivity values, and modulation scheme for the transceiver.

bsp += [{
    'id'        : 'efm32gecko_212b',  'mac_addr' : '0xCAFE',
    'txrx'      : ['11','-100'],      'mode'     :  qpsk100
}]

Step 4: Extend targets.scons script. A target configuration description should be added to the targets.scons script. The identifier shall start with prefix cs_ and application configuration attribute apps_conf is set to coap_srv, indicating CoAP Server demo application is used. Parameter for function get_descr shall be identical to identifier of newly created BSP configuration. A sample configuration is as following:

trg += [{
    'id'        : 'cs_efm32gecko_212b',
    'apps_conf' : [ coap_srv ],
    'bsp'       : get_descr(bsp, 'efm32gecko_212b')
}]

Clone this wiki locally