All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] cmd: nvedit: env_get_f must check for env_get_char error codes
@ 2018-01-31  6:56 Simon Goldschmidt
  2018-01-31  8:39 ` Maxime Ripard
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Simon Goldschmidt @ 2018-01-31  6:56 UTC (permalink / raw)
  To: u-boot

env_get_f calls env_get_char to load single characters from the
environment. However, the return value of env_get_char was not
checked for errors. Now if the env driver does not support the
.get_char call, env_get_f did not notice this and looped over the
whole size of the environment, calling env_get_char over 8000
times with the default settings, just to return an error in the
end.

Fix this by checking if env_get_char returns < 0.

Signed-off-by: Simon Goldschmidt <sgoldschmidt@de.pepperl-fuchs.com>
---

 cmd/nvedit.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index a690d743cd..4cb25b8248 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -650,12 +650,14 @@ char *env_get(const char *name)
  */
 int env_get_f(const char *name, char *buf, unsigned len)
 {
-	int i, nxt;
+	int i, nxt, c;
 
 	for (i = 0; env_get_char(i) != '\0'; i = nxt + 1) {
 		int val, n;
 
-		for (nxt = i; env_get_char(nxt) != '\0'; ++nxt) {
+		for (nxt = i; (c = env_get_char(nxt)) != '\0'; ++nxt) {
+			if (c < 0)
+				return c;
 			if (nxt >= CONFIG_ENV_SIZE)
 				return -1;
 		}
@@ -666,7 +668,10 @@ int env_get_f(const char *name, char *buf, unsigned len)
 
 		/* found; copy out */
 		for (n = 0; n < len; ++n, ++buf) {
-			*buf = env_get_char(val++);
+			c = env_get_char(val++);
+			if (c < 0)
+				return c;
+			*buf = c;
 			if (*buf == '\0')
 				return n;
 		}
-- 
2.11.0


Pepperl+Fuchs GmbH, Mannheim
Geschaeftsfuehrer/Managing Directors: Dr.-Ing. Gunther Kegel (Vors./CEO), Werner Guthier, Mehmet Hatiboglu
Vorsitzender des Aufsichtsrats/Chairman of the supervisory board: Claus Michael
Registergericht/Register Court: AG Mannheim HRB 4713

Wichtiger Hinweis:
Diese E-Mail einschliesslich ihrer Anhaenge enthaelt vertrauliche und rechtlich geschuetzte Informationen, die nur fuer den Adressaten bestimmt sind. 
Sollten Sie nicht der bezeichnete Adressat sein, so teilen Sie dies bitte dem Absender umgehend mit und loeschen Sie diese Nachricht und ihre Anhaenge. Die unbefugte Weitergabe, das Anfertigen von Kopien und jede Veraenderung der E-Mail ist untersagt. Der Absender haftet nicht fuer Inhalte von veraenderten E-Mails.


Important Information:
This e-mail message including its attachments contains confidential and legally protected information solely intended for the addressee. If you are not the intended addressee of this message, please contact the addresser immediately and delete this message including its attachments. The unauthorized dissemination, copying and change of this e-mail are strictly forbidden. The addresser shall not be liable for the content of such changed e-mails.

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH] cmd: nvedit: env_get_f must check for env_get_char error codes
  2018-01-31  6:56 [U-Boot] [PATCH] cmd: nvedit: env_get_f must check for env_get_char error codes Simon Goldschmidt
@ 2018-01-31  8:39 ` Maxime Ripard
  2018-01-31 23:00 ` York Sun
  2018-02-01 13:09 ` [U-Boot] " Tom Rini
  2 siblings, 0 replies; 11+ messages in thread
From: Maxime Ripard @ 2018-01-31  8:39 UTC (permalink / raw)
  To: u-boot

On Wed, Jan 31, 2018 at 07:56:48AM +0100, Simon Goldschmidt wrote:
> env_get_f calls env_get_char to load single characters from the
> environment. However, the return value of env_get_char was not
> checked for errors. Now if the env driver does not support the
> .get_char call, env_get_f did not notice this and looped over the
> whole size of the environment, calling env_get_char over 8000
> times with the default settings, just to return an error in the
> end.
> 
> Fix this by checking if env_get_char returns < 0.
> 
> Signed-off-by: Simon Goldschmidt <sgoldschmidt@de.pepperl-fuchs.com>

Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180131/6b8fc307/attachment.sig>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH] cmd: nvedit: env_get_f must check for env_get_char error codes
  2018-01-31  6:56 [U-Boot] [PATCH] cmd: nvedit: env_get_f must check for env_get_char error codes Simon Goldschmidt
  2018-01-31  8:39 ` Maxime Ripard
@ 2018-01-31 23:00 ` York Sun
  2018-02-01  9:16   ` Simon Goldschmidt
  2018-02-01 13:09 ` [U-Boot] " Tom Rini
  2 siblings, 1 reply; 11+ messages in thread
From: York Sun @ 2018-01-31 23:00 UTC (permalink / raw)
  To: u-boot

On 01/30/2018 10:57 PM, Simon Goldschmidt wrote:
> env_get_f calls env_get_char to load single characters from the
> environment. However, the return value of env_get_char was not
> checked for errors. Now if the env driver does not support the
> .get_char call, env_get_f did not notice this and looped over the
> whole size of the environment, calling env_get_char over 8000
> times with the default settings, just to return an error in the
> end.
> 
> Fix this by checking if env_get_char returns < 0.
> 
> Signed-off-by: Simon Goldschmidt <sgoldschmidt@de.pepperl-fuchs.com>
> ---
> 
>  cmd/nvedit.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/cmd/nvedit.c b/cmd/nvedit.c
> index a690d743cd..4cb25b8248 100644
> --- a/cmd/nvedit.c
> +++ b/cmd/nvedit.c
> @@ -650,12 +650,14 @@ char *env_get(const char *name)
>   */
>  int env_get_f(const char *name, char *buf, unsigned len)
>  {
> -	int i, nxt;
> +	int i, nxt, c;
>  
>  	for (i = 0; env_get_char(i) != '\0'; i = nxt + 1) {
>  		int val, n;
>  
> -		for (nxt = i; env_get_char(nxt) != '\0'; ++nxt) {
> +		for (nxt = i; (c = env_get_char(nxt)) != '\0'; ++nxt) {
> +			if (c < 0)
> +				return c;
>  			if (nxt >= CONFIG_ENV_SIZE)
>  				return -1;
>  		}
> @@ -666,7 +668,10 @@ int env_get_f(const char *name, char *buf, unsigned len)
>  
>  		/* found; copy out */
>  		for (n = 0; n < len; ++n, ++buf) {
> -			*buf = env_get_char(val++);
> +			c = env_get_char(val++);
> +			if (c < 0)
> +				return c;
> +			*buf = c;
>  			if (*buf == '\0')
>  				return n;
>  		}
> 

Simon,

This patch looks correct. But it doesn't fix NOR flash. Do you have plan
to add .get_char function to other drivers? Without that function, we
cannot get env variables before relocation.

York

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH] cmd: nvedit: env_get_f must check for env_get_char error codes
  2018-01-31 23:00 ` York Sun
@ 2018-02-01  9:16   ` Simon Goldschmidt
  2018-02-02 18:51     ` Maxime Ripard
  0 siblings, 1 reply; 11+ messages in thread
From: Simon Goldschmidt @ 2018-02-01  9:16 UTC (permalink / raw)
  To: u-boot

On 01.02.2018 00:00, York Sun wrote:
> On 01/30/2018 10:57 PM, Simon Goldschmidt wrote:
>> env_get_f calls env_get_char to load single characters from the
>> environment. However, the return value of env_get_char was not
>> checked for errors. Now if the env driver does not support the
>> .get_char call, env_get_f did not notice this and looped over the
>> whole size of the environment, calling env_get_char over 8000
>> times with the default settings, just to return an error in the
>> end.
>>
>> Fix this by checking if env_get_char returns < 0.
>>
>> Signed-off-by: Simon Goldschmidt <sgoldschmidt@de.pepperl-fuchs.com>
>> ---
>>
>>   cmd/nvedit.c | 11 ++++++++---
>>   1 file changed, 8 insertions(+), 3 deletions(-)
>>
>> diff --git a/cmd/nvedit.c b/cmd/nvedit.c
>> index a690d743cd..4cb25b8248 100644
>> --- a/cmd/nvedit.c
>> +++ b/cmd/nvedit.c
>> @@ -650,12 +650,14 @@ char *env_get(const char *name)
>>    */
>>   int env_get_f(const char *name, char *buf, unsigned len)
>>   {
>> -	int i, nxt;
>> +	int i, nxt, c;
>>   
>>   	for (i = 0; env_get_char(i) != '\0'; i = nxt + 1) {
>>   		int val, n;
>>   
>> -		for (nxt = i; env_get_char(nxt) != '\0'; ++nxt) {
>> +		for (nxt = i; (c = env_get_char(nxt)) != '\0'; ++nxt) {
>> +			if (c < 0)
>> +				return c;
>>   			if (nxt >= CONFIG_ENV_SIZE)
>>   				return -1;
>>   		}
>> @@ -666,7 +668,10 @@ int env_get_f(const char *name, char *buf, unsigned len)
>>   
>>   		/* found; copy out */
>>   		for (n = 0; n < len; ++n, ++buf) {
>> -			*buf = env_get_char(val++);
>> +			c = env_get_char(val++);
>> +			if (c < 0)
>> +				return c;
>> +			*buf = c;
>>   			if (*buf == '\0')
>>   				return n;
>>   		}
>>
> Simon,
>
> This patch looks correct. But it doesn't fix NOR flash. Do you have plan
> to add .get_char function to other drivers? Without that function, we
> cannot get env variables before relocation.

Ehrm, sorry  I don't plan to do that, no: my target seems to run fine 
without this.

Given that only the eeprom and nvram env drivers support the get_char 
method, I don't know if this is widely used at all. Maybe a better 
fallback would be to just remove that get_char code path totally and 
always load from the internal (default) environment until the full 
environment is available (after relocation).

After all, the environment variables loaded via get_char are not CRC 
checked at all. To me, this is another indication that this code is not 
really useful and should probably be removed.

Maxime and others, what do you think?

Simon

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] cmd: nvedit: env_get_f must check for env_get_char error codes
  2018-01-31  6:56 [U-Boot] [PATCH] cmd: nvedit: env_get_f must check for env_get_char error codes Simon Goldschmidt
  2018-01-31  8:39 ` Maxime Ripard
  2018-01-31 23:00 ` York Sun
@ 2018-02-01 13:09 ` Tom Rini
  2 siblings, 0 replies; 11+ messages in thread
From: Tom Rini @ 2018-02-01 13:09 UTC (permalink / raw)
  To: u-boot

On Wed, Jan 31, 2018 at 07:56:48AM +0100, Simon Goldschmidt wrote:

> env_get_f calls env_get_char to load single characters from the
> environment. However, the return value of env_get_char was not
> checked for errors. Now if the env driver does not support the
> .get_char call, env_get_f did not notice this and looped over the
> whole size of the environment, calling env_get_char over 8000
> times with the default settings, just to return an error in the
> end.
> 
> Fix this by checking if env_get_char returns < 0.
> 
> Signed-off-by: Simon Goldschmidt <sgoldschmidt@de.pepperl-fuchs.com>
> Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180201/5c07424e/attachment.sig>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH] cmd: nvedit: env_get_f must check for env_get_char error codes
  2018-02-01  9:16   ` Simon Goldschmidt
@ 2018-02-02 18:51     ` Maxime Ripard
  2018-02-02 20:04       ` York Sun
  0 siblings, 1 reply; 11+ messages in thread
From: Maxime Ripard @ 2018-02-02 18:51 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On Thu, Feb 01, 2018 at 10:16:46AM +0100, Simon Goldschmidt wrote:
> On 01.02.2018 00:00, York Sun wrote:
> > On 01/30/2018 10:57 PM, Simon Goldschmidt wrote:
> > > env_get_f calls env_get_char to load single characters from the
> > > environment. However, the return value of env_get_char was not
> > > checked for errors. Now if the env driver does not support the
> > > .get_char call, env_get_f did not notice this and looped over the
> > > whole size of the environment, calling env_get_char over 8000
> > > times with the default settings, just to return an error in the
> > > end.
> > > 
> > > Fix this by checking if env_get_char returns < 0.
> > > 
> > > Signed-off-by: Simon Goldschmidt <sgoldschmidt@de.pepperl-fuchs.com>
> > > ---
> > > 
> > >   cmd/nvedit.c | 11 ++++++++---
> > >   1 file changed, 8 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/cmd/nvedit.c b/cmd/nvedit.c
> > > index a690d743cd..4cb25b8248 100644
> > > --- a/cmd/nvedit.c
> > > +++ b/cmd/nvedit.c
> > > @@ -650,12 +650,14 @@ char *env_get(const char *name)
> > >    */
> > >   int env_get_f(const char *name, char *buf, unsigned len)
> > >   {
> > > -	int i, nxt;
> > > +	int i, nxt, c;
> > >   	for (i = 0; env_get_char(i) != '\0'; i = nxt + 1) {
> > >   		int val, n;
> > > -		for (nxt = i; env_get_char(nxt) != '\0'; ++nxt) {
> > > +		for (nxt = i; (c = env_get_char(nxt)) != '\0'; ++nxt) {
> > > +			if (c < 0)
> > > +				return c;
> > >   			if (nxt >= CONFIG_ENV_SIZE)
> > >   				return -1;
> > >   		}
> > > @@ -666,7 +668,10 @@ int env_get_f(const char *name, char *buf, unsigned len)
> > >   		/* found; copy out */
> > >   		for (n = 0; n < len; ++n, ++buf) {
> > > -			*buf = env_get_char(val++);
> > > +			c = env_get_char(val++);
> > > +			if (c < 0)
> > > +				return c;
> > > +			*buf = c;
> > >   			if (*buf == '\0')
> > >   				return n;
> > >   		}
> > > 
> > Simon,
> > 
> > This patch looks correct. But it doesn't fix NOR flash. Do you have plan
> > to add .get_char function to other drivers? Without that function, we
> > cannot get env variables before relocation.
> 
> Ehrm, sorry  I don't plan to do that, no: my target seems to run fine
> without this.
> 
> Given that only the eeprom and nvram env drivers support the get_char
> method, I don't know if this is widely used at all. Maybe a better fallback
> would be to just remove that get_char code path totally and always load from
> the internal (default) environment until the full environment is available
> (after relocation).
> 
> After all, the environment variables loaded via get_char are not CRC checked
> at all. To me, this is another indication that this code is not really
> useful and should probably be removed.

To be honest, I'm not really sure what get_char was here for in the
first place, so getting rid of it sounds like a good idea :)

Maxime

-- 
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
http://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180202/a5f79941/attachment.sig>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH] cmd: nvedit: env_get_f must check for env_get_char error codes
  2018-02-02 18:51     ` Maxime Ripard
@ 2018-02-02 20:04       ` York Sun
  2018-02-05 13:43         ` Maxime Ripard
  0 siblings, 1 reply; 11+ messages in thread
From: York Sun @ 2018-02-02 20:04 UTC (permalink / raw)
  To: u-boot

On 02/02/2018 10:51 AM, Maxime Ripard wrote:

<snip>

>>>>
>>> Simon,
>>>
>>> This patch looks correct. But it doesn't fix NOR flash. Do you have plan
>>> to add .get_char function to other drivers? Without that function, we
>>> cannot get env variables before relocation.
>>
>> Ehrm, sorry  I don't plan to do that, no: my target seems to run fine
>> without this.
>>
>> Given that only the eeprom and nvram env drivers support the get_char
>> method, I don't know if this is widely used at all. Maybe a better fallback
>> would be to just remove that get_char code path totally and always load from
>> the internal (default) environment until the full environment is available
>> (after relocation).
>>
>> After all, the environment variables loaded via get_char are not CRC checked
>> at all. To me, this is another indication that this code is not really
>> useful and should probably be removed.
> 
> To be honest, I'm not really sure what get_char was here for in the
> first place, so getting rid of it sounds like a good idea :)
> 

On almost all my boards, a variable hwconfig is read before relocation
to determine DDR configuration. This has been broken. I don't mind you
remove some dead code. But this is breaking almost all my boards booting
from NOR flash.

York

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH] cmd: nvedit: env_get_f must check for env_get_char error codes
  2018-02-02 20:04       ` York Sun
@ 2018-02-05 13:43         ` Maxime Ripard
  2018-02-05 16:30           ` York Sun
  0 siblings, 1 reply; 11+ messages in thread
From: Maxime Ripard @ 2018-02-05 13:43 UTC (permalink / raw)
  To: u-boot

Hi York,

On Fri, Feb 02, 2018 at 08:04:12PM +0000, York Sun wrote:
> On 02/02/2018 10:51 AM, Maxime Ripard wrote:
> >>> This patch looks correct. But it doesn't fix NOR flash. Do you have plan
> >>> to add .get_char function to other drivers? Without that function, we
> >>> cannot get env variables before relocation.
> >>
> >> Ehrm, sorry  I don't plan to do that, no: my target seems to run fine
> >> without this.
> >>
> >> Given that only the eeprom and nvram env drivers support the get_char
> >> method, I don't know if this is widely used at all. Maybe a better fallback
> >> would be to just remove that get_char code path totally and always load from
> >> the internal (default) environment until the full environment is available
> >> (after relocation).
> >>
> >> After all, the environment variables loaded via get_char are not CRC checked
> >> at all. To me, this is another indication that this code is not really
> >> useful and should probably be removed.
> > 
> > To be honest, I'm not really sure what get_char was here for in the
> > first place, so getting rid of it sounds like a good idea :)
> 
> On almost all my boards, a variable hwconfig is read before relocation
> to determine DDR configuration. This has been broken. I don't mind you
> remove some dead code. But this is breaking almost all my boards booting
> from NOR flash.

Sorry if it fell through the cracks, I don't have a board with NOR
myself. Do you know what breaks exactly?

Or can you bisect at least?

Thanks!
Maxime

-- 
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
http://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180205/411347de/attachment.sig>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH] cmd: nvedit: env_get_f must check for env_get_char error codes
  2018-02-05 13:43         ` Maxime Ripard
@ 2018-02-05 16:30           ` York Sun
  2018-02-07  8:31             ` Maxime Ripard
  0 siblings, 1 reply; 11+ messages in thread
From: York Sun @ 2018-02-05 16:30 UTC (permalink / raw)
  To: u-boot

On 02/05/2018 05:44 AM, Maxime Ripard wrote:
> Hi York,
> 
> On Fri, Feb 02, 2018 at 08:04:12PM +0000, York Sun wrote:
>> On 02/02/2018 10:51 AM, Maxime Ripard wrote:
>>>>> This patch looks correct. But it doesn't fix NOR flash. Do you have plan
>>>>> to add .get_char function to other drivers? Without that function, we
>>>>> cannot get env variables before relocation.
>>>>
>>>> Ehrm, sorry  I don't plan to do that, no: my target seems to run fine
>>>> without this.
>>>>
>>>> Given that only the eeprom and nvram env drivers support the get_char
>>>> method, I don't know if this is widely used at all. Maybe a better fallback
>>>> would be to just remove that get_char code path totally and always load from
>>>> the internal (default) environment until the full environment is available
>>>> (after relocation).
>>>>
>>>> After all, the environment variables loaded via get_char are not CRC checked
>>>> at all. To me, this is another indication that this code is not really
>>>> useful and should probably be removed.
>>>
>>> To be honest, I'm not really sure what get_char was here for in the
>>> first place, so getting rid of it sounds like a good idea :)
>>
>> On almost all my boards, a variable hwconfig is read before relocation
>> to determine DDR configuration. This has been broken. I don't mind you
>> remove some dead code. But this is breaking almost all my boards booting
>> from NOR flash.
> 
> Sorry if it fell through the cracks, I don't have a board with NOR
> myself. Do you know what breaks exactly?
> 
> Or can you bisect at least?
> 

Yes, I did. It was the #3 patch in the series of "env: Multiple env
support and env transition for sunxi". I reported in the email thread
"Re: [U-Boot] [PATCH v3 09/15] env: Support multiple environments",
along with another problem found regarding variable "env_load_location".
The latter problem breaks saveenv on NOR flash.

York

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH] cmd: nvedit: env_get_f must check for env_get_char error codes
  2018-02-05 16:30           ` York Sun
@ 2018-02-07  8:31             ` Maxime Ripard
  0 siblings, 0 replies; 11+ messages in thread
From: Maxime Ripard @ 2018-02-07  8:31 UTC (permalink / raw)
  To: u-boot

On Mon, Feb 05, 2018 at 04:30:50PM +0000, York Sun wrote:
> On 02/05/2018 05:44 AM, Maxime Ripard wrote:
> > Hi York,
> > 
> > On Fri, Feb 02, 2018 at 08:04:12PM +0000, York Sun wrote:
> >> On 02/02/2018 10:51 AM, Maxime Ripard wrote:
> >>>>> This patch looks correct. But it doesn't fix NOR flash. Do you have plan
> >>>>> to add .get_char function to other drivers? Without that function, we
> >>>>> cannot get env variables before relocation.
> >>>>
> >>>> Ehrm, sorry  I don't plan to do that, no: my target seems to run fine
> >>>> without this.
> >>>>
> >>>> Given that only the eeprom and nvram env drivers support the get_char
> >>>> method, I don't know if this is widely used at all. Maybe a better fallback
> >>>> would be to just remove that get_char code path totally and always load from
> >>>> the internal (default) environment until the full environment is available
> >>>> (after relocation).
> >>>>
> >>>> After all, the environment variables loaded via get_char are not CRC checked
> >>>> at all. To me, this is another indication that this code is not really
> >>>> useful and should probably be removed.
> >>>
> >>> To be honest, I'm not really sure what get_char was here for in the
> >>> first place, so getting rid of it sounds like a good idea :)
> >>
> >> On almost all my boards, a variable hwconfig is read before relocation
> >> to determine DDR configuration. This has been broken. I don't mind you
> >> remove some dead code. But this is breaking almost all my boards booting
> >> from NOR flash.
> > 
> > Sorry if it fell through the cracks, I don't have a board with NOR
> > myself. Do you know what breaks exactly?
> > 
> > Or can you bisect at least?

> Yes, I did. It was the #3 patch in the series of "env: Multiple env
> support and env transition for sunxi". I reported in the email thread
> "Re: [U-Boot] [PATCH v3 09/15] env: Support multiple environments",
> along with another problem found regarding variable "env_load_location".
> The latter problem breaks saveenv on NOR flash.

Ah, right, I overlooked it, sorry.

I'll reply there.

Thanks!
Maxime

-- 
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
http://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180207/08f1b11d/attachment.sig>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH] cmd: nvedit: env_get_f must check for env_get_char error codes
@ 2018-02-03 10:27 Goldschmidt Simon
  0 siblings, 0 replies; 11+ messages in thread
From: Goldschmidt Simon @ 2018-02-03 10:27 UTC (permalink / raw)
  To: u-boot

On 02/02/2018 21:04, York Sun wrote:
> On 02/02/2018 10:51 AM, Maxime Ripard wrote:
> 
> <snip>
> 
>>>>>
>>>> Simon,
>>>>
>>>> This patch looks correct. But it doesn't fix NOR flash. Do you have plan
>>>> to add .get_char function to other drivers? Without that function, we
>>>> cannot get env variables before relocation.
>>>
>>> Ehrm, sorry  I don't plan to do that, no: my target seems to run fine
>>> without this.
>>>
>>> Given that only the eeprom and nvram env drivers support the get_char
>>> method, I don't know if this is widely used at all. Maybe a better fallback
>>> would be to just remove that get_char code path totally and always load from
>>> the internal (default) environment until the full environment is available
>>> (after relocation).
>>>
>>> After all, the environment variables loaded via get_char are not CRC checked
>>> at all. To me, this is another indication that this code is not really
>>> useful and should probably be removed.
>>
>> To be honest, I'm not really sure what get_char was here for in the
>> first place, so getting rid of it sounds like a good idea :)
>>
> 
> On almost all my boards, a variable hwconfig is read before relocation
> to determine DDR configuration. This has been broken. I don't mind you
> remove some dead code. But this is breaking almost all my boards booting
> from NOR flash.

When talking about removing a feature I meant the code that
exists for 2 env drivers only where single characters are loaded
from an external environment without checking its crc first.

The thing you seem to need is reading from the default environment
before relocation. This should not be removed, of course!

I might prepare a patch to better show what I mean...

Simon

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2018-02-07  8:31 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-31  6:56 [U-Boot] [PATCH] cmd: nvedit: env_get_f must check for env_get_char error codes Simon Goldschmidt
2018-01-31  8:39 ` Maxime Ripard
2018-01-31 23:00 ` York Sun
2018-02-01  9:16   ` Simon Goldschmidt
2018-02-02 18:51     ` Maxime Ripard
2018-02-02 20:04       ` York Sun
2018-02-05 13:43         ` Maxime Ripard
2018-02-05 16:30           ` York Sun
2018-02-07  8:31             ` Maxime Ripard
2018-02-01 13:09 ` [U-Boot] " Tom Rini
2018-02-03 10:27 [U-Boot] [PATCH] " Goldschmidt Simon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.