SCons_bootloader.py - Build the bootloaderΒΆ

This builds the bootloader for a given configuration. It should be invoked from the main SConstruct.py script.

import os
Import('env bin2hex linker_side_effect')

## Inform SCons about the dependencies in the template-based files
SConscript('templates/SConscript.py', 'env')

targetName = 'p${MCU}_${HW}_bootloader'

Compile the bootloader to a .cof file.

p = env.Program(target=targetName, source=[
    'bootloader/pic24_dspic33_bootloader.X/main.c',
    'bootloader/pic24_dspic33_bootloader.X/mem.c',
    'lib/src/pic24_configbits.c',
    'lib/src/pic24_clockfreq.c',
    'lib/src/pic24_uart.c',
    'lib/src/pic24_serial.c',
    'lib/src/pic24_util.c',
])
linker_side_effect(env, p)

Convert it to a .hex

bin2hex(targetName, env, 'bootloader')

Copy the .hex to the hex/ directory.

env.Command('../../hex/' + targetName + '.hex', targetName + '.hex', Copy("$TARGET", "$SOURCE"))