Files
kunlun/dtest/snapshot_monitor_test/snapshot_monitor_test.c
2024-09-28 14:24:04 +08:00

276 lines
8.1 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/****************************************************************************
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
be copied by any method or incorporated into another program without
the express written consent of Aerospace C.Power. This Information or any portion
thereof remains the property of Aerospace C.Power. The Information contained herein
is believed to be accurate and Aerospace C.Power assumes no responsibility or
liability for its use in any way and conveys no license or title under
any patent or copyright and makes no representation or warranty that this
Information is free from patent or copyright infringement.
****************************************************************************/
/* os shim includes */
#include "os_types.h"
#include "os_task.h"
#include "os_utils.h"
/* common includes */
#include "iot_io.h"
#include "iot_bitops.h"
/* driver includes */
#include "iot_clock.h"
/* cli includes */
#include "iot_cli.h"
#include "iot_uart_h.h"
/* debug includes*/
#include "dbg_io.h"
#include "ahb.h"
#include "cpu.h"
#include "flash.h"
#include "snapshot.h"
#include "iot_busmon.h"
#include "iot_version.h"
int platform_init();
os_task_h snapshot_test_handle;
void test_init()
{
/* init common modules */
iot_bitops_init();
/* init os related modules and utilities */
os_utils_init();
/* init dbglog module */
iot_dbglog_init();
/*init uart module*/
iot_uart_init(1);
}
/**
* @brief snapshot_iram_test - 此函数为在ram中执行的测试函数
*
* @param cpu
*/
void snapshot_iram_test(uint32_t cpu)
{
iot_printf("run on %s", (cpu == HAL_INTR_CPU_0)?("HAL_INTR_CPU_0"): \
("HAL_INTR_CPU_1"));
}
void snapshot_task_1(void *arg)
{
snapshot_config_t config;
uint32_t ram_d_test = 0x12345677;
uint32_t tmp = 0;
config.cpu = cpu_get_mhartid();
config.assert = 0;
if(iot_snapshot_run_check()) {
iot_printf("Error : Snapshot is running.\r\n");
while(1);
}
iot_snapshot_monitor_init();
for(;;) {
iot_printf("\r\n\r\n*******************************************\r\n");
iot_printf("*******************************************\r\n");
/* RAM D 读测试 */
config.rw_mode = SNAPSHOT_MONITOR_READ;
config.mask = (config.cpu == HAL_INTR_CPU_0)?(SNAPSHOT_CPU0_D_MON): \
(SNAPSHOT_CPU1_D_MON);
config.data_low_limit = (uint32_t)&ram_d_test;
config.data_high_limit = (uint32_t)&ram_d_test;
iot_snapshot_monitor_config(&config);
/*iot_snapshot_monitor_enable()与iot_snapshot_monitor_disable()用于确定
需要监视的范围若无结束范围不需要调用iot_snapshot_monitor_disable()*/
iot_snapshot_monitor_enable();
iot_printf("1 - RAM D R Test\r\n");
tmp = ram_d_test + 1;
iot_printf("tmp = 0x%08X", tmp);
iot_snapshot_monitor_disable();
iot_snapshot_monitor_get_status();
/* RAM D 写测试 */
config.rw_mode = SNAPSHOT_MONITOR_WRITE;
config.mask = (config.cpu == HAL_INTR_CPU_0)?(SNAPSHOT_CPU0_D_MON): \
(SNAPSHOT_CPU1_D_MON);
config.data_low_limit = (uint32_t)&ram_d_test;
config.data_high_limit = (uint32_t)&ram_d_test;
iot_snapshot_monitor_config(&config);
iot_snapshot_monitor_enable();
iot_printf("\r\n\r\n2 - RAM D W Test\r\n");
ram_d_test = 0x87654321;
iot_printf("ram_d_test = 0x%08X", ram_d_test);
iot_snapshot_monitor_disable();
iot_snapshot_monitor_get_status();
/* RAM I 测试 */
config.rw_mode = SNAPSHOT_MONITOR_READ;
config.mask = (config.cpu == HAL_INTR_CPU_0)?(SNAPSHOT_CPU0_I_MON): \
(SNAPSHOT_CPU1_I_MON);
config.instruction_low_limit = (uint32_t)snapshot_iram_test;
config.instruction_high_limit = (uint32_t)snapshot_iram_test;
iot_snapshot_monitor_config(&config);
iot_snapshot_monitor_enable();
iot_printf("\r\n\r\n3 - RAM I R Test\r\n");
snapshot_iram_test(cpu_get_mhartid());
iot_snapshot_monitor_disable();
iot_snapshot_monitor_get_status();
/* FLASH D 读测试 */
config.rw_mode = SNAPSHOT_MONITOR_READ;
config.mask = (config.cpu == HAL_INTR_CPU_0)?(SNAPSHOT_CPU0_D_MON): \
(SNAPSHOT_CPU1_D_MON);
config.data_low_limit = (uint32_t)iot_version_hex;
config.data_high_limit = (uint32_t)iot_version_hex;
iot_snapshot_monitor_config(&config);
iot_snapshot_monitor_enable();
iot_printf("\r\n\r\n4 - FLASH D R Test\r\n");
tmp = *((volatile uint32_t *)iot_version_hex);
iot_printf("tmp = 0x%08X", tmp);
iot_snapshot_monitor_disable();
iot_snapshot_monitor_get_status();
/* FLASH D 写测试 */
config.rw_mode = SNAPSHOT_MONITOR_WRITE;
config.mask = (config.cpu == HAL_INTR_CPU_0)?(SNAPSHOT_CPU0_D_MON): \
(SNAPSHOT_CPU1_D_MON);
config.data_low_limit = (uint32_t)iot_version_hex;
config.data_high_limit = (uint32_t)iot_version_hex;
iot_snapshot_monitor_config(&config);
iot_snapshot_monitor_enable();
iot_printf("\r\n\r\n5 - FLASH D W Test\r\n");
*((volatile uint32_t *)iot_version_hex) = tmp;
iot_printf("tmp = 0x%08X", tmp);
iot_snapshot_monitor_disable();
iot_snapshot_monitor_get_status();
/* FLASH I 测试 */
config.rw_mode = SNAPSHOT_MONITOR_READ;
config.mask = (config.cpu == HAL_INTR_CPU_0)?(SNAPSHOT_CPU0_I_MON): \
(SNAPSHOT_CPU1_I_MON);
config.instruction_low_limit = (uint32_t)iot_version_hex;
config.instruction_high_limit = (uint32_t)iot_version_hex;
iot_snapshot_monitor_config(&config);
iot_snapshot_monitor_enable();
iot_printf("\r\n\r\n6 - FLASH I R Test\r\n");
tmp = iot_version_hex();
iot_printf("iot_version_hex() = 0x%08X", tmp);
iot_snapshot_monitor_disable();
iot_snapshot_monitor_get_status();
/* FLASH I ASSERT 测试 */
config.assert = (config.cpu == HAL_INTR_CPU_0)?(SNAPSHOT_CPU0_I_MON): \
(SNAPSHOT_CPU1_I_MON);
config.rw_mode = SNAPSHOT_MONITOR_READ;
config.mask = (config.cpu == HAL_INTR_CPU_0)?(SNAPSHOT_CPU0_I_MON): \
(SNAPSHOT_CPU1_I_MON);
config.instruction_low_limit = (uint32_t)iot_version_hex;
config.instruction_high_limit = (uint32_t)iot_version_hex;
iot_snapshot_monitor_config(&config);
iot_snapshot_monitor_enable();
iot_printf("\r\n\r\n7 - FLASH I R ASSERT Test\r\n");
tmp = iot_version_hex();
iot_printf("iot_version_hex() = 0x%08X", tmp);
iot_snapshot_monitor_disable();
iot_snapshot_monitor_get_status();
iot_printf("\r\n\r\n");
os_delay(3000);
}
os_delete_task(snapshot_test_handle);
}
int32_t snapshot_task_init()
{
/* start plc lib task */
snapshot_test_handle = os_create_task(snapshot_task_1, NULL, 9);
//create the tasks;
if(snapshot_test_handle != NULL) {
iot_printf("Task created successfully ..\r\n");
}
return 0;
}
int32_t iot_task_start()
{
//start the tasks;
os_start_kernel();
return 0;
}
static int32_t iot_platform_init()
{
/*platform intialization*/
platform_init();
//resource initializations;
system_clock_init();
dbg_uart_init();
dbg_uart_stage1_init();
return 0;
}
int32_t iot_module_init(void)
{
/* platform intialization */
iot_platform_init();
test_init();
flash_init(1);
/* cache enable */
ahb_cache_disable();
ahb_cache_enable();
ahb_cache_reset();
ahb_cache_fill_valid_space();
/* create all the tasks */
snapshot_task_init();
iot_printf("starting...\n");
return 0;
}
int32_t iot_module_start(void)
{
int32_t res = 0;
res = iot_task_start();
return res;
}
int main(void)
{
iot_module_init();
iot_module_start();
return 0;
}