meta-digi-arm: image_types_digi: separate data from implementation

Move the flash parameters to the machine configuration files so it's
easier to create derivative machines and use the image bbclass to create
flash images.

(based on a patch from Seth Bollinger <sethb@digi.com>)

https://jira.digi.com/browse/DEL-682

Signed-off-by: Javier Viguera <javier.viguera@digi.com>
This commit is contained in:
Javier Viguera 2013-11-04 13:25:13 +01:00
parent 1866f03b0a
commit 767fc18b85
6 changed files with 104 additions and 59 deletions

View File

@ -1,64 +1,28 @@
inherit image_types_fsl inherit image_types_fsl
################################################### # Dynamically calculate max LEB count for UBIFS images
## Platform data to be used in different scripts ## FLASH_MLC = "${@max_leb_count(d)}"
################################################### def max_leb_count(d):
# _mlc = []
# <platform> <max_leb_cnt> <peb (KiB)> <leb (bytes)> <min-io-size (bytes)> <sub-page-size (bytes)> _flash_peb = d.getVar('FLASH_PEB', True)
# mlc, peb, leb, mio and sub might be a list of values (separated by commas) _flash_psz = d.getVar('FLASH_PSZ', True)
# for i in _flash_peb.split(','):
# Values verified from actual modules with: _mlc.append(str(2 ** (int(_flash_psz)/int(i) - 1).bit_length() - 1))
# ubiattach -m <rootfs_part_number> /dev/ubi_ctrl return ','.join(_mlc)
#
# Max LEB count values calculated assuming following partition sizes:
#
# max_leb_cnt="$(($(power_of_2 $((psize / peb))) - 1))"
# psize = 524288 KiB; peb=128 KiB -> max_leb_cnt = 4095
# psize = 524288 KiB; peb=512 KiB -> max_leb_cnt = 1023
# psize = 262144 KiB; peb=128 KiB -> max_leb_cnt = 2047
#
load_platform_data() {
while read _pl _mlc _peb _leb _mio _sub; do
eval "${_pl}_mlc=\"$(echo ${_mlc} | tr ',' ' ')\""
eval "${_pl}_peb=\"$(echo ${_peb} | tr ',' ' ')\""
eval "${_pl}_leb=\"$(echo ${_leb} | tr ',' ' ')\""
eval "${_pl}_mio=\"$(echo ${_mio} | tr ',' ' ')\""
eval "${_pl}_sub=\"$(echo ${_sub} | tr ',' ' ')\""
done<<-_EOF_
ccardimx28js 2047 128 126976 2048 -
ccimx51js 4095,1023 128,512 129024,520192 2048,4096 512,1024
ccimx53js 4095,1023 128,512 129024,520192 2048,4096 512,1024
cpx2 2047 128 126976 2048 -
wr21 2047 128 126976 2048 -
_EOF_
# Set generic variables for current MACHINE
nimg="$(eval echo \${${MACHINE}_peb} | wc -w)"
for i in $(seq 1 ${nimg}); do
eval mlc${i}="$(eval echo \${${MACHINE}_mlc} | cut -d' ' -f${i})"
eval peb${i}="$(eval echo \${${MACHINE}_peb} | cut -d' ' -f${i})"
eval leb${i}="$(eval echo \${${MACHINE}_leb} | cut -d' ' -f${i})"
eval mio${i}="$(eval echo \${${MACHINE}_mio} | cut -d' ' -f${i})"
eval sub${i}="$(eval echo \${${MACHINE}_sub} | cut -d' ' -f${i})"
done
}
IMAGE_CMD_jffs2() { IMAGE_CMD_jffs2() {
# Source platform data nimg="$(echo ${FLASH_PEB} | awk -F, '{print NF}')"
load_platform_data
for i in $(seq 1 ${nimg}); do for i in $(seq 1 ${nimg}); do
eval peb_it="\${peb${i}}" peb_it="$(echo ${FLASH_PEB} | cut -d',' -f${i})"
# Do not use '-p (padding)' option. It breaks 'ccardimx28js' flash images [JIRA:DEL-218] # Do not use '-p (padding)' option. It breaks 'ccardimx28js' flash images [JIRA:DEL-218]
mkfs.jffs2 -n -e ${peb_it} -d ${IMAGE_ROOTFS} -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.${peb_it}.rootfs.jffs2 mkfs.jffs2 -n -e ${peb_it} -d ${IMAGE_ROOTFS} -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.${peb_it}.rootfs.jffs2
done done
} }
IMAGE_CMD_sum.jffs2() { IMAGE_CMD_sum.jffs2() {
# Source platform data nimg="$(echo ${FLASH_PEB} | awk -F, '{print NF}')"
load_platform_data
for i in $(seq 1 ${nimg}); do for i in $(seq 1 ${nimg}); do
eval peb_it="\${peb${i}}" peb_it="$(echo ${FLASH_PEB} | cut -d',' -f${i})"
# Do not use '-p (padding)' option. It breaks 'ccardimx28js' flash images [JIRA:DEL-218] # Do not use '-p (padding)' option. It breaks 'ccardimx28js' flash images [JIRA:DEL-218]
mkfs.jffs2 -n -e ${peb_it} -d ${IMAGE_ROOTFS} -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.${peb_it}.rootfs.jffs2 mkfs.jffs2 -n -e ${peb_it} -d ${IMAGE_ROOTFS} -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.${peb_it}.rootfs.jffs2
sumtool -e ${peb_it} -i ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.${peb_it}.rootfs.jffs2 -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.${peb_it}.rootfs.sum.jffs2 sumtool -e ${peb_it} -i ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.${peb_it}.rootfs.jffs2 -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.${peb_it}.rootfs.sum.jffs2
@ -67,19 +31,16 @@ IMAGE_CMD_sum.jffs2() {
} }
IMAGE_CMD_ubifs() { IMAGE_CMD_ubifs() {
# Source platform data nimg="$(echo ${FLASH_PEB} | awk -F, '{print NF}')"
load_platform_data
for i in $(seq 1 ${nimg}); do for i in $(seq 1 ${nimg}); do
eval mlc_it="\${mlc${i}}" mlc_it="$(echo ${FLASH_MLC} | cut -d',' -f${i})"
eval peb_it="\${peb${i}}" peb_it="$(echo ${FLASH_PEB} | cut -d',' -f${i})"
eval leb_it="\${leb${i}}" leb_it="$(echo ${FLASH_LEB} | cut -d',' -f${i})"
eval mio_it="\${mio${i}}" mio_it="$(echo ${FLASH_MIO} | cut -d',' -f${i})"
mkfs.ubifs -r ${IMAGE_ROOTFS} -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.${peb_it}.rootfs.ubifs -m ${mio_it} -e ${leb_it} -c ${mlc_it} mkfs.ubifs -r ${IMAGE_ROOTFS} -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.${peb_it}.rootfs.ubifs -m ${mio_it} -e ${leb_it} -c ${mlc_it}
done done
} }
# #
# A copy of the original function in 'image_types.bbclass', just overriding the # A copy of the original function in 'image_types.bbclass', just overriding the
# part of the symlinks generation so we can create more than one symlink (one per # part of the symlinks generation so we can create more than one symlink (one per
@ -96,8 +57,8 @@ runimagecmd_jffs2() {
if [ -n "${IMAGE_LINK_NAME}" ]; then if [ -n "${IMAGE_LINK_NAME}" ]; then
for type in ${subimages}; do for type in ${subimages}; do
for i in $(seq 1 ${nimg}); do for i in $(seq 1 ${nimg}); do
eval peb_it="\${peb${i}}" peb_it="$(echo ${FLASH_PEB} | cut -d',' -f${i})"
ln -s ${IMAGE_NAME}.${peb_it}.rootfs.$type ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.${peb_it}.$type ln -sf ${IMAGE_NAME}.${peb_it}.rootfs.$type ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.${peb_it}.$type
done done
done done
fi fi

View File

@ -12,3 +12,20 @@ SERIAL_CONSOLE = "115200 ttyS0"
# Use our wmiconfig instead of the one in meta-oe # Use our wmiconfig instead of the one in meta-oe
PREFERRED_VERSION_wmiconfig ?= "3.4p4" PREFERRED_VERSION_wmiconfig ?= "3.4p4"
#################################################
## Flash parameters for JFFS2 and UBIFS images ##
#################################################
# partition size (KiB)
# physical eraseblock size (KiB)
# logical eraseblock size (bytes)
# minimum input/output size (bytes)
# sub-page size (bytes)
#
# PEB, LEB, MIO and SUB might be a list of comma-separated values
#
FLASH_PSZ = "262144"
FLASH_PEB = "128"
FLASH_LEB = "126976"
FLASH_MIO = "2048"
FLASH_SUB = "-"

View File

@ -6,3 +6,19 @@ include conf/machine/include/ccimx51.inc
SERIAL_CONSOLE = "38400 ttymxc1" SERIAL_CONSOLE = "38400 ttymxc1"
#################################################
## Flash parameters for JFFS2 and UBIFS images ##
#################################################
# partition size (KiB)
# physical eraseblock size (KiB)
# logical eraseblock size (bytes)
# minimum input/output size (bytes)
# sub-page size (bytes)
#
# PEB, LEB, MIO and SUB might be a list of comma-separated values
#
FLASH_PSZ = "524288"
FLASH_PEB = "128,512"
FLASH_LEB = "129024,520192"
FLASH_MIO = "2048,4096"
FLASH_SUB = "512,1024"

View File

@ -6,3 +6,20 @@
include conf/machine/include/ccimx53.inc include conf/machine/include/ccimx53.inc
SERIAL_CONSOLE = "115200 ttymxc0" SERIAL_CONSOLE = "115200 ttymxc0"
#################################################
## Flash parameters for JFFS2 and UBIFS images ##
#################################################
# partition size (KiB)
# physical eraseblock size (KiB)
# logical eraseblock size (bytes)
# minimum input/output size (bytes)
# sub-page size (bytes)
#
# PEB, LEB, MIO and SUB might be a list of comma-separated values
#
FLASH_PSZ = "524288"
FLASH_PEB = "128,512"
FLASH_LEB = "129024,520192"
FLASH_MIO = "2048,4096"
FLASH_SUB = "512,1024"

View File

@ -19,3 +19,20 @@ MACHINE_FIRMWARE = "firmware-mxs-ar3k"
MACHINE_EXTRA_RRECOMMENDS += "${MACHINE_FIRMWARE}" MACHINE_EXTRA_RRECOMMENDS += "${MACHINE_FIRMWARE}"
# MACHINE_FEATURES_append = " wifi" # MACHINE_FEATURES_append = " wifi"
#################################################
## Flash parameters for JFFS2 and UBIFS images ##
#################################################
# partition size (KiB)
# physical eraseblock size (KiB)
# logical eraseblock size (bytes)
# minimum input/output size (bytes)
# sub-page size (bytes)
#
# PEB, LEB, MIO and SUB might be a list of comma-separated values
#
FLASH_PSZ = "262144"
FLASH_PEB = "128"
FLASH_LEB = "126976"
FLASH_MIO = "2048"
FLASH_SUB = "-"

View File

@ -10,3 +10,20 @@ UBOOT_ENTRYPOINT = "0x41008000"
UBOOT_LOADADDRESS = "0x41008000" UBOOT_LOADADDRESS = "0x41008000"
SERIAL_CONSOLE = "115200 ttySP1" SERIAL_CONSOLE = "115200 ttySP1"
#################################################
## Flash parameters for JFFS2 and UBIFS images ##
#################################################
# partition size (KiB)
# physical eraseblock size (KiB)
# logical eraseblock size (bytes)
# minimum input/output size (bytes)
# sub-page size (bytes)
#
# PEB, LEB, MIO and SUB might be a list of comma-separated values
#
FLASH_PSZ = "262144"
FLASH_PEB = "128"
FLASH_LEB = "126976"
FLASH_MIO = "2048"
FLASH_SUB = "-"