Only in The Code i think.... Because cant erase or mount our partitionI did implement bad block support a few years ago, but I can't remember if it was only in the mtd-erase code or in the other operations as well.
Only in The Code i think.... Because cant erase or mount our partitionI did implement bad block support a few years ago, but I can't remember if it was only in the mtd-erase code or in the other operations as well.
I did implement bad block support a few years ago, but I can't remember if it was only in the mtd-erase code or in the other operations as well.
I did a quick look at the code, and it looks like there's a path for the ARM routers where bad blocks aren't taken into account on an erase. I wrote a patch based on @sfx2000 's OpenWRT patch (had to change it a bit, since we have a different mtd) to add a bad block skip. It compiles, but I'm not in a position to test it for a few days. If anyone wants to try it 'untested', post here with your router type and I'll do a build for you.
Thanks for the review.....Can you post the patch to Gist or paste.bin? I can review it.
I think it really depends on if there are really is any hardware that doesn't support the MEMGETBADBLOCK ioctl. Maybe you have some more info here. If all the hardware is supposed to support it, and it errors on the call, it may be better to just give up then.That fourth point, I'm kinda thorn. It's how I used to handle it, as I consider that a BB check shouldn't be a fatal error - the erase attempt afterward should decide whether the action should truly fail or not. Thoughts?
I think it really depends on if there are really is any hardware that doesn't support the MEMGETBADBLOCK ioctl. Maybe you have some more info here. If all the hardware is supposed to support it, and it errors on the call, it may be better to just give up then.
Also, if we're going to really dig in to this one.....take a look at the mtd_write function, near the end after the comment 'Do-It'. Looks like it may be exposed as well, but it would require a little more work since you have to adjust the block pointer end on the fly to match the length of what you are writing taking into account any skips.
Just as an FYI...I was playing a bit with my original patch on my fork....I happen to have a 68R with a couple of bad blocks. Added a couple of status messages.....I'm starting to feel uncomfortable with all that mtd code patching tho, as we don't have any test case to confirm that we're not causing new issues by skipping blocks like this.
admin@RT-AC68R-BC88:/tmp/home/root# mtd-erase2
usage: mtd-erase2 [device]
admin@RT-AC68R-BC88:/tmp/home/root# mtd-erase2 brcmnand
Erase MTD brcmnand
Skipping bad block at 0x038e0000
Erase MTD brcmnand OK!
I'm starting to feel uncomfortable with all that mtd code patching tho, as we don't have any test case to confirm that we're not causing new issues by skipping blocks like this.
Just as an FYI...I was playing a bit with my original patch on my fork....I happen to have a 68R with a couple of bad blocks. Added a couple of status messages...
A patch like this, and in some ways I regret pointing out what OpenWRT has done, does help, but only at one point in time - and the risk here is that even with the patch, there might be code that just sits there and burns holes in flash - and that is the risk with straight NAND vs. eMMC (and external storage) where there is an intermediary layer of HW that works this outside of the OS...
Just as an FYI...I was playing a bit with my original patch on my fork....I happen to have a 68R with a couple of bad blocks. Added a couple of status messages.....
I was thinking about this as well.....what we are playing with is some 'big' functions (for lack of a better word), that take care of initialization types of events. What I don't know, is how subsequent 'random' updates are handled by the kernel. I would assume these update IOs would have to take into account bad blocks?A patch like this, and in some ways I regret pointing out what OpenWRT has done, does help, but only at one point in time
The patch itself is fine - it relies on ioctl(), asking the NAND driver if the block is mapped as being bad. So the whole mechanism itself is done by the nand driver, not by the code.
The OpenWRT code you pointed at was nothing new. I was using the same code before even OpenWRT did, except I only did so with the RT-AC66U (the first model which came with NAND with a badblock table). John just dug a bit deeper to locate other areas of the mtd code which also needed the same table lookups to be made.
we are playing with is some 'big' functions (for lack of a better word), that take care of initialization types of events. What I don't know, is how subsequent 'random' updates are handled by the kernel. I would assume these update IOs would have to take into account bad blocks?
Well....we have a couple of folks with unusable jffs. Maybe a test is in order (pretty much nothing to lose)
Welcome To SNBForums
SNBForums is a community for anyone who wants to learn about or discuss the latest in wireless routers, network storage and the ins and outs of building and maintaining a small network.
If you'd like to post a question, simply register and have at it!
While you're at it, please check out SmallNetBuilder for product reviews and our famous Router Charts, Ranker and plenty more!