I made a very expensive FAT32 128MB drive, filled it with data, unplugged to bypass cache, read back... 100% correct.
But restoring the system image keeps failing.
Boot and kernel works, it's only related to Data/Root. I suspect the problem is related to the ECC.
You can't directly write or read the ECC data, everything is done by the hardware.
To check if the data is ok, after reading a block you have to check Status Register 3 ECC bits (ECC-0, ECC-1).
If (0,0) it means everythign was ok. If (0,1) it means there was a recoverable error. And so on.
So my thoughts is that original FW enables ECC, and also the SPI programmer? But not this Linux, thus the ECC is not updated when writing data.
So, althought the data is valid, the ECC isn't, and the UBI driver fails.
There're references to the internal ECC in drivers/mtd/nand/spi/winbond.c and drivers/mtd/nand/spi/core.c
I've been searching a way to enable or disable it, but this was all the documentations I found : Documentation/devicetree/bindings/mtd/spi-nand.txt
SPI NAND flash
Required properties:
- compatible: should be "spi-nand"
- reg: should encode the chip-select line used to access the NAND chip
The current DTS code related to the spi nand:
&spi0 {
status = "okay";
spi-nand@0 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "spi-nand";
reg = <0>;
spi-max-frequency = <100000000>;
status = "okay";
partition@0 {
label = "spi-nand";
reg = <0x000000 0x8000000>;
};
};
};
BTW a very nice Windows alternative to dd is
usb image tool, been using it for years, for me it's the best for making disk images.
A truly lifesaver when I worked at fixing computers, the USB drives with utilities/proghrams/stuff failed very often (viruses, bad removals...).
I could plug 8 drives and restore all in a shot, take a 6-7 minutesa break and back to the work with new USBs!