flipperzero-firmware_official_dev 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. commit 1ef70c0bb4db8c4b7f537b39195fcba419af023b
  2. Author: hedger <hedger@users.noreply.github.com>
  3. Date: Mon Apr 24 11:19:36 2023 +0400
  4. [FL-3280] cubewb: downgraded to v1.15.0 (#2605)
  5. * cubewb: downgraded to v1.15.0
  6. * hal: updated f18 symbols to match LL
  7. * hal: flash: use furi_hal_cortex_timer for timeouts
  8. * scripts: fixed cube version validation from config file
  9. * hal: flash: added 3 seconds timeout when waiting for C2 to unlock flash controller. On timeout, triggers furi_check
  10. * nfc: fixed missing interrupt setup on multiple platformSetIrqCallback() invocations
  11. * hal: gpio: don't trigger furi_check on furi_hal_gpio_add_int_callback() with same parameters
  12. * Reverted NFC fixes - will be in a separate PR
  13. * scripts: storage: fixed exception handler for paths
  14. diff --git a/fbt_options.py b/fbt_options.py
  15. index 25e84afde..4fd7ef496 100644
  16. --- a/fbt_options.py
  17. +++ b/fbt_options.py
  18. @@ -20,7 +20,7 @@ DIST_SUFFIX = "local"
  19. COPRO_OB_DATA = "scripts/ob.data"
  20. # Must match lib/STM32CubeWB version
  21. -COPRO_CUBE_VERSION = "1.16.0"
  22. +COPRO_CUBE_VERSION = "1.15.0"
  23. COPRO_CUBE_DIR = "lib/STM32CubeWB"
  24. diff --git a/firmware/targets/f18/api_symbols.csv b/firmware/targets/f18/api_symbols.csv
  25. index 4ee3d8636..eb2d6f43f 100644
  26. --- a/firmware/targets/f18/api_symbols.csv
  27. +++ b/firmware/targets/f18/api_symbols.csv
  28. @@ -199,8 +199,8 @@ Function,-,LL_EXTI_StructInit,void,LL_EXTI_InitTypeDef*
  29. Function,-,LL_GPIO_DeInit,ErrorStatus,GPIO_TypeDef*
  30. Function,+,LL_GPIO_Init,ErrorStatus,"GPIO_TypeDef*, LL_GPIO_InitTypeDef*"
  31. Function,-,LL_GPIO_StructInit,void,LL_GPIO_InitTypeDef*
  32. -Function,-,LL_I2C_DeInit,ErrorStatus,const I2C_TypeDef*
  33. -Function,+,LL_I2C_Init,ErrorStatus,"I2C_TypeDef*, const LL_I2C_InitTypeDef*"
  34. +Function,-,LL_I2C_DeInit,ErrorStatus,I2C_TypeDef*
  35. +Function,+,LL_I2C_Init,ErrorStatus,"I2C_TypeDef*, LL_I2C_InitTypeDef*"
  36. Function,-,LL_I2C_StructInit,void,LL_I2C_InitTypeDef*
  37. Function,-,LL_Init1msTick,void,uint32_t
  38. Function,+,LL_LPTIM_DeInit,ErrorStatus,LPTIM_TypeDef*
  39. diff --git a/firmware/targets/f7/api_symbols.csv b/firmware/targets/f7/api_symbols.csv
  40. index a2d70e7f8..d0c6b36ad 100644
  41. --- a/firmware/targets/f7/api_symbols.csv
  42. +++ b/firmware/targets/f7/api_symbols.csv
  43. @@ -231,8 +231,8 @@ Function,-,LL_EXTI_StructInit,void,LL_EXTI_InitTypeDef*
  44. Function,-,LL_GPIO_DeInit,ErrorStatus,GPIO_TypeDef*
  45. Function,+,LL_GPIO_Init,ErrorStatus,"GPIO_TypeDef*, LL_GPIO_InitTypeDef*"
  46. Function,-,LL_GPIO_StructInit,void,LL_GPIO_InitTypeDef*
  47. -Function,-,LL_I2C_DeInit,ErrorStatus,const I2C_TypeDef*
  48. -Function,+,LL_I2C_Init,ErrorStatus,"I2C_TypeDef*, const LL_I2C_InitTypeDef*"
  49. +Function,-,LL_I2C_DeInit,ErrorStatus,I2C_TypeDef*
  50. +Function,+,LL_I2C_Init,ErrorStatus,"I2C_TypeDef*, LL_I2C_InitTypeDef*"
  51. Function,-,LL_I2C_StructInit,void,LL_I2C_InitTypeDef*
  52. Function,-,LL_Init1msTick,void,uint32_t
  53. Function,+,LL_LPTIM_DeInit,ErrorStatus,LPTIM_TypeDef*
  54. diff --git a/firmware/targets/f7/ble_glue/ble_app.c b/firmware/targets/f7/ble_glue/ble_app.c
  55. index cc6065b97..a325830cf 100644
  56. --- a/firmware/targets/f7/ble_glue/ble_app.c
  57. +++ b/firmware/targets/f7/ble_glue/ble_app.c
  58. @@ -18,8 +18,8 @@ PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static TL_CmdPacket_t ble_app_cmd_buffer;
  59. PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static uint32_t ble_app_nvm[BLE_NVM_SRAM_SIZE];
  60. _Static_assert(
  61. - sizeof(SHCI_C2_Ble_Init_Cmd_Packet_t) == 58,
  62. - "Ble stack config structure size mismatch (check new config options - last updated for v.1.16.0)");
  63. + sizeof(SHCI_C2_Ble_Init_Cmd_Packet_t) == 57,
  64. + "Ble stack config structure size mismatch (check new config options - last updated for v.1.15.0)");
  65. typedef struct {
  66. FuriMutex* hci_mtx;
  67. diff --git a/firmware/targets/f7/furi_hal/furi_hal_flash.c b/firmware/targets/f7/furi_hal/furi_hal_flash.c
  68. index d2dbff55f..464d88d95 100644
  69. --- a/firmware/targets/f7/furi_hal/furi_hal_flash.c
  70. +++ b/firmware/targets/f7/furi_hal/furi_hal_flash.c
  71. @@ -1,6 +1,7 @@
  72. #include <furi_hal_flash.h>
  73. #include <furi_hal_bt.h>
  74. #include <furi_hal_power.h>
  75. +#include <furi_hal_cortex.h>
  76. #include <furi.h>
  77. #include <ble/ble.h>
  78. #include <interface/patterns/ble_thread/shci/shci.h>
  79. @@ -26,6 +27,16 @@
  80. #define FURI_HAL_FLASH_OPT_KEY2 0x4C5D6E7F
  81. #define FURI_HAL_FLASH_OB_TOTAL_WORDS (0x80 / (sizeof(uint32_t) * 2))
  82. +/* lib/STM32CubeWB/Projects/P-NUCLEO-WB55.Nucleo/Applications/BLE/BLE_RfWithFlash/Core/Src/flash_driver.c
  83. + * ProcessSingleFlashOperation, quote:
  84. + > In most BLE application, the flash should not be blocked by the CPU2 longer than FLASH_TIMEOUT_VALUE (1000ms)
  85. + > However, it could be that for some marginal application, this time is longer.
  86. + > ... there is no other way than waiting the operation to be completed.
  87. + > If for any reason this test is never passed, this means there is a failure in the system and there is no other
  88. + > way to recover than applying a device reset.
  89. + */
  90. +#define FURI_HAL_FLASH_C2_LOCK_TIMEOUT_MS 3000u /* 3 seconds */
  91. +
  92. #define IS_ADDR_ALIGNED_64BITS(__VALUE__) (((__VALUE__)&0x7U) == (0x00UL))
  93. #define IS_FLASH_PROGRAM_ADDRESS(__VALUE__) \
  94. (((__VALUE__) >= FLASH_BASE) && ((__VALUE__) <= (FLASH_BASE + FLASH_SIZE - 8UL)) && \
  95. @@ -131,9 +142,11 @@ static void furi_hal_flash_begin_with_core2(bool erase_flag) {
  96. for(volatile uint32_t i = 0; i < 35; i++)
  97. ;
  98. + FuriHalCortexTimer timer = furi_hal_cortex_timer_get(FURI_HAL_FLASH_C2_LOCK_TIMEOUT_MS * 1000);
  99. while(true) {
  100. /* Wait till flash controller become usable */
  101. while(LL_FLASH_IsActiveFlag_OperationSuspended()) {
  102. + furi_check(!furi_hal_cortex_timer_is_expired(timer));
  103. furi_thread_yield();
  104. };
  105. @@ -143,6 +156,7 @@ static void furi_hal_flash_begin_with_core2(bool erase_flag) {
  106. /* Actually we already have mutex for it, but specification is specification */
  107. if(LL_HSEM_IsSemaphoreLocked(HSEM, CFG_HW_BLOCK_FLASH_REQ_BY_CPU1_SEMID)) {
  108. taskEXIT_CRITICAL();
  109. + furi_check(!furi_hal_cortex_timer_is_expired(timer));
  110. furi_thread_yield();
  111. continue;
  112. }
  113. @@ -150,6 +164,7 @@ static void furi_hal_flash_begin_with_core2(bool erase_flag) {
  114. /* Take sempahopre and prevent core2 from anything funky */
  115. if(LL_HSEM_1StepLock(HSEM, CFG_HW_BLOCK_FLASH_REQ_BY_CPU2_SEMID) != 0) {
  116. taskEXIT_CRITICAL();
  117. + furi_check(!furi_hal_cortex_timer_is_expired(timer));
  118. furi_thread_yield();
  119. continue;
  120. }
  121. @@ -231,17 +246,13 @@ static void furi_hal_flush_cache(void) {
  122. bool furi_hal_flash_wait_last_operation(uint32_t timeout) {
  123. uint32_t error = 0;
  124. - uint32_t countdown = 0;
  125. /* Wait for the FLASH operation to complete by polling on BUSY flag to be reset.
  126. Even if the FLASH operation fails, the BUSY flag will be reset and an error
  127. flag will be set */
  128. - countdown = timeout;
  129. + FuriHalCortexTimer timer = furi_hal_cortex_timer_get(timeout * 1000);
  130. while(READ_BIT(FLASH->SR, FLASH_SR_BSY)) {
  131. - if(LL_SYSTICK_IsActiveCounterFlag()) {
  132. - countdown--;
  133. - }
  134. - if(countdown == 0) {
  135. + if(furi_hal_cortex_timer_is_expired(timer)) {
  136. return false;
  137. }
  138. }
  139. @@ -264,12 +275,9 @@ bool furi_hal_flash_wait_last_operation(uint32_t timeout) {
  140. CLEAR_BIT(FLASH->SR, error);
  141. /* Wait for control register to be written */
  142. - countdown = timeout;
  143. + timer = furi_hal_cortex_timer_get(timeout * 1000);
  144. while(READ_BIT(FLASH->SR, FLASH_SR_CFGBSY)) {
  145. - if(LL_SYSTICK_IsActiveCounterFlag()) {
  146. - countdown--;
  147. - }
  148. - if(countdown == 0) {
  149. + if(furi_hal_cortex_timer_is_expired(timer)) {
  150. return false;
  151. }
  152. }
  153. diff --git a/lib/STM32CubeWB b/lib/STM32CubeWB
  154. index 06b8133fa..c4cec8ae5 160000
  155. --- a/lib/STM32CubeWB
  156. +++ b/lib/STM32CubeWB
  157. @@ -1 +1 @@
  158. -Subproject commit 06b8133fa295474507b55b1a5695d4b8bf804ed6
  159. +Subproject commit c4cec8ae57a79e949a184cd0b4117a008a0a25a7
  160. diff --git a/scripts/fbt_tools/fbt_dist.py b/scripts/fbt_tools/fbt_dist.py
  161. index f0b443486..d2808419c 100644
  162. --- a/scripts/fbt_tools/fbt_dist.py
  163. +++ b/scripts/fbt_tools/fbt_dist.py
  164. @@ -112,6 +112,8 @@ def DistCommand(env, name, source, **kw):
  165. def generate(env):
  166. + if not env["VERBOSE"]:
  167. + env.SetDefault(COPROCOMSTR="\tCOPRO\t${TARGET}")
  168. env.AddMethod(AddFwProject)
  169. env.AddMethod(DistCommand)
  170. env.AddMethod(AddOpenOCDFlashTarget)
  171. @@ -147,7 +149,7 @@ def generate(env):
  172. '--stack_file="${COPRO_STACK_BIN}" '
  173. "--stack_addr=${COPRO_STACK_ADDR} ",
  174. ],
  175. - "\tCOPRO\t${TARGET}",
  176. + "$COPROCOMSTR",
  177. )
  178. ),
  179. }
  180. diff --git a/scripts/flipper/assets/copro.py b/scripts/flipper/assets/copro.py
  181. index b61ac0329..e0375b51f 100644
  182. --- a/scripts/flipper/assets/copro.py
  183. +++ b/scripts/flipper/assets/copro.py
  184. @@ -34,7 +34,7 @@ class Copro:
  185. self.mcu_copro = None
  186. self.logger = logging.getLogger(self.__class__.__name__)
  187. - def loadCubeInfo(self, cube_dir, cube_version):
  188. + def loadCubeInfo(self, cube_dir, reference_cube_version):
  189. if not os.path.isdir(cube_dir):
  190. raise Exception(f'"{cube_dir}" doesn\'t exists')
  191. self.cube_dir = cube_dir
  192. @@ -50,7 +50,7 @@ class Copro:
  193. if not cube_version or not cube_version.startswith("FW.WB"):
  194. raise Exception(f"Incorrect Cube package or version info")
  195. cube_version = cube_version.replace("FW.WB.", "", 1)
  196. - if cube_version != cube_version:
  197. + if cube_version != reference_cube_version:
  198. raise Exception(f"Unsupported cube version")
  199. self.version = cube_version
  200. diff --git a/scripts/flipper/storage.py b/scripts/flipper/storage.py
  201. index 7b56ee0d0..cff32ceb1 100644
  202. --- a/scripts/flipper/storage.py
  203. +++ b/scripts/flipper/storage.py
  204. @@ -335,7 +335,9 @@ class FlipperStorage:
  205. def _check_no_error(self, response, path=None):
  206. if self.has_error(response):
  207. - raise FlipperStorageException.from_error_code(self.get_error(response))
  208. + raise FlipperStorageException.from_error_code(
  209. + path, self.get_error(response)
  210. + )
  211. def size(self, path: str):
  212. """file size on Flipper"""