RTOS 设计说明
27 Nov 2024
Read time: 2 minute(s)
RTOS 源码说明
相关模块 | 源码路径 |
---|---|
mtd blk |
kernel/rt-thread/components/drivers/mtd/mtd_nand.c //mtd 设备通用平台 bsp/artinchip/drv/spinand/spinand_port.c //mtd 设备通用平台对接 bsp/artinchip/drv/spinand/spinand_block.c //blk 设备接口实现 |
spinand | bsp/peripheral/spinand/ |
qspi | bsp/artinchip/drv/qspi/drv_qspi.c |
RTOS 层次关系
mtd 设备用来挂载 uffs 文件系统,blk 设备用来挂载 FatFS 文件系统。
RTOS 关键流程
- SPI NAND
初始化流程
rt_hw_spinand_register //bsp/artinchip/drv/spinand/spinand_port.c |-> aic_qspi_bus_attach_device("qspi0", "spinand0", 0, 4, RT_NULL, RT_NULL); //创建 qspi 总线 |-> rt_hw_mtd_spinand_register("spinand0"); |-> rt_hw_mtd_spinand_init(spinand); |-> spinand_flash_init(flash); //bsp/peripheral/spinand/spinand.c |-> spinand_info_read(flash); |-> nand_bbt_init(flash); |-> mtd_parts_parse(IMAGE_CFG_JSON_PARTS_MTD); |-> rt_mtd_nand_register_device(p->name, &g_mtd_partitions[i]); //注册 mtd 设备 |-> rt_blk_nand_register_device(p->name, &g_mtd_partitions[i]); //注册 block 设备
- 读数据流程
mtd_read //kernel/rt-thread/components/drivers/mtd/mtd_nand.c |-> spinand_mtd_read(device ...) //bsp/artinchip/drv/spinand/spinand_port.c |-> spinand_read(flash, data, start, dolen); //bsp/peripheral/spinand/spinand.c |-> spinand_block_isbad(flash, blk); |-> spinand_read_page(flash, page, p, flash->info->page_size, NULL, 0); |-> spinand_load_page_op(flash, page); |-> spinand_read_from_cache_op(flash, column, buf, nbytes);
- blk
设备读数据流程
rt_spinand_read //bsp/artinchip/drv/spinand/spinand_block.c |-> spinand_mtd_read(device ...) //bsp/artinchip/drv/spinand/spinand_port.c |-> spinand_read(flash, data, start, dolen); //bsp/peripheral/spinand/spinand.c |-> spinand_block_isbad(flash, blk); |-> spinand_read_page(flash, page, p, flash->info->page_size, NULL, 0); |-> spinand_load_page_op(flash, page); |-> spinand_read_from_cache_op(flash, column, buf, nbytes);