View Full Version : Fixing mtd cfg partition
Hi,
I was setting up a new nanostation with a rc.poststart, wpasup.conf, and certificate make it run correctly on my network. After putting all the files in the /etc/persistent directory, I ran cfgmtd -w -p /etc to save them. I then ran the reboot command from the shell. The NS booted up but I could no longer get into the web interface or the telnet interface; I got "connection refused."
The only way I could get back in was run the firmware recovery procedure. I did so using the firmware I made with the v3.0 SDK. That worked, but any changes I made would not be saved to flash. I went into the shell found a problem:
XS2.ar2316.v3.0.2927.080424.2052# cfgmtd -w -p /etc
Could not open MTD device cfg
XS2.ar2316.v3.0.2927.080424.2052# cfgmtd -w
Could not open MTD device cfg
XS2.ar2316.v3.0.2927.080424.2052# cat /proc/mtd
dev: size erasesize name
mtd0: 00030000 00010000 "RedBoot"
mtd1: 000d0000 00010000 "kernel"
mtd2: 002c0000 00010000 "cramfs"
mtd3: 00020000 00010000 "unallocated space"
mtd4: 00010000 00010000 "FIS directory"
mtd5: 00001000 00010000 "RedBoot config"
mtd6: 00010000 00010000 "EEPROM"
mtd7: 003b0000 00010000 "Working flash"
Mtd3 should be labeled "cfg" right? How can I rename/fix the partition? I tried accessing Redboot via telnet port 9000, but that did not work. Flashed it with the stock 3.0 firmware through the web interface and that did not work. I have a serial to USB cable for Meraki Minis, but I do not think it would work on the NS2.
Any suggestions would be appreciated.
hiwu.tw
05-31-2008, 09:56 AM
(1) Please try
cfgmtd -w -p /etc/ -r -f /tmp/system.cfg
(2)
mtd3: 00020000 00010000 "unallocated space"
It is correct.
cfgmtd writes data into mtdblock directly.
UBNT-keba
05-31-2008, 09:56 AM
Flash latest fw (v3.0) through the web then flash image through RedBoot through tftp (recovery procedure). It has to recreate cfg partition.
UBNT-keba
05-31-2008, 10:46 AM
An other method:
NOTE: it will works if you are already flashed v3.0 on the device
Use fwsplit on original fw v3.0
./fwsplit NS2.v3.0.bin
Firmware file: 'NS2.v3.0.bin'
Firmware version: 'NS2.ar2316.v3.0.2927.080424.2052'
Creating descriptor file:
NS2.ar2316.v3.0.2927.080424.2052.txt
Creating partition data files:
NS2.ar2316.v3.0.2927.080424.2052.RedBoot
NS2.ar2316.v3.0.2927.080424.2052.kernel
NS2.ar2316.v3.0.2927.080424.2052.cramfs
Create zeroed 128KB block (2 X 64KB erase blocks) to file NS2.ar2316.v3.0.2927.080424.2052.cfg
dd if=/dev/zero of=NS2.ar2316.v3.0.2927.080424.2052.cfg bs=64k count=2
Edit fw layout file NS2.ar2316.v3.0.2927.080424.2052.txt. Add one line at the end:
cfg 0x03 0xBFFC0000 0x00020000 0x00000000 0x00000000 NS2.ar2316.v3.0.2927.080424.2052.cfg
Note: separators are TABs
Collect all parts back to fw image.
./mkfwimage -v NS2.ar2316.v3.0.cfgfix -o NS2.v3.0.cfgfix.bin -i NS2.ar2316.v3.0.2927.080424.2052.txt
Firmware version: 'NS2.ar2316.v3.0.cfgfix'
Output file: 'NS2.v3.0.cfgfix.bin'
Part count: 4
RedBoot: 170856 bytes (free: 25752)
kernel: 471388 bytes (free: 380580)
cramfs: 2469888 bytes (free: 413696)
cfg: 131072 bytes (free: 0)
You will get NS2.v3.0.cfgfix.bin fw image
Flash NS2.v3.0.cfgfix.bin image through WEB.
Good luck
Keba,
Thank you for your help and quick replies. I tried the first method you suggested and I believe the NS2 recreated the cfg partition, but it restored the old (and bad) settings and scripts I added. So the NS2 does not set an IP address on the wireless or lan. I will try reseting the configuration using the second method.
Thanks again!
The cfg partition is back and cleared, and cfgmtd is working again. Thanks!
wifibot
07-24-2008, 02:10 PM
this post save me for an important customer thanks a lot :-)
roneyeduardo
08-05-2008, 02:10 PM
Keba,
With this method:
./mkfwimage -v NS2.ar2316.v3.0.cfgfix -o NS2.v3.0.cfgfix.bin -i NS2.ar2316.v3.0.2927.080424.2052.txt
Firmware version: 'NS2.ar2316.v3.0.cfgfix'
Output file: 'NS2.v3.0.cfgfix.bin'
Part count: 4
RedBoot: 170856 bytes (free: 25752)
kernel: 471388 bytes (free: 380580)
cramfs: 2469888 bytes (free: 413696)
cfg: 131072 bytes (free: 0)
Can I generate a firmware with only the vmlinuz and cramfs images, without the RedBoot ? Will it work?
UBNT-keba
08-05-2008, 11:51 PM
Yes, you can. Just make sure that fw-layout is correct and you will not overwrite other parts like Redboot or cramfs on device. Double check device 'fis list' info on running device.
Also it is possible from v3.0. Older versions were requiring kernel and cramfs to be present.
roneyeduardo
08-06-2008, 06:19 AM
Is RedBoot version from AirOS v2.x the same as in the v3.x ?
My situation is: I bought 100 units of NS2 and they came with AirOS v2.2.
As I had to deploy them rapidly on customers, I didn't have the time to make the modifications I need to the v3.x SDK.
Now, I'm finnishing the mods I want to 3.x and I will be remote updating (wirelessly) the ones already deployed.
I think that remote updating the firmware only with kernel and cramfs is safer than with redboot included. That way, if any thing goes wrong wirelessly, I'll still be able to go the customer's premise and recover via TFTP. Am I right?
UBNT-keba
08-06-2008, 11:59 AM
Yes, you are right
roneyeduardo
08-07-2008, 11:47 AM
Keba,
I'm trying to compile a new boa binary. I need it to read another file (other than /etc/passwd) to do the HTTP-AUTH.
I'm doing this to run an other instance of the webserver (I renamed boa to "web") in a different port. I got it to read a different config file (in that case, /etc/web.conf) and it start in the specified port.
But I'm not getting to do it read another pass file but /etc/passwd.
I went through it's src code, renamed every instance of the term "/etc/passwd" to the file I want (say... /etc/otherpass)...but the generated binary continues reading/opening /etc/passwd...
Could you give me some advice?!?
UBNT-keba
08-07-2008, 12:13 PM
Check your /etc/web.conf for
Auth / /etc/passwd
There could be the answer
BTW: it is wrong topic to discuss these questions ;-)
microshift
12-22-2008, 06:49 AM
How to add cfg partition to the original source code, so the make will generate a complete bin at once?
datanet
09-30-2009, 06:05 AM
Hi, I have de NS5 with firmware 3.3.2 and I have de same problem, the MTD device cfg is not found. I probe the two solution posted but still the same problem. Any suggestion?... Thanks.
UBNT-keba
01-05-2010, 04:34 AM
How to add cfg partition to the original source code, so the make will generate a complete bin at once?
This is not a good idea, because each time you will do upgrade you will recreate cfg patition to the same one as it is in fw binary. In other words after fw update with such fw last cfg modifications on device will be lost.
Please always use WEB method for fw uploaded and you will never loose cfg patition.
TFTP method described by me in this thread is for recovery when cfg partition is lost and you have custom fw only.