FR8000操作flash
-
FR800X系列的型号不一样,flash的大小也不一样;
如果使用的是FR8008GP,8M的flash需要app_config.h里面更新这段代码// <h> FLASH Configuration
// <o> FLASH_CAPACITY
// <i> Internal Flash capacity selection, Default: 4Mb
// <0x01000000=> 8Mb
// <0x00080000=> 4Mb
// <0x00040000=> 2Mb#define FLASH_CAPACITY 0x01000000
#if FLASH_CAPACITY == 0x00080000
#define BLE_STACK_KEY_STORAGE_OFFSET 0x7F000
#define BLE_BONDING_INFO_SAVE_ADDR 0x7D000
#define BLE_REMOTE_SERVICE_SAVE_ADDR 0x7E000
#elif FLASH_CAPACITY == 0x00040000
#define BLE_STACK_KEY_STORAGE_OFFSET 0x3F000
#define BLE_BONDING_INFO_SAVE_ADDR 0x3D000
#define BLE_REMOTE_SERVICE_SAVE_ADDR 0x3E000
#elif FLASH_CAPACITY == 0x01000000
#define BLE_STACK_KEY_STORAGE_OFFSET 0xFFF000
#define BLE_BONDING_INFO_SAVE_ADDR 0xFFD000
#define BLE_REMOTE_SERVICE_SAVE_ADDR 0xFFE000
#else
#error "flash capacity configuration error!"
#endif //FOR_2M_FLASH下面是操作Flash的操作
/************************ Flash -W -R *************************/
#define FLASH_ADDR0_0X101000 (0X40000)
#define FLASH_ADDR0_0X100000 (0X100000)
#define FLASH_SECTOR_SIZE (0x1000)
#define FLASH_WRITE_LEN_128 (0x100)#define FLASH_WRITE_LEN (0xA)
uint8_t read_retu_num=0xf,erase_retu_num=0xf,write_retu_num=0xf;
void flash_task(void)
{
co_printf("%s\r\n",func);
uint8_t w_buf[FLASH_WRITE_LEN_128] = {0};
uint8_t r_buf[FLASH_WRITE_LEN_128] = {0};
read_retu_num=flash_read(FLASH_ADDR0_0X101000, FLASH_WRITE_LEN, r_buf);
co_printf("read retu_num %d\r\n",read_retu_num);if(r_buf[0]==1&&r_buf[1]==2) { co_printf("**********************Start_Read**********************\r\n"); show_reg(r_buf, FLASH_WRITE_LEN, 1); co_printf("Read->Erase\r\n"); erase_retu_num=flash_erase(FLASH_ADDR0_0X101000, FLASH_SECTOR_SIZE); co_printf("erase_retu_num %d\r\n",erase_retu_num); co_delay_100us(10*2000); read_retu_num = flash_read(FLASH_ADDR0_0X101000, FLASH_WRITE_LEN, r_buf); co_printf("read retu_num %d\r\n",read_retu_num); co_printf("Erase->Read\r\n"); show_reg(r_buf, FLASH_WRITE_LEN, 1); } else { for(uint32_t i = 1;i<FLASH_WRITE_LEN+1;i++) { w_buf[i-1] = i; } co_printf("**********************Start->Erase**********************\r\n"); erase_retu_num=flash_erase(FLASH_ADDR0_0X101000, FLASH_SECTOR_SIZE); co_printf("erase_retu_num %d\r\n",erase_retu_num); co_printf("Erase->Write\r\n"); write_retu_num=flash_write(FLASH_ADDR0_0X101000, FLASH_WRITE_LEN, w_buf); co_printf("write_retu_num %d\r\n",write_retu_num); co_delay_100us(10*2000); erase_retu_num=flash_read(FLASH_ADDR0_0X101000, FLASH_WRITE_LEN, r_buf); co_printf("read retu_num %d\r\n",read_retu_num); co_printf("Write->Read\r\n"); show_reg(r_buf, FLASH_WRITE_LEN, 1); }
}
-
关于FR8008GP的flash分配,看了“FR8008XP Datasheet”、“FR8000 Specification”和“FR8000 SDK用户手册”这几个文件,发现表述的flash不太一样。
这里说挂载的flash是64M的。
但这里说最大支持的是16M
也和存储程序的flash不同
我想问一下,这几个flash之间的关系是什么,指向的物理地址是相同的吗,文中的 “FR8008GP为8M的flash”又是属于什么部分的。
-
@emrof 如果你的芯片flash是8M的指向的起始地址也是0x1000 0000
-
@mars FR8008GP 的flash能读 但是擦除和写不行