Skip to contentSkip to conversation

serial: add environment control for SERIAL_MULTI

PATCH New Allen Martin 5 participants 14 messages Oct 25, 2012 – Oct 26, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 serial: add environment control for SERIAL_MULTI

Add a new special environment variable "serial" that allows selection of serial device when CONFIG_SERIAL_MULTI is defined. This replaces the existing calls to serial_assign() from cmd_nvedit.c and iomux.c that were not doing anything.

---
 common/cmd_nvedit.c             |    7 ++++++-
 common/iomux.c                  |   10 ----------
 doc/driver-model/UDM-serial.txt |    5 +++--
 3 files changed, 9 insertions(+), 13 deletions(-)
common/cmd_nvedit.c +6 -1
index 1f9c674..d1ee07d 100644
@@ -238,11 +238,16 @@ int env_check_apply(const char *name, const char *oldval,
 		/* Try assigning specified device */
 		if (console_assign(console, newval) < 0)
 			return 1;
+#endif /* CONFIG_CONSOLE_MUX */
+	}
 
+#ifdef CONFIG_SERIAL_MULTI
+	/* Check for serial redirection */
+	if (strcmp(name, "serial") == 0) {
 		if (serial_assign(newval) < 0)
 			return 1;
-#endif /* CONFIG_CONSOLE_MUX */
 	}
+#endif /* CONFIG_SERIAL_MULTI */
 
 	/*
 	 * Some variables like "ethaddr" and "serial#" can be set only once and
common/iomux.c +0 -10
index dbc2312..6a75704 100644
@@ -135,16 +135,6 @@ int iomux_doenv(const int console, const char *arg)
 		 */
 		if (console_assign(console, start[j]) < 0)
 			continue;
-		/*
-		 * This was taken from common/cmd_nvedit.c.
-		 * This will never work because serial_assign() returns
-		 * 1 upon error, not -1.
-		 * This would almost always return an error anyway because
-		 * serial_assign() expects the name of a serial device, like
-		 * serial_smc, but the user generally only wants to set serial.
-		 */
-		if (serial_assign(start[j]) < 0)
-			continue;
 		cons_set[cs_idx++] = dev;
 	}
 	free(console_args);
doc/driver-model/UDM-serial.txt +3 -2
index 9feb2e5..66f3e6b 100644
@@ -26,8 +26,9 @@ and serial_setbrg() are often called from platform-dependent places.
 It's important to consider current implementation of CONFIG_SERIAL_MULTI though.
 This resides in common/serial.c and behaves as a multiplexer for serial ports.
 This, by calling serial_assign(), allows user to switch I/O from one serial port
-to another. Though the environmental variables "stdin", "stdout", "stderr"
-remain set to "serial".
+to another. The environment variable "serial" is used to select which of the
+serial ports is the currently active port.  The environmental variables
+"stdin", "stdout", "stderr" remain set to "serial".
 
 These variables are managed by the IOMUX. This resides in common/iomux.c and
 manages all console input/output from U-Boot. For serial port, only one IOMUX is
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 1/1 serial: add environment control for SERIAL_MULTI

Dear Allen Martin,

Quoted 17 lines

Add a new special environment variable "serial" that allows selection of serial device when CONFIG_SERIAL_MULTI is defined. This replaces the existing calls to serial_assign() from cmd_nvedit.c and iomux.c that were not doing anything.

---
 common/cmd_nvedit.c             |    7 ++++++-
 common/iomux.c                  |   10 ----------
 doc/driver-model/UDM-serial.txt |    5 +++--
 3 files changed, 9 insertions(+), 13 deletions(-)
common/cmd_nvedit.c +0 -0
index 1f9c674..d1ee07d 100644

common/cmd_nvedit.c int env_check_apply(const char *name, const char · line 244

Quoted 7 lines
common/cmd_nvedit.c +3 -0
@@ -238,11 +238,16 @@ int env_check_apply(const char *name, const char
 *oldval, /* Try assigning specified device */
 		if (console_assign(console, newval) < 0)
 			return 1;
+#endif /* CONFIG_CONSOLE_MUX */
+	}
 
+#ifdef CONFIG_SERIAL_MULTI

Drop this, it's default. There's no CONFIG_SERIAL_MULTI in the tree at all anymore.

Quoted 46 lines
common/cmd_nvedit.c +3 -1
+	/* Check for serial redirection */
+	if (strcmp(name, "serial") == 0) {
 		if (serial_assign(newval) < 0)
 			return 1;
-#endif /* CONFIG_CONSOLE_MUX */
 	}
+#endif /* CONFIG_SERIAL_MULTI */
 
 	/*
 	 * Some variables like "ethaddr" and "serial#" can be set only once and
common/iomux.c +0 -10
index dbc2312..6a75704 100644
@@ -135,16 +135,6 @@ int iomux_doenv(const int console, const char *arg)
 		 */
 		if (console_assign(console, start[j]) < 0)
 			continue;
-		/*
-		 * This was taken from common/cmd_nvedit.c.
-		 * This will never work because serial_assign() returns
-		 * 1 upon error, not -1.
-		 * This would almost always return an error anyway because
-		 * serial_assign() expects the name of a serial device, like
-		 * serial_smc, but the user generally only wants to set serial.
-		 */
-		if (serial_assign(start[j]) < 0)
-			continue;
 		cons_set[cs_idx++] = dev;
 	}
 	free(console_args);
(quoted diff) +0 -0

b/doc/driver-model/UDM-serial.txt index 9feb2e5..66f3e6b 100644

doc/driver-model/UDM-serial.txt +0 -0
@@ -26,8 +26,9 @@ and serial_setbrg() are often called from

platform-dependent places. It's important to consider current implementation of CONFIG_SERIAL_MULTI though. This resides in common/serial.c and behaves as a multiplexer for serial ports. This, by calling serial_assign(), allows user to switch I/O from one serial port -to another. Though the environmental variables "stdin", "stdout", "stderr" -remain set to "serial".
+to another. The environment variable "serial" is used to select which of the +serial ports is the currently active port. The environmental variables +"stdin", "stdout", "stderr" remain set to "serial".

Quoted 3 lines

These variables are managed by the IOMUX. This resides in common/iomux.c
and manages all console input/output from U-Boot. For serial port, only one IOMUX is

Best regards,
Marek Vasut

#2 lore raw

PATCH 1/1 serial: add environment control for SERIAL_MULTI

In reply to Allen Martin
Quoted 6 lines · Allen Martin

Add a new special environment variable "serial" that allows selection of serial device when CONFIG_SERIAL_MULTI is defined. This replaces the existing calls to serial_assign() from cmd_nvedit.c and iomux.c that were not doing anything.

Two things. First, should I or should I not need to have CONFIG_CONSOLE_MUX set? If I set it, adding serial=eserial3 to my default environment switches from eserial0 to eserial3 when we get to that point in the boot, otherwise I do have to manually setenv serial eserial3 for anything to happen. And the second thing, I can't get any output on the other UART, either way. It goes away from eserial0 but nothing ever shows up to eserial3 (the easiest one here to test).

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20121025/d17afa93/attachment.pgp>
#3 lore raw

PATCH 1/1 serial: add environment control for SERIAL_MULTI

In reply to Allen Martin

Hi Allen,

Quoted 21 lines · Allen Martin

Add a new special environment variable "serial" that allows selection of serial device when CONFIG_SERIAL_MULTI is defined. This replaces the existing calls to serial_assign() from cmd_nvedit.c and iomux.c that were not doing anything.

---
 common/cmd_nvedit.c             |    7 ++++++-
 common/iomux.c                  |   10 ----------
 doc/driver-model/UDM-serial.txt |    5 +++--
 3 files changed, 9 insertions(+), 13 deletions(-)
common/cmd_nvedit.c +1 -0
index 1f9c674..d1ee07d 100644
@@ -238,11 +238,16 @@ int env_check_apply(const char *name, const char *oldval,
                /* Try assigning specified device */
                if (console_assign(console, newval) < 0)
                        return 1;
+#endif /* CONFIG_CONSOLE_MUX */

common/cmd_nvedit.c int env_check_apply(const char *name, const char *oldval, · line 250

Quoted 10 lines
common/cmd_nvedit.c +5 -1
+       }
 
+#ifdef CONFIG_SERIAL_MULTI
+       /* Check for serial redirection */
+       if (strcmp(name, "serial") == 0) {
                if (serial_assign(newval) < 0)
                        return 1;
-#endif /* CONFIG_CONSOLE_MUX */
        }
+#endif /* CONFIG_SERIAL_MULTI */

Changes to this directly conflict with the environment callback series I sent out RFC (soon be be a real series). Can we hold off on this until that happens?

Quoted 46 lines
common/cmd_nvedit.c +0 -0
        /*
         * Some variables like "ethaddr" and "serial#" can be set only once and
common/iomux.c +0 -10
index dbc2312..6a75704 100644
@@ -135,16 +135,6 @@ int iomux_doenv(const int console, const char *arg)
                 */
                if (console_assign(console, start[j]) < 0)
                        continue;
-               /*
-                * This was taken from common/cmd_nvedit.c.
-                * This will never work because serial_assign() returns
-                * 1 upon error, not -1.
-                * This would almost always return an error anyway because
-                * serial_assign() expects the name of a serial device, like
-                * serial_smc, but the user generally only wants to set serial.
-                */
-               if (serial_assign(start[j]) < 0)
-                       continue;
                cons_set[cs_idx++] = dev;
        }
        free(console_args);
doc/driver-model/UDM-serial.txt +3 -3
index 9feb2e5..66f3e6b 100644
@@ -26,8 +26,9 @@ and serial_setbrg() are often called from platform-dependent places.
 It's important to consider current implementation of CONFIG_SERIAL_MULTI though.
 This resides in common/serial.c and behaves as a multiplexer for serial ports.
 This, by calling serial_assign(), allows user to switch I/O from one serial port
-to another. Though the environmental variables "stdin", "stdout", "stderr"
-remain set to "serial".
+to another. The environment variable "serial" is used to select which of the
+serial ports is the currently active port.  The environmental variables
+"stdin", "stdout", "stderr" remain set to "serial".
 
 These variables are managed by the IOMUX. This resides in common/iomux.c and
 manages all console input/output from U-Boot. For serial port, only one IOMUX is
--

1.7.10.4

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

#4 lore raw

PATCH 1/1 serial: add environment control for SERIAL_MULTI

Quoted 7 lines · Joe Hershberger

Hi Allen,

Quoted 4 lines · Allen Martin

Add a new special environment variable "serial" that allows selection of serial device when CONFIG_SERIAL_MULTI is defined. This replaces the existing calls to serial_assign() from cmd_nvedit.c and iomux.c that were not doing anything.

...

Quoted 3 lines

Changes to this directly conflict with the environment callback series I sent out RFC (soon be be a real series). Can we hold off on this until that happens?

The problem here is that serial output on Tegra simply doesn't work (after some point in boot?) without this patch. It seems better to get everything working before adding new features doesn't it? Otherwise, if the environment callback stuff (or any other change right now) breaks something Tegra-specific, there would be no way to identify which change broke it.

#5 lore raw

PATCH 1/1 serial: add environment control for SERIAL_MULTI

Hi Stephen,

Quoted 13 lines · Stephen Warren
Quoted 7 lines · Joe Hershberger

Hi Allen,

Quoted 4 lines · Allen Martin

Add a new special environment variable "serial" that allows selection of serial device when CONFIG_SERIAL_MULTI is defined. This replaces the existing calls to serial_assign() from cmd_nvedit.c and iomux.c that were not doing anything.

...

Quoted 3 lines

Changes to this directly conflict with the environment callback series I sent out RFC (soon be be a real series). Can we hold off on this until that happens?

Quoted 6 lines

The problem here is that serial output on Tegra simply doesn't work (after some point in boot?) without this patch. It seems better to get everything working before adding new features doesn't it? Otherwise, if the environment callback stuff (or any other change right now) breaks something Tegra-specific, there would be no way to identify which change broke it.

Fair enough. However I don't think this patch is the right way to fix it.

-Joe

#6 lore raw

PATCH 1/1 serial: add environment control for SERIAL_MULTI

Quoted 16 lines · Joe Hershberger

Hi Stephen,

Quoted 13 lines · Stephen Warren
Quoted 7 lines · Joe Hershberger

Hi Allen,

Quoted 4 lines · Allen Martin

Add a new special environment variable "serial" that allows selection of serial device when CONFIG_SERIAL_MULTI is defined. This replaces the existing calls to serial_assign() from cmd_nvedit.c and iomux.c that were not doing anything.

...

Quoted 3 lines

Changes to this directly conflict with the environment callback series I sent out RFC (soon be be a real series). Can we hold off on this until that happens?

Quoted 9 lines
Quoted 6 lines

The problem here is that serial output on Tegra simply doesn't work (after some point in boot?) without this patch. It seems better to get everything working before adding new features doesn't it? Otherwise, if the environment callback stuff (or any other change right now) breaks something Tegra-specific, there would be no way to identify which change broke it.

Fair enough. However I don't think this patch is the right way to fix it.

Ok, would removing the existing calls to serial_assign() from iomux.c and cmd_nvedit.c be an ok first step? They don't appear to do anything useful right now and that would fix tegra and raspberry pi.

-Allen

Signature · 1 line
nvpublic
#7 lore raw

PATCH 1/1 serial: add environment control for SERIAL_MULTI

Hi Allen,

Quoted 24 lines · Allen Martin
Quoted 23 lines · Joe Hershberger

Hi Stephen,

Quoted 19 lines · Stephen Warren
Quoted 7 lines · Joe Hershberger

Hi Allen,

Quoted 4 lines · Allen Martin

Add a new special environment variable "serial" that allows selection of serial device when CONFIG_SERIAL_MULTI is defined. This replaces the existing calls to serial_assign() from cmd_nvedit.c and iomux.c that were not doing anything.

...

Quoted 3 lines

Changes to this directly conflict with the environment callback series I sent out RFC (soon be be a real series). Can we hold off on this until that happens?

The problem here is that serial output on Tegra simply doesn't work (after some point in boot?) without this patch. It seems better to get everything working before adding new features doesn't it? Otherwise, if the environment callback stuff (or any other change right now) breaks something Tegra-specific, there would be no way to identify which change broke it.

Quoted 6 lines
Quoted 2 lines

Fair enough. However I don't think this patch is the right way to fix it.

Ok, would removing the existing calls to serial_assign() from iomux.c and cmd_nvedit.c be an ok first step? They don't appear to do anything useful right now and that would fix tegra and raspberry pi.

I think that's fine to just remove those 2 calls. Seem like a good short-term solution.

-Joe

#8 lore raw

PATCH 1/1 serial: add environment control for SERIAL_MULTI

Quoted 30 lines · Joe Hershberger

Hi Allen,

Quoted 27 lines · Allen Martin
Quoted 25 lines · Joe Hershberger

Hi Stephen,

Quoted 13 lines · Stephen Warren
Quoted 7 lines · Joe Hershberger

Hi Allen,

Quoted 4 lines · Allen Martin

Add a new special environment variable "serial" that allows selection of serial device when CONFIG_SERIAL_MULTI is defined. This replaces the existing calls to serial_assign() from cmd_nvedit.c and iomux.c that were not doing anything.

...

Quoted 3 lines

Changes to this directly conflict with the environment callback series I sent out RFC (soon be be a real series). Can we hold off on this until that happens?

Quoted 6 lines

The problem here is that serial output on Tegra simply doesn't work (after some point in boot?) without this patch. It seems better to get everything working before adding new features doesn't it? Otherwise, if the environment callback stuff (or any other change right now) breaks something Tegra-specific, there would be no way to identify which change broke it.

Fair enough. However I don't think this patch is the right way to fix it.

Quoted 7 lines
Quoted 3 lines

Ok, would removing the existing calls to serial_assign() from iomux.c and cmd_nvedit.c be an ok first step? They don't appear to do anything useful right now and that would fix tegra and raspberry pi.

I think that's fine to just remove those 2 calls. Seem like a good short-term solution.

Ok, I'll send out a patch for that now, thanks.

-Allen

Signature · 1 line
nvpublic
#9 lore raw

PATCH 1/1 serial: add environment control for SERIAL_MULTI

In reply to Allen Martin
Quoted 4 lines · Allen Martin

Add a new special environment variable "serial" that allows selection of serial device when CONFIG_SERIAL_MULTI is defined. This replaces the existing calls to serial_assign() from cmd_nvedit.c and iomux.c that were not doing anything.

So I think this requires (for example) the following environment variables:

stdout=serial
serial=eserial0

Is it possible to allow the following instead:

stdout=eserial0

That way, one could presumably set:

stdout=eserial0,eserial3

and hence allow the use of multiple serial consoles?

#10 lore raw

PATCH 1/1 serial: add environment control for SERIAL_MULTI

Hi Stephen,

Quoted 6 lines · Stephen Warren
Quoted 4 lines · Allen Martin

Add a new special environment variable "serial" that allows selection of serial device when CONFIG_SERIAL_MULTI is defined. This replaces the existing calls to serial_assign() from cmd_nvedit.c and iomux.c that were not doing anything.

Quoted 8 lines

So I think this requires (for example) the following environment variables:

stdout=serial
serial=eserial0

Is it possible to allow the following instead:

stdout=eserial0

This is precisely what the patch I had pre-Marek serial did.

Quoted 3 lines

That way, one could presumably set:

stdout=eserial0,eserial3

Though it didn't allow this.

-Joe

#11 lore raw

PATCH 1/1 serial: add environment control for SERIAL_MULTI

Quoted 11 lines · Joe Hershberger

Hi Stephen,

Quoted 8 lines · Stephen Warren
Quoted 4 lines · Allen Martin

Add a new special environment variable "serial" that allows selection of serial device when CONFIG_SERIAL_MULTI is defined. This replaces the existing calls to serial_assign() from cmd_nvedit.c and iomux.c that were not doing anything.

So I think this requires (for example) the following environment variables:

Quoted 8 lines
Quoted 6 lines

stdout=serial
serial=eserial0

Is it possible to allow the following instead:

stdout=eserial0

This is precisely what the patch I had pre-Marek serial did.

In your patch would "stdout=serial" still work for case where there is only one serial port? I think it's important to try to preserve that to no be too disruptive.

Quoted 7 lines
Quoted 4 lines

That way, one could presumably set:

stdout=eserial0,eserial3

Though it didn't allow this.

Shouldn't that be (nearly) transparent through iomux?

-Allen

Signature · 1 line
nvpublic
#12 lore raw

PATCH 1/1 serial: add environment control for SERIAL_MULTI

Hi Allen,

Quoted 17 lines · Allen Martin
Quoted 16 lines · Joe Hershberger

Hi Stephen,

Quoted 13 lines · Stephen Warren
Quoted 4 lines · Allen Martin

Add a new special environment variable "serial" that allows selection of serial device when CONFIG_SERIAL_MULTI is defined. This replaces the existing calls to serial_assign() from cmd_nvedit.c and iomux.c that were not doing anything.

So I think this requires (for example) the following environment variables:

stdout=serial
serial=eserial0

Is it possible to allow the following instead:

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

stdout=eserial0

This is precisely what the patch I had pre-Marek serial did.

In your patch would "stdout=serial" still work for case where there is only one serial port? I think it's important to try to preserve that to no be too disruptive.

It used to support stdout=serial based on not being CONFIG_SERIAL_MULTI. Now that that's gone, I'm guessing it would simply be based on only having one registered serial device.

Quoted 9 lines
Quoted 7 lines
Quoted 4 lines

That way, one could presumably set:

stdout=eserial0,eserial3

Though it didn't allow this.

Shouldn't that be (nearly) transparent through iomux?

If that's what iomux does, then sure! I haven't used I/O mux on a device before.

-Joe

#13 lore raw

PATCH 1/1 serial: add environment control for SERIAL_MULTI

Dear Joe Hershberger,

Quoted 7 lines

Hi Allen,

Quoted 4 lines · Allen Martin
Quoted 3 lines · Joe Hershberger

Hi Stephen,

On Thu, Oct 25, 2012 at 5:43 PM, Stephen Warren <[email protected]>

Quoted 28 lines · wrote:
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines · Allen Martin
Quoted 4 lines

Add a new special environment variable "serial" that allows selection of serial device when CONFIG_SERIAL_MULTI is defined. This replaces the existing calls to serial_assign() from cmd_nvedit.c and iomux.c that were not doing anything.

So I think this requires (for example) the following environment variables:

stdout=serial
serial=eserial0

Is it possible to allow the following instead:

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

stdout=eserial0

This is precisely what the patch I had pre-Marek serial did.

In your patch would "stdout=serial" still work for case where there is only one serial port? I think it's important to try to preserve that to no be too disruptive.

It used to support stdout=serial based on not being CONFIG_SERIAL_MULTI. Now that that's gone, I'm guessing it would simply be based on only having one registered serial device.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

That way, one could presumably set:

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

stdout=eserial0,eserial3

Though it didn't allow this.

Shouldn't that be (nearly) transparent through iomux?

If that's what iomux does, then sure! I haven't used I/O mux on a device before.

This is what we should do, indeed.

Best regards,
Marek Vasut