Skip to contentSkip to conversation

env_nand.c: fail gracefully if no nand is present

RFC PATCH New Steve Sakoman 2 participants 3 messages Aug 16, 2010

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 env_nand.c: fail gracefully if no nand is present

Rationale:

The upcoming Beagle xM, unlike previous Beagles, has no on-board NAND.

I'd like to continue to have a single version of u-boot that works for all version of Beagles. Therefore I need to have env_nand fail gracefully when it runs on the xM.

The patch below does the job, but I am not sure that my method of checking for the existence of nand (nand_info[0].type = 0 when no nand detected) is "correct"? Any opinions or advice?

Steve

---

common/env_nand.c +4 -0
index a15a950..325f112 100644
@@ -268,6 +268,10 @@ int readenv (size_t offset, u_char * buf)
 
 	u_char *char_ptr;
 
+	/* fail if no nand detected */
+	if (nand_info[0].type == 0)
+		return 1;
+
 	blocksize = nand_info[0].erasesize;
 	len = min(blocksize, CONFIG_ENV_SIZE);
 
#1 lore raw

RFC PATCH 1/1 env_nand.c: fail gracefully if no nand is present

Quoted 11 lines · Steve Sakoman

Rationale:

The upcoming Beagle xM, unlike previous Beagles, has no on-board NAND.

I'd like to continue to have a single version of u-boot that works for all version of Beagles. Therefore I need to have env_nand fail gracefully when it runs on the xM.

The patch below does the job, but I am not sure that my method of checking for the existence of nand (nand_info[0].type = 0 when no nand detected) is "correct"? Any opinions or advice?

I just applied Mike's patch for this a few days ago:
http://git.denx.de/?p=u-boot/u-boot-nand-flash.git;a=commitdiff;h=962ad59e25640e586e2bceabf67a628a27f8f508

-Scott

Quoted 26 lines

Steve

---

common/env_nand.c +4 -0
index a15a950..325f112 100644
@@ -268,6 +268,10 @@ int readenv (size_t offset, u_char * buf)
 
  	u_char *char_ptr;
 
+	/* fail if no nand detected */
+	if (nand_info[0].type == 0)
+		return 1;
+
  	blocksize = nand_info[0].erasesize;
  	len = min(blocksize, CONFIG_ENV_SIZE);
 

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#2 lore raw

RFC PATCH 1/1 env_nand.c: fail gracefully if no nand is present

Quoted 9 lines · Scott Wood
Quoted 8 lines · Steve Sakoman

Rationale:

The upcoming Beagle xM, unlike previous Beagles, has no on-board NAND.

I'd like to continue to have a single version of u-boot that works for all version of Beagles. Therefore I need to have env_nand fail gracefully when it runs on the xM.

Quoted 6 lines
Quoted 3 lines

The patch below does the job, but I am not sure that my method of checking for the existence of nand (nand_info[0].type = 0 when no nand detected) is "correct"? Any opinions or advice?

I just applied Mike's patch for this a few days ago:
http://git.denx.de/?p=u-boot/u-boot-nand-flash.git;a=commitdiff;h=962ad59e25640e586e2bceabf67a628a27f8f508

Thanks Scott! I'll add that patch to my working branch under the assumption that it will eventually make its way to mainline.

Steve

Quoted 30 lines

-Scott

Quoted 26 lines

Steve

---

common/env_nand.c +4 -0
index a15a950..325f112 100644
@@ -268,6 +268,10 @@ int readenv (size_t offset, u_char * buf)
 
  	u_char *char_ptr;
 
+	/* fail if no nand detected */
+	if (nand_info[0].type == 0)
+		return 1;
+
  	blocksize = nand_info[0].erasesize;
  	len = min(blocksize, CONFIG_ENV_SIZE);
 

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot