PX4 Firmware
PX4 Autopilot Software http://px4.io
uploader.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright (c) 2012-2015 PX4 Development Team. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in
13  * the documentation and/or other materials provided with the
14  * distribution.
15  * 3. Neither the name PX4 nor the names of its contributors may be
16  * used to endorse or promote products derived from this software
17  * without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
26  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  *
32  ****************************************************************************/
33 
34 /**
35  * @file uploader.h
36  * Firmware uploader definitions for PX4IO.
37  */
38 
39 #ifndef _PX4IO_UPLOADER_H
40 #define _PX4IO_UPLOADER_H value
41 
42 #include <stdint.h>
43 #include <stdbool.h>
44 
45 
47 {
48 public:
50  virtual ~PX4IO_Uploader() = default;
51 
52  int upload(const char *filenames[]);
53 
54 private:
55  enum {
56 
57  PROTO_NOP = 0x00,
58  PROTO_OK = 0x10,
59  PROTO_FAILED = 0x11,
60  PROTO_INSYNC = 0x12,
61  PROTO_INVALID = 0x13,
63  PROTO_EOC = 0x20,
70  PROTO_GET_CRC = 0x29,
71  PROTO_GET_OTP = 0x2a,
72  PROTO_GET_SN = 0x2b,
76  PROTO_REBOOT = 0x30,
77 
78  INFO_BL_REV = 1, /**< bootloader protocol revision */
79  BL_REV = 5, /**< supported bootloader protocol */
80  INFO_BOARD_ID = 2, /**< board type */
81  INFO_BOARD_REV = 3, /**< board revision */
82  INFO_FLASH_SIZE = 4, /**< max firmware size in bytes */
83 
84  PROG_MULTI_MAX = 248, /**< protocol max is 255, must be multiple of 4 */
85 
86  };
87 
88  int _io_fd;
89  int _fw_fd;
90 
91  uint32_t bl_rev; /**< bootloader revision */
92 
93  void log(const char *fmt, ...);
94 
95  int recv_byte_with_timeout(uint8_t *c, unsigned timeout);
96  int recv_bytes(uint8_t *p, unsigned count);
97  void drain();
98  int send(uint8_t c);
99  int send(uint8_t *p, unsigned count);
100  int get_sync(unsigned timeout = 40);
101  int sync();
102  int get_info(int param, uint32_t &val);
103  int erase();
104  int program(size_t fw_size);
105  int verify_rev2(size_t fw_size);
106  int verify_rev3(size_t fw_size);
107  int reboot();
108 };
109 
110 #endif
int get_info(int param, uint32_t &val)
int verify_rev2(size_t fw_size)
int verify_rev3(size_t fw_size)
int get_sync(unsigned timeout=40)
supported bootloader protocol
Definition: uploader.h:79
bootloader protocol revision
Definition: uploader.h:78
uint32_t bl_rev
bootloader revision
Definition: uploader.h:91
int program(size_t fw_size)
int recv_byte_with_timeout(uint8_t *c, unsigned timeout)
max firmware size in bytes
Definition: uploader.h:82
protocol max is 255, must be multiple of 4
Definition: uploader.h:84
int recv_bytes(uint8_t *p, unsigned count)
int send(uint8_t c)
int upload(const char *filenames[])
virtual ~PX4IO_Uploader()=default
void log(const char *fmt,...)