From: Joakim Tjernlund Date: Wed, 6 May 2020 09:21:21 +0000 Subject: [PATCH 2/2] env: add CONFIG_ENV_SECT_SIZE_AUTO In-Reply-To: <62f1f154-269f-1e5b-beb4-7cd820ec5e8c@prevas.dk> References: <20200506084701.8076-1-rasmus.villemoes@prevas.dk> <20200506084701.8076-3-rasmus.villemoes@prevas.dk> <62f1f154-269f-1e5b-beb4-7cd820ec5e8c@prevas.dk> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Wed, 2020-05-06 at 11:11 +0200, Rasmus Villemoes wrote: > > On 06/05/2020 10.59, Joakim Tjernlund wrote: > > On Wed, 2020-05-06 at 10:47 +0200, Rasmus Villemoes wrote: > > > At first, I wanted to allow setting CONFIG_ENV_SECT_SIZE to 0 to mean > > > "use the erase size the chip reports", but that config > > > option is used in a number of preprocessor conditionals, and shared > > > between ENV_IS_IN_FLASH and ENV_IS_IN_SPI_FLASH. > > > > I see, It had been good if one could have used 0 > > > > > So instead, introduce a new boolean config option, which for now can > > > only be used with ENV_IS_IN_SPI_FLASH. If left off, there's no change > > > in behaviour. > > > > Please don't stop at just SPI Flash, we could use this for common NOR flashes too. > > Certainly, but I don't have any such hardware, and the code also seems > to require a bit more work than the sf.c case due to the preprocessor > uses. It's quite possible that the > > #if CONFIG_ENV_SECT_SIZE > CONFIG_ENV_SIZE > foo; bar; > #endif > > can be replaced by > > u32 sect_size = CONFIG_ENV_SECT_SIZE; > if (IS_ENABLED(CONFIG_ENV_SECT_SIZE_AUTO)) > sect_size = [...however we want to get that info....] > > if (sect_size > CONFIG_ENV_SIZE { > foo; bar; > } > > but then there's the uses of CONFIG_ENV_SECT_SIZE to initialize end_addr > and end_addr_new. So I think doing the flash.c part requires someone > with hardware access. I can test NOR Flash ,I am on an older u-boot ATM but fw_setenv stuff should be simple to backport How would fw_env.config be dealt with? Just ignored when auto size? Jocke