# HG changeset patch # User Ideenmodellierer # Date 1723494346 -7200 # Node ID bc6c90e20d9e18976e1c3d7b77f19edd10c41f4c # Parent 4e10a3e087a115431d2a7231da3b2717d3256d03 Instrument code for Bootloader: the Bootloader was reactivated. Because some functions have changed in the past years an instrumentation had to be done to avoid compile issues (e.g. no multilanguage in Bootloader, no special fonts) diff -r 4e10a3e087a1 -r bc6c90e20d9e Discovery/Inc/gfx_engine.h --- a/Discovery/Inc/gfx_engine.h Mon Aug 12 22:23:03 2024 +0200 +++ b/Discovery/Inc/gfx_engine.h Mon Aug 12 22:25:46 2024 +0200 @@ -113,6 +113,7 @@ /* Exported functions --------------------------------------------------------*/ void GFX_init(uint32_t * pDestinationOut); +void GFX_init1_no_DMA(uint32_t * pDestinationOut, uint8_t blockFrames); void GFX_helper_font_memory_list(const tFont *Font); @@ -199,4 +200,5 @@ tFont* GFX_Check_Extra_Font(uint8_t character, tFont *Font); uint32_t GFX_Character_Width(uint8_t character, tFont *Font); +void Gfx_colorsscheme_mod(char *text, uint8_t alternativeColor); #endif // GFX_ENGINE_H diff -r 4e10a3e087a1 -r bc6c90e20d9e Discovery/Inc/gfx_fonts.h --- a/Discovery/Inc/gfx_fonts.h Mon Aug 12 22:23:03 2024 +0200 +++ b/Discovery/Inc/gfx_fonts.h Mon Aug 12 22:25:46 2024 +0200 @@ -52,6 +52,7 @@ // Actual data is stored between __upper_font_data and __upper_font_data_end, // and uses 0x081b9a3a - 0x08132040 = 879FA = 542 KB. // + extern const tFont Awe48; extern const tFont FontT24; extern const tFont FontT42; diff -r 4e10a3e087a1 -r bc6c90e20d9e Discovery/Inc/stm32f4xx_hal_conf.h --- a/Discovery/Inc/stm32f4xx_hal_conf.h Mon Aug 12 22:23:03 2024 +0200 +++ b/Discovery/Inc/stm32f4xx_hal_conf.h Mon Aug 12 22:25:46 2024 +0200 @@ -83,7 +83,9 @@ //#define HAL_USART_MODULE_ENABLED //#define HAL_IRDA_MODULE_ENABLED //#define HAL_SMARTCARD_MODULE_ENABLED -//#define HAL_WWDG_MODULE_ENABLED +#ifdef BOOTLOADER_STANDALONE +#define HAL_WWDG_MODULE_ENABLED +#endif //#define HAL_PCD_MODULE_ENABLED //#define HAL_HCD_MODULE_ENABLED #define HAL_SDRAM_MODULE_ENABLED diff -r 4e10a3e087a1 -r bc6c90e20d9e Discovery/Src/externLogbookFlash.c --- a/Discovery/Src/externLogbookFlash.c Mon Aug 12 22:23:03 2024 +0200 +++ b/Discovery/Src/externLogbookFlash.c Mon Aug 12 22:25:46 2024 +0200 @@ -115,16 +115,19 @@ /* Exported variables --------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ + +#ifndef BOOTLOADER_STANDALONE +static uint32_t entryPoint = 0; +static uint32_t LengthLeftSampleRead = 0; +static uint32_t actualPointerDevicedata_Read = DDSTART; +#endif + static uint32_t actualAddress = 0; static uint32_t preparedPageAddress = 0; static uint32_t closeSectorAddress = 0; -static uint32_t entryPoint = 0; - static uint32_t actualPointerHeader = 0; static uint32_t actualPointerSample = 0; -static uint32_t LengthLeftSampleRead = 0; static uint32_t actualPointerDevicedata = DDSTART; -static uint32_t actualPointerDevicedata_Read = DDSTART; static uint32_t actualPointerVPM = 0; static uint32_t actualPointerSettings = SETTINGSSTART; static uint32_t actualPointerFirmware = 0; @@ -133,9 +136,14 @@ /* Private function prototypes -----------------------------------------------*/ static void chip_unselect(void); static void chip_select(void); +#ifndef BOOTLOADER_STANDALONE static void error_led_on(void); static void error_led_off(void); - +static void ext_flash_decf_address_ring(uint8_t type); +static void ext_flash_disable_protection(void); +static _Bool ext_flash_test_remaining_space_of_page_empty(uint32_t pointer, uint16_t length); +static void ext_flash_set_to_begin_of_next_page(uint32_t *pointer, uint8_t type); +#endif static void write_spi(uint8_t data, uint8_t unselect_CS_afterwards); static uint8_t read_spi(uint8_t unselect_CS_afterwards); static void write_address(uint8_t unselect_CS_afterwards); @@ -143,7 +151,6 @@ static void wait_chip_not_busy(void); static void ext_flash_incf_address(uint8_t type); //void ext_flash_incf_address_ring(void); -static void ext_flash_decf_address_ring(uint8_t type); static void ext_flash_erase4kB(void); static void ext_flash_erase32kB(void); @@ -159,13 +166,11 @@ static void ef_hw_rough_delay_us(uint32_t delayUs); static void ef_erase_64K(uint32_t blocks); +#ifndef BOOTLOADER_STANDALONE static void ext_flash_overwrite_sample_without_erase(uint8_t *pSample, uint16_t length); - -static void ext_flash_disable_protection(void); +static void ext_flash_find_start(void); +#endif -static _Bool ext_flash_test_remaining_space_of_page_empty(uint32_t pointer, uint16_t length); -static void ext_flash_set_to_begin_of_next_page(uint32_t *pointer, uint8_t type); -static void ext_flash_find_start(void); /* Exported functions --------------------------------------------------------*/ @@ -1581,7 +1586,7 @@ } -#endif + static void ext_flash_disable_protection(void) { @@ -1596,7 +1601,7 @@ write_spi(status.uw,RELEASE); // new status */ } - +#endif void ext_flash_disable_protection_for_logbook(void) { @@ -1932,7 +1937,7 @@ } } - +#ifndef BOOTLOADER_STANDALONE static _Bool ext_flash_test_remaining_space_of_page_empty(uint32_t pointer, uint16_t length) { if((pointer & 0xFFF) == 0) @@ -2002,7 +2007,7 @@ if((*pointer < ringStart) || (*pointer >= ringStop)) *pointer = ringStart; } - +#endif static void ef_erase_64K(uint32_t blocks) { @@ -2027,7 +2032,7 @@ { HAL_GPIO_WritePin(EXTFLASH_CSB_GPIO_PORT,EXTFLASH_CSB_PIN,GPIO_PIN_RESET); // chip select } - +#ifndef BOOTLOADER_STANDALONE static void error_led_on(void) { HAL_GPIO_WritePin(OSCILLOSCOPE_GPIO_PORT,OSCILLOSCOPE_PIN,GPIO_PIN_SET); @@ -2037,7 +2042,7 @@ { HAL_GPIO_WritePin(OSCILLOSCOPE_GPIO_PORT,OSCILLOSCOPE_PIN,GPIO_PIN_RESET); } - +#endif static uint8_t read_spi(uint8_t unselect_CS_afterwards) { @@ -2150,7 +2155,7 @@ actualAddress = ringStart; } - +#ifndef BOOTLOADER_STANDALONE static void ext_flash_decf_address_ring(uint8_t type) { uint32_t ringStart, ringStop; @@ -2196,7 +2201,7 @@ else actualAddress -= 1; } - +#endif static void ef_hw_rough_delay_us(uint32_t delayUs) { @@ -2380,7 +2385,7 @@ } -/* + uint8_t ext_flash_erase_firmware_if_not_empty(void) { const uint8_t TESTSIZE_FW = 4; @@ -2431,4 +2436,4 @@ } else return 0; -}*/ +} diff -r 4e10a3e087a1 -r bc6c90e20d9e Discovery/Src/gfx_engine.c --- a/Discovery/Src/gfx_engine.c Mon Aug 12 22:23:03 2024 +0200 +++ b/Discovery/Src/gfx_engine.c Mon Aug 12 22:25:46 2024 +0200 @@ -36,7 +36,8 @@ /* Private types -------------------------------------------------------------*/ -#define RING_BUF_SIZE (5u) +#define RING_BUF_SIZE (5u) +#define MAX_COLOR_STRING_LENGTH (100u) typedef struct { @@ -248,7 +249,6 @@ backgroundHwStatus = LOGOSTOP; } - void GFX_build_hw_background_frame(void) { GFX_DrawCfgScreen tLogoTemp; @@ -316,7 +316,6 @@ */ } - void GFX_init(uint32_t * pDestinationOut) { frame[0].StartAddress = FBGlobalStart; @@ -358,6 +357,57 @@ DMA2D_at_work = 255; } +void GFX_init1_no_DMA(uint32_t * pDestinationOut, uint8_t blockFrames) +{ + frame[0].StartAddress = FBGlobalStart; + GFX_clear_frame_immediately(frame[0].StartAddress); + frame[0].status = CLEAR; + frame[0].caller = 0; + + for(int i=1;i= '\020') && (*pText <= '\032') && !minimal) settings.color = *pText - '\020'; else @@ -2187,15 +2241,13 @@ uint32_t found; uint32_t pText; uint16_t decodeUTF8; - uint8_t gfx_selected_language; #ifndef BOOTLOADER_STANDALONE + uint8_t gfx_selected_language = 0; SSettings *pSettings; pSettings = settingsGetPointer(); gfx_selected_language = pSettings->selected_language; - if(gfx_selected_language >= LANGUAGE_END) + if(gfx_selected_language >= LANGUAGE_END) gfx_selected_language = 0; #endif - gfx_selected_language = 0; - // ----------------------------- if(textId != (uint8_t)TXT_2BYTE) @@ -2204,23 +2256,27 @@ j = 0; for(i=(uint8_t)TXT_Language;i<(uint8_t)TXT_END;i++) { +#ifndef BOOTLOADER_STANDALONE if(text_array[j].code == textId) { found = 1; break; } +#endif j++; } if(!found) return cfg->Xdelta; // ----------------------------- +#ifndef BOOTLOADER_STANDALONE pText = (uint32_t)text_array[j].text[gfx_selected_language]; if(!pText) pText = (uint32_t)text_array[j].text[0]; else if(*(char*)pText == 0) pText = (uint32_t)text_array[j].text[0]; +#endif } // ----------------------------- else @@ -2231,14 +2287,17 @@ found = 0; for(j=0;j<(uint8_t)TXT2BYTE_END-(uint8_t)TXT2BYTE_START;j++) { +#ifndef BOOTLOADER_STANDALONE if((uint8_t)text_array2[j].code == (uint8_t)nextCharFor2Byte) { found = 1; break; } +#endif } if(!found) return cfg->Xdelta; +#ifndef BOOTLOADER_STANDALONE // ----------------------------- pText = (uint32_t)text_array2[j].text[gfx_selected_language]; if(!pText) @@ -2246,6 +2305,7 @@ else if(*(char*)pText == 0) pText = (uint32_t)text_array2[j].text[0]; +#endif } // ----------------------------- @@ -2684,7 +2744,10 @@ static uint32_t GFX_write_char(GFX_DrawCfgWindow* hgfx, GFX_CfgWriteString* cfg, uint8_t character, tFont *Font) { + +#ifndef BOOTLOADER_STANDALONE Font = GFX_Check_Extra_Font(character, Font); +#endif if(cfg->doubleSize) { return GFX_write_char_doubleSize(hgfx, cfg, character, Font); @@ -3005,6 +3068,7 @@ return cfg->Xdelta + width; } +#ifndef BOOTLOADER_STANDALONE /** ****************************************************************************** @@ -3104,7 +3168,7 @@ return counter; } - +#endif /** ****************************************************************************** * @brief GFX write Modify Ydelta for align. / calc Ydelta for start @@ -3125,23 +3189,22 @@ uint32_t result; uint32_t Xsum; uint32_t j; - uint8_t gfx_selected_language; uint32_t pText; uint16_t decodeUTF8; uint8_t tinyState = 0; /* used to identify the usage of tiny font */ tFont* ptargetFont; #ifndef BOOTLOADER_STANDALONE + uint8_t gfx_selected_language = 0; SSettings *pSettings; pSettings = settingsGetPointer(); gfx_selected_language = pSettings->selected_language; if(gfx_selected_language >= LANGUAGE_END) #endif - gfx_selected_language = 0; // ----------------------------- - +#ifndef BOOTLOADER_STANDALONE GFX_write__Modify_helper(cText,pTextInput,gfx_selected_language); - +#endif pText = (uint32_t)&cText[0]; Xsum = 0; j = 0; @@ -3218,28 +3281,29 @@ static uint32_t GFX_write__Modify_Xdelta__RightAlign(GFX_CfgWriteString* cfg, GFX_DrawCfgWindow* hgfx, const char *pTextInput) { - char cText[101]; uint32_t result; uint32_t Xsum; uint32_t j; tFont *font; - uint8_t gfx_selected_language; + char cText[101]; uint32_t pText; uint16_t decodeUTF8; uint8_t tinyState = 0; /* used to identify the usage of tiny font */ #ifndef BOOTLOADER_STANDALONE + uint8_t gfx_selected_language = 0; SSettings *pSettings; pSettings = settingsGetPointer(); gfx_selected_language = pSettings->selected_language; if(gfx_selected_language >= LANGUAGE_END) +#else + cText[0] = 0; #endif - gfx_selected_language = 0; // ----------------------------- - +#ifndef BOOTLOADER_STANDALONE GFX_write__Modify_helper(cText,pTextInput,gfx_selected_language); +#endif pText = (uint32_t)&cText[0]; - // ----------------------------- font = (tFont *)cfg->font; @@ -3917,6 +3981,7 @@ */ } +#ifndef BOOTLOADER_STANDALONE tFont* GFX_Check_Extra_Font(uint8_t character, tFont *Font) { uint32_t i; @@ -3946,11 +4011,13 @@ return Font; } - +#endif uint32_t GFX_Character_Width(uint8_t character, tFont *Font) { uint32_t i; +#ifndef BOOTLOADER_STANDALONE uint32_t found; +#endif for(i=0;ilength;i++) { @@ -3960,6 +4027,7 @@ } } +#ifndef BOOTLOADER_STANDALONE found = 0; if (Font == &FontT54) { @@ -3987,6 +4055,30 @@ } } } - +#endif return 0; } + +void Gfx_colorsscheme_mod(char *text, uint8_t alternativeColor) +{ + char *p = text; + uint8_t index = 0; + + while ((*p) && (index < MAX_COLOR_STRING_LENGTH)) + { + if (*p == '\020') + { + if(!GFX_is_colorschemeDiveStandard()) + { + *p = '\027'; + } + else if(alternativeColor != 0) + { + *p += alternativeColor; + } + } + p++; + index++; + } +} + diff -r 4e10a3e087a1 -r bc6c90e20d9e Discovery/Src/ostc.c --- a/Discovery/Src/ostc.c Mon Aug 12 22:23:03 2024 +0200 +++ b/Discovery/Src/ostc.c Mon Aug 12 22:25:46 2024 +0200 @@ -46,6 +46,7 @@ UART_HandleTypeDef UartIR_HUD_Handle; __IO ITStatus UartReady = RESET; +__IO ITStatus UartReadyHUD = RESET; /* Private types -------------------------------------------------------------*/ @@ -91,6 +92,42 @@ HAL_SPI_Init(&cpu2DmaSpi); } + +void MX_GPIO_Backlight_max_static_only_Init(void) +{ + GPIO_InitTypeDef GPIO_InitStruct; + TIM_BACKLIGHT_GPIO_ENABLE(); + + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL;//GPIO_PULLUP; /* should be normally high */ + GPIO_InitStruct.Speed = GPIO_SPEED_LOW; + + GPIO_InitStruct.Pin = TIM_BACKLIGHT_PIN; + HAL_GPIO_Init(TIM_BACKLIGHT_GPIO_PORT, &GPIO_InitStruct); + + HAL_GPIO_WritePin(TIM_BACKLIGHT_GPIO_PORT,TIM_BACKLIGHT_PIN,GPIO_PIN_SET); +} + + +void MX_GPIO_One_Button_only_Init(void) +{ + GPIO_InitTypeDef GPIO_InitStruct; + BUTTON_NEXT_GPIO_ENABLE(); + + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL;//GPIO_PULLUP; /* should be normally high */ + GPIO_InitStruct.Speed = GPIO_SPEED_LOW; + + GPIO_InitStruct.Pin = BUTTON_NEXT_PIN; + HAL_GPIO_Init(BUTTON_NEXT_GPIO_PORT, &GPIO_InitStruct); +} + + +GPIO_PinState MX_GPIO_Read_The_One_Button(void) +{ + return HAL_GPIO_ReadPin(BUTTON_NEXT_GPIO_PORT, BUTTON_NEXT_PIN); +} + void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct; @@ -228,6 +265,26 @@ #endif } + +void MX_SmallCPU_NO_Reset_Helper(void) +{ +#ifdef SMALLCPU_NRESET_PIN + GPIO_InitTypeDef GPIO_InitStruct; + + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_LOW; + + SMALLCPU_NRESET_GPIO_ENABLE(); + HAL_GPIO_Init(SMALLCPU_NRESET_GPIO_PORT, &GPIO_InitStruct); + HAL_GPIO_WritePin(SMALLCPU_NRESET_GPIO_PORT,SMALLCPU_NRESET_PIN,GPIO_PIN_SET); +// HAL_Delay(100); +// GPIO_InitStruct.Mode = GPIO_MODE_INPUT; +// HAL_GPIO_Init(SMALLCPU_NRESET_GPIO_PORT, &GPIO_InitStruct); +#endif +} + + void MX_SmallCPU_Reset_To_Standard(void) { #ifdef SMALLCPU_NRESET_PIN @@ -248,6 +305,23 @@ #endif } + +uint8_t MX_UART_ButtonAdjust(uint8_t *array) +{ +#ifdef USART_PIEZO + uint8_t answer[4]; + HAL_UART_Transmit(&UartPiezoTxHandle,array,4,1000); + HAL_UART_Receive(&UartPiezoTxHandle,answer,4,2000); + if( (answer[0] == array[0]) + &&(answer[1] == array[1]) + &&(answer[2] == array[2]) + &&(answer[3] == array[3])) + return 1; +#endif + return 0; +} + + void MX_UART_Init(void) { /*##-1- Configure the UART peripheral ######################################*/ @@ -311,7 +385,10 @@ else if(huart == &UartIR_HUD_Handle) { +#ifndef BOOTLOADER_STANDALONE tCCR_SetRXIndication(); +#endif + UartReadyHUD = SET; } } diff -r 4e10a3e087a1 -r bc6c90e20d9e Discovery/Src/settings.c --- a/Discovery/Src/settings.c Mon Aug 12 22:23:03 2024 +0200 +++ b/Discovery/Src/settings.c Mon Aug 12 22:25:46 2024 +0200 @@ -1858,7 +1858,7 @@ return (uint8_t)corrections; } - +#ifndef BOOTLOADER_STANDALONE /* always at 0x8080000, do not move -> bootloader access */ const SFirmwareData* firmwareDataGetPointer(void) { @@ -1872,7 +1872,7 @@ return (SHardwareData *)HARDWAREDATA_ADDRESS; } #endif - +#endif const SSettings* settingsGetPointerStandard(void) { return &SettingsStandard; @@ -3011,7 +3011,7 @@ RTEactualLow = low; } - +#ifndef BOOTLOADER_STANDALONE void getActualRTEandFONTversion(uint8_t *RTEhigh, uint8_t *RTElow, uint8_t *FONThigh, uint8_t *FONTlow) { if(RTEhigh && RTElow) @@ -3031,7 +3031,7 @@ { return hardwareDataGetPointer()->primaryLicence; } - +#endif void firmwareGetDate(RTC_DateTypeDef *SdateOutput) { diff -r 4e10a3e087a1 -r bc6c90e20d9e Discovery/Src/tComm.c --- a/Discovery/Src/tComm.c Mon Aug 12 22:23:03 2024 +0200 +++ b/Discovery/Src/tComm.c Mon Aug 12 22:25:46 2024 +0200 @@ -79,6 +79,7 @@ #else # include "base_bootloader.h" # include "firmwareEraseProgram.h" +# include "text_multilanguage.h" #endif #ifdef SPECIALPROGRAMM @@ -119,9 +120,11 @@ static BlueModTmpConfig_t BmTmpConfig = BM_CONFIG_OFF; /* Config BlueMod without storing the changes */ static uint8_t EvaluateBluetoothSignalStrength = 0; +#ifndef BOOTLOADER_STANDALONE static uint8_t RequestDisconnection = 0; /* Disconnection from remote device requested */ +static void tComm_Disconnect(void); +#endif /* Private function prototypes -----------------------------------------------*/ -static void tComm_Disconnect(void); static void tComm_Error_Handler(void); static uint8_t select_mode(uint8_t aRxByte); static uint8_t tComm_CheckAnswerOK(void); @@ -436,7 +439,7 @@ answer = HAL_OK; return answer; } - +#ifndef BOOTLOADER_STANDALONE void tComm_Disconnect() { uint8_t answer; @@ -482,7 +485,7 @@ MX_Bluetooth_PowerOff(); } } - +#endif uint8_t openComm(uint8_t aRxByte) { @@ -586,6 +589,8 @@ SSettings* pSettings = settingsGetPointer(); RTC_DateTypeDef sdatestructure; RTC_TimeTypeDef stimestructure; + uint16_t index; + uint32_t header_profileLength, OSTC3_profileLength; #else uint8_t dummyForBootloader[256] = {0}; #endif @@ -593,8 +598,6 @@ uint8_t aTxBuffer[128]; uint8_t aRxBuffer[68]; uint8_t answer; - uint16_t index; - uint32_t header_profileLength, OSTC3_profileLength; aTxBuffer[0] = type; aTxBuffer[1] = prompt4D4C(receiveStartByteUart); uint8_t tempHigh, tempLow; @@ -1451,9 +1454,9 @@ { return 0; } - uint32_t checksum = 256 * 256 * 256 *(uint32_t)sBuffer[0] + 256 * 256 * (uint32_t)sBuffer[1] + 256 * (uint32_t)sBuffer[2] + sBuffer[3]; + checksum = 256 * 256 * 256 *(uint32_t)sBuffer[0] + 256 * 256 * (uint32_t)sBuffer[1] + 256 * (uint32_t)sBuffer[2] + sBuffer[3]; // uint32_t checksumCalc = crc32c_checksum(pBuffer, length,0,0); - uint32_t checksumCalc = CRC_CalcBlockCRC((uint32_t*)pBuffer, length/4); + checksumCalc = CRC_CalcBlockCRC((uint32_t*)pBuffer, length/4); if(checksum != checksumCalc) {