Commit ffae353cd18217b7b534782a4c6868f0bc42a140

Authored by Eric Lee
1 parent 5ab46bc5e8

Upgrade Meson version to 0.45

Showing 22 changed files with 1363 additions and 0 deletions Side-by-side Diff

conf/machine/smarcimx8m2g.conf
... ... @@ -72,6 +72,7 @@
72 72 boost \
73 73 nodejs \
74 74 networkmanager \
  75 + imx-gpu-viv \
75 76 "
76 77  
77 78 BBMASK_prepend = "fsl-image-mfgtool-initramfs "
conf/machine/smarcimx8m4g.conf
... ... @@ -72,6 +72,7 @@
72 72 boost \
73 73 nodejs \
74 74 networkmanager \
  75 + imx-gpu-viv \
75 76 "
76 77  
77 78 BBMASK_prepend = "fsl-image-mfgtool-initramfs "
recipes-devtools/meson/meson.inc
  1 +HOMEPAGE = "http://mesonbuild.com"
  2 +SUMMARY = "A high performance build system"
  3 +
  4 +LICENSE = "Apache-2.0"
  5 +LIC_FILES_CHKSUM = "file://COPYING;md5=3b83ef96387f14655fc854ddc3c6bd57"
  6 +
  7 +SRC_URI = "https://github.com/mesonbuild/meson/releases/download/${PV}/meson-${PV}.tar.gz \
  8 + file://0001-gtkdoc-fix-issues-that-arise-when-cross-compiling.patch \
  9 + file://0002-gobject-introspection-determine-g-ir-scanner-and-g-i.patch \
  10 + file://0001-Linker-rules-move-cross_args-in-front-of-output_args.patch \
  11 + file://0003-native_bindir.patch \
  12 + file://gi-flags.patch \
  13 + file://gtkdoc-flags.patch \
  14 + file://0001-python-module-do-not-manipulate-the-environment-when.patch \
  15 + file://disable-rpath-handling.patch \
  16 + "
  17 +SRC_URI[sha256sum] = "92d8afd921751261e36151643464efd3394162f69efbe8cd53e0a66b1cf395eb"
  18 +SRC_URI[md5sum] = "31bda3519d8c0eb3438267268a78085e"
  19 +
  20 +SRC_URI_append_class-native = " \
  21 + file://0002-Make-CPU-family-warnings-fatal.patch \
  22 + file://0001-Support-building-allarch-recipes-again.patch \
  23 +"
  24 +
  25 +UPSTREAM_CHECK_URI = "https://github.com/mesonbuild/meson/releases"
  26 +
  27 +inherit setuptools3
  28 +
  29 +RDEPENDS_${PN} = "ninja python3-core python3-modules"
  30 +
  31 +FILES_${PN} += "${datadir}/polkit-1"
recipes-devtools/meson/meson/0001-Linker-rules-move-cross_args-in-front-of-output_args.patch
  1 +From 4676224dbdff0f7107e8cbdbe0eab19c855f1454 Mon Sep 17 00:00:00 2001
  2 +From: Alexander Kanavin <alex.kanavin@gmail.com>
  3 +Date: Fri, 17 Nov 2017 13:18:28 +0200
  4 +Subject: [PATCH] Linker rules: move {cross_args} in front of {output_args}
  5 +
  6 +The previous order was found to break linking in some cases
  7 +(e.g. when -no-pic -fno-PIC was present in {cross_args}.
  8 +
  9 +Upstream-Status: Pending
  10 +Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
  11 +---
  12 + mesonbuild/backend/ninjabackend.py | 2 +-
  13 + 1 file changed, 1 insertion(+), 1 deletion(-)
  14 +
  15 +diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
  16 +index bb281e1..969b70e 100644
  17 +--- a/mesonbuild/backend/ninjabackend.py
  18 ++++ b/mesonbuild/backend/ninjabackend.py
  19 +@@ -1501,7 +1501,7 @@ int dummy;
  20 + rspfile_content = $ARGS {output_args} $in $LINK_ARGS {cross_args} $aliasing
  21 + '''
  22 + else:
  23 +- command_template = ' command = {executable} $ARGS {output_args} $in $LINK_ARGS {cross_args} $aliasing\n'
  24 ++ command_template = ' command = {executable} $ARGS {cross_args} {output_args} $in $LINK_ARGS $aliasing\n'
  25 + command = command_template.format(
  26 + executable=' '.join(compiler.get_linker_exelist()),
  27 + cross_args=' '.join(cross_args),
  28 +--
  29 +2.15.0
recipes-devtools/meson/meson/0001-Support-building-allarch-recipes-again.patch
  1 +From d80d02a3ca6e21fa3d055c88c05234c2eb4db128 Mon Sep 17 00:00:00 2001
  2 +From: Peter Kjellerstedt <pkj@axis.com>
  3 +Date: Thu, 26 Jul 2018 16:32:49 +0200
  4 +Subject: [PATCH] Support building allarch recipes again
  5 +
  6 +This registers "allarch" as a known CPU family.
  7 +
  8 +Upstream-Status: Inappropriate [OE specific]
  9 +Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
  10 +---
  11 + mesonbuild/environment.py | 1 +
  12 + 1 file changed, 1 insertion(+)
  13 +
  14 +Index: meson-0.47.2/mesonbuild/environment.py
  15 +===================================================================
  16 +--- meson-0.47.2.orig/mesonbuild/environment.py
  17 ++++ meson-0.47.2/mesonbuild/environment.py
  18 +@@ -75,6 +75,7 @@ from .compilers import (
  19 + build_filename = 'meson.build'
  20 +
  21 + known_cpu_families = (
  22 ++ 'allarch',
  23 + 'aarch64',
  24 + 'arm',
  25 + 'e2k',
recipes-devtools/meson/meson/0001-gtkdoc-fix-issues-that-arise-when-cross-compiling.patch
  1 +From 3ac4e58c5494bd7e603a325b5b5c2b8075849fee Mon Sep 17 00:00:00 2001
  2 +From: Alexander Kanavin <alex.kanavin@gmail.com>
  3 +Date: Fri, 4 Aug 2017 16:16:41 +0300
  4 +Subject: [PATCH] gtkdoc: fix issues that arise when cross-compiling
  5 +
  6 +Specifically:
  7 +1) Make it possible to specify a wrapper for executing binaries
  8 +(usually, some kind of target hardware emulator, such as qemu)
  9 +2) Explicitly provide CC and LD via command line, as otherwise gtk-doc will
  10 +try to guess them, incorrectly.
  11 +3) If things break down, print the full command with arguments,
  12 +not just the binary name.
  13 +4) Correctly determine the compiler/linker executables and cross-options when cross-compiling
  14 +
  15 +Upstream-Status: Pending
  16 +Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
  17 +
  18 +---
  19 + mesonbuild/modules/gnome.py | 18 +++++++++++++++---
  20 + mesonbuild/scripts/gtkdochelper.py | 9 +++++++--
  21 + 2 files changed, 22 insertions(+), 5 deletions(-)
  22 +
  23 +diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py
  24 +index cb69641..727eb6a 100644
  25 +--- a/mesonbuild/modules/gnome.py
  26 ++++ b/mesonbuild/modules/gnome.py
  27 +@@ -792,6 +792,10 @@ This will become a hard error in the future.''')
  28 + '--mode=' + mode]
  29 + if namespace:
  30 + args.append('--namespace=' + namespace)
  31 ++ gtkdoc_exe_wrapper = state.environment.cross_info.config["properties"].get('gtkdoc_exe_wrapper', None)
  32 ++ if gtkdoc_exe_wrapper is not None:
  33 ++ args.append('--gtkdoc-exe-wrapper=' + gtkdoc_exe_wrapper)
  34 ++
  35 + args += self._unpack_args('--htmlargs=', 'html_args', kwargs)
  36 + args += self._unpack_args('--scanargs=', 'scan_args', kwargs)
  37 + args += self._unpack_args('--scanobjsargs=', 'scanobjs_args', kwargs)
  38 +diff --git a/mesonbuild/scripts/gtkdochelper.py b/mesonbuild/scripts/gtkdochelper.py
  39 +index 948dc5a..9c5bd19 100644
  40 +--- a/mesonbuild/scripts/gtkdochelper.py
  41 ++++ b/mesonbuild/scripts/gtkdochelper.py
  42 +@@ -45,6 +45,7 @@ parser.add_argument('--ignore-headers', dest='ignore_headers', default='')
  43 + parser.add_argument('--namespace', dest='namespace', default='')
  44 + parser.add_argument('--mode', dest='mode', default='')
  45 + parser.add_argument('--installdir', dest='install_dir')
  46 ++parser.add_argument('--gtkdoc-exe-wrapper', dest='gtkdoc_exe_wrapper')
  47 +
  48 + def gtkdoc_run_check(cmd, cwd, library_paths=None):
  49 + if library_paths is None:
  50 +@@ -64,7 +65,7 @@ def gtkdoc_run_check(cmd, cwd, library_paths=None):
  51 + # This preserves the order of messages.
  52 + p, out = Popen_safe(cmd, cwd=cwd, env=env, stderr=subprocess.STDOUT)[0:2]
  53 + if p.returncode != 0:
  54 +- err_msg = ["{!r} failed with status {:d}".format(cmd[0], p.returncode)]
  55 ++ err_msg = ["{!r} failed with status {:d}".format(cmd, p.returncode)]
  56 + if out:
  57 + err_msg.append(out)
  58 + raise MesonException('\n'.join(err_msg))
  59 +@@ -74,7 +75,7 @@ def gtkdoc_run_check(cmd, cwd, library_paths=None):
  60 + def build_gtkdoc(source_root, build_root, doc_subdir, src_subdirs,
  61 + main_file, module,
  62 + html_args, scan_args, fixxref_args, mkdb_args,
  63 +- gobject_typesfile, scanobjs_args, ld, cc, ldflags, cflags,
  64 ++ gobject_typesfile, scanobjs_args, gtkdoc_exe_wrapper, ld, cc, ldflags, cflags,
  65 + html_assets, content_files, ignore_headers, namespace,
  66 + expand_content_files, mode):
  67 + print("Building documentation for %s" % module)
  68 +@@ -135,6 +136,9 @@ def build_gtkdoc(source_root, build_root, doc_subdir, src_subdirs,
  69 + if gobject_typesfile:
  70 + scanobjs_cmd = ['gtkdoc-scangobj'] + scanobjs_args + ['--types=' + gobject_typesfile,
  71 + '--module=' + module,
  72 ++ '--run=' + gtkdoc_exe_wrapper,
  73 ++ '--cc=' + cc,
  74 ++ '--ld=' + ld,
  75 + '--cflags=' + cflags,
  76 + '--ldflags=' + ldflags,
  77 + '--cc=' + cc,
  78 +@@ -238,6 +242,7 @@ def run(args):
  79 + mkdbargs,
  80 + options.gobject_typesfile,
  81 + scanobjsargs,
  82 ++ options.gtkdoc_exe_wrapper,
  83 + options.ld,
  84 + options.cc,
  85 + options.ldflags,
recipes-devtools/meson/meson/0001-python-module-do-not-manipulate-the-environment-when.patch
  1 +From 45426f06689a520fc47f81ee29b49d509f11ba58 Mon Sep 17 00:00:00 2001
  2 +From: Alexander Kanavin <alex.kanavin@gmail.com>
  3 +Date: Mon, 19 Nov 2018 14:24:26 +0100
  4 +Subject: [PATCH] python module: do not manipulate the environment when calling
  5 + pkg-config
  6 +
  7 +Upstream-Status: Inappropriate [oe-core specific]
  8 +Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
  9 +---
  10 + mesonbuild/modules/python.py | 14 --------------
  11 + 1 file changed, 14 deletions(-)
  12 +
  13 +diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py
  14 +index 1195d8a..df81da4 100644
  15 +--- a/mesonbuild/modules/python.py
  16 ++++ b/mesonbuild/modules/python.py
  17 +@@ -67,26 +67,12 @@ class PythonDependency(ExternalDependency):
  18 + if DependencyMethods.PKGCONFIG in self.methods and not python_holder.is_pypy:
  19 + pkg_version = self.variables.get('LDVERSION') or self.version
  20 + pkg_libdir = self.variables.get('LIBPC')
  21 +- old_pkg_libdir = os.environ.get('PKG_CONFIG_LIBDIR')
  22 +- old_pkg_path = os.environ.get('PKG_CONFIG_PATH')
  23 +-
  24 +- os.environ.pop('PKG_CONFIG_PATH', None)
  25 +-
  26 +- if pkg_libdir:
  27 +- os.environ['PKG_CONFIG_LIBDIR'] = pkg_libdir
  28 +
  29 + try:
  30 + self.pkgdep = PkgConfigDependency('python-{}'.format(pkg_version), environment, kwargs)
  31 + except Exception:
  32 + pass
  33 +
  34 +- if old_pkg_path is not None:
  35 +- os.environ['PKG_CONFIG_PATH'] = old_pkg_path
  36 +-
  37 +- if old_pkg_libdir is not None:
  38 +- os.environ['PKG_CONFIG_LIBDIR'] = old_pkg_libdir
  39 +- else:
  40 +- os.environ.pop('PKG_CONFIG_LIBDIR', None)
  41 +
  42 + if self.pkgdep and self.pkgdep.found():
  43 + self.compile_args = self.pkgdep.get_compile_args()
recipes-devtools/meson/meson/0002-Make-CPU-family-warnings-fatal.patch
  1 +From 2e8553fc01e62ebc4faa240bf20984a8a0ac7387 Mon Sep 17 00:00:00 2001
  2 +From: Ross Burton <ross.burton@intel.com>
  3 +Date: Tue, 3 Jul 2018 13:59:09 +0100
  4 +Subject: [PATCH] Make CPU family warnings fatal
  5 +
  6 +Upstream-Status: Inappropriate [OE specific]
  7 +Signed-off-by: Ross Burton <ross.burton@intel.com>
  8 +
  9 +---
  10 + mesonbuild/environment.py | 6 ++----
  11 + 1 file changed, 2 insertions(+), 4 deletions(-)
  12 +
  13 +diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
  14 +index d29a77f..267acf9 100644
  15 +--- a/mesonbuild/environment.py
  16 ++++ b/mesonbuild/environment.py
  17 +@@ -239,9 +239,7 @@ def detect_cpu_family(compilers):
  18 + return 'x86_64'
  19 +
  20 + if trial not in known_cpu_families:
  21 +- mlog.warning('Unknown CPU family {!r}, please report this at '
  22 +- 'https://github.com/mesonbuild/meson/issues/new with the'
  23 +- 'output of `uname -a` and `cat /proc/cpuinfo`'.format(trial))
  24 ++ raise EnvironmentException('Unknown CPU family %s, see https://wiki.yoctoproject.org/wiki/Meson/UnknownCPU for directions.' % trial)
  25 +
  26 + return trial
  27 +
  28 +@@ -1014,7 +1012,7 @@ class CrossBuildInfo:
  29 + raise EnvironmentException('Malformed value in cross file variable %s.' % entry)
  30 +
  31 + if entry == 'cpu_family' and res not in known_cpu_families:
  32 +- mlog.warning('Unknown CPU family %s, please report this at https://github.com/mesonbuild/meson/issues/new' % value)
  33 ++ raise EnvironmentException('Unknown CPU family %s, see https://wiki.yoctoproject.org/wiki/Meson/UnknownCPU for directions.' % value)
  34 +
  35 + if self.ok_type(res):
  36 + self.config[s][entry] = res
recipes-devtools/meson/meson/0002-gobject-introspection-determine-g-ir-scanner-and-g-i.patch
  1 +From 0b860cb8a22ae876b6088939dbabca216bc29431 Mon Sep 17 00:00:00 2001
  2 +From: Alexander Kanavin <alex.kanavin@gmail.com>
  3 +Date: Fri, 4 Aug 2017 16:18:47 +0300
  4 +Subject: [PATCH] gobject-introspection: determine g-ir-scanner and
  5 + g-ir-compiler paths from pkgconfig
  6 +
  7 +Do not hardcode the name of those binaries; gobject-introspection
  8 +provides them via pkgconfig, and they can be set to something else
  9 +(for example when cross-compiling).
  10 +
  11 +Upstream-Status: Pending
  12 +Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
  13 +
  14 +---
  15 + mesonbuild/modules/gnome.py | 4 ++--
  16 + 1 file changed, 2 insertions(+), 2 deletions(-)
  17 +
  18 +diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py
  19 +index b29bab9..dc4c401 100644
  20 +--- a/mesonbuild/modules/gnome.py
  21 ++++ b/mesonbuild/modules/gnome.py
  22 +@@ -393,8 +393,6 @@ class GnomeModule(ExtensionModule):
  23 + raise MesonException('Gir takes one argument')
  24 + if kwargs.get('install_dir'):
  25 + raise MesonException('install_dir is not supported with generate_gir(), see "install_dir_gir" and "install_dir_typelib"')
  26 +- giscanner = self.interpreter.find_program_impl('g-ir-scanner')
  27 +- gicompiler = self.interpreter.find_program_impl('g-ir-compiler')
  28 + girtarget = args[0]
  29 + while hasattr(girtarget, 'held_object'):
  30 + girtarget = girtarget.held_object
  31 +@@ -405,6 +403,8 @@ class GnomeModule(ExtensionModule):
  32 + self.gir_dep = PkgConfigDependency('gobject-introspection-1.0',
  33 + state.environment,
  34 + {'native': True})
  35 ++ giscanner = os.environ['PKG_CONFIG_SYSROOT_DIR'] + self.gir_dep.get_pkgconfig_variable('g_ir_scanner', {})
  36 ++ gicompiler = os.environ['PKG_CONFIG_SYSROOT_DIR'] + self.gir_dep.get_pkgconfig_variable('g_ir_compiler', {})
  37 + pkgargs = self.gir_dep.get_compile_args()
  38 + except Exception:
  39 + raise MesonException('gobject-introspection dependency was not found, gir cannot be generated.')
recipes-devtools/meson/meson/0003-native_bindir.patch
  1 +From e762d85c823adfefc27ba6128c7b997aa50166ce Mon Sep 17 00:00:00 2001
  2 +From: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
  3 +Date: Wed, 15 Nov 2017 15:05:01 +0100
  4 +Subject: [PATCH] native_bindir
  5 +
  6 +Some libraries, like QT, have pre-processors that convert their input
  7 +files into something that the cross-compiler can process. We find the
  8 +path of those pre-processors via pkg-config-native instead of
  9 +pkg-config.
  10 +
  11 +This path forces the use of pkg-config-native for host_bins arguments.
  12 +
  13 +There are some discussions upstream to merge this patch, but I presonaly believe
  14 +that is is OE only. https://github.com/mesonbuild/meson/issues/1849#issuecomment-303730323
  15 +
  16 +Upstream-Status: Inappropriate [OE specific]
  17 +Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
  18 +
  19 +---
  20 + mesonbuild/dependencies/base.py | 19 +++++++++++--------
  21 + mesonbuild/dependencies/ui.py | 6 +++---
  22 + 2 files changed, 14 insertions(+), 11 deletions(-)
  23 +
  24 +diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
  25 +index 6d3678f..90fdb80 100644
  26 +--- a/mesonbuild/dependencies/base.py
  27 ++++ b/mesonbuild/dependencies/base.py
  28 +@@ -146,7 +146,7 @@ class Dependency:
  29 + def need_threads(self):
  30 + return False
  31 +
  32 +- def get_pkgconfig_variable(self, variable_name, kwargs):
  33 ++ def get_pkgconfig_variable(self, variable_name, kwargs, use_native=False):
  34 + raise DependencyException('{!r} is not a pkgconfig dependency'.format(self.name))
  35 +
  36 + def get_configtool_variable(self, variable_name):
  37 +@@ -183,7 +183,7 @@ class InternalDependency(Dependency):
  38 + self.sources = sources
  39 + self.ext_deps = ext_deps
  40 +
  41 +- def get_pkgconfig_variable(self, variable_name, kwargs):
  42 ++ def get_pkgconfig_variable(self, variable_name, kwargs, use_native=False):
  43 + raise DependencyException('Method "get_pkgconfig_variable()" is '
  44 + 'invalid for an internal dependency')
  45 +
  46 +@@ -523,15 +523,18 @@ class PkgConfigDependency(ExternalDependency):
  47 + return s.format(self.__class__.__name__, self.name, self.is_found,
  48 + self.version_reqs)
  49 +
  50 +- def _call_pkgbin_real(self, args, env):
  51 +- cmd = self.pkgbin.get_command() + args
  52 ++ def _call_pkgbin_real(self, args, env, use_native=False):
  53 ++ if use_native:
  54 ++ cmd = self.pkgbin.get_command() + "-native" + args
  55 ++ else:
  56 ++ cmd = self.pkgbin.get_command() + args
  57 + p, out = Popen_safe(cmd, env=env)[0:2]
  58 + rc, out = p.returncode, out.strip()
  59 + call = ' '.join(cmd)
  60 + mlog.debug("Called `{}` -> {}\n{}".format(call, rc, out))
  61 + return rc, out
  62 +
  63 +- def _call_pkgbin(self, args, env=None):
  64 ++ def _call_pkgbin(self, args, env=None, use_native=False):
  65 + if env is None:
  66 + fenv = env
  67 + env = os.environ
  68 +@@ -540,7 +543,7 @@ class PkgConfigDependency(ExternalDependency):
  69 + targs = tuple(args)
  70 + cache = PkgConfigDependency.pkgbin_cache
  71 + if (self.pkgbin, targs, fenv) not in cache:
  72 +- cache[(self.pkgbin, targs, fenv)] = self._call_pkgbin_real(args, env)
  73 ++ cache[(self.pkgbin, targs, fenv)] = self._call_pkgbin_real(args, env, use_native)
  74 + return cache[(self.pkgbin, targs, fenv)]
  75 +
  76 + def _convert_mingw_paths(self, args):
  77 +@@ -718,7 +721,7 @@ class PkgConfigDependency(ExternalDependency):
  78 + (self.name, out_raw))
  79 + self.link_args, self.raw_link_args = self._search_libs(out, out_raw)
  80 +
  81 +- def get_pkgconfig_variable(self, variable_name, kwargs):
  82 ++ def get_pkgconfig_variable(self, variable_name, kwargs, use_native=False):
  83 + options = ['--variable=' + variable_name, self.name]
  84 +
  85 + if 'define_variable' in kwargs:
  86 +@@ -731,7 +734,7 @@ class PkgConfigDependency(ExternalDependency):
  87 +
  88 + options = ['--define-variable=' + '='.join(definition)] + options
  89 +
  90 +- ret, out = self._call_pkgbin(options)
  91 ++ ret, out = self._call_pkgbin(options, use_native=use_native)
  92 + variable = ''
  93 + if ret != 0:
  94 + if self.required:
  95 +diff --git a/mesonbuild/dependencies/ui.py b/mesonbuild/dependencies/ui.py
  96 +index 197d22c..c683d21 100644
  97 +--- a/mesonbuild/dependencies/ui.py
  98 ++++ b/mesonbuild/dependencies/ui.py
  99 +@@ -285,7 +285,7 @@ class QtBaseDependency(ExternalDependency):
  100 + self.bindir = self.get_pkgconfig_host_bins(core)
  101 + if not self.bindir:
  102 + # If exec_prefix is not defined, the pkg-config file is broken
  103 +- prefix = core.get_pkgconfig_variable('exec_prefix', {})
  104 ++ prefix = core.get_pkgconfig_variable('exec_prefix', {}, use_native=True)
  105 + if prefix:
  106 + self.bindir = os.path.join(prefix, 'bin')
  107 +
  108 +@@ -427,7 +427,7 @@ class Qt4Dependency(QtBaseDependency):
  109 + applications = ['moc', 'uic', 'rcc', 'lupdate', 'lrelease']
  110 + for application in applications:
  111 + try:
  112 +- return os.path.dirname(core.get_pkgconfig_variable('%s_location' % application, {}))
  113 ++ return os.path.dirname(core.get_pkgconfig_variable('%s_location' % application, {}, use_native=True))
  114 + except MesonException:
  115 + pass
  116 +
  117 +@@ -437,7 +437,7 @@ class Qt5Dependency(QtBaseDependency):
  118 + QtBaseDependency.__init__(self, 'qt5', env, kwargs)
  119 +
  120 + def get_pkgconfig_host_bins(self, core):
  121 +- return core.get_pkgconfig_variable('host_bins', {})
  122 ++ return core.get_pkgconfig_variable('host_bins', {}, use_native=True)
  123 +
  124 + def get_private_includes(self, mod_inc_dir, module):
  125 + return _qt_get_private_includes(mod_inc_dir, module, self.version)
recipes-devtools/meson/meson/disable-rpath-handling.patch
  1 +We need to allow our rpaths generated through the compiler flags to make it into
  2 +our binaries. Therefore disable the meson manipulations of these unless there
  3 +is a specific directive to do something differently in the project.
  4 +
  5 +RP 2018/11/23
  6 +
  7 +Upstream-Status: Submitted [https://github.com/mesonbuild/meson/issues/2567]
  8 +
  9 +Index: meson-0.47.2/mesonbuild/minstall.py
  10 +===================================================================
  11 +--- meson-0.47.2.orig/mesonbuild/minstall.py
  12 ++++ meson-0.47.2/mesonbuild/minstall.py
  13 +@@ -486,8 +486,11 @@ class Installer:
  14 + printed_symlink_error = True
  15 + if os.path.isfile(outname):
  16 + try:
  17 +- depfixer.fix_rpath(outname, install_rpath, final_path,
  18 +- install_name_mappings, verbose=False)
  19 ++ if install_rpath:
  20 ++ depfixer.fix_rpath(outname, install_rpath, final_path,
  21 ++ install_name_mappings, verbose=False)
  22 ++ else:
  23 ++ print("RPATH changes at install time disabled")
  24 + except SystemExit as e:
  25 + if isinstance(e.code, int) and e.code == 0:
  26 + pass
recipes-devtools/meson/meson/gi-flags.patch
  1 +Pass the correct cflags/ldflags to the gobject-introspection tools.
  2 +
  3 +Upstream-Status: Submitted [https://github.com/mesonbuild/meson/pull/4261]
  4 +Signed-off-by: Ross Burton <ross.burton@intel.com>
  5 +
  6 +diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py
  7 +index cb69641e..bb4449a0 100644
  8 +--- a/mesonbuild/modules/gnome.py
  9 ++++ b/mesonbuild/modules/gnome.py
  10 +@@ -579,7 +579,10 @@ class GnomeModule(ExtensionModule):
  11 + external_ldflags += list(dep_external_ldflags)
  12 + scan_command += ['--cflags-begin']
  13 + scan_command += cflags
  14 +- scan_command += state.environment.coredata.get_external_args(lang)
  15 ++ if state.environment.is_cross_build():
  16 ++ scan_command += state.environment.cross_info.config["properties"].get(lang + '_args', "")
  17 ++ else:
  18 ++ scan_command += state.environment.coredata.get_external_args(lang)
  19 + scan_command += ['--cflags-end']
  20 + # need to put our output directory first as we need to use the
  21 + # generated libraries instead of any possibly installed system/prefix
  22 +@@ -614,7 +614,12 @@ class GnomeModule(ExtensionModule):
  23 + scan_command.append('-L' + d)
  24 + scan_command += ['--library', libname]
  25 +
  26 +- for link_arg in state.environment.coredata.get_external_link_args(lang):
  27 ++ if state.environment.is_cross_build():
  28 ++ link_args = state.environment.cross_info.config["properties"].get(lang + '_link_args', "")
  29 ++ else:
  30 ++ link_args = state.environment.coredata.get_external_link_args(lang)
  31 ++
  32 ++ for link_arg in link_args:
  33 + if link_arg.startswith('-L'):
  34 + scan_command.append(link_arg)
  35 + scan_command += list(external_ldflags)
recipes-devtools/meson/meson/gtkdoc-flags.patch
  1 +Ensure that in a cross compile only the target flags are passed to gtk-doc, and
  2 +not the native flags.
  3 +
  4 +Upstream-Status: Submitted [https://github.com/mesonbuild/meson/pull/4261]
  5 +Signed-off-by: Ross Burton <ross.burton@intel.com>
  6 +
  7 +diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py
  8 +index 4af33304..8751f53c 100644
  9 +--- a/mesonbuild/modules/gnome.py
  10 ++++ b/mesonbuild/modules/gnome.py
  11 +@@ -851,17 +851,30 @@ This will become a hard error in the future.''')
  12 + if not isinstance(incd.held_object, (str, build.IncludeDirs)):
  13 + raise MesonException(
  14 + 'Gir include dirs should be include_directories().')
  15 ++
  16 + cflags.update(get_include_args(inc_dirs))
  17 +- cflags.update(state.environment.coredata.get_external_args('c'))
  18 ++ if state.environment.is_cross_build():
  19 ++ cflags.update(state.environment.cross_info.config["properties"].get('c_args', ""))
  20 ++ else:
  21 ++ cflags.update(state.environment.coredata.get_external_args('c'))
  22 ++
  23 + ldflags = OrderedSet()
  24 + ldflags.update(internal_ldflags)
  25 +- ldflags.update(state.environment.coredata.get_external_link_args('c'))
  26 ++ if state.environment.is_cross_build():
  27 ++ ldflags.update(state.environment.cross_info.config["properties"].get('c_link_args', ""))
  28 ++ else:
  29 ++ ldflags.update(state.environment.coredata.get_external_link_args('c'))
  30 + ldflags.update(external_ldflags)
  31 ++
  32 + if cflags:
  33 + args += ['--cflags=%s' % ' '.join(cflags)]
  34 + if ldflags:
  35 + args += ['--ldflags=%s' % ' '.join(ldflags)]
  36 +- compiler = state.environment.coredata.compilers.get('c')
  37 ++
  38 ++ if state.environment.is_cross_build():
  39 ++ compiler = state.environment.coredata.cross_compilers.get('c')
  40 ++ else:
  41 ++ compiler = state.environment.coredata.compilers.get('c')
  42 + if compiler:
  43 + args += ['--cc=%s' % ' '.join(compiler.get_exelist())]
  44 + args += ['--ld=%s' % ' '.join(compiler.get_linker_exelist())]
recipes-devtools/meson/meson/meson-setup.py
  1 +#!/usr/bin/env python3
  2 +
  3 +import os
  4 +import sys
  5 +
  6 +def bail(msg):
  7 + print(msg, file=sys.stderr)
  8 + sys.exit(1)
  9 +
  10 +_MARKER = '@@'
  11 +def transform_line(line):
  12 + # Substitute any special markers of this form:
  13 + # @@ENV@@
  14 + # with the value of ENV, split into meson array syntax.
  15 + start = line.find(_MARKER)
  16 + if start == -1:
  17 + return line
  18 +
  19 + end = line.rfind(_MARKER)
  20 + if end == start:
  21 + return line
  22 +
  23 + # Lookup value of the env var.
  24 + var = line[start+len(_MARKER):end]
  25 + try:
  26 + val = os.environ[var]
  27 + except KeyError:
  28 + bail('cannot generate meson.cross; env var %s not set' % var)
  29 +
  30 + # Transform into meson array.
  31 + val = ["'%s'" % x for x in val.split()]
  32 + val = ', '.join(val)
  33 + val = '[%s]' % val
  34 +
  35 + before = line[:start]
  36 + after = line[end+len(_MARKER):]
  37 +
  38 + return '%s%s%s' % (before, val, after)
  39 +
  40 +# Make sure this is really an SDK extraction environment.
  41 +try:
  42 + sysroot = os.environ['OECORE_NATIVE_SYSROOT']
  43 +except KeyError:
  44 + bail('OECORE_NATIVE_SYSROOT env var must be set')
  45 +
  46 +cross_file = os.path.join(sysroot, 'usr/share/meson/meson.cross')
  47 +tmp_cross_file = '%s.tmp' % cross_file
  48 +
  49 +# Read through and transform the current meson.cross.
  50 +lines = []
  51 +with open(cross_file, 'r') as f:
  52 + for line in f:
  53 + lines.append(transform_line(line))
  54 +
  55 +# Write the transformed result to a tmp file and atomically rename it. In case
  56 +# we crash during the file write, we don't want an invalid meson.cross file.
  57 +with open(tmp_cross_file, 'w') as f:
  58 + for line in lines:
  59 + f.write(line)
  60 + f.flush()
  61 + os.fdatasync(f.fileno())
  62 +os.rename(tmp_cross_file, cross_file)
recipes-devtools/meson/meson/meson-wrapper
  1 +#!/bin/sh
  2 +
  3 +if [ -z "$OECORE_NATIVE_SYSROOT" ]; then
  4 + echo "OECORE_NATIVE_SYSROOT not set; are you in a Yocto SDK environment?" >&2
  5 +fi
  6 +
  7 +# If these are set to a cross-compile path, meson will get confused and try to
  8 +# use them as native tools. Unset them to prevent this, as all the cross-compile
  9 +# config is already in meson.cross.
  10 +unset CC CXX CPP LD AR NM STRIP
  11 +
  12 +exec "$OECORE_NATIVE_SYSROOT/usr/bin/meson.real" \
  13 + --cross-file "$OECORE_NATIVE_SYSROOT/usr/share/meson/meson.cross" \
  14 + "$@"
recipes-devtools/meson/meson_0.47.2.bb
  1 +include meson.inc
  2 +
  3 +BBCLASSEXTEND = "native"
recipes-devtools/meson/nativesdk-meson_0.47.2.bb
  1 +include meson.inc
  2 +
  3 +inherit nativesdk
  4 +
  5 +SRC_URI += "file://meson-setup.py \
  6 + file://meson-wrapper"
  7 +
  8 +def meson_array(var, d):
  9 + return "', '".join(d.getVar(var).split()).join(("'", "'"))
  10 +
  11 +# both are required but not used by meson
  12 +MESON_SDK_ENDIAN = "bogus-endian"
  13 +MESON_TARGET_ENDIAN = "bogus-endian"
  14 +
  15 +MESON_TOOLCHAIN_ARGS = "${BUILDSDK_CC_ARCH}${TOOLCHAIN_OPTIONS}"
  16 +MESON_C_ARGS = "${MESON_TOOLCHAIN_ARGS} ${BUILDSDK_CFLAGS}"
  17 +MESON_CPP_ARGS = "${MESON_TOOLCHAIN_ARGS} ${BUILDSDK_CXXFLAGS}"
  18 +MESON_LINK_ARGS = "${MESON_TOOLCHAIN_ARGS} ${BUILDSDK_LDFLAGS}"
  19 +
  20 +# This logic is similar but not identical to that in meson.bbclass, since it's
  21 +# generating for an SDK rather than a cross-compile. Important differences are:
  22 +# - We can't set vars like CC, CXX, etc. yet because they will be filled in with
  23 +# real paths by meson-setup.sh when the SDK is extracted.
  24 +# - Some overrides aren't needed, since the SDK injects paths that take care of
  25 +# them.
  26 +addtask write_config before do_install
  27 +do_write_config[vardeps] += "MESON_C_ARGS MESON_CPP_ARGS MESON_LINK_ARGS CC CXX LD AR NM STRIP READELF"
  28 +do_write_config() {
  29 + # This needs to be Py to split the args into single-element lists
  30 + cat >${WORKDIR}/meson.cross <<EOF
  31 +[binaries]
  32 +c = @@CC@@
  33 +cpp = @@CXX@@
  34 +ar = @@AR@@
  35 +nm = @@NM@@
  36 +ld = @@LD@@
  37 +strip = @@STRIP@@
  38 +pkgconfig = 'pkg-config'
  39 +
  40 +[properties]
  41 +needs_exe_wrapper = true
  42 +c_args = @@CFLAGS@@
  43 +c_link_args = @@LDFLAGS@@
  44 +cpp_args = @@CPPFLAGS@@
  45 +cpp_link_args = @@LDFLAGS@@
  46 +
  47 +[host_machine]
  48 +system = '${SDK_OS}'
  49 +cpu_family = '${SDK_ARCH}'
  50 +cpu = '${SDK_ARCH}'
  51 +endian = '${MESON_SDK_ENDIAN}'
  52 +EOF
  53 +}
  54 +
  55 +do_install_append() {
  56 + install -d ${D}${datadir}/meson
  57 + install -m 0644 ${WORKDIR}/meson.cross ${D}${datadir}/meson/
  58 +
  59 + install -d ${D}${SDKPATHNATIVE}/post-relocate-setup.d
  60 + install -m 0755 ${WORKDIR}/meson-setup.py ${D}${SDKPATHNATIVE}/post-relocate-setup.d/
  61 +
  62 + # We need to wrap the real meson with a thin env setup wrapper.
  63 + mv ${D}${bindir}/meson ${D}${bindir}/meson.real
  64 + install -m 0755 ${WORKDIR}/meson-wrapper ${D}${bindir}/meson
  65 +}
  66 +
  67 +RDEPENDS_${PN} += "\
  68 + nativesdk-ninja \
  69 + nativesdk-python3-core \
  70 + nativesdk-python3-misc \
  71 + nativesdk-python3-modules \
  72 + "
  73 +
  74 +FILES_${PN} += "${datadir}/meson ${SDKPATHNATIVE}"
scripts/emb_mk_yocto_sdcard/README.txt
  1 +How to use the Embedian SD card creation script:
  2 +=================================================
  3 +
  4 +This utility is provided on an "AS IS" basis.
  5 +This is the script we use to create our recovery SD card.
  6 +For machines with Android support, it is a part of a larger script we use to create our recovery SD card, which also includes Android.
  7 +It is a good example for using the output of the Yocto build to create a bootable SD card, and use it to flash the target NAND flash/eMMC.
  8 +
  9 +Note:
  10 +Before running this script you need to bitbake fsl-image-gui.
  11 +
  12 +
  13 +Usage:
  14 +sudo MACHINE=<smarcimx8m2g|smarcimx8m4g> ./emb-create-yocto-sdcard.sh [options] /dev/sdX
  15 +(Change /dev/sdX to your device name)
  16 +
  17 +options:
  18 + -h Display help message
  19 + -s Only show partition sizes to be written, without actually write them
  20 + -a Automatically set the rootfs partition size to fill the SD card
  21 + -r Select alternative rootfs for recovery images (default: build_x11/tmp/deploy/images/<machine name>/fsl-image-validation-imx.tar.bz2)
  22 +
  23 +If you don't use the '-a' option, a default rootfs size of 3700MiB will be used.
  24 +The '-r' option allows you to create a bootable sdcard with an alternative image for the installation to NAND flash or eMMC.
  25 +Example: "-r tmp/deploy/images/<machine name>/fsl-image-qt5-validation-imx" -- selects the "Qt5 image with X11" recovery image
  26 +
  27 +
  28 +Once the script is done, use the SD card to boot, and then to flash your internal storage/s either use the icons,
  29 +or the following linux shell script:
  30 +install_yocto.sh
scripts/emb_mk_yocto_sdcard/emb-create-yocto-emmc.sh
  1 +#!/bin/bash -e
  2 +
  3 +blue_underlined_bold_echo()
  4 +{
  5 + echo -e "\e[34m\e[4m\e[1m$@\e[0m"
  6 +}
  7 +
  8 +blue_bold_echo()
  9 +{
  10 + echo -e "\e[34m\e[1m$@\e[0m"
  11 +}
  12 +
  13 +red_bold_echo()
  14 +{
  15 + echo -e "\e[31m\e[1m$@\e[0m"
  16 +}
  17 +
  18 +IMGS_PATH=/opt/images/Yocto
  19 +UBOOT_IMAGE=imx-boot-sd.bin
  20 +KERNEL_IMAGE=Image
  21 +ROOTFS_IMAGE=rootfs.tar.bz2
  22 +BOOTLOADER_RESERVED_SIZE=2
  23 +PART1_SIZE=48
  24 +BOOTLOADER_OFFSET=33
  25 +DISPLAY=-hdmi
  26 +PART=p
  27 +BOOTPART=1
  28 +ROOTFSPART=2
  29 +BOOTDIR=/boot
  30 +
  31 +check_board()
  32 +{
  33 + if grep -q "i.MX8M" /sys/devices/soc0/soc_id; then
  34 + BOARD=smarc-imx8m
  35 + DTB_PREFIX=fsl-smarcimx8mq
  36 + BLOCK=mmcblk0
  37 +
  38 + if [[ $DISPLAY != "-lvds" && $DISPLAY != "-hdmi" && \
  39 + $DISPLAY != "-dual-display" && $DISPLAY != "" ]]; then
  40 + red_bold_echo "ERROR: invalid display, should be lvds, hdmi, dual-display or empty"
  41 + exit 1
  42 + fi
  43 + else
  44 + red_bold_echo "ERROR: Unsupported board"
  45 + exit 1
  46 + fi
  47 +
  48 +
  49 + if [[ ! -b /dev/${BLOCK} ]] ; then
  50 + red_bold_echo "ERROR: Can't find eMMC device (/dev/${BLOCK})."
  51 + red_bold_echo "Please verify you are using the correct options for your SMARC Module."
  52 + exit 1
  53 + fi
  54 +}
  55 +
  56 +check_images()
  57 +{
  58 + if [[ ! -f $IMGS_PATH/$UBOOT_IMAGE ]] ; then
  59 + red_bold_echo "ERROR: \"$IMGS_PATH/$UBOOT_IMAGE\" does not exist"
  60 + exit 1
  61 + fi
  62 +
  63 + if [[ ! -f $IMGS_PATH/$KERNEL_IMAGE ]] ; then
  64 + red_bold_echo "ERROR: \"$IMGS_PATH/$KERNEL_IMAGE\" does not exist"
  65 + exit 1
  66 + fi
  67 +
  68 + if [[ ! -f $IMGS_PATH/${DTB_PREFIX}${DISPLAY}.dtb ]] ; then
  69 + red_bold_echo "ERROR: \"$IMGS_PATH/${DTB_PREFIX}${DISPLAY}.dtb\" does not exist"
  70 + exit 1
  71 + fi
  72 +
  73 + if [[ ! -f $IMGS_PATH/uEnv.txt ]] ; then
  74 + red_bold_echo "ERROR: \"$IMGS_PATH/uEnv.txt\" does not exist"
  75 + exit 1
  76 + fi
  77 +
  78 + if [[ ! -f $IMGS_PATH/$ROOTFS_IMAGE ]] ; then
  79 + red_bold_echo "ERROR: \"$IMGS_PATH/$ROOTFS_IMAGE\" does not exist"
  80 + exit 1
  81 + fi
  82 +}
  83 +
  84 +delete_emmc()
  85 +{
  86 + echo
  87 + blue_underlined_bold_echo "Deleting current partitions"
  88 +
  89 + umount /dev/${BLOCK}${PART}* 2>/dev/null || true
  90 +
  91 + for ((i=1; i<=16; i++)); do
  92 + if [[ -e /dev/${BLOCK}${PART}${i} ]]; then
  93 + dd if=/dev/zero of=/dev/${BLOCK}${PART}${i} bs=1M count=1 2>/dev/null || true
  94 + fi
  95 + done
  96 + sync
  97 +
  98 + dd if=/dev/zero of=/dev/${BLOCK} bs=1M count=${BOOTLOADER_RESERVED_SIZE}
  99 +
  100 + sync; sleep 1
  101 +}
  102 +
  103 +create_emmc_parts()
  104 +{
  105 + echo
  106 + blue_underlined_bold_echo "Creating new partitions"
  107 +
  108 + SECT_SIZE_BYTES=`cat /sys/block/${BLOCK}/queue/hw_sector_size`
  109 + PART1_FIRST_SECT=$(($BOOTLOADER_RESERVED_SIZE * 1024 * 1024 / $SECT_SIZE_BYTES))
  110 + PART1_END_SECT=$((($BOOTLOADER_RESERVED_SIZE + $PART1_SIZE) * 1024 * 1024 / $SECT_SIZE_BYTES))
  111 + PART2_FIRST_SECT=`expr ${PART1_END_SECT} + 1`
  112 +
  113 + (echo n; echo p; echo $BOOTPART; echo $PART1_FIRST_SECT; \
  114 + echo $PART1_END_SECT; echo n; echo p; echo $ROOTFSPART; \
  115 + echo $PART2_FIRST_SECT; echo; \
  116 + echo p; echo w) | fdisk -u /dev/${BLOCK} > /dev/null
  117 +
  118 + sync; sleep 1
  119 + fdisk -u -l /dev/${BLOCK}
  120 +}
  121 +
  122 +format_emmc_parts()
  123 +{
  124 + echo
  125 + blue_underlined_bold_echo "Formatting partitions"
  126 +
  127 + mkfs.vfat -F 16 /dev/${BLOCK}${PART}${BOOTPART} -n boot
  128 + mkfs.ext4 /dev/${BLOCK}${PART}${ROOTFSPART} -L rootfs
  129 +
  130 + sync; sleep 1
  131 +}
  132 +
  133 +install_bootloader_to_emmc()
  134 +{
  135 + echo
  136 + blue_underlined_bold_echo "Installing booloader"
  137 +
  138 + dd if=${IMGS_PATH}/${UBOOT_IMAGE} of=/dev/${BLOCK} bs=1K seek=${BOOTLOADER_OFFSET}
  139 + sync
  140 +}
  141 +
  142 +install_kernel_to_emmc()
  143 +{
  144 + echo
  145 + blue_underlined_bold_echo "Installing kernel"
  146 +
  147 + MOUNTDIR=/run/media/${BLOCK}${PART}${BOOTPART}
  148 + mkdir -p ${MOUNTDIR}
  149 + mount /dev/${BLOCK}${PART}${BOOTPART} ${MOUNTDIR}
  150 + mkdir -p ${MOUNTDIR}/dtbs/
  151 + cp -v ${IMGS_PATH}/${KERNEL_IMAGE} ${MOUNTDIR}
  152 + cp -v ${IMGS_PATH}/${DTB_PREFIX}${DISPLAY}.dtb ${MOUNTDIR}/dtbs/fsl-smarcimx8mq.dtb
  153 + cp -v ${IMGS_PATH}/uEnv.txt ${MOUNTDIR}
  154 +
  155 + echo
  156 + sync
  157 +
  158 + umount ${MOUNTDIR}
  159 +}
  160 +
  161 +install_rootfs_to_emmc()
  162 +{
  163 + echo
  164 + blue_underlined_bold_echo "Installing rootfs"
  165 +
  166 + MOUNTDIR=/run/media/${BLOCK}${PART}${ROOTFSPART}
  167 + mkdir -p ${MOUNTDIR}
  168 + mount /dev/${BLOCK}${PART}${ROOTFSPART} ${MOUNTDIR}
  169 +
  170 + printf "Extracting files"
  171 + tar --warning=no-timestamp -jxvf ${IMGS_PATH}/${ROOTFS_IMAGE} -C ${MOUNTDIR} --checkpoint=.1200
  172 +
  173 + # Create DTB symlink
  174 + (cd ${MOUNTDIR}/${BOOTDIR}; ln -fs ${DTB_PREFIX}${DISPLAY}.dtb ${DTB_PREFIX}.dtb)
  175 +
  176 + echo
  177 + sync
  178 +
  179 + umount ${MOUNTDIR}
  180 +}
  181 +
  182 +stop_udev()
  183 +{
  184 + if [ -f /lib/systemd/system/systemd-udevd.service ]; then
  185 + systemctl -q mask --runtime systemd-udevd
  186 + systemctl -q stop systemd-udevd
  187 + fi
  188 +}
  189 +
  190 +start_udev()
  191 +{
  192 + if [ -f /lib/systemd/system/systemd-udevd.service ]; then
  193 + systemctl -q unmask --runtime systemd-udevd
  194 + systemctl -q start systemd-udevd
  195 + fi
  196 +}
  197 +
  198 +usage()
  199 +{
  200 + echo
  201 + echo "This script installs Yocto Rootfs on the SMARC-iMX8M's internal eMMC storage device"
  202 + echo
  203 + echo " Usage: $(basename $0) <option>"
  204 + echo
  205 + echo " options:"
  206 + echo " -h show help message"
  207 + echo " -d <lvds|hdmi|dual-display> set display type, default is lvds"
  208 + echo
  209 +}
  210 +
  211 +finish()
  212 +{
  213 + echo
  214 + blue_bold_echo "Yocto Sumo installed successfully"
  215 + exit 0
  216 +}
  217 +
  218 +#################################################
  219 +# Execution starts here #
  220 +#################################################
  221 +
  222 +if [[ $EUID != 0 ]] ; then
  223 + red_bold_echo "This script must be run with super-user privileges"
  224 + exit 1
  225 +fi
  226 +
  227 +blue_underlined_bold_echo "*** Embedian SMARC-iMX8M on-module eMMC Recovery ***"
  228 +echo
  229 +
  230 +while getopts d:h OPTION;
  231 +do
  232 + case $OPTION in
  233 + d)
  234 + DISPLAY=$OPTARG
  235 + ;;
  236 + h)
  237 + usage
  238 + exit 0
  239 + ;;
  240 + *)
  241 + usage
  242 + exit 1
  243 + ;;
  244 + esac
  245 +done
  246 +
  247 +printf "Board: "
  248 +blue_bold_echo $BOARD
  249 +
  250 +printf "Installing to internal storage device: "
  251 +blue_bold_echo eMMC
  252 +
  253 +check_board
  254 +check_images
  255 +stop_udev
  256 +delete_emmc
  257 +create_emmc_parts
  258 +format_emmc_parts
  259 +install_bootloader_to_emmc
  260 +install_kernel_to_emmc
  261 +install_rootfs_to_emmc
  262 +start_udev
  263 +finish
scripts/emb_mk_yocto_sdcard/emb-create-yocto-sdcard.sh
  1 +#!/bin/bash
  2 +set -e
  3 +
  4 +#### Script version ####
  5 +SCRIPT_NAME=${0##*/}
  6 +readonly SCRIPT_VERSION="0.7"
  7 +
  8 +#### Exports Variables ####
  9 +#### global variables ####
  10 +readonly ABSOLUTE_FILENAME=`readlink -e "$0"`
  11 +readonly ABSOLUTE_DIRECTORY=`dirname ${ABSOLUTE_FILENAME}`
  12 +readonly SCRIPT_POINT=${ABSOLUTE_DIRECTORY}
  13 +readonly SCRIPT_START_DATE=`date +%Y%m%d`
  14 +
  15 +readonly YOCTO_ROOT="${SCRIPT_POINT}/../../../../"
  16 +
  17 +readonly BSP_TYPE="YOCTO"
  18 +readonly YOCTO_BUILD=${YOCTO_ROOT}/imx8m-build-qt5wayland
  19 +readonly YOCTO_DEFAULT_IMAGE=fsl-image-qt5-validation-imx
  20 +
  21 +readonly YOCTO_SCRIPTS_PATH=${SCRIPT_POINT}
  22 +readonly YOCTO_IMGS_PATH=${YOCTO_BUILD}/tmp/deploy/images/${MACHINE}
  23 +
  24 +## display (one of "-hdmi", "-lcdif-lvds", "-dp", "-dcss-lvds", "-dual-display", "-edp")
  25 +readonly DISPLAY="-hdmi"
  26 +
  27 +# $1 -- block device
  28 +# $2 -- output images dir
  29 +readonly LPARAM_BLOCK_DEVICE=${1}
  30 +readonly LPARAM_OUTPUT_DIR=${2}
  31 +readonly P1_MOUNT_DIR="${G_TMP_DIR}/p1"
  32 +readonly P2_MOUNT_DIR="${G_TMP_DIR}/p2"
  33 +
  34 +readonly BOOTLOAD_RESERVE_SIZE=2
  35 +readonly PART1_SIZE=48
  36 +readonly BOOTPART=1
  37 +readonly ROOTFSPART=2
  38 +readonly SPARE_SIZE=4
  39 +
  40 +# Sizes are in MiB
  41 +BOOTLOADER_OFFSET=33
  42 +
  43 +AUTO_FILL_SD=0
  44 +LOOP_MAJOR=7
  45 +
  46 +# This function performs sanity check to verify that the target device is removable devise of proper size
  47 +function check_device()
  48 +{
  49 + # Check that parameter is a valid block device
  50 + if [ ! -b "$1" ]; then
  51 + echo "$1 is not a valid block device, exiting"
  52 + exit 1
  53 + fi
  54 +
  55 + local dev=$(basename $1)
  56 +
  57 + # Check that /sys/block/$dev exists
  58 + if [ ! -d /sys/block/$dev ]; then
  59 + echo "Directory /sys/block/${dev} missing, exiting"
  60 + exit 1
  61 + fi
  62 +
  63 + # Get device parameters
  64 + local removable=$(cat /sys/block/${dev}/removable)
  65 + local size_bytes=$((512*$(cat /sys/class/block/${dev}/size)))
  66 + local size_gb=$((size_bytes/1000000000))
  67 +
  68 + # Non-removable SD card readers require additional check
  69 + if [ "${removable}" != "1" ]; then
  70 + local drive=$(udisksctl info -b /dev/${dev}|grep "Drive:"|cut -d"'" -f 2)
  71 + local mediaremovable=$(gdbus call --system --dest org.freedesktop.UDisks2 \
  72 + --object-path ${drive} --method org.freedesktop.DBus.Properties.Get \
  73 + org.freedesktop.UDisks2.Drive MediaRemovable)
  74 + if [[ "${mediaremovable}" = *"true"* ]]; then
  75 + removable=1
  76 + fi
  77 + fi
  78 +
  79 + # Check that device is either removable or loop
  80 + if [ "$removable" != "1" -a $(stat -c '%t' /dev/$dev) != ${LOOP_MAJOR} ]; then
  81 + echo "$1 is not a removable device, exiting"
  82 + exit 1
  83 + fi
  84 +
  85 + # Check that device is attached
  86 + if [ ${size_bytes} -eq 0 ]; then
  87 + echo "$1 is not attached, exiting"
  88 + exit 1
  89 + fi
  90 +
  91 + # Check that device has a valid size
  92 + echo "Detected removable device $1, size=${size_gb}GB"
  93 +}
  94 +
  95 +YOCTO_RECOVERY_ROOTFS_PATH=${YOCTO_IMGS_PATH}
  96 +
  97 +echo "================================================"
  98 +echo "= Embedian recovery SD card creation script ="
  99 +echo "================================================"
  100 +
  101 +help() {
  102 + bn=`basename $0`
  103 + echo " Usage: MACHINE=<smarcimx8m2g|smarcimx8m4g> $bn <options> device_node"
  104 + echo
  105 + echo " options:"
  106 + echo " -h display this Help message"
  107 + echo " -s only Show partition sizes to be written, without actually write them"
  108 + echo " -a Automatically set the rootfs partition size to fill the SD card (leaving spare ${SPARE_SIZE}MiB)"
  109 + echo " -r ROOTFS_NAME select an alternative Rootfs for recovery images"
  110 + echo " (default: \"${YOCTO_RECOVERY_ROOTFS_PATH}/${YOCTO_DEFAULT_IMAGE}\")"
  111 + echo " -n TEXT_FILE add a release Notes text file"
  112 + echo
  113 +}
  114 +
  115 +if [[ $EUID -ne 0 ]] ; then
  116 + echo "This script must be run with super-user privileges"
  117 + exit 1
  118 +fi
  119 +
  120 +if [[ $MACHINE != "smarcimx8m2g" && $MACHINE != "smarcimx8m4g" ]] ; then
  121 + help
  122 + exit 1
  123 +fi
  124 +
  125 +
  126 +# Parse command line
  127 +moreoptions=1
  128 +node="na"
  129 +cal_only=0
  130 +
  131 +while [ "$moreoptions" = 1 -a $# -gt 0 ]; do
  132 + case $1 in
  133 + -h) help; exit 3 ;;
  134 + -s) cal_only=1 ;;
  135 + -a) AUTO_FILL_SD=1 ;;
  136 + -r) shift;
  137 + YOCTO_RECOVERY_ROOTFS_MASK_PATH=`readlink -e "${1}.tar.bz2"`;
  138 + YOCTO_RECOVERY_ROOTFS_PATH=`dirname ${YOCTO_RECOVERY_ROOTFS_MASK_PATH}`
  139 + YOCTO_RECOVERY_ROOTFS_BASE_IN_NAME=`basename ${1}`
  140 + ;;
  141 + -n) shift;
  142 + RELEASE_NOTES_FILE=${1}
  143 + ;;
  144 + *) moreoptions=0;;
  145 + esac
  146 + [ "$moreoptions" = 0 ] && [ $# -gt 1 ] && help && exit 1
  147 + [ "$moreoptions" = 1 ] && shift
  148 +done
  149 +
  150 + part=""
  151 + if [ `echo ${LPARAM_BLOCK_DEVICE} | grep -c mmcblk` -ne 0 ]; then
  152 + part="p"
  153 + fi
  154 +
  155 +# allow only removable/loopback devices, to protect host PC
  156 +echo "MACHINE=${MACHINE}"
  157 +echo "SD card rootfs: ${YOCTO_DEFAULT_IMAGE}"
  158 +echo "Recovery rootfs: ${YOCTO_DEFAULT_IMAGE}"
  159 +echo "================================================"
  160 +check_device ${LPARAM_BLOCK_DEVICE}
  161 +echo "================================================"
  162 +read -p "Press Enter to continue"
  163 +
  164 +function delete_device
  165 +{
  166 + echo
  167 + echo "Deleting current partitions"
  168 + for ((i=0; i<10; i++))
  169 + do
  170 + if [ `ls ${LPARAM_BLOCK_DEVICE}${part}$i 2> /dev/null | grep -c ${LPARAM_BLOCK_DEVICE}${part}$i` -ne 0 ]; then
  171 + dd if=/dev/zero of=${LPARAM_BLOCK_DEVICE}${part}$i bs=512 count=1024
  172 + fi
  173 + done
  174 + sync
  175 +
  176 + ((echo d; echo 1; echo d; echo 2; echo d; echo 3; echo d; echo w) | fdisk ${LPARAM_BLOCK_DEVICE} &> /dev/null) || true
  177 + sync
  178 +
  179 + dd if=/dev/zero of=${LPARAM_BLOCK_DEVICE} bs=1M count=${BOOTLOAD_RESERVE_SIZE}
  180 + sync; sleep 1
  181 +}
  182 +
  183 +function ceildiv
  184 +{
  185 + local num=$1
  186 + local div=$2
  187 + echo $(( (num + div - 1) / div ))
  188 +}
  189 +
  190 +function create_parts
  191 +{
  192 + echo
  193 + echo "Creating new partitions"
  194 + # Get total card size
  195 + TOTAL_SIZE=`fdisk -s ${LPARAM_BLOCK_DEVICE}`
  196 + TOTAL_SIZE=`expr ${TOTAL_SIZE} / 1024`
  197 + ROOTFS_SIZE=`expr ${TOTAL_SIZE} - ${BOOTLOAD_RESERVE_SIZE} - ${PART1_SIZE} - ${SPARE_SIZE}`
  198 +
  199 + echo "ROOT SIZE=${ROOTFS_SIZE} TOTAl SIZE=${TOTAL_SIZE}"
  200 +
  201 + BLOCK=`echo ${LPARAM_BLOCK_DEVICE} | cut -d "/" -f 3`
  202 + SECT_SIZE_BYTES=`cat /sys/block/${BLOCK}/queue/physical_block_size`
  203 +
  204 + BOOTLOAD_RESERVE_SIZE_BYTES=$((BOOTLOAD_RESERVE_SIZE * 1024 * 1024))
  205 + PART1_SIZE_BYTES=$((PART1_SIZE * 1024 * 1024))
  206 + PART1_END_BYTES=`expr ${BOOTLOAD_RESERVE_SIZE_BYTES} + ${PART1_SIZE_BYTES}`
  207 + ROOTFS_SIZE_BYTES=$((ROOTFS_SIZE * 1024 * 1024))
  208 +
  209 + PART1_FIRST_SECT=`ceildiv ${BOOTLOAD_RESERVE_SIZE_BYTES} ${SECT_SIZE_BYTES}`
  210 + PART1_END_SECT=`ceildiv ${PART1_END_BYTES} ${SECT_SIZE_BYTES}`
  211 + PART2_FIRST_SECT=`expr ${PART1_END_SECT} + 1 `
  212 +
  213 + (echo n; echo p; echo $BOOTPART; echo $PART1_FIRST_SECT; \
  214 + echo $PART1_END_SECT; echo n; echo p; echo $ROOTFSPART; \
  215 + echo $PART2_FIRST_SECT; echo; echo p; echo w) | fdisk -u ${LPARAM_BLOCK_DEVICE} > /dev/null
  216 +
  217 + sleep 2; sync;
  218 + fdisk -l ${LPARAM_BLOCK_DEVICE}
  219 +
  220 + sleep 2; sync;
  221 +}
  222 +
  223 +function format_parts
  224 +{
  225 + echo
  226 + echo "Formatting partitions"
  227 + mkfs.vfat -F 16 ${LPARAM_BLOCK_DEVICE}${part}1 -n boot
  228 + mkfs.ext4 ${LPARAM_BLOCK_DEVICE}${part}2 -L rootfs
  229 + sync; sleep 1
  230 +}
  231 +
  232 +function install_bootloader
  233 +{
  234 + echo
  235 + echo "Installing U-Boot"
  236 + dd if=${YOCTO_IMGS_PATH}/imx-boot-${MACHINE}-sd.bin-flash_evk of=${LPARAM_BLOCK_DEVICE} bs=1K seek=${BOOTLOADER_OFFSET}; sync
  237 +}
  238 +
  239 +function mount_parts
  240 +{
  241 + mkdir -p ${P1_MOUNT_DIR}
  242 + mkdir -p ${P2_MOUNT_DIR}
  243 + sync
  244 +
  245 + mount ${LPARAM_BLOCK_DEVICE}${part}1 ${P1_MOUNT_DIR}
  246 + mount ${LPARAM_BLOCK_DEVICE}${part}2 ${P2_MOUNT_DIR}
  247 + sleep 2; sync;
  248 +}
  249 +
  250 +function unmount_parts
  251 +{
  252 + umount ${P1_MOUNT_DIR}
  253 + umount ${P2_MOUNT_DIR}
  254 +
  255 + rm -rf ${P1_MOUNT_DIR}
  256 + rm -rf ${P2_MOUNT_DIR}
  257 +}
  258 +
  259 +function install_yocto
  260 +{
  261 + echo
  262 + echo "Flashing \"Image, device tree and uEnv.txt\" partition"
  263 + cp -v ${YOCTO_IMGS_PATH}/Image ${P1_MOUNT_DIR}/
  264 + mkdir -p ${P1_MOUNT_DIR}/dtbs/
  265 + cp -v ${YOCTO_IMGS_PATH}/fsl-smarcimx8mq${DISPLAY}.dtb ${P1_MOUNT_DIR}/dtbs/fsl-smarcimx8mq.dtb
  266 + cp -v ${YOCTO_SCRIPTS_PATH}/uEnv.txt ${P1_MOUNT_DIR}/
  267 +
  268 + echo
  269 + echo "Installing Yocto Root File System"
  270 + tar jxvf ${YOCTO_IMGS_PATH}/${YOCTO_DEFAULT_IMAGE}-${MACHINE}.tar.bz2 -C ${P2_MOUNT_DIR}/
  271 + sync
  272 +}
  273 +
  274 +function copy_images
  275 +{
  276 + echo
  277 + echo "Copying Yocto images to /opt/images/"
  278 + mkdir -p ${P2_MOUNT_DIR}/opt/images/Yocto
  279 +
  280 + # Copy image for eMMC
  281 + if [ -f ${YOCTO_IMGS_PATH}/${YOCTO_DEFAULT_IMAGE}-${MACHINE}.tar.bz2 ]; then
  282 + pv ${YOCTO_IMGS_PATH}/${YOCTO_DEFAULT_IMAGE}-${MACHINE}.tar.bz2 > ${P2_MOUNT_DIR}/opt/images/Yocto/rootfs.tar.bz2
  283 + else
  284 + echo "rootfs.tar.gz file is not present. Installation on \"eMMC\" will not be supported."
  285 + fi
  286 +
  287 + echo
  288 + echo "Copying Kernel Images to /opt/images/"
  289 + cp ${YOCTO_IMGS_PATH}/Image ${P2_MOUNT_DIR}/opt/images/Yocto/Image
  290 +
  291 + echo
  292 + echo "Copying Kernel Device Tree Blob to /opt/images/"
  293 + cp -v ${YOCTO_IMGS_PATH}/*.dtb ${P2_MOUNT_DIR}/opt/images/Yocto/
  294 +
  295 + echo
  296 + echo "Copying Kernel Parameter uEnv.txt to /opt/images/"
  297 + cp -v ${YOCTO_SCRIPTS_PATH}/uEnv_emmc.txt ${P2_MOUNT_DIR}/opt/images/Yocto/uEnv.txt
  298 +
  299 + if [[ $MACHINE = "smarcimx8m2g" || ${MACHINE} = "smarcimx8m4g" ]]; then
  300 + cp ${YOCTO_IMGS_PATH}/imx-boot-${MACHINE}-sd.bin-* ${P2_MOUNT_DIR}/opt/images/Yocto
  301 + (cd ${P2_MOUNT_DIR}/opt/images/Yocto; ln -fs imx-boot-${MACHINE}-sd.bin-flash_evk imx-boot-sd.bin)
  302 + else
  303 + cp ${YOCTO_IMGS_PATH}/imx-boot-${MACHINE}-sd.bin ${P2_MOUNT_DIR}/opt/images/Yocto/imx-boot-sd.bin
  304 + fi
  305 +}
  306 +
  307 +function copy_scripts
  308 +{
  309 + echo
  310 + echo "Copying scripts"
  311 +
  312 + cp ${YOCTO_SCRIPTS_PATH}/emb-create-yocto-emmc.sh ${P2_MOUNT_DIR}/usr/bin/
  313 +}
  314 +
  315 +umount ${LPARAM_BLOCK_DEVICE}${part}* 2> /dev/null || true
  316 +
  317 +delete_device
  318 +create_parts
  319 +format_parts
  320 +
  321 +mount_parts
  322 +install_yocto
  323 +copy_images
  324 +copy_scripts
  325 +
  326 +echo
  327 +echo "Syncing"
  328 +sync | pv -t
  329 +
  330 +unmount_parts
  331 +
  332 +install_bootloader
  333 +
  334 +echo
  335 +echo "Done"
  336 +echo "========Flash to SD card Completed!========="
  337 +
  338 +exit 0
scripts/emb_mk_yocto_sdcard/uEnv.txt
  1 +optargs="video=HDMI-A-1:1920x1080-32@60 consoleblank=0"
  2 +#optargs="video=HDMI-A-1:3840x2160-32@30 consoleblank=0"
  3 +#optargs="video=HDMI-A-1:3840x2160-32@60 consoleblank=0"
  4 +#console port SER3
  5 +console=ttymxc0,115200 earlycon=ec_imx6q,0x30860000,115200
  6 +#console port SER2
  7 +#console=ttymxc1,115200 earlycon=ec_imx6q,0x30890000,115200
  8 +#console port SER1
  9 +#console=ttymxc2,115200 earlycon=ec_imx6q,0x30880000,115200
  10 +#console port SER0
  11 +#console=ttymxc3,115200 earlycon=ec_imx6q,0x30A60000,115200
  12 +mmcdev=1
  13 +mmcpart=1
  14 +image=Image
  15 +loadaddr=0x40480000
  16 +fdt_addr=0x43000000
  17 +mmcroot=/dev/mmcblk1p2 rw
  18 +usbroot=/dev/sda2 rw
  19 +mmcrootfstype=ext4 rootwait fixrtc
  20 +netdev=eth0
  21 +ethact=FEC0
  22 +ipaddr=192.168.1.150
  23 +serverip=192.168.1.53
  24 +gatewayip=192.168.1.254
  25 +mmcargs=setenv bootargs console=${console} root=${mmcroot} rootfstype=${mmcrootfstype} ${optargs}
  26 +uenvcmd=run loadimage; run loadfdt; run mmcboot
  27 +# USB Boot
  28 +#usbargs=setenv bootargs console=${console} root=${usbroot} rootfstype=${mmcrootfstype} ${optargs}
  29 +#uenvcmd=run loadusbimage; run loadusbfdt; run usbboot
scripts/emb_mk_yocto_sdcard/uEnv_emmc.txt
  1 +optargs="video=HDMI-A-1:1920x1080-32@60 consoleblank=0"
  2 +#optargs="video=HDMI-A-1:3840x2160-32@30 consoleblank=0"
  3 +#optargs="video=HDMI-A-1:3840x2160-32@60 consoleblank=0"
  4 +#console port SER3
  5 +console=ttymxc0,115200 earlycon=ec_imx6q,0x30860000,115200
  6 +#console port SER2
  7 +#console=ttymxc1,115200 earlycon=ec_imx6q,0x30890000,115200
  8 +#console port SER1
  9 +#console=ttymxc2,115200 earlycon=ec_imx6q,0x30880000,115200
  10 +#console port SER0
  11 +#console=ttymxc3,115200 earlycon=ec_imx6q,0x30A60000,115200
  12 +mmcdev=0
  13 +mmcpart=1
  14 +image=Image
  15 +loadaddr=0x40480000
  16 +fdt_addr=0x43000000
  17 +mmcroot=/dev/mmcblk0p2 rw
  18 +usbroot=/dev/sda2 rw
  19 +mmcrootfstype=ext4 rootwait fixrtc
  20 +netdev=eth0
  21 +ethact=FEC0
  22 +ipaddr=192.168.1.150
  23 +serverip=192.168.1.53
  24 +gatewayip=192.168.1.254
  25 +mmcargs=setenv bootargs console=${console} root=${mmcroot} rootfstype=${mmcrootfstype} ${optargs}
  26 +uenvcmd=run loadimage; run loadfdt; run mmcboot
  27 +# USB Boot
  28 +#usbargs=setenv bootargs console=${console} root=${usbroot} rootfstype=${mmcrootfstype} ${optargs}
  29 +#uenvcmd=run loadusbimage; run loadusbfdt; run usbboot