mpu缺页模拟完善
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
#include <unistd.h>
|
||||
#include <u_vmam.h>
|
||||
#include "fs_test.h"
|
||||
#include "mm_test.h"
|
||||
#include <u_sleep.h>
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
for (int i = 0; i < argc; i++)
|
||||
@@ -16,5 +18,11 @@ int main(int argc, char *argv[])
|
||||
fs_test3();
|
||||
fs_test2();
|
||||
fs_test();
|
||||
mm_test();
|
||||
mm_test1();
|
||||
// while (1)
|
||||
// {
|
||||
// u_sleep_ms(1000);
|
||||
// }
|
||||
return 0;
|
||||
}
|
||||
|
||||
42
mkrtos_user/user/app/test/mm_test.c
Normal file
42
mkrtos_user/user/app/test/mm_test.c
Normal file
@@ -0,0 +1,42 @@
|
||||
#include <sys/mman.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
void mm_test(void)
|
||||
{
|
||||
#define TEST_MEM_SIZE (1024)
|
||||
for (int i = 0; i < 1024; i++)
|
||||
{
|
||||
void *mem = mmap(0, TEST_MEM_SIZE, PROT_READ | PROT_WRITE | PROT_PFS, MAP_PRIVATE, -1, 0);
|
||||
if (mem == NULL)
|
||||
{
|
||||
printf("mmap failed.\n");
|
||||
return;
|
||||
}
|
||||
memset(mem, 0, TEST_MEM_SIZE);
|
||||
if (munmap(mem, TEST_MEM_SIZE) < 0)
|
||||
{
|
||||
printf("munmap failed.\n");
|
||||
}
|
||||
}
|
||||
#undef TEST_MEM_SIZE
|
||||
}
|
||||
void mm_test1(void)
|
||||
{
|
||||
#define TEST_MEM_SIZE (1024 + 512)
|
||||
for (int i = 0; i < 1024; i++)
|
||||
{
|
||||
void *mem = mmap(0, TEST_MEM_SIZE, PROT_READ | PROT_WRITE | PROT_PFS, MAP_PRIVATE, -1, 0);
|
||||
if ((long)mem < 0)
|
||||
{
|
||||
printf("mmap failed.\n");
|
||||
return;
|
||||
}
|
||||
memset(mem, 0, TEST_MEM_SIZE);
|
||||
// if (munmap(mem, TEST_MEM_SIZE) < 0)
|
||||
// {
|
||||
// printf("munmap failed.\n");
|
||||
// }
|
||||
}
|
||||
#undef TEST_MEM_SIZE
|
||||
}
|
||||
5
mkrtos_user/user/app/test/mm_test.h
Normal file
5
mkrtos_user/user/app/test/mm_test.h
Normal file
@@ -0,0 +1,5 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
void mm_test(void);
|
||||
void mm_test1(void);
|
||||
@@ -102,14 +102,14 @@ int flash_init(void)
|
||||
msg_tag_t tag;
|
||||
addr_t vaddr;
|
||||
|
||||
tag = u_vmam_alloc(VMA_PROT, vma_addr_create(VPAGE_PROT_RW, 0, 0),
|
||||
tag = u_vmam_alloc(VMA_PROT, vma_addr_create(VPAGE_PROT_RW, VMA_ADDR_PAGE_FAULT_SIM, 0),
|
||||
0x400 /*TODO:*/, 0x40023C00, &vaddr);
|
||||
if (msg_tag_get_val(tag) < 0)
|
||||
{
|
||||
return msg_tag_get_val(tag);
|
||||
}
|
||||
|
||||
tag = u_vmam_alloc(VMA_PROT, vma_addr_create(VPAGE_PROT_RW, 0, 0),
|
||||
tag = u_vmam_alloc(VMA_PROT, vma_addr_create(VPAGE_PROT_RW, VMA_ADDR_PAGE_FAULT_SIM, 0),
|
||||
32 * 1024 * 1024 /*TODO:*/, 0x8000000, &vaddr);
|
||||
if (msg_tag_get_val(tag) < 0)
|
||||
{
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
cmake_minimum_required(VERSION 3.13)
|
||||
|
||||
file(GLOB_RECURSE deps
|
||||
*.c
|
||||
*.S
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_bsp/STM32/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/src/*.c
|
||||
file(
|
||||
GLOB deps
|
||||
*.c
|
||||
)
|
||||
|
||||
|
||||
add_executable(
|
||||
block
|
||||
block.elf
|
||||
${deps}
|
||||
${START_SRC}
|
||||
)
|
||||
target_link_libraries(
|
||||
block
|
||||
block.elf
|
||||
PUBLIC
|
||||
-Bstatic
|
||||
${LIBC_NAME}
|
||||
@@ -23,53 +24,53 @@ target_link_libraries(
|
||||
sys
|
||||
sys_util
|
||||
sys_svr
|
||||
printf
|
||||
--no-whole-archive
|
||||
${GCC_LIB_PATH}/libgcc.a
|
||||
)
|
||||
|
||||
target_include_directories(
|
||||
block
|
||||
block.elf
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../mk_drv
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/sys/inc
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/sys/inc/${ARCH_NAME}
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/sys_svr/inc
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/util/inc
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/libfdt/lib/contrib
|
||||
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_bsp/STM32/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Include
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_bsp/STM32/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_bsp/STM32/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/
|
||||
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/sys/inc
|
||||
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/user/drv/lib/mk_block
|
||||
)
|
||||
add_dependencies(
|
||||
block.elf
|
||||
${START_LIB}
|
||||
sys
|
||||
sys_util
|
||||
mk_char
|
||||
mk_drv
|
||||
printf
|
||||
# mk_block
|
||||
)
|
||||
|
||||
set_target_properties(
|
||||
block PROPERTIES LINK_FLAGS
|
||||
block.elf PROPERTIES LINK_FLAGS
|
||||
"-T ${CMAKE_CURRENT_LIST_DIR}/${ARCH_NAME}/link.lds ${CORTEX_M_LINK_FLAGS} --gc-section -no-dynamic-linker "
|
||||
#--no-warn-rwx-segments
|
||||
)
|
||||
add_custom_target(
|
||||
block_dump ALL
|
||||
COMMAND
|
||||
${CMAKE_OBJDUMP} -s -S block > ${CMAKE_SOURCE_DIR}/build/output/block.S
|
||||
${CMAKE_OBJDUMP} -s -S block.elf > ${CMAKE_SOURCE_DIR}/build/output/block.S
|
||||
COMMAND
|
||||
${CMAKE_READELF} -a block > ${CMAKE_SOURCE_DIR}/build/output/block.txt
|
||||
${CMAKE_READELF} -a block.elf > ${CMAKE_SOURCE_DIR}/build/output/block.txt
|
||||
COMMAND
|
||||
${CMAKE_OBJCOPY} -O binary -S block block.bin
|
||||
${CMAKE_OBJCOPY} -O binary -S block.elf block.bin
|
||||
COMMAND
|
||||
${CMAKE_SIZE} block
|
||||
${CMAKE_SIZE} block.elf
|
||||
COMMAND
|
||||
${CMAKE_COMMAND} -E copy block.bin ${CMAKE_SOURCE_DIR}/build/output/cpio/block
|
||||
COMMAND
|
||||
cp block ${CMAKE_SOURCE_DIR}/build/output/block
|
||||
cp block.elf ${CMAKE_SOURCE_DIR}/build/output/block.elf
|
||||
)
|
||||
add_dependencies(block_dump block)
|
||||
|
||||
add_dependencies(
|
||||
block
|
||||
fdt
|
||||
sys
|
||||
sys_util
|
||||
sys_svr
|
||||
mk_drv
|
||||
)
|
||||
add_dependencies(block_dump block.elf)
|
||||
|
||||
@@ -1,115 +1,63 @@
|
||||
|
||||
#include "stm32f2xx_conf.h"
|
||||
#include <u_types.h>
|
||||
|
||||
/* Base address of the Flash sectors */
|
||||
#define ADDR_FLASH_SECTOR_0 ((uint32_t)0x08000000) /* Base @ of Sector 0, 16 Kbytes */
|
||||
#define ADDR_FLASH_SECTOR_1 ((uint32_t)0x08004000) /* Base @ of Sector 1, 16 Kbytes */
|
||||
#define ADDR_FLASH_SECTOR_2 ((uint32_t)0x08008000) /* Base @ of Sector 2, 16 Kbytes */
|
||||
#define ADDR_FLASH_SECTOR_3 ((uint32_t)0x0800C000) /* Base @ of Sector 3, 16 Kbytes */
|
||||
#define ADDR_FLASH_SECTOR_4 ((uint32_t)0x08010000) /* Base @ of Sector 4, 64 Kbytes */
|
||||
#define ADDR_FLASH_SECTOR_5 ((uint32_t)0x08020000) /* Base @ of Sector 5, 128 Kbytes */
|
||||
#define ADDR_FLASH_SECTOR_6 ((uint32_t)0x08040000) /* Base @ of Sector 6, 128 Kbytes */
|
||||
#define ADDR_FLASH_SECTOR_7 ((uint32_t)0x08060000) /* Base @ of Sector 7, 128 Kbytes */
|
||||
#define ADDR_FLASH_SECTOR_8 ((uint32_t)0x08080000) /* Base @ of Sector 8, 128 Kbytes */
|
||||
#define ADDR_FLASH_SECTOR_9 ((uint32_t)0x080A0000) /* Base @ of Sector 9, 128 Kbytes */
|
||||
#define ADDR_FLASH_SECTOR_10 ((uint32_t)0x080C0000) /* Base @ of Sector 10, 128 Kbytes */
|
||||
#define ADDR_FLASH_SECTOR_11 ((uint32_t)0x080E0000) /* Base @ of Sector 11, 128 Kbytes */
|
||||
|
||||
uint32_t GetSector(uint32_t Address)
|
||||
{
|
||||
uint32_t sector = 0;
|
||||
|
||||
if ((Address < ADDR_FLASH_SECTOR_1) && (Address >= ADDR_FLASH_SECTOR_0)) {
|
||||
sector = FLASH_Sector_0;
|
||||
} else if ((Address < ADDR_FLASH_SECTOR_2) && (Address >= ADDR_FLASH_SECTOR_1)) {
|
||||
sector = FLASH_Sector_1;
|
||||
} else if ((Address < ADDR_FLASH_SECTOR_3) && (Address >= ADDR_FLASH_SECTOR_2)) {
|
||||
sector = FLASH_Sector_2;
|
||||
} else if ((Address < ADDR_FLASH_SECTOR_4) && (Address >= ADDR_FLASH_SECTOR_3)) {
|
||||
sector = FLASH_Sector_3;
|
||||
} else if ((Address < ADDR_FLASH_SECTOR_5) && (Address >= ADDR_FLASH_SECTOR_4)) {
|
||||
sector = FLASH_Sector_4;
|
||||
} else if ((Address < ADDR_FLASH_SECTOR_6) && (Address >= ADDR_FLASH_SECTOR_5)) {
|
||||
sector = FLASH_Sector_5;
|
||||
} else if ((Address < ADDR_FLASH_SECTOR_7) && (Address >= ADDR_FLASH_SECTOR_6)) {
|
||||
sector = FLASH_Sector_6;
|
||||
} else if ((Address < ADDR_FLASH_SECTOR_8) && (Address >= ADDR_FLASH_SECTOR_7)) {
|
||||
sector = FLASH_Sector_7;
|
||||
} else if ((Address < ADDR_FLASH_SECTOR_9) && (Address >= ADDR_FLASH_SECTOR_8)) {
|
||||
sector = FLASH_Sector_8;
|
||||
} else if ((Address < ADDR_FLASH_SECTOR_10) && (Address >= ADDR_FLASH_SECTOR_9)) {
|
||||
sector = FLASH_Sector_9;
|
||||
} else if ((Address < ADDR_FLASH_SECTOR_11) && (Address >= ADDR_FLASH_SECTOR_10)) {
|
||||
sector = FLASH_Sector_10;
|
||||
} else /*(Address < FLASH_END_ADDR) && (Address >= ADDR_FLASH_SECTOR_11))*/
|
||||
{
|
||||
sector = FLASH_Sector_11;
|
||||
}
|
||||
|
||||
return sector;
|
||||
}
|
||||
int flash_write(addr_t st_addr, addr_t end_addr, umword_t *data)
|
||||
{
|
||||
uint32_t StartSector = 0, EndSector = 0, Address = 0, SectorCounter = 0;
|
||||
/* Unlock the Flash to enable the flash control register access *************/
|
||||
FLASH_Unlock();
|
||||
|
||||
/* Erase the user Flash area
|
||||
(area defined by FLASH_USER_START_ADDR and FLASH_USER_END_ADDR) ***********/
|
||||
|
||||
/* Clear pending flags (if any) */
|
||||
FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR |
|
||||
FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR);
|
||||
|
||||
/* Get the number of the start and end sectors */
|
||||
StartSector = GetSector(st_addr);
|
||||
EndSector = GetSector(end_addr);
|
||||
|
||||
for (SectorCounter = StartSector; SectorCounter < EndSector; SectorCounter += 8) {
|
||||
/* Device voltage range supposed to be [2.7V to 3.6V], the operation will
|
||||
be done by word */
|
||||
if (FLASH_EraseSector(SectorCounter, VoltageRange_3) != FLASH_COMPLETE) {
|
||||
/* Error occurred while sector erase.
|
||||
User can add here some code to deal with this error */
|
||||
FLASH_Lock();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
Address = st_addr;
|
||||
|
||||
while (Address < end_addr) {
|
||||
if (FLASH_ProgramWord(Address, *data++) == FLASH_COMPLETE) {
|
||||
Address = Address + 4;
|
||||
} else {
|
||||
/* Error occurred while writing data in Flash memory.
|
||||
User can add here some code to deal with this error */
|
||||
FLASH_Lock();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
FLASH_Lock();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <u_prot.h>
|
||||
#include <u_vmam.h>
|
||||
|
||||
int flash_init(void)
|
||||
{
|
||||
msg_tag_t tag;
|
||||
addr_t vaddr;
|
||||
|
||||
tag = u_vmam_alloc(VMA_PROT, vma_addr_create(VPAGE_PROT_RWX, 0, 0),
|
||||
0x400 /*TODO:*/, 0x40023C00, &vaddr);
|
||||
if (msg_tag_get_val(tag) < 0) {
|
||||
return msg_tag_get_val(tag);
|
||||
}
|
||||
|
||||
tag = u_vmam_alloc(VMA_PROT, vma_addr_create(VPAGE_PROT_RWX, 0, 0),
|
||||
32 * 1024 * 1024 /*TODO:*/, 0x8000000, &vaddr);
|
||||
if (msg_tag_get_val(tag) < 0) {
|
||||
return msg_tag_get_val(tag);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include "flash.h"
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include "u_sys.h"
|
||||
#include "u_prot.h"
|
||||
#include <u_vmam.h>
|
||||
|
||||
#define SECTOR_SIZE 4096
|
||||
static sys_info_t sys_info;
|
||||
|
||||
int flash_get_sector_size(umword_t *mem_addr, int *blk_size, int *blk_nr)
|
||||
{
|
||||
assert(blk_size);
|
||||
assert(mem_addr);
|
||||
assert(blk_nr);
|
||||
msg_tag_t tag;
|
||||
|
||||
tag = sys_read_info(SYS_PROT, &sys_info, 0);
|
||||
if (msg_tag_get_val(tag) < 0)
|
||||
{
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
*mem_addr = sys_info.bootfs_start_addr;
|
||||
*blk_size = SECTOR_SIZE;
|
||||
*blk_nr = (CONFIG_SYS_TEXT_SIZE - CONFIG_BOOTSTRAP_TEXT_SIZE - CONFIG_KNL_TEXT_SIZE - CONFIG_DTBO_TEXT_SIZE) / SECTOR_SIZE;
|
||||
|
||||
printf("flash mem_addr:0x%x blk_size:0x%x blk_nr:0x%x\n", *mem_addr, *blk_size, *blk_nr);
|
||||
return 0;
|
||||
}
|
||||
int flash_read_sector(uint32_t sector_inx, uint32_t *p_buffer, uint16_t num_read)
|
||||
{
|
||||
uint16_t i;
|
||||
uint32_t read_addr;
|
||||
|
||||
if (num_read < SECTOR_SIZE / 4)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
read_addr = sector_inx * SECTOR_SIZE + sys_info.bootfs_start_addr;
|
||||
|
||||
for (i = 0; i < num_read; i++)
|
||||
{
|
||||
p_buffer[i] = *(uint32_t *)(read_addr);
|
||||
read_addr += 4;
|
||||
}
|
||||
return num_read;
|
||||
}
|
||||
int flash_erase_sector(uint32_t sector_inx)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
int flash_write_sector(uint32_t sector_inx, uint32_t *p_buffer, uint16_t num_write)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
int flash_init(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <u_types.h>
|
||||
|
||||
int flash_read_sector(uint32_t sector_inx, uint32_t *p_buffer, uint16_t num_read);
|
||||
int flash_write_sector(uint32_t sector_inx, uint32_t *p_buffer, uint16_t num_write);
|
||||
int flash_get_sector_size(umword_t *mem_addr, int *blk_size, int *blk_nr);
|
||||
int flash_erase_sector(uint32_t sector_inx);
|
||||
int flash_init(void);
|
||||
int flash_write(addr_t st_addr, addr_t end_addr, umword_t *data);
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
|
||||
#include <stdio.h>
|
||||
// #include <at32f435_437_conf.h>
|
||||
#include "flash.h"
|
||||
#include "u_share_mem.h"
|
||||
#include <assert.h>
|
||||
#include <blk_drv_cli.h>
|
||||
#include <blk_drv_svr.h>
|
||||
#include <errno.h>
|
||||
#include <mk_dtb_parse.h>
|
||||
#include <ns_cli.h>
|
||||
#include <rpc_prot.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
#include <u_fast_ipc.h>
|
||||
#include <u_hd_man.h>
|
||||
#include <u_sleep.h>
|
||||
#include <u_sys.h>
|
||||
#include <u_task.h>
|
||||
@@ -19,50 +24,104 @@ void fast_ipc_init(void)
|
||||
{
|
||||
u_fast_ipc_init(stack_coms, msg_buf_coms, 1, STACK_COM_ITME_SIZE);
|
||||
}
|
||||
void assert_param(int val)
|
||||
static blk_drv_t blk_drv;
|
||||
int blk_drv_write(obj_handler_t obj, int len, int inx)
|
||||
{
|
||||
if (!val) {
|
||||
while (1)
|
||||
;
|
||||
int ret = -1;
|
||||
addr_t addr = 0;
|
||||
umword_t size = 0;
|
||||
msg_tag_t tag;
|
||||
|
||||
if (len == 0)
|
||||
{
|
||||
ret = flash_erase_sector(inx);
|
||||
}
|
||||
else
|
||||
{
|
||||
tag = share_mem_map(obj, vma_addr_create(VPAGE_PROT_RWX, 0, 0), &addr, &size);
|
||||
if (msg_tag_get_val(tag) < 0)
|
||||
{
|
||||
handler_free_umap(obj);
|
||||
printf("net write error.\n");
|
||||
return msg_tag_get_val(tag);
|
||||
}
|
||||
ret = flash_write_sector(inx, (void *)addr, len / 4);
|
||||
handler_free_umap(obj);
|
||||
}
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
return ret * 4;
|
||||
}
|
||||
int blk_drv_read(obj_handler_t obj, int len, int inx)
|
||||
{
|
||||
int ret = -1;
|
||||
addr_t addr = 0;
|
||||
umword_t size = 0;
|
||||
uint32_t _err;
|
||||
msg_tag_t tag = share_mem_map(obj, vma_addr_create(VPAGE_PROT_RWX, 0, 0), &addr, &size);
|
||||
|
||||
if (msg_tag_get_val(tag) < 0)
|
||||
{
|
||||
handler_free_umap(obj);
|
||||
printf("net write error.\n");
|
||||
return msg_tag_get_val(tag);
|
||||
}
|
||||
ret = flash_read_sector(inx, (void *)addr, len / 4);
|
||||
handler_free_umap(obj);
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
return ret * 4;
|
||||
}
|
||||
int blk_drv_map(obj_handler_t *hd)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
int blk_drv_info(blk_drv_info_t *info)
|
||||
{
|
||||
umword_t mem_addr;
|
||||
int blk_size;
|
||||
int blk_nr;
|
||||
int ret;
|
||||
|
||||
ret = flash_get_sector_size(&mem_addr, &blk_size, &blk_nr);
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
info->blk_nr = blk_nr;
|
||||
info->blk_size = blk_size;
|
||||
info->blk_start_addr = mem_addr;
|
||||
return 0;
|
||||
}
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
obj_handler_t hd;
|
||||
int ret;
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
printf("please set dev path.\n");
|
||||
printf("example:block /block");
|
||||
return -1;
|
||||
}
|
||||
task_set_obj_name(TASK_THIS, TASK_THIS, "tk_blk");
|
||||
task_set_obj_name(TASK_THIS, THREAD_MAIN, "th_blk");
|
||||
printf("%s init..\n", argv[0]);
|
||||
fast_ipc_init();
|
||||
printf("%s:%d\n", __func__, __LINE__);
|
||||
ret = flash_init();
|
||||
if (ret < 0) {
|
||||
printf("flash init error.\n");
|
||||
return -1;
|
||||
}
|
||||
printf("%s:%d\n", __func__, __LINE__);
|
||||
ret = flash_write(0x8000000 + 512 * 1024, 0x8000000 + 512 * 1024 + 4, "123");
|
||||
if (ret < 0) {
|
||||
printf("flash init error.\n");
|
||||
return -1;
|
||||
}
|
||||
printf("%s:%d\n", __func__, __LINE__);
|
||||
char *read_str = (char *)(0x8000000 + 512 * 1024);
|
||||
printf("read str is %s\n", read_str);
|
||||
while (1) {
|
||||
u_sleep_ms(1000);
|
||||
}
|
||||
// mk_drv_init();
|
||||
// mk_dev_init();
|
||||
// // drv_i2c_init();
|
||||
// dtb_parse_init();
|
||||
|
||||
// ret = rpc_meta_init(THREAD_MAIN, &hd);
|
||||
// assert(ret >= 0);
|
||||
// fs_svr_init();
|
||||
// ns_register("/block", hd, FILE_NODE);
|
||||
// while (1)
|
||||
// {
|
||||
// fs_svr_loop();
|
||||
// }
|
||||
flash_init();
|
||||
blk_drv_init(&blk_drv);
|
||||
ret = rpc_meta_init(THREAD_MAIN, &hd);
|
||||
assert(ret >= 0);
|
||||
ns_register(argv[1], hd, FILE_NODE);
|
||||
meta_reg_svr_obj(&blk_drv.svr, BLK_DRV_PROT);
|
||||
|
||||
while (1)
|
||||
{
|
||||
rpc_loop();
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,94 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file FLASH/Program/stm32f2xx_conf.h
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 13-April-2012
|
||||
* @brief Library configuration file.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM32F2xx_CONF_H
|
||||
#define __STM32F2xx_CONF_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/* Uncomment the line below to enable peripheral header file inclusion */
|
||||
#include "stm32f2xx_adc.h"
|
||||
#include "stm32f2xx_can.h"
|
||||
#include "stm32f2xx_crc.h"
|
||||
#include "stm32f2xx_cryp.h"
|
||||
#include "stm32f2xx_dac.h"
|
||||
#include "stm32f2xx_dbgmcu.h"
|
||||
#include "stm32f2xx_dcmi.h"
|
||||
#include "stm32f2xx_dma.h"
|
||||
#include "stm32f2xx_exti.h"
|
||||
#include "stm32f2xx_flash.h"
|
||||
#include "stm32f2xx_fsmc.h"
|
||||
#include "stm32f2xx_hash.h"
|
||||
#include "stm32f2xx_gpio.h"
|
||||
#include "stm32f2xx_i2c.h"
|
||||
#include "stm32f2xx_iwdg.h"
|
||||
#include "stm32f2xx_pwr.h"
|
||||
#include "stm32f2xx_rcc.h"
|
||||
#include "stm32f2xx_rng.h"
|
||||
#include "stm32f2xx_rtc.h"
|
||||
#include "stm32f2xx_sdio.h"
|
||||
#include "stm32f2xx_spi.h"
|
||||
#include "stm32f2xx_syscfg.h"
|
||||
#include "stm32f2xx_tim.h"
|
||||
#include "stm32f2xx_usart.h"
|
||||
#include "stm32f2xx_wwdg.h"
|
||||
#include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
/* If an external clock source is used, then the value of the following define
|
||||
should be set to the value of the external clock source, else, if no external
|
||||
clock is used, keep this define commented */
|
||||
/*#define I2S_EXTERNAL_CLOCK_VAL 12288000 */ /* Value of the external clock in Hz */
|
||||
|
||||
|
||||
/* Uncomment the line below to expanse the "assert_param" macro in the
|
||||
Standard Peripheral Library drivers code */
|
||||
#define USE_FULL_ASSERT 1
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
#ifdef USE_FULL_ASSERT
|
||||
|
||||
/**
|
||||
* @brief The assert_param macro is used for function's parameters check.
|
||||
* @param expr: If expr is false, it calls assert_failed function
|
||||
* which reports the name of the source file and the source
|
||||
* line number of the call that failed.
|
||||
* If expr is true, it returns no value.
|
||||
* @retval None
|
||||
*/
|
||||
#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void assert_failed(uint8_t* file, uint32_t line);
|
||||
#else
|
||||
#define assert_param(expr) ((void)0)
|
||||
#endif /* USE_FULL_ASSERT */
|
||||
|
||||
#endif /* __STM32F2xx_CONF_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
@@ -1,105 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file system_stm32f2xx.h
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.3
|
||||
* @date 05-March-2012
|
||||
* @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Header File.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/** @addtogroup CMSIS
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup stm32f2xx_system
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Define to prevent recursive inclusion
|
||||
*/
|
||||
#ifndef __SYSTEM_STM32F2XX_H
|
||||
#define __SYSTEM_STM32F2XX_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @addtogroup STM32F2xx_System_Includes
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @addtogroup STM32F2xx_System_Exported_types
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32F2xx_System_Exported_Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32F2xx_System_Exported_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32F2xx_System_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern void SystemInit(void);
|
||||
extern void SystemCoreClockUpdate(void);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__SYSTEM_STM32F2XX_H */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
Reference in New Issue
Block a user