<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>i.MX ProcessorsのトピックRe: Add validation to u-boot cmd setenv</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/Add-validation-to-u-boot-cmd-setenv/m-p/1915412#M226530</link>
    <description>&lt;P&gt;Correct function was &lt;STRONG&gt;_do_env_set&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 23 Jul 2024 18:00:02 GMT</pubDate>
    <dc:creator>pilotnite</dc:creator>
    <dc:date>2024-07-23T18:00:02Z</dc:date>
    <item>
      <title>Add validation to u-boot cmd setenv</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Add-validation-to-u-boot-cmd-setenv/m-p/1915069#M226511</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;I want to add a validation rule to a custom variable I'm defining in the u-boot environment. Let's call it &lt;STRONG&gt;foo&lt;/STRONG&gt;, and the only values foo should accept are &lt;STRONG&gt;null&lt;/STRONG&gt; or &lt;STRONG&gt;ttyLP0,115200&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;My u-boot environment is protected, so only specific variables are whitelisted. &lt;STRONG&gt;foo&lt;/STRONG&gt; will be whitelisted.&lt;/P&gt;&lt;P&gt;I was able to achieve this for &lt;STRONG&gt;fw_setenv&lt;/STRONG&gt;&amp;nbsp;by creating patch for &lt;STRONG&gt;libubootenv&lt;/STRONG&gt;&amp;nbsp;under&amp;nbsp;&lt;STRONG&gt;src/fw_printenv.c&lt;/STRONG&gt; for the Linux user-space:&lt;/P&gt;&lt;PRE&gt;root@localhost:~# fw_setenv foo woof
Error: invalid value for "foo": woof
root@localhost:~# &lt;/PRE&gt;&lt;PRE&gt;root@localhost:~# fw_setenv foo null
root@localhost:~# fw_printenv | grep foo
foo=null&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, I'm trying to figure out how to do this for u-boot-imx &lt;STRONG&gt;setenv&lt;/STRONG&gt;. I looked into the &lt;STRONG&gt;cmd/nvedit.c&lt;/STRONG&gt; function &lt;STRONG&gt;env_set&lt;/STRONG&gt; and applied the same logic, but that did not work. Am I in the right place for &lt;STRONG&gt;setenv&lt;/STRONG&gt;, or is there different code for &lt;STRONG&gt;setenv&lt;/STRONG&gt;?&lt;/P&gt;&lt;P&gt;Any help will be highly appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers,&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jul 2024 12:25:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Add-validation-to-u-boot-cmd-setenv/m-p/1915069#M226511</guid>
      <dc:creator>pilotnite</dc:creator>
      <dc:date>2024-07-23T12:25:48Z</dc:date>
    </item>
    <item>
      <title>Re: Add validation to u-boot cmd setenv</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Add-validation-to-u-boot-cmd-setenv/m-p/1915187#M226522</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You must saveenv the variables, but please check this page&amp;gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://docs.u-boot.org/en/latest/usage/environment.html" target="_blank"&gt;https://docs.u-boot.org/en/latest/usage/environment.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.nxp.com/t5/i-MX-Processors/U-boot-Environment-Variables-Source-Code/m-p/974719" target="_blank"&gt;https://community.nxp.com/t5/i-MX-Processors/U-boot-Environment-Variables-Source-Code/m-p/974719&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jul 2024 14:52:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Add-validation-to-u-boot-cmd-setenv/m-p/1915187#M226522</guid>
      <dc:creator>Bio_TICFSL</dc:creator>
      <dc:date>2024-07-23T14:52:04Z</dc:date>
    </item>
    <item>
      <title>Re: Add validation to u-boot cmd setenv</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Add-validation-to-u-boot-cmd-setenv/m-p/1915207#M226524</link>
      <description>&lt;P&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/34846"&gt;@Bio_TICFSL&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the feedback and the links.&lt;/P&gt;&lt;P&gt;Maybe I was not clear enough, but what I'm looking for is the C-code implementation of &lt;STRONG&gt;setenv&lt;/STRONG&gt; so I can add my validation rule.&lt;/P&gt;&lt;P&gt;So when a user executes from the u-boot prompt:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;=&amp;gt; setenv foo 'woof'&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P&gt;It should reject it with an error. It should only accept &lt;STRONG&gt;null&lt;/STRONG&gt; or &lt;STRONG&gt;ttyLP0,115200&lt;/STRONG&gt; as input values, or it should reset the value back to its original state. Similar to environment variables &lt;STRONG&gt;serial#&lt;/STRONG&gt; and &lt;STRONG&gt;ethaddr&lt;/STRONG&gt;, which you cannot reset. You can &lt;STRONG&gt;setenv&lt;/STRONG&gt; and&amp;nbsp;&lt;SPAN&gt;&lt;STRONG&gt;saveenv&lt;/STRONG&gt;, but on the next reset, it will set back to its original value.&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P&gt;As I explained in my first post, I did add the code in &lt;STRONG&gt;cmd/nvedit.c&lt;/STRONG&gt; function &lt;STRONG&gt;env_set&lt;/STRONG&gt;, but I'm not sure if this is the right function for &lt;STRONG&gt;setenv&lt;/STRONG&gt; or if there is another function call.&lt;/P&gt;&lt;P&gt;I hope I have made my request clearer now. What I'm trying to achieve is a way to enforce validation rules directly within the &lt;STRONG&gt;setenv&lt;/STRONG&gt; function in the u-boot code.&lt;/P&gt;&lt;P&gt;Thank you for your assistance.&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jul 2024 15:23:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Add-validation-to-u-boot-cmd-setenv/m-p/1915207#M226524</guid>
      <dc:creator>pilotnite</dc:creator>
      <dc:date>2024-07-23T15:23:21Z</dc:date>
    </item>
    <item>
      <title>Re: Add validation to u-boot cmd setenv</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Add-validation-to-u-boot-cmd-setenv/m-p/1915411#M226529</link>
      <description>&lt;P&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/34846"&gt;@Bio_TICFSL&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was able to find the right function and patch it through with my validation rule. Correct function was &lt;STRONG&gt;_do_end_set&lt;/STRONG&gt; in &lt;STRONG&gt;cmd/nvedit.c&lt;/STRONG&gt;.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;Autoboot in 3 seconds

=&amp;gt; setenv current_console woof
## Error: invalid value for "current_console": woof
=&amp;gt; setenv current_console null
=&amp;gt; printenv current_console
current_console=null&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your support.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jul 2024 17:57:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Add-validation-to-u-boot-cmd-setenv/m-p/1915411#M226529</guid>
      <dc:creator>pilotnite</dc:creator>
      <dc:date>2024-07-23T17:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: Add validation to u-boot cmd setenv</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Add-validation-to-u-boot-cmd-setenv/m-p/1915412#M226530</link>
      <description>&lt;P&gt;Correct function was &lt;STRONG&gt;_do_env_set&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jul 2024 18:00:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Add-validation-to-u-boot-cmd-setenv/m-p/1915412#M226530</guid>
      <dc:creator>pilotnite</dc:creator>
      <dc:date>2024-07-23T18:00:02Z</dc:date>
    </item>
  </channel>
</rss>

