<br><br><div class="gmail_quote">2011/12/28 Anders Darander <span dir="ltr">&lt;<a href="mailto:anders@chargestorm.se" target="_blank">anders@chargestorm.se</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div><br>
On 27 dec 2011, at 21:35, &quot;Frans Meulenbroeks&quot; &lt;<a href="mailto:fransmeulenbroeks@gmail.com" target="_blank">fransmeulenbroeks@gmail.com</a>&gt; wrote:<br>
<br>
&gt; This adds building the u-boot tools for target.<br>
&gt; (fw_printenv, fw_setenv).<br>
&gt; They are put into a separate package<br>
&gt; With these files it becomes possible to modify<br>
&gt; the u-boot environment when linux is booted<br>
&gt;<br>
&gt; The #ifdef&#39;s in fw_env.h were needed to avoid compilation issues<br>
&gt; The constants have been changed to more meaningful defaults<br>
&gt; (as 128k flash pages are much more common than 4k pages)<br>
&gt; but can be overridden using a configuration file.<br>
&gt;<br>
&gt; This resolves bug 1800<br>
&gt;<br>
&gt; Signed-off-by: Frans Meulenbroeks &lt;<a href="mailto:fransmeulenbroeks@gmail.com" target="_blank">fransmeulenbroeks@gmail.com</a>&gt;<br>
&gt;<br>
&gt; ---<br>
&gt; Note: development and testing was done under openembedded classic.<br>
&gt; I&#39;ve tested it there quite heavily (for mpc8313 if that matters).<br>
&gt; I was requested to provide a patch for oe-core too (to resolve bug 1800)<br>
&gt; so here it is, although at the moment I am unable to test the patch for oe-core.<br>
&gt; I suggest that this is carefully reviewed and tested before being merged.<br>
<br>
<br>
</div><div>&gt; create mode 100644 meta/recipes-bsp/u-boot/files/tools_fwenv.patch<br>
&gt;<br>
&gt; diff --git a/meta/recipes-bsp/u-boot/files/tools_fwenv.patch b/meta/recipes-bsp/u-boot/files/tools_fwenv.patch<br>
&gt; new file mode 100644<br>
&gt; index 0000000..8e87800<br>
&gt; --- /dev/null<br>
&gt; +++ b/meta/recipes-bsp/u-boot/files/tools_fwenv.patch<br>
&gt; @@ -0,0 +1,48 @@<br>
&gt; +Index: u-boot-2011.03/tools/env/fw_env.h<br>
&gt; +===================================================================<br>
</div>&gt; +--- u-boot-2011.03.orig/tools/env/fw_env.h    2011-03-31 23:45:36.000000000 +0200++++ u-boot-2011.03/tools/env/fw_env.h    2011-12-02 13:55:24.667278362 +0100<br>
<div>&gt; +@@ -27,25 +27,35 @@<br>
&gt; +  * See included &quot;fw_env.config&quot; sample file (TRAB board)<br>
&gt; +  * for notes on configuration.<br>
&gt; +  */<br>
&gt; +-#define CONFIG_FILE     &quot;/etc/fw_env.config&quot;<br>
&gt; ++//#define CONFIG_FILE     &quot;/etc/fw_env.config&quot;<br>
<br>
</div>Why do you remove the default for CONFIG_FILE?<br>
I haven&#39;t the u-boot code here, but isn&#39;t there a check for the configuration file in the code? Thus, you would still get compiled in defaults if no config file is found?<br></blockquote><div><br>Good catch.<br>This was based on work I did for a project a while ago.<br>

Didn&#39;t have time to submit a patch then and decided the Xmas holiday was a good point in time to upstream this, but apparently I overlooked this local change.<br><br>I peeked into the code (tools/env/fw_env.c). If config file is used it does uses the values in it, otherwise it fails. It does not use the built-in values in that case (which imho would be preferable)<br>

Anyway, for this specific project it was decided to use hardcoded values, and that crept in.<br>I&#39;ll see if I can come up with a patch to use the default values if the config file cannot be opened.<br> <br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">


<div><br>
&gt; ++<br>
&gt; ++#include &quot;config.h&quot;<br>
&gt; +<br>
&gt; + #define HAVE_REDUND /* For systems with 2 env sectors */<br>
&gt; +-#define DEVICE1_NAME      &quot;/dev/mtd1&quot;<br>
&gt; +-#define DEVICE2_NAME      &quot;/dev/mtd2&quot;<br>
&gt; ++#define DEVICE1_NAME      &quot;/dev/mtd0&quot;<br>
&gt; ++#define DEVICE2_NAME      &quot;/dev/mtd0&quot;<br>
<br>
</div>Would this really be a more comman case than he original defines? (Personally, I&#39;m usually using the config file, so this doesn&#39;t really matter. But I&#39;d still question changing these to mtd0...)<br></blockquote>

<div>I can live with either value. This was what was used in our project. <br>Personally I&#39;m somewhat inclined to keep the # of partitions small, so I am less inclined to make two partitions for the env.<br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">


<div><br>
&gt; + #define DEVICE1_OFFSET    0x0000<br>
&gt; +-#define ENV1_SIZE         0x4000<br>
&gt; +-#define DEVICE1_ESIZE     0x4000<br>
&gt; +-#define DEVICE2_OFFSET    0x0000<br>
&gt; +-#define ENV2_SIZE         0x4000<br>
&gt; +-#define DEVICE2_ESIZE     0x4000<br>
&gt; ++#define ENV1_SIZE         0x2000<br>
&gt; ++#define DEVICE1_ESIZE     0x20000<br>
&gt; ++#define DEVICE1_ENVSECTORS     1<br>
&gt; ++#define DEVICE2_OFFSET    0x20000<br>
&gt; ++#define ENV2_SIZE         0x2000<br>
&gt; ++#define DEVICE2_ESIZE     0x20000<br>
&gt; ++#define DEVICE2_ENVSECTORS     1<br>
<br>
</div>Ok, I can agree with you that 128k pages are more common, thus that could be a sensible default.<br>
<br>
I can also see a few reasons for changing the size of the environments, ENV1_SIZE and ENV2_SIZE, but there is no reason given in the commit log.<br>
<br></blockquote><div>Again probably a personal preference that crept in. <br>I did a quick grep: in u-boot/include/configs 146 boards have a size of 0x2000, and 78 have a size of 0x4000, so it seems 0x2000 is more used.<br>

THen again perhaps the code should be modified to make use of whatever config/include says.<br></div></div><br>I&#39;ll see if I can come up with an update.<br>But actually the most important part of this patch is to add the code in .inc and .bb to compile the tools.<br>
<br>Best regards, Frans<br><br>PS: it could also be decided to make a separate u-boot-env recipe.<br>PPS: if interested in why fw_prntenv is compiled with HOSTCC: see this thread: <a href="http://old.nabble.com/-U-Boot---PATCH-1-4--tools%3A-enable-img2srec-for-%22all%22-target-td29440508.html#a29440510">http://old.nabble.com/-U-Boot---PATCH-1-4--tools%3A-enable-img2srec-for-%22all%22-target-td29440508.html#a29440510</a><br>
discussion starts somewhere halfway the thread.<br><br>