OpenWrt Forum Archive

Topic: Poll for AR7Port bootloader: What do your MTD variables mean?

The content of this topic has been archived on 25 Mar 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi everyone.

I'm trying to tweak linux/drivers/mtd/map/ar7_flash.c to allow for config partition to be located right after adam2 partition. That is not the common situation (nbd, thanks for telling me so) so I am tryting to recode the openwrt partition table gathering data from mtd variables directly instead of guessing what is which from the position in the flash.

For example, for Linksys ADSL2MUE, the partition table looks like this <adam2><config><linux><fs>, while WAG54G shows the following <adam2><linux><fs><config>.

Before nbd noticed the difference, the flash map resulted in kernel panic on ADSL2MUE, so I decided to make it work myself.

My modifications take partition data from mtd variables makeing the following assumptions:
-> mtd0 == filesystem
-> mtd1 == linux
-> mtd2 == adam2/pspboot/any_bootloader
-> mtd3 == configuration
But I need to be sure that those assumptions are correct on every piece of hardware based on AR7 that we may be dealing with.

And here is where I need your help: Could you please post if it is so for every piece of hardware you may know about detailing hardware and software revision?

Thanks for your valuable contribution.

Jose Angel

For the actiontec Gt701 the mtd look something like this:

-> mtd0 == filesystem
-> mtd1 == linux
-> mtd2 == adam2/pspboot/any_bootloader
-> mtd3 == environment (which I believe is for adam2)
-> mtd4 == configuration (config.xml)

Gary

Could you please provide the values of the mapping? I mean the addresses where each mtd partition starts and ends.

The patch I wrote would not work with Actiontec GT701 map, that is why I ask you for more details, to be able to adjust the flash map driver properly.

Edited
I found this on google. Could you please confirm it? Thanks

mtd2    0x90000000,0x90010000
mtd1    0x90010000,0x900d0000
mtd0    0x900d0000,0x903e0000
mtd4    0x903e0000,0x903f0000
mtd3    0x903f0000,0x90400000

mtd0            3,136K     Root (SquashFS - compressed filesystem)
mtd1            768K       Kernel
mtd2            64K        ADAM2
mtd3            64K        config.xml
mtd4            64K        unkown/unused

so: <adam2><kernel><filesystem><unknown><config>

(Last edited by joseangel on 1 Nov 2005, 00:24)

The hex address you listed for mtd0 through mtd4 are correct for the GT701.  However, I am now not sure of the contents of the mtd3 and mtd4. Both are labeled configs but neither match the config.xml.  I will have to download them tomorrow and look through them, and if you need I can send them or post them.

Gary

That won't be necesary. Just try to find out what do those partitions contain to be able to make a decision on where should them be included when presented to OpenWRT software. Perhaps the best way is the "oficial openwrt" way, that is getting both of them into the config area and just forget about them. But I would like to know what gets inside that to let OpenWRT have an easy upgrade path if someday a "nvram" command is developed for our platforms (It could become a real pain if anything but config gets into the "config" partition).

Have you tried my patch on openwrt sources? Did it boot correctly on your actiontec?

Thanks

(Last edited by joseangel on 4 Nov 2005, 16:44)

In TI-standard-setups, config.xml or whatever the config file is called, is located _in_ the config partition (mtd3 by default).

The config partition is divided into the environment at the beginning (default: 80 env vars of 128 bytes fixed size == 10k) and the raw config.xml just after that till the end of the flash sector. Details can be found in the ticfg-driver that is part of most AR7 source balls.

Then the question is: Would it harm OpenWRT to leave mtd4 together with mtd3 as config partition? Would it be better to leave mtd4 out of the partitions range? Could we just erase mtd4 and extend mtd0 so we get more room for our software applications?

By now I will make my patch to accept mtd4 into mtd3 but I'll leave a door opened just in case we decide in the (near?) future to get it away and let mtd0 make better use of its space.

joseangel wrote:

That won't be necesary. Just try to find out what do those partitions contain to be able to make a decision on where should them be included when presented to OpenWRT software. Perhaps the best way is the "oficial openwrt" way, that is getting both of them into the config area and just forget about them. But I would like to know what gets inside that to let OpenWRT have an easy upgrade path if someday a "nvram" command is developed for our platforms (It could become a real pain if anything but config gets into the "config" partition).

Have you tried my patch on openwrt sources? Did it boot correctly on your actiontec?

Thanks

Which patch are you refering too?

Also another member of the board got openwrt to boot on the actiontec .  He made a mtd5 that encompassed mtd0 through mtd1 and supposidly did not touch mtd3 or mtd4.  I tried this several months ago, but no boot.  I have not had time to hook up a serial interface to see where it gut stuck.



Edit:  The mtd3 has adam2 environment variables plus a large amount of the config.xml file.  mtd4 has user level settings for the dsl password, modem password, plus the config.xml information.  So there appears to be some redundency in the files.

Gary

(Last edited by gwf on 6 Nov 2005, 01:25)

Recompiling right now.  Are we supposed to use the combined kernel and rootfs in one file or the separate files.  The instructions are not very helpful from that respect.  Also I assume the squashfs not the jffs?

Thanks

Gary

The patch works on squashfs and jffs2 but has only been tested on single file version. And, please, keep in mind that the patch won't prevent you from reflashing from adam2/pspboot but it could result easily on kernel panic and halt right at the beggining of the booting process.

(Last edited by joseangel on 6 Nov 2005, 14:23)

joseangel wrote:

Then the question is: Would it harm OpenWRT to leave mtd4 together with mtd3 as config partition? Would it be better to leave mtd4 out of the partitions range? Could we just erase mtd4 and extend mtd0 so we get more room for our software applications?

AVM Fritz!Box, for example, uses mtd3 and mtd4 as config alternatingly to make "safe" config updates possible when the active config sector runs out of space.

nbd told me on irc that there are boxes that have mtd4 spanning the whole flash.

Enrik

OK, then. So from what we learnt, OpenWRT could just ignore mtd4 partitions and take mtd3 as readonly config partition. I say readonly because for AR7, for example, every config parameter and script is inside the squashfs/jffs2 partitions, not from nvram like the wrt54g does.

I understand why nbd does not like the mtd variable to meaning mapping, but by now I still think it is better than the flash location aproach currently used. I agree I should add some checking on partitions to make sure the mapping makes sense before giving it back to openwrt on boot, but I also think it is more versatile and future proof than address based partition recognition.

Of course, he is one of the developers and I am just a newbie, his opinion is far more valuable than mine. In the end I will try to help and align my efforts with him but perhaps I will leave my own compilation there to run on my own box. That's Linux spirit, isn't it? smile

Tried the jffs2 and squashfs neither will boot.  Can not access the box after flashing except booting to the adam2 ftp server.  Anyway guess I should get a serial cable so I can see what is going on.

Gary

For troubleshooting, yes, a serial cable would help a lot. Actually I would not recommend testing anything like this without serial console available.

BTW, by now the patch is known to be working on FritzBox and Linksys ADSL2MUE.

(Last edited by joseangel on 9 Nov 2005, 23:04)

The discussion might have continued from here.