Merge "Read entire HNVRAM partition space available"
diff --git a/common/cmd_hnvram.c b/common/cmd_hnvram.c
index 2f4d308..97c2ff2 100644
--- a/common/cmd_hnvram.c
+++ b/common/cmd_hnvram.c
@@ -39,28 +39,29 @@
#define CONFIG_SF_DEFAULT_MODE SPI_MODE_3
-// Flash erase block size
-#define HNVRAM_BLOCKSIZE 0x00010000
-
// Location in DRAM where hnvram variables are stored during boot
// DRAM is 128 MB [0x80000000 - 0x88000000]
// Store hnvram at 120 - 122 MB
-#define HNVRAM_DRAM_OFFSET 0x87800000
+#define HNVRAM_DRAM_OFFSET 0x87800000
// Where in flash does hnvram partition start
-#define HNVRAM_MTD_OFFSET 0x00200000
+#define HNVRAM_MTD_OFFSET UBOOT_PARTITION_OFFSET_HNVRAM
// Total hnvram is 2MB with 4 partitions
-#define MAX_HNVRAM_SIZE 0x00200000
+#define MAX_HNVRAM_SIZE UBOOT_HNVRAM_PARTITION_SIZE
+// Sub-partitions are stored packed, in this order.
+// HNVRAM_RW_SIZE is halved to match HNVRAM_RWB_SIZE, though the offset
+// to RWB remains the same.
#define HNVRAM_RO_SIZE 0x00100000
-#define HNVRAM_RW_SIZE 0x00040000
+#define HNVRAM_RW_SIZE 0x00020000
+#define HNVRAM_RESERVED_SIZE 0x00020000
#define HNVRAM_RWB_SIZE 0x00020000
#define HNVRAM_RAW_FS_SIZE 0x00020000
// B1 and B2 corresponding to RW_OFFSET and RWB_OFFSET
#define HNVRAM_B1_OFFSET (HNVRAM_RO_SIZE)
-#define HNVRAM_B2_OFFSET (HNVRAM_RO_SIZE + HNVRAM_RW_SIZE)
+#define HNVRAM_B2_OFFSET (HNVRAM_RO_SIZE + HNVRAM_RW_SIZE + HNVRAM_RESERVED_SIZE)
#define CMD_RET_SUCCESS 0
#define CMD_RET_FAILURE 1
@@ -236,17 +237,18 @@
// Next step: Seek to different parts of the buffer that contain the
// first, second, and third sections of hnvram.
- if (_parse_hnvram(buf, HNVRAM_BLOCKSIZE) != 0) {
- printf("failed parsing hnvram at offset: 0x%p\n", buf);
+ if (_parse_hnvram(buf, HNVRAM_RO_SIZE) != 0) {
+ printf("failed parsing HNVRAM_RO at offset: 0x%p\n", buf);
return -1;
}
- if (_parse_hnvram(buf+HNVRAM_B1_OFFSET, HNVRAM_BLOCKSIZE) != 0) {
- printf("failed parsing hnvram at offset: 0x%p\n", buf+HNVRAM_B1_OFFSET);
- return -1;
- }
- if (_parse_hnvram(buf+HNVRAM_B2_OFFSET, HNVRAM_BLOCKSIZE) != 0) {
- printf("failed parsing hnvram at offset: 0x%p\n", buf+HNVRAM_B2_OFFSET);
- return -1;
+ // Read from the RWB partition on failure to read RW.
+ if (_parse_hnvram(buf+HNVRAM_B1_OFFSET, HNVRAM_RW_SIZE) != 0) {
+ printf("failed parsing HNVRAM_RW at offset: 0x%p\n", buf+HNVRAM_B1_OFFSET);
+ if (_parse_hnvram(buf+HNVRAM_B2_OFFSET, HNVRAM_RWB_SIZE) != 0) {
+ printf("failed parsing HNVRAM_RWB at offset: 0x%p\n",
+ buf+HNVRAM_B2_OFFSET);
+ return -1;
+ }
}
return CMD_RET_SUCCESS;
diff --git a/quantenna/common/ruby_partitions.h b/quantenna/common/ruby_partitions.h
index 7d688fe..9a1cb53 100644
--- a/quantenna/common/ruby_partitions.h
+++ b/quantenna/common/ruby_partitions.h
@@ -40,11 +40,12 @@
#define CONFIG_ENV_OFFSET 0x00040000 /* offset of uboot environment */
-#define UBOOT_PARTITION_OFFSET_KERNEL0 (UBOOT_TEXT_PARTITION_SIZE + \
+#define UBOOT_PARTITION_OFFSET_HNVRAM (UBOOT_TEXT_PARTITION_SIZE + \
UBOOT_ENV_PARTITION_SIZE + \
UBOOT_RESERVED_A_PARTITION_SIZE + \
UBOOT_VENDOR_PARTITION_SIZE + \
- UBOOT_RESERVED_B_PARTITION_SIZE + \
+ UBOOT_RESERVED_B_PARTITION_SIZE)
+#define UBOOT_PARTITION_OFFSET_KERNEL0 (UBOOT_PARTITION_OFFSET_HNVRAM + \
UBOOT_HNVRAM_PARTITION_SIZE)
#define UBOOT_PARTITION_OFFSET_KERNEL1 (UBOOT_PARTITION_OFFSET_KERNEL0 + \
UBOOT_KERNEL_PARTITION_SIZE)