Skip to contentSkip to conversation

Advice needed.

DISCUSSION W.P. 4 participants 16 messages Jan 31, 2007 – Feb 8, 2007 3 messages not in the archive MIPS

lore
Share & tools
lore

W.P.

author
#0 lore raw

Hello,
currently i am "fighting" with Edimax BR-6024Wg, (Realtek-8186 based, lexra-mips). I need an advice from a system developer/programmer:

1). When using original firmware (EDIMAX-developed Linux-mips), task of upgrading firmware is done by web server binary: webs, which is GoAhead 2.1.1, BUT Edimax didn't published "applets" -> C functions, that implement real functionality.

2). In /dev directory there is a block node with mtd name. I have cat'ed it's contents to /web, and downloaded to PC. File seems to be raw contents of Flash memory: 2048*1024bytes long. If I drop first 64kB and truncate file to same length that Edimax-supplied firmware, files show to be the same (using cmp). The first 64kB looks to contain among others, variables used in BR system. There is originally an utility "flash" to get/set variables.

Now the question:
When I will have a new firmware (image) will it be safe(!?) to do such
thing: (instead of using webs binary):
cat /dev/mtd > some.file
dd first 64k of some.file to other.file,
then download image (from PC) to a third.file
cat other.file third.file > /dev/mtd back.??????

W.Piotrzkowski

#1 lore raw
Quoted 17 lines · W.P.

Hello,
currently i am "fighting" with Edimax BR-6024Wg, (Realtek-8186 based, lexra-mips). I need an advice from a system developer/programmer:

1). When using original firmware (EDIMAX-developed Linux-mips), task of upgrading firmware is done by web server binary: webs, which is GoAhead 2.1.1, BUT Edimax didn't published "applets" -> C functions, that implement real functionality.

2). In /dev directory there is a block node with mtd name. I have cat'ed it's contents to /web, and downloaded to PC. File seems to be raw contents of Flash memory: 2048*1024bytes long. If I drop first 64kB and truncate file to same length that Edimax-supplied firmware, files show to be the same (using cmp). The first 64kB looks to contain among others, variables used in BR system. There is originally an utility "flash" to get/set variables.

Quoted 7 lines

Now the question:
When I will have a new firmware (image) will it be safe(!?) to do such
thing: (instead of using webs binary):
cat /dev/mtd > some.file
dd first 64k of some.file to other.file,
then download image (from PC) to a third.file
cat other.file third.file > /dev/mtd back.??????

Using cat or dd to write to /dev/mtd? probably will not work. If there is a /dev/mtdblock? perhaps. Otherwise use the mtd utilities (flashcp or nandwrite depending on the type of flash memory) to write to /dev/mtd?.

Take a look at this site for more information:

http://www.linux-mtd.infradead.org/

David Daney

author
#2 lore raw

<cut>

Quoted 1 line

If there is a /dev/mtdblock? perhaps.

There is only one node related to mtd:

brw-rw-rw- 1 0 0 31, 0 Aug 29 2006 mtd

Kernel modules supposed by me to be related: mtdlink.o or mtdlink_gw.o (different size), probably supplied by Realtek or Edimax -> there are some closed source modules/tools in this toolchain. Kernel is 2.4.18, gcc 3.3.3, uClibc.

/proc/mtd shows:

mtd0: 00200000 00010000 "DiskOnChip Millennium"

Quoted 1 line

http://www.linux-mtd.infradead.org/

I will, thanks.

I'm looking for the simpliest reliable method of not using webs-included procedures for programming flash.
What i want, is to be able to reprogram flash with image generated on PC, that i may download to BR system.

If more information is needed please tell.

W.P.

A message that is not in the archive (sent off-list or not yet received): 1170276219.6791.18.camel@localhost

author
#4 lore raw
Quoted 10 lines · Użytkownik Brett Neumeier
Quoted 6 lines · W.P.

I'm looking for the simpliest reliable method of not using webs-included procedures for programming flash.
What i want, is to be able to reprogram flash with image generated on PC, that i may download to BR system.

Quoted 8 lines

Suppose that you create a new image on your computer, and program it into the flash, and the new image does not boot.

Do you have any way of recovering from that situation? (This might involve something like a JTAG cable.)

No, I don't have JTAG cable nor software ;(

Quoted 4 lines

If not, I'm not sure how you can really do anything "safely"....

Now i am changing firmware using supplied tool inside webs program. I am able to generate working image on a PC.
The problem for now, is how to program it into Flash NOT USING webs program. Problem i am asking here for help is in
programming flash, not in generating image. If I generate image that will not boot, i'll have a problem.
Could you help?

W.P.

#5 lore raw
In reply to W.P.

Hello

I think you should check my webpage, www.amilda.org. It's a distro for other Edimax routers, based on the (also MIPS) ADM5120. While the kernel may not be what you need, the rest is quite the same. It may still be useful for you.

Regards,

Sergio Aguayo

Quoted 28 lines

Hello,
currently i am "fighting" with Edimax BR-6024Wg, (Realtek-8186 based, lexra-mips). I need an advice from a system developer/programmer:

1). When using original firmware (EDIMAX-developed Linux-mips), task of upgrading firmware is done by web server binary: webs, which is GoAhead 2.1.1, BUT Edimax didn't published "applets" -> C functions, that implement real functionality.

2). In /dev directory there is a block node with mtd name. I have cat'ed it's contents to /web, and downloaded to PC. File seems to be raw contents of Flash memory: 2048*1024bytes long. If I drop first 64kB and truncate file to same length that Edimax-supplied firmware, files show to be the same (using cmp). The first 64kB looks to contain among others, variables used in BR system. There is originally an utility "flash" to get/set variables.

Now the question:
When I will have a new firmware (image) will it be safe(!?) to do such
thing: (instead of using webs binary):
cat /dev/mtd > some.file
dd first 64k of some.file to other.file,
then download image (from PC) to a third.file
cat other.file third.file > /dev/mtd back.??????

W.Piotrzkowski

#6 lore raw

Hello

Le mercredi 31 janvier 2007, Sergio Aguayo a écrit :

Quoted 6 lines

Hello

I think you should check my webpage, www.amilda.org. It's a distro for other Edimax routers, based on the (also MIPS) ADM5120. While the kernel may not be what you need, the rest is quite the same. It may still be useful for you.

The board he is talking about is based on a rtl8186 which has few things in common with admtek 5120?

Quoted 13 lines

Regards,

Sergio Aguayo

Quoted 8 lines

Hello,
currently i am "fighting" with Edimax BR-6024Wg, (Realtek-8186 based, lexra-mips). I need an advice from a system developer/programmer:

1). When using original firmware (EDIMAX-developed Linux-mips), task of upgrading firmware is done by web server binary: webs, which is GoAhead 2.1.1, BUT Edimax didn't published "applets" -> C functions, that implement real functionality.

This might be under particular licensing so that it has not been published. By analysing the web uploadable image, you should be able to discover how the web image format works. Probably : header, crc check, kernel, rootfs ...

Quoted 8 lines
Quoted 8 lines

2). In /dev directory there is a block node with mtd name. I have cat'ed it's contents to /web, and downloaded to PC. File seems to be raw contents of Flash memory: 2048*1024bytes long. If I drop first 64kB and truncate file to same length that Edimax-supplied firmware, files show to be the same (using cmp). The first 64kB looks to contain among others, variables used in BR system. There is originally an utility "flash" to get/set variables.

There is probably some kind of nvram on this flash, to store settings. The flash utility is probably checking crc on key+variable for instance.

Quoted 8 lines
Quoted 8 lines

Now the question:
When I will have a new firmware (image) will it be safe(!?) to do such
thing: (instead of using webs binary):
cat /dev/mtd > some.file
dd first 64k of some.file to other.file,
then download image (from PC) to a third.file
cat other.file third.file > /dev/mtd back.??????

I think you had better using dd rather than cat, because /dev/mtdblock are block devices, and should be treated like that. If your image has a valid format, i.e : the bootloader accepts it, unless you made important modifications to the system code, it should at least be booting.

