public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] Reading from NAND
@ 2011-02-18 13:29 D Kesselring
  2011-02-18 13:40 ` Wolfgang Denk
  2011-02-18 18:54 ` Scott Wood
  0 siblings, 2 replies; 12+ messages in thread
From: D Kesselring @ 2011-02-18 13:29 UTC (permalink / raw)
  To: u-boot

Hello,
I am trying to add some code to U-Boot that will read a NAND location
to determine how to setup some environment variables. I am using a
LogicPD SOM board with an OMAP3503 (very similar to Zoom). I have
found the code that handles the user nand commands and am trying to
use ?nand_read_skip_bad?.  This needs a ?nand_info_t*? which I was
trying to get from the global ?nand_info[]? but it does not seem to be
initialized. My questions are (1) is the the best way to do this and
(2) if so, how do I get ?nand_info[]? initialized. I am adding my code
to main_loop() just after ?getenv (?bootcmd?)?.
Thanks for any pointers.

Regards,
David Kesselring


-- 
W. David Kesselring
919-349-1079

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

* [U-Boot] Reading from NAND
  2011-02-18 13:29 [U-Boot] Reading from NAND D Kesselring
@ 2011-02-18 13:40 ` Wolfgang Denk
       [not found]   ` <AANLkTik3hq8tUc5-Uh23G=F0Of2q8QNzJ2fO+JCr3wZy@mail.gmail.com>
  2011-02-18 18:54 ` Scott Wood
  1 sibling, 1 reply; 12+ messages in thread
From: Wolfgang Denk @ 2011-02-18 13:40 UTC (permalink / raw)
  To: u-boot

Dear D Kesselring,

In message <AANLkTikvgGvhgf-K04mn75EEYXEzwvOFHsy=uZ=1HO77@mail.gmail.com> you wrote:
> I am trying to add some code to U-Boot that will read a NAND location
> to determine how to setup some environment variables. I am using a

Why are you adding any code to do that in the fist place?

A few lines of shell scripting should be all that's needed?

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
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
Man is the best computer we can put aboard a spacecraft ...  and  the
only one that can be mass produced with unskilled labor.
                                                  - Wernher von Braun

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

* [U-Boot] Reading from NAND
  2011-02-18 13:29 [U-Boot] Reading from NAND D Kesselring
  2011-02-18 13:40 ` Wolfgang Denk
@ 2011-02-18 18:54 ` Scott Wood
  2011-02-18 19:48   ` D Kesselring
  1 sibling, 1 reply; 12+ messages in thread
From: Scott Wood @ 2011-02-18 18:54 UTC (permalink / raw)
  To: u-boot

On Fri, 18 Feb 2011 08:29:45 -0500
D Kesselring <kesselringd@gmail.com> wrote:

> Hello,
> I am trying to add some code to U-Boot that will read a NAND location
> to determine how to setup some environment variables. I am using a
> LogicPD SOM board with an OMAP3503 (very similar to Zoom). I have
> found the code that handles the user nand commands and am trying to
> use ?nand_read_skip_bad?.  This needs a ?nand_info_t*? which I was
> trying to get from the global ?nand_info[]? but it does not seem to be
> initialized. My questions are (1) is the the best way to do this and
> (2) if so, how do I get ?nand_info[]? initialized.

As Wolfgang pointed out, the best way is probably using scripting (and
certainly not by hacking up main_loop()), and thus you won't be calling
nand_raed_skip_bad() directly.  But that still requires NAND to have been
initialized.

You need a NAND controller driver.  This driver supplies board_nand_init(),
or in some cases may be called by board_nand_init() that platform code
supplies.

I'm not familiar with OMAP chips, but perhaps drivers/mtd/nand/omap_gpmc.c
is the driver you want?  In which case your board config file needs to
define CONFIG_NAND_OMAP_GPMC, as well as any driver-specific defines there
may be.

-Scott

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

* [U-Boot] Reading from NAND
  2011-02-18 18:54 ` Scott Wood
@ 2011-02-18 19:48   ` D Kesselring
  2011-02-18 19:55     ` Scott Wood
  2011-02-18 22:48     ` Wolfgang Denk
  0 siblings, 2 replies; 12+ messages in thread
From: D Kesselring @ 2011-02-18 19:48 UTC (permalink / raw)
  To: u-boot

I understand about scripting. I am trying to implement some somewhat
involved logic that walks a table of valid images. I am not convinced
that the u-boot scripting is sufficient for it. This table is an array
of structs. I need a loop that looks at a struct and determine if it
is valid and then do a couple of setenv.
Nand is working fine. I can execute the nand commands from the command
line without problems.
If you have any insights please let me know.
David

On Fri, Feb 18, 2011 at 1:54 PM, Scott Wood <scottwood@freescale.com> wrote:
> On Fri, 18 Feb 2011 08:29:45 -0500
> D Kesselring <kesselringd@gmail.com> wrote:
>
>> Hello,
>> I am trying to add some code to U-Boot that will read a NAND location
>> to determine how to setup some environment variables. I am using a
>> LogicPD SOM board with an OMAP3503 (very similar to Zoom). I have
>> found the code that handles the user nand commands and am trying to
>> use ?nand_read_skip_bad?. ?This needs a ?nand_info_t*? which I was
>> trying to get from the global ?nand_info[]? but it does not seem to be
>> initialized. My questions are (1) is the the best way to do this and
>> (2) if so, how do I get ?nand_info[]? initialized.
>
> As Wolfgang pointed out, the best way is probably using scripting (and
> certainly not by hacking up main_loop()), and thus you won't be calling
> nand_raed_skip_bad() directly. ?But that still requires NAND to have been
> initialized.
>
> You need a NAND controller driver. ?This driver supplies board_nand_init(),
> or in some cases may be called by board_nand_init() that platform code
> supplies.
>
> I'm not familiar with OMAP chips, but perhaps drivers/mtd/nand/omap_gpmc.c
> is the driver you want? ?In which case your board config file needs to
> define CONFIG_NAND_OMAP_GPMC, as well as any driver-specific defines there
> may be.
>
> -Scott
>
>



-- 
W. David Kesselring
919-349-1079

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

* [U-Boot] Reading from NAND
  2011-02-18 19:48   ` D Kesselring
@ 2011-02-18 19:55     ` Scott Wood
  2011-02-18 22:48     ` Wolfgang Denk
  1 sibling, 0 replies; 12+ messages in thread
From: Scott Wood @ 2011-02-18 19:55 UTC (permalink / raw)
  To: u-boot

On Fri, 18 Feb 2011 14:48:13 -0500
D Kesselring <kesselringd@gmail.com> wrote:

> I understand about scripting. I am trying to implement some somewhat
> involved logic that walks a table of valid images. I am not convinced
> that the u-boot scripting is sufficient for it. This table is an array
> of structs. I need a loop that looks at a struct and determine if it
> is valid and then do a couple of setenv.

If scripting is insufficient, then perhaps you could use platform code --
but it should go in your board directory, perhaps registering a command
that triggers the functionality.

> Nand is working fine. I can execute the nand commands from the command
> line without problems.

That means your nand_info[] array has been initialized.

-Scott

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

* [U-Boot] Reading from NAND
  2011-02-18 19:48   ` D Kesselring
  2011-02-18 19:55     ` Scott Wood
@ 2011-02-18 22:48     ` Wolfgang Denk
  2011-02-19 15:57       ` D Kesselring
  1 sibling, 1 reply; 12+ messages in thread
From: Wolfgang Denk @ 2011-02-18 22:48 UTC (permalink / raw)
  To: u-boot

Dear D Kesselring,

please stop top posting / full quoting.

In message <AANLkTikgXnuEOQ16zt6T_rDztrFWJKHiwgmXPa1=kEWk@mail.gmail.com> you wrote:
> I understand about scripting. I am trying to implement some somewhat
> involved logic that walks a table of valid images. I am not convinced
> that the u-boot scripting is sufficient for it. This table is an array
> of structs. I need a loop that looks at a struct and determine if it
> is valid and then do a couple of setenv.

U-Boot's implementation of the hush shell is a bit limited, that's
true, but you still can do a lot with it.

I am pretty sure that that would be more efficient and easier to
implement instead of adding code.


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
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
"Summit meetings tend to be like panda matings. The expectations  are
always high, and the results usually disappointing."   - Robert Orben

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

* [U-Boot] Reading from NAND
  2011-02-18 22:48     ` Wolfgang Denk
@ 2011-02-19 15:57       ` D Kesselring
  2011-02-19 19:41         ` Wolfgang Denk
  0 siblings, 1 reply; 12+ messages in thread
From: D Kesselring @ 2011-02-19 15:57 UTC (permalink / raw)
  To: u-boot

After some experimenting the only issue that I have now is trying to
do an itest on a non-aligned byte. I get an alignment exception if I
test a non-word aligned bype. Is there a way to do a bitwise AND so
that I can read a word and mask out the byte that I am interested in?
Also does the shell support adding values like "itest *(${base} +
${offset}) == 0x01"?

Thanks,
David

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

* [U-Boot] Reading from NAND
  2011-02-19 15:57       ` D Kesselring
@ 2011-02-19 19:41         ` Wolfgang Denk
  2011-02-21 19:43           ` D Kesselring
  0 siblings, 1 reply; 12+ messages in thread
From: Wolfgang Denk @ 2011-02-19 19:41 UTC (permalink / raw)
  To: u-boot

Dear D Kesselring,

In message <AANLkTik=nRPJpeYTiW2Xg3+qtZ9hZ-pei6LO=CbrwSCu@mail.gmail.com> you wrote:
> After some experimenting the only issue that I have now is trying to
> do an itest on a non-aligned byte. I get an alignment exception if I
> test a non-word aligned bype. Is there a way to do a bitwise AND so
> that I can read a word and mask out the byte that I am interested in?
> Also does the shell support adding values like "itest *(${base} +
> ${offset}) == 0x01"?

Why do you want to read a word when you are only interested in a
single byte? This sounds somewhat stupid.

Is there any reason for not using itest.b directly?

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
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
The universe does not have laws - it has habits, and  habits  can  be
broken.

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

* [U-Boot] Reading from NAND
       [not found]   ` <AANLkTik3hq8tUc5-Uh23G=F0Of2q8QNzJ2fO+JCr3wZy@mail.gmail.com>
@ 2011-02-19 19:59     ` Wolfgang Denk
       [not found]     ` <AANLkTimn1deSepOQOUTVbD=c5-njULYNc=tqAw9TKUBm@mail.gmail.com>
  1 sibling, 0 replies; 12+ messages in thread
From: Wolfgang Denk @ 2011-02-19 19:59 UTC (permalink / raw)
  To: u-boot

Dear D Kesselring,

please keep the mailing list on Cc:,  and don;t top post / full quote.
You may want to read http://www.netmeister.org/news/learn2quote.html

In message <AANLkTik3hq8tUc5-Uh23G=F0Of2q8QNzJ2fO+JCr3wZy@mail.gmail.com> you wrote:
> This is for an embedded system and I am trying to read a nand location
> to determine which Linux image to boot. How can U-Boot run scripts
> automatically?

Put some "run your_macro_name" in bootcmd and/or preboot.
Read the manual about how to use these environment variables.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
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
"Don't worry about people stealing your ideas. If your ideas are  any
good, you'll have to ram them down people's throats."  - Howard Aiken

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

* [U-Boot] Reading from NAND
       [not found]     ` <AANLkTimn1deSepOQOUTVbD=c5-njULYNc=tqAw9TKUBm@mail.gmail.com>
@ 2011-02-19 20:01       ` Wolfgang Denk
  0 siblings, 0 replies; 12+ messages in thread
From: Wolfgang Denk @ 2011-02-19 20:01 UTC (permalink / raw)
  To: u-boot

Dear D Kesselring,

please keep the mailing list on Cc:,  and don't top post / full quote.

In message <AANLkTimn1deSepOQOUTVbD=c5-njULYNc=tqAw9TKUBm@mail.gmail.com> you wrote:
> I think understand what you mean now. I can add a script to bootcmd
> before kicking off Linux. I did not know that the Uboot scripts would
> support if-else statements. Is there a simple way within a script to
> ask for user input for testing things?

You can for example use the "askenv" command.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
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
Cogito cogito ergo cogito sum - "I think that I  think,  therefore  I
think that I am."          - Ambrose Bierce, "The Devil's Dictionary"

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

* [U-Boot] Reading from NAND
  2011-02-19 19:41         ` Wolfgang Denk
@ 2011-02-21 19:43           ` D Kesselring
  2011-02-21 20:48             ` Wolfgang Denk
  0 siblings, 1 reply; 12+ messages in thread
From: D Kesselring @ 2011-02-21 19:43 UTC (permalink / raw)
  To: u-boot

> Is there any reason for not using itest.b directly?
If I do a test on a non-word aligned location the processor gets an exception.

Also does the shell support adding values like "itest *(${base} +
${offset}) == 0x01"?
Or any other integer addition or subtraction so that a loop can walk an array?

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

* [U-Boot] Reading from NAND
  2011-02-21 19:43           ` D Kesselring
@ 2011-02-21 20:48             ` Wolfgang Denk
  0 siblings, 0 replies; 12+ messages in thread
From: Wolfgang Denk @ 2011-02-21 20:48 UTC (permalink / raw)
  To: u-boot

Dear D Kesselring,

In message <AANLkTimMa27Q6rpH4hL32J7URQWR5Fj7V1tgeX2OWBxe@mail.gmail.com> you wrote:
> > Is there any reason for not using itest.b directly?
> If I do a test on a non-word aligned location the processor gets an exception.

You cannot do a byte access on a random address?? Than something is
seriously broken in your system.

> Also does the shell support adding values like "itest *(${base} +
> ${offset}) == 0x01"?

Why would that be needed?

> Or any other integer addition or subtraction so that a loop can walk an array?

You can use setexpr in a loop to increment or decrement an address or
perform any other kind of arithmetics.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
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
Marriage is the sole cause of divorce.

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

end of thread, other threads:[~2011-02-21 20:48 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-18 13:29 [U-Boot] Reading from NAND D Kesselring
2011-02-18 13:40 ` Wolfgang Denk
     [not found]   ` <AANLkTik3hq8tUc5-Uh23G=F0Of2q8QNzJ2fO+JCr3wZy@mail.gmail.com>
2011-02-19 19:59     ` Wolfgang Denk
     [not found]     ` <AANLkTimn1deSepOQOUTVbD=c5-njULYNc=tqAw9TKUBm@mail.gmail.com>
2011-02-19 20:01       ` Wolfgang Denk
2011-02-18 18:54 ` Scott Wood
2011-02-18 19:48   ` D Kesselring
2011-02-18 19:55     ` Scott Wood
2011-02-18 22:48     ` Wolfgang Denk
2011-02-19 15:57       ` D Kesselring
2011-02-19 19:41         ` Wolfgang Denk
2011-02-21 19:43           ` D Kesselring
2011-02-21 20:48             ` Wolfgang Denk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox