{"id":25,"date":"2009-10-23T12:07:22","date_gmt":"2009-10-23T11:07:22","guid":{"rendered":"http:\/\/paguilar.org\/?p=25"},"modified":"2009-10-23T12:07:22","modified_gmt":"2009-10-23T11:07:22","slug":"cross-compiling-udev","status":"publish","type":"post","link":"https:\/\/paguilar.org\/?p=25","title":{"rendered":"Cross-compiling udev"},"content":{"rendered":"<p>udev is the device manager for the Linux 2.6 kernel series. It takes care of handling all the devices in \/dev, such as adding\/removing devices, and loading firmware when a driver asks for it.<\/p>\n<p>Compiling and installing udev is a straight-forward procedure, but you need to pay attention to it&#8217;s requirements. The README file inside the source code describes clearly these requirements.<\/p>\n<p>One of these requirements in later versions of udev, such as udev-136 and on, specifies that you need to disable the CONFIG_SYSFS_DEPRECATED* option in the kernel configuration, but some drivers of embedded Linux distros such as STLinux2.3 that use a 2.6.23.17 kernel need this flag enabled, therefore, you have to<br \/>\nuse a udev version that doesn&#8217;t have this constraint.<br \/>\nAlthough this requirement was introduced for a kernel 2.6.22 and the kernel of the STLinux2.3 distro is greater, udev has problems when uploading the firmware for a driver. In my case it fails when uploading it for a DVB-S2 tuner:<\/p>\n<p><pre>\ncx24116_firmware_ondemand: Waiting for firmware upload (dvb-fe-cx24116.fw)...\nkobject_add failed for i2c-1 with -EEXIST, don't try to register things with the same name in the same directory.\nStack: (0x866fdde8 to 0x866fe000)\n\n(skipping stack dump)\n\nCall trace:\n[<841eba80>] kobject_get+0x0\/0x20\n[<8422713e>] device_add+0x9e\/0x5c0\n[<84226180>] get_device+0x0\/0x20\n[<841ec0ae>] kobject_init+0x2e\/0x60\n[<8422eef0>] _request_firmware+0xd0\/0x3e0\n[<841ef420>] strlcpy+0x0\/0x80\n[<c115f81c>] cx24116_cmd_execute+0x1bc\/0x620 [cx24116]\n[<c115f660>] cx24116_cmd_execute+0x0\/0x620 [cx24116]\n[<842cf432>] i2c_transfer+0x32\/0x60\n[<c115f5f8>] cx24116_writereg+0x58\/0xc0 [cx24116]\n[<c115f660>] cx24116_cmd_execute+0x0\/0x620 [cx24116]\n[<c115f5a0>] cx24116_writereg+0x0\/0xc0 [cx24116]\n[<c1160040>] cx24116_initfe+0x60\/0x140 [cx24116]\n[<c115f660>] cx24116_cmd_execute+0x0\/0x620 [cx24116]\n[<c115f5a0>] cx24116_writereg+0x0\/0xc0 [cx24116]\n[<84011776>] dequeue_entity+0x16\/0xc0\n[<84254880>] dvb_frontend_init+0x20\/0xa0\n[<84013140>] complete+0x0\/0xa0\n[<842574e0>] dvb_frontend_thread+0x0\/0x5c0\n[<84257534>] dvb_frontend_thread+0x54\/0x5c0\n[<842574e0>] dvb_frontend_thread+0x0\/0x5c0\n[<843ab2a6>] __switch_to_end+0x84\/0x3fe\n[<8403112c>] kthread+0x2c\/0x80\n[<84031138>] kthread+0x38\/0x80\n[<84013140>] complete+0x0\/0xa0\n[<842574e0>] dvb_frontend_thread+0x0\/0x5c0\n[<840310c0>] kthread_should_stop+0x0\/0x20\n[<84003924>] kernel_thread_helper+0x4\/0x20\n[<84031100>] kthread+0x0\/0x80\n[<84003920>] kernel_thread_helper+0x0\/0x20\n<\/pre>\n<\/p>\n<p>Notice that I had this problem with STLinux2.3&#8217;s kernel an its drivers, this doesn&#8217;t mean that udev is buggy.<\/p>\n<p>I used udev-129 for solving this problem. This udev version has only the following requirements:<\/p>\n<ul>\n<li>A 2.6.19 kernel<\/li>\n<li>The kernel must have sysfs, unix domain sockets (compiled inside the kernel, not as a module) and networking enabled.<\/li>\n<li>The proc and sysfs filesystems must be mounted in \/proc and \/sys<\/li>\n<\/ul>\n<p>Since my system follows these requirements I had no problems for compiling and running it:<\/p>\n<p>Download <a href=\"http:\/\/www.kernel.org\/pub\/linux\/utils\/kernel\/hotplug\/udev-129.tar.bz2\">udev-129<\/a>. <\/p>\n<p>Create a directory for installing it:<\/p>\n<pre lang=\"bash\">\n$ mkdir -p \/opt\/build-129\n<\/pre>\n<p>Set the following environment variables that will make our life easier:<\/p>\n<pre lang=\"bash\">\n$ export BUILD=i386-linux\n$ export HOST=sh4-linux\n$ export PREFIX=\/usr\n$ export BUILDDIR=\/opt\/build-129\n<\/pre>\n<p>Configure, compile and install it in $BUILDDIR<\/p>\n<pre lang=\"bash\">\n$ .\/configure --build=$BUILD --host=$HOST --prefix=$PREFIX\n$ make\n$ make DESTDIR=$BUILDDIR install\n<\/pre>\n<p>Copy the <em>$BUILDDIR<\/em> directory to your target&#8217;s filesystem, you can leave aside the includes (<em>\/usr\/include<\/em>) and doc (<em>\/usr\/share<\/em>) directories that normally are not needed in the target.<\/p>\n<p>Now you can start the fine-tuning of the rules and customize them as you need.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>udev is the device manager for the Linux 2.6 kernel series. It takes care of handling all the devices in \/dev, such as adding\/removing devices, and loading firmware when a driver asks for it. Compiling and installing udev is a straight-forward procedure, but you need to pay attention to it&#8217;s requirements. The README file inside\u2026 <span class=\"read-more\"><a href=\"https:\/\/paguilar.org\/?p=25\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,8,13],"tags":[22,57,60,41],"class_list":["post-25","post","type-post","status-publish","format-standard","hentry","category-compiling","category-driver","category-kernel","tag-cross-compiling","tag-kernel","tag-stlinux","tag-udev"],"_links":{"self":[{"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/posts\/25","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/paguilar.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=25"}],"version-history":[{"count":0,"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/posts\/25\/revisions"}],"wp:attachment":[{"href":"https:\/\/paguilar.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=25"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/paguilar.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=25"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/paguilar.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=25"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}