Index: fw/makefile
===================================================================
--- /YC3121_ROM/fw/makefile	(revision 622)
+++ /YC3121_ROM/fw/makefile	(working copy)
@@ -48,8 +48,7 @@
 OBJS = $(ROM_OBJS) main core/flash_start core/bt_code\
 				   sdk/yc_uart \
 				   sdk/yc_sysctrl\
-				   sdk/yc_it\
-				   otp_boot
+				   sdk/yc_it
 				  
 OTPS = otp
 
Index: fw/otp_boot.c
===================================================================
--- /YC3121_ROM/fw/otp_boot.c	(revision 622)
+++ /YC3121_ROM/fw/otp_boot.c	(working copy)
@@ -1,29 +1,4 @@
-#include "core\type.h"
-#include "core\yc3121.h"
-/*
-#define ROM_UART_INIT  (0x6504+1)   
-#define ROM_PRINT      (0x4da8+1)
-
-
-void otp_boot(void)
-{
-    unsigned int  t = 0;
-    unsigned char tbuf[256];
-    ((void(*)())ROM_UART_INIT)();
-    for(t = 0; t < 256; t++)
-        tbuf[t] = t;
-    ((void(*)())ROM_PRINT)(0,tbuf,256);
-}
-
-*/
-/*
-File Name    : otp_boot.c
-Author       : Yichip
-Version      : V1.0
-Date         : 2019/04/30
-Description  : ...
-*/
-
+#include "core/yc3121.h"
 
 
 #define BOOT_BUF_LEN       						 (int)1100
@@ -129,36 +104,25 @@
 uint8_t rom_switch;
 QSPI_ParamTypeDef qspi_param;
 
-
+//#define OTP__DEBUG
+#if defined (OTP__DEBUG) 
 void uart_send(uint8_t step);
 void uart_sendnun(uint32_t num);
-void _init_otp_();
+#endif
 void  _Hardware_Init_();
-uint8_t _qspi_flash_cmd_(uint8_t cmd);
-void _delay_ms_(int ms);
-SCY_Boolean _self_check_(uint8_t flag);
-void _boot_load_config_();
-SCY_Boolean _detect_DownloadSignal_();
-void _boot_download_();
-void _enable_debug_port_();
-void _DeInit_download_port_();
-SCY_Boolean _verify_signature_(uint8_t verify_type);
-void  _prefetch_len_(void *start_addr, int len);
+uint32_t lpm_bt_read_(uint8_t type);
+void lpm_bt_write_(uint8_t type,uint32_t val);
 void  _jump_back_rom_boot();
 
 
 
 void _otp_main()
 {
-    uint8_t isok;
 	_Hardware_Init_();
-	//wakeup bt
-	SYSCTRL_ROM_SWITCH = 0x8c;
-	_delay_ms_(10);
-	_qspi_flash_cmd_(0xab);
-	
+
 	
 	main_flow_ctrl=0;
+	#if defined (OTP__DEBUG) 
 	uart_send('o');
 	uart_send('t');
 	uart_send('p');
@@ -169,122 +133,15 @@
 	uart_send('n');
 	uart_send('\r');
 	uart_send('\n');
-
-	main_flow_ctrl+= STEP1;
-	
+	#endif
+	uint32_t val_lpm_ctrl1=lpm_bt_read_(LPMBT_CONTROL1);
+	val_lpm_ctrl1 &= (~(1<<21));
+	lpm_bt_write_(LPMBT_CONTROL1,val_lpm_ctrl1);
 	_jump_back_rom_boot();
-
-	/*
-	//self check
-	main_flow_ctrl=0;
-	if(_self_check_(self_test_config)==SCY_TRUE)
-	{
-		main_flow_ctrl+= STEP1;
-	}
-	else
-	{
-		return;//debug
-	}
-	uart_send(1);
-	//load config info
-	_boot_load_config_();
-	uart_send(2);
-	if(RomBooDataStruct->sec_chip_stage==RomBooDataStruct->C_infoStruct.chip_stage)
-	{
-		main_flow_ctrl+= STEP2;
-	}
-	else
-	{
-		return;
-	}
-	if(RomBooDataStruct->C_infoStruct.chip_stage==TEST_STAGE||\
-	   RomBooDataStruct->C_infoStruct.chip_stage==DEBUG_STAGE||\
-	   RomBooDataStruct->C_infoStruct.chip_stage==PRODUCT_STAGE)
-	{
-		main_flow_ctrl+= STEP3;
-	}
-	else
-	{
-		return;
-	}
-	if(main_flow_ctrl!=(STEP1+STEP2+STEP3))
-	{
-		return;
-	}
-
-	if(_detect_DownloadSignal_()==SCY_TRUE)
-	{
-		_boot_download_();
-	}
-
-
-   // ((void(*)(void))(0x4b40+1))();
-
-    isok = 0;
-    uint8_t rd;
-    uint32_t i;
-    uint32_t k;
-	for(i =0;i<64;i++)
-    {
-        _prefetch_len_((uint32_t *)(0x1000200+i*1024),1024);
-//        uart_sendnun(i);
-        for(k=0;k<1024;k++)
-        {
-            rd = *(uint8_t*)(0x1000200+i*1024+k);
-            if((k%256) != rd)
-            {
-                uart_send('\n');
-                uart_sendnun(0x1000200+i*1024+k);
-                uart_send('e');
-                uart_send('r');
-                uart_send('r');
-                isok = 1;
-            }
-            else
-            {
-                // uart_send('\n');
-                // uart_sendnun(0x1000200+i*1024+k);
-                // uart_send('o');
-                // uart_send('k');
-            }
-        }
-    }
-
-    uart_send('\n');
-    uart_send('i');
-    uart_send('s');
-    uart_send('o');
-    uart_send('k');
-    uart_send('=');
-    uart_send(isok?'E':'O');
-
-	_DeInit_download_port_();	//debug
-
-	switch(RomBooDataStruct->C_infoStruct.chip_stage)
-	{
-		case TEST_STAGE:
-		case DEBUG_STAGE:
-			_enable_debug_port_();	
-			start_flash();
-			break;
-
-		case PRODUCT_STAGE:
-			if(_verify_signature_(VERIFY_FLASH_SIGNATURE)==SCY_TRUE)
-			{		  	
-				start_flash();
-			}
-			break;
-
-		default:
-			while(1);	//debug
-			break;
-	}
-	while(1);	//debug
-	*/
 }
 
 
-
+#if defined (OTP__DEBUG)
 #define ROM_UART_SEND_BUF_ADDR      (0x4b4c+1)
 void uart_send(uint8_t step)
 {
@@ -304,74 +161,33 @@
     }
     ((void(*)())ROM_UART_SEND_BUF_ADDR)(0,tbuf,8);
 }
-
-
-void _init_otp_()
-{
-	((void(*)(void))(0x442c+1))();
-}
-
+#endif
 
 void  _Hardware_Init_()
 {
 	((void(*)(void))(0x6adc+1))();
 }
 
-uint8_t _qspi_flash_cmd_(uint8_t cmd)
+uint32_t lpm_bt_read_(uint8_t type)
 {
-	((uint8_t(*)(uint8_t))(0x4708+1))(cmd);
+	return ((uint32_t(*)(uint8_t))(0x4d24+1))(type);
 }
 
-void _delay_ms_(int ms)
+void lpm_bt_write_(uint8_t type,uint32_t val)
 {
-	((void(*)(int))(0x425c+1))(ms);
+	((void(*)(uint8_t,uint32_t))(0x4cb0+1))(type,val);
 }
 
-SCY_Boolean _self_check_(uint8_t flag)
-{
-		((SCY_Boolean(*)(uint8_t))(0x65ac+1))(flag);
-}
-
-void _boot_load_config_()
-{
-		((void(*)(void))(0x6d64+1))();
-}
-
-SCY_Boolean _detect_DownloadSignal_()
-{
-		((SCY_Boolean(*)(void))(0x6e04+1))();
-}
-
-void _boot_download_()
-{
-		((void(*)(void))(0x7530+1))();
-}
-
-void _enable_debug_port_()
-{
-		((void(*)(void))(0x760c+1))();
-}
-void _DeInit_download_port_()
-{
-        ((void(*)(void))(0x6dd8+1))();
-}
-
-SCY_Boolean _verify_signature_(uint8_t verify_type)
-{
-
-    ((SCY_Boolean(*)(uint8_t))(0x7046+1))(verify_type);
-}
-
-void  _prefetch_len_(void *start_addr, int len)
+void  _jump_back_rom_boot()
 {
-     ((void(*)(void*,int))(0x444a+1))(start_addr,len);
+     //((void(*)(void))(0x7856+1))();//skip self check  bl to "_boot_load_config();" in _boot_main
+	 ((void(*)(void))(0x7842+1))();//jump to after _Hardware_Init
 
 }
 
-void  _jump_back_rom_boot()
+void main()
 {
-     ((void(*)(void))(0x7856+1))();//skip self check  bl to "_boot_load_config();" in _boot_main
-
+	while(1);	
 }
 
 
Index: fw/sdk/yc_it.c
===================================================================
--- /YC3121_ROM/fw/sdk/yc_it.c	(revision 622)
+++ /YC3121_ROM/fw/sdk/yc_it.c	(working copy)
@@ -11,7 +11,7 @@
 
 void NMI_IRQHandler()
 {
-	MyPrintf("\nNMI_IRQHandler");
+	//MyPrintf("\nNMI_IRQHandler");
 	while(1);
 }
 
@@ -23,152 +23,152 @@
 
 void SVC_IRQHandler()
 {
-	MyPrintf("\nSVC_IRQHandler");
+	//MyPrintf("\nSVC_IRQHandler");
 	
 }
 
 void PENDSV_IRQHandler()
 {
-	MyPrintf("\nPENDSV_IRQHandler");
+	//MyPrintf("\nPENDSV_IRQHandler");
 	
 }
 
 void SYSTICK_IRQHandler()
 {
-	MyPrintf("\nSYSTICK_IRQHandler");
+	//MyPrintf("\nSYSTICK_IRQHandler");
 }
 
 void USB_IRQHandler()
 {
-	MyPrintf("\nUSB_IRQHandler");
+	//MyPrintf("\nUSB_IRQHandler");
 	while(1);
 }
 
 void IIC_IRQHandler()
 {
-	MyPrintf("iic Interrupted\n");
+	//MyPrintf("iic Interrupted\n");
 }
 
 void QSPI_IRQHandler() 
 {
-	MyPrintf("qspi Interrupted\n");
+	//MyPrintf("qspi Interrupted\n");
 }
 
 void SPI0_IRQHandler()
 {
-	MyPrintf("spi0 Interrupted\n");
+	//MyPrintf("spi0 Interrupted\n");
 }
 
 void SPI1_IRQHandler()
 {
-	MyPrintf("spi1 Interrupted\n");
+	//MyPrintf("spi1 Interrupted\n");
 }
 
 void UART0_IRQHandler()
 {
-	MyPrintf("UART0_IRQHandler\n");
+	//MyPrintf("UART0_IRQHandler\n");
 }
 
 void UART1_IRQHandler()
 {
-	MyPrintf("UART1_IRQHandler\n");
+	//MyPrintf("UART1_IRQHandler\n");
 }
 
 void MEMCP_IRQHandler()
 {
-	MyPrintf("memcp Interrupted\n");		
+	//MyPrintf("memcp Interrupted\n");		
 }
 
 void RSA_IRQHandler()
 {
-	MyPrintf("rsa Interrupted\n");
+	//MyPrintf("rsa Interrupted\n");
 }
 
 void SCI0_IRQHandler()
 {
-	MyPrintf("sci0 Interrupted\n");
+	//MyPrintf("sci0 Interrupted\n");
 }
 
 void SCI1_IRQHandler()
 {
-	MyPrintf("sci1  Interrupted\n");
+	//MyPrintf("sci1  Interrupted\n");
 }
 
 void BT_IRQHandler()
 {
-	MyPrintf("\nBt Irq Handler \n");
+	//MyPrintf("\nBt Irq Handler \n");
 }
 
 void GPIO_IRQHandler()
 {
-	MyPrintf("\nGPIO_IRQHandler");
+	//MyPrintf("\nGPIO_IRQHandler");
 }
 
 void TIMER0_IRQHandler() 
 {
-	MyPrintf("timer0 Interrupted\n");
+	//MyPrintf("timer0 Interrupted\n");
 }
 
 void TIMER1_IRQHandler() 
 {
-	MyPrintf("timer1 Interrupted\n");
+	//MyPrintf("timer1 Interrupted\n");
 }
 
 void TIMER2_IRQHandler() 
 {
-	MyPrintf("timer2 Interrupted\n");
+	//MyPrintf("timer2 Interrupted\n");
 }
 
 void TIMER3_IRQHandler() 
 {
-	MyPrintf("timer3 Interrupted\n");
+	//MyPrintf("timer3 Interrupted\n");
 }
 
 void TIMER4_IRQHandler() 
 {
-	MyPrintf("timer4 Interrupted\n");
+	//MyPrintf("timer4 Interrupted\n");
 }
 
 void TIMER5_IRQHandler() 
 {
-	MyPrintf("timer5 Interrupted\n");
+	//MyPrintf("timer5 Interrupted\n");
 }
 void TIMER6_IRQHandler() 
 {
-	MyPrintf("timer6 Interrupted\n");
+	//MyPrintf("timer6 Interrupted\n");
 }
 
 void TIMER7_IRQHandler() 
 {
-	MyPrintf("timer7 Interrupted\n");
+	//MyPrintf("timer7 Interrupted\n");
 }
 
 void TIMER8_IRQHandler() 
 {
-	MyPrintf("timer8 Interrupted\n");
+	//MyPrintf("timer8 Interrupted\n");
 }
 
 void SM4_IRQHandler() 
 {
-	MyPrintf("sm4 Interrupted\n");
+	//MyPrintf("sm4 Interrupted\n");
 }
 
 void SEC_IRQHandler() 
 {
-	MyPrintf("\r\nSEC_IRQHandler");
+	//MyPrintf("\r\nSEC_IRQHandler");
 }
 
 void MSR_IRQHandler()
 {
-	MyPrintf("\r\nMSR_IRQHandler");
+	//MyPrintf("\r\nMSR_IRQHandler");
 }
 
 void TRNG_IRQHandler()
 {
-	MyPrintf("\r\nTRNG_IRQHandler");
+	//MyPrintf("\r\nTRNG_IRQHandler");
 }	
 
 void WDT_IRQHandler()
 {
-	MyPrintf("\r\nWDT_IRQHandler");
+	//MyPrintf("\r\nWDT_IRQHandler");
 }
\ No newline at end of file
