Mercurial > public > ostc4
comparison BootLoader/Src/base_bootlader.c @ 969:81049905d829 Evo_2_23
Zusammenf?hren
| author | heinrichsweikamp |
|---|---|
| date | Sun, 19 Jan 2025 12:02:59 +0100 |
| parents | 58cc980ee848 |
| children | d29e752660c5 |
comparison
equal
deleted
inserted
replaced
| 968:b9a1710522b1 | 969:81049905d829 |
|---|---|
| 37 ============================================================================== | 37 ============================================================================== |
| 38 ##### bootloader specific ##### | 38 ##### bootloader specific ##### |
| 39 ============================================================================== | 39 ============================================================================== |
| 40 | 40 |
| 41 151130 hw sleep on button3 | 41 151130 hw sleep on button3 |
| 42 (MX_tell_reset_logik_alles_ok() + DataEX_call() in endlos loop) | 42 (MX_tell_reset_logik_alles_ok() + DataEX_call() in endless loop) |
| 43 | 43 |
| 44 ============================================================================== | 44 ============================================================================== |
| 45 ##### bootloader specific ##### | 45 ##### bootloader specific ##### |
| 46 ============================================================================== | 46 ============================================================================== |
| 47 | 47 |
| 87 with the NVIC_PRIORITYGROUP_2 setting. | 87 with the NVIC_PRIORITYGROUP_2 setting. |
| 88 | 88 |
| 89 ============================================================================== | 89 ============================================================================== |
| 90 ##### MainTask ##### | 90 ##### MainTask ##### |
| 91 ============================================================================== | 91 ============================================================================== |
| 92 [..] For everthing slow without importance to be 'in time'. | 92 [..] For everything slow without importance to be 'in time'. |
| 93 Like VPM and Buehlmann. | 93 Like VPM and Buehlmann. |
| 94 No sprintf and probably no GFX_SetFramesTopBottom() stuff neither. | 94 No sprintf and probably no GFX_SetFramesTopBottom() stuff neither. |
| 95 If sprintf is called while sprintf is executed it blows up everything. | 95 If sprintf is called while sprintf is executed it blows up everything. |
| 96 | 96 |
| 97 ============================================================================== | 97 ============================================================================== |
| 98 ##### Frames / the external SDRAM ##### | 98 ##### Frames / the external SDRAM ##### |
| 99 ============================================================================== | 99 ============================================================================== |
| 100 [..] The SDRAM is handled by getFrame() and releaseFrame(). | 100 [..] The SDRAM is handled by getFrame() and releaseFrame(). |
| 101 Each frame with 800*480*2 Bytes. | 101 Each frame with 800*480*2 Bytes. |
| 102 Be carefull to release every frame | 102 Be careful to release every frame |
| 103 otherwise there will be a memory leakage over time. | 103 otherwise there will be a memory leakage over time. |
| 104 housekeepingFrame() in the MainTask takes care of cleaning the frames. | 104 housekeepingFrame() in the MainTask takes care of cleaning the frames. |
| 105 All frames are filled with 0x00. This will be transparent with color of | 105 All frames are filled with 0x00. This will be transparent with color of |
| 106 CLUT_Font020 (is CLUT 0) if the alpha is set for a 16bit pair. | 106 CLUT_Font020 (is CLUT 0) if the alpha is set for a 16bit pair. |
| 107 housekeepingFrame() delays the cleaning of frames still used as screen | 107 housekeepingFrame() delays the cleaning of frames still used as screen |
| 125 | 125 |
| 126 (#) GFX_SetFramesTopBottom() and the subset | 126 (#) GFX_SetFramesTopBottom() and the subset |
| 127 GFX_SetFrameTop() + GFX_SetFrameBottom() | 127 GFX_SetFrameTop() + GFX_SetFrameBottom() |
| 128 Those do not change anything on the display but give commands to.. | 128 Those do not change anything on the display but give commands to.. |
| 129 (#) GFX_change_LTDC() The only place that changes the pointer. | 129 (#) GFX_change_LTDC() The only place that changes the pointer. |
| 130 This prevents erratic behaviour if several changes | 130 This prevents erratic behavior if several changes |
| 131 are made within one refresh rate of the screen. | 131 are made within one refresh rate of the screen. |
| 132 Is called in IRQ by PD4 and HAL_GPIO_EXTI_IRQHandler | 132 Is called in IRQ by PD4 and HAL_GPIO_EXTI_IRQHandler |
| 133 from VSYNC signal. | 133 from VSYNC signal. |
| 134 | 134 |
| 135 [..] Content | 135 [..] Content |
| 140 (#) Text by text_multilinguage.h/.c with one char | 140 (#) Text by text_multilinguage.h/.c with one char |
| 141 necessary only starting from '\x80' | 141 necessary only starting from '\x80' |
| 142 with automatic language switch by | 142 with automatic language switch by |
| 143 selected_language in SSettings | 143 selected_language in SSettings |
| 144 see openEdit_Language() in tMenuEditSystem.c | 144 see openEdit_Language() in tMenuEditSystem.c |
| 145 Therefore there are differnent functions | 145 Therefore there are different functions |
| 146 for example: | 146 for example: |
| 147 write_label_fix() for single char multilanguage | 147 write_label_fix() for single char multilanguage |
| 148 write_label_var() for strings that could include | 148 write_label_var() for strings that could include |
| 149 multilanguage as well | 149 multilanguage as well |
| 150 see GFX_write_string() to get an overview of the controls | 150 see GFX_write_string() to get an overview of the controls |
| 263 .versionSecond = 0, | 263 .versionSecond = 0, |
| 264 .versionThird = 1, | 264 .versionThird = 1, |
| 265 .versionBeta = 1, | 265 .versionBeta = 1, |
| 266 | 266 |
| 267 /* 4 bytes with trailing 0 */ | 267 /* 4 bytes with trailing 0 */ |
| 268 .signature = "cw", | 268 .signature = "mh", |
| 269 | 269 |
| 270 .release_year = 16, | 270 .release_year = 25, |
| 271 .release_month = 4, | 271 .release_month = 1, |
| 272 .release_day = 8, | 272 .release_day = 13, |
| 273 .release_sub = 0, | 273 .release_sub = 0, |
| 274 | 274 |
| 275 /* max 48 with trailing 0 */ | 275 /* max 48 with trailing 0 */ |
| 276 .release_info ="tComm with all", | 276 .release_info ="tComm with all", |
| 277 | 277 |
| 280 .magic[1] = FIRMWARE_MAGIC_SECOND, | 280 .magic[1] = FIRMWARE_MAGIC_SECOND, |
| 281 .magic[2] = FIRMWARE_MAGIC_FIRMWARE, /* the magic byte */ | 281 .magic[2] = FIRMWARE_MAGIC_FIRMWARE, /* the magic byte */ |
| 282 .magic[3] = FIRMWARE_MAGIC_END | 282 .magic[3] = FIRMWARE_MAGIC_END |
| 283 }; | 283 }; |
| 284 | 284 |
| 285 #if 0 | 285 const SHardwareData HardwareData __attribute__((section(".bootloader_hardware_data"))) = |
| 286 const SHardwareData HardwareData __attribute__((at(HARDWAREDATA_ADDRESS))) = { | 286 { |
| 287 | 287 |
| 288 // first 52 bytes | 288 // first 52 bytes |
| 289 .primarySerial = 0xFFFF, | 289 .primarySerial = 0xFFFF, |
| 290 .primaryLicence = 0xFF, | 290 .primaryLicence = 0x00, |
| 291 .revision8bit = 0xFF, | 291 .revision8bit = 0x02, |
| 292 .production_year = 0xFF, | 292 .production_year = 0x19, |
| 293 .production_month = 0xFF, | 293 .production_month = 0x01, |
| 294 .production_day = 0xFF, | 294 .production_day = 0x10, |
| 295 .production_bluetooth_name_set = 0xFF, | 295 .production_bluetooth_name_set = 0xFF, |
| 296 | 296 |
| 297 .production_info = { | 297 .production_info = { |
| 298 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, | 298 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x4F,0x53,0x54,0x43, |
| 299 0x20,0x35,0x20,0x65,0x6E,0x64,0x2D,0x32,0x30,0x32,0x34, | |
| 300 0x20,0x68,0x61,0x72,0x64,0x77,0x61,0x72,0x65,0x20,0x20, | |
| 301 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20}, | |
| 302 | |
| 303 /* 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, | |
| 299 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, | 304 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
| 300 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, | 305 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
| 301 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}, | 306 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}, |
| 302 | 307 */ |
| 303 // other 12 bytes (64 in total) | 308 // other 12 bytes (64 in total) |
| 304 .secondarySerial = 0xFFFF, | 309 .secondarySerial = 0xFFFF, |
| 305 .secondaryLicence = 0xFF, | 310 .secondaryLicence = 0xFF, |
| 306 .secondaryReason8bit = 0xFF, | 311 .secondaryReason8bit = 0xFF, |
| 307 .secondary_year = 0xFF, | 312 .secondary_year = 0xFF, |
| 308 .secondary_month = 0xFF, | 313 .secondary_month = 0xFF, |
| 309 .secondary_day = 0xFF, | 314 .secondary_day = 0xFF, |
| 310 .secondary_bluetooth_name_set = 0xFF, | 315 .secondary_bluetooth_name_set = 0xFF, |
| 311 .secondary_info = {0xFF,0xFF,0xFF,0xFF} | 316 .secondary_info = {0xFF,0xFF,0xFF,0xFF} |
| 312 }; | 317 }; |
| 313 #endif | 318 |
| 314 | 319 |
| 315 RTC_HandleTypeDef RtcHandle; | 320 RTC_HandleTypeDef RtcHandle; |
| 316 TIM_HandleTypeDef TimHandle; /* used in stm32f4xx_it.c too */ | 321 TIM_HandleTypeDef TimHandle; /* used in stm32f4xx_it.c too */ |
| 317 TIM_HandleTypeDef TimBacklightHandle; /* used in stm32f4xx_it.c too */ | 322 TIM_HandleTypeDef TimBacklightHandle; /* used in stm32f4xx_it.c too */ |
| 318 | 323 |
| 438 HAL_Init(); | 443 HAL_Init(); |
| 439 HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_2); | 444 HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_2); |
| 440 SystemClock_Config(); | 445 SystemClock_Config(); |
| 441 | 446 |
| 442 MX_GPIO_Init(); | 447 MX_GPIO_Init(); |
| 443 | |
| 444 /* feedback for the user | |
| 445 * aber sehr unsch�n beim Warmstart | |
| 446 * da das letzte Bild noch lange nachleuchtet */ | |
| 447 // MX_GPIO_Backlight_max_static_only_Init(); | |
| 448 | |
| 449 | 448 |
| 450 /* button press is only 40 to 50 us low */ | 449 /* button press is only 40 to 50 us low */ |
| 451 MX_GPIO_One_Button_only_Init(); | 450 MX_GPIO_One_Button_only_Init(); |
| 452 | 451 |
| 453 uint32_t i = 500000; | 452 uint32_t i = 500000; |
| 586 } | 585 } |
| 587 | 586 |
| 588 /* here comes the variable upper firmware loader */ | 587 /* here comes the variable upper firmware loader */ |
| 589 if((i == 0) && (status == HAL_OK)) | 588 if((i == 0) && (status == HAL_OK)) |
| 590 { | 589 { |
| 591 tInfo_newpage("load firmware2 data"); | 590 tInfo_newpage("load fontpack data"); |
| 592 uint8_t* pBuffer = (uint8_t*)((uint32_t)0xD0000000); /* blocked via GFX_init1_no_DMA */ | 591 uint8_t* pBuffer = (uint8_t*)((uint32_t)0xD0000000); /* blocked via GFX_init1_no_DMA */ |
| 593 firmware_load_result = ext_flash_read_firmware2(&pOffset, pBuffer,768000*2,0,0); | 592 firmware_load_result = ext_flash_read_firmware2(&pOffset, pBuffer,768000*2,0,0); |
| 594 | 593 |
| 595 if((firmware_load_result > 0) && (firmware_load_result + pOffset <= 1024000)) | 594 if((firmware_load_result > 0) && (firmware_load_result + pOffset <= 1024000)) |
| 596 { | 595 { |
| 658 } | 657 } |
| 659 } | 658 } |
| 660 | 659 |
| 661 if((i == 0) && (status == HAL_OK)) | 660 if((i == 0) && (status == HAL_OK)) |
| 662 { | 661 { |
| 663 tInfo_newpage("Done."); | 662 tInfo_newpage("done."); |
| 664 tInfo_write("Cleaning."); | 663 tInfo_write("cleaning."); |
| 665 ext_flash_erase_firmware_if_not_empty(); | 664 ext_flash_erase_firmware_if_not_empty(); |
| 666 ext_flash_erase_firmware2_if_not_empty(); | 665 ext_flash_erase_firmware2_if_not_empty(); |
| 667 tInfo_write("Reset device."); | 666 tInfo_write("reset device."); |
| 668 reset_to_firmware_using_Watchdog(); | 667 reset_to_firmware_using_Watchdog(); |
| 669 } | 668 } |
| 670 | 669 |
| 671 ptr = 0; | 670 ptr = 0; |
| 672 textVersion[ptr++] = '\020'; | 671 textVersion[ptr++] = '\020'; |
| 707 TIM_init(); | 706 TIM_init(); |
| 708 MX_UART_Init(); | 707 MX_UART_Init(); |
| 709 MX_Bluetooth_PowerOn(); | 708 MX_Bluetooth_PowerOn(); |
| 710 tComm_init(); | 709 tComm_init(); |
| 711 | 710 |
| 712 tInfo_button_text("Exit","","Sleep"); | 711 tInfo_button_text("exit","","sleep"); |
| 713 tInfo_newpage("Bootloader 240812"); | 712 tInfo_newpage("bootloader 250113"); |
| 714 tInfo_write("start bluetooth"); | 713 tInfo_write("start bluetooth"); |
| 715 tInfo_write(""); | 714 tInfo_write(""); |
| 716 tInfo_write(textVersion); | 715 tInfo_write(textVersion); |
| 717 if(tComm_Set_Bluetooth_Name(0) == 0xFF) | 716 if(tComm_Set_Bluetooth_Name(0) == 0xFF) |
| 718 { | 717 { |
| 719 tInfo_write("Init bluetooth"); | 718 tInfo_write("init bluetooth"); |
| 720 tComm_StartBlueModBaseInit(); | 719 tComm_StartBlueModBaseInit(); |
| 721 } | 720 } |
| 722 else | 721 else |
| 723 { | 722 { |
| 724 tInfo_write("Bluetooth set"); | 723 tInfo_write("bluetooth set"); |
| 725 tComm_StartBlueModConfig(); | 724 tComm_StartBlueModConfig(); |
| 726 } | 725 } |
| 727 | 726 |
| 728 set_globalState_Base(); | 727 set_globalState_Base(); |
| 729 | 728 |
| 773 if(returnFromCommCleanUpRequest) | 772 if(returnFromCommCleanUpRequest) |
| 774 { | 773 { |
| 775 tComm_exit(); | 774 tComm_exit(); |
| 776 returnFromCommCleanUpRequest = 0; | 775 returnFromCommCleanUpRequest = 0; |
| 777 GFX_hwBackgroundOn(); | 776 GFX_hwBackgroundOn(); |
| 778 tInfo_button_text("Exit","","Sleep"); | 777 tInfo_button_text("exit","","sleep"); |
| 779 tInfo_newpage("bluetooth disonnected"); | 778 tInfo_newpage("bluetooth disonnected"); |
| 780 tInfo_write(""); | 779 tInfo_write(""); |
| 781 tInfo_write(""); | 780 tInfo_write(""); |
| 782 tInfo_write(""); | 781 tInfo_write(""); |
| 783 tInfo_write(""); | 782 tInfo_write(""); |
| 819 time_without_button_pressed_deciseconds = 0; | 818 time_without_button_pressed_deciseconds = 0; |
| 820 | 819 |
| 821 if(GFX_logoStatus() != 0) | 820 if(GFX_logoStatus() != 0) |
| 822 return; | 821 return; |
| 823 | 822 |
| 824 if(GPIO_Pin == BUTTON_BACK_PIN) // links | 823 if(GPIO_Pin == BUTTON_BACK_PIN) // left |
| 825 action = ACTION_BUTTON_BACK; | 824 action = ACTION_BUTTON_BACK; |
| 826 else | 825 else |
| 827 if(GPIO_Pin == BUTTON_ENTER_PIN) // mitte | 826 if(GPIO_Pin == BUTTON_ENTER_PIN) // center |
| 828 action = ACTION_BUTTON_ENTER; | 827 action = ACTION_BUTTON_ENTER; |
| 829 else | 828 else |
| 830 if(GPIO_Pin == BUTTON_NEXT_PIN) // rechts | 829 if(GPIO_Pin == BUTTON_NEXT_PIN) // right |
| 831 action = ACTION_BUTTON_NEXT; | 830 action = ACTION_BUTTON_NEXT; |
| 832 #ifdef BUTTON_CUSTOM_PIN | 831 #ifdef BUTTON_CUSTOM_PIN |
| 833 else | 832 else |
| 834 if(GPIO_Pin == BUTTON_CUSTOM_PIN) // extra | 833 if(GPIO_Pin == BUTTON_CUSTOM_PIN) // extra |
| 835 action = ACTION_BUTTON_CUSTOM; | 834 action = ACTION_BUTTON_CUSTOM; |
| 1250 { | 1249 { |
| 1251 } | 1250 } |
| 1252 } | 1251 } |
| 1253 | 1252 |
| 1254 /** | 1253 /** |
| 1255 * @brief Perform the SDRAM exernal memory inialization sequence | 1254 * @brief Perform the SDRAM external memory initialization sequence |
| 1256 * @param hsdram: SDRAM handle | 1255 * @param hsdram: SDRAM handle |
| 1257 * @param Command: Pointer to SDRAM command structure | 1256 * @param Command: Pointer to SDRAM command structure |
| 1258 * @retval None | 1257 * @retval None |
| 1259 */ | 1258 */ |
| 1260 static void SDRAM_Initialization_Sequence(SDRAM_HandleTypeDef *hsdram, FMC_SDRAM_CommandTypeDef *Command) | 1259 static void SDRAM_Initialization_Sequence(SDRAM_HandleTypeDef *hsdram, FMC_SDRAM_CommandTypeDef *Command) |
| 1314 | 1313 |
| 1315 /* | 1314 /* |
| 1316 static void DualBoot(void) | 1315 static void DualBoot(void) |
| 1317 { | 1316 { |
| 1318 // Set BFB2 bit to enable boot from Flash Bank2 | 1317 // Set BFB2 bit to enable boot from Flash Bank2 |
| 1319 // Allow Access to Flash control registers and user Falsh | 1318 // Allow Access to Flash control registers and user Flash |
| 1320 HAL_FLASH_Unlock(); | 1319 HAL_FLASH_Unlock(); |
| 1321 | 1320 |
| 1322 // Allow Access to option bytes sector | 1321 // Allow Access to option bytes sector |
| 1323 HAL_FLASH_OB_Unlock(); | 1322 HAL_FLASH_OB_Unlock(); |
| 1324 | 1323 |
| 1364 */ | 1363 */ |
| 1365 | 1364 |
| 1366 | 1365 |
| 1367 /** | 1366 /** |
| 1368 * @brief DMA2D configuration. | 1367 * @brief DMA2D configuration. |
| 1369 * @note This function Configure tha DMA2D peripheral : | 1368 * @note This function Configure the DMA2D peripheral : |
| 1370 * 1) Configure the transfer mode : memory to memory W/ pixel format conversion | 1369 * 1) Configure the transfer mode : memory to memory W/ pixel format conversion |
| 1371 * 2) Configure the output color mode as ARGB4444 | 1370 * 2) Configure the output color mode as ARGB4444 |
| 1372 * 3) Configure the output memory address at SRAM memory | 1371 * 3) Configure the output memory address at SRAM memory |
| 1373 * 4) Configure the data size : 320x120 (pixels) | 1372 * 4) Configure the data size : 320x120 (pixels) |
| 1374 * 5) Configure the input color mode as ARGB8888 | 1373 * 5) Configure the input color mode as ARGB8888 |
