Skip to content

Commit

Permalink
Merge branch 'Copter-4.5' into Copter-4.5-lida2003
Browse files Browse the repository at this point in the history
  • Loading branch information
lida2003 committed Apr 10, 2024
2 parents 220478c + 913ec4b commit b440735
Show file tree
Hide file tree
Showing 12 changed files with 138 additions and 12 deletions.
39 changes: 39 additions & 0 deletions AntennaTracker/ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,43 @@
Antenna Tracker Release Notes:

------------------------------------------------------------------
Release 4.5.1 8th April 2024

This release fixes a critical bug in the CRSF R/C protocol parser that
can lead to a handfault and a vehicle crashing. A similar fix was
applied to the GHST protocol, although we believe that GHST could not
be affected by the bug, so this was just a precaution.

There are no other changes in this release.

------------------------------------------------------------------
Release 4.5.0-beta4 22nd March 2024

Changes from 4.5.0-beta3

1) system changes

- fixed a cache corruption issue with microSD card data on H7 based boards
- rename parameter NET_ENABLED to NET_ENABLE
- fixed FDCAN labels for adding new H7 boards
- avoid logging dma.txt to save CPU
- fixed roll/pitch in viewpro driver
- added band X in VideoTX
- fixed quaternion attitude reporting for Microstrain external AHRS
- add RPLidarC1 proximity support

2) new boards
- added MicoAir405v2
- add Orqa F405 Pro

------------------------------------------------------------------
Release 4.5.0 2nd April 2024

No changes from 4.5.0-beta4
------------------------------------------------------------------
Release 4.5.0 2nd April 2024

No changes from 4.5.0-beta4
------------------------------------------------------------------
Release 4.5.0 2nd April 2024

Expand Down
6 changes: 3 additions & 3 deletions AntennaTracker/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

#include "ap_version.h"

#define THISFIRMWARE "AntennaTracker V4.5.0"
#define THISFIRMWARE "AntennaTracker V4.5.1"

// the following line is parsed by the autotest scripts
#define FIRMWARE_VERSION 4,5,0,FIRMWARE_VERSION_TYPE_OFFICIAL
#define FIRMWARE_VERSION 4,5,1,FIRMWARE_VERSION_TYPE_OFFICIAL

#define FW_MAJOR 4
#define FW_MINOR 5
#define FW_PATCH 0
#define FW_PATCH 1
#define FW_TYPE FIRMWARE_VERSION_TYPE_OFFICIAL

#include <AP_Common/AP_FWVersionDefine.h>
11 changes: 11 additions & 0 deletions ArduCopter/ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
ArduPilot Copter Release Notes:
-------------------------------

Release 4.5.1 8th April 2024

This release fixes a critical bug in the CRSF R/C protocol parser that
can lead to a handfault and a vehicle crashing. A similar fix was
applied to the GHST protocol, although we believe that GHST could not
be affected by the bug, so this was just a precaution.

There are no other changes in this release.

------------------------------------------------------------------
Release 4.5.0 2nd April 2024

No changes from 4.5.0-beta4
Expand Down
6 changes: 3 additions & 3 deletions ArduCopter/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

#include "ap_version.h"

#define THISFIRMWARE "ArduCopter V4.5.0"
#define THISFIRMWARE "ArduCopter V4.5.1"

// the following line is parsed by the autotest scripts
#define FIRMWARE_VERSION 4,5,0,FIRMWARE_VERSION_TYPE_OFFICIAL
#define FIRMWARE_VERSION 4,5,1,FIRMWARE_VERSION_TYPE_OFFICIAL

#define FW_MAJOR 4
#define FW_MINOR 5
#define FW_PATCH 0
#define FW_PATCH 1
#define FW_TYPE FIRMWARE_VERSION_TYPE_OFFICIAL

#include <AP_Common/AP_FWVersionDefine.h>
10 changes: 10 additions & 0 deletions ArduPlane/ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
Release 4.5.1 8th April 2024
----------------------------

This release fixes a critical bug in the CRSF R/C protocol parser that
can lead to a handfault and a vehicle crashing. A similar fix was
applied to the GHST protocol, although we believe that GHST could not
be affected by the bug, so this was just a precaution.

There are no other changes in this release.

Release 4.5.0 2nd April 2024
----------------------------

Expand Down
6 changes: 3 additions & 3 deletions ArduPlane/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

#include "ap_version.h"

#define THISFIRMWARE "ArduPlane V4.5.0"
#define THISFIRMWARE "ArduPlane V4.5.1"

// the following line is parsed by the autotest scripts
#define FIRMWARE_VERSION 4,5,0,FIRMWARE_VERSION_TYPE_OFFICIAL
#define FIRMWARE_VERSION 4,5,1,FIRMWARE_VERSION_TYPE_OFFICIAL

#define FW_MAJOR 4
#define FW_MINOR 5
#define FW_PATCH 0
#define FW_PATCH 1
#define FW_TYPE FIRMWARE_VERSION_TYPE_OFFICIAL

#include <AP_Common/AP_FWVersionDefine.h>
10 changes: 10 additions & 0 deletions Rover/release-notes.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
Rover Release Notes:
--------------------
Release 4.5.1 8th April 2024

