mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-22 05:30:24 +00:00
doc: Update the steps for generating 'partition_desc.bin'
This commit is contained in:
parent
1fc10d514c
commit
f0f943bd9e
113
doc/tutorials/gpt_ini2bin.py
Executable file
113
doc/tutorials/gpt_ini2bin.py
Executable file
@ -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('<I', magic))
|
||||
out.write(struct.pack('<I', start_lba))
|
||||
out.write(struct.pack('<I', npart))
|
||||
for p in part:
|
||||
length = cfg.get('partition.' + p, 'len')
|
||||
out.write(struct.pack('<i', int(length)))
|
||||
|
||||
label = cfg.get('partition.' + p, 'label').encode('utf-16le')
|
||||
out.write(zero_pad(label, 36 * 2))
|
||||
|
||||
guid_type = cfg.get('partition.' + p, 'type')
|
||||
guid_type = uuid.UUID(type_2_guid[guid_type])
|
||||
out.write(guid_type.bytes_le)
|
||||
|
||||
guid = uuid.uuid4()
|
||||
out.write(guid.bytes_le)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
26
doc/tutorials/partition_desc.ini
Executable file
26
doc/tutorials/partition_desc.ini
Executable file
@ -0,0 +1,26 @@
|
||||
# ----------------- BEGIN MIX-IN DEFINITIONS -----------------
|
||||
# Mix-In definitions are auto-generated by mixin-update
|
||||
##############################################################
|
||||
# Source: device/intel/mixins/groups/boot-arch/abl/gpt.ini
|
||||
##############################################################
|
||||
[base]
|
||||
# The sequence matters, and the index starts from p1.
|
||||
# The fastboot ABL by default boots from the 2nd partition.
|
||||
partitions = sos_rootfs sos_boot data_partition
|
||||
device = auto
|
||||
|
||||
[partition.sos_boot]
|
||||
label = sos_boot
|
||||
len = 100
|
||||
type = linux
|
||||
|
||||
[partition.sos_rootfs]
|
||||
label = sos_rootfs
|
||||
len = 4000
|
||||
type = linux
|
||||
|
||||
[partition.data_partition]
|
||||
label = data_partition
|
||||
len = -1
|
||||
type = linux
|
||||
# ------------------ END MIX-IN DEFINITIONS ------------------
|
@ -53,8 +53,6 @@ and `Stitching <https://slimbootloader.github.io/supported-hardware/up2.html#sti
|
||||
from `<https://slimbootloader.github.io/supported-hardware/up2.html>`_ to generate the
|
||||
BIOS binary file ``<SBL_IFWI_IMAGE>``, 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 <SBL_IFWI_IMAGE> -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
|
||||
`<https://github.com/projectceladon/tools/tree/master/platform_flash_tool_lite/latest/>`_.
|
||||
|
||||
|
||||
#. For Ubuntu host, install `platformflashtoollite_5.8.9.0_linux_x86_64.deb
|
||||
<https://github.com/projectceladon/tools/blob/master/platform_flash_tool_lite/latest/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!
|
||||
|
Loading…
Reference in New Issue
Block a user