From mboxrd@z Thu Jan 1 00:00:00 1970 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 017B6C433F5 for ; Sun, 2 Oct 2022 18:39:43 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 32F13848DC; Sun, 2 Oct 2022 20:39:41 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="R2xl840d"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7C87184949; Sun, 2 Oct 2022 20:39:39 +0200 (CEST) Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) (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 B43B0803D2 for ; Sun, 2 Oct 2022 20:39:36 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=maleisner@gmail.com Received: by mail-lj1-x233.google.com with SMTP id b6so9703182ljr.10 for ; Sun, 02 Oct 2022 11:39:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=j59x2MqSrNxPtaa6UmlZBPDXw7dSS3bN1kx+ZSFif/s=; b=R2xl840d1vI73ZXEHOgsTY/qRHWyZzYj9Oh4Bg8UpjLlaVjeSRPehx9Crz81NgW8o3 n+EraoNqXT+7dhcCFlJyRqmIYFiOgEjbz6UVr6YhSiugBfgzsmoMf+yTXHxFy8UjIYgU oDjPpjjbiuWcrhHxuV++bdIv4ax9z7DHab+BGlUXCcu9iyidGYoRJtJS1BhdCcqRmqjD sOpjVgNCQ24zvJQhR+Iq+jPbCU/UHfZDv6mJefeM2dFzPZpGD8Xowna6XxkPl0CuaRmu by0ncQ16dYABu7AmDdkdvRf0rR4nBrLs0XX48gRUIvN9xFnHb9MKwVqUb31bcpJXH20U 1jLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=j59x2MqSrNxPtaa6UmlZBPDXw7dSS3bN1kx+ZSFif/s=; b=eYSQvKhcrV5xIjOceKyt03KH0Vllw/nM3Nj4t+uFhfS5j76Y/SfBHR+U77e9zLI4OQ 8sAaCQCWT085sSf/WRIAMspgB8S8fuqx1MbTqlPF0tjQRC+TNEth9bDhH7blcaVr8W9D ba7ubhk8pTqVxbuZohG+NBcr4/OIpDDp/+BE7hgtVXb1NhMMYpZ1RGKqyz+cCTdVZTfY Dw+Mwy8SsGlAKq70SwbTaZcI4T4U+JFypiGY8uTvCrO9m+pfmY7WKlJRIVxabeUQBOH6 kiaUiMfJPxqynr6ii9femx49CW64xPt/s62FrAlCfkdbFER+bZjKJIZXP6acKLFuPkrX eKIQ== X-Gm-Message-State: ACrzQf2hgmnY4OgMKHHxnDNNkNOF4JWIUB61KQpL38uV8c2yjIBygX9o SS0xT7CRRgvg+5rhBh/5EA9Dm/Kms+zIO8XutrztgKFyPVzl X-Google-Smtp-Source: AMsMyM5vzfknUIomApV8uylYgcg7HyzkNEyxz77kLEB8ouI5CSAu2WWYOUCWPMHL/ke2jWxzLiSDDMUzyJ9UqiDWqYg= X-Received: by 2002:a2e:780b:0:b0:26c:1458:ddc3 with SMTP id t11-20020a2e780b000000b0026c1458ddc3mr5824949ljc.375.1664735975742; Sun, 02 Oct 2022 11:39:35 -0700 (PDT) MIME-Version: 1.0 References: <20220929125714.GY3044094@bill-the-cat> In-Reply-To: <20220929125714.GY3044094@bill-the-cat> From: marty leisner Date: Sun, 2 Oct 2022 14:38:58 -0400 Message-ID: Subject: Re: how u-boot handles the environment (rpi4, fat environment) To: Tom Rini Cc: u-boot@lists.denx.de Content-Type: multipart/mixed; boundary="0000000000007ab79c05ea118ce9" X-Content-Filtered-By: Mailman/MimeDel 2.1.39 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.6 at phobos.denx.de X-Virus-Status: Clean --0000000000007ab79c05ea118ce9 Content-Type: text/plain; charset="UTF-8" In order for fw_printenv/fw_setenv to work, I have to attach the attached patch. leisner@rpi4b:~/bin$ cat /etc/fw_env.config /boot/firmware/uboot.env 0x0000 0x20000 leisner@rpi4b:/usr/local/src/consulting/turf-tank/u-boot-2021.01+dfsg$ grep CONFIG_ENV .config CONFIG_ENV_SIZE=0x20000 CONFIG_ENV_VARS_UBOOT_CONFIG=y CONFIG_ENV_SUPPORT=y # CONFIG_ENV_OVERWRITE is not set # CONFIG_ENV_IS_NOWHERE is not set # CONFIG_ENV_IS_IN_EEPROM is not set CONFIG_ENV_IS_IN_FAT=y # CONFIG_ENV_IS_IN_EXT4 is not set # CONFIG_ENV_IS_IN_FLASH is not set # CONFIG_ENV_IS_IN_MMC is not set # CONFIG_ENV_IS_IN_NAND is not set # CONFIG_ENV_IS_IN_NVRAM is not set # CONFIG_ENV_IS_IN_ONENAND is not set # CONFIG_ENV_IS_IN_REMOTE is not set # CONFIG_ENV_IS_IN_SPI_FLASH is not set CONFIG_ENV_FAT_INTERFACE="mmc" CONFIG_ENV_FAT_DEVICE_AND_PART="0:1" CONFIG_ENV_FAT_FILE="uboot.env" CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y # CONFIG_ENV_APPEND is not set # CONFIG_ENV_WRITEABLE_LIST is not set # CONFIG_ENV_ACCESS_IGNORE_FORCE is not set I still get the "1" in the printenv output of the first env variable. But I was able to use setenv. Without the patch, on reboot I get: *** Warning - bad CRC, using default environment The version string (I'm using the ubuntu source) is: U-Boot 2021.01-gc7eed6f7-dirty (Sep 27 2022 - 20:05:05 -0400) On Thu, Sep 29, 2022 at 8:57 AM Tom Rini wrote: > On Sun, Sep 25, 2022 at 12:46:10PM -0400, marty leisner wrote: > > > I'm running ubuntu 20.04 server (which uses u-boot v2021.01 with minor > > changes/enhancements) > > > > fw_printenv doesn't seem to work -- it always comes up with a crc error > (I > > haven't tried fw_setenv yet). > > > > Is there a spec of how the environment works? I haven't seen one. > > > > Without this patch, I get: > > Warning: Bad CRC, using default environment > > > > The first environment variable has a "0x1" in front of it. > > When I apply this patch, things seem to work: > > > > diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c > > index 66cb9d2a..c85b471a 100644 > > --- a/tools/env/fw_env.c > > +++ b/tools/env/fw_env.c > > @@ -1457,8 +1457,8 @@ int fw_env_open(struct env_opts *opts) > > goto open_cleanup; > > } > > > > - crc0 = crc32(0, (uint8_t *)environment.data, ENV_SIZE); > > - > > + crc0 = crc32(0, (uint8_t *) (environment.data + 1) , ENV_SIZE - > 1); > > > > But I'm not at the phase of doing fw_setenv (I would have used a newer > > u-boot, but I'm getting resets on bootup (it works > > on a vanilla 20.04 system). > > Please include your /etc/fw_env.config file and relevant CONFIG_ENV > settings from the U-Boot build. > > -- > Tom > --0000000000007ab79c05ea118ce9 Content-Type: text/x-patch; charset="US-ASCII"; name="fw_env.c.diff" Content-Disposition: attachment; filename="fw_env.c.diff" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_l8roa0ou0 ZGlmZiAtLWdpdCBhL3Rvb2xzL2Vudi9md19lbnYuYyBiL3Rvb2xzL2Vudi9md19lbnYuYwppbmRl eCA2NmNiOWQyYS4uMWFjNDEzYjEgMTAwNjQ0Ci0tLSBhL3Rvb2xzL2Vudi9md19lbnYuYworKysg Yi90b29scy9lbnYvZndfZW52LmMKQEAgLTUxMyw3ICs1MTMsNyBAQCBpbnQgZndfZW52X2ZsdXNo KHN0cnVjdCBlbnZfb3B0cyAqb3B0cykKICAgICAgICAvKgogICAgICAgICAqIFVwZGF0ZSBDUkMK ICAgICAgICAgKi8KLSAgICAgICAqZW52aXJvbm1lbnQuY3JjID0gY3JjMzIoMCwgKHVpbnQ4X3Qg KikgZW52aXJvbm1lbnQuZGF0YSwgRU5WX1NJWkUpOworICAgICAgICplbnZpcm9ubWVudC5jcmMg PSBjcmMzMigwLCAodWludDhfdCAqKSBlbnZpcm9ubWVudC5kYXRhICsgMSwgRU5WX1NJWkUgLSAx KTsKIAogICAgICAgIC8qIHdyaXRlIGVudmlyb25tZW50IGJhY2sgdG8gZmxhc2ggKi8KICAgICAg ICBpZiAoZmxhc2hfaW8oT19SRFdSKSkgewpAQCAtMTQ1Nyw4ICsxNDU3LDggQEAgaW50IGZ3X2Vu dl9vcGVuKHN0cnVjdCBlbnZfb3B0cyAqb3B0cykKICAgICAgICAgICAgICAgIGdvdG8gb3Blbl9j bGVhbnVwOwogICAgICAgIH0KIAotICAgICAgIGNyYzAgPSBjcmMzMigwLCAodWludDhfdCAqKWVu dmlyb25tZW50LmRhdGEsIEVOVl9TSVpFKTsKLQorICAgICAgIGNyYzAgPSBjcmMzMigwLCAodWlu dDhfdCAqKSAoZW52aXJvbm1lbnQuZGF0YSArIDEpICwgRU5WX1NJWkUgLSAxKTsKKy8vICAgICBj cmMwID0gY3JjMzIoMCwgKHVpbnQ4X3QgKikgKGVudmlyb25tZW50LmRhdGEpICwgRU5WX1NJWkUp OwogICAgICAgIGNyYzBfb2sgPSAoY3JjMCA9PSAqZW52aXJvbm1lbnQuY3JjKTsKICAgICAgICBp ZiAoIWhhdmVfcmVkdW5kX2VudikgewogICAgICAgICAgICAgICAgaWYgKCFjcmMwX29rKSB7Cgo= --0000000000007ab79c05ea118ce9--