I recently upgraded my 64 MB NOR flash on my PowerPC (P2020) embedded board to a 256 MB NOR flash. (The board has 2 GB of DDR RAM.) I had to decrease the page offset to provide enough room for VMALLOC of the the 256MB NOR, just like this:
This allows me to see all 256 MB of the NOR from Linux-user space. (I've verified by writing in u-boot, rebooting, and reading from Linux-user.)
However, I can only erase the first 139 MB of 256 MB. Curiously, the virtual memory boundary where the erases begin to fail is close to 0xE0000000. (Maybe it's nothing.)
I have instrumented the kernel code (printk) and verified that the erase fails above 139MB, because the CFI driver does not read-back 0xFFFF as expected after erase.
Because I can read and write all of the NOR from u-boot, I suspect this is a software problem. Specifically, I fear it is some kind of Linux kernel-virtual memory layout issue, but I'm not sure what would allow me to read all of a memory region - but only write to part of the same region.
Is there any memory (high, low, virtual) configuration in the kernel that would explain this behavior, being able to read all 256 MB of NOR but only able to write to the first 139 MB? Since I've verified the hardware in u-boot, what other software issue should I consider, if not the kernel?
FWIW, at boot, the kernel-virtual memory layout is reported as:
[ 0.000000] Zone PFN ranges: [ 0.000000] DMA 0x00000000 -> 0x00020000 [ 0.000000] Normal 0x00020000 -> 0x00020000 [ 0.000000] HighMem 0x00020000 -> 0x00080000 [ 0.000000] Movable zone start PFN for each node [ 0.000000] early_node_map active PFN ranges [ 0.000000] 0: 0x00000000 -> 0x00080000 [ 0.000000] MMU: Allocated 1088 bytes of context maps for 255 contexts [ 0.000000] PERCPU: Embedded 7 pages/cpu @b1c0d000 s7688 r8192 d12792 u65536 [ 0.000000] pcpu-alloc: s7688 r8192 d12792 u65536 alloc=16*4096 [ 0.000000] pcpu-alloc:  0  1 [ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 520192 ... [ 0.000000] PID hash table entries: 2048 (order: 1, 8192 bytes) [ 0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes) [ 0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes) [ 0.000000] Memory: 2072548k/2097152k available (6360k kernel code, 23728k reserved, 252k data, 151k bss, 232k init) [ 0.000000] Kernel virtual memory layout: [ 0.000000] * 0xfffe0000..0xfffff000 : fixmap [ 0.000000] * 0xff800000..0xffc00000 : highmem PTEs [ 0.000000] * 0xff7fe000..0xff800000 : early ioremap [ 0.000000] * 0xd1000000..0xff7fe000 : vmalloc & ioremap [ 0.000000] SLUB: Genslabs=13, HWalign=32, Order=0-3, MinObjects=0, CPUs=2, Nodes=1 ... [ 1546.968602] e0000000.nor: Found 1 x16 devices at 0x0 in 16-bit bank [ 1546.974874] Amd/Fujitsu Extended Query Table at 0x0040 [ 1546.980463] Using buffer write method [ 1546.984122] e0000000.nor: CFI does not contain boot bank location. Assuming top. [ 1546.991518] number of CFI chips: 1 [ 1546.994912] cfi_cmdset_0002: Disabling erase-suspend-program due to code brokenness. [ 1547.002680] Searching for RedBoot partition table in e0000000.nor at offset 0xffe0000 [ 1547.133862] No RedBoot partition table detected in e0000000.nor [ 1547.139807] Creating 8 MTD partitions on "e0000000.nor": [ 1547.145120] 0x000000000000-0x000002700000 : "NOR Partition 1" [ 1547.153078] mtd: Giving out device 0 to NOR Partition 1 [ 1547.160343] 0x000002700000-0x000002800000 : "NOR Partition 2" [ 1547.167177] mtd: Giving out device 1 to NOR Partition 2 [ 1547.173324] 0x000002800000-0x000003300000 : "NOR Partition 3" [ 1547.181109] mtd: Giving out device 2 to NOR Partition 3 [ 1547.188201] 0x00000f300000-0x00000fe00000 : "NOR Partition 4" [ 1547.195743] mtd: Giving out device 3 to NOR Partition 4 [ 1547.202574] 0x00000fe00000-0x00000ff40000 : "NOR Partition 5" [ 1547.209759] mtd: Giving out device 4 to NOR Partition 5 [ 1547.216244] 0x00000ff40000-0x00000ff60000 : "NOR Partition 6 - DTB" [ 1547.223602] mtd: Giving out device 5 to NOR Partition 6 - DTB [ 1547.230273] 0x00000ff60000-0x00000ff80000 : "NOR Partition 7 - ENV" [ 1547.238674] mtd: Giving out device 6 to NOR Partition 7 - ENV [ 1547.246405] 0x00000ff80000-0x000010000000 : "NOR Partition 8 - u-boot" [ 1547.254371] mtd: Giving out device 7 to NOR Partition 8 - u-boot