mirror of
https://github.com/pvvx/RTL00_WEB.git
synced 2025-07-31 20:31:05 +00:00
update
This commit is contained in:
parent
34d3652711
commit
39f77eb92b
1844 changed files with 899433 additions and 7 deletions
102
USDK/example_sources/flash/main_tst_speed_flash.c
Normal file
102
USDK/example_sources/flash/main_tst_speed_flash.c
Normal file
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
* Test: Speed rd Flash
|
||||
*/
|
||||
|
||||
#include "rtl8195a.h"
|
||||
//#include "cortex.h"
|
||||
//#include "rtl8710.h"
|
||||
//#include "rom_lib.h"
|
||||
//#include "mask.h"
|
||||
#include "core_cm3.h"
|
||||
#include "flash_api.h"
|
||||
|
||||
//extern uint8_t __StackTop;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
u32 t[10];
|
||||
int i = 333333, x = SpicDualBitMode + 1;
|
||||
HalPinCtrlRtl8195A(JTAG, 0, 1);
|
||||
HalCpuClkConfig(1); // 0 - 166666666 Hz, 1 - 83333333 Hz, 2 - 41666666 Hz, 3 - 20833333 Hz, 4 - 10416666 Hz, 5 - 4000000 Hz
|
||||
ConfigDebugErr = -1;
|
||||
ConfigDebugInfo = -1;
|
||||
ConfigDebugWarn = -1;
|
||||
VectorTableInitRtl8195A(0x1FFFFFFC);
|
||||
HalInitPlatformLogUartV02();
|
||||
HalInitPlatformTimerV02();
|
||||
HalShowBuildInfoV02();
|
||||
flash_turnon();
|
||||
flash_init(&flashobj);
|
||||
// HalPinCtrlRtl8195A(SPI_FLASH, 0, 1); // SPI_FLASH_PIN_FCTRL(ON); // enable spi flash pins
|
||||
// SpicLoadInitParaFromClockRtl8195AV02();
|
||||
// SpicInitRtl8195AV02(2, SpicDualBitMode); //
|
||||
// SpicWaitBusyDoneRtl8195A();
|
||||
DiagPrintf("Flash[0]: 0x%08X\r\n", *(volatile u32 *)SPI_FLASH_BASE );
|
||||
// HalDelayUs(1000000);
|
||||
DiagPrintf("CPU CLK : %d Hz\r\n", HalGetCpuClk());
|
||||
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
|
||||
if(!(DWT->CTRL & DWT_CTRL_CYCCNTENA_Msk)) {
|
||||
DWT->CYCCNT = 0;
|
||||
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
|
||||
}
|
||||
while(x) {
|
||||
x--;
|
||||
DiagPrintf("<---- Init %d ---->\n", x);
|
||||
if (!SpicFlashInitRtl8195A(x)) {// SpicOneBitMode)){
|
||||
|
||||
DiagPrintf("SPI Init Fail!\n"); // DBG_SPIF_ERR?
|
||||
HAL_WRITE32(SYSTEM_CTRL_BASE, REG_SYS_DSTBY_INFO3, HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_DSTBY_INFO3)|0xf);
|
||||
while(1);
|
||||
}
|
||||
t[0] = DWT->CYCCNT;
|
||||
DiagPrintf("Test: t0 = %d\r\n", DWT->CYCCNT - t[0]);
|
||||
t[0] = DWT->CYCCNT;
|
||||
volatile u32 * ptr = (volatile u32 *)SPI_FLASH_BASE+0x4000;
|
||||
for(i=0; i < 16384; i++) *ptr++;
|
||||
t[1] = DWT->CYCCNT - t[0];
|
||||
DiagPrintf("read(): tFlash = %d, clk/byte = %d\r\n", t[1], t[1] >> 16);
|
||||
ptr = (volatile u32 *)SPI_FLASH_BASE+0x10000;
|
||||
t[0] = DWT->CYCCNT;
|
||||
memcpy((u8 *)0x10060000,(u8 *) SPI_FLASH_BASE+0x10000, 65536);
|
||||
for(i=0; i < 16384; i++) *ptr++;
|
||||
t[2] = DWT->CYCCNT - t[0];
|
||||
DiagPrintf("memcpy(): tFlash = %d, clk/byte = %d\r\n", t[2], t[2] >> 16);
|
||||
ptr = (volatile u32 *)0x10060000;
|
||||
t[0] = DWT->CYCCNT;
|
||||
for(i=0; i < 16384; i++) *ptr++;
|
||||
t[3] = DWT->CYCCNT - t[0];
|
||||
DiagPrintf("Speed rd RAM = %d, clk/byte = %d\r\n", t[3], t[3]>>16);
|
||||
ptr = (volatile u32 *)0x1FFF0000;
|
||||
t[0] = DWT->CYCCNT;
|
||||
for(i=0; i < 16384; i++) *ptr++;
|
||||
t[4] = DWT->CYCCNT - t[0];
|
||||
DiagPrintf("Speed rd TCM = %d, clk/byte = %d\r\n", t[4], t[4]>>16);
|
||||
DiagPrintf("read(): tFlash/tTCM = %d, tFlash/tRAM = %d\r\n", t[1]/t[4], t[1]/t[3]);
|
||||
DiagPrintf("memcpy(): tFlash/tTCM = %d, tFlash/tRAM = %d\r\n", t[2]/t[4], t[2]/t[3]);
|
||||
|
||||
t[0] = DWT->CYCCNT;
|
||||
SpicUserReadRtl8195A(16384*2, 0, (u8 *)0x10060000, x);
|
||||
t[1] = DWT->CYCCNT - t[0];
|
||||
DiagPrintf("Spic 1Read to RAM = %d, clk/byte = %d\r\n", t[1], t[1]>>16);
|
||||
t[0] = DWT->CYCCNT;
|
||||
SpicUserReadFourByteRtl8195A(16384*2, 0, (u32 *)0x10060000, x);
|
||||
t[1] = DWT->CYCCNT - t[0];
|
||||
DiagPrintf("Spic 4Read to RAM = %d, clk/byte = %d\r\n", t[1], t[1]>>16);
|
||||
|
||||
t[0] = DWT->CYCCNT;
|
||||
SpicUserReadRtl8195A(16384*2, 0, (u8 *)0x1FFF0000, x);
|
||||
t[1] = DWT->CYCCNT - t[0];
|
||||
DiagPrintf("Spic 1Read to TCM = %d, clk/byte = %d\r\n", t[1], t[1]>>16);
|
||||
t[0] = DWT->CYCCNT;
|
||||
SpicUserReadFourByteRtl8195A(16384*2, 0, (u32 *)0x1FFF0000, x);
|
||||
t[1] = DWT->CYCCNT - t[0];
|
||||
DiagPrintf("Spic 4Read to TCM = %d, clk/byte = %d\r\n", t[1], t[1]>>16);
|
||||
|
||||
}
|
||||
DiagPrintf("Flash[0]: 0x%08X\r\n", *(volatile u32 *)SPI_FLASH_BASE );
|
||||
DiagPrintf("End");
|
||||
while(1);
|
||||
}
|
||||
|
||||
|
||||
|
8
USDK/example_sources/flash/readme.txt
Normal file
8
USDK/example_sources/flash/readme.txt
Normal file
|
@ -0,0 +1,8 @@
|
|||
Example Description
|
||||
|
||||
This example read a specific flash offset, modify it and re-read again.
|
||||
|
||||
Requirement Components:
|
||||
None
|
||||
|
||||
|
119
USDK/example_sources/flash/src/main.c
Normal file
119
USDK/example_sources/flash/src/main.c
Normal file
|
@ -0,0 +1,119 @@
|
|||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "diag.h"
|
||||
#include "objects.h"
|
||||
#include "flash_api.h"
|
||||
#include "osdep_service.h"
|
||||
#include "device_lock.h"
|
||||
#include "main.h"
|
||||
|
||||
// Decide starting flash address for storing application data
|
||||
// User should pick address carefully to avoid corrupting image section
|
||||
|
||||
#define FLASH_APP_BASE 0xFF000
|
||||
static void flash_test_task(void *param)
|
||||
{
|
||||
flash_t flash;
|
||||
uint32_t address = FLASH_APP_BASE;
|
||||
|
||||
#if 1
|
||||
uint32_t val32_to_write = 0x13572468;
|
||||
uint32_t val32_to_read;
|
||||
int loop = 0;
|
||||
int result = 0;
|
||||
|
||||
for(loop = 0; loop < 10; loop++)
|
||||
{
|
||||
device_mutex_lock(RT_DEV_LOCK_FLASH);
|
||||
flash_read_word(&flash, address, &val32_to_read);
|
||||
DBG_8195A("Read Data 0x%x\n", val32_to_read);
|
||||
flash_erase_sector(&flash, address);
|
||||
flash_write_word(&flash, address, val32_to_write);
|
||||
flash_read_word(&flash, address, &val32_to_read);
|
||||
device_mutex_unlock(RT_DEV_LOCK_FLASH);
|
||||
|
||||
DBG_8195A("Read Data 0x%x\n", val32_to_read);
|
||||
|
||||
// verify result
|
||||
result = (val32_to_write == val32_to_read) ? 1 : 0;
|
||||
//printf("\r\nResult is %s\r\n", (result) ? "success" : "fail");
|
||||
DBG_8195A("\r\nResult is %s\r\n", (result) ? "success" : "fail");
|
||||
result = 0;
|
||||
}
|
||||
|
||||
#else
|
||||
int VERIFY_SIZE = 256;
|
||||
int SECTOR_SIZE = 16;
|
||||
|
||||
uint8_t writedata[VERIFY_SIZE];
|
||||
uint8_t readdata[VERIFY_SIZE];
|
||||
uint8_t verifydata = 0;
|
||||
int loop = 0;
|
||||
int index = 0;
|
||||
int sectorindex = 0;
|
||||
int result = 0;
|
||||
int resultsector = 0;
|
||||
int testloop = 0;
|
||||
|
||||
for(testloop = 0; testloop < 1; testloop++){
|
||||
address = FLASH_APP_BASE;
|
||||
for(sectorindex = 0; sectorindex < 4080; sectorindex++){
|
||||
result = 0;
|
||||
//address += SECTOR_SIZE;
|
||||
device_mutex_lock(RT_DEV_LOCK_FLASH);
|
||||
flash_erase_sector(&flash, address);
|
||||
device_mutex_unlock(RT_DEV_LOCK_FLASH);
|
||||
//DBG_8195A("Address = %x \n", address);
|
||||
for(loop = 0; loop < SECTOR_SIZE; loop++){
|
||||
for(index = 0; index < VERIFY_SIZE; index++)
|
||||
{
|
||||
writedata[index] = verifydata + index;
|
||||
}
|
||||
device_mutex_lock(RT_DEV_LOCK_FLASH);
|
||||
flash_stream_write(&flash, address, VERIFY_SIZE, &writedata);
|
||||
flash_stream_read(&flash, address, VERIFY_SIZE, &readdata);
|
||||
device_mutex_unlock(RT_DEV_LOCK_FLASH);
|
||||
|
||||
for(index = 0; index < VERIFY_SIZE; index++)
|
||||
{
|
||||
//DBG_8195A("Address = %x, Writedata = %x, Readdata = %x \n",address,writedata[index],readdata[index]);
|
||||
if(readdata[index] != writedata[index]){
|
||||
DBG_8195A("Error: Loop = %d, Address = %x, Writedata = %x, Readdata = %x \n",testloop,address,writedata[index],readdata[index]);
|
||||
}
|
||||
else{
|
||||
result++;
|
||||
//DBG_8195A(ANSI_COLOR_BLUE"Correct: Loop = %d, Address = %x, Writedata = %x, Readdata = %x \n"ANSI_COLOR_RESET,testloop,address,writedata[index],readdata[index]);
|
||||
}
|
||||
}
|
||||
address += VERIFY_SIZE;
|
||||
}
|
||||
if(result == VERIFY_SIZE * SECTOR_SIZE){
|
||||
//DBG_8195A("Sector %d Success \n", sectorindex);
|
||||
resultsector++;
|
||||
}
|
||||
}
|
||||
if(resultsector == 4079){
|
||||
DBG_8195A("Test Loop %d Success \n", testloop);
|
||||
}
|
||||
resultsector = 0;
|
||||
verifydata++;
|
||||
}
|
||||
//DBG_8195A("%d Sector Success \n", resultsector);
|
||||
|
||||
DBG_8195A("Test Done");
|
||||
|
||||
#endif
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
if(xTaskCreate(flash_test_task, ((const char*)"flash_test_task"), 1024, NULL, tskIDLE_PRIORITY + 1, NULL) != pdPASS)
|
||||
printf("\n\r%s xTaskCreate(flash_test_task) failed", __FUNCTION__);
|
||||
|
||||
/*Enable Schedule, Start Kernel*/
|
||||
if(rtw_get_scheduler_state() == OS_SCHEDULER_NOT_STARTED)
|
||||
vTaskStartScheduler();
|
||||
else
|
||||
vTaskDelete(NULL);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue