Skip to contentSkip to conversation

w1: fix build without CONFIG_W1_EEPROM

PATCH New Martin Fuzzey 3 participants 7 messages Oct 22, 2018 – Oct 24, 2018 W1 dallas's 1-wire bus

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 w1: fix build without CONFIG_W1_EEPROM

Building with CONFIG_W1 and CONFIG_CMD_W1 but without CONFIG_W1_EEPROM fails with
drivers/w1/w1-uclass.c:104: undefined reference to w1_eeprom_register_new_device' cmd/w1.c:93: undefined reference to w1_eeprom_read_buf'

Fix this.

---
 cmd/w1.c               | 9 ++++++++-
 drivers/w1/w1-uclass.c | 2 ++
 2 files changed, 10 insertions(+), 1 deletion(-)
cmd/w1.c +8 -1
index 9c95fcf..9765bd6 100644
@@ -41,6 +41,7 @@ static int w1_bus(void)
 	return CMD_RET_SUCCESS;
 }
 
+#ifdef CONFIG_W1_EEPROM
 static int w1_read(int argc, char *const argv[])
 {
 	int bus_n = 0, dev_n = 0, offset = 0, len = 512;
@@ -102,6 +103,7 @@ static int w1_read(int argc, char *const argv[])
 
 	return CMD_RET_SUCCESS;
 }
+#endif
 
 int do_w1(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 {
@@ -111,8 +113,10 @@ int do_w1(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 	if (!strcmp(argv[1], "bus"))
 		return w1_bus();
 
+#ifdef CONFIG_W1_EEPROM
 	if (!strcmp(argv[1], "read"))
 		return w1_read(argc, argv);
+#endif
 
 	return CMD_RET_SUCCESS;
 }
@@ -120,7 +124,10 @@ int do_w1(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 U_BOOT_CMD(w1, 6, 0, do_w1,
 	   "onewire interface utility commands",
 	   "bus - show onewire bus info (all)\n"
+#ifdef CONFIG_W1_EEPROM
 	   "w1 read [<bus> [<dev> [offset [length]]]]"
 	   "    - read from onewire device 'dev' on onewire bus 'bus'"
 	   " starting from offset 'offset' and length 'length'\n"
-	   "      defaults: bus 0, dev 0, offset 0, length 512 bytes.");
+	   "      defaults: bus 0, dev 0, offset 0, length 512 bytes."
+#endif
+	   );
drivers/w1/w1-uclass.c +2 -0
index cb41b68..5544b19 100644
@@ -100,8 +100,10 @@ static int w1_enumerate(struct udevice *bus)
 			debug("%s: Detected new device 0x%llx (family 0x%x)\n",
 			      bus->name, rn, (u8)(rn & 0xff));
 
+#ifdef CONFIG_W1_EEPROM
 			/* attempt to register as w1-eeprom device */
 			w1_eeprom_register_new_device(rn);
+#endif
 		}
 	}
 
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 w1: fix build without CONFIG_W1_EEPROM

Quoted 6 lines · Martin Fuzzey

Building with CONFIG_W1 and CONFIG_CMD_W1 but without CONFIG_W1_EEPROM fails with
drivers/w1/w1-uclass.c:104: undefined reference to w1_eeprom_register_new_device' cmd/w1.c:93: undefined reference to w1_eeprom_read_buf'

Fix this.

I would prefer if you let the w1 read command to be accessible regardless if CONFIG_W1_EEPROM is defined or not. Hence have only the w1 eeprom reads under the ifdef...
The w1_read checks for devices anyway and for the bus, so it should print invalid bus/device if nothing is present there.
Any opinion on this ?

Thanks,
Eugen

Quoted 66 lines
---
  cmd/w1.c               | 9 ++++++++-
  drivers/w1/w1-uclass.c | 2 ++
  2 files changed, 10 insertions(+), 1 deletion(-)
cmd/w1.c +8 -1
index 9c95fcf..9765bd6 100644
@@ -41,6 +41,7 @@ static int w1_bus(void)
  	return CMD_RET_SUCCESS;
  }
 
+#ifdef CONFIG_W1_EEPROM
  static int w1_read(int argc, char *const argv[])
  {
  	int bus_n = 0, dev_n = 0, offset = 0, len = 512;
@@ -102,6 +103,7 @@ static int w1_read(int argc, char *const argv[])
 
  	return CMD_RET_SUCCESS;
  }
