OpenNuvoton / NUC970_Linux_Kernel

Linux Kernel Source Code for NUC970 Series Microprocessor
Other
68 stars 69 forks source link

Reading from SPI flash gives wrong data #31

Closed lightelf76 closed 5 years ago

lightelf76 commented 5 years ago

I have a NUC976 custom board with SPI NOR flash as main storage. Flash connected with 4-wire interface (i.e. Quad mode not possible). There are problem with Flash using, I need to resolve. What I got so far: 1) ROM code successfully load U-Boot 2) U-Boot successfully loads kernel 3) Kernel tries to mount root from JFFS2 MTD partition, but usually fail with error. Scenarios, I seen so far: A) If SPI flash forced to operate in Single mode, data offset by single byte. JFFS2 complain "jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0001d604: 0x0219 instead", when actual data at offset 0x0001d604 is "85 19 02 E0", so byte "85" lost. B) If SPI flash set to operate in Dual mode, data offset by 2 bytes, i.e. "jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000000: 0x2003 instead" actual data at offset 0x00000000 is "85 19 03 20", so bytes "85 19" lost. Errors are unstable, after power cycling/resets they appear at different addresses. I was tried to lower SPI clock, but still have same errors. Given that U-Boot and kernel are always loaded successfully from the same flash chip, I do not think the problem related to routing/soldering. Data offset to exactly 1 or 2 bytes (not to some random number of bits) leaves EMC-related issues out of reason also.

cwweng-nuvoton commented 5 years ago

Hi, I cannot reproduce your issue. Did you modify any source code ? Please provide your kernel config for us to check this issue.

yachen commented 5 years ago

Please reopen and provide kernel config if this issue still exists

lightelf76 commented 5 years ago

Yes, it seems related to my kernel CONFIG/changes, I need to bissect to find issues. Clean build (TOMATO_DEFCONFIG) from OpenNuvoton kernel sources works as expected. Will check later.