[U-Boot] UBIFS will not build for Davinci (2006.06-rc2)

kevin_springle at telus.net
2009-06-01T18:58:39Z

Hi,

I am trying to add UBIFS support to the davinci_dvevm board (ARCH=arm, CPU=arm926ejs,
BOARD=dvevm, VENDOR=davinci, SOC=davinci) configuration. However, I encountered a
number of issues that lead me to belive that UBIFS support is limited to PowerPC
architectures.

Has UBIFS support been built and tested on any platform other than PowerPC?

The patch I used to enable UBIFS support on the DVEVM board is:
--- /home/tester/uboot/u-boot-2009.06-rc2.orig/include/configs/davinci_dvevm.h 2009-05-15 14:29:23.000000000 -0700
+++ /home/tester/uboot/u-boot-2009.06-rc2/include/configs/davinci_dvevm.h 2009-06-01 11:15:59.000000000 -0700
@@ -51,7 +51,7 @@
/*=======*/
#define DV_EVM
#define CONFIG_SYS_NAND_SMALLPAGE
-#define CONFIG_SYS_USE_NOR
+#define CONFIG_SYS_USE_NAND
/*===================*/
/* SoC Configuration */
/*===================*/
@@ -129,6 +129,14 @@
#define CONFIG_SYS_MAX_NAND_DEVICE 1 /* Max number of NAND devices */
#define CONFIG_ENV_OFFSET 0x0 /* Block 0--not used by bootcode */
#define DEF_BOOTM ""
+#define CONFIG_MTD_PARTITIONS
+#define CONFIG_CMD_MTDPARTS
+#define CONFIG_CMD_UBI
+#define CONFIG_CMD_UBIFS
+#define CONFIG_SYS_64BIT_VSPRINTF
+#define CONFIG_RBTREE
+#define CONFIG_LZO
#elif defined(CONFIG_SYS_USE_NOR)
#ifdef CONFIG_NOR_UART_BOOT
#define CONFIG_SKIP_LOWLEVEL_INIT /* U-Boot is loaded by a bootloader */

The first problem I encountered was a compiler error:
In file included from ubifs.c:27:
ubifs.h:468: error: conflicting types for '__set_bit'
/home/tester/uboot/u-boot-2009.06-rc2/include/asm/bitops.h:29: error: previous definition of '__set_bit' was here
ubifs.h:476: error: conflicting types for '__clear_bit'
/home/tester/uboot/u-boot-2009.06-rc2/include/asm/bitops.h:36: error: previous definition of '__clear_bit' was here
make[2]: *** [ubifs.o] Error 1

The error seems to occur becase fs/ubifs/ubifs.h defines two inline functions,
__set_bit() and __clear_bit(). For some architectures, including ARM, these
functions are already defined in bitops.h AND the prototypes are different from
the ones in ubifs.h:
__set_bit() & __clear_bit():
include/asm-arm/bitops.h
include/asm-microblaze/bitops.h
__set_bit() only:
include/asm-blackfin/bitops.h
include/asm-i386/bitops.h
include/asm-mips/bitops.h

For a quick fix (and probably not the recommended one), I renamed all the __set_bit()
and __clear_bit() symbols in fs/ubifs to be __ubi_set_bit() and __ubi_clear_bit().

The second problem was a compiler error in lzo1x_decompress.c:
lzo1x_decompress.c:17:27: error: asm/unaligned.h: No such file or directory
lzo1x_decompress.c: In function 'lzo1x_decompress_safe':
lzo1x_decompress.c:72: warning: implicit declaration of function 'put_unaligned'
lzo1x_decompress.c:72: warning: implicit declaration of function 'get_unaligned'
lzo1x_decompress.c:140: warning: implicit declaration of function 'get_unaligned_le16'
make[2]: *** [lzo1x_decompress.o] Error 1

File unaligned.h is ONLY present in include/asm-ppc.

So I undefined CONFIG_LZO and now I get linker errors:
fs/ubifs/libubifs.a(super.o): In function `init_constants_early':
/home/tester/uboot/u-boot-2009.06-rc2/fs/ubifs/super.c:317: undefined reference to `fls'
fs/ubifs/libubifs.a(lpt.o): In function `dirty_cow_nnode':
/home/tester/uboot/u-boot-2009.06-rc2/fs/ubifs/lpt.c:893: undefined reference to `test_and_set_bit'
fs/ubifs/libubifs.a(lpt.o): In function `dirty_cow_pnode':
/home/tester/uboot/u-boot-2009.06-rc2/fs/ubifs/lpt.c:944: undefined reference to `test_and_set_bit'
fs/ubifs/libubifs.a(lpt.o): In function `do_calc_lpt_geom':
/home/tester/uboot/u-boot-2009.06-rc2/fs/ubifs/lpt.c:81: undefined reference to `fls'
/home/tester/uboot/u-boot-2009.06-rc2/fs/ubifs/lpt.c:82: undefined reference to `fls'
/home/tester/uboot/u-boot-2009.06-rc2/fs/ubifs/lpt.c:83: undefined reference to `fls'
/home/tester/uboot/u-boot-2009.06-rc2/fs/ubifs/lpt.c:84: undefined reference to `fls'
/home/tester/uboot/u-boot-2009.06-rc2/fs/ubifs/lpt.c:87: undefined reference to `fls'
fs/ubifs/libubifs.a(lpt.o):/home/tester/uboot/u-boot-2009.06-rc2/fs/ubifs/lpt.c:89: more undefined references to `fls' follow
fs/ubifs/libubifs.a(tnc.o): In function `dirty_cow_znode':
/home/tester/uboot/u-boot-2009.06-rc2/fs/ubifs/tnc.c:274: undefined reference to `test_and_set_bit'
fs/ubifs/libubifs.a(ubifs.o):(.data+0xc): undefined reference to `lzo1x_decompress_safe'

* Function test_and_set_bit() is declared in include/asm-arm/bitops.h but it is never defined, like it is for other architectures.
* Function fls() is ONLY defined for PowerPC architectures.
* Function lzo1x_decompress_safe is missing, of course, because I undefined CONFIG_LZO.

Also, there are some C library related linker errors:
/usr/local/WindRiver_3_0/wrlinux-3.0/layers/wrll-toolchain-4.3-85/arm/toolchain/x86-linux2/bin/../lib/gcc/arm-wrs-linux-gnueabi/4.3.2/libgcc.a(_udivsi3.o): In function `__aeabi_uidiv':
(.text+0x0): multiple definition of `__udivsi3'
lib_arm/libarm.a(_udivsi3.o):/home/tester/uboot/u-boot-2009.06-rc2/lib_arm/_udivsi3.S:17: first defined here
fs/ubifs/libubifs.a(ubifs.o):(.data+0xc): undefined reference to `lzo1x_decompress_safe'
/usr/local/WindRiver_3_0/wrlinux-3.0/layers/wrll-toolchain-4.3-85/arm/toolchain/x86-linux2/bin/../lib/gcc/arm-wrs-linux-gnueabi/4.3.2/libgcc.a(_dvmd_lnx.o): In function `__aeabi_ldiv0':
(.text+0x8): undefined reference to `raise'

These C library errors are directly related to the CONFIG_SYS_64BIT_VSPRINTF option,
which I enabled because ubifs.c told me to:
ubifs.c:30:2: warning: #warning Please define CONFIG_SYS_64BIT_VSPRINTF for correct output!
Disabling CONFIG_SYS_64BIT_VSPRINTF produced the warning, but the linker no longer complains about the symbols.

Regards,
Kevin