Skip to contentSkip to conversation

ARM: at91: at91sam9x5: mmc: save environment as a FAT file (uboot.env)

PATCH New Josh Wu 2 participants 4 messages Nov 22, 2013 – Nov 27, 2013 Arm/Microchip (AT91) SoC support

lore
Share & tools
lore

Josh Wu

author
#0 lore raw

PATCH 1/2 ARM: at91: at91sam9x5: mmc: save environment as a FAT file (uboot.env)

This patch will save U-Boot environment as a file: uboot.env, in FAT partition instead of saving it in raw sector of SD card.

Since saving environment in raw sector has risk of corrupting the SD card and only can use very small size. Save as a FAT file has no above limitation.

---
 include/configs/at91sam9x5ek.h |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
include/configs/at91sam9x5ek.h +7 -5
index ea9a50e..2cd4fae 100644
@@ -205,11 +205,13 @@
 				"bootm 0x22000000"
 #else /* CONFIG_SYS_USE_MMC */
 /* bootstrap + u-boot + env + linux in mmc */
-#define CONFIG_ENV_IS_IN_MMC
-/* For FAT system, most cases it should be in the reserved sector */
-#define CONFIG_ENV_OFFSET	0x2000
-#define CONFIG_ENV_SIZE		0x1000
-#define CONFIG_SYS_MMC_ENV_DEV	0
+#define CONFIG_ENV_IS_IN_FAT
+#define CONFIG_FAT_WRITE
+#define FAT_ENV_INTERFACE	"mmc"
+#define FAT_ENV_FILE		"uboot.env"
+#define FAT_ENV_DEVICE		0
+#define FAT_ENV_PART		1
+#define CONFIG_ENV_SIZE		0x4000
 #endif
 
 #ifdef CONFIG_SYS_USE_MMC
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH 2/2 ARM: at91: sama5d3: mmc: save enviroment as a fat file (uboot.env)

This patch will save U-Boot environment as a file: uboot.env, in FAT partition instead of saving it in raw sector of SD card.

Since saving environment in raw sector has risk of corrupting the SD card and only can use very small size. Save as a FAT file has no above limitation.

---
 include/configs/sama5d3xek.h |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
include/configs/sama5d3xek.h +7 -3
index 5a6f0fc..a77ab5f 100644
@@ -196,9 +196,13 @@
 				"bootm 0x22000000 - 0x21000000"
 #elif CONFIG_SYS_USE_MMC
 /* bootstrap + u-boot + env in sd card */
-#define CONFIG_ENV_IS_IN_MMC
-#define CONFIG_ENV_OFFSET	0x2000
-#define CONFIG_ENV_SIZE		0x1000
+#define CONFIG_ENV_IS_IN_FAT
+#define CONFIG_FAT_WRITE
+#define FAT_ENV_INTERFACE	"mmc"
+#define FAT_ENV_FILE		"uboot.env"
+#define FAT_ENV_DEVICE		0
+#define FAT_ENV_PART		1
+#define CONFIG_ENV_SIZE		0x4000
 #define CONFIG_BOOTCOMMAND	"fatload mmc 0:1 0x21000000 dtb; " \
 				"fatload mmc 0:1 0x22000000 uImage; " \
 				"bootm 0x22000000 - 0x21000000"
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 2/2 ARM: at91: sama5d3: mmc: save enviroment as a fat file (uboot.env)

Hi Josh,

Quoted 10 lines · Josh Wu

This patch will save U-Boot environment as a file: uboot.env, in FAT partition instead of saving it in raw sector of SD card.

Since saving environment in raw sector has risk of corrupting the SD card and only can use very small size. Save as a FAT file has no above limitation.

---
  include/configs/sama5d3xek.h |   10 +++++++---
  1 file changed, 7 insertions(+), 3 deletions(-)

Tested on sama5d31ek board. It doesn't work. Please check it, and also check on at91sam9x5ek board.

Please take the following information as a reference. --->8---
U-Boot 2013.10-00389-gf37e980 (Nov 22 2013 - 17:56:53)

CPU: SAMA5D31
Crystal frequency:       12 MHz
CPU clock        :      528 MHz
Master clock     :      132 MHz
DRAM:  512 MiB
NAND:  256 MiB
MMC:   mci: 0
mci: setting clock 257812 Hz, block size 512
mci: setting clock 257812 Hz, block size 512
mci: setting clock 257812 Hz, block size 512
mci: setting clock 257812 Hz, block size 512
mci: setting clock 22000000 Hz, block size 512

reading uboot.env

** Unable to read "uboot.env" from mmc0:1 ** Using default environment

In:    serial
Out:   serial
Err:   serial
Net:   macb0
Warning: failed to set MAC address

, usb_ether
Hit any key to stop autoboot: 0
U-Boot> fat
fatinfo fatload fatls fatwrite
U-Boot> fatls mmc 0

     20737   boot.bin
    332916   u-boot.bin

2 file(s), 0 dir(s)

U-Boot> saveenv
Saving Environment to FAT...
mci: setting clock 257812 Hz, block size 512
mci: setting clock 22000000 Hz, block size 512
mci: setting clock 257812 Hz, block size 512
mci: setting clock 257812 Hz, block size 512
mci: setting clock 22000000 Hz, block size 512 writing uboot.env
done
U-Boot> fatls mmc 0

     20737   boot.bin
    332916   u-boot.bin

2 file(s), 0 dir(s)
---8<---

Quoted 12 lines
include/configs/sama5d3xek.h +0 -3
index 5a6f0fc..a77ab5f 100644
@@ -196,9 +196,13 @@
  				"bootm 0x22000000 - 0x21000000"
  #elif CONFIG_SYS_USE_MMC
  /* bootstrap + u-boot + env in sd card */
-#define CONFIG_ENV_IS_IN_MMC
-#define CONFIG_ENV_OFFSET	0x2000
-#define CONFIG_ENV_SIZE		0x1000

include/configs/sama5d3xek.h line 208

Quoted 10 lines
include/configs/sama5d3xek.h +7 -0
+#define CONFIG_ENV_IS_IN_FAT
+#define CONFIG_FAT_WRITE
+#define FAT_ENV_INTERFACE	"mmc"
+#define FAT_ENV_FILE		"uboot.env"
+#define FAT_ENV_DEVICE		0
+#define FAT_ENV_PART		1
+#define CONFIG_ENV_SIZE		0x4000
  #define CONFIG_BOOTCOMMAND	"fatload mmc 0:1 0x21000000 dtb; " \
  				"fatload mmc 0:1 0x22000000 uImage; " \
  				"bootm 0x22000000 - 0x21000000"

Best Regards,
Bo Shen

author
#3 lore raw

PATCH 2/2 ARM: at91: sama5d3: mmc: save enviroment as a fat file (uboot.env)

Quoted 66 lines · Bo Shen

Hi Josh,

Quoted 9 lines · Josh Wu

This patch will save U-Boot environment as a file: uboot.env, in FAT partition
instead of saving it in raw sector of SD card.

Since saving environment in raw sector has risk of corrupting the SD card and
only can use very small size. Save as a FAT file has no above limitation.

Quoted 4 lines
---
  include/configs/sama5d3xek.h |   10 +++++++---
  1 file changed, 7 insertions(+), 3 deletions(-)

Tested on sama5d31ek board. It doesn't work. Please check it, and also check on at91sam9x5ek board.

Please take the following information as a reference. --->8---
U-Boot 2013.10-00389-gf37e980 (Nov 22 2013 - 17:56:53)

CPU: SAMA5D31
Crystal frequency:       12 MHz
CPU clock        :      528 MHz
Master clock     :      132 MHz
DRAM:  512 MiB
NAND:  256 MiB
MMC:   mci: 0
mci: setting clock 257812 Hz, block size 512
mci: setting clock 257812 Hz, block size 512
mci: setting clock 257812 Hz, block size 512
mci: setting clock 257812 Hz, block size 512
mci: setting clock 22000000 Hz, block size 512

reading uboot.env

** Unable to read "uboot.env" from mmc0:1 ** Using default environment

In:    serial
Out:   serial
Err:   serial
Net:   macb0
Warning: failed to set MAC address

, usb_ether
Hit any key to stop autoboot: 0
U-Boot> fat
fatinfo fatload fatls fatwrite
U-Boot> fatls mmc 0

    20737   boot.bin

332916 u-boot.bin

2 file(s), 0 dir(s)

U-Boot> saveenv
Saving Environment to FAT...
mci: setting clock 257812 Hz, block size 512
mci: setting clock 22000000 Hz, block size 512
mci: setting clock 257812 Hz, block size 512
mci: setting clock 257812 Hz, block size 512
mci: setting clock 22000000 Hz, block size 512 writing uboot.env
done
U-Boot> fatls mmc 0

Quoted 5 lines
    20737   boot.bin

332916 u-boot.bin

2 file(s), 0 dir(s)
---8<---

Oops, this indeed happened in my side too. I will follow on this issue. Thanks for the testing.

Quoted 18 lines
Quoted 18 lines
include/configs/sama5d3xek.h +6 -3
index 5a6f0fc..a77ab5f 100644
@@ -196,9 +196,13 @@
                  "bootm 0x22000000 - 0x21000000"
  #elif CONFIG_SYS_USE_MMC
  /* bootstrap + u-boot + env in sd card */
-#define CONFIG_ENV_IS_IN_MMC
-#define CONFIG_ENV_OFFSET    0x2000
-#define CONFIG_ENV_SIZE        0x1000
+#define CONFIG_ENV_IS_IN_FAT
+#define CONFIG_FAT_WRITE
+#define FAT_ENV_INTERFACE    "mmc"
+#define FAT_ENV_FILE        "uboot.env"
+#define FAT_ENV_DEVICE        0
+#define FAT_ENV_PART        1
Quoted 8 lines

include/configs/sama5d3xek.h line 208

Quoted 5 lines
include/configs/sama5d3xek.h +1 -0
+#define CONFIG_ENV_SIZE        0x4000
  #define CONFIG_BOOTCOMMAND    "fatload mmc 0:1 0x21000000 dtb; " \
                  "fatload mmc 0:1 0x22000000 uImage; " \
                  "bootm 0x22000000 - 0x21000000"

Best Regards,
Bo Shen

Best Regards,
Josh Wu