/**************************************************************************** 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_lock.h" #include "os_mem.h" #include "os_utils.h" /* common includes */ #include "iot_io.h" #include "iot_clock.h" #include "dbg_io.h" #include "strformat.h" #include "ahb.h" #include "uart.h" #include "iot_uart.h" #include "mtd.h" #include "iot_mtd.h" #include "iot_led.h" extern int platform_init(); void iot_task_1(void *arg) { iot_printf("task 1 entry....\r\n"); int ret = -1; uint32_t pos = 0; uint32_t rbuf[0x100] = {0}; int wsize = 0x0400; int rsize = 0x100; int unit = 0x100; uint32_t *wbuf = os_mem_malloc(IOT_DRIVER_MID, wsize); int i = 0, j=0; int fd = dev_open(PART_NUM_FW1, 0); if (fd<0) { iot_printf("open file failed.\n"); return ; } /* test get info */ mtd_device_get_info(rbuf, DEV_TYPE_FLASH); iot_printf("\r\n ID : %02x\r\n", (uint32_t )rbuf[0]); /* test erase */ uint32_t mode = 0x00U; mode = DEV_ERASE_TYPE_FULL_PART; ret = dev_erase(fd, 0x0, mode); if (ret < 0) { iot_printf("\r\nerase failed.\r\n"); return ; } /* test write: size 0x50000 */ uint32_t tmp = 0; for (i=0;i<0x010;i++) { for (j=0;j= 0x010000 ) { iot_printf("read at the end, back to head.\r\n"); pos = dev_seek(fd, 0, DEV_SEEK_SET); //break; } else { pos = dev_seek(fd, 0, DEV_SEEK_CUR); } iot_printf("\r\nread data ++ start pos is %02x\r\n", pos); ret = dev_read(fd, rbuf, rsize); if (ret<0) { iot_printf("read error\r\n"); dev_close(fd); return ; /* move to DEV_SEEK_SET */ dev_seek(fd, 0, DEV_SEEK_SET); continue; } for(i=0;i