[U-Boot] Bad block present before NAND flash partition offset

Madhu koriginja madhava.koriginja at gmail.com
Fri Jan 18 12:50:28 UTC 2019


Hi All,
In my NAND flash one bad block present before some 'X' binary offset, after
this binary partition kernel and rootfs partitions are present.
In U-Boot when I access this x binary using the offset address it is not
getting binary file content, because of one bad block the 'X' binary
flashed in next block after the offset. I used nand_read and
nand_read_skip_bad functions, nand_read_skip_bad function is handling if
bad block present between offset and the length of the data required after
offset.

I want to know is there any function in existing u-boot source code to
handle  the above issue(if bad blocks present before offset)?

If there is no provision, there are two ways to solve it
1. it is working if I change the offset value of 'X' binary in U-boot
source code based on the no. of bad blocks present before offset 'X'
binary.
2. Check the no. of bad blocks present before offset at run time and add
those many bad blocks length to the offset.
First method does not work if different boards NAND flash have bad blocks
in different places, but second method handles this.

With the second method, the changes in my specific code to access my 'X'
binary, it does not affect common code.
After this U-boot is failing to load kernel, because the same issue for
kernel also, U-boot is reading the kernel image from the kernel offset, but
the kernel image also flashed after 1 block due to 1 bad block.
If I follow the above second method here also, I need to do change in "nand
read" command function. But with this change it may create some confusion
to others in situation like, if some one debugging and wants to read the
content from some offset, if bad block present before this offset, it does
not read exactly from that offset, it reads after that due to bad block
because nand read function is modified above.
I want to address this issue in general way, to solve the problem in
dynamic way to handle different bad blocks can present in different boards
and do not create confusion. Please comment.

I am thinking in nand read function while displaying the content it should
print from which address it is displaying, so that if they observe it they
know it is displaying after the specified offset due to bad blocks, but
people may miss to see the address print.

Thanks.


More information about the U-Boot mailing list