From ada72d6113588b54989a1a92c4f3c6ab4671a1f2 Mon Sep 17 00:00:00 2001 From: Ben Lye Date: Tue, 1 Oct 2019 07:43:08 +0100 Subject: [PATCH 1/5] Update Travis Configuration (#273) Various improvements to the Travis CI script: * Add channel order builds to releases - now building AETR, TAER, and RETA * Add PPM builds for each channel order with no inversion and PPM banks set to 5 * Log config diff for each build (diff output folded to keep the log readable) * Colorify the "Building" lines to make parsing the log easier * Export .bin files instead of .hex files for the AVR modules * Add Multi.txt to the release files --- .travis.yml | 109 +++++++++++++++++++++++++++++++------- buildroot/bin/opt_replace | 5 ++ 2 files changed, 96 insertions(+), 18 deletions(-) create mode 100644 buildroot/bin/opt_replace diff --git a/.travis.yml b/.travis.yml index 4a5a23d..43492c3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -42,9 +42,9 @@ before_install: arduino --install-boards multi4in1:avr; fi # - - buildMulti() { exitcode=0; BUILDCMD="arduino --verify --board $BOARD Multiprotocol/Multiprotocol.ino --pref build.path=./build/"; echo $BUILDCMD; $BUILDCMD; if [ $? -ne 0 ]; then exitcode=1; fi; echo; return $exitcode; } + - buildMulti() { start_fold config_diff; travis_time_start; git diff Multiprotocol/_Config.h; end_fold config_diff; exitcode=0; BUILDCMD="arduino --verify --board $BOARD Multiprotocol/Multiprotocol.ino --pref build.path=./build/"; echo $BUILDCMD; $BUILDCMD; if [ $? -ne 0 ]; then exitcode=1; fi; echo; return $exitcode; } - buildProtocol() { exitcode=0; opt_disable $ALL_PROTOCOLS; opt_enable $1; buildMulti; if [ $? -ne 0 ]; then exitcode=1; fi; return $exitcode; } - - buildEachProtocol() { exitcodesum=0; for PROTOCOL in $ALL_PROTOCOLS ; do echo Building $PROTOCOL; buildProtocol $PROTOCOL; if [ $? -ne 0 ]; then exitcodesum=$((exitcodesum + 1)); fi; done; return $exitcodesum; } + - buildEachProtocol() { exitcodesum=0; for PROTOCOL in $ALL_PROTOCOLS ; do printf "\e[33;1mBuilding $PROTOCOL\e[0m"; buildProtocol $PROTOCOL; if [ $? -ne 0 ]; then exitcodesum=$((exitcodesum + 1)); fi; done; return $exitcodesum; } # # Arduino IDE adds a lot of noise caused by network traffic; firewall it - sudo iptables -P INPUT DROP @@ -86,6 +86,12 @@ before_script: opt_enable FRSKYX_CC2500_INO AFHDS2A_A7105_INO MJXQ_NRF24L01_INO DSM_CYRF6936_INO; fi # + - export -f travis_fold + - export -f travis_nanoseconds + - export -f travis_time_start + - export -f travis_time_finish + - start_fold() { echo -e "travis_fold:start:$1"; } + - end_fold() { echo -e "\ntravis_fold:end:$1\r"; } script: # Build with all protocols enabled for STM32; a subset of protocols for Atmega - buildMulti @@ -113,91 +119,158 @@ before_deploy: - cp ./_Config.h.bak Multiprotocol/_Config.h # Build the release files for OrangeRX - if [[ "$BOARD" == "multi4in1:avr:multixmega32d4" ]]; then + printf "\n\e[33;1mBuilding multi-orangerx-aetr-green-inv-$TRAVIS_TAG.bin\e[0m"; opt_enable $ALL_PROTOCOLS; opt_disable ORANGE_TX_BLUE; buildMulti; - mv build/Multiprotocol.ino.hex ./binaries/multi-orangerx-green-inv-$TRAVIS_TAG.hex; + mv build/Multiprotocol.ino.bin ./binaries/multi-orangerx-aetr-green-inv-$TRAVIS_TAG.bin; + printf "\n\e[33;1mBuilding multi-orangerx-aetr-blue-inv-$TRAVIS_TAG.bin\e[0m"; opt_enable ORANGE_TX_BLUE; buildMulti; - mv build/Multiprotocol.ino.hex ./binaries/multi-orangerx-blue-inv-$TRAVIS_TAG.hex; + mv build/Multiprotocol.ino.bin ./binaries/multi-orangerx-aetr-blue-inv-$TRAVIS_TAG.bin; + cp Multiprotocol/Multi.txt ./binaries/Multi.txt; fi # Build the release files for AVR without bootloader - if [[ "$BOARD" == "multi4in1:avr:multiatmega328p:bootloader=none" ]]; then + printf "\n\e[33;1mBuilding multi-avr-usbasp-aetr-A7105-inv-$TRAVIS_TAG.bin\e[0m"; opt_disable CHECK_FOR_BOOTLOADER; opt_disable $ALL_PROTOCOLS; opt_enable $A7105_PROTOCOLS; buildMulti; - mv build/Multiprotocol.ino.hex ./binaries/multi-avr-usbasp-A7105-inv-$TRAVIS_TAG.hex; + mv build/Multiprotocol.ino.bin ./binaries/multi-avr-usbasp-aetr-A7105-inv-$TRAVIS_TAG.bin; + printf "\n\e[33;1mBuilding multi-avr-usbasp-aetr-CC2500-inv-$TRAVIS_TAG.bin\e[0m"; opt_disable $ALL_PROTOCOLS; opt_enable $CC2500_PROTOCOLS; buildMulti; - mv build/Multiprotocol.ino.hex ./binaries/multi-avr-usbasp-CC2500-inv-$TRAVIS_TAG.hex; + mv build/Multiprotocol.ino.bin ./binaries/multi-avr-usbasp-aetr-CC2500-inv-$TRAVIS_TAG.bin; + printf "\n\e[33;1mBuilding multi-avr-usbasp-aetr-CYRF6936-inv-$TRAVIS_TAG.bin\e[0m"; opt_disable $ALL_PROTOCOLS; opt_enable $CYRF6936_PROTOCOLS; buildMulti; - mv build/Multiprotocol.ino.hex ./binaries/multi-avr-usbasp-CYRF6936-inv-$TRAVIS_TAG.hex; + mv build/Multiprotocol.ino.bin ./binaries/multi-avr-usbasp-aetr-CYRF6936-inv-$TRAVIS_TAG.bin; fi # Build the release files for AVR with bootloader - if [[ "$BOARD" == "multi4in1:avr:multiatmega328p:bootloader=optiboot" ]]; then + printf "\n\e[33;1mBuilding multi-avr-txflash-aetr-A7105-inv-$TRAVIS_TAG.bin\e[0m"; opt_enable CHECK_FOR_BOOTLOADER; opt_disable $ALL_PROTOCOLS; opt_enable $A7105_PROTOCOLS; buildMulti; - mv build/Multiprotocol.ino.hex ./binaries/multi-avr-txflash-A7105-inv-$TRAVIS_TAG.hex; + mv build/Multiprotocol.ino.bin ./binaries/multi-avr-txflash-aetr-A7105-inv-$TRAVIS_TAG.bin; + printf "\n\e[33;1mBuilding multi-avr-txflash-aetr-CC2500-inv-$TRAVIS_TAG.bin\e[0m"; opt_disable $ALL_PROTOCOLS; opt_enable $CC2500_PROTOCOLS; buildMulti; - mv build/Multiprotocol.ino.hex ./binaries/multi-avr-txflash-CC2500-inv-$TRAVIS_TAG.hex; + mv build/Multiprotocol.ino.bin ./binaries/multi-avr-txflash-aetr-CC2500-inv-$TRAVIS_TAG.bin; + printf "\n\e[33;1mBuilding multi-avr-txflash-aetr-CYRF6936-inv-$TRAVIS_TAG.bin\e[0m"; opt_disable $ALL_PROTOCOLS; opt_enable $CYRF6936_PROTOCOLS; buildMulti; - mv build/Multiprotocol.ino.hex ./binaries/multi-avr-txflash-CYRF6936-inv-$TRAVIS_TAG.hex; + mv build/Multiprotocol.ino.bin ./binaries/multi-avr-txflash-aetr-CYRF6936-inv-$TRAVIS_TAG.bin; fi # Build the release files for STM32 without debug - if [[ "$BOARD" == "multi4in1:STM32F1:multistm32f103c:debug_option=none" ]]; then + printf "\n\e[33;1mBuilding multi-stm-erskytx-aetr-inv-$TRAVIS_TAG.bin\e[0m"; opt_enable CHECK_FOR_BOOTLOADER; opt_enable $ALL_PROTOCOLS; opt_enable MULTI_STATUS; opt_disable MULTI_TELEMETRY; buildMulti; - mv build/Multiprotocol.ino.bin ./binaries/multi-stm-erskytx-inv-$TRAVIS_TAG.bin; + mv build/Multiprotocol.ino.bin ./binaries/multi-stm-erskytx-aetr-inv-$TRAVIS_TAG.bin; + printf "\n\e[33;1mBuilding multi-stm-erskytx-taer-inv-$TRAVIS_TAG.bin\e[0m"; + opt_replace AETR TAER; + buildMulti; + mv build/Multiprotocol.ino.bin ./binaries/multi-stm-erskytx-taer-inv-$TRAVIS_TAG.bin; + printf "\n\e[33;1mBuilding multi-stm-erskytx-reta-inv-$TRAVIS_TAG.bin\e[0m"; + opt_replace TAER RETA; + buildMulti; + mv build/Multiprotocol.ino.bin ./binaries/multi-stm-erskytx-reta-inv-$TRAVIS_TAG.bin; + printf "\n\e[33;1mBuilding multi-stm-erskytx-aetr-noinv-$TRAVIS_TAG.bin\e[0m"; + opt_replace RETA AETR; opt_disable INVERT_TELEMETRY; buildMulti; - mv build/Multiprotocol.ino.bin ./binaries/multi-stm-erskytx-noinv-$TRAVIS_TAG.bin; + mv build/Multiprotocol.ino.bin ./binaries/multi-stm-erskytx-aetr-noinv-$TRAVIS_TAG.bin; + printf "\n\e[33;1mBuilding multi-stm-erskytx-taer-noinv-$TRAVIS_TAG.bin\e[0m"; + opt_replace AETR TAER; + buildMulti; + mv build/Multiprotocol.ino.bin ./binaries/multi-stm-erskytx-taer-noinv-$TRAVIS_TAG.bin; + printf "\n\e[33;1mBuilding multi-stm-erskytx-reta-noinv-$TRAVIS_TAG.bin\e[0m"; + opt_replace TAER RETA; + buildMulti; + mv build/Multiprotocol.ino.bin ./binaries/multi-stm-erskytx-reta-noinv-$TRAVIS_TAG.bin; + printf "\n\e[33;1mBuilding multi-stm-opentx-aetr-inv-$TRAVIS_TAG.bin\e[0m"; + opt_replace RETA AETR; opt_disable MULTI_STATUS; opt_enable MULTI_TELEMETRY; opt_enable INVERT_TELEMETRY; buildMulti; - mv build/Multiprotocol.ino.bin ./binaries/multi-stm-opentx-inv-$TRAVIS_TAG.bin; + mv build/Multiprotocol.ino.bin ./binaries/multi-stm-opentx-aetr-inv-$TRAVIS_TAG.bin; + printf "\n\e[33;1mBuilding multi-stm-opentx-taer-inv-$TRAVIS_TAG.bin\e[0m"; + opt_replace AETR TAER; + buildMulti; + mv build/Multiprotocol.ino.bin ./binaries/multi-stm-opentx-taer-inv-$TRAVIS_TAG.bin; + printf "\n\e[33;1mBuilding multi-stm-opentx-reta-inv-$TRAVIS_TAG.bin\e[0m"; + opt_replace TAER RETA; + buildMulti; + mv build/Multiprotocol.ino.bin ./binaries/multi-stm-opentx-reta-inv-$TRAVIS_TAG.bin; + printf "\n\e[33;1mBuilding multi-stm-opentx-aetr-noinv-$TRAVIS_TAG.bin\e[0m"; + opt_replace RETA AETR; opt_disable INVERT_TELEMETRY; buildMulti; - mv build/Multiprotocol.ino.bin ./binaries/multi-stm-opentx-noinv-$TRAVIS_TAG.bin; + mv build/Multiprotocol.ino.bin ./binaries/multi-stm-opentx-aetr-noinv-$TRAVIS_TAG.bin; + printf "\n\e[33;1mBuilding multi-stm-opentx-taer-noinv-$TRAVIS_TAG.bin\e[0m"; + opt_replace AETR TAER; + buildMulti; + mv build/Multiprotocol.ino.bin ./binaries/multi-stm-opentx-taer-noinv-$TRAVIS_TAG.bin; + printf "\n\e[33;1mBuilding multi-stm-opentx-reta-noinv-$TRAVIS_TAG.bin\e[0m"; + opt_replace TAER RETA; + buildMulti; + mv build/Multiprotocol.ino.bin ./binaries/multi-stm-opentx-reta-noinv-$TRAVIS_TAG.bin; + printf "\n\e[33;1mBuilding multi-stm-ppm-aetr-noinv-$TRAVIS_TAG.bin\e[0m"; + opt_replace RETA AETR; + opt_disable MULTI_STATUS; + opt_disable MULTI_TELEMETRY; + opt_set NBR_BANKS 5; + buildMulti; + mv build/Multiprotocol.ino.bin ./binaries/multi-stm-ppm-aetr-noinv-$TRAVIS_TAG.bin; + printf "\n\e[33;1mBuilding multi-stm-ppm-taer-noinv-$TRAVIS_TAG.bin\e[0m"; + opt_replace AETR TAER; + buildMulti; + mv build/Multiprotocol.ino.bin ./binaries/multi-stm-ppm-taer-noinv-$TRAVIS_TAG.bin; + printf "\n\e[33;1mBuilding multi-stm-ppm-reta-noinv-$TRAVIS_TAG.bin\e[0m"; + opt_replace TAER RETA; + buildMulti; + mv build/Multiprotocol.ino.bin ./binaries/multi-stm-ppm-reta-noinv-$TRAVIS_TAG.bin; fi # Build the release files for STM32 with Native USB debugging - if [[ "$BOARD" == "multi4in1:STM32F1:multistm32f103c:debug_option=native" ]]; then + printf "\n\e[33;1mBuilding multi-stm-erskytx-aetr-inv-usbdebug-$TRAVIS_TAG.bin\e[0m"; opt_enable CHECK_FOR_BOOTLOADER; opt_enable $ALL_PROTOCOLS; opt_enable MULTI_STATUS; opt_disable MULTI_TELEMETRY; buildMulti; - mv build/Multiprotocol.ino.bin ./binaries/multi-stm-erskytx-inv-usbdebug-$TRAVIS_TAG.bin; + mv build/Multiprotocol.ino.bin ./binaries/multi-stm-erskytx-aetr-inv-usbdebug-$TRAVIS_TAG.bin; + printf "\n\e[33;1mBuilding multi-stm-opentx-aetr-inv-usbdebug-$TRAVIS_TAG.bin\e[0m"; opt_disable MULTI_STATUS; opt_enable MULTI_TELEMETRY; buildMulti; - mv build/Multiprotocol.ino.bin ./binaries/multi-stm-opentx-inv-usbdebug-$TRAVIS_TAG.bin; + mv build/Multiprotocol.ino.bin ./binaries/multi-stm-opentx-aetr-inv-usbdebug-$TRAVIS_TAG.bin; fi # Build the release files for STM32 with FTDI USB debugging - if [[ "$BOARD" == "multi4in1:STM32F1:multistm32f103c:debug_option=ftdi" ]]; then + printf "\n\e[33;1mBuilding multi-stm-erskytx-aetr-inv-ftdidebug-$TRAVIS_TAG.bin\e[0m"; opt_enable CHECK_FOR_BOOTLOADER; opt_enable $ALL_PROTOCOLS; opt_enable MULTI_STATUS; opt_disable MULTI_TELEMETRY; buildMulti; - mv build/Multiprotocol.ino.bin ./binaries/multi-stm-erskytx-inv-ftdidebug-$TRAVIS_TAG.bin; + mv build/Multiprotocol.ino.bin ./binaries/multi-stm-erskytx-aetr-inv-ftdidebug-$TRAVIS_TAG.bin; + printf "\n\e[33;1mBuilding multi-stm-opentx-aetr-inv-ftdidebug-$TRAVIS_TAG.bin\e[0m"; opt_disable MULTI_STATUS; opt_enable MULTI_TELEMETRY; buildMulti; - mv build/Multiprotocol.ino.bin ./binaries/multi-stm-opentx-inv-ftdidebug-$TRAVIS_TAG.bin; + mv build/Multiprotocol.ino.bin ./binaries/multi-stm-opentx-aetr-inv-ftdidebug-$TRAVIS_TAG.bin; fi deploy: provider: releases diff --git a/buildroot/bin/opt_replace b/buildroot/bin/opt_replace new file mode 100644 index 0000000..b29075e --- /dev/null +++ b/buildroot/bin/opt_replace @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +SED=$(which gsed || which sed) + +eval "${SED} -i 's/#define \b${1}\b$/#define ${2}/g' Multiprotocol/_Config.h" From e8b5f071fed44289677b13f2c56745f85d5a959e Mon Sep 17 00:00:00 2001 From: Ben Lye Date: Tue, 1 Oct 2019 10:05:37 +0100 Subject: [PATCH 2/5] Move signature conditionals to separate file, add channel order (#274) --- Multiprotocol/Binary_Signature.ino | 181 +++++++++++++++++++++++++++++ Multiprotocol/Multiprotocol.ino | 17 --- 2 files changed, 181 insertions(+), 17 deletions(-) create mode 100644 Multiprotocol/Binary_Signature.ino diff --git a/Multiprotocol/Binary_Signature.ino b/Multiprotocol/Binary_Signature.ino new file mode 100644 index 0000000..af2f343 --- /dev/null +++ b/Multiprotocol/Binary_Signature.ino @@ -0,0 +1,181 @@ +/* + This project is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Multiprotocol is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Multiprotocol. If not, see . + */ + +/************************/ +/** Firmware Signature **/ +/************************/ + +/* +The firmware signature is appended to the compiled binary image in order to provide information +about the options used to compile the firmware file. This information is then used by Multi-module +flashing tools to verify that the image is correct / valid. + +In order for the build process to determine the options used to build the firmware this file conditionally +declares 'flag' variables for the options we are interested in. + +When the pre-compiler parses the source code these variables are either present or not in the parsed cpp file, +typically '$build_dir$/preproc/ctags_target_for_gcc_minus_e.cpp'. + +Once the .bin file is compiled an additional command-line tool scans the parsed cpp file, detects the flags, +assembles the signature, and finally appends to the end of the binary file. + +The signature is 24 bytes long: +multi-x[8-byte hex code]-[8-byte version number] + +For example: +multi-x1234abcd-01020199 + +The 8-byte hex code is a 32-bit bitmask value indicating the configuration options, currently: + +Bit(s) Option Comment +1-2 Module type Read as a two-bit value indicating a number from 0-3 which maps to a module type (AVR, STM32, OrangeRX) +3-7 Channel order Read as a five-bit value indicating a number from 0-23 which maps to as channel order (AETR, TAER, RETA, etc) +8 Bootloader support Indicates whether or not the firmware was built with support for the bootloader +9 CHECK_FOR_BOOTLOADER +10 INVERT_TELEMETRY +11 MULTI_STATUS +12 MULTI_TELEMETRY +13 DEBUG_SERIAL + +The 8-byte version number is the version number zero-padded to a fixed width of two-bytes per segment and no separator. +E.g. 1.2.3.45 becomes 01020345. + +Module types are mapped to the following decimal / binary values: + +Module Type Decimal Value Binary Valsue +AVR 0 00 +STM32 1 01 +OrangeRX 2 10 + +Channel orders are mapped to the following decimal / binary values: + +Channel Order Decimal Value Binary Value +AETR 0 00000 +AERT 1 00001 +ARET 2 00010 +ARTE 3 00011 +ATRE 4 00100 +ATER 5 00101 +EATR 6 00110 +EART 7 00111 +ERAT 8 01000 +ERTA 9 01001 +ETRA 10 01010 +ETAR 11 01011 +TEAR 12 01100 +TERA 13 01101 +TREA 14 01110 +TRAE 15 01111 +TARE 16 10000 +TAER 17 10001 +RETA 18 10010 +REAT 19 10011 +RAET 20 10100 +RATE 21 10101 +RTAE 22 10110 +RTEA 23 10111 + +*/ + +// Set the flags for detecting and writing the firmware signature +#if defined (CHECK_FOR_BOOTLOADER) + bool firmwareFlag_CHECK_FOR_BOOTLOADER = true; +#endif +#if defined (INVERT_TELEMETRY) + bool firmwareFlag_INVERT_TELEMETRY = true; +#endif +#if defined (MULTI_STATUS) + bool firmwareFlag_MULTI_STATUS = true; +#endif +#if defined (MULTI_TELEMETRY) + bool firmwareFlag_MULTI_TELEMETRY = true; +#endif +#if defined (DEBUG_SERIAL) + bool firmwareFlag_DEBUG_SERIAL = true; +#endif + +// Channel order flags +#if defined (AETR) + bool firmwareFlag_ChannelOrder_AETR = true; +#endif +#if defined (AERT) + bool firmwareFlag_ChannelOrder_AERT = true; +#endif +#if defined (ARET) + bool firmwareFlag_ChannelOrder_ARET = true; +#endif +#if defined (ARTE) + bool firmwareFlag_ChannelOrder_ARTE = true; +#endif +#if defined (ATRE) + bool firmwareFlag_ChannelOrder_ATRE = true; +#endif +#if defined (ATER) + bool firmwareFlag_ChannelOrder_ATER = true; +#endif +#if defined (EATR) + bool firmwareFlag_ChannelOrder_EATR = true; +#endif +#if defined (EART) + bool firmwareFlag_ChannelOrder_EART = true; +#endif +#if defined (ERAT) + bool firmwareFlag_ChannelOrder_ERAT = true; +#endif +#if defined (ERTA) + bool firmwareFlag_ChannelOrder_ERTA = true; +#endif +#if defined (ETRA) + bool firmwareFlag_ChannelOrder_ETRA = true; +#endif +#if defined (ETAR) + bool firmwareFlag_ChannelOrder_ETAR = true; +#endif +#if defined (TEAR) + bool firmwareFlag_ChannelOrder_TEAR = true; +#endif +#if defined (TERA) + bool firmwareFlag_ChannelOrder_TERA = true; +#endif +#if defined (TREA) + bool firmwareFlag_ChannelOrder_TREA = true; +#endif +#if defined (TRAE) + bool firmwareFlag_ChannelOrder_TRAE = true; +#endif +#if defined (TARE) + bool firmwareFlag_ChannelOrder_TARE = true; +#endif +#if defined (TAER) + bool firmwareFlag_ChannelOrder_TAER = true; +#endif +#if defined (RETA) + bool firmwareFlag_ChannelOrder_RETA = true; +#endif +#if defined (REAT) + bool firmwareFlag_ChannelOrder_REAT = true; +#endif +#if defined (RAET) + bool firmwareFlag_ChannelOrder_RAET = true; +#endif +#if defined (RATE) + bool firmwareFlag_ChannelOrder_RATE = true; +#endif +#if defined (RTAE) + bool firmwareFlag_ChannelOrder_RTAE = true; +#endif +#if defined (RTEA) + bool firmwareFlag_ChannelOrder_RTEA = true; +#endif \ No newline at end of file diff --git a/Multiprotocol/Multiprotocol.ino b/Multiprotocol/Multiprotocol.ino index 8315f79..433c824 100644 --- a/Multiprotocol/Multiprotocol.ino +++ b/Multiprotocol/Multiprotocol.ino @@ -2011,20 +2011,3 @@ static uint32_t random_id(uint16_t address, uint8_t create_new) } } #endif - -// Set the flags for detecting and writing the firmware signature -#if defined (CHECK_FOR_BOOTLOADER) - bool firmwareFlag_CHECK_FOR_BOOTLOADER = true; -#endif -#if defined (MULTI_STATUS) - bool firmwareFlag_MULTI_STATUS = true; -#endif -#if defined (MULTI_TELEMETRY) - bool firmwareFlag_MULTI_TELEMETRY = true; -#endif -#if defined (INVERT_TELEMETRY) - bool firmwareFlag_INVERT_TELEMETRY = true; -#endif -#if defined (DEBUG_SERIAL) - bool firmwareFlag_DEBUG_SERIAL = true; -#endif From f3d2ab61e4bb5f429a5f9d3a8bb4c2400be67c30 Mon Sep 17 00:00:00 2001 From: goebish Date: Tue, 1 Oct 2019 20:44:26 +0200 Subject: [PATCH 3/5] Protocol Flysky AFHDS2A receiver (#275) * Add skeleton for AFHDS2A receiver protocol * Bind & data Ok * Send channels to TX via telemetry * Add RSSI * Fix AVR compilation * Fix channel number --- Multiprotocol/A7105_SPI.ino | 5 +- Multiprotocol/AFHDS2A_Rx_a7105.ino | 207 +++++++++++++++++++++++++++++ Multiprotocol/Multi.txt | 1 + Multiprotocol/Multiprotocol.h | 4 +- Multiprotocol/Multiprotocol.ino | 7 + Multiprotocol/Telemetry.ino | 21 +-- Multiprotocol/Validate.h | 7 + Multiprotocol/_Config.h | 4 + 8 files changed, 245 insertions(+), 11 deletions(-) create mode 100644 Multiprotocol/AFHDS2A_Rx_a7105.ino diff --git a/Multiprotocol/A7105_SPI.ino b/Multiprotocol/A7105_SPI.ino index ae58415..51b1847 100644 --- a/Multiprotocol/A7105_SPI.ino +++ b/Multiprotocol/A7105_SPI.ino @@ -198,6 +198,7 @@ void A7105_AdjustLOBaseFreq(uint8_t cmd) #endif break; case PROTO_AFHDS2A: + case PROTO_AFHDS2A_RX: #ifdef FORCE_AFHDS2A_TUNING offset=(int16_t)FORCE_AFHDS2A_TUNING; #endif @@ -252,7 +253,7 @@ static void __attribute__((unused)) A7105_SetVCOBand(uint8_t vb1, uint8_t vb2) A7105_WriteReg(A7105_25_VCO_SBCAL_I, vb2 | 0x08); } -#ifdef AFHDS2A_A7105_INO +#if defined(AFHDS2A_A7105_INO) || defined(AFHDS2A_RX_A7105_INO) const uint8_t PROGMEM AFHDS2A_A7105_regs[] = { 0xFF, 0x42 | (1<<5), 0x00, 0x25, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x01, 0x3c, 0x05, 0x00, 0x50, // 00 - 0f 0x9e, 0x4b, 0x00, 0x02, 0x16, 0x2b, 0x12, 0x4f, 0x62, 0x80, 0xFF, 0xFF, 0x2a, 0x32, 0xc3, 0x1f, // 10 - 1f @@ -329,7 +330,7 @@ void A7105_Init(void) else #endif { - #ifdef AFHDS2A_A7105_INO + #if defined(AFHDS2A_A7105_INO) || defined(AFHDS2A_RX_A7105_INO) A7105_Regs=(uint8_t*)AFHDS2A_A7105_regs; #endif } diff --git a/Multiprotocol/AFHDS2A_Rx_a7105.ino b/Multiprotocol/AFHDS2A_Rx_a7105.ino new file mode 100644 index 0000000..fcf9413 --- /dev/null +++ b/Multiprotocol/AFHDS2A_Rx_a7105.ino @@ -0,0 +1,207 @@ +/* + This project is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Multiprotocol is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Multiprotocol. If not, see . + */ + +#if defined(AFHDS2A_RX_A7105_INO) + +#include "iface_a7105.h" + +#define AFHDS2A_RX_TXPACKET_SIZE 38 +#define AFHDS2A_RX_RXPACKET_SIZE 37 +#define AFHDS2A_RX_NUMFREQ 16 + +static uint8_t afhds2a_rx_data_started; +static uint8_t afhds2a_rx_disable_lna; + +enum { + AFHDS2A_RX_BIND1, + AFHDS2A_RX_BIND2, + AFHDS2A_RX_DATA +}; + +static void __attribute__((unused)) AFHDS2A_Rx_build_telemetry_packet() +{ + uint32_t bits = 0; + uint8_t bitsavailable = 0; + uint8_t idx = 0; + + pkt[idx++] = RX_LQI; // 0 - 130 + pkt[idx++] = RX_RSSI; + pkt[idx++] = 0; // start channel + pkt[idx++] = 14; // number of channels in packet + // pack channels + for (uint8_t i = 0; i < 14; i++) { + uint16_t val = packet[9+i*2] | (packet[10+i*2] << 8); + if (val < 860) + val = 860; + else if (val > 2140) + val = 2140; + val -= 860; + + bits |= val << bitsavailable; + bitsavailable += 11; + while (bitsavailable >= 8) { + pkt[idx++] = bits & 0xff; + bits >>= 8; + bitsavailable -= 8; + } + } +} + +static uint8_t __attribute__((unused)) AFHDS2A_Rx_data_ready() +{ + // check if FECF+CRCF Ok + return !(A7105_ReadReg(A7105_00_MODE) & (1 << 5 | 1 << 6 | 1 << 0)); +} + +uint16_t initAFHDS2A_Rx() +{ + uint8_t i; + A7105_Init(); + hopping_frequency_no = 0; + packet_count = 0; + afhds2a_rx_data_started = 0; + afhds2a_rx_disable_lna = IS_POWER_FLAG_on; + CC2500_SetTxRxMode(afhds2a_rx_disable_lna ? TXRX_OFF : RX_EN); + A7105_Strobe(A7105_RX); + + if (IS_BIND_IN_PROGRESS) { + phase = AFHDS2A_RX_BIND1; + } + else { + uint16_t temp = AFHDS2A_RX_EEPROM_OFFSET; + for (i = 0; i < 4; i++) + rx_id[i] = eeprom_read_byte((EE_ADDR)temp++); + for (i = 0; i < AFHDS2A_RX_NUMFREQ; i++) + hopping_frequency[i] = eeprom_read_byte((EE_ADDR)temp++); + phase = AFHDS2A_RX_DATA; + } + return 1000; +} + +#define AFHDS2A_RX_WAIT_WRITE 0x80 + +uint16_t AFHDS2A_Rx_callback() +{ + static uint32_t pps_timer = 0; + static uint16_t pps_counter = 0; + static int8_t read_retry; + int16_t temp; + uint8_t i; + +#ifndef FORCE_AFHDS2A_TUNING + A7105_AdjustLOBaseFreq(1); +#endif + if (afhds2a_rx_disable_lna != IS_POWER_FLAG_on) { + afhds2a_rx_disable_lna = IS_POWER_FLAG_on; + CC2500_SetTxRxMode(afhds2a_rx_disable_lna ? TXRX_OFF : RX_EN); + } + + switch(phase) { + case AFHDS2A_RX_BIND1: + if (AFHDS2A_Rx_data_ready()) { + A7105_ReadData(AFHDS2A_RX_TXPACKET_SIZE); + if ((packet[0] == 0xbb && packet[9] == 0x01) || (packet[0] == 0xbc && packet[9] <= 0x02)) { + memcpy(rx_id, &packet[1], 4); // TX id actually + memcpy(hopping_frequency, &packet[11], AFHDS2A_RX_NUMFREQ); + phase = AFHDS2A_RX_BIND2; + } + } + A7105_WriteReg(A7105_0F_PLL_I, (packet_count++ & 1) ? 0x0D : 0x8C); // bind channels + A7105_SetTxRxMode(RX_EN); + A7105_Strobe(A7105_RX); + return 10000; + + case AFHDS2A_RX_BIND2: + // got 2nd bind packet from tx ? + if (AFHDS2A_Rx_data_ready()) { + A7105_ReadData(AFHDS2A_RX_TXPACKET_SIZE); + if ((packet[0] == 0xBC && packet[9] == 0x02 && packet[10] == 0x00) && + (memcmp(rx_id, &packet[1], 4) == 0) && + (memcmp(rx_tx_addr, &packet[5], 4) == 0)) { + // save tx info to eeprom + temp = AFHDS2A_RX_EEPROM_OFFSET; + for (i = 0; i < 4; i++) + eeprom_write_byte((EE_ADDR)temp++, rx_id[i]); + for (i = 0; i < AFHDS2A_RX_NUMFREQ; i++) + eeprom_write_byte((EE_ADDR)temp++, hopping_frequency[i]); + BIND_DONE; + phase = AFHDS2A_RX_DATA; + return 3850; + } + } + + // transmit response packet + packet[0] = 0xBC; + memcpy(&packet[1], rx_id, 4); + memcpy(&packet[5], rx_tx_addr, 4); + packet[9] = 0x01; + packet[10] = 0x00; + memset(&packet[11], 0xFF, 26); + A7105_WriteData(AFHDS2A_RX_RXPACKET_SIZE, packet_count++ & 1 ? 0x0D : 0x8C); + phase |= AFHDS2A_RX_WAIT_WRITE; + return 1700; + + case AFHDS2A_RX_BIND2 | AFHDS2A_RX_WAIT_WRITE: + //Wait for TX completion + pps_timer = micros(); + while (micros() - pps_timer < 700) // Wait max 700µs, using serial+telemetry exit in about 120µs + if (!(A7105_ReadReg(A7105_00_MODE) & 0x01)) + break; + A7105_Strobe(A7105_RX); + phase &= ~AFHDS2A_RX_WAIT_WRITE; + return 10000; + + case AFHDS2A_RX_DATA: + if (AFHDS2A_Rx_data_ready()) { + A7105_ReadData(AFHDS2A_RX_TXPACKET_SIZE); + if (memcmp(&packet[1], rx_id, 4) == 0 && memcmp(&packet[5], rx_tx_addr, 4) == 0) { + if (packet[0] = 0x58 && packet[37] == 0x00 && telemetry_link == 0) { // standard packet, send channels to TX + int rssi = min(A7105_ReadReg(A7105_1D_RSSI_THOLD),160); + RX_RSSI = map(rssi, 160, 8, 0, 100); + AFHDS2A_Rx_build_telemetry_packet(); + telemetry_link = 1; + } + afhds2a_rx_data_started = 1; + read_retry = 10; // hop to next channel + pps_counter++; + } + } + + // packets per second + if (millis() - pps_timer >= 1000) { + pps_timer = millis(); + debugln("%ld pps", pps_counter); + RX_LQI = pps_counter / 2; + pps_counter = 0; + } + + // frequency hopping + if (read_retry++ >= 10) { + hopping_frequency_no++; + if(hopping_frequency_no >= AFHDS2A_RX_NUMFREQ) + hopping_frequency_no = 0; + A7105_WriteReg(A7105_0F_PLL_I, hopping_frequency[hopping_frequency_no]); + A7105_Strobe(A7105_RX); + if (afhds2a_rx_data_started) + read_retry = 0; + else + read_retry = -127; // retry longer until first packet is catched + } + return 385; + } + return 3850; // never reached +} + +#endif diff --git a/Multiprotocol/Multi.txt b/Multiprotocol/Multi.txt index bd9d6c3..b866d0b 100644 --- a/Multiprotocol/Multi.txt +++ b/Multiprotocol/Multi.txt @@ -53,4 +53,5 @@ 53,Flyzone,FZ-410 54,Scanner 55,FrskyX_RX,FCC,EU_LBT +56,AFHDS2A_RX 63,XN_DUMP,250K,1M,2M diff --git a/Multiprotocol/Multiprotocol.h b/Multiprotocol/Multiprotocol.h index 5b7c5a0..9f47a6f 100644 --- a/Multiprotocol/Multiprotocol.h +++ b/Multiprotocol/Multiprotocol.h @@ -82,6 +82,7 @@ enum PROTOCOLS PROTO_FLYZONE = 53, // =>A7105 PROTO_SCANNER = 54, // =>CC2500 PROTO_FRSKYX_RX = 55, // =>CC2500 + PROTO_AFHDS2A_RX= 56, // =>A7105 PROTO_XN297DUMP = 63, // =>NRF24L01 }; @@ -575,7 +576,8 @@ enum { #define AFHDS2A_EEPROM_OFFSET 50 // RX ID, 4 bytes per model id, end is 50+64=114 #define BUGS_EEPROM_OFFSET 114 // RX ID, 2 bytes per model id, end is 114+32=146 #define BUGSMINI_EEPROM_OFFSET 146 // RX ID, 2 bytes per model id, end is 146+32=178 -#define FRSKYX_RX_EEPROM_OFFSET 178 // (3) TX ID + (1) freq_tune + (47) channels, 51 bytes per model, end is 178+51=229 +#define FRSKYX_RX_EEPROM_OFFSET 178 // (3) TX ID + (1) freq_tune + (47) channels, 51 bytes, end is 178+51=229 +#define AFHDS2A_RX_EEPROM_OFFSET 229 // (4) TX ID + (16) channels, 20 bytes, end is 229+20=249 //#define CONFIG_EEPROM_OFFSET 210 // Current configuration of the multimodule //**************************************** diff --git a/Multiprotocol/Multiprotocol.ino b/Multiprotocol/Multiprotocol.ino index 433c824..5775b5b 100644 --- a/Multiprotocol/Multiprotocol.ino +++ b/Multiprotocol/Multiprotocol.ino @@ -1003,6 +1003,13 @@ static void protocol_init() remote_callback = ReadFlyzone; break; #endif + #if defined(AFHDS2A_RX_A7105_INO) + case PROTO_AFHDS2A_RX: + PE1_off; //antenna RF1 + next_callback = initAFHDS2A_Rx(); + remote_callback = AFHDS2A_Rx_callback; + break; + #endif #endif #ifdef CC2500_INSTALLED #if defined(FRSKYD_CC2500_INO) diff --git a/Multiprotocol/Telemetry.ino b/Multiprotocol/Telemetry.ino index da0b08c..40e83d7 100644 --- a/Multiprotocol/Telemetry.ino +++ b/Multiprotocol/Telemetry.ino @@ -184,16 +184,21 @@ static void multi_send_status() } #endif -#ifdef FRSKYX_RX_TELEMETRY - void frskyx_rx_channels_frame() +#if defined (FRSKYX_RX_TELEMETRY) || defined (AFHDS2A_RX_TELEMETRY) + void receiver_channels_frame() { + uint16_t len = pkt[3] * 11; // 11 bit per channel + if (len % 8 == 0) + len = 4 + (len / 8); + else + len = 5 + (len / 8); #if defined MULTI_TELEMETRY - multi_send_header(MULTI_TELEMETRY_RX_CHANNELS, 26); + multi_send_header(MULTI_TELEMETRY_RX_CHANNELS, len); #else Serial_write(0xAA); // Telemetry packet #endif - for (uint8_t i = 0; i < 26; i++) - Serial_write(pkt[i]); // pps, rssi, ch start, ch count, 16x ch data + for (uint8_t i = 0; i < len; i++) + Serial_write(pkt[i]); // pps, rssi, ch start, ch count, packed ch data } #endif @@ -1032,10 +1037,10 @@ void TelemetryUpdate() } #endif - #if defined FRSKYX_RX_TELEMETRY - if (telemetry_link && protocol == PROTO_FRSKYX_RX) + #if defined (FRSKYX_RX_TELEMETRY) || defined(AFHDS2A_RX_TELEMETRY) + if (telemetry_link && (protocol == PROTO_FRSKYX_RX || protocol == PROTO_AFHDS2A_RX)) { - frskyx_rx_channels_frame(); + receiver_channels_frame(); telemetry_link = 0; return; } diff --git a/Multiprotocol/Validate.h b/Multiprotocol/Validate.h index 4479c9b..7ced7b1 100644 --- a/Multiprotocol/Validate.h +++ b/Multiprotocol/Validate.h @@ -174,6 +174,7 @@ #undef AFHDS2A_A7105_INO #undef BUGS_A7105_INO #undef FLYZONE_A7105_INO + #undef AFHDS2A_RX_A7105_INO #endif #ifndef CYRF6936_INSTALLED #undef DEVO_CYRF6936_INO @@ -254,6 +255,8 @@ #undef SCANNER_CC2500_INO #undef FRSKYX_RX_TELEMETRY #undef FRSKYX_RX_CC2500_INO + #undef AFHDS2A_RX_TELEMETRY + #undef AFHDS2A_RX_A7105_INO #else #if defined(MULTI_TELEMETRY) && defined(MULTI_STATUS) #error You should choose either MULTI_TELEMETRY or MULTI_STATUS but not both. @@ -266,6 +269,10 @@ #undef FRSKYX_RX_TELEMETRY #undef FRSKYX_RX_CC2500_INO #endif + #if not defined(AFHDS2A_RX_A7105_INO) || not defined(AFHDS2A_RX_TELEMETRY) + #undef AFHDS2A_RX_TELEMETRY + #undef AFHDS2A_RX_A7105_INO + #endif #if not defined(BAYANG_NRF24L01_INO) #undef BAYANG_HUB_TELEMETRY #endif diff --git a/Multiprotocol/_Config.h b/Multiprotocol/_Config.h index 6f71e8c..8c4b757 100644 --- a/Multiprotocol/_Config.h +++ b/Multiprotocol/_Config.h @@ -157,6 +157,7 @@ //The protocols below need an A7105 to be installed #define AFHDS2A_A7105_INO +#define AFHDS2A_RX_A7105_INO #define BUGS_A7105_INO #define FLYSKY_A7105_INO #define FLYZONE_A7105_INO @@ -286,6 +287,7 @@ #define HITEC_FW_TELEMETRY // Under development: Forward received telemetry packets to be decoded by ersky9x and OpenTX #define SCANNER_TELEMETRY // Forward spectrum scanner data to TX #define FRSKYX_RX_TELEMETRY // Forward channels data to TX +#define AFHDS2A_RX_TELEMETRY // Forward channels data to TX //SPORT_POLLING is an implementation of the same polling routine as XJT module for sport telemetry bidirectional communication. //This is useful for passing sport control frames from TX to RX(ex: changing Betaflight PID or VTX channels on the fly using LUA scripts with OpentX). @@ -476,6 +478,8 @@ const PPM_Parameters PPM_prot[14*NBR_BANKS]= { PPM_IBUS PWM_SBUS PPM_SBUS + PROTO_AFHDS2A_RX + NONE PROTO_ASSAN NONE PROTO_BAYANG From 032e0641a585a4fda750ded38325d41f8beed2ae Mon Sep 17 00:00:00 2001 From: goebish Date: Wed, 2 Oct 2019 09:04:13 +0200 Subject: [PATCH 4/5] Fix AFHDS2A receiver packet filter (#276) * Add skeleton for AFHDS2A receiver protocol * Bind & data Ok * Send channels to TX via telemetry * Add RSSI * Fix AVR compilation * Fix channel number * Fix packet type check --- Multiprotocol/AFHDS2A_Rx_a7105.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Multiprotocol/AFHDS2A_Rx_a7105.ino b/Multiprotocol/AFHDS2A_Rx_a7105.ino index fcf9413..d4c8b8e 100644 --- a/Multiprotocol/AFHDS2A_Rx_a7105.ino +++ b/Multiprotocol/AFHDS2A_Rx_a7105.ino @@ -167,7 +167,7 @@ uint16_t AFHDS2A_Rx_callback() if (AFHDS2A_Rx_data_ready()) { A7105_ReadData(AFHDS2A_RX_TXPACKET_SIZE); if (memcmp(&packet[1], rx_id, 4) == 0 && memcmp(&packet[5], rx_tx_addr, 4) == 0) { - if (packet[0] = 0x58 && packet[37] == 0x00 && telemetry_link == 0) { // standard packet, send channels to TX + if (packet[0] == 0x58 && packet[37] == 0x00 && telemetry_link == 0) { // standard packet, send channels to TX int rssi = min(A7105_ReadReg(A7105_1D_RSSI_THOLD),160); RX_RSSI = map(rssi, 160, 8, 0, 100); AFHDS2A_Rx_build_telemetry_packet(); From 331da37840463f791b3576ae2d95a59573122dd2 Mon Sep 17 00:00:00 2001 From: Ben Lye Date: Wed, 2 Oct 2019 09:15:13 +0100 Subject: [PATCH 5/5] Update Binary_Signature.ino (#278) Clean up the comments, add bitmasks. --- Multiprotocol/Binary_Signature.ino | 67 ++++++++++++++++-------------- 1 file changed, 35 insertions(+), 32 deletions(-) diff --git a/Multiprotocol/Binary_Signature.ino b/Multiprotocol/Binary_Signature.ino index af2f343..49d8546 100644 --- a/Multiprotocol/Binary_Signature.ino +++ b/Multiprotocol/Binary_Signature.ino @@ -28,8 +28,8 @@ declares 'flag' variables for the options we are interested in. When the pre-compiler parses the source code these variables are either present or not in the parsed cpp file, typically '$build_dir$/preproc/ctags_target_for_gcc_minus_e.cpp'. -Once the .bin file is compiled an additional command-line tool scans the parsed cpp file, detects the flags, -assembles the signature, and finally appends to the end of the binary file. +Once the .bin file is created an additional command-line build tool scans the parsed cpp file, detects the +flags, assembles the signature, and finally appends the signature to the end of the binary file. The signature is 24 bytes long: multi-x[8-byte hex code]-[8-byte version number] @@ -39,28 +39,32 @@ multi-x1234abcd-01020199 The 8-byte hex code is a 32-bit bitmask value indicating the configuration options, currently: -Bit(s) Option Comment -1-2 Module type Read as a two-bit value indicating a number from 0-3 which maps to a module type (AVR, STM32, OrangeRX) -3-7 Channel order Read as a five-bit value indicating a number from 0-23 which maps to as channel order (AETR, TAER, RETA, etc) -8 Bootloader support Indicates whether or not the firmware was built with support for the bootloader -9 CHECK_FOR_BOOTLOADER -10 INVERT_TELEMETRY -11 MULTI_STATUS -12 MULTI_TELEMETRY -13 DEBUG_SERIAL +Bit(s) Bitmask Option Comment +1-2 0x3 Module type Read as a two-bit value indicating a number from 0-3 which maps to a module type (AVR, STM32, OrangeRX) +3-7 0x7C Channel order Read as a five-bit value indicating a number from 0-23 which maps to as channel order (AETR, TAER, RETA, etc) (right-shift two bits to read) +8 0x80 Bootloader support Indicates whether or not the firmware was built with support for the bootloader +9 0x100 CHECK_FOR_BOOTLOADER Indicates if CHECK_FOR_BOOTLOADER is defined +10 0x200 INVERT_TELEMETRY Indicates if INVERT_TELEMETRY is defined +11 0x400 MULTI_STATUS Indicates if MULTI_STATUS is defined +12 0x800 MULTI_TELEMETRY Indicates if MULTI_TELEMETRY is defined +13 0x1000 DEBUG_SERIAL Indicates if DEBUG_SERIAL is defined The 8-byte version number is the version number zero-padded to a fixed width of two-bytes per segment and no separator. E.g. 1.2.3.45 becomes 01020345. -Module types are mapped to the following decimal / binary values: +Multi Telemetery Type can be read from bits 11 and 12 using the bitmask 0xC00 and right-shifting ten bits: +Telemetry Type Decimal Value Binary Value +Undefined 0 00 +erSkyTX 1 01 +OpenTX 2 10 -Module Type Decimal Value Binary Valsue -AVR 0 00 -STM32 1 01 -OrangeRX 2 10 +Module types are mapped to the following decimal / binary values: +Module Type Decimal Value Binary Valsue +AVR 0 00 +STM32 1 01 +OrangeRX 2 10 Channel orders are mapped to the following decimal / binary values: - Channel Order Decimal Value Binary Value AETR 0 00000 AERT 1 00001 @@ -72,21 +76,20 @@ EATR 6 00110 EART 7 00111 ERAT 8 01000 ERTA 9 01001 -ETRA 10 01010 -ETAR 11 01011 -TEAR 12 01100 -TERA 13 01101 -TREA 14 01110 -TRAE 15 01111 -TARE 16 10000 -TAER 17 10001 -RETA 18 10010 -REAT 19 10011 -RAET 20 10100 -RATE 21 10101 -RTAE 22 10110 -RTEA 23 10111 - +ETRA 10 01010 +ETAR 11 01011 +TEAR 12 01100 +TERA 13 01101 +TREA 14 01110 +TRAE 15 01111 +TARE 16 10000 +TAER 17 10001 +RETA 18 10010 +REAT 19 10011 +RAET 20 10100 +RATE 21 10101 +RTAE 22 10110 +RTEA 23 10111 */ // Set the flags for detecting and writing the firmware signature