示例#1
0
static void
process_boot_cmd()
{
  boot_cmd_t boot_cmd;
  sxfs_read(SP_BOOT_PARAMS, 0, (uint8_t*)&boot_cmd, sizeof(boot_cmd));

  switch (boot_cmd) {
    case BOOT_LOAD_RECOVERY_IMG:
      write_app_img(SP_RECOVERY_IMG);
      break;

    case BOOT_LOAD_UPDATE_IMG:
      write_app_img(SP_UPDATE_IMG);
      break;

    case BOOT_DEFAULT:
    default:
      break;
  }

  if (boot_cmd != BOOT_DEFAULT) {
    boot_cmd = BOOT_DEFAULT;
    sxfs_erase_all(SP_BOOT_PARAMS);
    sxfs_write(SP_BOOT_PARAMS, 0, (uint8_t*)&boot_cmd, sizeof(boot_cmd));
  }
}
示例#2
0
文件: app_cfg.c 项目: jaumann/model-t
static app_cfg_rec_t*
app_cfg_load_from(sxfs_part_id_t part)
{
  bool ret;
  app_cfg_rec_t* app_cfg = malloc(sizeof(app_cfg_rec_t));

  ret = sxfs_read(part, 0, app_cfg, sizeof(app_cfg_rec_t));
  if (!ret) {
    free(app_cfg);
    return NULL;
  }

  uint32_t calc_crc = crc32_block(0, &app_cfg->data, sizeof(app_cfg_data_t));
  if (calc_crc != app_cfg->crc) {
    free(app_cfg);
    return NULL;
  }

  return app_cfg;
}