Skip to content

Commit

Permalink
test fine
Browse files Browse the repository at this point in the history
  • Loading branch information
qitas committed Nov 1, 2021
1 parent 031a800 commit 35b9e65
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 63 deletions.
101 changes: 42 additions & 59 deletions project/IAP/Core/Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void StartSystemTask(void const * argument);

/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
static uint32_t rcnt = 0;


/* USER CODE END 0 */

Expand Down Expand Up @@ -110,28 +110,23 @@ int main(void)
// uint32_t rcnt = 0;
#ifdef BLT
char buf[50];
// bootinit();
// LL_mDelay(30);
bootinit();
// appjump(USER_APP2_ADDRESS);
LL_mDelay(30);
memset((char *)buf,0,sizeof(buf));
// uint16_t *uuid = (uint16_t *) UID_BASE;
sprintf((char *)buf, "BLT:%x-%x,%x-%x,%d\r\n",Mark_Get(bkp_app1_addr),Mark_Get(bkp_app2_addr),Mark_Get(bkp_app1_mark),Mark_Get(bkp_app2_mark),flash_size);
// HAL_UART_Transmit(&huart1,(uint8_t *)buf,strlen((char *)buf),100);
uart_tx_str((uint8_t *)buf,strlen((char *)buf));
appjump(USER_APP1_ADDRESS);
//
#else

// SCB->VTOR = USER_APP2_ADDRESS;
// appjump(USER_APP2_ADDRESS);
char buf[50];
sprintf((char *)buf, "APP:%x-%x,%x-%x\r\n",Mark_Get(bkp_app1_addr),Mark_Get(bkp_app2_addr),Mark_Get(bkp_app1_mark),Mark_Get(bkp_app2_mark));
uart_tx_str((uint8_t *)buf,strlen((char *)buf));

// feed_dog();
// if(Mark_Get(bkp_app1_mark))
// {
// if (appjump(Mark_Get(bkp_app1_addr))) Mark_Set(bkp_app1_mark,0);
// }
// else if(Mark_Get(bkp_app2_mark))
// {
// if (appjump(Mark_Get(bkp_app2_addr))) Mark_Set(bkp_app2_mark,0);
// }

// FlashTestWR();
/* USER CODE END 2 */

Expand Down Expand Up @@ -171,6 +166,7 @@ int main(void)
/* Infinite loop */
/* USER CODE BEGIN WHILE */
#endif
uint32_t rcnt = 0;
while (1)
{
/* USER CODE END WHILE */
Expand All @@ -181,53 +177,14 @@ int main(void)
feed_dog();
#ifdef BLT
bootloop();
if(rcnt%1000==0)
if(rcnt%3000==0)
{
feed_dog();
memset((char *)buf,0,sizeof(buf));
sprintf((char *)buf, "\r\nBKP:%x,%x,%x,%x,%x\r\n",Mark_Get(bkp_app1_addr),Mark_Get(bkp_app2_addr),Mark_Get(bkp_app1_mark),Mark_Get(bkp_app2_mark),Mark_Get(bkp_boot_mark));
uart_tx_str((uint8_t *)buf,strlen((char *)buf));
}
#endif
#ifdef APP1
if(rcnt%1000==0)
{
feed_dog();
uart_tx_str("App1 Mark\r\n",15);
}
if(rcnt>5000)
{
sprintf(buf, "\r\nAPP1:%x,%x,%x,%x,%x\r\n\r\n",Mark_Get(bkp_app1_addr),Mark_Get(bkp_app2_addr),Mark_Get(bkp_app1_mark),Mark_Get(bkp_app2_mark),Mark_Get(bkp_boot_mark));
// HAL_UART_Transmit(&huart1,(uint8_t *)buf,strlen(buf),100);
uart_tx_str((uint8_t *)buf,strlen((char *)buf));
Mark_Set(bkp_app1_addr,0);
Mark_Set(bkp_app1_mark,0);
Mark_Set(bkp_app2_mark,0);
Mark_Set(bkp_app2_addr,USER_APP2_ADDRESS);
LL_mDelay(20);
NVIC_SystemReset();
}
#endif
#ifdef APP2
if(rcnt%1000==0)
{
feed_dog();
// HAL_UART_Transmit(&huart1,"test app2\r\n",15,100);
uart_tx_str("app2 test\r\n",15);
}
else if(rcnt>10000)
{
sprintf((char *)buf, "APP2:%x,%x,%x,%x,%x\r\n",Mark_Get(bkp_app1_addr),Mark_Get(bkp_app2_addr),Mark_Get(bkp_app1_mark),Mark_Get(bkp_app2_mark),Mark_Get(bkp_boot_mark));
// HAL_UART_Transmit(&huart1,(uint8_t *)buf,strlen((char *)buf),100);
uart_tx_str((uint8_t *)buf,strlen((char *)buf));
Mark_Set(bkp_app1_addr,USER_APP1_ADDRESS);
Mark_Set(bkp_app2_addr,0);
Mark_Set(bkp_app2_mark,0);
Mark_Set(bkp_app1_mark,0);
LL_mDelay(50);
NVIC_SystemReset();
}
#endif
}
/* USER CODE END 3 */
}
Expand Down Expand Up @@ -514,17 +471,43 @@ void StartDefaultTask(void const * argument)
void StartSystemTask(void const * argument)
{
/* USER CODE BEGIN StartSystemTask */
#ifndef BLT
char buf[50];
static uint32_t rcnt = 0;
/* Infinite loop */
for(;;)
{
rcnt++;
#ifdef APP1
osDelay(1000);
uart_tx_str("App Mark\r\n",15);
// sprintf(buf, "\r\nAPP Mark:%x,%x,%x,%x,%x\r\n\r\n",Mark_Get(bkp_app1_addr),Mark_Get(bkp_app2_addr),Mark_Get(bkp_app1_mark),Mark_Get(bkp_app2_mark),Mark_Get(bkp_boot_mark));
// uart_tx_str((uint8_t *)buf,strlen((char *)buf));
uart_tx_str("App1 Mark\r\n",15);
if(rcnt>5)
{
sprintf(buf, "\r\nAPP1:%x,%x,%x,%x,%x\r\n\r\n",Mark_Get(bkp_app1_addr),Mark_Get(bkp_app2_addr),Mark_Get(bkp_app1_mark),Mark_Get(bkp_app2_mark),Mark_Get(bkp_boot_mark));
uart_tx_str((uint8_t *)buf,strlen((char *)buf));
Mark_Set(bkp_app1_addr,0);
Mark_Set(bkp_app1_mark,0);
Mark_Set(bkp_app2_mark,0);
Mark_Set(bkp_app2_addr,USER_APP2_ADDRESS);
osDelay(10);
sysReset();
}
#endif
#ifdef APP2
osDelay(1000);
uart_tx_str("app2 test\r\n",15);
if(rcnt>5)
{
sprintf((char *)buf, "APP2:%x,%x,%x,%x,%x\r\n",Mark_Get(bkp_app1_addr),Mark_Get(bkp_app2_addr),Mark_Get(bkp_app1_mark),Mark_Get(bkp_app2_mark),Mark_Get(bkp_boot_mark));
uart_tx_str((uint8_t *)buf,strlen((char *)buf));
Mark_Set(bkp_app1_addr,USER_APP1_ADDRESS);
Mark_Set(bkp_app2_addr,0);
Mark_Set(bkp_app2_mark,0);
Mark_Set(bkp_app1_mark,0);
osDelay(10);
sysReset();
}
#endif
}
#endif
/* USER CODE END StartSystemTask */
}

Expand Down
4 changes: 2 additions & 2 deletions project/IAP/MDK-ARM/IAP.uvoptx
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@
<OPTFL>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<IsCurrentTarget>0</IsCurrentTarget>
<IsCurrentTarget>1</IsCurrentTarget>
</OPTFL>
<CpuCode>18</CpuCode>
<DebugOpt>
Expand Down Expand Up @@ -395,7 +395,7 @@
<OPTFL>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<IsCurrentTarget>1</IsCurrentTarget>
<IsCurrentTarget>0</IsCurrentTarget>
</OPTFL>
<CpuCode>18</CpuCode>
<DebugOpt>
Expand Down
3 changes: 1 addition & 2 deletions project/IAP/User/Src/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@ uint8_t appjump(const uint32_t addr)
__set_PSP(*(__IO uint32_t*) addr);
__set_MSP(*(__IO uint32_t*) addr);
__set_CONTROL(0);
SCB->VTOR = USER_APP1_ADDRESS;
SCB->VTOR = addr;
Jump_To_Application();
return 0;
}
else return 1;
}

/******************************************************************************
**函数信息 :
**功能描述 :
Expand Down

0 comments on commit 35b9e65

Please sign in to comment.