Преглед на файлове

更新fastboot工程
优化当程序进入fastboot工程后iram数据丢失的问题。

helen преди 3 месеца
родител
ревизия
02d6f4702b
променени са 2 файла, в които са добавени 33 реда и са изтрити 4 реда
  1. 6 2
      amt630hv160-fastboot/fastboot.icf
  2. 27 2
      amt630hv160-fastboot/src/ArkmicroFiles/libcpu-amt630hv160/source/amt630hv160_rtc.c

+ 6 - 2
amt630hv160-fastboot/fastboot.icf

@@ -8,6 +8,8 @@ define symbol __ICFEDIT_region_ROM_start__ = 0x0100000;
 define symbol __ICFEDIT_region_ROM_end__   = 0x0101FFF;
 define symbol __ICFEDIT_region_RAM_start__ = 0x0104000;
 define symbol __ICFEDIT_region_RAM_end__   = 0x0107FFF;
+define symbol __ICFEDIT_region_RELOCATE_start__ = 0x00108000;
+define symbol __ICFEDIT_region_RELOCATE_end__   = 0x0010ffff;
 
 /*-Sizes-*/
 define symbol __ICFEDIT_size_cstack__ = 0x1000;
@@ -50,13 +52,14 @@ define region ROM_region_privileged     = mem:[from __reigon_ROM_privileged_star
 define region ROM_region_unprivileged   = mem:[from __reigon_ROM_unprivileged_start__ to __reigon_ROM_unprivileged_end__];
 define region RAM_region_privileged     = mem:[from __region_RAM_privileged_start__   to __region_RAM_privileged_end__];
 define region RAM_region_unprivileged   = mem:[from __region_RAM_unprivileged_start__   to __region_RAM_unprivileged_end__];
+define region RELOCATE_region           = mem:[from __ICFEDIT_region_RELOCATE_start__ to __ICFEDIT_region_RELOCATE_end__];
 
 /* Stack and Heap. */
 define block CSTACK    with alignment = 8, size = __ICFEDIT_size_cstack__   { };
 define block HEAP      with alignment = 8, size = __ICFEDIT_size_heap__     { };
 
 /* Initialization. */
-initialize by copy { readwrite };
+initialize by copy { readwrite, section realocate_functions };
 do not initialize  { section .noinit };
 do not initialize  { section privileged_data };
 
@@ -79,4 +82,5 @@ place in ROM_region_privileged      { readonly section privileged_functions };
 place in ROM_region_unprivileged    { readonly };
 place in RAM_region_privileged      { readwrite section privileged_data };
 place in RAM_region_unprivileged    { readwrite,
-                                      block CSTACK, block HEAP };
+                                      block CSTACK, block HEAP };
+place in RELOCATE_region	        { readwrite section realocate_functions };

+ 27 - 2
amt630hv160-fastboot/src/ArkmicroFiles/libcpu-amt630hv160/source/amt630hv160_rtc.c

@@ -78,6 +78,29 @@ void RTC_SetWatchdog(eRTCWdtTmo tmo, int enable)
 		RTC_SendCmd(RTC_WDTEn, 0);
 }
 
+__attribute__( ( section( "realocate_functions" ) ) )
+static void RTC_SendCmdRelocate(eRTCCmd cmd, int enable)
+{
+	int retries = 10;
+	volatile int timeout;
+
+retry:
+	RTC->ANAWEN = 1 << (cmd - RTC_PowerOff);
+	if (enable)
+		RTC->ANACTL = 1 << (cmd - RTC_PowerOff);
+	else
+		RTC->ANACTL = 0;
+	timeout = 50;
+	while (timeout--);
+	timeout = 3000;
+	while ((RTC->RTCSTA & RTC_STA_BUSY) && timeout--);
+	if (timeout < 0 && retries--) {
+		RTC->RTCCTL |= 1;
+		goto retry;
+	}
+}
+
+__attribute__( ( section( "realocate_functions" ) ) )
 void RTC_PowerDown(int fastboot)
 {
 	u32 val = RTC->PARA;
@@ -107,8 +130,10 @@ void RTC_PowerDown(int fastboot)
 	RTC_SendCmd(RTC_Clk32KSel, 1);
 
 	TIMER_Mdelay(10);
+
+	RTC_SendCmdRelocate(RTC_ISOForce, 0);
 	//power off
-	RTC_SendCmd(RTC_PowerOff, 1);
+	RTC_SendCmdRelocate(RTC_PowerOff, 1);
 }
 
 void RTC_CanStbOut(int id, int value)
@@ -185,4 +210,4 @@ void RTC_SetWakeup(eRTCWakeupSource src, eRTCWakeupMode mode, int enable)
 		val &= ~(1 << enbit);
 	}
 	RTC_WriteReg(RTC_PMC, &RTC->PMC, val);
-}
+}