Mike Frysinger | 48d3159 | 2013-05-02 15:44:42 -0400 | [diff] [blame] | 1 | #include <fcntl.h> |
| 2 | #include <stdio.h> |
| 3 | #include <string.h> |
| 4 | #include <termios.h> |
| 5 | #include <unistd.h> |
| 6 | #include <sys/ioctl.h> |
| 7 | #include <mtd/mtd-user.h> |
| 8 | |
| 9 | int main() { |
| 10 | int fd = open("/dev/null", 0); |
| 11 | struct mtd_info_user minfo; |
| 12 | struct erase_info_user einfo; |
| 13 | struct erase_info_user64 einfo64; |
| 14 | struct mtd_oob_buf mbuf; |
| 15 | struct mtd_oob_buf64 mbuf64; |
| 16 | struct region_info_user rinfo; |
| 17 | /* struct otp_info oinfo; */ |
| 18 | struct mtd_ecc_stats estat; |
| 19 | struct mtd_write_req mreq; |
| 20 | struct nand_oobinfo ninfo; |
| 21 | struct nand_ecclayout_user nlay; |
| 22 | off_t f = 333; |
| 23 | |
| 24 | memset(&einfo, 0, sizeof(einfo)); |
| 25 | memset(&einfo64, 0xff, sizeof(einfo64)); |
| 26 | |
| 27 | ioctl(fd, MEMGETINFO, &minfo); |
| 28 | |
| 29 | ioctl(fd, MEMERASE, &einfo); |
| 30 | ioctl(fd, MEMERASE64, &einfo64); |
| 31 | |
| 32 | ioctl(fd, MEMGETBADBLOCK, &f); |
| 33 | int i = 0; |
| 34 | ioctl(fd, OTPSELECT, &i); |
| 35 | ioctl(fd, MEMSETBADBLOCK, &f); |
| 36 | |
| 37 | ioctl(fd, MEMREADOOB, &mbuf); |
| 38 | ioctl(fd, MEMREADOOB64, &mbuf64); |
| 39 | |
| 40 | ioctl(fd, MEMGETREGIONINFO, &rinfo); |
| 41 | |
| 42 | ioctl(fd, ECCGETSTATS, &estat); |
| 43 | ioctl(fd, MEMWRITE, &mreq); |
| 44 | |
| 45 | ioctl(fd, MEMGETOOBSEL, &ninfo); |
| 46 | ioctl(fd, ECCGETLAYOUT, &nlay); |
| 47 | |
| 48 | return 0; |
| 49 | } |