/* * * Copyright(c) 2014-2016 Allwinnertech Co., Ltd. * http://www.allwinnertech.com * * Author: sunny * Author: superm * Author: Matteo * * Allwinner sunxi soc chip version and chip id manager. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. */ #include #include #include #include #include "common.h" #include "efuse_ioctl.h" void help(void) { printf("-ew : write key to efuse\n"); printf("-er : read key from efuse\n"); printf("-h : help\n"); } void sunxi_dump(char *buf, int count) { int i, j; for (j = 0; j < count; j += 16) { for (i = 0; i < 16; i++) { printf("%02x ", buf[j + i] & 0xff); if (j + i >= count) { break; } } printf("\n"); } printf("\n"); } int main(int argc, char **argv) { char buf[256]; int ret; if (argc < 2) { goto error; } if (!strncmp(argv[1], "-er", 3)) { if (argv[4]) { if (sunxi_efuse_read(argv[2], simple_strtoul(argv[3], NULL, 16), simple_strtoul(argv[4], NULL, 16), buf) < 0) { printf("read efuse data fail\n"); goto error; } printf("api buf:\n"); for (ret = 0; ret < simple_strtoul(argv[4], NULL, 16); ret++) printf("%x ", buf[ret]); printf("\n"); } } else if (!strncmp(argv[1], "-ew", 3)) { if (argv[4]) { if (sunxi_efuse_write(argv[2], simple_strtoul(argv[3], NULL, 16), argv[4]) < 0) { printf("write efuse data fail\n"); goto error; } } } else if (!strncmp(argv[1], "-h", 2)) { help(); } return 0; error: printf("-----------------------\n"); printf("---- Test fail ------\n"); printf("---- Test fail ------\n"); printf("---- Test fail ------\n"); printf("-----------------------\n"); return -1; }