Last updated: 2026-02-19
This document describes the VSCP bootloader module implemented by:
common/vscp-bootloader.hcommon/vscp-bootloader.c
The module provides a protocol-driven firmware update state machine for VSCP nodes.
vscpboot_loader() is the boot entry state machine.
At boot:
- Initialize bootloader hardware.
- Read boot flag from persistent storage.
- Jump to application if boot flag indicates normal run.
- Otherwise enter VSCP boot protocol mode and handle firmware transfer events.
The implementation supports Level I and Level II usage patterns via configuration.
#include <vscp-bootloader.h>Primary dependencies:
vscp.hvscp-class.hvscp-type.hcrc.hvscp-projdefs.h
STATE_BLOCKSTARTSTATE_BLOCKPRGSTATE_BLOCKDATA
vscpboot_config_t:
vscpLevel(0= Level I,1= Level II)blockSizeblockCount
VSCPBOOT_FLAG_BOOT(0xFF): value used to force bootloader mode.VSCPBOOT_NICKNAME_BOOT(0xFE): reserved nickname for booting node.
vscpboot_initEventExvscpboot_initvscpboot_loader
vscpboot_goApplicationvscpboot_runvscpboot_init_hardwarevscpboot_release_hardwarevscpboot_getBootFlagvscpboot_setBootFlagvscpboot_rebootvscpboot_getConfigvscpboot_getGUIDvscpboot_isMemTypeValidvscpboot_isMemBankValidvscpboot_programBlockvscpboot_calcPrgCrcvscpboot_sendEventExvscpboot_getEventEx
On entering boot mode, the node sends VSCP_TYPE_PROTOCOL_ACK_BOOT_LOADER with:
- block size
- block count
Host sends VSCP_TYPE_PROTOCOL_START_BLOCK with block index and optional memory type/bank.
Bootloader validates request and responds:
VSCP_TYPE_PROTOCOL_START_BLOCK_ACKon successVSCP_TYPE_PROTOCOL_START_BLOCK_NACKon failure
Host sends VSCP_TYPE_PROTOCOL_BLOCK_DATA frames.
Bootloader appends payload into an internal block buffer until full and responds with ACK/NACK events.
Host sends VSCP_TYPE_PROTOCOL_PROGRAM_BLOCK_DATA for the active block.
Bootloader calls vscpboot_programBlock() and returns:
VSCP_TYPE_PROTOCOL_PROGRAM_BLOCK_DATA_ACKon successVSCP_TYPE_PROTOCOL_PROGRAM_BLOCK_DATA_NACKon failure
Host sends VSCP_TYPE_PROTOCOL_ACTIVATE_NEW_IMAGE with expected CRC.
Bootloader compares against vscpboot_calcPrgCrc() and responds with:
VSCP_TYPE_PROTOCOL_ACTIVATE_NEW_IMAGE_ACKwhen CRC matchesVSCP_TYPE_PROTOCOL_ACTIVATE_NEW_IMAGE_NACKwhen CRC differs
These functions are mandatory integration points:
- Hardware lifecycle (
init/release) - Boot flag storage (
get/set) - Application jump (
goApplication) - Transport receive/send (
getEventEx/sendEventEx) - Memory validation/programming (
isMemTypeValid,isMemBankValid,programBlock) - Program CRC calculation (
calcPrgCrc)
vscpboot_getEventEx() must normalize protocol events so bootloader logic receives expected class/type and payload layout. In particular, Level II class-wrapped Level I protocol events should be mapped to the Level I protocol format expected by this module.
void boot_entry(void)
{
vscpboot_init();
vscpboot_loader();
}Typical target-specific implementations include:
vscpboot_getBootFlag()reading EEPROM/flash/NVM marker.vscpboot_setBootFlag()updating marker before reboot.vscpboot_goApplication()jumping to reset vector of application image.
- Boot flag logic inverted: nonzero should enter bootloader, zero should run app.
- Block configuration mismatch: host and node must agree on
blockSizeandblockCount. - Missing transport mapping: protocol class conversion not applied in
vscpboot_getEventEx(). - Incomplete hardware teardown: communication/peripherals not reset before jumping to app.
- CRC mismatch at activation: CRC algorithm or programmed range not aligned with host.
common/vscp-bootloader.hcommon/vscp-bootloader.ccommon/vscp-firmware-helper.hcommon/vscp-firmware.hdocs/README.md