Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1A4B0C433EF for ; Mon, 29 Nov 2021 15:25:43 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8BD1082F9D; Mon, 29 Nov 2021 16:25:40 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="U3gWENk0"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1898B82FAB; Mon, 29 Nov 2021 16:25:38 +0100 (CET) Received: from mail-qk1-x732.google.com (mail-qk1-x732.google.com [IPv6:2607:f8b0:4864:20::732]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 755CB82F8B for ; Mon, 29 Nov 2021 16:25:34 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-qk1-x732.google.com with SMTP id p4so23216476qkm.7 for ; Mon, 29 Nov 2021 07:25:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=dnpAfVzrPU8d608jTWA9TJwvGYccH3eTHHDgChY4Upg=; b=U3gWENk0Pd4xuvip9Q0XqKngJd7ihirlN2lWQ5/XU0ISQtHNjcH6pVhoLZJZbaauwV BX4ZONftidqYKlxkgAGRGWkYtMm9aqdSo119CNlIA1JuutVCXCGQ4cy18n1wBsEjF9tP VFug4MXHA+I6Lc2eZCK7e3CTo69Mqap/2amF8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=dnpAfVzrPU8d608jTWA9TJwvGYccH3eTHHDgChY4Upg=; b=7U7FilAFhH2e3IazMK49LPiWvfsHuHGY+U8Vc8IrV08Q87F9L9yb6IpHWXDmFooDsO dZGfJSM8B8EEEuWWwh53ZOZx+orIUwU+V8uRTY7LAwoTV7pGpUI0fhKpid2rO62IYRDy yCU7Ddr93bg0M22U9sJE/obiPHnIzNqf+hwNWpiA3NqCbOUmAklGxsp2sR/Ol7nm+gCh ElKYBpbr29nYWtwlL+y9bYw9l347QoyEOn8D+xd7LQxAwQV1FAd5MErJUfHLMeKX549F E6tUpRfEpj2UAgbuhSiq8N67+Z3QhuwvT/gLrr2LZRXOWGSejfwjKGVmosDrvLzkaIqi yY+A== X-Gm-Message-State: AOAM531BqrzXhJxoETY29CI6pQ5IZfYAz1mkKwNKC1t8vnP8sfWhLSGC MmvyUy2t44g+i/rj/NIrlo1bnw== X-Google-Smtp-Source: ABdhPJyUk+JS5FjyBo10V3ZWvET+doiOJFQGIz9Dpa9ZitonD/vjsDCXHTYDZmGbL+Sluzx/Ebc4Mg== X-Received: by 2002:a05:620a:d86:: with SMTP id q6mr39222328qkl.138.1638199533255; Mon, 29 Nov 2021 07:25:33 -0800 (PST) Received: from bill-the-cat (2603-6081-7b01-cbda-edec-aa90-ebd5-017a.res6.spectrum.com. [2603:6081:7b01:cbda:edec:aa90:ebd5:17a]) by smtp.gmail.com with ESMTPSA id w63sm6955514qkd.88.2021.11.29.07.25.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Nov 2021 07:25:31 -0800 (PST) Date: Mon, 29 Nov 2021 10:25:30 -0500 From: Tom Rini To: Francesco Dolcini Cc: u-boot@lists.denx.de Subject: Re: [BUG] emmc `env erase` erase unrelated data Message-ID: <20211129152530.GI24579@bill-the-cat> References: <20211129132123.GA306087@francesco-nb.int.toradex.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="9jvRriNXkuZHA3Qm" Content-Disposition: inline In-Reply-To: <20211129132123.GA306087@francesco-nb.int.toradex.com> X-Clacks-Overhead: GNU Terry Pratchett X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.37 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean --9jvRriNXkuZHA3Qm Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Nov 29, 2021 at 02:21:23PM +0100, Francesco Dolcini wrote: > Hello, > I noticed an issue with env erase command when environment is stored in a > emmc device, in case start/end are not aligned to the emmc erase groups > size additional data is erased with just a warning. >=20 > ``` > Erasing Environment on MMC... >=20 > Caution! Your devices Erase group is 0x400 > The erase range would be change to 0xf800~0xfbff > ``` >=20 > Output from `mmc info`: >=20 > ``` > Device: FSL_SDHC > Manufacturer ID: 13 > OEM: 14e > Name: S0J56 > Bus Speed: 200000000 > Mode: HS400 (200MHz) > Rd Block Len: 512 > MMC version 5.1 > High Capacity: Yes > Capacity: 14.8 GiB > Bus Width: 8-bit DDR > Erase Group Size: 512 KiB > HC WP Group Size: 8 MiB > User Capacity: 14.8 GiB WRREL > Boot Capacity: 31.5 MiB ENH > RPMB Capacity: 4 MiB ENH > ``` >=20 > I do not think that this is the correct behavior, I think that in case > the env is not aligned to the erase block size the erase should either > fail or fall back to just writing 0xff. Not sure if just changing > `mmc_berase()` is going to affect any other use case in which is valid > to have a non-aligned start/size and just erase around it after a > warning. >=20 > Any comment? Largely intentional behavior. Perhaps the help text at least should be updated to note that environment size for MMC needs to be a multiple of erase block size? And further that when using redundant environment it's strongly encouraged to make sure each environment is on its own erase block. --=20 Tom --9jvRriNXkuZHA3Qm Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmGk8OYACgkQFHw5/5Y0 tyyiXwv7Bcp0yrdZ3oJ7QlEr8grDA9TLl+QVA9uxrtCRC2Ro5WdCHPalJg55Tjj2 6r4G4nvb02n53H+8yFVpAxFjAPnBb0N9Wzrr1MviI691bY68cS2xwghsglozfngo JPXTzTjgv+i3VWzWCdmU3QtvpD3T0E3nABKrYGai7InDlQE3R2kf0E/FPAmKm2FZ 8nBsfX4WcBHynczRfjTUt35ROd3PnJyZhIIkOMgCs6AYDqpFlyqzJnNXPlBLp+Fp dX4bi+SEMkWeHo2oNtaiaJHHiYb3b+c+dDIO0ASth/4Unp8pm8mvmmZwZ1uPyhjX oPzZgj+YXbkHhvyblA0Z5vistvyVj5pinDIKg0mCcdnJwv201VS0kPgMZO4AHeI/ 2FMBnhv7qudu0eqlGS+8xhBuXRsXjynpdf8jW4W9jtU0ewNxs2vHKYcE9JMg2I38 /rEq1b/bZQEQCom7Yy50kQyye/XmP4wCLbju8OFWJMKccc624NwhWidnIA21cw6m KVQeSOwp =LJir -----END PGP SIGNATURE----- --9jvRriNXkuZHA3Qm--