mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Antony Pavlov <antonynpavlov@gmail.com>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Peter Mamonov <piton@cs.niisi.ras.ru>, barebox@lists.infradead.org
Subject: memcpy strange behaviour
Date: Wed, 4 Nov 2015 11:04:33 +0300	[thread overview]
Message-ID: <20151104110433.696aef0a00e53bb950e97674@gmail.com> (raw)

Hi!

Peter has reported on strange barebox memcpy command behaviour on his MIPS board:

  he copies a file to memory using memcpy and then copyies appropriate memory contents
  back to another file. Next he checks files md5sum and the sums are differ.

I have reproduced the problem on Qemu VersatilePB ARM board.

Here is an instruction.

Configure barebox:

$ cd barebox.git
$ export ARCH=arm
$ export CROSS_COMPILE=<your cross compiler prefix>
$ make versatilepb_defconfig
$ sed -i "s/^# CONFIG_CMD_MD5SUM.*$/CONFIG_CMD_MD5SUM=y/" .config

Prepare testfile on host and compile:

$ dd if=/dev/zero bs=1 count=4414 | tr "\000" "\377" > defaultenv/defaultenv-2-base/testfile
$ make
...

Run barebox under qemu:

$ qemu-system-arm -M versatilepb -nographic -monitor null -kernel arch/arm/pbl/zbarebox -serial stdio
...
barebox# memcpy -s /env/testfile 0 0x01000000

barebox# memcpy -d _testfile 0x01000000 0 4414

barebox# md5sum /env/testfile _testfile
bf8278051ba8de868def083bcc209002  /env/testfile 0x00000000 ... 0xffffffffffffffff
e295c2bfe32498e03531017443120e89  _testfile     0x00000000 ... 0xffffffffffffffff

barebox# memcmp -s /env/testfile -d _testfile 0 0
files differ at offset 4408

barebox# md -s /env/testfile 4400
00001130: ffffffff ffffffff ffffffff ffffffff                ..............

barebox# md -s _testfile 4400
00001130: ffffffff ffffffff 00000000 ffff0000                ..............

barebox# md -b 0x01001130+0xe
01001130: ff ff ff ff ff ff ff ff 00 00 00 00 00 00          ..............

barebox# md -b -s /env/testfile 0x1130+0xe
00001130: ff ff ff ff ff ff ff ff ff ff ff ff ff ff          ..............

So you see that last 6 bytes have not been copied.

Please comment this report!

-- 
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2015-11-04  7:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-04  8:04 Antony Pavlov [this message]
2015-11-04  8:36 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151104110433.696aef0a00e53bb950e97674@gmail.com \
    --to=antonynpavlov@gmail.com \
    --cc=barebox@lists.infradead.org \
    --cc=piton@cs.niisi.ras.ru \
    --cc=s.hauer@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox