From: caisking Date: Thu, 30 Apr 2026 08:44:29 +0000 (+0800) Subject: 增加时间重置限制(海思修改 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=10ab8571fcad68876ad0c704f0b8e97117eab0f9;p=mirrors%2FFD230.git 增加时间重置限制(海思修改 --- diff --git a/code/sdk/bootloader/flashboot/brandy/boot_ulp/boot_ulp.c b/code/sdk/bootloader/flashboot/brandy/boot_ulp/boot_ulp.c index bfe411af9..7e454b75e 100644 --- a/code/sdk/bootloader/flashboot/brandy/boot_ulp/boot_ulp.c +++ b/code/sdk/bootloader/flashboot/brandy/boot_ulp/boot_ulp.c @@ -43,38 +43,23 @@ calendar_regs_t *g_calendar_reg = SSB_CALENDAR_BASE_ADDR; #else static uint64_t uapi_ulp_systick_get_count(void) { + #define ULP_SYSTICK_GET_DELAY_US 60UL uint64_t count = 0; - static uint64_t s_last_count = 0; - uint16_t lock_before = readw(ULP_LOCK_REG); - uint16_t lock_after_set = (uint16_t)(lock_before | 0x1); - writew(ULP_LOCK_REG, lock_after_set); - - uint16_t v0 = readw(ULP_SYSTICK_VAL0); - uint16_t v1 = readw(ULP_SYSTICK_VAL1); - uint16_t v2 = readw(ULP_SYSTICK_VAL2); - uint16_t v3 = readw(ULP_SYSTICK_VAL3); - - count = ((uint64_t)v3 << 48U) | - ((uint64_t)v2 << 32U) | - ((uint64_t)v1 << 16U) | - ((uint64_t)v0); - - uint16_t lock_before_restore = readw(ULP_LOCK_REG); - writew(ULP_LOCK_REG, lock_before); - uint16_t lock_after_restore = readw(ULP_LOCK_REG); - - PRINT("[ULP_CNT][boot] lock_before=0x%04x lock_set=0x%04x lock_before_restore=0x%04x lock_after_restore=0x%04x " - "v3=0x%04x v2=0x%04x v1=0x%04x v0=0x%04x count=0x%016llx (%llu)\r\n", - lock_before, lock_after_set, lock_before_restore, lock_after_restore, - v3, v2, v1, v0, - (unsigned long long)count, (unsigned long long)count); - - if (s_last_count != 0 && count < s_last_count) { - PRINT("[ULP_CNT][WARN][boot] rollback! last=0x%016llx now=0x%016llx\r\n", - (unsigned long long)s_last_count, (unsigned long long)count); - } - s_last_count = count; + unsigned int irq_sts = osal_irq_lock(); + + uint64_t before = readw(0x5702c510); + before = before | 0x01; + writew(0x5702c510,before); + // writew(ULP_LOCK_REG, 0x1); + + uapi_tcxo_delay_us(ULP_SYSTICK_GET_DELAY_US); + count = (uint64_t)readw(ULP_SYSTICK_VAL3) << 48U; + count |= (uint64_t)readw(ULP_SYSTICK_VAL2) << 32U; + count |= (uint64_t)readw(ULP_SYSTICK_VAL1) << 16U; + count |= (uint64_t)readw(ULP_SYSTICK_VAL0); + writew(ULP_LOCK_REG, 0x0); + osal_irq_restore(irq_sts); return count; } #endif