<?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>topic Re: Write u-Boot environment variable to SD card in i.MX Processors</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/Write-u-Boot-environment-variable-to-SD-card/m-p/1675461#M208092</link>
    <description>&lt;P&gt;Hello Khang,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, you can use a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;uEnv.txt&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;or&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;boot.scr&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;file to set u-Boot environment variables from the SD card. These methods are still valid and can be used with recent BSPs like hardknott 5.10.52.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To use the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;uEnv.txt&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;method, create a plain text file named 'uEnv.txt' in the root directory of your SD card. Add the environment variables you want to set, one per line, in the following format:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; variable_name=value &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, to set the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;ethaddr&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;variable, your uEnv.txt file should contain:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; ethaddr=00:11:22:33:44:55 &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Next, you need to modify the u-Boot configuration to read and apply the uEnv.txt file during the boot process. Add the following lines to your u-Boot configuration:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; # Load uEnv.txt from SD card load mmc ${mmcdev}:${mmcpart} ${loadaddr} uEnv.txt env import -t ${loadaddr} ${filesize} &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Alternatively, you can use the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;boot.scr&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;method. Create a plain text file with the same environment variable settings as in the uEnv.txt method, and then convert it to a boot.scr file using the following command:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n 'Boot script' -d input.txt boot.scr &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Place the generated boot.scr file in the root directory of your SD card. The u-Boot will automatically execute the script during the boot process, setting the environment variables accordingly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Both methods should work for setting u-Boot environment variables from the SD card. Choose the one that best fits your needs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;</description>
    <pubDate>Sun, 25 Jun 2023 09:59:25 GMT</pubDate>
    <dc:creator>giraffe508</dc:creator>
    <dc:date>2023-06-25T09:59:25Z</dc:date>
    <item>
      <title>Write u-Boot environment variable to SD card</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Write-u-Boot-environment-variable-to-SD-card/m-p/1675235#M208070</link>
      <description>&lt;P&gt;Dear Community,&lt;/P&gt;&lt;P&gt;We designed an iMX8MP based system booting from SD card only and we would like to know if there's any efficient way to set some u-Boot environment variable (such as the &lt;STRONG&gt;ethaddr&lt;/STRONG&gt;) into a file in the SD card before booting and being taken effect by the u-Boot then the kernel, please ?&lt;/P&gt;&lt;P&gt;This might be u-Boot relevant question and I thought about &lt;STRONG&gt;uEnv.txt&lt;/STRONG&gt; or &lt;STRONG&gt;boot.scr&lt;/STRONG&gt; script but I am not sure that they are not obsolete as I do not see them in the u-Boot of recent BSPs (we are using hardknott 5.10.52).&lt;/P&gt;&lt;P&gt;Thanks in advance for your advice.&lt;/P&gt;&lt;P&gt;Khang&lt;/P&gt;</description>
      <pubDate>Sat, 24 Jun 2023 15:06:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Write-u-Boot-environment-variable-to-SD-card/m-p/1675235#M208070</guid>
      <dc:creator>khang_letruong</dc:creator>
      <dc:date>2023-06-24T15:06:46Z</dc:date>
    </item>
    <item>
      <title>Re: Write u-Boot environment variable to SD card</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Write-u-Boot-environment-variable-to-SD-card/m-p/1675461#M208092</link>
      <description>&lt;P&gt;Hello Khang,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, you can use a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;uEnv.txt&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;or&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;boot.scr&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;file to set u-Boot environment variables from the SD card. These methods are still valid and can be used with recent BSPs like hardknott 5.10.52.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To use the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;uEnv.txt&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;method, create a plain text file named 'uEnv.txt' in the root directory of your SD card. Add the environment variables you want to set, one per line, in the following format:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; variable_name=value &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, to set the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;ethaddr&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;variable, your uEnv.txt file should contain:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; ethaddr=00:11:22:33:44:55 &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Next, you need to modify the u-Boot configuration to read and apply the uEnv.txt file during the boot process. Add the following lines to your u-Boot configuration:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; # Load uEnv.txt from SD card load mmc ${mmcdev}:${mmcpart} ${loadaddr} uEnv.txt env import -t ${loadaddr} ${filesize} &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Alternatively, you can use the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;boot.scr&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;method. Create a plain text file with the same environment variable settings as in the uEnv.txt method, and then convert it to a boot.scr file using the following command:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n 'Boot script' -d input.txt boot.scr &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Place the generated boot.scr file in the root directory of your SD card. The u-Boot will automatically execute the script during the boot process, setting the environment variables accordingly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Both methods should work for setting u-Boot environment variables from the SD card. Choose the one that best fits your needs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;</description>
      <pubDate>Sun, 25 Jun 2023 09:59:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Write-u-Boot-environment-variable-to-SD-card/m-p/1675461#M208092</guid>
      <dc:creator>giraffe508</dc:creator>
      <dc:date>2023-06-25T09:59:25Z</dc:date>
    </item>
  </channel>
</rss>

