PX4 Firmware
PX4 Autopilot Software http://px4.io
PX4IO_Uploader Class Reference

#include <uploader.h>

Collaboration diagram for PX4IO_Uploader:

Public Member Functions

 PX4IO_Uploader ()
 
virtual ~PX4IO_Uploader ()=default
 
int upload (const char *filenames[])
 

Private Types

enum  {
  PROTO_NOP = 0x00, PROTO_OK = 0x10, PROTO_FAILED = 0x11, PROTO_INSYNC = 0x12,
  PROTO_INVALID = 0x13, PROTO_BAD_SILICON_REV = 0x14, PROTO_EOC = 0x20, PROTO_GET_SYNC = 0x21,
  PROTO_GET_DEVICE = 0x22, PROTO_CHIP_ERASE = 0x23, PROTO_CHIP_VERIFY = 0x24, PROTO_PROG_MULTI = 0x27,
  PROTO_READ_MULTI = 0x28, PROTO_GET_CRC = 0x29, PROTO_GET_OTP = 0x2a, PROTO_GET_SN = 0x2b,
  PROTO_GET_CHIP = 0x2c, PROTO_SET_DELAY = 0x2d, PROTO_GET_CHIP_DES = 0x2e, PROTO_REBOOT = 0x30,
  INFO_BL_REV = 1, BL_REV = 5, INFO_BOARD_ID = 2, INFO_BOARD_REV = 3,
  INFO_FLASH_SIZE = 4, PROG_MULTI_MAX = 248
}
 

Private Member Functions

void log (const char *fmt,...)
 
int recv_byte_with_timeout (uint8_t *c, unsigned timeout)
 
int recv_bytes (uint8_t *p, unsigned count)
 
void drain ()
 
int send (uint8_t c)
 
int send (uint8_t *p, unsigned count)
 
int get_sync (unsigned timeout=40)
 
int sync ()
 
int get_info (int param, uint32_t &val)
 
int erase ()
 
int program (size_t fw_size)
 
int verify_rev2 (size_t fw_size)
 
int verify_rev3 (size_t fw_size)
 
int reboot ()
 

Private Attributes

int _io_fd
 
int _fw_fd
 
uint32_t bl_rev
 bootloader revision More...
 

Detailed Description

Definition at line 46 of file uploader.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
PROTO_NOP 
PROTO_OK 
PROTO_FAILED 
PROTO_INSYNC 
PROTO_INVALID 
PROTO_BAD_SILICON_REV 
PROTO_EOC 
PROTO_GET_SYNC 
PROTO_GET_DEVICE 
PROTO_CHIP_ERASE 
PROTO_CHIP_VERIFY 
PROTO_PROG_MULTI 
PROTO_READ_MULTI 
PROTO_GET_CRC 
PROTO_GET_OTP 
PROTO_GET_SN 
PROTO_GET_CHIP 
PROTO_SET_DELAY 
PROTO_GET_CHIP_DES 
PROTO_REBOOT 
INFO_BL_REV 

bootloader protocol revision

BL_REV 

supported bootloader protocol

INFO_BOARD_ID 

board type

INFO_BOARD_REV 

board revision

INFO_FLASH_SIZE 

max firmware size in bytes

PROG_MULTI_MAX 

protocol max is 255, must be multiple of 4

Definition at line 55 of file uploader.h.

Constructor & Destructor Documentation

◆ PX4IO_Uploader()

PX4IO_Uploader::PX4IO_Uploader ( )

Definition at line 67 of file px4io_uploader.cpp.

◆ ~PX4IO_Uploader()

virtual PX4IO_Uploader::~PX4IO_Uploader ( )
virtualdefault

Member Function Documentation

◆ drain()

void PX4IO_Uploader::drain ( )
private

Definition at line 293 of file px4io_uploader.cpp.

References log(), OK, and recv_byte_with_timeout().

Referenced by sync().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ erase()

int PX4IO_Uploader::erase ( )
private

Definition at line 404 of file px4io_uploader.cpp.

References get_sync(), log(), PROTO_CHIP_ERASE, PROTO_EOC, and send().

Referenced by upload().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_info()

int PX4IO_Uploader::get_info ( int  param,
uint32_t &  val 
)
private

Definition at line 386 of file px4io_uploader.cpp.

References get_sync(), OK, PROTO_EOC, PROTO_GET_DEVICE, recv_bytes(), and send().

Referenced by upload(), and verify_rev3().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_sync()

int PX4IO_Uploader::get_sync ( unsigned  timeout = 40)
private

Definition at line 345 of file px4io_uploader.cpp.

References log(), OK, PROTO_INSYNC, PROTO_OK, and recv_byte_with_timeout().

Referenced by erase(), get_info(), program(), reboot(), sync(), verify_rev2(), and verify_rev3().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ log()

void PX4IO_Uploader::log ( const char *  fmt,
  ... 
)
private

Definition at line 680 of file px4io_uploader.cpp.

Referenced by drain(), erase(), get_sync(), program(), recv_byte_with_timeout(), send(), upload(), verify_rev2(), and verify_rev3().

Here is the caller graph for this function:

◆ program()

int PX4IO_Uploader::program ( size_t  fw_size)
private

Definition at line 432 of file px4io_uploader.cpp.

References _fw_fd, get_sync(), log(), OK, PROG_MULTI_MAX, PROTO_EOC, PROTO_PROG_MULTI, read_with_retry(), and send().

Referenced by upload().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reboot()

int PX4IO_Uploader::reboot ( )
private

Definition at line 662 of file px4io_uploader.cpp.

References get_sync(), OK, PROTO_EOC, PROTO_REBOOT, and send().

Referenced by upload().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ recv_byte_with_timeout()

int PX4IO_Uploader::recv_byte_with_timeout ( uint8_t *  c,
unsigned  timeout 
)
private

Definition at line 252 of file px4io_uploader.cpp.

References _io_fd, log(), OK, and read().

Referenced by drain(), get_sync(), recv_bytes(), and verify_rev2().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ recv_bytes()

int PX4IO_Uploader::recv_bytes ( uint8_t *  p,
unsigned  count 
)
private

Definition at line 277 of file px4io_uploader.cpp.

References OK, and recv_byte_with_timeout().

Referenced by get_info(), and verify_rev3().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send() [1/2]

int PX4IO_Uploader::send ( uint8_t  c)
private

Definition at line 315 of file px4io_uploader.cpp.

References _io_fd, log(), OK, and write().

Referenced by erase(), get_info(), program(), reboot(), send(), sync(), verify_rev2(), and verify_rev3().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send() [2/2]

int PX4IO_Uploader::send ( uint8_t *  p,
unsigned  count 
)
private

Definition at line 329 of file px4io_uploader.cpp.

References OK, and send().

Here is the call graph for this function:

◆ sync()

int PX4IO_Uploader::sync ( )
private

Definition at line 371 of file px4io_uploader.cpp.

References drain(), get_sync(), PROG_MULTI_MAX, PROTO_EOC, PROTO_GET_SYNC, and send().

Referenced by upload().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ upload()

int PX4IO_Uploader::upload ( const char *  filenames[])

Definition at line 75 of file px4io_uploader.cpp.

References _fw_fd, _io_fd, BL_REV, bl_rev, erase(), get_info(), INFO_BL_REV, log(), OK, program(), reboot(), sync(), verify_rev2(), and verify_rev3().

Referenced by px4io_main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ verify_rev2()

int PX4IO_Uploader::verify_rev2 ( size_t  fw_size)
private

Definition at line 492 of file px4io_uploader.cpp.

References _fw_fd, get_sync(), log(), OK, PROTO_CHIP_VERIFY, PROTO_EOC, PROTO_READ_MULTI, read_with_retry(), recv_byte_with_timeout(), and send().

Referenced by upload().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ verify_rev3()

int PX4IO_Uploader::verify_rev3 ( size_t  fw_size)
private

Definition at line 572 of file px4io_uploader.cpp.

References _fw_fd, get_info(), get_sync(), INFO_FLASH_SIZE, log(), OK, PROTO_EOC, PROTO_GET_CRC, read_with_retry(), recv_bytes(), and send().

Referenced by upload().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _fw_fd

int PX4IO_Uploader::_fw_fd
private

Definition at line 89 of file uploader.h.

Referenced by program(), upload(), verify_rev2(), and verify_rev3().

◆ _io_fd

int PX4IO_Uploader::_io_fd
private

Definition at line 88 of file uploader.h.

Referenced by recv_byte_with_timeout(), send(), and upload().

◆ bl_rev

uint32_t PX4IO_Uploader::bl_rev
private

bootloader revision

Definition at line 91 of file uploader.h.

Referenced by upload().


The documentation for this class was generated from the following files: