Sunday, February 17, 2008

Let arm-linux support setlocale

Author: XianJim lee

Most of the ARM-linux BSP(Board support package) provided by the CPU manufacture don't support setlocate. Marvell PXA3xx linux BSP is an example, I ask FAE for help, but they told me that it is beyond their support scope. So, I have to do it myself.

After reading the source code of setlocale in glibc-2.5, I knew setlocale need the data file /usr/lib/locale/locale-archive, but it doesn't exist in my board. I should put one at here, but where can I get the file? From the PC? Oh, it is about 60M, too large for mobile device.

Does the toolchain provide a tiny one? I checked the toolchain, no, there is no such file in the toolchain directory. I studied the crosstool and glibc-2.5, I found it is easy to make a customized one. The following text shows the process step by step:

1. Unpack the glibc tarball in the sources directory.

  # tar zxvf glibc-2.5.tar.gz


2.Edit glibc-2.5/localedata/SUPPORTED to customize your own locale-archive.
 # vim glibc-2.5/localedata/SUPPORTED
(Delete all the unused locales.)


3.Edit glibc-2.5/localedata/Makefile to support cross-compile.
 # vim glibc-2.5/localedata/Makefile
(Redefine the macro LOCALEDEF, use host localedef instead.)


4.Edit crosstool.sh to build and install locale-archive.
 # vim crosstool.sh
(Uncomment the line make localedata/install-locales install_root=${SYSROOT},
and change it to make localedata/install-locales install root=${TARGET},
or your system locale-archive will be overwritten.)


5. Tar the modified file back the tarball.
 # tar czvf glibc-2.5.tar.gz glibc-2.5.)


6.Build it by run build.sh. Wait until it is done,
copy locale-archive to your board.
 NOTE: You should copy the files in lib/gconv too, 
or the function iconv will still fail..)


No comments: