From 1111a3d6a0551b251c40a5161d92c79b776a74e7 Mon Sep 17 00:00:00 2001 From: Javier Viguera Date: Tue, 5 Nov 2013 11:16:13 +0100 Subject: [PATCH] image_types_digi: make it compatible with python 2.6 Python 2.6 does not have bit_length function: 'int' object has no attribute 'bit_length' Signed-off-by: Javier Viguera --- meta-digi-arm/classes/image_types_digi.bbclass | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/meta-digi-arm/classes/image_types_digi.bbclass b/meta-digi-arm/classes/image_types_digi.bbclass index d7758c48d..65f0ee5e4 100644 --- a/meta-digi-arm/classes/image_types_digi.bbclass +++ b/meta-digi-arm/classes/image_types_digi.bbclass @@ -7,9 +7,16 @@ def max_leb_count(d): _flash_peb = d.getVar('FLASH_PEB', True) _flash_psz = d.getVar('FLASH_PSZ', True) for i in _flash_peb.split(','): - _mlc.append(str(2 ** (int(_flash_psz)/int(i) - 1).bit_length() - 1)) + _mlc.append(str(next_power_of_2(int(_flash_psz)/int(i)) - 1)) return ','.join(_mlc) +# Return next power_of_2 bigger than passed argument +def next_power_of_2(n): + i = 1 + while (n > i): + i <<= 1 + return i + IMAGE_CMD_jffs2() { nimg="$(echo ${FLASH_PEB} | awk -F, '{print NF}')" for i in $(seq 1 ${nimg}); do