From f0f943bd9e226c41aae3730e253a70e2ab925d25 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 9 Jan 2019 22:37:35 +0800 Subject: [PATCH] doc: Update the steps for generating 'partition_desc.bin' --- doc/tutorials/gpt_ini2bin.py | 113 +++++++++++++++++++++++++++++ doc/tutorials/partition_desc.ini | 26 +++++++ doc/tutorials/using_sbl_on_up2.rst | 67 +++++++++-------- 3 files changed, 176 insertions(+), 30 deletions(-) create mode 100755 doc/tutorials/gpt_ini2bin.py create mode 100755 doc/tutorials/partition_desc.ini diff --git a/doc/tutorials/gpt_ini2bin.py b/doc/tutorials/gpt_ini2bin.py new file mode 100755 index 000000000..892f36556 --- /dev/null +++ b/doc/tutorials/gpt_ini2bin.py @@ -0,0 +1,113 @@ +#!/usr/bin/env python + +# Copyright (C) 2018 Intel Corporation. +# SPDX-License-Identifier: BSD-3-Clause + +import ConfigParser +import uuid +import struct +import sys + +type_2_guid = { +# official guid for gpt partition type + 'fat' : 'ebd0a0a2-b9e5-4433-87c0-68b6b72699c7', + 'esp' : 'c12a7328-f81f-11d2-ba4b-00a0c93ec93b', + 'linux' : '0fc63daf-8483-4772-8e79-3d69d8477de4', + 'linux-swap' : '0657fd6d-a4ab-43c4-84e5-0933c84b4f4f', +# generated guid for android + 'boot' : '49a4d17f-93a3-45c1-a0de-f50b2ebe2599', + 'recovery' : '4177c722-9e92-4aab-8644-43502bfd5506', + 'misc' : 'ef32a33b-a409-486c-9141-9ffb711f6266', + 'metadata' : '20ac26be-20b7-11e3-84c5-6cfdb94711e9', + 'tertiary' : '767941d0-2085-11e3-ad3b-6cfdb94711e9', + 'factory' : '9fdaa6ef-4b3f-40d2-ba8d-bff16bfb887b' } + +def zero_pad(s, size): + if (len(s) > size): + print 'error', len(s) + s += '\0' * (size - len(s)) + return s + +def copy_section(cfg, a, b): + cfg.add_section(b) + for option in cfg.options(a): + cfg.set(b, option, cfg.get(a, option)) + +def preparse_slots(cfg, partitions): + if not cfg.has_option('base', 'nb_slot'): + return partitions + + nb_slot = cfg.getint('base', 'nb_slot') + + parts_with_slot = [] + for p in partitions: + section = "partition." + p + if cfg.has_option(section, 'has_slot'): + for i in range(ord('a'), ord('a') + nb_slot): + suffix = "_%c" % i + new_part = p + suffix + new_section = "partition." + new_part + + copy_section(cfg, section, new_section) + cfg.set(new_section, 'label', cfg.get(section, 'label') + suffix) + parts_with_slot.append(new_part); + else: + parts_with_slot.append(p); + + return parts_with_slot + +def preparse_partitions(gpt_in, cfg): + with open(gpt_in, 'r') as f: + data = f.read() + + partitions = cfg.get('base', 'partitions').split() + + for l in data.split('\n'): + words = l.split() + if len(words) > 2: + if words[0] == 'partitions' and words[1] == '+=': + partitions += words[2:] + + return partitions + +def main(): + if len(sys.argv) != 2: + print 'Usage : ', sys.argv[0], 'gpt_in1.ini' + print ' write binary to stdout' + sys.exit(1) + + gpt_in = sys.argv[1] + + cfg = ConfigParser.SafeConfigParser() + + cfg.read(gpt_in) + + part = preparse_partitions(gpt_in, cfg) + part = preparse_slots(cfg, part) + + magic = 0x6a8b0da1 + start_lba = 0 + if cfg.has_option('base', 'start_lba'): + start_lba = cfg.getint('base', 'start_lba') + npart = len(part) + + out = sys.stdout + out.write(struct.pack('`_ to generate the BIOS binary file ````, which is the new IFWI image with SBL in BIOS region. - - Flash SBL on the UP2 ******************** @@ -72,7 +70,6 @@ Flash SBL on the UP2 Fpt_3.1.50.2222.efi -f -y - Build ACRN for UP2 ****************** @@ -89,51 +86,64 @@ An example of the configuration file ``uos.json``: "DestinationType" : "virtual", "PartitionLayout" : [ { "disk" : "clearlinux.img", "partition" : 1, "size" : "100M", "type" : "EFI" }, { "disk" : "clearlinux.img", "partition" : 2, "size" : "10G", "type" : "linux" } ], - "FilesystemTypes" : [ { "disk" : "clearlinux.img", "partition" : 1, "type" : "ext2" }, + "FilesystemTypes" : [ { "disk" : "clearlinux.img", "partition" : 1, "type" : "vfat" }, { "disk" : "clearlinux.img", "partition" : 2, "type" : "ext4" } ], "PartitionMountPoints" : [ { "disk" : "clearlinux.img", "partition" : 1, "mount" : "/boot" }, { "disk" : "clearlinux.img", "partition" : 2, "mount" : "/" } ], - "Version": 26880, + "Version": 27050, "Bundles": ["kernel-iot-lts2018", "openssh-server", "software-defined-cockpit", "os-core", "os-core-update"] } .. note:: To generate the image with a specified version, please modify the "Version" argument, ``"Version": 26000`` instead - of ``"Version": 26880`` for example. + of ``"Version": 27050`` for example. -Clone the source code of ``acrn-hypervisor`` and build SOS and LaaG image: +Clone the source code of ``acrn-hypervisor`` for building: .. code-block:: none + + $ cd ~ + $ git clone https://github.com/projectacrn/acrn-hypervisor - cd ~ - git clone https://github.com/projectacrn/acrn-hypervisor - sudo ./acrn-hypervisor/devicemodel/samples/up2/create-up2-images.sh --images-type all \ - --clearlinux-version 26880 --laag-json uos.json --acrn-code-path ~/acrn-hypervisor/ +Build SOS and LaaG image: + +.. code-block:: none + $ sudo -s + # ./acrn-hypervisor/devicemodel/samples/up2/create-up2-images.sh --images-type all \ + --clearlinux-version 27050 --laag-json uos.json --acrn-code-path ~/acrn-hypervisor/ +.. note:: + Run ``create-up2-images.sh`` as root. + +.. note:: + When building images, you can modify the ``--clearlinux-version`` argument + to a specific version (such as 26800). To generate the images of SOS only, + modify the ``--images-type`` argument to ``sos``. + This step will generate the images of SOS and LaaG: * sos_boot.img * sos_rootfs.img * up2_laag.img -.. note:: - When building images, you can modify the ``--clearlinux-version`` argument - to a specific version (such as 26800). To generate the images of SOS only, - modify the ``--images-type`` argument to ``sos``. +Build the binary image ``partition_desc.bin`` for +GPT partitions, and change the partition layout +in ``partition_desc.ini`` if needed. +.. code-block:: none -We still need the binary image for GPT partitions and -configuration file for flashing: + $ wget https://raw.githubusercontent.com/projectacrn/acrn-hypervisor/master/doc/tutorials/gpt_ini2bin.py + $ wget https://raw.githubusercontent.com/projectacrn/acrn-hypervisor/master/doc/tutorials/partition_desc.ini + $ sudo -s + # python2 gpt_ini2bin.py partition_desc.ini>partition_desc.bin -* partition_desc.bin -* flash_LaaG.json +We still need the configuration file for flashing: -.. note:: - ``partition_desc.bin`` and ``flash_LaaG.json`` are in the directory - ``~/acrn-hypervisor/doc/tutorials/``. +.. code-block:: none + $ wget https://raw.githubusercontent.com/projectacrn/acrn-hypervisor/master/doc/tutorials/flash_LaaG.json .. table:: :widths: auto @@ -167,12 +177,10 @@ Download and install flash tool #. Download IntelĀ® Platform Flash Tool Lite from ``_. - #. For Ubuntu host, install `platformflashtoollite_5.8.9.0_linux_x86_64.deb `_ for example. - SOS and LaaG Installation ************************* @@ -182,14 +190,14 @@ SOS and LaaG Installation .. code-block:: none - ls /dev/ttyUSB* + $ ls /dev/ttyUSB* /dev/ttyUSB0 #. Connect to board via ``minicom``, and use ``/dev/ttyUSB0`` for example: .. code-block:: none - sudo minicom -s /dev/ttyUSB0 + $ sudo minicom -s /dev/ttyUSB0 .. note:: Please verify the minicom serial port settings are 115200 8N1 and @@ -207,7 +215,6 @@ SOS and LaaG Installation Shell> - #. Swap the boot sequence of ``DevType: MEM`` to ``Idx:0``: .. code-block:: none @@ -290,8 +297,8 @@ Run the ``launch_uos.sh`` script to launch the UOS: .. code-block:: none - cd ~ - wget https://raw.githubusercontent.com/projectacrn/acrn-hypervisor/master/doc/tutorials/launch_uos.sh - sudo ./launch_uos.sh -V 1 + $ cd ~ + $ wget https://raw.githubusercontent.com/projectacrn/acrn-hypervisor/master/doc/tutorials/launch_uos.sh + $ sudo ./launch_uos.sh -V 1 **Congratulations**, you are now watching the User OS booting up!