We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

AR# 64357

Embedded Linux - flashcp Command Fails When Writing Images Larger than 16MiB


I am trying to write to a 128Mib flash device using the flashcp command.

The image I am trying to write is more than 16MiB.

I am using the following command:

flashcp -v /mnt/image.ub/ /dev/mtd2

Approximately half-way through the write operation, a Linux kernel internal errors occurs:

root@zynq-microzed-z7020:~# flashcp -v /mnt/image.ub /dev/mtd2
Erasing blocks: 1789/1789 (100%)
Writing data: 7154k/0k (100%))
Verifying data: 7154k/0k (100%))
root@zynq-microzed-z7020:~# flashcp -v /mnt/from_cust/image.ub /dev/mtd2
Erasing blocks: 4859/4859 (100%)
Writing data: 11140k/0k (19433%)Unable to handle kernel paging request at virtual address ef800000
pgd = ee37c000
[ef800000] *pgd=00000000
Internal error: Oops: 5 [#1] PREEMPT SMP ARM
Modules linked in: ipv6
CPU: 0 PID: 442 Comm: spi32766 Not tainted 3.18.0-xilinx-g3913e72 #10
task: eeb14040 ti: ee2aa000 task.ti: ee2aa000
PC is at zynq_qspi_fill_tx_fifo+0x28/0x5c
LR is at zynq_qspi_start_transfer+0x50/0xe8
pc : [<c02f9b20>] lr : [<c02fa37c>] psr: a00f0013
sp : ee2abe90 ip : ef800000 fp : 00000000
r10: c0a99d50 r9 : 0000000a r8 : 00000000
r7 : 00000004 r6 : 00000100 r5 : ee9d7dbc r4 : ee26a3b0
r3 : f006e000 r2 : 00000000 r1 : 0000003f r0 : ee26a3b0
Flags: NzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel
Control: 18c5387d Table: 2e37c04a DAC: 00000015
Process spi32766 (pid: 442, stack limit = 0xee2aa238)
Stack: (0xee2abe90 to 0xee2ac000)
be80: ee26a000 ee26ec00 ee9d7dbc ee9d7d50
bea0: ee9d7dbc ee26a000 00000004 c02f7064 c02f6ff8 ee26a30c ee26a000 ee9d7d50
bec0: 00000000 c128124c 00000001 00000000 00000000 c02f7820 eeb14040 ee2aa030
bee0: 00000001 c04d4700 c128124c ee26a30c ee26a2d8 ee2aa000 ee2aa010 c128124c
bf00: 00000001 00000000 00000000 c003da68 ee26dc00 00000000 ee26a2d8 c003d9bc
bf20: 00000000 00000000 00000000 c003d958 ee2aa000 00000000 eeb14040 ee26a2d8
bf40: 00000000 00000000 dead4ead ffffffff ffffffff c0acf648 00000000 00000000
bf60: c06019f0 ee2abf64 ee2abf64 00000000 00000000 dead4ead ffffffff ffffffff
bf80: c0acf648 00000000 00000000 c06019f0 ee2abf90 ee2abf90 ee2abfac ee26dc00
bfa0: c003d87c 00000000 00000000 c000e8e8 00000000 00000000 00000000 00000000
bfc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
bfe0: 00000000 00000000 00000000 00000000 00000013 00000000 35777cff 96ff7e27
[<c02f9b20>] (zynq_qspi_fill_tx_fifo) from [<c02fa37c>] (zynq_qspi_start_transfer+0x50/0xe8)
[<c02fa37c>] (zynq_qspi_start_transfer) from [<c02f7064>] (spi_transfer_one_message+0x6c/0x1c8)
[<c02f7064>] (spi_transfer_one_message) from [<c02f7820>] (spi_pump_messages+0x42c/0x468)
[<c02f7820>] (spi_pump_messages) from [<c003da68>] (kthread_worker_fn+0xac/0x158)
[<c003da68>] (kthread_worker_fn) from [<c003d958>] (kthread+0xdc/0xf0)
[<c003d958>] (kthread) from [<c000e8e8>] (ret_from_fork+0x14/0x2c)
Code: e590c010 e5903000 e35c0000 0a000005 (e59cc000)
---[ end trace 244300203ab18e73 ]---


To work around this issue, you can do either of the following:

Note: The source code modification outlined below has been integrated into the official Xilinx GitHub source repository on git.xilinx.com as of the 2015.1 release tag. 

1. You can use the dd command to copy over the image instead of the flashcp command:

dd if=/mnt/image.ub of=/dev/mtd2

2.Alternatively, you can make the following changes to m25p80.c in the following location in your Linux source repository:


The bolded line below should be added and the other commented out.

+++ devices/m25p80.c 2015-02-23 18:07:08.000000000 +0100
@@ -102,7 +102,7 @@
spi_sync(spi, &m);
- *retlen += m.actual_length - cmd_sz;
+ *retlen = m.actual_length - cmd_sz;
static inline unsigned int m25p80_rx_nbits(struct spi_nor *nor)

Once the change is complete, recompile the Linux kernel sources.
AR# 64357
Date 06/18/2015
Status Active
Type General Article
  • Zynq-7000
  • PetaLinux - 2014.4
Page Bookmarked