Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

acrn-sblimage: add custom image type to inject ACRN SBL boot image #182

Merged
merged 2 commits into from
Aug 14, 2020
Merged

acrn-sblimage: add custom image type to inject ACRN SBL boot image #182

merged 2 commits into from
Aug 14, 2020

Conversation

tnishiok
Copy link
Contributor

add the image class to generate the multiboot compliant container
images which stitch ACRN Hypervisor and Operating Systems to boot with
Slim Bootloader.

Usage: Example for the ACRN hybrid scenario

  1. setup meta-acrn yocto build environment by following the meta-acrn GSG

meta-intel with commit#180027 is required.
http://git.yoctoproject.org/cgit/cgit.cgi/meta-intel/commit/?id=180027

  1. add sos to BBMULTICONFIG in conf/local.conf
    BBMULTICONFIG = "sos uos"

  2. enable the SBL containerization feature for sos in conf/multiconfig/sos.conf

TMPDIR = "${TOPDIR}/master-acrn-sos"
DISTRO = "acrn-demo-sos"

ACRN_BOARD = "ehl-crb-b"
ACRN_SCENARIO = "hybrid"

IMAGE_CLASSES_append = " acrn-sblimage"

  1. specify the module files in conf/multiconfig/sos.conf to be stitched in the container

MB_ACRN_MODULES = "
${TOPDIR}/conf/zephyr.txt;${TOPDIR}/conf/zephyr.bin
${TOPDIR}/conf/linux.txt;${TMPDIR}/deploy/images/${MACHINE}/${KERNEL_IMAGETYPE}
"

  1. create module tag files
    build$ echo Linux_bzImage > conf/linux.txt
    build$ echo Zephyr_RawImage > conf/zephyr.txt

Note: zephyr.bin is supposed to be built outside of yocto

  1. generate SBL sign key file
    build$ python $(SBL_ROOT)/BootloaderCorePkg/Tools/GenerateKeys.py -k cert
    build$ cp cert/OS1_TestKey_Priv_RSA2048.pem cert/TestSigningPrivateKey.pem

ref: https://slimbootloader.github.io/getting-started/build-host-setup.html#sbl-keys

  1. build SOS image
    build$ bitbake mc:sos:acrn-image-minimal

  2. confirm the sbl_os container file has been deployed in the generated wic image

build$ sudo losetup -Pf master-acrn-sos/deploy/images/intel-corei7-64/acrn-image-minimal-intel-corei7-64.wic.acrn
build$ sudo mount /dev/loop0p2 /mnt/
build$ ls /mnt/boot/
bzImage bzImage-5.4.52-linux-intel-acrn-sos EFI loader sbl_os

Signed-off-by: Schmidt, Michael [email protected]
Signed-off-by: Nishioka, Toshiki [email protected]

@saininav
Copy link
Contributor

Thanks Toshi for the patch.
It would be great, if we document above steps under docs/

MB_MC_DEPENDENCY ?= ""
MB_ACRN_BINARY ?= "${TMPDIR}/deploy/images/${MACHINE}/acrn.32.out"
MB_ACRN_CMDLINE ?= ""
MB_ACRN_MODULES ?= "${TOPDIR}/conf/linux.txt;${TMPDIR}/deploy/images/${MACHINE}/${KERNEL_IMAGETYPE}"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably use DEPLOY_DIR_IMAGE instead of ${TMPDIR}/deploy/images/${MACHINE} in case someone has overriden that. Same for MB_ACRN_BINARY

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it. thanks

classes/acrn-sblimage.bbclass Show resolved Hide resolved

mbAcrnBinaryDeployDir = d.getVar('MB_ACRN_BINARY').lstrip().rstrip()
if not os.path.isfile(mbAcrnBinaryDeployDir):
bb.error("acrn %s not found!" % mbAcrnBinaryDeployDir)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it help if we can give some helpful hints to the user when this happens? When can this happen?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, do we expect the task to fail here? bb.error doesn't cause the task to fail I think. Perhaps raise an exception or check if bb.fatal make more sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the task should fail. I will use bb.fatal. In normal case this never happens. Because if ACRN hypervisor build failed, bitbake will not reach at here. It could happen only when user moved acrn.32.out file like below.

$ bitbake mc:sos:acrn-hypervisor
$ rm master-acrn-sos/deploy/images/intel-corei7-64/acrn.32.out
$ bitbake mc:sos:acrn-image-minimal

In this case bitbake will run the do_acrn_sblimage() task because it is not aware of that acrn.32.out is missing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the error message will show file path which is not available. for example,

acrn master-acrn-sos/deploy/images/intel-corei7-64/acrn.32.out not found!

It should be enough hint for users to understand the failure reason.

bb.error("module %s not found!" % mbAcrnBinaryDeployDirPairMods[0])

if not os.path.isfile(mbAcrnBinaryDeployDirPairMods[1]):
bb.error("module %s not found!" % mbAcrnBinaryDeployDirPairMods[1])
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment, I don't know much about the internals ... when can this happen? Is there any helpful hint that we can provide here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some module files such as Zephyr OS image are supposed to be provided by users. Because Yocto cannot build Zephyr. These errors can happen when the task could not find files specified by users. Again it will output file path which the task could not find as a hint of failure.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zephyr can be build using Yocto. We have meta-zephyr layer.
http://git.yoctoproject.org/cgit/cgit.cgi/meta-zephyr

Previously I created a PR to build zephyr as UOS. But need to rebase that PR.
#39

for multibootPackageMcDependency in multibootPackageMcDependencyList:
if multibootPackageMcDependency:
mcdependency = "multiconfig::%s" % (multibootPackageMcDependency)
print("MultibootMcDependency: %s" % (mcdependency))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps some of these prints should be replaced by bb.debug?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree

@tnishiok
Copy link
Contributor Author

Thanks Toshi for the patch.
It would be great, if we document above steps under docs/

okay


bb.debug(1, "genContainerCmd: %s" % (genContainerCmd))
os.system("%s" % (genContainerCmd))
os.system("install -d %s/boot; install -m 644 %s/%s %s/boot" % (d.getVar('IMAGE_ROOTFS'), d.getVar('WORKDIR'), d.getVar('SBLIMAGE_NAME'), d.getVar('IMAGE_ROOTFS')))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I had not noticed this in the first revision. I think these two calls should be replaced by subprocess.

@tnishiok tnishiok marked this pull request as draft August 14, 2020 04:35
add the image class to generate the multiboot compliant container
images which stitch ACRN Hypervisor and Operating Systems to boot with
Slim Bootloader.

Signed-off-by: Schmidt, Michael <[email protected]>
Signed-off-by: Nishioka, Toshiki <[email protected]>
Signed-off-by: Nishioka, Toshiki <[email protected]>
@tnishiok tnishiok marked this pull request as ready for review August 14, 2020 04:56
@saininav saininav merged commit d89c345 into intel:master Aug 14, 2020
@cheeyanglee cheeyanglee mentioned this pull request Aug 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants