dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages

Message definitions for the unified bootloader. More...

Data Structures

struct  bl_messages
 
struct  xfer_state
 
struct  led_pwm_state
 
struct  bl_fsm_context
 
struct  bl_transition
 

Macros

#define BL_INCLUDE_CAP_EXTENSIONS
 
#define BL_MSG_FLAGS_ECHO_REQ   0x80
 
#define BL_MSG_FLAGS_ECHO_REP   0x40
 
#define BL_MSG_FLAGS_MASK   0xC0
 
#define BL_MSG_COMMAND_MASK   0x3F
 
#define MIN(x, y)   ((x) < (y) ? (x) : (y))
 
#define MSEC_TO_USEC(ms)   ((ms) * 1000)
 
#define SEC_TO_MSEC(s)   ((s) * 1000)
 
#define SEC_TO_USEC(s)   ((s) * 1000 * 1000)
 
#define BL_DETECT_BREAK_TO_BL_TIMER_WITH_VSENSE   MSEC_TO_USEC(2)
 
#define BL_DETECT_BREAK_TO_BL_TIMER_NO_VSENSE   MSEC_TO_USEC(500)
 
#define BL_WAIT_FOR_DFU_TIMER   SEC_TO_USEC(6)
 
#define BL_RECOVER_FROM_FAULT_TIMER   SEC_TO_USEC(10)
 

Enumerations

enum  bl_commands {
  BL_MSG_RESERVED = 0, BL_MSG_CAP_REQ, BL_MSG_CAP_REP, BL_MSG_ENTER_DFU,
  BL_MSG_JUMP_FW, BL_MSG_RESET, BL_MSG_OP_ABORT, BL_MSG_WRITE_CONT,
  BL_MSG_OP_END, BL_MSG_READ_START, BL_MSG_READ_CONT, BL_MSG_STATUS_REQ,
  BL_MSG_STATUS_REP, BL_MSG_WIPE_PARTITION, BL_MSG_WRITE_START = 0x27
}
 
enum  dfu_partition_label
 
enum  bl_states {
  BL_STATE_FSM_FAULT = 0, BL_STATE_INIT, BL_STATE_DETECT_BREAK_TO_BL, BL_STATE_WAIT_FOR_DFU,
  BL_STATE_JUMPING_TO_APP, BL_STATE_JUMP_FAILED, BL_STATE_DFU_OPERATION_FAILED, BL_STATE_DFU_OPERATION_OK,
  BL_STATE_DFU_IDLE, BL_STATE_DFU_READ_IN_PROGRESS, BL_STATE_DFU_WRITE_IN_PROGRESS, BL_STATE_NUM_STATES
}
 
enum  legacy_dfu_states {
  DFU_IDLE = 0, DFU_WRITING, DFU_WRONG_PACKET_RX, DFU_TOO_MANY_PACKETS,
  DFU_TOO_FEW_PACKETS, DFU_LAST_OP_SUCCESS, DFU_READING, DFU_BL_IDLE,
  DFU_LAST_OP_FAILED, DFU_WRITE_START, DFU_OUTSIDE_DEV_CAP, DFU_CRC_FAIL,
  DFU_FAILED_JUMP
}
 
enum  bl_events {
  BL_EVENT_ENTER_DFU, BL_EVENT_USB_CONNECTED, BL_EVENT_USB_DISCONNECTED, BL_EVENT_JUMP_TO_APP,
  BL_EVENT_TIMER_EXPIRY, BL_EVENT_READ_START, BL_EVENT_WRITE_START, BL_EVENT_ABORT_OPERATION,
  BL_EVENT_TRANSFER_DONE, BL_EVENT_TRANSFER_ERROR, BL_EVENT_AUTO, BL_EVENT_FORCE_BOOT,
  BL_EVENT_NUM_EVENTS
}
 

Functions

enum dfu_partition_label __attribute__ ((packed))
 
static uint32_t bl_compute_partition_crc (uintptr_t partition_id, uint32_t partition_offset, uint32_t length)
 
bool bl_xfer_completed_p (const struct xfer_state *xfer)
 
bool bl_xfer_crc_ok_p (const struct xfer_state *xfer)
 
bool bl_xfer_read_start (struct xfer_state *xfer, const struct msg_xfer_start *xfer_start)
 
bool bl_xfer_send_next_read_packet (struct xfer_state *xfer)
 
bool bl_xfer_write_start (struct xfer_state *xfer, const struct msg_xfer_start *xfer_start)
 
bool bl_xfer_write_cont (struct xfer_state *xfer, const struct msg_xfer_cont *xfer_cont)
 
bool bl_xfer_wipe_partition (const struct msg_wipe_partition *wipe_partition)
 
bool bl_xfer_send_capabilities_self (void)
 
static uint32_t led_pwm_on_p (uint32_t pwm_period, uint32_t pwm_sweep_steps, uint32_t uptime, uint8_t *fraction)
 
void led_pwm_config (struct led_pwm_state *leds, uint32_t pwm_1_period_us, uint32_t pwm_1_sweep_steps, uint32_t pwm_2_period_us, uint32_t pwm_2_sweep_steps)
 
void led_pwm_add_ticks (struct led_pwm_state *leds, uint32_t elapsed_us)
 
bool led_pwm_update_leds (struct led_pwm_state *leds)
 
void PIOS_Board_Init (void)
 
static void go_fsm_fault (struct bl_fsm_context *context)
 
static void go_detect_break_to_bl (struct bl_fsm_context *context)
 
static void go_wait_for_dfu (struct bl_fsm_context *context)
 
static void go_jumping_to_app (struct bl_fsm_context *context)
 
static void go_dfu_idle (struct bl_fsm_context *context)
 
static void go_read_in_progress (struct bl_fsm_context *context)
 
static void go_write_in_progress (struct bl_fsm_context *context)
 
static void go_dfu_operation_ok (struct bl_fsm_context *context)
 
static void go_dfu_operation_failed (struct bl_fsm_context *context)
 
static enum bl_states bl_fsm_get_state (struct bl_fsm_context *context)
 
static void bl_fsm_timer_start (struct bl_fsm_context *context, uint32_t timer_duration_us)
 
static void bl_fsm_timer_cancel (struct bl_fsm_context *context)
 
static void bl_fsm_timer_add_ticks (struct bl_fsm_context *context, uint32_t elapsed_us)
 
static bool bl_fsm_timer_expired_p (struct bl_fsm_context *context)
 
static void bl_fsm_process_auto (struct bl_fsm_context *context)
 
static void bl_fsm_inject_event (struct bl_fsm_context *context, enum bl_events event)
 
static void bl_fsm_init (struct bl_fsm_context *context)
 
static void process_packet_rx (struct bl_fsm_context *context, const struct bl_messages *msg)
 
int main (void)
 
static bool bl_select_dfu_device (struct bl_fsm_context *context, uint8_t device_number)
 
static bool bl_send_status (struct bl_fsm_context *context)
 
static bool bl_send_capabilities (struct bl_fsm_context *context, uint8_t device_number)
 

Variables

static const uint8_t fsm_to_dfu_state_map []
 
bool have_vsense
 
static const struct bl_transition bl_transitions [BL_STATE_NUM_STATES]
 

Detailed Description

Message definitions for the unified bootloader.

Unified bootloader main loop and FSM.

LED PWM emulation for the unified bootloader.

Data transfer functions for the unified bootloader.

Macro Definition Documentation

#define BL_DETECT_BREAK_TO_BL_TIMER_NO_VSENSE   MSEC_TO_USEC(500)

Definition at line 46 of file main.c.

#define BL_DETECT_BREAK_TO_BL_TIMER_WITH_VSENSE   MSEC_TO_USEC(2)

Definition at line 45 of file main.c.

#define BL_INCLUDE_CAP_EXTENSIONS

Definition at line 30 of file bl_messages.h.

#define BL_MSG_COMMAND_MASK   0x3F

Definition at line 58 of file bl_messages.h.

#define BL_MSG_FLAGS_ECHO_REP   0x40

Definition at line 56 of file bl_messages.h.

#define BL_MSG_FLAGS_ECHO_REQ   0x80

Definition at line 55 of file bl_messages.h.

#define BL_MSG_FLAGS_MASK   0xC0

Definition at line 57 of file bl_messages.h.

#define BL_RECOVER_FROM_FAULT_TIMER   SEC_TO_USEC(10)

Definition at line 49 of file main.c.

#define BL_WAIT_FOR_DFU_TIMER   SEC_TO_USEC(6)

Definition at line 48 of file main.c.

#define MIN (   x,
 
)    ((x) < (y) ? (x) : (y))

Definition at line 42 of file bl_xfer.c.

#define MSEC_TO_USEC (   ms)    ((ms) * 1000)

Definition at line 41 of file main.c.

#define SEC_TO_MSEC (   s)    ((s) * 1000)

Definition at line 42 of file main.c.

#define SEC_TO_USEC (   s)    ((s) * 1000 * 1000)

Definition at line 43 of file main.c.

Enumeration Type Documentation

Enumerator
BL_MSG_RESERVED 
BL_MSG_CAP_REQ 
BL_MSG_CAP_REP 
BL_MSG_ENTER_DFU 
BL_MSG_JUMP_FW 
BL_MSG_RESET 
BL_MSG_OP_ABORT 
BL_MSG_WRITE_CONT 
BL_MSG_OP_END 
BL_MSG_READ_START 
BL_MSG_READ_CONT 
BL_MSG_STATUS_REQ 
BL_MSG_STATUS_REP 
BL_MSG_WIPE_PARTITION 
BL_MSG_WRITE_START 

Definition at line 36 of file bl_messages.h.

enum bl_events
Enumerator
BL_EVENT_ENTER_DFU 
BL_EVENT_USB_CONNECTED 
BL_EVENT_USB_DISCONNECTED 
BL_EVENT_JUMP_TO_APP 
BL_EVENT_TIMER_EXPIRY 
BL_EVENT_READ_START 
BL_EVENT_WRITE_START 
BL_EVENT_ABORT_OPERATION 
BL_EVENT_TRANSFER_DONE 
BL_EVENT_TRANSFER_ERROR 
BL_EVENT_AUTO 
BL_EVENT_FORCE_BOOT 
BL_EVENT_NUM_EVENTS 

Definition at line 98 of file main.c.

enum bl_states
Enumerator
BL_STATE_FSM_FAULT 
BL_STATE_INIT 
BL_STATE_DETECT_BREAK_TO_BL 
BL_STATE_WAIT_FOR_DFU 
BL_STATE_JUMPING_TO_APP 
BL_STATE_JUMP_FAILED 
BL_STATE_DFU_OPERATION_FAILED 
BL_STATE_DFU_OPERATION_OK 
BL_STATE_DFU_IDLE 
BL_STATE_DFU_READ_IN_PROGRESS 
BL_STATE_DFU_WRITE_IN_PROGRESS 
BL_STATE_NUM_STATES 

Definition at line 51 of file main.c.

Definition at line 64 of file bl_messages.h.

Enumerator
DFU_IDLE 
DFU_WRITING 
DFU_WRONG_PACKET_RX 
DFU_TOO_MANY_PACKETS 
DFU_TOO_FEW_PACKETS 
DFU_LAST_OP_SUCCESS 
DFU_READING 
DFU_BL_IDLE 
DFU_LAST_OP_FAILED 
DFU_WRITE_START 
DFU_OUTSIDE_DEV_CAP 
DFU_CRC_FAIL 
DFU_FAILED_JUMP 

Definition at line 67 of file main.c.

Function Documentation

enum dfu_partition_label __attribute__ ( (packed)  )

Definition at line 38 of file serial_4way.h.

static uint32_t bl_compute_partition_crc ( uintptr_t  partition_id,
uint32_t  partition_offset,
uint32_t  length 
)
static

Definition at line 44 of file bl_xfer.c.

static enum bl_states bl_fsm_get_state ( struct bl_fsm_context context)
static

Definition at line 255 of file main.c.

static void bl_fsm_init ( struct bl_fsm_context context)
static

Definition at line 431 of file main.c.

static void bl_fsm_inject_event ( struct bl_fsm_context context,
enum bl_events  event 
)
static

Definition at line 411 of file main.c.

static void bl_fsm_process_auto ( struct bl_fsm_context context)
static

Definition at line 399 of file main.c.

static void bl_fsm_timer_add_ticks ( struct bl_fsm_context context,
uint32_t  elapsed_us 
)
static

Definition at line 271 of file main.c.

static void bl_fsm_timer_cancel ( struct bl_fsm_context context)
static

Definition at line 266 of file main.c.

static bool bl_fsm_timer_expired_p ( struct bl_fsm_context context)
static

Definition at line 284 of file main.c.

static void bl_fsm_timer_start ( struct bl_fsm_context context,
uint32_t  timer_duration_us 
)
static

Definition at line 260 of file main.c.

static bool bl_select_dfu_device ( struct bl_fsm_context context,
uint8_t  device_number 
)
static
Todo:
Should check if we're in the right state for this

Definition at line 537 of file main.c.

static bool bl_send_capabilities ( struct bl_fsm_context context,
uint8_t  device_number 
)
static

Definition at line 565 of file main.c.

static bool bl_send_status ( struct bl_fsm_context context)
static

Definition at line 551 of file main.c.

bool bl_xfer_completed_p ( const struct xfer_state xfer)

Definition at line 66 of file bl_xfer.c.

bool bl_xfer_crc_ok_p ( const struct xfer_state xfer)

Definition at line 71 of file bl_xfer.c.

bool bl_xfer_read_start ( struct xfer_state xfer,
const struct msg_xfer_start xfer_start 
)

Definition at line 85 of file bl_xfer.c.

bool bl_xfer_send_capabilities_self ( void  )

Definition at line 354 of file bl_xfer.c.

bool bl_xfer_send_next_read_packet ( struct xfer_state xfer)

Definition at line 149 of file bl_xfer.c.

bool bl_xfer_wipe_partition ( const struct msg_wipe_partition wipe_partition)

Definition at line 314 of file bl_xfer.c.

bool bl_xfer_write_cont ( struct xfer_state xfer,
const struct msg_xfer_cont xfer_cont 
)

Definition at line 270 of file bl_xfer.c.

bool bl_xfer_write_start ( struct xfer_state xfer,
const struct msg_xfer_start xfer_start 
)

Definition at line 189 of file bl_xfer.c.

static void go_detect_break_to_bl ( struct bl_fsm_context context)
static

Definition at line 298 of file main.c.

static void go_dfu_idle ( struct bl_fsm_context context)
static

Definition at line 369 of file main.c.

static void go_dfu_operation_failed ( struct bl_fsm_context context)
static

Definition at line 393 of file main.c.

static void go_dfu_operation_ok ( struct bl_fsm_context context)
static

Definition at line 387 of file main.c.

static void go_fsm_fault ( struct bl_fsm_context context)
static

Definition at line 292 of file main.c.

static void go_jumping_to_app ( struct bl_fsm_context context)
static

Definition at line 321 of file main.c.

static void go_read_in_progress ( struct bl_fsm_context context)
static

Definition at line 375 of file main.c.

static void go_wait_for_dfu ( struct bl_fsm_context context)
static

Definition at line 313 of file main.c.

static void go_write_in_progress ( struct bl_fsm_context context)
static

Definition at line 381 of file main.c.

void led_pwm_add_ticks ( struct led_pwm_state leds,
uint32_t  elapsed_us 
)

Definition at line 77 of file led_pwm.c.

void led_pwm_config ( struct led_pwm_state leds,
uint32_t  pwm_1_period_us,
uint32_t  pwm_1_sweep_steps,
uint32_t  pwm_2_period_us,
uint32_t  pwm_2_sweep_steps 
)

Definition at line 51 of file led_pwm.c.

static uint32_t led_pwm_on_p ( uint32_t  pwm_period,
uint32_t  pwm_sweep_steps,
uint32_t  uptime,
uint8_t *  fraction 
)
static

Definition at line 29 of file led_pwm.c.

bool led_pwm_update_leds ( struct led_pwm_state leds)

Definition at line 82 of file led_pwm.c.

int main ( void  )

dRonin Main function:

Initialize PiOS
Create the "System" task (SystemModInitializein Modules/System/systemmod.c)
Start the RTOS Scheduler

CortexM3 CPU vectors

CortexM3 CPU vectors

Definition at line 441 of file main.c.

void PIOS_Board_Init ( )

PIOS_Board_Init() initializes all the core subsystems on this specific hardware called from System/openpilot.c

Initialise PWM Output for black/white level setting PIOS_Board_Init() initializes all the core subsystems on this specific hardware called from System/openpilot.c

PIOS_Board_Init() initializes all the core subsystems on this specific hardware

PIOS_Board_Init() initializes all the core systems on this specific hardware called from System/openpilot.c

Definition at line 44 of file pios_board.c.

static void process_packet_rx ( struct bl_fsm_context context,
const struct bl_messages msg 
)
static

Definition at line 586 of file main.c.

Variable Documentation

const struct bl_transition bl_transitions[BL_STATE_NUM_STATES]
static

Definition at line 150 of file main.c.

bool have_vsense

Definition at line 133 of file main.c.