初始提交

This commit is contained in:
2024-09-28 14:24:04 +08:00
commit c756587541
5564 changed files with 2413077 additions and 0 deletions

53
dtest/nand_test/Makefile Executable file
View File

@@ -0,0 +1,53 @@
# OUTPUT type
# 1 - .out
# 2 - .a
# 3 - .so
OUTPUT_TYPE = 1
OUTPUT_NAME = nand_test
SUB_DIRS = $(TOPDIR)/common/os_shim/dtestos
# .h files dir
ADD_INCLUDE += $(TOPDIR)/inc/io_lib $(TOPDIR)/inc/driver $(TOPDIR)/driver/inc
# predefined macro
PRE_MARCO +=
LD_SCRIPT = link_soc.lds
ifeq ($(gcc),arm)
ADD_LIB = cm3
ADD_LIBDIR = $(TOPDIR)/startup/cm3
else
ADD_LIB = riscv
ADD_LIBDIR =$(TOPDIR)/startup/riscv
endif
# lib dir
ADD_LIBDIR += $(TOPDIR)/driver $(TOPDIR)/common
# lib need to ld together
ADD_LIB += driver common
#####################################################
ifdef TOPDIR
include $(TOPDIR)/build/makefile.cfg
else
include $(CURDIR)/build/makefile.cfg
TOPDIR = $(CURDIR)
export TOPDIR
endif
dump:
$(OBJDUMP) -D -S -l $(OUTPUT_FULL_NAME) > $(OUTPUT_FULL_NAME).dump
# display the obj files and output name
debug:
@echo TOPDIR=$(TOPDIR)
@echo OUTPUT_LIB=$(OUTPUT_FULL_NAME)
@echo DEPS=$(DEPS)
@echo OBJECTS=$(OBJECTS)
@echo SRCS=$(SRCS)
@echo OBJECTS folder=$(foreach dirname, $(SUB_DIRS), $(addprefix $(BIN_DIR)/, $(dirname)))
@echo output_name=$(OUTPUT_FULL_NAME)

161
dtest/nand_test/nand_flash_test.c Executable file
View File

@@ -0,0 +1,161 @@
/****************************************************************************
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.
****************************************************************************/
#include "chip_reg_base.h"
#include "hw_reg_api.h"
#include "iot_bitops.h"
#include "os_lock.h"
#include "iot_config.h"
#include "ahb_rf.h"
#include "os_mem.h"
#include "dbg_io.h"
#include "iot_io.h"
#include "hw_reg_api.h"
#include "ds35x1gaxxx.h"
#include "iot_config.h"
#include "gpio_mtx.h"
#include "nand_flash.h"
#include "iot_nand_flash_api.h"
#define RX_NUM 20
#define TX_NUM 30
void nand_main() {
volatile uint32_t loop = 0x10000;
uint8_t dev_ID = 0;
uint8_t manuf_ID = 0;
uint8_t reg_stats = 0;
uint8_t i = 0;
uint8_t check_cnt = 0;
char TxBuf[TX_NUM] = {0x39,0x08,0x08,0x44,0x55,0x07,0x57,
0x88,0x08,0x39,0x39,0x39,0xdd,0xee,0xff,
0x15,0x20,0x88,0x11,0x39,0x60,0x70,
0x88,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0};
char RxBuf[RX_NUM];
dbg_uart_init();
iot_printf("nand flash test start..........\r\n");
iot_nandfc_cfg_t cfg = {0};
cfg.spi.gpio.clk = 37;
cfg.spi.gpio.cs = 28;
cfg.spi.gpio.miso = 40;
cfg.spi.gpio.mosi = 39;
cfg.spi.port = 0;
iot_nandfc_init(&cfg);
os_mem_set(RxBuf, 0,RX_NUM);
do {
iot_nandfc_reset_device();
loop = 0x1000;
while(loop--);
dev_ID = iot_nandfc_read_chip_ID();
manuf_ID = iot_nandfc_read_manufactury_ID();
iot_printf("Device ID: %x\r\n", dev_ID);
iot_printf("Manuf ID: %x\r\n", manuf_ID);
iot_printf("******************************\r\n");
iot_printf("\r\n");
reg_stats = nandfc_get_feature(STATUS_ADDR);
iot_printf("status reg: %x\r\n", reg_stats);
iot_printf("******************************\r\n");
iot_printf("\r\n");
reg_stats = nandfc_set_feature(BLOCK_LOCK_ADDR,0x00);
iot_printf("BL reg set: %x\r\n", reg_stats);
iot_printf("******************************\r\n");
iot_printf("\r\n");
reg_stats = nandfc_get_feature(BLOCK_LOCK_ADDR);
iot_printf("BL reg get: %x\r\n", reg_stats);
iot_printf("******************************\r\n");
iot_printf("\r\n");
nandfc_write_en_switch(ENABLE);
loop = 0x1000;
while(loop--);
reg_stats = nandfc_get_feature(STATUS_ADDR);
iot_printf("status reg: %x\r\n", reg_stats);
iot_printf("******************************\r\n");
iot_printf("\r\n");
if(!iot_nandfc_program_data_with_erase(TxBuf, 2045+(11<<12), TX_NUM))
{
iot_printf("Program data done! \r\n");
iot_printf("******************************\r\n");
iot_printf("\r\n");
}
else
{
iot_printf("Program data Failed!!!! \r\n");
iot_printf("******************************\r\n");
iot_printf("\r\n");
}
iot_nandfc_read_data(RxBuf, 2045+(11<<12), RX_NUM);
for(i = 0; i<RX_NUM; i++)
{
iot_printf("Received data1[%d]: %x\r\n",i, RxBuf[i]);
}
iot_printf("******************************\r\n");
iot_printf("\r\n");
for(i = 0; i<RX_NUM; i++)
{
if(RxBuf[i] != TxBuf[i])
{
iot_printf("Somthing wrong in programing or reading progress!!: RxBuf[%d] != TxBuf[%d]\r\n",i, i);
}
else
{
check_cnt++;
}
}
if(RX_NUM==check_cnt)
{
iot_printf("NAND flash test done!!!");
}
else
{
iot_printf("NAND flash test Failed!!!");
}
check_cnt = 0;
iot_printf("******************************\r\n");
loop = 0x2000000;
while(loop--);
} while (true);
return;
}
#ifdef __GNUC__
int main(void) {
nand_main();
return 0;
}
#endif // __GCC__