This release fixes a critical bug in the CRSF R/C protocol parser that
can lead to a handfault and a vehicle crashing. A similar fix was
applied to the GHST protocol, although we believe that GHST could not
be affected by the bug, so this was just a precaution.

There are no other changes in this release.

------------------------------------------------------------------
Release 4.5.0 2nd April 2024

No changes from 4.5.0-beta4
Expand Down
6 changes: 3 additions & 3 deletions Rover/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

#include "ap_version.h"

#define THISFIRMWARE "ArduRover V4.5.0"
#define THISFIRMWARE "ArduRover V4.5.1"

// the following line is parsed by the autotest scripts
#define FIRMWARE_VERSION 4,5,0,FIRMWARE_VERSION_TYPE_OFFICIAL
#define FIRMWARE_VERSION 4,5,1,FIRMWARE_VERSION_TYPE_OFFICIAL

#define FW_MAJOR 4
#define FW_MINOR 5
#define FW_PATCH 0
#define FW_PATCH 1
#define FW_TYPE FIRMWARE_VERSION_TYPE_OFFICIAL

#include <AP_Common/AP_FWVersionDefine.h>
5 changes: 5 additions & 0 deletions libraries/AP_RCProtocol/AP_RCProtocol_CRSF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@ bool AP_RCProtocol_CRSF::check_frame(uint32_t timestamp_us)
return false;
}

if (_frame.length < CRSF_FRAME_LENGTH_MIN) {
// invalid short frame
return false;
}

// decode whatever we got and expect
if (_frame_ofs >= _frame.length + CRSF_HEADER_LEN) {
const uint8_t crc = crc8_dvb_s2_update(0, &_frame_bytes[CRSF_HEADER_LEN], _frame.length - 1);
Expand Down
1 change: 1 addition & 0 deletions libraries/AP_RCProtocol/AP_RCProtocol_CRSF.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#define CRSF_FRAMELEN_MAX 64U // maximum possible framelength
#define CRSF_HEADER_LEN 2U // header length
#define CRSF_FRAME_PAYLOAD_MAX (CRSF_FRAMELEN_MAX - CRSF_HEADER_LEN) // maximum size of the frame length field in a packet
#define CRSF_FRAME_LENGTH_MIN 2 // min value for _frame.length
#define CRSF_BAUDRATE 416666U
#define ELRS_BAUDRATE 420000U
#define CRSF_TX_TIMEOUT 500000U // the period after which the transmitter is considered disconnected (matches copters failsafe)
Expand Down
6 changes: 6 additions & 0 deletions libraries/AP_RCProtocol/AP_RCProtocol_GHST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ void AP_RCProtocol_GHST::_process_byte(uint32_t timestamp_us, uint8_t byte)
return;
}

if (_frame.length < 2) {
// invalid length, we subtract 2 below
_frame_ofs = 0;
return;
}

// decode whatever we got and expect
if (_frame_ofs == _frame.length + GHST_HEADER_LEN) {
log_data(AP_RCProtocol::GHST, timestamp_us, (const uint8_t*)&_frame, _frame_ofs - GHST_HEADER_LEN);
Expand Down
44 changes: 44 additions & 0 deletions libraries/AP_RCProtocol/examples/RCProtocolTest/RCProtocolTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
#include <AP_VideoTX/AP_VideoTX.h>
#include <stdio.h>

#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#endif

void setup();
void loop();

Expand Down Expand Up @@ -280,6 +286,39 @@ static bool test_protocol_bytesonly(const char *name, uint32_t baudrate,
return ret;
}

/*
test with random data
*/
static void test_random(void)
{
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
const uint32_t baudrates[] = { 115200, 100000, 416666, 420000 };
const uint32_t test_bytes = 1000000;
int fd = open("/dev/urandom", O_RDONLY);
if (fd == -1) {
printf("Can't open /dev/urandom\n");
return;
}
uint8_t *buf = (uint8_t *)malloc(test_bytes);
for (const auto b : baudrates) {
printf("Testing random with baud %u\n", unsigned(b));
rcprot = new AP_RCProtocol();
rcprot->init();
if (::read(fd, buf, test_bytes) != test_bytes) {
printf("Failed to read from /dev/urandom\n");
break;
}
for (uint32_t i=0; i<test_bytes; i++) {
rcprot->process_byte(buf[i], b);
}
delete rcprot;
rcprot = nullptr;
}
free(buf);
close(fd);
#endif
}

//Main loop where the action takes place
#pragma GCC diagnostic error "-Wframe-larger-than=2000"
void loop()
Expand Down Expand Up @@ -479,6 +518,11 @@ void loop()
test_protocol("FPORT2_16CH", 115200, fport2_16ch_bytes, sizeof(fport2_16ch_bytes), fport2_16ch_output, ARRAY_SIZE(fport2_16ch_output), 3, 0, true);
test_protocol("FPORT2_24CH", 115200, fport2_24ch_bytes, sizeof(fport2_24ch_bytes), fport2_24ch_output, ARRAY_SIZE(fport2_24ch_output), 3, 0, true);

/*
now test with random data to ensure we don't have any logic bugs that can cause a crash of the parser
*/
test_random();

if (test_count++ == 10) {
if (test_failures == 0) {
printf("Test PASSED\n");
Expand Down

0 comments on commit b440735

Please sign in to comment.