mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-22 01:12:31 +00:00
durandal-v1:Bootloader
Change PID to 0x4b:
Holybro obtained their own PID and VID but APM did not follow
the PX4 convention of makeing the board_id (0x8b) match the PID)
Incorporated the Upstream Bootloader state sequencing checking change.
Change the usb cout to send all chars in 1 write.
This commit is contained in:
committed by
Lorenz Meier
parent
5b235c34c2
commit
7ca8a8dbaa
@@ -29,7 +29,7 @@ CONFIG_BOARD_LOOPSPERMSEC=22114
|
|||||||
CONFIG_BOARD_RESET_ON_ASSERT=2
|
CONFIG_BOARD_RESET_ON_ASSERT=2
|
||||||
CONFIG_C99_BOOL8=y
|
CONFIG_C99_BOOL8=y
|
||||||
CONFIG_CDCACM=y
|
CONFIG_CDCACM=y
|
||||||
CONFIG_CDCACM_PRODUCTID=0x008b
|
CONFIG_CDCACM_PRODUCTID=0x004b
|
||||||
CONFIG_CDCACM_PRODUCTSTR="PX4 BL Holybro Durandal Vx"
|
CONFIG_CDCACM_PRODUCTSTR="PX4 BL Holybro Durandal Vx"
|
||||||
CONFIG_CDCACM_RXBUFSIZE=600
|
CONFIG_CDCACM_RXBUFSIZE=600
|
||||||
CONFIG_CDCACM_TXBUFSIZE=12000
|
CONFIG_CDCACM_TXBUFSIZE=12000
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ CONFIG_BOARD_RESET_ON_ASSERT=2
|
|||||||
CONFIG_BUILTIN=y
|
CONFIG_BUILTIN=y
|
||||||
CONFIG_C99_BOOL8=y
|
CONFIG_C99_BOOL8=y
|
||||||
CONFIG_CDCACM=y
|
CONFIG_CDCACM=y
|
||||||
CONFIG_CDCACM_PRODUCTID=0x008b
|
CONFIG_CDCACM_PRODUCTID=0x004b
|
||||||
CONFIG_CDCACM_PRODUCTSTR="PX4 DurandalV1"
|
CONFIG_CDCACM_PRODUCTSTR="PX4 DurandalV1"
|
||||||
CONFIG_CDCACM_RXBUFSIZE=600
|
CONFIG_CDCACM_RXBUFSIZE=600
|
||||||
CONFIG_CDCACM_TXBUFSIZE=12000
|
CONFIG_CDCACM_TXBUFSIZE=12000
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
* Aside from the header includes below, this file should have no board-specific logic.
|
* Aside from the header includes below, this file should have no board-specific logic.
|
||||||
*/
|
*/
|
||||||
#include "hw_config.h"
|
#include "hw_config.h"
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
@@ -141,7 +142,7 @@
|
|||||||
#define STATE_ALLOWS_REBOOT (STATE_PROTO_GET_SYNC)
|
#define STATE_ALLOWS_REBOOT (STATE_PROTO_GET_SYNC)
|
||||||
# define SET_BL_STATE(s)
|
# define SET_BL_STATE(s)
|
||||||
#else
|
#else
|
||||||
#define STATE_ALLOWS_ERASE (STATE_PROTO_GET_SYNC|STATE_PROTO_GET_DEVICE|STATE_PROTO_GET_CHIP)
|
#define STATE_ALLOWS_ERASE (STATE_PROTO_GET_SYNC|STATE_PROTO_GET_DEVICE)
|
||||||
#define STATE_ALLOWS_REBOOT (STATE_ALLOWS_ERASE|STATE_PROTO_PROG_MULTI|STATE_PROTO_GET_CRC)
|
#define STATE_ALLOWS_REBOOT (STATE_ALLOWS_ERASE|STATE_PROTO_PROG_MULTI|STATE_PROTO_GET_CRC)
|
||||||
# define SET_BL_STATE(s) bl_state |= (s)
|
# define SET_BL_STATE(s) bl_state |= (s)
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -53,8 +53,11 @@ char *g_init = 0;
|
|||||||
#if defined(SERIAL_TRACE)
|
#if defined(SERIAL_TRACE)
|
||||||
int in = 0;
|
int in = 0;
|
||||||
int out = 0;
|
int out = 0;
|
||||||
char in_trace[254];
|
// must be powere of 2 length
|
||||||
char out_trace[254];
|
#define TRACE_SIZE 256
|
||||||
|
#define TRACE_WRAP(f) (f) &=(TRACE_SIZE-1)
|
||||||
|
char in_trace[TRACE_SIZE];
|
||||||
|
char out_trace[TRACE_SIZE];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void usb_cinit(void *config)
|
void usb_cinit(void *config)
|
||||||
@@ -72,6 +75,7 @@ void usb_cinit(void *config)
|
|||||||
g_device = pt;
|
g_device = pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_usb_df = -1;
|
||||||
int fd = open(g_device, O_RDWR | O_NONBLOCK);
|
int fd = open(g_device, O_RDWR | O_NONBLOCK);
|
||||||
|
|
||||||
if (fd >= 0) {
|
if (fd >= 0) {
|
||||||
@@ -105,9 +109,8 @@ int usb_cin(void)
|
|||||||
if (read(g_usb_df, &b, 1) == 1) {
|
if (read(g_usb_df, &b, 1) == 1) {
|
||||||
c = b;
|
c = b;
|
||||||
#if defined(SERIAL_TRACE)
|
#if defined(SERIAL_TRACE)
|
||||||
in_trace[in] = b;
|
in_trace[in++] = b;
|
||||||
in++;
|
TRACE_WRAP(in);
|
||||||
in &= 255;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,24 +118,18 @@ int usb_cin(void)
|
|||||||
}
|
}
|
||||||
void usb_cout(uint8_t *buf, unsigned len)
|
void usb_cout(uint8_t *buf, unsigned len)
|
||||||
{
|
{
|
||||||
uint32_t timeout = 1000;
|
write(g_usb_df, buf, len);
|
||||||
|
#if defined(SERIAL_TRACE)
|
||||||
|
|
||||||
|
if (len > TRACE_SIZE) {
|
||||||
|
len = TRACE_SIZE;
|
||||||
|
out = 0;
|
||||||
|
}
|
||||||
|
|
||||||
for (unsigned i = 0; i < len; i++) {
|
for (unsigned i = 0; i < len; i++) {
|
||||||
while (timeout) {
|
out_trace[out++] = buf[i];
|
||||||
if (write(g_usb_df, &buf[i], 1) == 1) {
|
TRACE_WRAP(out);
|
||||||
#if defined(SERIAL_TRACE)
|
}
|
||||||
out_trace[out] = buf[i];
|
|
||||||
out++;
|
|
||||||
out &= 255;
|
|
||||||
#endif
|
|
||||||
timeout = 1000;
|
|
||||||
break;
|
|
||||||
|
|
||||||
} else {
|
#endif
|
||||||
if (timeout-- == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user