+#endif
 
  int do_w1(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
  {
@@ -111,8 +113,10 @@ int do_w1(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
  	if (!strcmp(argv[1], "bus"))
  		return w1_bus();
 
+#ifdef CONFIG_W1_EEPROM
  	if (!strcmp(argv[1], "read"))
  		return w1_read(argc, argv);
+#endif
 
  	return CMD_RET_SUCCESS;
  }
@@ -120,7 +124,10 @@ int do_w1(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
  U_BOOT_CMD(w1, 6, 0, do_w1,
  	   "onewire interface utility commands",
  	   "bus - show onewire bus info (all)\n"
+#ifdef CONFIG_W1_EEPROM
  	   "w1 read [<bus> [<dev> [offset [length]]]]"
  	   "    - read from onewire device 'dev' on onewire bus 'bus'"
  	   " starting from offset 'offset' and length 'length'\n"
-	   "      defaults: bus 0, dev 0, offset 0, length 512 bytes.");
+	   "      defaults: bus 0, dev 0, offset 0, length 512 bytes."
+#endif
+	   );
drivers/w1/w1-uclass.c +2 -0
index cb41b68..5544b19 100644
@@ -100,8 +100,10 @@ static int w1_enumerate(struct udevice *bus)
  			debug("%s: Detected new device 0x%llx (family 0x%x)\n",
  			      bus->name, rn, (u8)(rn & 0xff));
 
+#ifdef CONFIG_W1_EEPROM
  			/* attempt to register as w1-eeprom device */
  			w1_eeprom_register_new_device(rn);
+#endif
  		}
  	}
 
#2 lore raw

PATCH 1/1 w1: fix build without CONFIG_W1_EEPROM

Quoted 7 lines · Eugen.Hristev at microchip.com
Quoted 5 lines · Martin Fuzzey

Building with CONFIG_W1 and CONFIG_CMD_W1 but without CONFIG_W1_EEPROM fails with
drivers/w1/w1-uclass.c:104: undefined reference to w1_eeprom_register_new_device' cmd/w1.c:93: undefined reference to w1_eeprom_read_buf'

Quoted 7 lines
Quoted 1 line

Fix this.

I would prefer if you let the w1 read command to be accessible regardless if CONFIG_W1_EEPROM is defined or not. Hence have only the w1 eeprom reads under the ifdef...
The w1_read checks for devices anyway and for the bus, so it should print invalid bus/device if nothing is present there.
Any opinion on this ?

I don't really have a strong opinion on this.

Completely removing non implemented commands seems to be a common thing to do in u-boot (cmd/i2c.c for instance) presumably to keep the image size as small as possible.
But for the one wire case the code space saving is likely to be small and, currently at least, there is little point buiding without CONFIG_W1_EEPROM, not sure if that will change some day - of course there are other types of one wire devices like various sensors but they are probably of less interest in the context of a bootloader.

Let's wait a bit and see what Maxime or anyone else has to say about this.

Regards,

Martin

#3 lore raw

PATCH 1/1 w1: fix build without CONFIG_W1_EEPROM

Quoted 28 lines · Martin Fuzzey
Quoted 8 lines · Eugen.Hristev at microchip.com
Quoted 6 lines · Martin Fuzzey

Building with CONFIG_W1 and CONFIG_CMD_W1 but without CONFIG_W1_EEPROM fails with
    drivers/w1/w1-uclass.c:104: undefined reference to `w1_eeprom_register_new_device'
    cmd/w1.c:93: undefined reference to `w1_eeprom_read_buf'

Quoted 7 lines
Quoted 1 line

Fix this.

I would prefer if you let the w1 read command to be accessible regardless if CONFIG_W1_EEPROM is defined or not. Hence have only the w1 eeprom reads under the ifdef...
The w1_read checks for devices anyway and for the bus, so it should print invalid bus/device if nothing is present there.
Any opinion on this ?

I don't really have a strong opinion on this.

Completely removing non implemented commands seems to be a common thing to do in u-boot (cmd/i2c.c for instance) presumably to keep the image size as small as possible.
But for the one wire case the code space saving is likely to be small and, currently at least, there is little point buiding without CONFIG_W1_EEPROM, not sure if that will change some day - of course there are other types of one wire devices like various sensors but they are probably of less interest in the context of a bootloader.

Quoted 1 line

Let's wait a bit and see what Maxime or anyone else has to say about this.

I tried as much as possible to decouple the W1 bus from the W1 EEPROM memories. It is possible that we will have a different framework for EEPROMs that will include both 1wire and i2c eeproms, and then the interfacing would be pretty easy to change to.

That's why I am thinking that w1 bus read should not be much affected if the 1w EEPROMs are unknown to U-boot

Quoted 6 lines

Regards,

Martin

#4 lore raw

PATCH 1/1 w1: fix build without CONFIG_W1_EEPROM

Quoted 9 lines · Eugen.Hristev at microchip.com

I tried as much as possible to decouple the W1 bus from the W1 EEPROM memories. It is possible that we will have a different framework for EEPROMs that will include both 1wire and i2c eeproms, and then the interfacing would be pretty easy to change to.

That's why I am thinking that w1 bus read should not be much affected if the 1w EEPROMs are unknown to U-boot

Yes sure that's great.

Somewhat diverting this thread....

I noticed that currently "w1 read" displays the data in hex with "%x", which means it prints just one character if in range 00-0f. And as there is no seperator the output isn't currently useful.

That's a trivial fix of course but it got me thinking about what do we want to "w1 read" to do?

A lot of other storage reading commands use "read" to mean "read to memory" and take a destination RAM address parameter.
Eg mmc read, sf read, ...

There are counter examples though like "mii read" or "pmic read" which just print the output but they don't read aribitary
user defined data like an eeprom.

So I was wondering if it would be better to modify "w1 read" to mean "read to memory" and add a new "w1 dump" command
to do what "w1 read" currently does (as it is much more convenient for quickly checking the eeprom contents than
having to use md).

The type of use case I'm thinking of for "read to memory" is if someone wants to put a device tree blob on an eeprom.

What do you think?

Regards,

Martin

Quoted 5 lines
Quoted 5 lines

Regards,

Martin

#5 lore raw

PATCH 1/1 w1: fix build without CONFIG_W1_EEPROM

Hi Martin, Eugen,

Quoted 29 lines · Eugen.Hristev at microchip.com
Quoted 9 lines

I tried as much as possible to decouple the W1 bus from the W1 EEPROM memories. It is possible that we will have a different framework for EEPROMs that will include both 1wire and i2c eeproms, and then the interfacing would be pretty easy to change to.

That's why I am thinking that w1 bus read should not be much affected if the 1w EEPROMs are unknown to U-boot

Yes sure that's great.

Somewhat diverting this thread....

I noticed that currently "w1 read" displays the data in hex with "%x", which means it prints just one character if in range 00-0f. And as there is no seperator the output isn't currently useful.

That's a trivial fix of course but it got me thinking about what do we want to "w1 read" to do?

A lot of other storage reading commands use "read" to mean "read to memory" and take a destination RAM address parameter.
Eg mmc read, sf read, ...

There are counter examples though like "mii read" or "pmic read" which just print the output but they don't read aribitary user defined data like an eeprom.

Quoted 9 lines

So I was wondering if it would be better to modify "w1 read" to mean "read to memory" and add a new "w1 dump" command
to do what "w1 read" currently does (as it is much more convenient for quickly checking the eeprom contents than
having to use md).

The type of use case I'm thinking of for "read to memory" is if someone wants to put a device tree blob on an eeprom.

If I may add my 2cents.

I also would like to see the w1 command to load read data to memory (to be consistent with e.g. load), so we could use md.b, mw.b, etc.

Quoted 10 lines

What do you think?

Regards,

Martin

Quoted 2 lines
Quoted 2 lines

Regards,

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines

Martin

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

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181024/beb37de8/attachment.sig>

#6 lore raw

PATCH 1/1 w1: fix build without CONFIG_W1_EEPROM

Quoted 37 lines · Lukasz Majewski

Hi Martin, Eugen,

Quoted 35 lines · Eugen.Hristev at microchip.com
Quoted 9 lines

I tried as much as possible to decouple the W1 bus from the W1 EEPROM memories. It is possible that we will have a different framework for EEPROMs that will include both 1wire and i2c eeproms, and then the interfacing would be pretty easy to change to.

That's why I am thinking that w1 bus read should not be much affected if the 1w EEPROMs are unknown to U-boot

Yes sure that's great.

Somewhat diverting this thread....

I noticed that currently "w1 read" displays the data in hex with "%x", which means it prints just one character if in range 00-0f. And as there is no seperator the output isn't currently useful.

That's a trivial fix of course but it got me thinking about what do we want to "w1 read" to do?

A lot of other storage reading commands use "read" to mean "read to memory" and take a destination RAM address parameter.
Eg mmc read, sf read, ...

There are counter examples though like "mii read" or "pmic read" which just print the output but they don't read aribitary user defined data like an eeprom.

So I was wondering if it would be better to modify "w1 read" to mean "read to memory" and add a new "w1 dump" command
to do what "w1 read" currently does (as it is much more convenient for quickly checking the eeprom contents than
having to use md).

Quoted 10 lines
Quoted 3 lines

The type of use case I'm thinking of for "read to memory" is if someone wants to put a device tree blob on an eeprom.

If I may add my 2cents.

I also would like to see the w1 command to load read data to memory (to be consistent with e.g. load), so we could use md.b, mw.b, etc.

Quoted 1 line

What do you think?

I believe it's a good thing to have them as you said. The w1 support which I made was "initial" and "minimal" . I am happy to see it extended.

Eugen

Quoted 31 lines
Quoted 9 lines

Regards,

Martin

Quoted 2 lines
Quoted 2 lines

Regards,

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines

Martin

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

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de