/* The minimum size of flash erasure. May be a flash sector size. */ #define EF_ERASE_MIN_SIZE 2048 /* 擦除粒度@note you must define it for a value */
/* the flash write granularity, unit: bit * only support 1(nor flash)/ 8(stm32f4)/ 32(stm32f1) */ #define EF_WRITE_GRAN 32 /* 写入粒度@note you must define it for a value */
/* backup area start address */ #define EF_START_ADDR (FLASH_BASE + 100 * 1024) /* @note you must define it for a value */
/* ENV area size. It's at least one empty sector for GC. So it's definition must more then or equal 2 flash sector size. */ #define ENV_AREA_SIZE (2 * EF_ERASE_MIN_SIZE)/* @note you must define it for a value if you used ENV */
/* get the boot count number from Env */ c_old_boot_times = ef_get_env("boot_times"); assert_param(c_old_boot_times); i_boot_times = atol(c_old_boot_times); /* boot count +1 */ i_boot_times ++; printf("The system now boot %d times\n\r", i_boot_times); /* interger to string */ sprintf(c_new_boot_times,"%ld", i_boot_times); /* set and store the boot count number to Env */ ef_set_env("boot_times", c_new_boot_times); ef_save_env(); }