You've already forked slimbootloader.github.io
mirror of
https://github.com/Dasharo/slimbootloader.github.io.git
synced 2026-03-06 15:26:36 -08:00
272 lines
20 KiB
HTML
272 lines
20 KiB
HTML
<!DOCTYPE html>
|
||
<html class="writer-html5" lang="en" >
|
||
<head>
|
||
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />
|
||
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||
<title>Boot MicroPython — Slim Bootloader 1.0 documentation</title>
|
||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
||
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
|
||
<link rel="stylesheet" href="../_static/graphviz.css" type="text/css" />
|
||
<link rel="stylesheet" href="../_static/custom.css" type="text/css" />
|
||
<link rel="shortcut icon" href="../_static/sbl_logo_blue_32x32_icon.ico"/>
|
||
<!--[if lt IE 9]>
|
||
<script src="../_static/js/html5shiv.min.js"></script>
|
||
<![endif]-->
|
||
|
||
<script src="../_static/jquery.js"></script>
|
||
<script src="../_static/_sphinx_javascript_frameworks_compat.js"></script>
|
||
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
|
||
<script src="../_static/doctools.js"></script>
|
||
<script src="../_static/sphinx_highlight.js"></script>
|
||
<script src="../_static/js/theme.js"></script>
|
||
<link rel="index" title="Index" href="../genindex.html" />
|
||
<link rel="search" title="Search" href="../search.html" />
|
||
<link rel="next" title="Boot Linux as a Payload" href="boot-with-linux-payload.html" />
|
||
<link rel="prev" title="Boot Zephyr" href="boot-zephyr.html" />
|
||
</head>
|
||
|
||
<body class="wy-body-for-nav">
|
||
<div class="wy-grid-for-nav">
|
||
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
||
<div class="wy-side-scroll">
|
||
<div class="wy-side-nav-search" >
|
||
|
||
|
||
|
||
<a href="../index.html" class="icon icon-home">
|
||
Slim Bootloader
|
||
<img src="../_static/sbl_logo_white_200x200.png" class="logo" alt="Logo"/>
|
||
</a>
|
||
<div class="version">
|
||
1.0
|
||
</div>
|
||
<div role="search">
|
||
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
|
||
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
|
||
<input type="hidden" name="check_keywords" value="yes" />
|
||
<input type="hidden" name="area" value="default" />
|
||
</form>
|
||
</div>
|
||
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
|
||
<ul class="current">
|
||
<li class="toctree-l1"><a class="reference internal" href="../introduction/index.html">Introduction</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../getting-started/index.html">Getting Started</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../supported-hardware/index.html">Supported Hardware</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../developer-guides/index.html">Developer’s Guide</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../security/index.html">Security Features</a></li>
|
||
<li class="toctree-l1 current"><a class="reference internal" href="index.html">How-Tos</a><ul class="current">
|
||
<li class="toctree-l2"><a class="reference internal" href="customize-build.html">Customize Build</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="change-boot-option.html">Change Boot Options</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="enable-verified-boot.html">Enable Verified Boot</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="enable-intel-tcc.html">Intel® TCC enable</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="enable-intel-tsn.html">TSN</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="enable-tsn-gbe-sgmii.html">Enable TSN GbE SGMII</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="enable-pre-os-payload.html">Enable Pre-OS Payload Support</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="reduce-debug-message.html">Reduce debug messages</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="add-new-library.html">Add New Library</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="add-new-payload.html">Create New Payload</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="add-new-payload.html#helloworld-payload">HelloWorld Payload</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="integrate-multiple-payloads.html">Integrate Multiple Payloads</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="create-container-boot-image.html">Create Container Boot Image</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="create-ias-boot-image.html">Create IAS Boot Image</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="boot-windows.html">Boot Windows with UEFI Payload</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="boot-netboot.html">Netboot / PXE boot with UEFI Payload</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="boot-ubuntu.html">Boot Ubuntu</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="boot-ubuntu.html#setup-spn-os-container-boot">Setup SBL OS Container Boot</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="boot-vxworks.html">Boot VxWorks</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="boot-zephyr.html">Boot Zephyr</a></li>
|
||
<li class="toctree-l2 current"><a class="current reference internal" href="#">Boot MicroPython</a><ul>
|
||
<li class="toctree-l3"><a class="reference internal" href="#how-to-build-micropython-payload-module">How to Build MicroPython Payload Module</a></li>
|
||
<li class="toctree-l3"><a class="reference internal" href="#how-to-integrate-micropython-into-slim-bootloader">How to Integrate MicroPython into Slim Bootloader</a></li>
|
||
<li class="toctree-l3"><a class="reference internal" href="#how-to-enable-micropython-for-other-platforms">How to Enable MicroPython for Other Platforms</a></li>
|
||
</ul>
|
||
</li>
|
||
<li class="toctree-l2"><a class="reference internal" href="boot-with-linux-payload.html">Boot Linux as a Payload</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="boot-with-u-boot-payload.html">Boot Linux with U-Boot Payload</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="boot-pxe-uboot.html">PXE Boot Through U-Boot Payload</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="configure-memory-down.html">Configure Memory Down</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="collect-time-logs.html">Capture Boot Time Data</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="configure_gpio.html">GPIO / CFIO Configuration</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="configure_gpio.html#run-gengpiodata-tool">Run GenGpioData Tool</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="add-fastboot.html">Add Fastboot Support</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="boot-acrn.html">Boot ACRN Hypervisor</a></li>
|
||
</ul>
|
||
</li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../tools/index.html">Tools</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../tutorials/index.html">Tutorials</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../specs/index.html">Specifications</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../references/references.html">References and Links</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../references/terminology.html">Terminology and Acronyms</a></li>
|
||
</ul>
|
||
|
||
</div>
|
||
</div>
|
||
</nav>
|
||
|
||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
|
||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||
<a href="../index.html">Slim Bootloader</a>
|
||
</nav>
|
||
|
||
<div class="wy-nav-content">
|
||
<div class="rst-content">
|
||
<div role="navigation" aria-label="Page navigation">
|
||
<ul class="wy-breadcrumbs">
|
||
<li><a href="../index.html" class="icon icon-home" aria-label="Home"></a></li>
|
||
<li class="breadcrumb-item"><a href="index.html">How-Tos</a></li>
|
||
<li class="breadcrumb-item active">Boot MicroPython</li>
|
||
<li class="wy-breadcrumbs-aside">
|
||
</li>
|
||
</ul>
|
||
<hr/>
|
||
</div>
|
||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
||
<div itemprop="articleBody">
|
||
|
||
<section id="boot-micropython">
|
||
<span id="id1"></span><h1>Boot MicroPython<a class="headerlink" href="#boot-micropython" title="Permalink to this heading"></a></h1>
|
||
<p><a href="https://micropython.org" target="_blank">MicroPython</a> is a lean and efficient implementation of the Python 3 programming language
|
||
that includes a small subset of the Python standard library. MicroPython can be built as
|
||
a standalone module that can be launched by SBL’s OsLoader payload. This can then be used
|
||
to run python based applications.</p>
|
||
<p>Below are the steps to enable MicroPython for SBL QEMU platform. Similar steps can be
|
||
followed to enable it on other platforms.</p>
|
||
<section id="how-to-build-micropython-payload-module">
|
||
<h2>How to Build MicroPython Payload Module<a class="headerlink" href="#how-to-build-micropython-payload-module" title="Permalink to this heading"></a></h2>
|
||
<ol class="arabic">
|
||
<li><p>Clone latest SBL tree and prepare the build environment following <a class="reference internal" href="../getting-started/build-source.html#build-steps"><span class="std std-ref">SBL Build Steps</span></a>.
|
||
Here, assume SBL is cloned into directionary named ‘SlimBoot’.</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">git</span> <span class="n">clone</span> <span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">github</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="n">slimbootloader</span><span class="o">/</span><span class="n">slimbootloader</span><span class="o">.</span><span class="n">git</span> <span class="n">SlimBoot</span>
|
||
</pre></div>
|
||
</div>
|
||
</li>
|
||
<li><p>Clone MicroPython payloads repo into SBL tree root directory named ‘PayloadModPkg’.</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">cd</span> <span class="n">SlimBoot</span>
|
||
<span class="n">git</span> <span class="n">clone</span> <span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">github</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="n">slimbootloader</span><span class="o">/</span><span class="n">payloads</span><span class="o">.</span><span class="n">git</span> <span class="n">PayloadModPkg</span>
|
||
<span class="n">cd</span> <span class="n">PayloadModPkg</span>
|
||
<span class="n">git</span> <span class="n">submodule</span> <span class="n">update</span> <span class="o">--</span><span class="n">init</span>
|
||
<span class="n">cd</span> <span class="o">..</span>
|
||
<span class="n">python</span> <span class="n">PayloadModPkg</span>\<span class="n">MicroPython</span>\<span class="n">Tools</span>\<span class="n">prep</span><span class="o">.</span><span class="n">py</span>
|
||
</pre></div>
|
||
</div>
|
||
</li>
|
||
<li><p>Build MicroPython module binary.
|
||
Currently, only Windows VS2017 Community build environment is tested for MicroPython build.</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">python</span> <span class="n">BuildLoader</span><span class="o">.</span><span class="n">py</span> <span class="n">build_dsc</span> <span class="o">-</span><span class="n">p</span> <span class="n">PayloadModPkg</span>\<span class="n">PayloadModPkg</span><span class="o">.</span><span class="n">dsc</span> <span class="o">-</span><span class="n">d</span> <span class="n">MICRO_PYTHON</span>
|
||
</pre></div>
|
||
</div>
|
||
</li>
|
||
<li><p>Copy generated MicroPython payload module binary to payload binary directory.
|
||
The MicroPython.efi file path might change depending on the selected build toolchain.</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mkdir</span> <span class="n">PayloadPkg</span>\<span class="n">PayloadBins</span>
|
||
<span class="n">copy</span> <span class="n">Build</span>\<span class="n">PayloadModPkg</span>\<span class="n">DEBUG_VS2017</span>\<span class="n">IA32</span>\<span class="n">MicroPython</span><span class="o">.</span><span class="n">efi</span> <span class="n">PayloadPkg</span>\<span class="n">PayloadBins</span> <span class="o">/</span><span class="n">y</span>
|
||
</pre></div>
|
||
</div>
|
||
</li>
|
||
</ol>
|
||
</section>
|
||
<section id="how-to-integrate-micropython-into-slim-bootloader">
|
||
<h2>How to Integrate MicroPython into Slim Bootloader<a class="headerlink" href="#how-to-integrate-micropython-into-slim-bootloader" title="Permalink to this heading"></a></h2>
|
||
<ol class="arabic">
|
||
<li><p>Ensure MicroPython.efi is located in PayloadPkgPayloadBins directory.
|
||
If not, please build MicroPython payload module as mentioned above.</p></li>
|
||
<li><p>Enable a python based application. Here use the implemented example SBL Setup.
|
||
Add or modify so that “self.ENABLE_SBL_SETUP = 1” is in related BoardConfig.py
|
||
Board.__init__(). For QEMU, the file is located at PlatformQemuBoardPkgBoardConfig.py.</p></li>
|
||
<li><p>Build Slim Bootloader as normal.</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">python</span> <span class="n">BuildLoader</span><span class="o">.</span><span class="n">py</span> <span class="n">build</span> <span class="n">qemu</span> <span class="o">-</span><span class="n">k</span>
|
||
</pre></div>
|
||
</div>
|
||
</li>
|
||
<li><p>Boot QEMU and enable MicroPython setup payload module launching.</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">qemu</span><span class="o">-</span><span class="n">system</span><span class="o">-</span><span class="n">x86_64</span> <span class="o">-</span><span class="n">m</span> <span class="mi">256</span><span class="n">M</span> <span class="o">-</span><span class="n">cpu</span> <span class="nb">max</span> <span class="o">-</span><span class="n">machine</span> <span class="n">q35</span> <span class="o">-</span><span class="n">serial</span> <span class="n">telnet</span><span class="p">:</span><span class="mf">127.0.0.1</span><span class="p">:</span><span class="mi">8888</span><span class="p">,</span><span class="n">server</span>
|
||
<span class="o">-</span><span class="n">drive</span> <span class="k">if</span><span class="o">=</span><span class="n">pflash</span><span class="p">,</span><span class="nb">format</span><span class="o">=</span><span class="n">raw</span><span class="p">,</span><span class="n">file</span><span class="o">=</span><span class="n">Outputs</span>\<span class="n">qemu</span>\<span class="n">SlimBootloader</span><span class="o">.</span><span class="n">bin</span> <span class="o">-</span><span class="n">boot</span> <span class="n">order</span><span class="o">=</span><span class="n">a</span>
|
||
</pre></div>
|
||
</div>
|
||
</li>
|
||
<li><p>Start a telnet console using Putty telnet 127.0.0.1 port 8888 to connect to QEMU.
|
||
Make sure the console screen is set to 100 x 30 with Linux keypad for terminal keyboard.</p></li>
|
||
<li><p>Once booted, it will launch MicroPython first, and then run a python script located at:
|
||
BootloaderCorePkgToolsSblSetup.py. A screenshot is captured as below:</p></li>
|
||
</ol>
|
||
<img alt="../_images/sbl_setup.jpg" src="../_images/sbl_setup.jpg" />
|
||
</section>
|
||
<section id="how-to-enable-micropython-for-other-platforms">
|
||
<h2>How to Enable MicroPython for Other Platforms<a class="headerlink" href="#how-to-enable-micropython-for-other-platforms" title="Permalink to this heading"></a></h2>
|
||
<ol class="arabic">
|
||
<li><p>To run MicroPython on other platforms, the similar steps can be followed as QEMU.
|
||
If the intention is to run some other python script other than SblSetup.py, please
|
||
set “self.ENABLE_PAYLOD_MODULE = 1” instead of “self.ENABLE_SBL_SETUP = 1” in BoardConfig.py.</p></li>
|
||
<li><p>It might be required to define a new container for it if it is not already there.
|
||
Please refer to QEMU BoardConfig.py to see how to define a container for MicroPython.
|
||
Assume the container signature is ‘SETP’, and it contains the following components:</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">MPYM</span><span class="p">:</span> <span class="n">Required</span><span class="o">.</span> <span class="n">MicroPython</span><span class="o">.</span><span class="n">efi</span> <span class="n">binary</span><span class="o">.</span>
|
||
<span class="n">STPY</span><span class="p">:</span> <span class="n">Required</span><span class="o">.</span> <span class="n">MicroPython</span> <span class="n">script</span> <span class="n">file</span> <span class="n">to</span> <span class="n">launch</span><span class="o">.</span>
|
||
<span class="n">CFGJ</span><span class="p">:</span> <span class="n">Optional</span><span class="o">.</span> <span class="n">Generated</span> <span class="n">CfgDataDef</span><span class="o">.</span><span class="n">json</span> <span class="n">file</span> <span class="n">by</span> <span class="n">build</span><span class="o">.</span> <span class="n">Only</span> <span class="n">required</span> <span class="k">if</span> <span class="n">need</span> <span class="n">to</span> <span class="n">run</span> <span class="n">SblSetup</span><span class="o">.</span><span class="n">py</span><span class="o">.</span>
|
||
<span class="n">CFGD</span><span class="p">:</span> <span class="n">Optional</span><span class="o">.</span> <span class="n">Spare</span> <span class="n">space</span> <span class="n">to</span> <span class="n">store</span> <span class="n">the</span> <span class="n">new</span> <span class="n">CFGDATA</span><span class="o">.</span> <span class="n">Only</span> <span class="n">required</span> <span class="k">if</span> <span class="n">need</span> <span class="n">to</span> <span class="n">run</span> <span class="n">SblSetup</span><span class="o">.</span><span class="n">py</span><span class="o">.</span>
|
||
</pre></div>
|
||
</div>
|
||
</li>
|
||
<li><p>Add SETP.bin container into the Flash layout in non-redundant region. Adjust the the
|
||
region size accordingly so that the build can complete successfully.</p></li>
|
||
<li><p>Add a boot option to boot to MicroPython.
|
||
It can be done using ConfigEditor.py to add new boot option or modify an existing boot option.
|
||
The new boot option in the platform should have the parameters as below</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>Boot Device Type: Memory
|
||
File System Type: Auto
|
||
Normal OS info : !SETP/MPYM:STPY
|
||
</pre></div>
|
||
</div>
|
||
</li>
|
||
<li><p>MicroPython now can be launched as a standard boot option for Slim Bootloader.</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>Jumping into FV/PE32 ...
|
||
|
||
Starting MicroPython ...
|
||
HASH verification for usage (0x00000000) with Hash Alg (0x2): Success
|
||
Hello world!
|
||
MicroPython v1.12-700-g0e6ef4035 on 2020-09-04; SBL with x86
|
||
>>>
|
||
>>>
|
||
>>
|
||
</pre></div>
|
||
</div>
|
||
</li>
|
||
</ol>
|
||
</section>
|
||
</section>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
|
||
<a href="boot-zephyr.html" class="btn btn-neutral float-left" title="Boot Zephyr" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
|
||
<a href="boot-with-linux-payload.html" class="btn btn-neutral float-right" title="Boot Linux as a Payload" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
|
||
</div>
|
||
|
||
<hr/>
|
||
|
||
<div role="contentinfo">
|
||
<p>© Copyright 2018 - 2024, Intel Corporation.
|
||
<span class="lastupdated">Last updated on Dec 16, 2024.
|
||
</span></p>
|
||
</div>
|
||
|
||
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
|
||
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
|
||
provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||
|
||
|
||
</footer>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
<script>
|
||
jQuery(function () {
|
||
SphinxRtdTheme.Navigation.enable(true);
|
||
});
|
||
</script>
|
||
|
||
</body>
|
||
</html> |