Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Horus bootloader #5455

Merged
merged 26 commits into from Dec 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
884343f
Generalize bootloader to STM32
kilrah Nov 21, 2017
42ae4be
first draft for horus bootloader (WiP)
raphaelcoeffic Nov 22, 2017
e300493
removed unused HAL definitions
raphaelcoeffic Nov 29, 2017
2b98d45
allow the DMA buffers to be placed correctly in RAM instead of CCM se…
raphaelcoeffic Nov 29, 2017
720898e
horus BL stack in ram instead of CCM
raphaelcoeffic Nov 29, 2017
7dd5c49
wait for power button to be release in bootloader
raphaelcoeffic Nov 29, 2017
083af49
fixed linker script for taranis
raphaelcoeffic Nov 29, 2017
11cbf1e
fixed CMakeLists for X7 target
raphaelcoeffic Nov 29, 2017
fc6ee2e
cleanup WiP
raphaelcoeffic Nov 30, 2017
30e0ece
added support for writing up to 2MB flash
raphaelcoeffic Nov 30, 2017
6c53b50
added X12S to bootloader targets
raphaelcoeffic Nov 30, 2017
2169ef7
reworked beginning of flash sector detection
raphaelcoeffic Nov 30, 2017
0d9b5d2
re-enabled getTextWidth() in BL
raphaelcoeffic Nov 30, 2017
a20d3af
cosmetics
raphaelcoeffic Nov 30, 2017
53e44db
fixed flashing over 1MB issue
raphaelcoeffic Dec 1, 2017
364e24a
fixed showing firmware version
raphaelcoeffic Dec 1, 2017
4bd28c9
wdt_reset() while waiting for PWR button to be released
raphaelcoeffic Dec 1, 2017
3d0b494
implemented horus screens as designed
raphaelcoeffic Dec 2, 2017
9c56a2b
small fixes
raphaelcoeffic Dec 2, 2017
5293d1b
removed unneeded linker workaround
raphaelcoeffic Dec 2, 2017
298a2b8
fixed width in drawSizedText()
raphaelcoeffic Dec 2, 2017
8fddbd6
some bin file handling cleanup
raphaelcoeffic Dec 2, 2017
36e7514
Let getOtherVersion also find version string in a buffer
schwabe Dec 3, 2017
93a30e3
some more graphical improvements and final cleanup
raphaelcoeffic Dec 2, 2017
878c436
remove CLI from bootloader builds
raphaelcoeffic Dec 3, 2017
088412a
disable DEBUG again on non-Horus boot loader builds
raphaelcoeffic Dec 4, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion CMakeLists.txt
Expand Up @@ -72,6 +72,9 @@ else()
set(LUA NO)
endif()

option(DISABLE_COMPANION "Disable building companion and simulators" OFF)

if(NOT DISABLE_COMPANION)
find_package(Qt5Core)
find_package(Qt5Widgets)
find_package(Qt5Xml)
Expand Down Expand Up @@ -150,6 +153,7 @@ if(Qt5Core_FOUND OR FOX_FOUND)
message(STATUS "SDL not found! Simulator audio, and joystick inputs, will not work.")
endif()
endif()
endif()

# Check for a file that is typically left from a OpenTX 2.1 build and abort if found
if (EXISTS ${RADIO_SRC_DIRECTORY}/stamp.h OR EXISTS ${RADIO_SRC_DIRECTORY}/translations/en.h)
Expand Down Expand Up @@ -180,6 +184,6 @@ endif()

add_subdirectory(${RADIO_SRC_DIRECTORY})

if(Qt5Core_FOUND)
if(Qt5Core_FOUND AND NOT DISABLE_COMPANION)
add_subdirectory(${COMPANION_SRC_DIRECTORY})
endif()
6 changes: 3 additions & 3 deletions radio/src/CMakeLists.txt
Expand Up @@ -486,9 +486,9 @@ if(NOT MSVC)
endif()


