summaryrefslogtreecommitdiffstats
path: root/classes
diff options
context:
space:
mode:
authorOtavio Salvador <otavio@ossystems.com.br>2015-07-15 17:14:27 -0300
committerOtavio Salvador <otavio@ossystems.com.br>2015-07-16 15:01:29 -0300
commitf8517afc7a5ada4538b3b7d397fa32586d57ffe5 (patch)
tree79349f091306d1760fd4687e62336ffa8fb8c721 /classes
parentc92b415d653afc55f33b6b93fb9248193bfd4fa0 (diff)
downloadmeta-freescale-f8517afc7a5ada4538b3b7d397fa32586d57ffe5.tar.gz
Move meta-fsl-arm content to layer root
The meta-fsl-arm is going to be used as the base for this layer. It contains a clean history and allowing a more granullar set of changes. This commit is just a rename of all contents of meta-fsl-arm subdirectory to this layer's root, subsequent changes are based on top of that. Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
Diffstat (limited to 'classes')
-rw-r--r--classes/fsl-dynamic-packagearch.bbclass65
-rw-r--r--classes/fsl-eula-unpack.bbclass67
-rw-r--r--classes/fsl-kernel-localversion.bbclass39
-rw-r--r--classes/fsl-u-boot-localversion.bbclass27
-rw-r--r--classes/image_types_fsl.bbclass320
-rw-r--r--classes/mfgtool-initramfs-image.bbclass40
6 files changed, 558 insertions, 0 deletions
diff --git a/classes/fsl-dynamic-packagearch.bbclass b/classes/fsl-dynamic-packagearch.bbclass
new file mode 100644
index 00000000..fa542fce
--- /dev/null
+++ b/classes/fsl-dynamic-packagearch.bbclass
@@ -0,0 +1,65 @@
1# Automatically set PACKAGE_ARCH for MACHINE_SOCARCH
2#
3# This allow to easy reuse of binary packages among similar SoCs. The
4# usual use for this is to share SoC specific packages among different
5# boards.
6#
7# MACHINE_SOCARCH_FILTER list all packages associated with
8# MACHINE_SOCARCH and, when match, will set PACKAGE_ARCH as MACHINE_SOCARCH
9#
10# MACHINE_ARCH_FILTER list all packages associated with
11# MACHINE_ARCH and, when match, will set PACKAGE_ARCH as MACHINE_ARCH
12#
13# For example, in meta-fsl-arm, this is used to share GPU packages for
14# i.MX53 boards (as all them share the AMD GPU) and i.MX6 based boards
15# (as all them share Vivante GPU).
16#
17# To use the class, specify, for example:
18#
19# MACHINE_SOCARCH_SUFFIX_soc = "-soc"
20#
21# and the need filters, as:
22#
23# MACHINE_ARCH_FILTER = "virtual/kernel"
24# MACHINE_SOCARCH_FILTER_soc = "virtual/libgles1 ... virtual/libgl"
25#
26# Copyright 2013-2015 (C) O.S. Systems Software LTDA.
27
28python __anonymous () {
29 machine_arch_filter = set((d.getVar("MACHINE_ARCH_FILTER", True) or "").split())
30 machine_socarch_filter = set((d.getVar("MACHINE_SOCARCH_FILTER", True) or "").split())
31 if machine_socarch_filter or machine_arch_filter:
32 provides = set((d.getVar("PROVIDES", True) or "").split())
33 depends = set((d.getVar("DEPENDS", True) or "").split())
34 PN = d.getVar("PN", True)
35
36 package_arch = None
37 if list(machine_arch_filter & (provides | depends)):
38 package_arch = d.getVar("MACHINE_ARCH", True)
39 elif list(machine_socarch_filter & (provides | depends)):
40 package_arch = d.getVar("MACHINE_SOCARCH", True)
41 if not package_arch:
42 raise bb.parse.SkipPackage("You must set MACHINE_SOCARCH as MACHINE_SOCARCH_FILTER is set for this SoC.")
43
44 machine_socarch_suffix = d.getVar("MACHINE_SOCARCH_SUFFIX", True)
45 if not machine_socarch_suffix:
46 raise bb.parse.SkipPackage("You must set MACHINE_SOCARCH_SUFFIX as MACHINE_SOCARCH_FILTER is set for this SoC.")
47
48 if package_arch:
49 bb.debug(1, "Use '%s' as package archictecture for '%s'" % (package_arch, PN))
50 d.setVar("PACKAGE_ARCH", package_arch)
51
52 cur_package_archs = (d.getVar("PACKAGE_ARCHS", True) or "").split()
53 arch_extra_socarch = (d.getVar("ARM_EXTRA_SOCARCH", True) or "")
54 thumb_extra_socarch = (d.getVar("THUMB_EXTRA_SOCARCH", True) or "")
55 if not arch_extra_socarch in cur_package_archs:
56 d.appendVar("PACKAGE_EXTRA_ARCHS", " %s" % arch_extra_socarch)
57
58 if not thumb_extra_socarch in cur_package_archs:
59 d.appendVar("PACKAGE_EXTRA_ARCHS", " %s" % thumb_extra_socarch)
60}
61
62ARM_EXTRA_SOCARCH = "${ARMPKGARCH}${ARMPKGSFX_DSP}${ARMPKGSFX_EABI}${ARMPKGSFX_ENDIAN}${ARMPKGSFX_FPU}${MACHINE_SOCARCH_SUFFIX}"
63THUMB_EXTRA_SOCARCH = "${ARMPKGARCH}${ARM_THUMB_SUFFIX}${ARMPKGSFX_DSP}${ARMPKGSFX_EABI}${ARMPKGSFX_ENDIAN}${ARMPKGSFX_FPU}${MACHINE_SOCARCH_SUFFIX}"
64
65MACHINE_SOCARCH = "${@bb.utils.contains('ARM_INSTRUCTION_SET', 'thumb', '${THUMB_EXTRA_SOCARCH}', '${ARM_EXTRA_SOCARCH}', d)}"
diff --git a/classes/fsl-eula-unpack.bbclass b/classes/fsl-eula-unpack.bbclass
new file mode 100644
index 00000000..a9f16ef0
--- /dev/null
+++ b/classes/fsl-eula-unpack.bbclass
@@ -0,0 +1,67 @@
1# fsl-eula-unpack.bbclass provides the mechanism used for unpacking
2# the .bin file downloaded by HTTP and handle the EULA acceptance.
3#
4# To use it, the 'fsl-eula' parameter needs to be added to the
5# SRC_URI entry, e.g:
6#
7# SRC_URI = "${FSL_MIRROR}/firmware-imx-${PV};fsl-eula=true"
8
9LIC_FILES_CHKSUM_append = " file://${FSL_EULA_FILE};md5=acdb807ac7275fe32f9f64992e111241"
10LIC_FILES_CHKSUM[vardepsexclude] += "FSL_EULA_FILE"
11
12python fsl_bin_do_unpack() {
13 src_uri = (d.getVar('SRC_URI', True) or "").split()
14 if len(src_uri) == 0:
15 return
16
17 localdata = bb.data.createCopy(d)
18 bb.data.update_data(localdata)
19
20 rootdir = localdata.getVar('WORKDIR', True)
21 fetcher = bb.fetch2.Fetch(src_uri, localdata)
22
23 for url in fetcher.ud.values():
24 save_cwd = os.getcwd()
25 # Check for supported fetchers
26 if url.type in ['http', 'https', 'ftp', 'file']:
27 if url.parm.get('fsl-eula', False):
28 # If download has failed, do nothing
29 if not os.path.exists(url.localpath):
30 bb.debug(1, "Exiting as '%s' cannot be found" % url.basename)
31 return
32
33 # Change to the working directory
34 bb.note("Handling file '%s' as a Freescale's EULA binary." % url.basename)
35 save_cwd = os.getcwd()
36 os.chdir(rootdir)
37
38 cmd = "sh %s --auto-accept --force" % (url.localpath)
39 bb.fetch2.runfetchcmd(cmd, d, quiet=True)
40
41 # Return to the previous directory
42 os.chdir(save_cwd)
43}
44
45python do_unpack() {
46 eula = d.getVar('ACCEPT_FSL_EULA', True)
47 eula_file = d.getVar('FSL_EULA_FILE', True)
48 pkg = d.getVar('PN', True)
49 if eula == None:
50 bb.fatal("To use '%s' you need to accept the Freescale EULA at '%s'. "
51 "Please read it and in case you accept it, write: "
52 "ACCEPT_FSL_EULA = \"1\" in your local.conf." % (pkg, eula_file))
53 elif eula == '0':
54 bb.fatal("To use '%s' you need to accept the Freescale EULA." % pkg)
55 else:
56 bb.note("Freescale EULA has been accepted for '%s'" % pkg)
57
58 # The binary unpack needs to be done first so 'S' is valid
59 bb.build.exec_func('fsl_bin_do_unpack', d)
60
61 try:
62 bb.build.exec_func('base_do_unpack', d)
63 except:
64 raise
65}
66
67do_unpack[vardepsexclude] += "FSL_EULA_FILE"
diff --git a/classes/fsl-kernel-localversion.bbclass b/classes/fsl-kernel-localversion.bbclass
new file mode 100644
index 00000000..1004e355
--- /dev/null
+++ b/classes/fsl-kernel-localversion.bbclass
@@ -0,0 +1,39 @@
1# Freescale Kernel LOCALVERSION extension
2#
3# This allow to easy reuse of code between different kernel recipes
4#
5# The following options are supported:
6#
7# SCMVERSION Puts the Git hash in kernel local version
8# LOCALVERSION Value used in LOCALVERSION (default to '+fslc')
9#
10# Copyright 2014, 2015 (C) O.S. Systems Software LTDA.
11
12SCMVERSION ??= "y"
13LOCALVERSION ??= "+fslc"
14
15kernel_conf_variable() {
16 CONF_SED_SCRIPT="$CONF_SED_SCRIPT /CONFIG_$1[ =]/d;"
17 if test "$2" = "n"
18 then
19 echo "# CONFIG_$1 is not set" >> ${B}/.config
20 else
21 echo "CONFIG_$1=$2" >> ${B}/.config
22 fi
23}
24
25do_configure_prepend() {
26 echo "" > ${B}/.config
27 CONF_SED_SCRIPT=""
28
29 kernel_conf_variable LOCALVERSION "\"${LOCALVERSION}\""
30 kernel_conf_variable LOCALVERSION_AUTO y
31
32 sed -e "${CONF_SED_SCRIPT}" < '${WORKDIR}/defconfig' >> '${B}/.config'
33
34 if [ "${SCMVERSION}" = "y" ]; then
35 # Add GIT revision to the local version
36 head=`git --git-dir=${S}/.git rev-parse --verify --short HEAD 2> /dev/null`
37 printf "%s%s" +g $head > ${S}/.scmversion
38 fi
39}
diff --git a/classes/fsl-u-boot-localversion.bbclass b/classes/fsl-u-boot-localversion.bbclass
new file mode 100644
index 00000000..f7e09714
--- /dev/null
+++ b/classes/fsl-u-boot-localversion.bbclass
@@ -0,0 +1,27 @@
1# Freescale U-Boot LOCALVERSION extension
2#
3# This allow to easy reuse of code between different U-Boot recipes
4#
5# The following options are supported:
6#
7# SCMVERSION Puts the Git hash in U-Boot local version
8# LOCALVERSION Value used in LOCALVERSION (default to '+fslc')
9#
10# Copyright 2014 (C) O.S. Systems Software LTDA.
11
12SCMVERSION ??= "y"
13LOCALVERSION ??= "+fslc"
14
15UBOOT_LOCALVERSION = "${LOCALVERSION}"
16
17do_compile_prepend() {
18 if [ "${SCMVERSION}" = "y" ]; then
19 # Add GIT revision to the local version
20 head=`git rev-parse --verify --short HEAD 2> /dev/null`
21 printf "%s%s%s" "${UBOOT_LOCALVERSION}" +g $head > ${S}/.scmversion
22 printf "%s%s%s" "${UBOOT_LOCALVERSION}" +g $head > ${B}/.scmversion
23 else
24 printf "%s" "${UBOOT_LOCALVERSION}" > ${S}/.scmversion
25 printf "%s" "${UBOOT_LOCALVERSION}" > ${B}/.scmversion
26 fi
27}
diff --git a/classes/image_types_fsl.bbclass b/classes/image_types_fsl.bbclass
new file mode 100644
index 00000000..b542549d
--- /dev/null
+++ b/classes/image_types_fsl.bbclass
@@ -0,0 +1,320 @@
1inherit image_types
2
3IMAGE_BOOTLOADER ?= "u-boot"
4
5# Handle u-boot suffixes
6UBOOT_SUFFIX ?= "bin"
7UBOOT_SUFFIX_SDCARD ?= "${UBOOT_SUFFIX}"
8
9#
10# Handles i.MX mxs bootstream generation
11#
12MXSBOOT_NAND_ARGS ?= ""
13
14# IMX Bootlets Linux bootstream
15IMAGE_DEPENDS_linux.sb = "elftosb-native:do_populate_sysroot \
16 imx-bootlets:do_deploy \
17 virtual/kernel:do_deploy"
18IMAGE_LINK_NAME_linux.sb = ""
19IMAGE_CMD_linux.sb () {
20 kernel_bin="`readlink ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${MACHINE}.bin`"
21 kernel_dtb="`readlink ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${MACHINE}.dtb || true`"
22 linux_bd_file=imx-bootlets-linux.bd-${MACHINE}
23 if [ `basename $kernel_bin .bin` = `basename $kernel_dtb .dtb` ]; then
24 # When using device tree we build a zImage with the dtb
25 # appended on the end of the image
26 linux_bd_file=imx-bootlets-linux.bd-dtb-${MACHINE}
27 cat $kernel_bin $kernel_dtb \
28 > $kernel_bin-dtb
29 rm -f ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${MACHINE}.bin-dtb
30 ln -s $kernel_bin-dtb ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${MACHINE}.bin-dtb
31 fi
32
33 # Ensure the file is generated
34 rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.linux.sb
35 (cd ${DEPLOY_DIR_IMAGE}; elftosb -z -c $linux_bd_file -o ${IMAGE_NAME}.linux.sb)
36
37 # Remove the appended file as it is only used here
38 rm -f ${DEPLOY_DIR_IMAGE}/$kernel_bin-dtb
39}
40
41# IMX Bootlets barebox bootstream
42IMAGE_DEPENDS_barebox.mxsboot-sdcard = "elftosb-native:do_populate_sysroot \
43 u-boot-mxsboot-native:do_populate_sysroot \
44 imx-bootlets:do_deploy \
45 barebox:do_deploy"
46IMAGE_CMD_barebox.mxsboot-sdcard () {
47 barebox_bd_file=imx-bootlets-barebox_ivt.bd-${MACHINE}
48
49 # Ensure the files are generated
50 (cd ${DEPLOY_DIR_IMAGE}; rm -f ${IMAGE_NAME}.barebox.sb ${IMAGE_NAME}.barebox.mxsboot-sdcard; \
51 elftosb -f mx28 -z -c $barebox_bd_file -o ${IMAGE_NAME}.barebox.sb; \
52 mxsboot sd ${IMAGE_NAME}.barebox.sb ${IMAGE_NAME}.barebox.mxsboot-sdcard)
53}
54
55# U-Boot mxsboot generation to SD-Card
56UBOOT_SUFFIX_SDCARD_mxs ?= "mxsboot-sdcard"
57IMAGE_DEPENDS_uboot.mxsboot-sdcard = "u-boot-mxsboot-native:do_populate_sysroot \
58 u-boot:do_deploy"
59IMAGE_CMD_uboot.mxsboot-sdcard = "mxsboot sd ${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.${UBOOT_SUFFIX} \
60 ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.uboot.mxsboot-sdcard"
61
62IMAGE_DEPENDS_uboot.mxsboot-nand = "u-boot-mxsboot-native:do_populate_sysroot \
63 u-boot:do_deploy"
64IMAGE_CMD_uboot.mxsboot-nand = "mxsboot ${MXSBOOT_NAND_ARGS} nand \
65 ${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.${UBOOT_SUFFIX} \
66 ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.uboot.mxsboot-nand"
67
68# Boot partition volume id
69BOOTDD_VOLUME_ID ?= "Boot ${MACHINE}"
70
71# Boot partition size [in KiB]
72BOOT_SPACE ?= "8192"
73
74# Barebox environment size [in KiB]
75BAREBOX_ENV_SPACE ?= "512"
76
77# Set alignment to 4MB [in KiB]
78IMAGE_ROOTFS_ALIGNMENT = "4096"
79
80IMAGE_DEPENDS_sdcard = "parted-native:do_populate_sysroot \
81 dosfstools-native:do_populate_sysroot \
82 mtools-native:do_populate_sysroot \
83 virtual/kernel:do_deploy \
84 ${@d.getVar('IMAGE_BOOTLOADER', True) and d.getVar('IMAGE_BOOTLOADER', True) + ':do_deploy' or ''}"
85
86SDCARD = "${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.sdcard"
87
88SDCARD_GENERATION_COMMAND_mxs = "generate_mxs_sdcard"
89SDCARD_GENERATION_COMMAND_mx25 = "generate_imx_sdcard"
90SDCARD_GENERATION_COMMAND_mx5 = "generate_imx_sdcard"
91SDCARD_GENERATION_COMMAND_mx6 = "generate_imx_sdcard"
92SDCARD_GENERATION_COMMAND_vf = "generate_imx_sdcard"
93
94#
95# Create an image that can by written onto a SD card using dd for use
96# with i.MX SoC family
97#
98# External variables needed:
99# ${SDCARD_ROOTFS} - the rootfs image to incorporate
100# ${IMAGE_BOOTLOADER} - bootloader to use {u-boot, barebox}
101#
102# The disk layout used is:
103#
104# 0 -> IMAGE_ROOTFS_ALIGNMENT - reserved to bootloader (not partitioned)
105# IMAGE_ROOTFS_ALIGNMENT -> BOOT_SPACE - kernel and other data
106# BOOT_SPACE -> SDIMG_SIZE - rootfs
107#
108# Default Free space = 1.3x
109# Use IMAGE_OVERHEAD_FACTOR to add more space
110# <--------->
111# 4MiB 8MiB SDIMG_ROOTFS 4MiB
112# <-----------------------> <----------> <----------------------> <------------------------------>
113# ------------------------ ------------ ------------------------ -------------------------------
114# | IMAGE_ROOTFS_ALIGNMENT | BOOT_SPACE | ROOTFS_SIZE | IMAGE_ROOTFS_ALIGNMENT |
115# ------------------------ ------------ ------------------------ -------------------------------
116# ^ ^ ^ ^ ^
117# | | | | |
118# 0 4096 4MiB + 8MiB 4MiB + 8Mib + SDIMG_ROOTFS 4MiB + 8MiB + SDIMG_ROOTFS + 4MiB
119generate_imx_sdcard () {
120 # Create partition table
121 parted -s ${SDCARD} mklabel msdos
122 parted -s ${SDCARD} unit KiB mkpart primary fat32 ${IMAGE_ROOTFS_ALIGNMENT} $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED})
123 parted -s ${SDCARD} unit KiB mkpart primary $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED}) $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED} \+ $ROOTFS_SIZE)
124 parted ${SDCARD} print
125
126 # Burn bootloader
127 case "${IMAGE_BOOTLOADER}" in
128 imx-bootlets)
129 bberror "The imx-bootlets is not supported for i.MX based machines"
130 exit 1
131 ;;
132 u-boot)
133 if [ -n "${SPL_BINARY}" ]; then
134 dd if=${DEPLOY_DIR_IMAGE}/${SPL_BINARY} of=${SDCARD} conv=notrunc seek=2 bs=512
135 dd if=${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.${UBOOT_SUFFIX_SDCARD} of=${SDCARD} conv=notrunc seek=69 bs=1K
136 else
137 dd if=${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.${UBOOT_SUFFIX_SDCARD} of=${SDCARD} conv=notrunc seek=2 bs=512
138 fi
139 ;;
140 barebox)
141 dd if=${DEPLOY_DIR_IMAGE}/barebox-${MACHINE}.bin of=${SDCARD} conv=notrunc seek=1 skip=1 bs=512
142 dd if=${DEPLOY_DIR_IMAGE}/bareboxenv-${MACHINE}.bin of=${SDCARD} conv=notrunc seek=1 bs=512k
143 ;;
144 "")
145 ;;
146 *)
147 bberror "Unknown IMAGE_BOOTLOADER value"
148 exit 1
149 ;;
150 esac
151
152 # Create boot partition image
153 BOOT_BLOCKS=$(LC_ALL=C parted -s ${SDCARD} unit b print \
154 | awk '/ 1 / { print substr($4, 1, length($4 -1)) / 1024 }')
155 rm -f ${WORKDIR}/boot.img
156 mkfs.vfat -n "${BOOTDD_VOLUME_ID}" -S 512 -C ${WORKDIR}/boot.img $BOOT_BLOCKS
157 mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${MACHINE}.bin ::/${KERNEL_IMAGETYPE}
158
159 # Copy boot scripts
160 for item in ${BOOT_SCRIPTS}; do
161 src=`echo $item | awk -F':' '{ print $1 }'`
162 dst=`echo $item | awk -F':' '{ print $2 }'`
163
164 mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/$src ::/$dst
165 done
166
167 # Copy device tree file
168 if test -n "${KERNEL_DEVICETREE}"; then
169 for DTS_FILE in ${KERNEL_DEVICETREE}; do
170 DTS_BASE_NAME=`basename ${DTS_FILE} | awk -F "." '{print $1}'`
171 if [ -e "${KERNEL_IMAGETYPE}-${DTS_BASE_NAME}.dtb" ]; then
172 kernel_bin="`readlink ${KERNEL_IMAGETYPE}-${MACHINE}.bin`"
173 kernel_bin_for_dtb="`readlink ${KERNEL_IMAGETYPE}-${DTS_BASE_NAME}.dtb | sed "s,$DTS_BASE_NAME,${MACHINE},g;s,\.dtb$,.bin,g"`"
174 if [ $kernel_bin = $kernel_bin_for_dtb ]; then
175 mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTS_BASE_NAME}.dtb ::/${DTS_BASE_NAME}.dtb
176 fi
177 fi
178 done
179 fi
180
181 # Burn Partition
182 dd if=${WORKDIR}/boot.img of=${SDCARD} conv=notrunc,fsync seek=1 bs=$(expr ${IMAGE_ROOTFS_ALIGNMENT} \* 1024)
183 dd if=${SDCARD_ROOTFS} of=${SDCARD} conv=notrunc,fsync seek=1 bs=$(expr ${BOOT_SPACE_ALIGNED} \* 1024 + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024)
184}
185
186#
187# Create an image that can by written onto a SD card using dd for use
188# with i.MXS SoC family
189#
190# External variables needed:
191# ${SDCARD_ROOTFS} - the rootfs image to incorporate
192# ${IMAGE_BOOTLOADER} - bootloader to use {imx-bootlets, u-boot}
193#
194generate_mxs_sdcard () {
195 # Create partition table
196 parted -s ${SDCARD} mklabel msdos
197
198 case "${IMAGE_BOOTLOADER}" in
199 imx-bootlets)
200 # The disk layout used is:
201 #
202 # 0 -> 1024 - Unused (not partitioned)
203 # 1024 -> BOOT_SPACE - kernel and other data (bootstream)
204 # BOOT_SPACE -> SDIMG_SIZE - rootfs
205 #
206 # Default Free space = 1.3x
207 # Use IMAGE_OVERHEAD_FACTOR to add more space
208 # <--------->
209 # 1024 8MiB SDIMG_ROOTFS 4MiB
210 # <-------> <----------> <----------------------> <------------------------------>
211 # --------------------- ------------------------ -------------------------------
212 # | Unused | BOOT_SPACE | ROOTFS_SIZE | IMAGE_ROOTFS_ALIGNMENT |
213 # --------------------- ------------------------ -------------------------------
214 # ^ ^ ^ ^ ^
215 # | | | | |
216 # 0 1024 1024 + 8MiB 1024 + 8Mib + SDIMG_ROOTFS 1024 + 8MiB + SDIMG_ROOTFS + 4MiB
217 parted -s ${SDCARD} unit KiB mkpart primary 1024 $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED})
218 parted -s ${SDCARD} unit KiB mkpart primary $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED}) $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED} \+ $ROOTFS_SIZE)
219
220 # Empty 4 blocks from boot partition
221 dd if=/dev/zero of=${SDCARD} conv=notrunc seek=2048 count=4
222
223 # Write the bootstream in (2048 + 4) blocks
224 dd if=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.linux.sb of=${SDCARD} conv=notrunc seek=2052
225 ;;
226 u-boot)
227 # The disk layout used is:
228 #
229 # 1M - 2M - reserved to bootloader and other data
230 # 2M - BOOT_SPACE - kernel
231 # BOOT_SPACE - SDCARD_SIZE - rootfs
232 #
233 # The disk layout used is:
234 #
235 # 1M -> 2M - reserved to bootloader and other data
236 # 2M -> BOOT_SPACE - kernel and other data
237 # BOOT_SPACE -> SDIMG_SIZE - rootfs
238 #
239 # Default Free space = 1.3x
240 # Use IMAGE_OVERHEAD_FACTOR to add more space
241 # <--------->
242 # 4MiB 8MiB SDIMG_ROOTFS 4MiB
243 # <-----------------------> <-------------> <----------------------> <------------------------------>
244 # ---------------------------------------- ------------------------ -------------------------------
245 # | | | |ROOTFS_SIZE | IMAGE_ROOTFS_ALIGNMENT |
246 # ---------------------------------------- ------------------------ -------------------------------
247 # ^ ^ ^ ^ ^ ^ ^
248 # | | | | | | |
249 # 0 1M 2M 4M 4MiB + BOOTSPACE 4MiB + BOOTSPACE + SDIMG_ROOTFS 4MiB + BOOTSPACE + SDIMG_ROOTFS + 4MiB
250 #
251 parted -s ${SDCARD} unit KiB mkpart primary 1024 2048
252 parted -s ${SDCARD} unit KiB mkpart primary 2048 $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED})
253 parted -s ${SDCARD} unit KiB mkpart primary $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED}) $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED} \+ $ROOTFS_SIZE)
254
255 dd if=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.uboot.mxsboot-sdcard of=${SDCARD} conv=notrunc seek=1 bs=$(expr 1024 \* 1024)
256 BOOT_BLOCKS=$(LC_ALL=C parted -s ${SDCARD} unit b print \
257 | awk '/ 2 / { print substr($4, 1, length($4 -1)) / 1024 }')
258
259 rm -f ${WORKDIR}/boot.img
260 mkfs.vfat -n "${BOOTDD_VOLUME_ID}" -S 512 -C ${WORKDIR}/boot.img $BOOT_BLOCKS
261 mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${MACHINE}.bin ::/${KERNEL_IMAGETYPE}
262 if test -n "${KERNEL_DEVICETREE}"; then
263 for DTS_FILE in ${KERNEL_DEVICETREE}; do
264 DTS_BASE_NAME=`basename ${DTS_FILE} | awk -F "." '{print $1}'`
265 if [ -e "${KERNEL_IMAGETYPE}-${DTS_BASE_NAME}.dtb" ]; then
266 kernel_bin="`readlink ${KERNEL_IMAGETYPE}-${MACHINE}.bin`"
267 kernel_bin_for_dtb="`readlink ${KERNEL_IMAGETYPE}-${DTS_BASE_NAME}.dtb | sed "s,$DTS_BASE_NAME,${MACHINE},g;s,\.dtb$,.bin,g"`"
268 if [ $kernel_bin = $kernel_bin_for_dtb ]; then
269 mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTS_BASE_NAME}.dtb ::/${DTS_BASE_NAME}.dtb
270 fi
271 fi
272 done
273 fi
274
275 dd if=${WORKDIR}/boot.img of=${SDCARD} conv=notrunc seek=2 bs=$(expr 1024 \* 1024)
276 ;;
277 barebox)
278 # BAREBOX_ENV_SPACE is taken on BOOT_SPACE_ALIGNED but it doesn't really matter as long as the rootfs is aligned
279 parted -s ${SDCARD} unit KiB mkpart primary 1024 $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED} - ${BAREBOX_ENV_SPACE})
280 parted -s ${SDCARD} unit KiB mkpart primary $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED} - ${BAREBOX_ENV_SPACE}) $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED})
281 parted -s ${SDCARD} unit KiB mkpart primary $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED}) $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED} \+ $ROOTFS_SIZE)
282
283 dd if=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.barebox.mxsboot-sdcard of=${SDCARD} conv=notrunc seek=1 bs=$(expr 1024 \* 1024)
284 dd if=${DEPLOY_DIR_IMAGE}/bareboxenv-${MACHINE}.bin of=${SDCARD} conv=notrunc seek=$(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED} - ${BAREBOX_ENV_SPACE}) bs=1024
285 ;;
286 *)
287 bberror "Unknown IMAGE_BOOTLOADER value"
288 exit 1
289 ;;
290 esac
291
292 # Change partition type for mxs processor family
293 bbnote "Setting partition type to 0x53 as required for mxs' SoC family."
294 echo -n S | dd of=${SDCARD} bs=1 count=1 seek=450 conv=notrunc
295
296 parted ${SDCARD} print
297
298 dd if=${SDCARD_ROOTFS} of=${SDCARD} conv=notrunc,fsync seek=1 bs=$(expr ${BOOT_SPACE_ALIGNED} \* 1024 + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024)
299}
300
301IMAGE_CMD_sdcard () {
302 if [ -z "${SDCARD_ROOTFS}" ]; then
303 bberror "SDCARD_ROOTFS is undefined. To use sdcard image from Freescale's BSP it needs to be defined."
304 exit 1
305 fi
306
307 # Align boot partition and calculate total SD card image size
308 BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE} + ${IMAGE_ROOTFS_ALIGNMENT} - 1)
309 BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE_ALIGNED} - ${BOOT_SPACE_ALIGNED} % ${IMAGE_ROOTFS_ALIGNMENT})
310 SDCARD_SIZE=$(expr ${IMAGE_ROOTFS_ALIGNMENT} + ${BOOT_SPACE_ALIGNED} + $ROOTFS_SIZE + ${IMAGE_ROOTFS_ALIGNMENT})
311
312 # Initialize a sparse file
313 dd if=/dev/zero of=${SDCARD} bs=1 count=0 seek=$(expr 1024 \* ${SDCARD_SIZE})
314
315 ${SDCARD_GENERATION_COMMAND}
316}
317
318# The sdcard requires the rootfs filesystem to be built before using
319# it so we must make this dependency explicit.
320IMAGE_TYPEDEP_sdcard = "${@d.getVar('SDCARD_ROOTFS', 1).split('.')[-1]}"
diff --git a/classes/mfgtool-initramfs-image.bbclass b/classes/mfgtool-initramfs-image.bbclass
new file mode 100644
index 00000000..a9a2adf1
--- /dev/null
+++ b/classes/mfgtool-initramfs-image.bbclass
@@ -0,0 +1,40 @@
1# Generates a Manufacturing Tool Initramfs image
2#
3# This generates the initramfs used for the installation process. The
4# image provides the utilities which are used, in the target, during
5# the process and receive the commands from the MfgTool application.
6#
7# Copyright 2014 (C) O.S. Systems Software LTDA.
8
9DEPENDS += "u-boot-mfgtool linux-mfgtool"
10
11FEATURE_PACKAGES_mtd = "packagegroup-fsl-mfgtool-mtd"
12FEATURE_PACKAGES_extfs = "packagegroup-fsl-mfgtool-extfs"
13
14IMAGE_FSTYPES = "cpio.gz.u-boot"
15IMAGE_ROOTFS_SIZE ?= "8192"
16IMAGE_CLASSES = "image_types_uboot"
17
18# Filesystems enabled by default
19DEFAULT_FS_SUPPORT = " \
20 mtd \
21 extfs \
22"
23
24IMAGE_FEATURES = " \
25 ${DEFAULT_FS_SUPPORT} \
26 \
27 read-only-rootfs \
28"
29
30# Avoid installation of syslog
31BAD_RECOMMENDATIONS += "busybox-syslog"
32
33# Avoid static /dev
34USE_DEVFS = "1"
35
36inherit core-image
37
38CORE_IMAGE_BASE_INSTALL = " \
39 ${CORE_IMAGE_EXTRA_INSTALL} \
40"