增加时间重置限制(海思修改
authorcaisking <caiyqm@qq.com>
Thu, 30 Apr 2026 08:44:29 +0000 (16:44 +0800)
committercaisking <caiyqm@qq.com>
Thu, 30 Apr 2026 08:44:29 +0000 (16:44 +0800)
code/sdk/bootloader/flashboot/brandy/boot_ulp/boot_ulp.c

index bfe411a..7e454b7 100644 (file)
@@ -43,38 +43,23 @@ calendar_regs_t *g_calendar_reg = SSB_CALENDAR_BASE_ADDR;
 #else\r
     static uint64_t uapi_ulp_systick_get_count(void)\r
     {\r
+        #define ULP_SYSTICK_GET_DELAY_US 60UL\r
         uint64_t count = 0;\r
-        static uint64_t s_last_count = 0;\r
-        uint16_t lock_before = readw(ULP_LOCK_REG);\r
-        uint16_t lock_after_set = (uint16_t)(lock_before | 0x1);\r
-        writew(ULP_LOCK_REG, lock_after_set);\r
-\r
-        uint16_t v0 = readw(ULP_SYSTICK_VAL0);\r
-        uint16_t v1 = readw(ULP_SYSTICK_VAL1);\r
-        uint16_t v2 = readw(ULP_SYSTICK_VAL2);\r
-        uint16_t v3 = readw(ULP_SYSTICK_VAL3);\r
-\r
-        count = ((uint64_t)v3 << 48U) |\r
-                ((uint64_t)v2 << 32U) |\r
-                ((uint64_t)v1 << 16U) |\r
-                ((uint64_t)v0);\r
-\r
-        uint16_t lock_before_restore = readw(ULP_LOCK_REG);\r
-        writew(ULP_LOCK_REG, lock_before);\r
-        uint16_t lock_after_restore = readw(ULP_LOCK_REG);\r
-\r
-        PRINT("[ULP_CNT][boot] lock_before=0x%04x lock_set=0x%04x lock_before_restore=0x%04x lock_after_restore=0x%04x "\r
-              "v3=0x%04x v2=0x%04x v1=0x%04x v0=0x%04x count=0x%016llx (%llu)\r\n",\r
-              lock_before, lock_after_set, lock_before_restore, lock_after_restore,\r
-              v3, v2, v1, v0,\r
-              (unsigned long long)count, (unsigned long long)count);\r
-\r
-        if (s_last_count != 0 && count < s_last_count) {\r
-            PRINT("[ULP_CNT][WARN][boot] rollback! last=0x%016llx now=0x%016llx\r\n",\r
-                  (unsigned long long)s_last_count, (unsigned long long)count);\r
-        }\r
-        s_last_count = count;\r
+        unsigned int irq_sts = osal_irq_lock();\r
+        \r
+        uint64_t before = readw(0x5702c510);\r
+        before = before | 0x01;\r
+        writew(0x5702c510,before); \r
+        // writew(ULP_LOCK_REG, 0x1);\r
+\r
+        uapi_tcxo_delay_us(ULP_SYSTICK_GET_DELAY_US);\r
 \r
+        count = (uint64_t)readw(ULP_SYSTICK_VAL3) << 48U;\r
+        count |= (uint64_t)readw(ULP_SYSTICK_VAL2) << 32U;\r
+        count |= (uint64_t)readw(ULP_SYSTICK_VAL1) << 16U;\r
+        count |= (uint64_t)readw(ULP_SYSTICK_VAL0);\r
+        writew(ULP_LOCK_REG, 0x0);\r
+        osal_irq_restore(irq_sts);\r
         return count;\r
     }\r
 #endif\r