if(PCB STREQUAL X9D OR PCB STREQUAL X9D+ OR PCB STREQUAL X9E OR PCB STREQUAL X7)
add_subdirectory(targets/${TARGET_DIR}/bootloader)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/targets/${TARGET_DIR}/bootloader)
if(PCB STREQUAL X9D OR PCB STREQUAL X9D+ OR PCB STREQUAL X9E OR PCB STREQUAL X7 OR PCB STREQUAL X10 OR PCB STREQUAL X12S)
add_subdirectory(targets/common/arm/stm32/bootloader)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/targets/common/arm/stm32/bootloader)
set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} bootloader)
elseif(OPENRC_BOOTLOADER)
# We fetch Mike's bootloader as it is not included inside OpenTX
Expand Down
8 changes: 6 additions & 2 deletions radio/src/bitmaps/480x272/CMakeLists.txt
Expand Up @@ -10,7 +10,9 @@ if(PCB STREQUAL X12S)
add_bitmaps_target(x12s_themes_bitmaps "${RADIO_SRC_DIRECTORY}/gui/480x272/themes/*.png" 480 5/6/5)
add_bitmaps_target(x12s_fonts ${RADIO_SRC_DIRECTORY}/fonts/480x272/*.png 480 8bits)
add_bitmaps_target(x12s_volume_masks ${RADIO_SRC_DIRECTORY}/bitmaps/480x272/volume/*.png 480 8bits)
add_dependencies(x12s_bitmaps x12s_calibration_bitmaps x12s_button_bitmaps x12s_alpha_bitmaps x12s_alpha_calibration_bitmaps x12s_masks x12s_slider_masks x12s_layouts_masks x12s_themes_bitmaps x12s_fonts x12s_volume_masks)
add_bitmaps_target(x12s_bootloader_bitmaps ${RADIO_SRC_DIRECTORY}/bitmaps/480x272/bootloader/bmp_*.png 480 5/6/5)
add_bitmaps_target(x12s_bootloader_icons ${RADIO_SRC_DIRECTORY}/bitmaps/480x272/bootloader/icon_*.png 480 8bits)
add_dependencies(x12s_bitmaps x12s_calibration_bitmaps x12s_button_bitmaps x12s_alpha_bitmaps x12s_alpha_calibration_bitmaps x12s_masks x12s_slider_masks x12s_layouts_masks x12s_themes_bitmaps x12s_fonts x12s_volume_masks x12s_bootloader_bitmaps x12s_bootloader_icons)
else()
add_bitmaps_target(x10_bitmaps "${RADIO_SRC_DIRECTORY}/bitmaps/480x272/bmp_*.png" 480 5/6/5-R)
add_bitmaps_target(x10_calibration_bitmaps "${RADIO_SRC_DIRECTORY}/bitmaps/480x272/calibration/bmp_*.png" 480 5/6/5-R)
Expand All @@ -23,5 +25,7 @@ else()
add_bitmaps_target(x10_themes_bitmaps "${RADIO_SRC_DIRECTORY}/gui/480x272/themes/*.png" 480 5/6/5-R)
add_bitmaps_target(x10_fonts ${RADIO_SRC_DIRECTORY}/fonts/480x272/*.png 480 8bits)
add_bitmaps_target(x10_volume_masks ${RADIO_SRC_DIRECTORY}/bitmaps/480x272/volume/*.png 480 8bits)
add_dependencies(x10_bitmaps x10_calibration_bitmaps x10_button_bitmaps x10_alpha_bitmaps x10_alpha_calibration_bitmaps x10_masks x10_slider_masks x10_layouts_masks x10_themes_bitmaps x10_fonts x10_volume_masks)
add_bitmaps_target(x10_bootloader_bitmaps ${RADIO_SRC_DIRECTORY}/bitmaps/480x272/bootloader/bmp_*.png 480 5/6/5-R)
add_bitmaps_target(x10_bootloader_icons ${RADIO_SRC_DIRECTORY}/bitmaps/480x272/bootloader/icon_*.png 480 8bits)
add_dependencies(x10_bitmaps x10_calibration_bitmaps x10_button_bitmaps x10_alpha_bitmaps x10_alpha_calibration_bitmaps x10_masks x10_slider_masks x10_layouts_masks x10_themes_bitmaps x10_fonts x10_volume_masks x10_bootloader_bitmaps x10_bootloader_icons)
endif()
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added radio/src/bitmaps/480x272/bootloader/icon_exit.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added radio/src/bitmaps/480x272/bootloader/icon_file.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added radio/src/bitmaps/480x272/bootloader/icon_flash.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added radio/src/bitmaps/480x272/bootloader/icon_ok.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added radio/src/bitmaps/480x272/bootloader/icon_sd.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion radio/src/definitions.h
Expand Up @@ -29,7 +29,7 @@

#if defined(SIMU)
#define __DMA
#elif defined(STM32F4) && !defined(BOOT)
#elif (defined(STM32F4) && !defined(BOOT)) || defined(PCBHORUS)
#define __DMA __attribute__((section(".ram"), aligned(32)))
#else
#define __DMA __ALIGNED
Expand Down
5 changes: 5 additions & 0 deletions radio/src/fonts.h
Expand Up @@ -23,8 +23,13 @@

#if defined(COLORLCD)

#if !defined(BOOT)
extern const uint16_t * const fontspecsTable[16];
extern const uint8_t * const fontsTable[16];
#else
extern const uint16_t * const fontspecsTable[1];
extern const uint8_t * const fontsTable[1];
#endif

#if defined(PCBHORUS)
extern BitmapBuffer * fontCache[2];
Expand Down
16 changes: 9 additions & 7 deletions radio/src/gui/480x272/bitmapbuffer.cpp
Expand Up @@ -320,10 +320,12 @@ void BitmapBuffer::drawSizedText(coord_t x, coord_t y, const char * s, uint8_t l
const uint16_t * fontspecs = fontspecsTable[fontindex];
BitmapBuffer * fontcache = NULL;

if (flags & RIGHT)
if (flags & RIGHT) {
INCREMENT_POS(-width);
else if (flags & CENTERED)
}
else if (flags & CENTERED) {
INCREMENT_POS(-width/2);
}

coord_t & pos = (flags & VERTICAL) ? y : x;

Expand Down Expand Up @@ -380,11 +382,11 @@ void BitmapBuffer::drawSizedText(coord_t x, coord_t y, const char * s, uint8_t l
bool setpos = false;
const coord_t orig_pos = pos;
while (len--) {
unsigned char c;
if (flags & ZCHAR)
c = idx2char(*s);
else
c = pgm_read_byte(s);
#if defined(BOOT)
unsigned char c = *s;
#else
unsigned char c = (flags & ZCHAR) ? idx2char(*s) : *s;
#endif
if (setpos) {
pos = c;
setpos = false;
Expand Down
9 changes: 9 additions & 0 deletions radio/src/gui/480x272/fonts.cpp
Expand Up @@ -20,6 +20,7 @@

#include "opentx.h"

#if !defined(BOOT)
const uint16_t font_tinsize_specs[] = {
#include "font_tinsize.specs"
};
Expand All @@ -35,6 +36,7 @@ const uint16_t font_smlsize_specs[] = {
const pm_uchar font_smlsize[] = {
#include "font_smlsize.lbm"
};
#endif

const uint16_t font_stdsize_specs[] = {
#include "font_stdsize.specs"
Expand All @@ -44,6 +46,7 @@ const pm_uchar font_stdsize[] = {
#include "font_stdsize.lbm"
};

#if !defined(BOOT)
const uint16_t font_midsize_specs[] = {
#include "font_midsize.specs"
};
Expand Down Expand Up @@ -75,7 +78,9 @@ const uint16_t font_stdsizebold_specs[] = {
const pm_uchar font_stdsizebold[] = {
#include "font_stdsizebold.lbm"
};
#endif

#if !defined(BOOT)
const uint16_t * const fontspecsTable[16] = {
font_stdsize_specs, font_tinsize_specs, font_smlsize_specs, font_midsize_specs, font_dblsize_specs, font_xxlsize_specs, font_stdsize_specs, font_stdsize_specs,
font_stdsizebold_specs, font_tinsize_specs, font_smlsize_specs, font_midsize_specs, font_dblsize_specs, font_xxlsize_specs, font_stdsize_specs, font_stdsize_specs
Expand All @@ -85,6 +90,10 @@ const uint8_t * const fontsTable[16] = {
font_stdsize, font_tinsize, font_smlsize, font_midsize, font_dblsize, font_xxlsize, font_stdsize, font_stdsize,
font_stdsizebold, font_tinsize, font_smlsize, font_midsize, font_dblsize, font_xxlsize, font_stdsize, font_stdsize
};
#else
const uint16_t * const fontspecsTable[1] = { font_stdsize_specs };
const uint8_t * const fontsTable[1] = { font_stdsize };
#endif

BitmapBuffer * fontCache[2] = { NULL, NULL };

Expand Down
16 changes: 9 additions & 7 deletions radio/src/gui/480x272/lcd.cpp
Expand Up @@ -21,6 +21,7 @@
#include <math.h>
#include <stdio.h>
#include "opentx.h"
#include "strhelpers.h"

#if defined(SIMU)
display_t displayBuf[DISPLAY_BUFFER_SIZE];
Expand Down Expand Up @@ -103,11 +104,12 @@ int getTextWidth(const char * s, int len, LcdFlags flags)

int result = 0;
for (int i=0; len==0 || i<len; ++i) {
char c;
if (flags & ZCHAR)
c = idx2char(*s);
else
c = *s;

#if !defined(BOOT)
char c = (flags & ZCHAR) ? idx2char(*s) : *s;
#else
char c = *s;
#endif
if (c == '\0')
break;
result += getCharWidth(c, specs);
Expand Down Expand Up @@ -175,7 +177,6 @@ void lcdDrawNumber(coord_t x, coord_t y, int32_t val, LcdFlags flags, uint8_t le
lcdDrawText(x, y, s, flags);
}

#if !defined(BOOT)
void lcdDrawLine(coord_t x1, coord_t y1, coord_t x2, coord_t y2, uint8_t pat, LcdFlags att)
{
int dx = x2-x1; /* the horizontal distance of the line */
Expand Down Expand Up @@ -218,8 +219,8 @@ void lcdDrawLine(coord_t x1, coord_t y1, coord_t x2, coord_t y2, uint8_t pat, Lc
}
}
}
#endif

#if !defined(BOOT)
void drawRtcTime(coord_t x, coord_t y, LcdFlags flags)
{
drawTimer(x, y, getValue(MIXSRC_TX_TIME), flags);
Expand Down Expand Up @@ -388,6 +389,7 @@ void drawGPSSensorValue(coord_t x, coord_t y, TelemetryItem & telemetryItem, Lcd
{
drawGPSPosition(x, y, telemetryItem.gps.longitude, telemetryItem.gps.latitude, flags);
}
#endif

void lcdSetContrast()
{
Expand Down
18 changes: 14 additions & 4 deletions radio/src/gui/480x272/lcd.h
Expand Up @@ -87,8 +87,14 @@ enum FontSizeIndex {
#define XXLSIZE (XXLSIZE_INDEX << 8)
#define BOLD (STDSIZE_BOLD_INDEX << 8)
#define FONTSIZE_MASK 0x0f00

#if !defined(BOOT)
#define FONTSIZE(flags) ((flags) & FONTSIZE_MASK)
#define FONTINDEX(flags) (FONTSIZE(flags) >> 8)
#else
#define FONTSIZE(flags) STDSIZE
#define FONTINDEX(flags) STDSIZE_INDEX
#endif

#define TIMEBLINK 0x1000
#define TIMEHOUR 0x2000
Expand Down Expand Up @@ -134,6 +140,13 @@ inline void lcdDrawSizedText(coord_t x, coord_t y, const pm_char * s, uint8_t le
void lcdDrawHexNumber(coord_t x, coord_t y, uint32_t val, LcdFlags mode=0);
void lcdDrawNumber(coord_t x, coord_t y, int32_t val, LcdFlags flags=0, uint8_t len=0, const char * prefix=NULL, const char * suffix=NULL);

#if !defined(BOOT)

#define putstime_t int32_t

void drawRtcTime(coord_t x, coord_t y, LcdFlags att=0);
void drawTimer(coord_t x, coord_t y, putstime_t tme, LcdFlags att=0);

void putsModelName(coord_t x, coord_t y, char *name, uint8_t id, LcdFlags att);
void putsStickName(coord_t x, coord_t y, uint8_t idx, LcdFlags att=0);
void drawSwitch(coord_t x, coord_t y, swsrc_t swtch, LcdFlags flags=0);
Expand All @@ -145,10 +158,7 @@ void drawTrimMode(coord_t x, coord_t y, uint8_t phase, uint8_t idx, LcdFlags att
#define putsChn(x, y, idx, att) drawSource(x, y, MIXSRC_CH1+idx-1, att)
void putsChnLetter(coord_t x, coord_t y, uint8_t idx, LcdFlags attr);

#define putstime_t int32_t

void drawRtcTime(coord_t x, coord_t y, LcdFlags att=0);
void drawTimer(coord_t x, coord_t y, putstime_t tme, LcdFlags att=0);
#endif // !BOOT

#define SOLID 0xff
#define DOTTED 0x55
Expand Down