Skip to contentSkip to conversation

common: env: support sata device

PATCH New Peng Fan 2 participants 3 messages Mar 28, 2016 – Mar 29, 2016

lore
Share & tools
lore

Peng Fan

author
#0 lore raw

PATCH 1/1 common: env: support sata device

Introduce env support for sata device.
1. Implement write_env/read_env/env_relocate_spec/saveenv/sata_get_env_dev
2. If want to enable this feature, define CONFIG_ENV_IS_IN_SATA, and define CONFIG_SYS_SATA_ENV_DEV or implement your own sata_get_ev_dev.

Cc Simon Glass <[email protected]>
Cc Joe Hershberger <[email protected]>
Cc Bin Meng <[email protected]>
Cc Stefan Roese <[email protected]>
Cc Heiko Schocher <[email protected]>
Cc Stuart Longland <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Tom Rini <[email protected]>
---
 cmd/nvedit.c      |   3 +-
 common/Makefile   |   1 +
 common/env_sata.c | 135 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 138 insertions(+), 1 deletion(-)
 create mode 100644 common/env_sata.c
cmd/nvedit.c +2 -1
index 9cf884e..b67563b 100644
@@ -49,12 +49,13 @@ DECLARE_GLOBAL_DATA_PTR;
 	!defined(CONFIG_ENV_IS_IN_NAND)		&& \
 	!defined(CONFIG_ENV_IS_IN_NVRAM)	&& \
 	!defined(CONFIG_ENV_IS_IN_ONENAND)	&& \
+	!defined(CONFIG_ENV_IS_IN_SATA)		&& \
 	!defined(CONFIG_ENV_IS_IN_SPI_FLASH)	&& \
 	!defined(CONFIG_ENV_IS_IN_REMOTE)	&& \
 	!defined(CONFIG_ENV_IS_IN_UBI)		&& \
 	!defined(CONFIG_ENV_IS_NOWHERE)
 # error Define one of CONFIG_ENV_IS_IN_{EEPROM|FLASH|DATAFLASH|ONENAND|\
-SPI_FLASH|NVRAM|MMC|FAT|EXT4|REMOTE|UBI} or CONFIG_ENV_IS_NOWHERE
+SATA|SPI_FLASH|NVRAM|MMC|FAT|EXT4|REMOTE|UBI} or CONFIG_ENV_IS_NOWHERE
 #endif
 
 /*
common/Makefile +1 -0
index 9a4b817..b23f312 100644
@@ -50,6 +50,7 @@ obj-$(CONFIG_ENV_IS_IN_EXT4) += env_ext4.o
 obj-$(CONFIG_ENV_IS_IN_NAND) += env_nand.o
 obj-$(CONFIG_ENV_IS_IN_NVRAM) += env_nvram.o
 obj-$(CONFIG_ENV_IS_IN_ONENAND) += env_onenand.o
+obj-$(CONFIG_ENV_IS_IN_SATA) += env_sata.o
 obj-$(CONFIG_ENV_IS_IN_SPI_FLASH) += env_sf.o
 obj-$(CONFIG_ENV_IS_IN_REMOTE) += env_remote.o
 obj-$(CONFIG_ENV_IS_IN_UBI) += env_ubi.o
common/env_sata.c new file +135 -0

135 lines not on this page · raw message

Signature · 1 line
2.6.2
#1 lore raw

PATCH 1/1 common: env: support sata device

Quoted 4 lines · Peng Fan

Introduce env support for sata device.
1. Implement write_env/read_env/env_relocate_spec/saveenv/sata_get_env_dev
2. If want to enable this feature, define CONFIG_ENV_IS_IN_SATA, and define CONFIG_SYS_SATA_ENV_DEV or implement your own sata_get_ev_dev.

[snip]

Quoted 3 lines

+/*
+ * TODO: Support CONFIG_ENV_SIZE_REDUND CONFIG_ENV_OFFSET_REDUND
+ */

I'd like to see #error here as well, having been bit in the past in cases of "Oh, redund doesn't work?".

common/env_sata.c line 30

Quoted 8 lines
common/env_sata.c new file +8 -0
+#if !defined(CONFIG_ENV_OFFSET) || !defined(CONFIG_ENV_SIZE)
+#error CONFIG_ENV_OFFSET or CONFIG_ENV_SIZE not defined
+#endif
+
+char *env_name_spec = "SATA";
+
+#ifdef ENV_IS_EMBEDDED
+env_t *env_ptr = (env_t *)(&environment[0]);

So, you're not adding (and I'm not suggesting you do) SATA to the list of environment types where we support embedded env. Please just remove these tests here and elsewhere. Thanks!

[snip]

common/env_sata.c line 106

Quoted 9 lines
common/env_sata.c new file +9 -0
+static inline int read_env(struct blk_desc *sata, unsigned long size,
+			   unsigned long offset, const void *buffer)
+{
+	uint blk_start, blk_cnt, n;
+
+	blk_start = ALIGN(offset, sata->blksz) / sata->blksz;
+	blk_cnt   = ALIGN(size, sata->blksz) / sata->blksz;
+
+	n = sata->block_read(sata, blk_start, blk_cnt, (uchar *)buffer);

Here and elsewhere, please update to use blk_dread, etc, from blk.h to help future proof this code, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160328/a945ce3d/attachment.sig>
author
#2 lore raw

PATCH 1/1 common: env: support sata device

Hi Tom,

Thanks for reviewing.

Quoted 6 lines · Tom Rini
Quoted 4 lines · Peng Fan

Introduce env support for sata device.
1. Implement write_env/read_env/env_relocate_spec/saveenv/sata_get_env_dev
2. If want to enable this feature, define CONFIG_ENV_IS_IN_SATA, and define CONFIG_SYS_SATA_ENV_DEV or implement your own sata_get_ev_dev.

Quoted 7 lines

[snip]

Quoted 3 lines

+/*
+ * TODO: Support CONFIG_ENV_SIZE_REDUND CONFIG_ENV_OFFSET_REDUND
+ */

I'd like to see #error here as well, having been bit in the past in cases of "Oh, redund doesn't work?".

Will fix in V2.

Quoted 13 lines

common/env_sata.c line 30

Quoted 9 lines
common/env_sata.c new file +8 -0
+#if !defined(CONFIG_ENV_OFFSET) || !defined(CONFIG_ENV_SIZE)
+#error CONFIG_ENV_OFFSET or CONFIG_ENV_SIZE not defined
+#endif
+
+char *env_name_spec = "SATA";
+
+#ifdef ENV_IS_EMBEDDED
+env_t *env_ptr = (env_t *)(&environment[0]);

So, you're not adding (and I'm not suggesting you do) SATA to the list of environment types where we support embedded env. Please just remove these tests here and elsewhere. Thanks!

Fix in V2.

Quoted 14 lines

[snip]

common/env_sata.c line 106

Quoted 9 lines
common/env_sata.c new file +9 -0
+static inline int read_env(struct blk_desc *sata, unsigned long size,
+			   unsigned long offset, const void *buffer)
+{
+	uint blk_start, blk_cnt, n;
+
+	blk_start = ALIGN(offset, sata->blksz) / sata->blksz;
+	blk_cnt   = ALIGN(size, sata->blksz) / sata->blksz;
+
+	n = sata->block_read(sata, blk_start, blk_cnt, (uchar *)buffer);

Here and elsewhere, please update to use blk_dread, etc, from blk.h to help future proof this code, thanks!

Fix in V2.

Thanks,
Peng.

Quoted 3 lines
Signature · 2 lines
-- 
Tom