All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] Can u-boot access Linux's mtd partition?
@ 2010-03-01 15:13 Joe Culler
  2010-03-01 19:52 ` Wolfgang Denk
  0 siblings, 1 reply; 6+ messages in thread
From: Joe Culler @ 2010-03-01 15:13 UTC (permalink / raw)
  To: u-boot

Hi,

If I've already created some configuration files such as mac address
in mtd2 partition.
For example:
0x00000000-0x00040000 : "Bootloader"
0x00040000-0x02000000 : "User config"

Does u-boot can access mtd2 partition and read the mac address from
the configure file?
If so, would anyone tell me how to do or what similar code can I refer
to in u-boot? Thanks.
If not, can u-boot read the mac address from the eeprom instead of set
it manually?

Thank you,

Best regards,
Joe.

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

* [U-Boot] Can u-boot access Linux's mtd partition?
  2010-03-01 15:13 Joe Culler
@ 2010-03-01 19:52 ` Wolfgang Denk
  0 siblings, 0 replies; 6+ messages in thread
From: Wolfgang Denk @ 2010-03-01 19:52 UTC (permalink / raw)
  To: u-boot

Dear Joe Culler,

In message <67a3f13e1003010713y432d5ee2y17a7962b15e89c9a@mail.gmail.com> you wrote:
> 
> If I've already created some configuration files such as mac address
> in mtd2 partition.
> For example:
> 0x00000000-0x00040000 : "Bootloader"
> 0x00040000-0x02000000 : "User config"
> 
> Does u-boot can access mtd2 partition and read the mac address from
> the configure file?

Yes, it can, but you're implementing this the wrong way round.
Normally the boot loader configured low level things like the MAC
address, and then passes this information on to Linux.

> If so, would anyone tell me how to do or what similar code can I refer
> to in u-boot? Thanks.

See for example the "mtdparts" command.

> If not, can u-boot read the mac address from the eeprom instead of set
> it manually?

You can implement anything- it's softwrae, and thus extremely
flexible. But don't expect to find any ready-to-use code for your own
proprietary data formats. You will have to adapt this yourself. 

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
A father doesn't destroy his children.
	-- Lt. Carolyn Palamas, "Who Mourns for Adonais?",
	   stardate 3468.1.

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

* [U-Boot] Can u-boot access Linux's mtd partition?
@ 2010-03-02 15:33 Joe Culler
  2010-03-02 15:57 ` Ian Jeffray
  2010-03-02 16:22 ` Wolfgang Denk
  0 siblings, 2 replies; 6+ messages in thread
From: Joe Culler @ 2010-03-02 15:33 UTC (permalink / raw)
  To: u-boot

Wolfgang Denk wrote:
Dear Joe Culler,
>
Dear Wolfgang,

In message <67a3f13e1003010713y432d5ee2y17a7962b15e89c9a@mail.gmail.com>
you wrote:
> >
> > If I've already created some configuration files such as mac address
> > in mtd2 partition.
> > For example:
> > 0x00000000-0x00040000 : "Bootloader"
> > 0x00040000-0x02000000 : "User config"
> >
> > Does u-boot can access mtd2 partition and read the mac address from
> > the configure file?
>
> Yes, it can, but you're implementing this the wrong way round.
> Normally the boot loader configured low level things like the MAC
> address, and then passes this information on to Linux.
>
Thanks for the reply. Let me explain why I do this way in details.
I work for the system integration company, the board I have is no
eeprom, that means I have to burn the mac address before shipping the
product. So the following steps are what I do before shipping:

1. First, I set default CONFIG_ETHADDR(for example, 02:80:ad:20:31:e8)
   in u-boot, then use flash writer to burn the flash on each board.
2. I have a program for burning mac address on Linux.
   After booting linux kernel, my program can burn the mac address.
   Reboot the system if burning the mac address successfully.
3. Since the mac address is already stored in mtd2, for example.
   I want u-boot to detect the correct mac address I burned in mtd2
   partition rather than the default setting 02:80:ad:20:31:e8.

Is it the correct way I do or do you have any better idea? Thank you.

> If so, would anyone tell me how to do or what similar code can I refer
> > to in u-boot? Thanks.
>
> See for example the "mtdparts" command.
>
In my example, would you like to tell me how to use mtdparts command to
access mtd2 partition and read the file where the mac address stored?
Thanks again! I'm still don't know how to use mtdparts after reading
the doc :(

> If not, can u-boot read the mac address from the eeprom instead of set
> > it manually?
>
> You can implement anything- it's softwrae, and thus extremely
> flexible. But don't expect to find any ready-to-use code for your own
> proprietary data formats. You will have to adapt this yourself.
>
> Best regards,
>
> Wolfgang Denk
>
Best regards,
Joe.

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

* [U-Boot] Can u-boot access Linux's mtd partition?
  2010-03-02 15:33 [U-Boot] Can u-boot access Linux's mtd partition? Joe Culler
@ 2010-03-02 15:57 ` Ian Jeffray
  2010-03-02 16:22 ` Wolfgang Denk
  1 sibling, 0 replies; 6+ messages in thread
From: Ian Jeffray @ 2010-03-02 15:57 UTC (permalink / raw)
  To: u-boot

On 02/03/2010 15:33, Joe Culler wrote:

> 1. First, I set default CONFIG_ETHADDR(for example, 02:80:ad:20:31:e8)
>     in u-boot, then use flash writer to burn the flash on each board.
> 2. I have a program for burning mac address on Linux.
>     After booting linux kernel, my program can burn the mac address.
>     Reboot the system if burning the mac address successfully.
> 3. Since the mac address is already stored in mtd2, for example.
>     I want u-boot to detect the correct mac address I burned in mtd2
>     partition rather than the default setting 02:80:ad:20:31:e8.
>
> Is it the correct way I do or do you have any better idea? Thank you.

I just use U-Boot tools "fw_setenv" to update the U-Boot ETHADDR
variable from within Linux.   If you do this, it may be advisable
to move the environment out of the code sector in case of failure
during writeback.

http://www.denx.de/wiki/DULG/HowCanIAccessUBootEnvironmentVariablesInLinux

http://elinux.org/U-boot_environment_variables_in_linux

Ian.

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

* [U-Boot] Can u-boot access Linux's mtd partition?
  2010-03-02 15:33 [U-Boot] Can u-boot access Linux's mtd partition? Joe Culler
  2010-03-02 15:57 ` Ian Jeffray
@ 2010-03-02 16:22 ` Wolfgang Denk
  2010-03-02 17:24   ` Joe Culler
  1 sibling, 1 reply; 6+ messages in thread
From: Wolfgang Denk @ 2010-03-02 16:22 UTC (permalink / raw)
  To: u-boot

Dear Joe Culler,

In message <67a3f13e1003020733p5459c999r1f7346fd9cd8a92d@mail.gmail.com> you wrote:
>
> Thanks for the reply. Let me explain why I do this way in details.
> I work for the system integration company, the board I have is no
> eeprom, that means I have to burn the mac address before shipping the
> product. So the following steps are what I do before shipping:
> 
> 1. First, I set default CONFIG_ETHADDR(for example, 02:80:ad:20:31:e8)
>    in u-boot, then use flash writer to burn the flash on each board.
> 2. I have a program for burning mac address on Linux.
>    After booting linux kernel, my program can burn the mac address.
>    Reboot the system if burning the mac address successfully.
> 3. Since the mac address is already stored in mtd2, for example.
>    I want u-boot to detect the correct mac address I burned in mtd2
>    partition rather than the default setting 02:80:ad:20:31:e8.
> 
> Is it the correct way I do or do you have any better idea? Thank you.

As usual, TIMTOWTDI.

The quickest approach to me seems to use the flash writer (as in
your step 1) to program first the U-Boot image (common for all
boards, without any MAC address setting), and then additionally
program a small information block that contains vital product data
like MAC address, serial number etc. [This block is usually
dynamically generated by a database query during prodution of the
board.] This second part will probably just require a few bytes which
probably will fit at a well-known address in the last (only partially
filled) block used for the U-Boot image. See for example the code in
board/tqc/tqm8xx/load_sernum_ethaddr.c


On theother hand, if you really want to jump through all the loops and
boot Linux to program the MAC address, you could as well use the
fw_setenv program (see tools/env/) to store the MAC address directly
in the U-Boot environment, where U-Boot will pick it up without any
special measures.

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
It became apparent that one reason why the Ice Giants were  known  as
the  Ice  Giants  was  because they were, well, giants. The other was
that they were made of ice.              -Terry Pratchett, _Sourcery_

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

* [U-Boot] Can u-boot access Linux's mtd partition?
  2010-03-02 16:22 ` Wolfgang Denk
@ 2010-03-02 17:24   ` Joe Culler
  0 siblings, 0 replies; 6+ messages in thread
From: Joe Culler @ 2010-03-02 17:24 UTC (permalink / raw)
  To: u-boot

On Wed, Mar 3, 2010 at 12:22 AM, Wolfgang Denk  wrote:
> Dear Joe Culler,
>
> In message <67a3f13e1003020733p5459c999r1f7346fd9cd8a92d@mail.gmail.com> you wrote:
>>
>> Thanks for the reply. Let me explain why I do this way in details.
>> I work for the system integration company, the board I have is no
>> eeprom, that means I have to burn the mac address before shipping the
>> product. So the following steps are what I do before shipping:
>>
>> 1. First, I set default CONFIG_ETHADDR(for example, 02:80:ad:20:31:e8)
>> ? ?in u-boot, then use flash writer to burn the flash on each board.
>> 2. I have a program for burning mac address on Linux.
>> ? ?After booting linux kernel, my program can burn the mac address.
>> ? ?Reboot the system if burning the mac address successfully.
>> 3. Since the mac address is already stored in mtd2, for example.
>> ? ?I want u-boot to detect the correct mac address I burned in mtd2
>> ? ?partition rather than the default setting 02:80:ad:20:31:e8.
>>
>> Is it the correct way I do or do you have any better idea? Thank you.
>
> As usual, TIMTOWTDI.
>
> The quickest approach to me seems to use the flash writer (as in
> your step 1) to program first the U-Boot image (common for all
> boards, without any MAC address setting), and then additionally
> program a small information block that contains vital product data
> like MAC address, serial number etc. [This block is usually
> dynamically generated by a database query during prodution of the
> board.] This second part will probably just require a few bytes which
> probably will fit at a well-known address in the last (only partially
> filled) block used for the U-Boot image. See for example the code in
> board/tqc/tqm8xx/load_sernum_ethaddr.c
>
>
> On theother hand, if you really want to jump through all the loops and
> boot Linux to program the MAC address, you could as well use the
> fw_setenv program (see tools/env/) to store the MAC address directly
> in the U-Boot environment, where U-Boot will pick it up without any
> special measures.

Dear Wolfgang,

Thank you very much for your quick reply and ideas.
I'll try to both ways you provided, thanks again!! ;-)

> 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
> It became apparent that one reason why the Ice Giants were ?known ?as
> the ?Ice ?Giants ?was ?because they were, well, giants. The other was
> that they were made of ice. ? ? ? ? ? ? ?-Terry Pratchett, _Sourcery_

Best regards,
Joe.

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

end of thread, other threads:[~2010-03-02 17:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-02 15:33 [U-Boot] Can u-boot access Linux's mtd partition? Joe Culler
2010-03-02 15:57 ` Ian Jeffray
2010-03-02 16:22 ` Wolfgang Denk
2010-03-02 17:24   ` Joe Culler
  -- strict thread matches above, loose matches on Subject: below --
2010-03-01 15:13 Joe Culler
2010-03-01 19:52 ` Wolfgang Denk

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.