Index: BPU/RTC_Time/user/main.c
===================================================================
--- /YC3121_demo/ModuleDemo/BPU/RTC_Time/user/main.c	(revision 793)
+++ /YC3121_demo/ModuleDemo/BPU/RTC_Time/user/main.c	(working copy)
@@ -44,7 +44,7 @@
                        '2', '3', '5', '9', \
                        '3', '6', 0
                       };
-int g_time_offset = 0;
+time_t g_time_offset = 0;
 
 /* Private function prototypes -----------------------------------------------*/
 void UART_Configuration(void);
@@ -209,7 +209,7 @@
 uint8_t GetDeviceTime(void)
 {
     char buf[16] = {0};
-    int now = 0;
+    time_t now = 0;
     struct tm *pTime;
 
     now = RTC_GetRefRegister();
@@ -217,7 +217,7 @@
     qspi_flash_read(RTC_OFFSET_ADR, (uint8_t *)(&g_time_offset), 4);
 
     now = now  + g_time_offset;
-    pTime = localtime((const time_t *)&now);
+    pTime = localtime(&now);
     MyPrintf("%04d-%02d-%02d %02d:%02d:%02d", pTime->tm_year + 1900, pTime->tm_mon + 1, pTime->tm_mday, pTime->tm_hour, pTime->tm_min, pTime->tm_sec);
     return FALSE;
 }
Index: GPIO/GPIO_IO_Interrupt/user/main.c
===================================================================
--- /YC3121_demo/ModuleDemo/GPIO/GPIO_IO_Interrupt/user/main.c	(revision 792)
+++ /YC3121_demo/ModuleDemo/GPIO/GPIO_IO_Interrupt/user/main.c	(working copy)
@@ -188,7 +188,7 @@
   * @param  None
   * @retval None
   */
-void EXTI2_IRQHandler(void)
+void EXTI0_IRQHandler(void)
 {
     MyPrintf("EXTI0_IRQHandler In\n");
 }
Index: IIC/IIC_EEPROM_128/user/main.c
===================================================================
--- /YC3121_demo/ModuleDemo/IIC/IIC_EEPROM_128/user/main.c	(revision 792)
+++ /YC3121_demo/ModuleDemo/IIC/IIC_EEPROM_128/user/main.c	(working copy)
@@ -149,12 +149,16 @@
         }
 
         IIC_SendData(src_w, 67);
-        MyPrintf("Initial dest: %s\n", dest);
+        MyPrintf("write:\r\n");
+        for(int i=0;i<64;i++) MyPrintf("%02x ",src_w[3+i]);
+        MyPrintf("\r\n");
         for (uint32_t i = 0xfffff; i > 0; i--);
 
         IIC_ReceiveData(src_r, 4, dest, 64);
         for (uint32_t i = 0xfffff; i > 0; i--);
-        MyPrintf("End dest: %s\n", dest);
+        MyPrintf("read:\r\n");
+        for(int i=0;i<64;i++) MyPrintf("%02x ",dest[i]);
+        MyPrintf("\r\n");
     }
 
     GPIO_Config(IIC_WP2_PORT, IIC_WP2_PIN, OUTPUT_HIGH);
Index: POS/prj/GCC/makefile
===================================================================
--- /YC3121_demo/ModuleDemo/POS/prj/GCC/makefile	(revision 792)
+++ /YC3121_demo/ModuleDemo/POS/prj/GCC/makefile	(working copy)
@@ -21,6 +21,7 @@
 CORE_OBJS =  $(LIB_PATH)/startup/flash_start_gcc \
              $(LIB_PATH)/core/system \
              $(LIB_PATH)/core/misc \
+             $(LIB_PATH)/core/bt_code \
              $(LIB_PATH)/sdk/yc_adc \
              $(LIB_PATH)/sdk/yc_bt \
              $(LIB_PATH)/sdk/yc_chrg \
@@ -44,19 +45,18 @@
              $(LIB_PATH)/sdk/yc_nfc/yc_emv_contactless_l1 \
              $(LIB_PATH)/sdk/yc_7816/yc_7816 \
              $(LIB_PATH)/sdk/yc_7816/yc_7816_T0 \
-             $(LIB_PATH)/sdk/yc_7816/yc_7816_T1 
+             $(LIB_PATH)/sdk/yc_7816/yc_7816_T1
+
 
 
-             
 USER_OBJS = $(USER_PATH)/main \
             $(USER_PATH)/meun \
-            $(USER_PATH)/font \
-            $(USER_PATH)/bt_code
+            $(USER_PATH)/font
 
 LIB_OBJS = $(LIB_PATH)/sdk/libyc_qspi.a \
            $(LIB_PATH)/sdk/yc_msr/libyc_msr.a \
            $(LIB_PATH)/sdk/yc_qr/YC_QRDecode_lib.a
-           
+
 
 
 OBJS = $(CORE_OBJS) $(USER_OBJS)
@@ -73,9 +73,9 @@
 CFLAG =  -mthumb -mcpu=cortex-m0 -c -g -Os $(INC_DIR) $(DEF) -fno-toplevel-reorder -ffunction-sections -fdata-sections
 LDFLAG = -T output/ld.script -Map=output/memmap $(LIB_OBJS) -lc -lm -lgcc -lnosys -L "$(DIR)/lib/gcc/arm-none-eabi/7.3.1/thumb/v6-m"  -L "$(DIR)/arm-none-eabi/lib/thumb/v6-m"
 
-define ldscript = 
-/* Linker script to configure memory regions. 
- * Need modifying for a specific board. 
+define ldscript =
+/* Linker script to configure memory regions.
+ * Need modifying for a specific board.
  *   FLASH.ORIGIN: starting address of flash
  *   FLASH.LENGTH: length of flash
  *   RAM.ORIGIN: starting address of RAM bank 0
@@ -91,7 +91,7 @@
  * with other linker script that defines memory regions FLASH and RAM.
  * It references following symbols, which must be defined in code:
  *   Reset_Handler : Entry of reset handler
- * 
+ *
  * It defines following symbols, which code can use without definition:
  *   __exidx_start
  *   __exidx_end
@@ -147,15 +147,15 @@
 
 		KEEP(*(.eh_frame*))
 	} > FLASH
-	
-	
 
-	.ARM.extab : 
+
+
+	.ARM.extab :
 	{
 		*(.ARM.extab* .gnu.linkonce.armextab.*)
 	} > FLASH
 
-	
+
 	.ARM.exidx :
 	{
 		*(.ARM.exidx* .gnu.linkonce.armexidx.*)
@@ -165,7 +165,7 @@
 	__exidx_start = .;
 
 	__etext = .;
-		
+
 	.data : AT (__etext)
 	{
 		__data_start__ = .;
@@ -209,7 +209,7 @@
 		. = ALIGN(4);
 		__bss_end__ = .;
 	} > RAM
-	
+
 	.heap (COPY):
 	{
 		__end__ = .;
@@ -231,7 +231,7 @@
 	__StackTop = ORIGIN(RAM) + LENGTH(RAM);
 	__StackLimit = __StackTop - SIZEOF(.stack_dummy);
 	PROVIDE(__stack = __StackTop);
-	
+
 	/* Check if data + heap + stack exceeds RAM limit */
 	ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
 }
Index: POS/prj/MDK/YC3121_Keil.uvoptx
===================================================================
--- /YC3121_demo/ModuleDemo/POS/prj/MDK/YC3121_Keil.uvoptx	(revision 792)
+++ /YC3121_demo/ModuleDemo/POS/prj/MDK/YC3121_Keil.uvoptx	(working copy)
@@ -229,6 +229,18 @@
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
+    <File>
+      <GroupNumber>1</GroupNumber>
+      <FileNumber>3</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\..\..\..\Librarier\core\bt_code.c</PathWithFileName>
+      <FilenameWithoutPath>bt_code.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
   </Group>
 
   <Group>
@@ -239,7 +251,7 @@
     <RteFlg>0</RteFlg>
     <File>
       <GroupNumber>2</GroupNumber>
-      <FileNumber>3</FileNumber>
+      <FileNumber>4</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -251,7 +263,7 @@
     </File>
     <File>
       <GroupNumber>2</GroupNumber>
-      <FileNumber>4</FileNumber>
+      <FileNumber>5</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -263,7 +275,7 @@
     </File>
     <File>
       <GroupNumber>2</GroupNumber>
-      <FileNumber>5</FileNumber>
+      <FileNumber>6</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -273,18 +285,6 @@
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
-    <File>
-      <GroupNumber>2</GroupNumber>
-      <FileNumber>6</FileNumber>
-      <FileType>1</FileType>
-      <tvExp>0</tvExp>
-      <tvExpOptDlg>0</tvExpOptDlg>
-      <bDave2>0</bDave2>
-      <PathWithFileName>..\..\user\bt_code.c</PathWithFileName>
-      <FilenameWithoutPath>bt_code.c</FilenameWithoutPath>
-      <RteFlg>0</RteFlg>
-      <bShared>0</bShared>
-    </File>
   </Group>
 
   <Group>
Index: POS/prj/MDK/YC3121_Keil.uvprojx
===================================================================
--- /YC3121_demo/ModuleDemo/POS/prj/MDK/YC3121_Keil.uvprojx	(revision 792)
+++ /YC3121_demo/ModuleDemo/POS/prj/MDK/YC3121_Keil.uvprojx	(working copy)
@@ -392,6 +392,11 @@
               <FileType>1</FileType>
               <FilePath>..\..\..\..\Librarier\core\system.c</FilePath>
             </File>
+            <File>
+              <FileName>bt_code.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\..\Librarier\core\bt_code.c</FilePath>
+            </File>
           </Files>
         </Group>
         <Group>
@@ -412,11 +417,6 @@
               <FileType>1</FileType>
               <FilePath>..\..\user\font.c</FilePath>
             </File>
-            <File>
-              <FileName>bt_code.c</FileName>
-              <FileType>1</FileType>
-              <FilePath>..\..\user\bt_code.c</FilePath>
-            </File>
           </Files>
         </Group>
         <Group>
Index: POS/user/meun.c
===================================================================
--- /YC3121_demo/ModuleDemo/POS/user/meun.c	(revision 792)
+++ /YC3121_demo/ModuleDemo/POS/user/meun.c	(working copy)
@@ -1834,6 +1834,7 @@
 
 uint8_t camera_setpara[][2] =
 {
+    0x00
 //	{0xfe, 0x00},
 //	{0x14, 0x7f},//[1] updown [0]mirror //MIRROR
 };
Index: SPI/SPI_TFT/user/main.c
===================================================================
--- /YC3121_demo/ModuleDemo/SPI/SPI_TFT/user/main.c	(revision 792)
+++ /YC3121_demo/ModuleDemo/SPI/SPI_TFT/user/main.c	(working copy)
@@ -48,7 +48,7 @@
 int main(void)
 {
     SYSCTRL_HCLK_CON = 0x0;
-
+    GPIO_Config(GPIOA, GPIO_Pin_2, OUTPUT_HIGH);//3.3v EN
     UART_Configuration();
     TFT_Configuration();
 
Index: UART/UART_Interrupt/user/main.c
===================================================================
--- /YC3121_demo/ModuleDemo/UART/UART_Interrupt/user/main.c	(revision 792)
+++ /YC3121_demo/ModuleDemo/UART/UART_Interrupt/user/main.c	(working copy)
@@ -32,7 +32,7 @@
 /* Private define ------------------------------------------------------------*/
 /* Private macro -------------------------------------------------------------*/
 /* Private variables ---------------------------------------------------------*/
-uint8_t p = '\n';
+uint8_t p[10] ={'1','2','3','4','5','6','7','8','9','0'};
 
 /* Private function prototypes -----------------------------------------------*/
 void NVIC_Configuration(void);
@@ -70,13 +70,14 @@
                 UART_ITConfig(UART1, UART_IT_RX, ENABLE);
                 UART_SetRxITNum(UART1, 10);
                 UART_SetITTimeout(UART1, 0xff);
+                UART_SendBuf(UART1, p,sizeof(p));
                 break;
             }
             case 'T':
             {
                 MyPrintf("TEST UART1 TX INTERRUPT!\n");
                 UART_ITConfig(UART1, UART_IT_TX, ENABLE);
-                UART_SendData(UART1, p);
+                UART_SendBuf(UART1, p,sizeof(p));
                 break;
             }
             default:
@@ -170,23 +171,20 @@
   */
 void UART1_IRQHandler(void)
 {
-    uint8_t rbuf[10], r;
-    uint8_t tbuf[] = "UART1 TX INTERRUPT test successful!\n";
-
-
     if (UART_GetITIdentity(UART1) == UART_IT_RX)
     {
-        if (UART_IsRXFIFONotEmpty(UART1))
+        UART_ClearIT(UART1);
+        MyPrintf("UART1 RX data:\n");
+        while(UART_IsRXFIFONotEmpty(UART1))
         {
-            r = UART_RecvBuf(UART1, rbuf, 9);
-            rbuf[r] = '\0';
+            MyPrintf("%c",UART_ReceiveData(UART1));
         }
-        MyPrintf("UART1 RX INTERRUPT test successful, this buf is %s!\n", rbuf);
+        MyPrintf("\nUART1 RX INTERRUPT test successful!\n");
     }
     else if (UART_GetITIdentity(UART1) == UART_IT_TX)
     {
-        UART_SendBuf(UART1, tbuf, sizeof(tbuf) - 1);
         UART_ClearIT(UART1);
+        MyPrintf("UART1 TX INTERRUPT test successful!\n");
     }
 }
 
Index: updata_app/Boot/prj/GCC/makefile
===================================================================
--- /YC3121_demo/ModuleDemo/updata_app/Boot/prj/GCC/makefile	(revision 794)
+++ /YC3121_demo/ModuleDemo/updata_app/Boot/prj/GCC/makefile	(working copy)
@@ -18,38 +18,212 @@
 all : output/out.hex
 
 
-CORE_OBJS =  $(LIB_PATH)/startup/flash_start_gcc \
+CORE_OBJS =  $(LIB_PATH)/startup/boot_flash_start_gcc \
              $(LIB_PATH)/core/system \
              $(LIB_PATH)/core/misc \
+             $(LIB_PATH)/core/bt_code \
              $(LIB_PATH)/sdk/yc_gpio \
-             $(LIB_PATH)/sdk/yc_uart
+             $(LIB_PATH)/sdk/yc_timer \
+             $(LIB_PATH)/sdk/yc_ipc \
+             $(LIB_PATH)/sdk/yc_uart \
+             $(LIB_PATH)/sdk/yc_lpm \
+             $(LIB_PATH)/sdk/yc_otp \
+             $(LIB_PATH)/sdk/yc_sysctrl \
+             $(LIB_PATH)/sdk/yc_systick \
+             $(LIB_PATH)/sdk/yc_bt \
+             $(LIB_PATH)/sdk/yc_usb/libraries/harward_Der/usb_core \
+             $(LIB_PATH)/sdk/yc_usb/libraries/harward_Der/Usb_dcd \
+             $(LIB_PATH)/sdk/yc_usb/libraries/harward_Der/Usb_dcd_init \
+             $(LIB_PATH)/sdk/yc_usb/libraries/SCPU_USB_Device_Library/core/usbd_core \
+             $(LIB_PATH)/sdk/yc_usb/libraries/SCPU_USB_Device_Library/core/usbd_ioreq \
+             $(LIB_PATH)/sdk/yc_usb/libraries/SCPU_USB_Device_Library/core/usbd_req \
+             $(LIB_PATH)/sdk/yc_usb/libraries/SCPU_USB_Device_Library/class/HID/usbd_hid_core \
+             $(LIB_PATH)/sdk/yc_usb/scpu_usb_hid_Device_Demo/usb_main \
+             $(LIB_PATH)/sdk/yc_usb/scpu_usb_hid_Device_Demo/usbd_desc \
+             $(LIB_PATH)/sdk/yc_usb/scpu_usb_hid_Device_Demo/usbd_usr
+
+
+
+USER_OBJS =  $(USER_PATH)/main \
+             $(USER_PATH)/halUSB \
+             $(USER_PATH)/ota_ble \
+             $(USER_PATH)/otausb
 
-             
-USER_OBJS = $(USER_PATH)/main \
-            $(USER_PATH)/bt_code
-			
 OBJS = $(CORE_OBJS) $(USER_OBJS)
 
 INC_DIR = -I $(LIB_PATH)/core \
-          -I $(LIB_PATH)/sdk
-
+          -I $(LIB_PATH)/sdk \
+          -I $(LIB_PATH)/sdk/yc_usb/libraries/harward_Der \
+          -I $(LIB_PATH)/sdk/yc_usb/libraries/SCPU_USB_Device_Library/core \
+          -I $(LIB_PATH)/sdk/yc_usb/libraries/SCPU_USB_Device_Library/class/HID \
+          -I $(LIB_PATH)/sdk/yc_usb/scpu_usb_hid_Device_Demo \
+          -I $(USER_PATH)
+
+
+CFLAG =  -mthumb -mcpu=cortex-m0 -c -g -Os $(INC_DIR) $(DEF) -fno-toplevel-reorder -ffunction-sections -fdata-sections
+LDFLAG = -T output/ld.script -Map=output/memmap $(LIB_PATH)/sdk/libyc_qspi.a $(LIB_PATH)/sdk/libyc_encflash_bulk.a -lc -lm -lgcc -L "$(DIR)/lib/gcc/arm-none-eabi/7.3.1/thumb/v6-m"  -L "$(DIR)/arm-none-eabi/lib/thumb/v6-m"
+
+define ldscript =
+/* Linker script to configure memory regions.
+ * Need modifying for a specific board.
+ *   FLASH.ORIGIN: starting address of flash
+ *   FLASH.LENGTH: length of flash
+ *   RAM.ORIGIN: starting address of RAM bank 0
+ *   RAM.LENGTH: length of RAM bank 0
+ */
+MEMORY
+{
+  FLASH (rx) : ORIGIN = 0x1000000, LENGTH = 0x80000 /* 512K */
+  RAM (rwx) : ORIGIN = 0x20000, LENGTH = 0x10000 /* 64K */
+}
 
