From: =?UTF-8?Q?S=c3=a9bastien_Szymanski?= Date: Fri, 20 Jan 2017 18:32:49 +0100 Subject: [U-Boot] ext4: crash when writing a file In-Reply-To: <2757307.t5dS6qHjZC@sbruens-linux> References: <9c9637dd-582d-ac8a-fb71-ee5dcb8307bb@armadeus.com> <2757307.t5dS6qHjZC@sbruens-linux> Message-ID: <90bd01f1-165d-6fbb-3328-97b497c439d9@armadeus.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi, sorry for the late answer. > So to restate what you are doing: > > 1. You have a partitioned MMC, where the 2nd partition starts at block > 264192/0x40800 > 2. You load a 93958144 byte (~90 MB) file via TFTP to ${loadaddr} > 3. You write this partition image to 0x40800 using "mmc write" > 4. You load another 5345128 byte (5 MB) file via TFTP to $loadaddr > 5. You try to write this file to the 2nd partition, which now is ext4 > formatted, and already contains a file of the same name, i.e. boot/opos6ul- > linux.bin That's right. > > > Actually, I can't reproduce the crash. Maybe you have corrupted part of the > memory when loading the image, e.g. overwritten part of u-boot or its heap. > > Things you can try: > a) reboot the system after loading/writing the partion image. > b) checking the fs contents after the reboot, e.g "ls mmc 0:2 /boot" No issue here. > c) overwriting opos6ul-linux.bin with just a single byte, e.g "ext4write mmc > 0:2 0x0 /boot/opos6ul-linux.bin 1" It doesn't crash here. On the u-boot sandbox I can write up to 256Ko. When I try 512Ko it crashes. > d) transferring back the partition image to your host and running fschk on it The partition is fine when transferred back to my host. > > You may also able to reproduce this using the u-boot sandbox. I'm able to reproduce it using the u-boot sandbox. I've created a disk image as explained in board/sandbox/README.sandbox "Block Device Emulation": Command (m for help): p Disk /dev/loop0: 3 GiB, 3221225472 bytes, 6291456 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0xd8192f55 Device Boot Start End Sectors Size Id Type /dev/loop0p1 2048 264191 262144 128M 83 Linux /dev/loop0p2 264192 4458495 4194304 2G 83 Linux Then I use dd to emulate the mmc write command since there is no host write command: dd if=/tftproot/opos6ul-rootfs.ext4 of=/dev/loop0p2 The partition seems to be fine according to fsck.ext4: e2fsck 1.43.3 (04-Sep-2016) "ROOTFS": clean, 3830/4312 files, 73797/88390 blocks I can mount it and see its content. Then under the sandbox I do the following: U-Boot 2017.01-00002-g558e41e-dirty (Jan 20 2017 - 16:19:47 +0100) DRAM: 256 MiB MMC: Using default environment In: serial Out: serial Err: serial SCSI: Net: No ethernet found. IDE: Bus 0: not available => host bind 0 /tftproot/rootfs.raw => ls host 0:2 1024 . 1024 .. 16384 lost+found 1024 var 1024 run 1024 root 1024 media 1024 mnt 1024 tmp 3 lib32 1024 usr 1024 proc 1024 dev 1024 boot 1024 sys 3072 sbin 3072 bin 11 linuxrc 1024 etc 1024 opt 3072 lib => ls host 0:2 /boot 1024 . 1024 .. 26909 imx6ul-opos6uldev.dtb 1 dtbs 5359984 opos6ul-linux.bin => host load hostfs - 0 /tftproot/opos6ul-linux.bin 5359984 bytes read in 2 ms (2.5 GiB/s) => printenv filesize filesize=51c970 => ext4write host 0:2 0 /boot/opos6ul-linux.bin ${filesize} File System is consistent file found, deleting update journal finished File System is consistent update journal finished Segmentation fault Regards, > > Kind regards, > > Stefan S?bastien Szymanski