summaryrefslogtreecommitdiff
path: root/recipes-bsp/u-boot/u-boot-2016.09.01/printeepromcrc.patch
blob: 19fca0262f495913c10bd5d84c9ef44f2c53859f (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
diff -raNu old/common/env_nand.c new/common/env_nand.c
--- old/common/env_nand.c	2017-05-11 16:27:26.160067136 -0500
+++ new/common/env_nand.c	2017-05-11 16:44:12.134434145 -0500
@@ -68,15 +68,22 @@
 #if defined(ENV_IS_EMBEDDED) || defined(CONFIG_NAND_ENV_DST)
 	int crc1_ok = 0, crc2_ok = 0;
 	env_t *tmp_env1;
+	uint32_t calc_crc;
 
 #ifdef CONFIG_ENV_OFFSET_REDUND
 	env_t *tmp_env2;
 
 	tmp_env2 = (env_t *)((ulong)env_ptr + CONFIG_ENV_SIZE);
-	crc2_ok = crc32(0, tmp_env2->data, ENV_SIZE) == tmp_env2->crc;
+	calc_crc = crc32(0, tmp_env2->data, ENV_SIZE);
+	crc2_ok = (calc_crc == tmp_env2->crc);
+	printf("env_relocate_spec: crc2_ok=%d saved crc=0x%x calculated crc=0x%x flags=%d\n",
+		crc2_ok,tmp_env2->crc,calc_crc,tmp_env2->flags);
 #endif
 	tmp_env1 = env_ptr;
-	crc1_ok = crc32(0, tmp_env1->data, ENV_SIZE) == tmp_env1->crc;
+	calc_crc = crc32(0, tmp_env1->data, ENV_SIZE);
+	crc1_ok = (calc_crc == tmp_env1->crc);
+	printf("env_relocate_spec: crc1_ok=%d saved crc=0x%x calculated crc=0x%x flags=%d\n",
+		crc1_ok,tmp_env1->crc,calc_crc,tmp_env1->flags);
 
 	if (!crc1_ok && !crc2_ok) {
 		gd->env_addr	= 0;
@@ -317,6 +324,7 @@
 	int read1_fail = 0, read2_fail = 0;
 	int crc1_ok = 0, crc2_ok = 0;
 	env_t *ep, *tmp_env1, *tmp_env2;
+	uint32_t calc_crc;
 
 	tmp_env1 = (env_t *)malloc(CONFIG_ENV_SIZE);
 	tmp_env2 = (env_t *)malloc(CONFIG_ENV_SIZE);
@@ -334,11 +342,16 @@
 	else if (read1_fail || read2_fail)
 		puts("*** Warning - some problems detected "
 		     "reading environment; recovered successfully\n");
-
+    calc_crc = crc32(0, tmp_env1->data, ENV_SIZE);
 	crc1_ok = !read1_fail &&
-		(crc32(0, tmp_env1->data, ENV_SIZE) == tmp_env1->crc);
+		(calc_crc == tmp_env1->crc);
+	printf("env_relocate_spec: crc1_ok=%d saved crc=0x%x calculated crc=0x%x flags=%d\n",
+		crc1_ok,tmp_env1->crc,calc_crc,tmp_env1->flags);
+    calc_crc = crc32(0, tmp_env2->data, ENV_SIZE);
 	crc2_ok = !read2_fail &&
-		(crc32(0, tmp_env2->data, ENV_SIZE) == tmp_env2->crc);
+		(calc_crc == tmp_env2->crc);
+	printf("env_relocate_spec: crc2_ok=%d saved crc=0x%x calculated crc=0x%x flags=%d\n",
+		crc2_ok,tmp_env2->crc,calc_crc,tmp_env2->flags);
 
 	if (!crc1_ok && !crc2_ok) {
 		set_default_env("!bad CRC");