Skip to contentSkip to conversation

Protect Flash from tftpboot typos

U-Boot-Users Konstantin Kletschke 4 participants 10 messages Jul 23, 2004 – Jul 26, 2004 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

Hi there!

I wonder if there is a solution possible to Protect the FLASH Chip from typos.

I have physikal Ram at 0x8000000 to 0x8FFFFFF and FLASH from 0x10000000 to 0x10FFFFFF.
u-boot gets startet by the i.MX mechanism which maps the 1st MB of Flash to 0x0. The i.MX executes 1st command at 0x0 to 0xFFFFF

tftpboot should only put downloaded images to RAM.
I had a customer recently who put 130.1.2.3 as the 1st argument to tftpboot and tftpboot tries to put the image to 0x130.
I also do typos there and an 0x0 as 1st Argument destroys contents of Flash though it is protected!
I think an linux kernel Image for example contains code sequences who unlock, erase and write flash succesfully.

I want to implement a mechanism which implements out of an config option a area where tftpboot acts (0x800000 to 0x8FFFFFF) and gives an error message otherway.

Is that possible and where is the entry point in the code to put the funtkionality to?

Regards, Konstantin Kletschke

Signature · 2 lines
GPG KeyID EF62FCEF
Fingerprint: 13C9 B16B 9844 EC15 CC2E  A080 1E69 3FDA EF62 FCEF
#1 lore raw
Quoted 3 lines · In message <20040723102408.GB11790@synertronixx3> you wrote:

I wonder if there is a solution possible to Protect the FLASH Chip from typos.

No. I will not accept any submissions of an AI machine for U-Boot.

Quoted 2 lines

I have physikal Ram at 0x8000000 to 0x8FFFFFF and FLASH from 0x10000000 to 0x10FFFFFF.

...

Quoted 1 line

tftpboot should only put downloaded images to RAM.

Indeed this is what it does. At least in the default configuration, i. e. if you don't enable options like CFG_DIRECT_FLASH_TFTP which are unsafe and officially deprecated.

Quoted 2 lines

I had a customer recently who put 130.1.2.3 as the 1st argument to tftpboot and tftpboot tries to put the image to 0x130.

U-Boot follows Unix design here:

"UNIX was not designed to stop you from doing stupid things, because
that would also stop you from doing clever things." - Doug Gwyn

Quoted 2 lines

I also do typos there and an 0x0 as 1st Argument destroys contents of Flash though it is protected!

Seems you have configured U-Boot like that. On systems for which I am responsible attempts to TFTP to flash will not do harm.

Quoted 2 lines

I think an linux kernel Image for example contains code sequences who unlock, erase and write flash succesfully.

This may be, but a TFTP download will write to increasing addresses, while the programming sequence must be written to certain addresses which are (1) not contiguous and (2) which must be written in a special sequence. I don't think that TFTP (or a copy) to a memory region can accidentally trigger a flash programming sequence, unless the code explicitely attemts to program the flash (like TFTP with CFG_DIRECT_FLASH_TFTP option aenabled, or the "cp" command with a target address in flash memory).

Quoted 3 lines

I want to implement a mechanism which implements out of an config option a area where tftpboot acts (0x800000 to 0x8FFFFFF) and gives an error message otherway.

Such a feature is definitely not necessary. Don't waste your time. Instead, go and check what's going wrong on your system.

Best regards,

Wolfgang Denk

Signature · 5 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd at denx.de
FORTRAN? The syntactically incorrect statement "DO 10 I = 1.10"  will
parse  and  generate  code  creating  a  variable, DO10I, as follows:
"DO10I = 1.10" If that doesn't terrify you, it should.
#2 lore raw

Am 2004-07-23 15:46 +0200 schrieb Wolfgang Denk:

Quoted 1 line

i. e. if you don't enable options like CFG_DIRECT_FLASH_TFTP which

I do not find CFG_DIRECT_FLASH_TFTP mentioned anywhere in our include/configs/scb9328.h.

Is it included by

#define CONFIG_COMMANDS         (CONFIG_CMD_DFL     \
                & ~CFG_CMD_LOADS    \
                & ~CFG_CMD_CONSOLE  \
                & ~CFG_CMD_AUTOSCRIPT   \
                | CFG_CMD_NET           \
                | CFG_CMD_PING          \
                | CFG_CMD_DHCP          \
                )

?

Otherwise I don't know where else I could have this option enabled.

Quoted 2 lines

"UNIX was not designed to stop you from doing stupid things, because
that would also stop you from doing clever things." - Doug Gwyn

Yeah, thats right. I have to protect our customers to fry their boards, not me :)

Quoted 5 lines
Quoted 2 lines

I also do typos there and an 0x0 as 1st Argument destroys contents of Flash though it is protected!

Seems you have configured U-Boot like that. On systems for which I am responsible attempts to TFTP to flash will not do harm.

tftp to flash does no harm. It is the mapped Area which is not protected by an default load adress when typos occur.

Quoted 8 lines

This may be, but a TFTP download will write to increasing addresses, while the programming sequence must be written to certain addresses which are (1) not contiguous and (2) which must be written in a special sequence. I don't think that TFTP (or a copy) to a memory region can accidentally trigger a flash programming sequence, unless the code explicitely attemts to program the flash (like TFTP with CFG_DIRECT_FLASH_TFTP option aenabled, or the "cp" command with a target address in flash memory).

Reading this I agree to you unlocking, erasing is not possible on increasing adresses. Otherwise IIRC I think the whole block can be unlocked and erased on different access adresses inside the block!

Otherwise how is it possible typos fry the flash device?

I am using intel 28F128J3...

I think I will replace tftpboot an cp commands for customers by two argument less firmware - linux kernel or rootfs - commands.

Konsti

Signature · 2 lines
GPG KeyID EF62FCEF
Fingerprint: 13C9 B16B 9844 EC15 CC2E  A080 1E69 3FDA EF62 FCEF
#3 lore raw
Quoted 3 lines · Konstantin Kletschke
Quoted 1 line

I think I will replace tftpboot an cp commands for customers by two argument less firmware - linux kernel or rootfs - commands.

Send the customer an autoscript file. That way they don't have to type any commands.

Kyle.

#4 lore raw
In reply to Konstantin Kletschke
Quoted 3 lines · In message <20040723143731.GA10725@synertronixx3> you wrote:

I do not find CFG_DIRECT_FLASH_TFTP mentioned anywhere in our include/configs/scb9328.h.

-> ls -l include/configs/scb9328.h
ls: include/configs/scb9328.h: No such file or directory

I cannot comment on code I've never seen.

Quoted 1 line

Is it included by

...

Quoted 1 line

Otherwise I don't know where else I could have this option enabled.

No, it is not.

Quoted 2 lines

Yeah, thats right. I have to protect our customers to fry their boards, not me :)

Just set up a service to recover these boards, and get rich ;-)

Quoted 5 lines
Quoted 2 lines

Seems you have configured U-Boot like that. On systems for which I am responsible attempts to TFTP to flash will not do harm.

tftp to flash does no harm. It is the mapped Area which is not protected by an default load adress when typos occur.

What is a "mapped area"?

Quoted 7 lines

Reading this I agree to you unlocking, erasing is not possible on increasing adresses. Otherwise IIRC I think the whole block can be unlocked and erased on different access adresses inside the block!

Otherwise how is it possible typos fry the flash device?

I am using intel 28F128J3...

Your flash driver does not drive the VPEN pin, it seems?

Quoted 2 lines

I think I will replace tftpboot an cp commands for customers by two argument less firmware - linux kernel or rootfs - commands.

I don't think this is a good idea. The software should behave as documented, and U-Boot documentation does not contain such arbitrary limits (nor do I like them).

Best regards,

Wolfgang Denk

Signature · 5 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd at denx.de
Teenagers are people who express a burning desire to be different by
dressing exactly alike.
There are some strings. They're just not attached.
#5 lore raw

Am 2004-07-23 17:13 +0200 schrieb Wolfgang Denk:

Quoted 4 lines

-> ls -l include/configs/scb9328.h
ls: include/configs/scb9328.h: No such file or directory

I cannot comment on code I've never seen.

Yes, is not commited yet. Only wan't to know if the mentioned config snippets did not include the falsh tftp routines, thats all...

Quoted 1 line

Just set up a service to recover these boards, and get rich ;-)

That is possible when this company has become big and richt like other global players :)

Quoted 1 line

What is a "mapped area"?

the i.MX mirrors the first MegaByte of flash to 0x00000000 -> 0x000fffff

Quoted 1 line

Your flash driver does not drive the VPEN pin, it seems?

No, it does not :(

Konsti

Signature · 2 lines
GPG KeyID EF62FCEF
Fingerprint: 13C9 B16B 9844 EC15 CC2E  A080 1E69 3FDA EF62 FCEF
#6 lore raw
Quoted 4 lines · In message <20040726120408.GA23386@synertronixx3> you wrote:
Quoted 2 lines

Your flash driver does not drive the VPEN pin, it seems?

No, it does not :(

Well, it seems a solution for your problems has been found.

Best regards,

Wolfgang Denk

Signature · 4 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd at denx.de
Q: How do you spell "onomatopoeia"?
A: The way it sounds.
#7 lore raw

Am 2004-07-26 15:34 +0200 schrieb Wolfgang Denk:

Quoted 2 lines

Well, it seems a solution for your problems has been found.

I don't understand. If Flash driver drives VPEN Pin there also must be defined, where it should be driven and where not. So I could allow tftpboot in some areas and in some not also.

Regards,
Konsti

Signature · 2 lines
GPG KeyID EF62FCEF
Fingerprint: 13C9 B16B 9844 EC15 CC2E  A080 1E69 3FDA EF62 FCEF
#8 lore raw
Quoted 6 lines · In message <20040726150944.GA8491@synertronixx3> you wrote:
Quoted 2 lines

Well, it seems a solution for your problems has been found.

I don't understand. If Flash driver drives VPEN Pin there also must be defined, where it should be driven and where not. So I could allow tftpboot in some areas and in some not also.

Enable earing/programming only in the flash erase/program routines. Than any other code that really triggers a erase/program sequence will not do any harm.

This has nothing to do with tftp - it does not write to flash.

Best regards,

Wolfgang Denk

Signature · 3 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd at denx.de
Old programmers never die, they just branch to a new address.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#10 lore raw

Am 2004-07-23 11:10 -0400 schrieb Kyle Harris:

Quoted 3 lines

Send the customer an autoscript file. That way they don't have to type any commands.

My be thats a good solution. Where is some comprehensive Doc how to use these autoscript stuff? The section in the documentation wiki is missing :) My be an short excerpt how to create such an autoscript image for example. If I understood right and it really _is_ an image in the end.

Can such an autoscript image work with cp an tftpboot commands disabled?

Regards, Konsti

Signature · 2 lines
GPG KeyID EF62FCEF
Fingerprint: 13C9 B16B 9844 EC15 CC2E  A080 1E69 3FDA EF62 FCEF