Remove legacy fonts and make the bootloader compile with LVGL

This commit is contained in:
Raphael Coeffic
2022-06-11 15:38:08 +02:00
committed by Raphael Coeffic
parent 0404919667
commit ee0c37157d
74 changed files with 2027 additions and 775 deletions
@@ -21,11 +21,9 @@
#include "stm32_hal_ll.h"
#include "stm32_usart_driver.h"
#include "opentx.h"
#include "targets/horus/board.h"
#include "aux_serial_driver.h"
#include "board.h"
#include "fifo.h"
#include "dmafifo.h"
@@ -132,6 +132,13 @@ void delay_ms(uint32_t count);
}
#endif
#if !defined(BOOT)
void watchdogSuspend(uint32_t timeout);
#define WATCHDOG_SUSPEND(x) watchdogSuspend(x)
#else
#define WATCHDOG_SUSPEND(...)
#endif
#define INIT_KEYS_PINS(GPIO) \
GPIO_InitStructure.GPIO_Pin = KEYS_ ## GPIO ## _PINS; \
GPIO_Init(GPIO, &GPIO_InitStructure)
@@ -141,4 +148,26 @@ void delay_ms(uint32_t count);
GPIO_Init(GPIO, &GPIO_InitStructure); \
GPIO_SetBits(GPIO, KEYS_ ## GPIO ## _PINS)
#if defined(ROTARY_ENCODER_NAVIGATION)
typedef int32_t rotenc_t;
extern volatile rotenc_t rotencValue;
#define IS_ROTARY_ENCODER_NAVIGATION_ENABLE() true
#define ROTARY_ENCODER_NAVIGATION_VALUE rotencValue
#define ROTENC_LOWSPEED 1
#define ROTENC_MIDSPEED 5
#define ROTENC_HIGHSPEED 50
#define ROTENC_DELAY_MIDSPEED 32
#define ROTENC_DELAY_HIGHSPEED 16
#elif defined(RADIO_T8)
constexpr uint8_t rotencSpeed = 1;
#endif
#define ROTARY_ENCODER_GRANULARITY (2)
#if defined(PWR_BUTTON_PRESS)
#define pwrOffPressed() pwrPressed()
#else
#define pwrOffPressed() (!pwrPressed())
#endif
#endif
@@ -114,7 +114,7 @@ if(PCB STREQUAL X10 OR PCB STREQUAL X12S OR PCB STREQUAL NV14)
${BOOTLOADER_SRC}
../../../../../gui/colorlcd/fonts.cpp
../../../../../gui/colorlcd/colors.cpp
../../../../../fonts/lvgl/lv_font_roboto_16.c
../../../../../fonts/lvgl/lv_font_roboto_bl_16.c
../../../../../thirdparty/libopenui/src/bitmapbuffer.cpp
../../../../../targets/${TARGET_DIR}/sdram_driver.c
../../../../../targets/common/arm/stm32/sdio_sd.c
@@ -124,7 +124,7 @@ if(PCB STREQUAL X10 OR PCB STREQUAL X12S OR PCB STREQUAL NV14)
)
# Add LVGL sources
foreach(LVGL_FILE ${LVGL_SRC_FILES})
foreach(LVGL_FILE ${LVGL_SRC_FILES_MINIMAL})
set(BOOTLOADER_SRC ${BOOTLOADER_SRC} ../../../../../${LVGL_FILE})
endforeach()
@@ -174,15 +174,9 @@ set(CMAKE_EXE_LINKER_FLAGS "-mcpu=${MCU} -mthumb -nostartfiles -lm -T${RADIO_SRC
# use smaller nano libc
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --specs=nano.specs")
add_executable(bootloader EXCLUDE_FROM_ALL
${BOOTLOADER_SRC}
)
add_executable(bootloader EXCLUDE_FROM_ALL ${BOOTLOADER_SRC})
add_dependencies(bootloader ${BITMAPS_TARGET} radio_translations)
if(PCB STREQUAL X10 OR PCB STREQUAL X12S OR PCB STREQUAL NV14)
add_dependencies(bootloader truetype_fonts)
endif()
add_custom_command(
TARGET bootloader POST_BUILD
COMMAND ${CMAKE_OBJCOPY} -O binary bootloader.elf ${CMAKE_BINARY_DIR}/bootloader.bin
@@ -19,9 +19,11 @@
* GNU General Public License for more details.
*/
#include "opentx.h"
#include "boot.h"
#include "sdcard.h"
#include "bin_files.h"
#include "fw_version.h"
#include "strhelpers.h"
// 'private'
static DIR dir;
@@ -22,7 +22,8 @@
#ifndef _bin_files_h_
#define _bin_files_h_
#include "opentx.h"
#include <FatFs/ff.h>
#include "bitmapbuffer.h"
enum MemoryType {
MEM_FLASH,
@@ -19,9 +19,11 @@
* GNU General Public License for more details.
*/
#include "opentx.h"
#include "board.h"
#include "boot.h"
#include "bin_files.h"
#include "dataconstants.h"
#include "lcd.h"
#if defined(PCBXLITE)
#define BOOTLOADER_KEYS 0x0F
@@ -47,16 +49,14 @@ typedef void (*voidFunction)(void);
jumpFn(); \
} while(0)
#if !defined(SIMU)
// Bootloader marker:
// -> used to detect valid bootloader files
const uint8_t bootloaderVersion[] __attribute__ ((section(".version"), used)) =
{'B', 'O', 'O', 'T', '1', '0'};
#if defined(ROTARY_ENCODER_NAVIGATION)
volatile rotenc_t rotencValue = 0;
#endif
#if defined(DEBUG)
#if defined(DEBUG) && !defined(SIMU)
volatile tmr10ms_t g_tmr10ms;
#endif
@@ -113,14 +113,17 @@ void init10msTimer()
NVIC_EnableIRQ(INTERRUPT_xMS_IRQn);
}
#if !defined(SIMU)
extern "C" void INTERRUPT_xMS_IRQHandler()
{
INTERRUPT_xMS_TIMER->SR &= ~TIM_SR_UIF;
interrupt10ms();
}
#endif
uint32_t isValidBufferStart(const uint8_t * buffer)
{
#if !defined(SIMU)
#if defined(EEPROM)
if (memoryType == MEM_FLASH)
return isFirmwareStart(buffer);
@@ -129,6 +132,9 @@ uint32_t isValidBufferStart(const uint8_t * buffer)
#else
return isFirmwareStart(buffer);
#endif
#else
return 1;
#endif
}
FlashCheckRes checkFlashFile(unsigned int index, FlashCheckRes res)
@@ -175,7 +181,9 @@ void flashWriteBlock()
{
uint32_t blockOffset = 0;
while (BlockCount) {
#if !defined(SIMU)
flashWrite((uint32_t *)firmwareAddress, (uint32_t *)&Block_buffer[blockOffset]);
#endif
blockOffset += FLASH_PAGESIZE;
firmwareAddress += FLASH_PAGESIZE;
if (BlockCount > FLASH_PAGESIZE) {
@@ -195,14 +203,9 @@ void writeEepromBlock()
}
#endif
int main()
#if !defined(SIMU)
void bootloaderInitApp()
{
BootloaderState state = ST_START;
uint32_t vpos = 0;
uint8_t index = 0;
FRESULT fr;
uint32_t nameCount = 0;
RCC_AHB1PeriphClockCmd(PWR_RCC_AHB1Periph | KEYS_RCC_AHB1Periph |
LCD_RCC_AHB1Periph | BACKLIGHT_RCC_AHB1Periph |
AUX_SERIAL_RCC_AHB1Periph | AUX2_SERIAL_RCC_AHB1Periph |
@@ -281,6 +284,22 @@ int main()
// SD card detect pin
sdInit();
usbInit();
}
int main()
#else // SIMU
void bootloaderInitApp() {}
int bootloaderMain()
#endif
{
BootloaderState state = ST_START;
uint32_t vpos = 0;
uint8_t index = 0;
FRESULT fr;
uint32_t nameCount = 0;
// init hardware (may jump to app)
bootloaderInitApp();
// init screen
bootloaderInitScreen();
@@ -305,15 +324,18 @@ int main()
unlocked = 1;
unlockFlash();
}
#if !defined(SIMU)
usbStart();
usbPluggedIn();
#endif
}
}
if (state == ST_USB) {
if (usbPlugged() == 0) {
vpos = 0;
#if !defined(SIMU)
usbStop();
#endif
if (unlocked) {
lockFlash();
unlocked = 0;
@@ -528,12 +550,16 @@ int main()
lcdRefresh();
lcdRefreshWait();
#if !defined(SIMU)
#if defined(RTC_BACKUP_RAM)
rtcInit();
RTC->BKP0R = SOFTRESET_REQUEST;
#endif
NVIC_SystemReset();
#else
exit(1);
#endif
}
}
@@ -22,6 +22,7 @@
#ifndef _boot_h_
#define _boot_h_
#include <stdint.h>
#include "stamp.h"
#if LCD_W < 212
@@ -86,7 +87,7 @@ void bootloaderInitScreen();
// Depending on the state, up to two optional parameters are passed.
// See boot.cpp/main for more details
void bootloaderDrawScreen(BootloaderState st, int opt, const char* str = NULL);
void bootloaderDrawScreen(BootloaderState st, int opt, const char* str = nullptr);
// Once for each file in a filename list on screen
void bootloaderDrawFilename(const char* str, uint8_t line, bool selected);
@@ -19,7 +19,7 @@
* GNU General Public License for more details.
*/
#include "opentx.h"
#include "board.h"
void waitFlashIdle()
{
@@ -19,7 +19,7 @@
* GNU General Public License for more details.
*/
#include "opentx.h"
#include "board.h"
void pwrInit()
{
@@ -19,10 +19,10 @@
* GNU General Public License for more details.
*/
#include "opentx.h"
#include "heartbeat_driver.h"
#include "board.h"
uint8_t rotencPosition;
static uint8_t rotencPosition;
volatile rotenc_t rotencValue;
void rotaryEncoderInit()
{
@@ -123,12 +123,6 @@ void rotaryEncoderCheck()
rotencValue += INC_ROT;
}
rotencPosition = newPosition;
#endif
#if !defined(BOOT)
if (g_eeGeneral.backlightMode & e_backlight_mode_keys) {
resetBacklightTimeout();
}
inactivity.counter = 0;
#endif
}
}
@@ -19,7 +19,8 @@
* GNU General Public License for more details.
*/
#include "opentx.h"
#include "board.h"
#include "rtc.h"
void rtcSetTime(const struct gtm * t)
{
@@ -52,7 +52,14 @@ void stop1msTimer()
NVIC_DisableIRQ(INTERRUPT_xMS_IRQn);
}
static void interrupt1ms()
static uint32_t watchdogTimeout = 0;
void watchdogSuspend(uint32_t timeout)
{
watchdogTimeout = timeout;
}
void interrupt1ms()
{
static uint8_t pre_scale; // Used to get 10 Hz counter
@@ -78,6 +85,12 @@ static void interrupt1ms()
// 10ms loop
if (pre_scale == 10) {
pre_scale = 0;
if (watchdogTimeout) {
watchdogTimeout -= 1;
WDG_RESET(); // Retrigger hardware watchdog
}
DEBUG_TIMER_START(debugTimerPer10ms);
DEBUG_TIMER_SAMPLE(debugTimerPer10msPeriod);
per10ms();
@@ -19,24 +19,18 @@
* GNU General Public License for more details.
*/
#include "opentx.h"
#include "debug.h"
#include "usb_driver.h"
extern "C" {
#include "usb_conf.h"
#include "usb_dcd_int.h"
#include "usb_bsp.h"
#include "usbd_cdc_core.h"
#include "usbd_msc_core.h"
#include "usbd_hid_core.h"
#include "usbd_usr.h"
#include "usbd_desc.h"
#include "usbd_conf.h"
}
#include "board.h"
#include "debug.h"
#include "debounce.h"
static bool usbDriverStarted = false;
#if defined(BOOT)
static usbMode selectedUsbMode = USB_MASS_STORAGE_MODE;
@@ -75,6 +69,8 @@ void usbInit()
usbDriverStarted = false;
}
extern void usbInitLUNs();
void usbStart()
{
switch (getSelectedUsbMode()) {
@@ -93,6 +89,7 @@ void usbStart()
default:
case USB_MASS_STORAGE_MODE:
// initialize USB as MSC device
usbInitLUNs();
USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_MSC_cb, &USR_cb);
break;
}
@@ -111,6 +108,8 @@ bool usbStarted()
}
#if !defined(BOOT)
#include "globals.h"
/*
Prepare and send new USB data packet
@@ -20,9 +20,13 @@
*/
/* Includes ------------------------------------------------------------------*/
#include "opentx.h"
#include "FatFs/diskio.h"
#include "stamp.h"
#include "fw_version.h"
#include "board.h"
#include "debug.h"
#include <string.h>
#if defined(__cplusplus) && !defined(SIMU)
extern "C" {
@@ -168,7 +172,7 @@ int8_t STORAGE_GetCapacity (uint8_t lun, uint32_t *block_num, uint32_t *block_si
uint8_t lunReady[STORAGE_LUN_NBR];
void usbPluggedIn()
void usbInitLUNs()
{
lunReady[STORAGE_SDCARD_LUN] = 1;
lunReady[STORAGE_EEPROM_LUN] = 1;
@@ -20,7 +20,6 @@
*/
/* Includes ------------------------------------------------------------------*/
#include "opentx.h"
extern "C" {
#include "usbd_usr.h"