Quoted 2 lines
Quoted 2 lines

W.Piotrzkowski

Signature · 15 lines
Cordialement, Florian Fainelli
---------------------------------------------
5, rue Charles Fourier
Chambre 1202
91011 Evry
http://www.alphacore.net
(+33) 01 60 76 64 21
(+33) 06 09 02 64 95
---------------------------------------------
Association MiNET
http://www.minet.net
---------------------------------------------
Institut National des Télécommunication
http://www.int-evry.fr/telecomint
---------------------------------------------
author
#7 lore raw

<cut>

Quoted 4 lines

The board he is talking about is based on a rtl8186 which has few things in common with admtek 5120?

As i realize, it is a MIPS too, and he's talking about utilities, not the kernel. (I'll download sources tomorrow, i have only GPRS internet connection, so i will take several hours, and the i'll examine it). At least some idea ;)

<cut>

Quoted 6 lines

I think you had better using dd rather than cat, because /dev/mtdblock are block devices, and should be treated like that. If your image has a valid format, i.e : the bootloader accepts it, unless you made important modifications to the system code, it should at least be booting.

Using dd also suggests padding resulting file to 2048*1024 bytes, am i right? And using block size of 64k?
As of image, i remarked, that file resulting from reading /dev/mtd look
like: boot&variables(64k) + original image I have uploaded using Edimax program(approx 1.9M) + zeros to the end of 2M boundary.

So you think it may work? (dd ?) Image generation and upload using Edimax-supplied tools works.

W.P.

#8 lore raw
Quoted 7 lines

<cut>

Quoted 5 lines

The board he is talking about is based on a rtl8186 which has few things in
common with admtek 5120?

Quoted 5 lines

As i realize, it is a MIPS too, and he's talking about utilities, not the kernel. (I'll download sources tomorrow, i have only GPRS internet connection, so i will take several hours, and the i'll examine it). At least some idea ;)

The realtek chipset by itself doesn't have many things in common with the ADM5120. But the board used (in this case by Edimax), is very similar for both chipsets. Almost the only thing needed to make the software of the one work in the other is placing some platform-dependent code in the kernel. The user-space should be quite the same (except the wireless driver, which is different).

Quoted 10 lines

<cut>

Quoted 7 lines

I think you had better using dd rather than cat, because /dev/mtdblock are
block devices, and should be treated like that. If your image has a valid format, i.e : the bootloader accepts it, unless you made important modifications to the system code, it should at least be booting.

Quoted 6 lines

Using dd also suggests padding resulting file to 2048*1024 bytes, am i right? And using block size of 64k?
As of image, i remarked, that file resulting from reading /dev/mtd look
like: boot&variables(64k) + original image I have uploaded using Edimax program(approx 1.9M) + zeros to the end of 2M boundary.

The structure (of the flash memory) is something like this:

32KB             Boot loader
32KB             Config stuff
rest             Kernel+BZIP2 RAMDISK

The exact size of the kernel and the ramdisk varies greatly between firmware versions. YOu can find the start of the ramdisk by searching for the bzip2 signature (in this case 'BZh'). The kernel+ramdisk doesn't have to occupy the rest of the flash memory: the part not occupied by it is just undefined and its contents may be whatever.

Quoted 3 lines

So you think it may work? (dd ?) Image generation and upload using Edimax-supplied tools works.

dd would certainly work. I would suggest you to check the way AMiLDA generates the firmware image. It's a lot more practical than a dd :D

Regards,

Sergio

Quoted 4 lines

W.P.

author
#9 lore raw

<cut>

Quoted 4 lines

dd would certainly work. I would suggest you to check the way AMiLDA generates the firmware image. It's a lot more practical than a dd :D

Thanks, i'll look at this (just finished downloading source). But my question was NOT concerning GENERATING image (that part
of toolchain works, so let it be), but FLasing it. Normally done by webs app. And as i see in Amilda, it uses the same scheme -> webs-buried C function. And I would have an alternative, because of: first -> have no source for webs-buried functions supplied by Edimax, so I have only choice of using built binary no chance to simply add some functionality, second -> webs is quite heavyweight, approx 450kb -> it is a lot on system with 2M Flash expanded to 5M Ramdisk.

BTW maybe someone reading this knows what Edimax devices have 4M flash?

W.P.

#10 lore raw
Quoted 11 lines

Thanks, i'll look at this (just finished downloading source). But my question was NOT concerning GENERATING image (that part
of toolchain works, so let it be), but FLasing it. Normally done by webs app. And as i see in Amilda, it uses the same scheme -> webs-buried C function. And I would have an alternative, because of: first -> have no source for webs-buried functions supplied by Edimax, so I have only choice of using built binary no chance to simply add some functionality, second -> webs is quite heavyweight, approx 450kb -> it is a lot on system with 2M Flash expanded to 5M Ramdisk.

The flash memory is represented under Linux as a block device driven by the mtd driver. Therefore it behaves as a normal block device that can be read or written to. Basically, webs does a write to that block device. Earlier versions of the source code released by Edimax included the webs functions. I think the source download is getting more and more useless on every revision.

Remember that the whole ramdisk (which has data of less than 3MB) is BZIP2 compressed, and it is concatenated with the kernel and then compressed in GZIP. That makes 450KB not-so-big in 2MB.

Quoted 2 lines

BTW maybe someone reading this knows what Edimax devices have 4M flash?

check this: http://www.linux-mips.org/wiki/Adm5120

Sergio

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

#12 lore raw
Quoted 6 lines

<cut>

Quoted 4 lines

check this: http://www.linux-mips.org/wiki/Adm5120

Quoted 7 lines

Nice ;)

Sergio,
1). I am trying now to port the flash utility to BR-6204Wg (different data structure), as of now i have succeded to read part of hardware-related settings -> nic0, nic1, wlan-mac. As I finish I'll send you a copy of related changes needed.

Are you talking about the configuration structure? If so, it varies between model to model. AMiLDA itself uses a totally different configuration which may very from version to version.

Quoted 3 lines

2). I have compiled webs server as-is from Amilda, it compiles, but when started just returns with no output. I will investigate this.

That means that webs encountered an error starting up. Usually it is due to another webs instance already running or another process that has port 80 opened.

Sergio

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

#14 lore raw
Quoted 11 lines

<cut>

Quoted 6 lines

Are you talking about the configuration structure? If so, it varies between model to model. AMiLDA itself uses a totally different configuration which may very from version to version.

Yes.

The configuration structure is difficult to understand (even if you have the C header containing the struct) because of many conditional compiling macros (if this model, and not that one or this but not the other, etc). Just use the "flash" program.

Quoted 8 lines
Quoted 6 lines

That means that webs encountered an error starting up. Usually it is due to another webs instance already running or another process that has port 80 opened.

That is not the case, sure.

When webs does that, it means that it encountered an error during startup. If i remember correctly, webs does the following during startup:

- Allocate some memory for its own use.
- Figure out the document root.
- Register asp and cgi functions.
- Bind to port 80 (or whatever it is told to use)

If any of these fail, then you will experience that simpton.

Sergio

author
#15 lore raw

<cut>

Quoted 4 lines

The configuration structure is difficult to understand (even if you have the C header containing the struct)

I don't have any header files for flash. Do you? In tarballs for BR, there is no source for utilities like flash.
I'm trying to "decode" this structure, variable-by-variable. I have used your flash utility source

Quoted 3 lines

Just use the "flash" program.

The one, that comes with original firmware? But what about webs, as i looked into, this needs too some knowledge of flash datastructures.?

About webs -> will try to add some printf for debugging, and see.

BTW, maybe the JP3 connector (just 12 little holes) is the JTAG. Will upload photo i think tomorrow. I have checked this with ohmometer and pin-map of 8186, and it seems to be JTAG + RESET+ something(?). You have published schema of JTAG cable, but what software shall anyone use?

W.Piotrzkowski.

#16 lore raw
Quoted 4 lines

<cut>

Quoted 9 lines
Quoted 4 lines

The configuration structure is difficult to understand (even if you have the C header containing the struct)

I don't have any header files for flash. Do you? In tarballs for BR, there is no source for utilities like flash.
I'm trying to "decode" this structure, variable-by-variable. I have used your flash utility source

When Edimax was forced to release the sources, they released a different source archive than the one currently available. That one contained some more files than the current one does. I'll upload it today for you to download it.

Quoted 6 lines
Quoted 3 lines

Just use the "flash" program.

The one, that comes with original firmware? But what about webs, as i looked into, this needs too some knowledge of flash datastructures.?

webs and the flash program share some sources. Originally, flash's sources are contained in the LINUX directory of webs.

Quoted 3 lines

About webs -> will try to add some printf for debugging, and see.

Ok, let me know what your results are.

Quoted 5 lines

BTW, maybe the JP3 connector (just 12 little holes) is the JTAG. Will upload photo i think tomorrow. I have checked this with ohmometer and pin-map of 8186, and it seems to be JTAG + RESET+ something(?). You have published schema of JTAG cable, but what software shall anyone use?

That's a JTAG. But AFAIK no software can drive it yet (except maybe some commercial software?). See forum.amilda.org, forum MODs for some information that may be useful for you to experiment with jtag.

Sergio

#17 lore raw
In reply to W.P.
Quoted 12 lines

<cut>

Quoted 4 lines

The configuration structure is difficult to understand (even if you have the C header containing the struct)

I don't have any header files for flash. Do you? In tarballs for BR, there is no source for utilities like flash.
I'm trying to "decode" this structure, variable-by-variable. I have used your flash utility source

When Edimax was forced to release the sources, they released a different source archive than the one currently available. That one contained some more files than the current one does. I'll upload it today for you to download it.

Quoted 6 lines
Quoted 3 lines

Just use the "flash" program.

The one, that comes with original firmware? But what about webs, as i looked into, this needs too some knowledge of flash datastructures.?

webs and the flash program share some sources. Originally, flash's sources are contained in the LINUX directory of webs.

Quoted 3 lines

About webs -> will try to add some printf for debugging, and see.

Ok, let me know what your results are.

Quoted 5 lines

BTW, maybe the JP3 connector (just 12 little holes) is the JTAG. Will upload photo i think tomorrow. I have checked this with ohmometer and pin-map of 8186, and it seems to be JTAG + RESET+ something(?). You have published schema of JTAG cable, but what software shall anyone use?

That's a JTAG. But AFAIK no software can drive it yet (except maybe some commercial software?). See forum.amilda.org, forum MODs for some information that may be useful for you to experiment with jtag.

Sergio

author
#18 lore raw
Quoted 7 lines · Użytkownik Sergio Aguayo
Quoted 7 lines

<cut>
When Edimax was forced to release the sources, they released a different source archive than the one currently available. That one contained some more files than the current one does. I'll upload it today for you to download it.

OK, i'll wait for it. Please notify me.

<cut>

Quoted 5 lines

webs and the flash program share some sources. Originally, flash's sources are contained in the LINUX directory of webs.

This is why i am "disassembling" data structure. Looks like using a lot of space -> 0x7FFA if the 2 bytes after signature are the length. If i have found correctly, config data is 0x8000->0xFFFA in mdt, a bit earlier are hardware parameters: 0x6000, and there is something (maybe default config) at 0x6400.

Quoted 1 line
Quoted 1 line

About webs -> will try to add some printf for debugging, and see.

At this moment, have located, that problem is in flash parameters loading (before socket binding etc), so i'll finish "dissasembling" and return to webs.

<cut>

Quoted 5 lines

That's a JTAG. But AFAIK no software can drive it yet (except maybe some commercial software?). See forum.amilda.org, forum MODs for some information that may be useful for you to experiment with jtag.

Will look on the net, it's hard to believe, that no one developed JTAG open source software.

W.Piotrzkowski.