-CFLAG =  -mthumb -mcpu=cortex-m0 -c -g -Os $(INC_DIR) $(DEF) -fno-toplevel-reorder
-LDFLAG = -T output/ld.script -Map=output/memmap -lc -lm -lgcc -L "$(DIR)/lib/gcc/arm-none-eabi/7.3.1/thumb/v6-m"  -L "$(DIR)/arm-none-eabi/lib/thumb/v6-m"
+/* Linker script to place sections and symbol values. Should be used together
+ * with other linker script that defines memory regions FLASH and RAM.
+ * It references following symbols, which must be defined in code:
+ *   Reset_Handler : Entry of reset handler
+ *
+ * It defines following symbols, which code can use without definition:
+ *   __exidx_start
+ *   __exidx_end
+ *   __copy_table_start__
+ *   __copy_table_end__
+ *   __zero_table_start__
+ *   __zero_table_end__
+ *   __etext
+ *   __data_start__
+ *   __preinit_array_start
+ *   __preinit_array_end
+ *   __init_array_start
+ *   __init_array_end
+ *   __fini_array_start
+ *   __fini_array_end
+ *   __data_end__
+ *   __bss_start__
+ *   __bss_end__
+ *   __end__
+ *   end
+ *   __HeapLimit
+ *   __StackLimit
+ *   __StackTop
+ *   __stack
+ */
+ENTRY(Reset_Handler)
 
-define ldscript = 
 SECTIONS
-{ 
-        . = 0x1000000;
-        .text : { *flash_start.o *(.text*) *(.rodata*) }
-        _sidata = ALIGN(4);
-        . = 0x20000;
-        .data : AT (_sidata) { _sdata = .; *(.data) _edata = .; }
-        .bss : { _sbss = .;     *(*.bss) *(*.scommon*) }
-        _ebss = .;
-        . = 0x30000;
-        _stack = .;
-        ASSERT(_ebss < _stack, "data size overflow")
+{
+	.text :
+	{
+		*flash_start*.o
+		*(.text*)
+
+		KEEP(*(.init))
+		KEEP(*(.fini))
+
+		/* .ctors */
+		*crtbegin.o(.ctors)
+		*crtbegin?.o(.ctors)
+		*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
+		*(SORT(.ctors.*))
+		*(.ctors)
+
+		/* .dtors */
+ 		*crtbegin.o(.dtors)
+ 		*crtbegin?.o(.dtors)
+ 		*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
+ 		*(SORT(.dtors.*))
+ 		*(.dtors)
+
+		*(.rodata*)
+
+		KEEP(*(.eh_frame*))
+	} > FLASH
+
+
+
+	.ARM.extab :
+	{
+		*(.ARM.extab* .gnu.linkonce.armextab.*)
+	} > FLASH
+
+
+	.ARM.exidx :
+	{
+		*(.ARM.exidx* .gnu.linkonce.armexidx.*)
+	} > FLASH
+
+	 . = ALIGN(4);
+	__exidx_start = .;
+
+	__etext = .;
+
+	.data : AT (__etext)
+	{
+		__data_start__ = .;
+		*(vtable)
+		*(.data*)
+
+		. = ALIGN(4);
+		/* preinit data */
+		PROVIDE_HIDDEN (__preinit_array_start = .);
+		KEEP(*(.preinit_array))
+		PROVIDE_HIDDEN (__preinit_array_end = .);
+
+		. = ALIGN(4);
+		/* init data */
+		PROVIDE_HIDDEN (__init_array_start = .);
+		KEEP(*(SORT(.init_array.*)))
+		KEEP(*(.init_array))
+		PROVIDE_HIDDEN (__init_array_end = .);
+
+
+		. = ALIGN(4);
+		/* finit data */
+		PROVIDE_HIDDEN (__fini_array_start = .);
+		KEEP(*(SORT(.fini_array.*)))
+		KEEP(*(.fini_array))
+		PROVIDE_HIDDEN (__fini_array_end = .);
+
+		KEEP(*(.jcr*))
+		. = ALIGN(4);
+		/* All data end */
+		__data_end__ = .;
+
+	} > RAM
+
+	.bss :
+	{
+		. = ALIGN(4);
+		__bss_start__ = .;
+		*(.bss*)
+		*(COMMON)
+		. = ALIGN(4);
+		__bss_end__ = .;
+	} > RAM
+
+	.heap (COPY):
+	{
+		__end__ = .;
+		PROVIDE(end = .);
+		*(.heap*)
+		__HeapLimit = .;
+	} > RAM
+
+	/* .stack_dummy section doesn't contains any symbols. It is only
+	 * used for linker to calculate size of stack sections, and assign
+	 * values to stack symbols later */
+	.stack_dummy (COPY):
+	{
+		*(.stack*)
+	} > RAM
+
+	/* Set stack top to end of RAM, and stack limit move down by
+	 * size of stack_dummy section */
+	__StackTop = ORIGIN(RAM) + LENGTH(RAM);
+	__StackLimit = __StackTop - SIZEOF(.stack_dummy);
+	PROVIDE(__stack = __StackTop);
+
+	/* Check if data + heap + stack exceeds RAM limit */
+	ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
 }
 endef
 
@@ -60,7 +234,7 @@
 
 output/out : $(addprefix output/, $(addsuffix .o, $(OBJS)))
 	$(file >output/ld.script, $(ldscript))
-	$(LD) $(addprefix output/obj/,$(addsuffix .o, $(notdir $(OBJS)))) -o $@  $(LDFLAG)
+	$(LD) $(addprefix output/obj/,$(addsuffix .o, $(notdir $(OBJS)))) -o $@ $(LDFLAG)
 	$(OBJDUMP) -S $@ > output/disasm
 
 output/%.o : %.c
Index: updata_app/Boot/user/main.c
===================================================================
--- /YC3121_demo/ModuleDemo/updata_app/Boot/user/main.c	(revision 794)
+++ /YC3121_demo/ModuleDemo/updata_app/Boot/user/main.c	(working copy)
@@ -104,6 +104,7 @@
     }
     else
     {
+        MyPrintf("Run App\n");
         start_app();
     }
 }
Index: updata_app/app/prj/GCC/makefile
===================================================================
--- /YC3121_demo/ModuleDemo/updata_app/app/prj/GCC/makefile	(revision 794)
+++ /YC3121_demo/ModuleDemo/updata_app/app/prj/GCC/makefile	(working copy)
@@ -22,34 +22,184 @@
              $(LIB_PATH)/core/system \
              $(LIB_PATH)/core/misc \
              $(LIB_PATH)/sdk/yc_gpio \
+             $(LIB_PATH)/sdk/yc_otp \
+             $(LIB_PATH)/sdk/yc_timer \
+             $(LIB_PATH)/sdk/yc_systick \
              $(LIB_PATH)/sdk/yc_uart
 
-             
-USER_OBJS = $(USER_PATH)/main \
-            $(USER_PATH)/bt_code
-			
+
+USER_OBJS = $(USER_PATH)/main
+
 OBJS = $(CORE_OBJS) $(USER_OBJS)
 
 INC_DIR = -I $(LIB_PATH)/core \
           -I $(LIB_PATH)/sdk
 
 
-CFLAG =  -mthumb -mcpu=cortex-m0 -c -g -Os $(INC_DIR) $(DEF) -fno-toplevel-reorder
-LDFLAG = -T output/ld.script -Map=output/memmap -lc -lm -lgcc -L "$(DIR)/lib/gcc/arm-none-eabi/7.3.1/thumb/v6-m"  -L "$(DIR)/arm-none-eabi/lib/thumb/v6-m"
+CFLAG =  -mthumb -mcpu=cortex-m0 -c -g -Os $(INC_DIR) $(DEF) -fno-toplevel-reorder -ffunction-sections -fdata-sections
+LDFLAG = -T output/ld.script -Map=output/memmap $(LIB_PATH)/sdk/libyc_qspi.a -lc -lm -lgcc -L "$(DIR)/lib/gcc/arm-none-eabi/7.3.1/thumb/v6-m"  -L "$(DIR)/arm-none-eabi/lib/thumb/v6-m"
+
+define ldscript =
+/* Linker script to configure memory regions.
+ * Need modifying for a specific board.
+ *   FLASH.ORIGIN: starting address of flash
+ *   FLASH.LENGTH: length of flash
+ *   RAM.ORIGIN: starting address of RAM bank 0
+ *   RAM.LENGTH: length of RAM bank 0
+ */
+MEMORY
+{
+  FLASH (rx) : ORIGIN = 0x101FE00, LENGTH = 0x80000 /* 512K */
+  RAM (rwx) : ORIGIN = 0x20000, LENGTH = 0x10000 /* 64K */
+}
+
+/* Linker script to place sections and symbol values. Should be used together
+ * with other linker script that defines memory regions FLASH and RAM.
+ * It references following symbols, which must be defined in code:
+ *   Reset_Handler : Entry of reset handler
+ *
+ * It defines following symbols, which code can use without definition:
+ *   __exidx_start
+ *   __exidx_end
+ *   __copy_table_start__
+ *   __copy_table_end__
+ *   __zero_table_start__
+ *   __zero_table_end__
+ *   __etext
+ *   __data_start__
+ *   __preinit_array_start
+ *   __preinit_array_end
+ *   __init_array_start
+ *   __init_array_end
+ *   __fini_array_start
+ *   __fini_array_end
+ *   __data_end__
+ *   __bss_start__
+ *   __bss_end__
+ *   __end__
+ *   end
+ *   __HeapLimit
+ *   __StackLimit
+ *   __StackTop
+ *   __stack
+ */
+ENTRY(Reset_Handler)
 
-define ldscript = 
 SECTIONS
-{ 
-        . = 0x1000000;
-        .text : { *flash_start.o *(.text*) *(.rodata*) }
-        _sidata = ALIGN(4);
-        . = 0x20000;
-        .data : AT (_sidata) { _sdata = .; *(.data) _edata = .; }
-        .bss : { _sbss = .;     *(*.bss) *(*.scommon*) }
-        _ebss = .;
-        . = 0x30000;
-        _stack = .;
-        ASSERT(_ebss < _stack, "data size overflow")
+{
+	.text :
+	{
+		*flash_start*.o
+		*(.text*)
+
+		KEEP(*(.init))
+		KEEP(*(.fini))
+
+		/* .ctors */
+		*crtbegin.o(.ctors)
+		*crtbegin?.o(.ctors)
+		*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
+		*(SORT(.ctors.*))
+		*(.ctors)
+
+		/* .dtors */
+ 		*crtbegin.o(.dtors)
+ 		*crtbegin?.o(.dtors)
+ 		*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
+ 		*(SORT(.dtors.*))
+ 		*(.dtors)
+
+		*(.rodata*)
+
+		KEEP(*(.eh_frame*))
+	} > FLASH
+
+
+
+	.ARM.extab :
+	{
+		*(.ARM.extab* .gnu.linkonce.armextab.*)
+	} > FLASH
+
+
+	.ARM.exidx :
+	{
+		*(.ARM.exidx* .gnu.linkonce.armexidx.*)
+	} > FLASH
+
+	 . = ALIGN(4);
+	__exidx_start = .;
+
+	__etext = .;
+
+	.data : AT (__etext)
+	{
+		__data_start__ = .;
+		*(vtable)
+		*(.data*)
+
+		. = ALIGN(4);
+		/* preinit data */
+		PROVIDE_HIDDEN (__preinit_array_start = .);
+		KEEP(*(.preinit_array))
+		PROVIDE_HIDDEN (__preinit_array_end = .);
+
+		. = ALIGN(4);
+		/* init data */
+		PROVIDE_HIDDEN (__init_array_start = .);
+		KEEP(*(SORT(.init_array.*)))
+		KEEP(*(.init_array))
+		PROVIDE_HIDDEN (__init_array_end = .);
+
+
+		. = ALIGN(4);
+		/* finit data */
+		PROVIDE_HIDDEN (__fini_array_start = .);
+		KEEP(*(SORT(.fini_array.*)))
+		KEEP(*(.fini_array))
+		PROVIDE_HIDDEN (__fini_array_end = .);
+
+		KEEP(*(.jcr*))
+		. = ALIGN(4);
+		/* All data end */
+		__data_end__ = .;
+
+	} > RAM
+
+	.bss :
+	{
+		. = ALIGN(4);
+		__bss_start__ = .;
+		*(.bss*)
+		*(COMMON)
+		. = ALIGN(4);
+		__bss_end__ = .;
+	} > RAM
+
+	.heap (COPY):
+	{
+		__end__ = .;
+		PROVIDE(end = .);
+		*(.heap*)
+		__HeapLimit = .;
+	} > RAM
+
+	/* .stack_dummy section doesn't contains any symbols. It is only
+	 * used for linker to calculate size of stack sections, and assign
+	 * values to stack symbols later */
+	.stack_dummy (COPY):
+	{
+		*(.stack*)
+	} > RAM
+
+	/* Set stack top to end of RAM, and stack limit move down by
+	 * size of stack_dummy section */
+	__StackTop = ORIGIN(RAM) + LENGTH(RAM);
+	__StackLimit = __StackTop - SIZEOF(.stack_dummy);
+	PROVIDE(__stack = __StackTop);
+
+	/* Check if data + heap + stack exceeds RAM limit */
+	ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
 }
 endef
 
@@ -60,7 +210,7 @@
 
 output/out : $(addprefix output/, $(addsuffix .o, $(OBJS)))
 	$(file >output/ld.script, $(ldscript))
-	$(LD) $(addprefix output/obj/,$(addsuffix .o, $(notdir $(OBJS)))) -o $@  $(LDFLAG)
+	$(LD) $(addprefix output/obj/,$(addsuffix .o, $(notdir $(OBJS)))) -o $@ $(LDFLAG)
 	$(OBJDUMP) -S $@ > output/disasm
 
 output/%.o : %.c
Index: updata_app/app/prj/MDK/YC3121_Keil.uvprojx
===================================================================
--- /YC3121_demo/ModuleDemo/updata_app/app/prj/MDK/YC3121_Keil.uvprojx	(revision 794)
+++ /YC3121_demo/ModuleDemo/updata_app/app/prj/MDK/YC3121_Keil.uvprojx	(working copy)
@@ -437,6 +437,16 @@
               <FileType>1</FileType>
               <FilePath>..\..\..\..\..\Librarier\sdk\yc_otp.c</FilePath>
             </File>
+            <File>
+              <FileName>yc_systick.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\..\..\Librarier\sdk\yc_systick.c</FilePath>
+            </File>
+            <File>
+              <FileName>yc_timer.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\..\..\Librarier\sdk\yc_timer.c</FilePath>
+            </File>
           </Files>
         </Group>
         <Group>
Index: updata_app/app/user/main.c
===================================================================
--- /YC3121_demo/ModuleDemo/updata_app/app/user/main.c	(revision 794)
+++ /YC3121_demo/ModuleDemo/updata_app/app/user/main.c	(working copy)
@@ -23,8 +23,10 @@
 
 /* Includes ------------------------------------------------------------------*/
 #include "yc3121.h"
-#include "..\sdk\yc_gpio.h"
-#include "..\sdk\yc_uart.h"
+#include "yc_gpio.h"
+#include "yc_uart.h"
+#include "yc_timer.h"
+#include "yc_systick.h"
 #include "yc_qspi.h"
 #include "yc_encflash_bulk.h"
 #include "board_config.h"
@@ -37,6 +39,7 @@
 /* Private variables ---------------------------------------------------------*/
 /* Private function prototypes -----------------------------------------------*/
 void UART_Configuration(void);
+void TIMER_Configuration(void);
 /**
   * @brief  Main program
   * @param  None
@@ -49,6 +52,8 @@
 {
 	UART_Configuration();
 	MyPrintf("YC3121 OTA APP Demo\n");
+    SysTick_Config(CPU_MHZ/100);//10ms
+    TIMER_Configuration();
 	MyPrintf("/*************************/\n");
 	MyPrintf("Please input 'B' or 'U'\n");
 	MyPrintf("B: BLE OTA Updata\n");
@@ -125,4 +130,29 @@
 	UART_Init(UART0, &UART_InitStruct);
 }
 
