Skip to content

Commit

Permalink
Implement reading firmware on Horus via USB (#5442)
Browse files Browse the repository at this point in the history
* Add firmware lun target for non EEPROM platforms

* Fix Fat fat tables and make FAT 1024 byte big

* Niceify some constants

* Cleanup (saves 1024 byte of flash) and fix reporting wrong Size of drive

* Silence compiler warning, set right size for flash on X12/X10

* Add firmware.txt/bootload.txt to virtual drive that displays version information

* Report also version of other component (bootloader/firmware)

* Show version also in bootloader and fix F4 platforms

* Save space on X7

* Fix X7 logic

* Compile fix for AVR

* avr-gcc does not like no newline after ifdef

* Really fix avr
  • Loading branch information
schwabe authored and bsongis committed Dec 18, 2017
1 parent d13e770 commit 9757592
Show file tree
Hide file tree
Showing 10 changed files with 250 additions and 356 deletions.
1 change: 1 addition & 0 deletions radio/src/opentx.h
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,7 @@ extern const char eeprom_stamp[];
#else
extern const char vers_stamp[];
#endif
const char* getOtherVersion();

extern uint8_t g_vbat100mV;
#if LCD_W > 128
Expand Down
36 changes: 36 additions & 0 deletions radio/src/stamp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,39 @@
#else
const pm_char vers_stamp[] PROGMEM = "FW\037\033: " "opentx-" FLAVOUR "\036VERS\037\033: " VERSION "\036DATE\037\033: " DATE "\036TIME\037\033: " TIME "\036EEPR\037\033: " EEPROM_STR;
#endif

/**
* Retrieves the version of the bootloader or firmware
* @return
*/
#if defined(HORUS)
const char* getOtherVersion()
{
return "no bootloader support";
}
#elif defined(STM32)

__attribute__ ((section(".fwversiondata"), used)) const char firmware_version[32] = "opentx-" FLAVOUR "-" VERSION " (" GIT_STR ")";
__attribute__ ((section(".bootversiondata"), used)) const char boot_version[32] = "opentx-" FLAVOUR "-" VERSION " (" GIT_STR ")";

const char* getOtherVersion()
{
#if defined(BOOT)
const char* startother = (char*)(FIRMWARE_ADDRESS+BOOTLOADER_SIZE);
#else
const char* startother = (char*)(FIRMWARE_ADDRESS);
#endif

const char* other_str = nullptr;
for (int i=0; i< 1024;i++) {
if (memcmp(startother+i, "opentx-", 7)==0) {
other_str = startother + i;
break;
}
}
if (other_str != nullptr)
return other_str;
else
return "no version found";
}
#endif
Loading

1 comment on commit 9757592

@mpaperno
Copy link
Member

@mpaperno mpaperno commented on 9757592 Dec 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks my MSVC build:

radio\src\stamp.cpp(59): error C3861: 'section': identifier not found
radio\src\stamp.cpp(59): error C2065: 'used': undeclared identifier
radio\src\stamp.cpp(59): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
radio\src\stamp.cpp(59): error C2059: syntax error: 'const'
radio\src\stamp.cpp(60): error C3861: 'section': identifier not found
radio\src\stamp.cpp(60): error C2065: 'used': undeclared identifier
radio\src\stamp.cpp(60): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
radio\src\stamp.cpp(60): error C2374: '__attribute__': redefinition; multiple initialization
radio\src\stamp.cpp(59): note: see declaration of '__attribute__'
radio\src\stamp.cpp(60): error C2059: syntax error: 'const'

Seems OK on GCC (windows also).

Please sign in to comment.