static int set_bootloader_message_block_rk29(const struct bootloader_message *in, const Volume* v) { FILE* f = fopen(v->blk_device, "wb+"); if (f == NULL) { LOGE("Can't open %s\n(%s)\n", v->blk_device, strerror(errno)); return -1; } const ssize_t size =WRITE_SIZE * MISC_PAGES; char data[size]; memset(data,0,size); memcpy(&data[WRITE_SIZE * MISC_COMMAND_PAGE], in, sizeof(*in)); int count = rk29_fwrite(data, size, 1, f); if (count != 1) { LOGE("Failed writing %s\n(%s)\n", v->blk_device, strerror(errno)); fclose(f); return -1; } if (fclose(f) != 0) { LOGE("Failed closing %s\n(%s)\n", v->blk_device, strerror(errno)); return -1; } return 0; }
static int set_bootloader_message_block(const struct bootloader_message *in, const Volume* v) { wait_for_device(v->blk_device); #if TARGET_BOARD_PLATFORM == rockchip FILE* f = fopen(v->blk_device, "wb+"); #else FILE* f = fopen(v->blk_device, "wb"); #endif if (f == NULL) { LOGE("Can't open %s\n(%s)\n", v->blk_device, strerror(errno)); return -1; } #if TARGET_BOARD_PLATFORM == rockchip int count = rk29_fwrite(in, sizeof(*in), 1, f); #else int count = fwrite(in, sizeof(*in), 1, f); #endif if (count != 1) { LOGE("Failed writing %s\n(%s)\n", v->blk_device, strerror(errno)); return -1; } if (fclose(f) != 0) { LOGE("Failed closing %s\n(%s)\n", v->blk_device, strerror(errno)); return -1; } return 0; }
static int set_bootloader_message_block_rk29(const struct bootloader_message *in, const Volume* v) { FILE* f = NULL; #ifdef TARGET_RK3188 if (strcmp(v->fs_type, "emmc") == 0){ f = fopen(v->blk_device, "wb+"); }else{ f = fopen("/dev/block/rknand_misc", "wb+"); } #else f = fopen(v->blk_device, "wb+"); #endif if (f == NULL) { LOGE("Can't open %s\n(%s)\n", v->blk_device, strerror(errno)); return -1; } const ssize_t size =WRITE_SIZE * MISC_PAGES; char data[size]; memset(data,0,size); memcpy(&data[WRITE_SIZE * MISC_COMMAND_PAGE], in, sizeof(*in)); int count = rk29_fwrite(data, size, 1, f); if (count != 1) { LOGE("Failed writing %s\n(%s)\n", v->blk_device, strerror(errno)); fclose(f); return -1; } fflush(f); if (fclose(f) != 0) { LOGE("Failed closing %s\n(%s)\n", v->blk_device, strerror(errno)); return -1; } return 0; }