+void TIMER_Configuration(void)
+{
+    TIM_InitTypeDef TIM_struct;
+    TIM_struct.TIMx=TIM0;
+    TIM_struct.period=CPU_MHZ;
+    TIM_Init(&TIM_struct);
+    TIM_Cmd(TIM_struct.TIMx, ENABLE);
+    NVIC_EnableIRQ(TIM0_IRQn);
+}
+
+extern tick SystickCount;
+void SYSTICK_IRQHandler(void)
+{
+    SystickCount++;
+    if(SystickCount>=TICK_MAX_VALUE)
+    {
+        SystickCount=0;
+    }
+}
+
+void TIMER0_IRQHandler(void)
+{
+    MyPrintf("TIMER0_IRQHandler irq[SystickCount=%d]\r\n",SystickCount);
+}
+
 /************************ (C) COPYRIGHT Yichip Microelectronics *****END OF FILE****/
\ No newline at end of file
Index: updata_app/hex_to_bin/genbin_gcc.bat
===================================================================
--- /YC3121_demo/ModuleDemo/updata_app/hex_to_bin/genbin_gcc.bat	(nonexistent)
+++ /YC3121_demo/ModuleDemo/updata_app/hex_to_bin/genbin_gcc.bat	(working copy)
@@ -0,0 +1,7 @@
+echo on
+cls
+
+perl hex2rom.pl 1000000 1ffffff  32 ..\app\prj\GCC\output\out.hex  .\app_flash.rom
+perl hex2rom.pl 1000000 1ffffff  32 ..\Boot\prj\GCC\output\out.hex  .\boot_flash.rom
+
+f_updata_rom_to_bin 128
\ No newline at end of file
