summaryrefslogtreecommitdiff
path: root/common/cmd_wipeisb.c
blob: b23b4cef232cc313c2e55f76396b537627f287b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <common.h>
#include <amlogic/storage_if.h>

#ifndef PAGE_SIZE
#define PAGE_SIZE 4096
#endif

unsigned char w_buf[PAGE_SIZE];
extern int has_instaboot_part(void);
static int do_wipeisb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
	int rc = 0;
	u64 partSz = 0;

	if (!has_instaboot_part())
		return 0;
	rc = store_get_partititon_size((unsigned char*)"instaboot", &partSz);
	if (rc || !partSz) {
	    printf("can not get instaboot part size\n");
	    return -1;
	}

	memset(w_buf, 0, PAGE_SIZE);
	rc = store_write_ops((unsigned char*)"instaboot",
		w_buf, 0, PAGE_SIZE);
	if (rc) {
	    printf("wipe instaboot header error\n");
	    return -1;
	}
	return 0;
}

U_BOOT_CMD(
   wipeisb,         //command name
   1,               //maxargs
   0,               //repeatable
   do_wipeisb,   //command function
   "wipeisb",
   "wipe the insaboot image header"
);