title: Cross compile Linux kernel module for MIPS
body: <p>I need to cross compile the Linux kernel module <code>ftdi_sio</code> for a modem running Linux 32 bit on mips. The output of the uname command on the modem is this:<br />
  <code>Linux localhost 2.6.30 #1 SMP PREEMPT Mon Jun 8 16:14:23 CEST 2015 mips GNU/Linux</code>.</p>
  <p>The output of <code>cat /proc/cpuinfo</code> is this:</p>
  <pre><code>system type             : 963168_IADR
  voice type              : SI32261
  processor               : 0
  cpu model               : Broadcom4350 V8.0
  BogoMIPS                : 398.33
  wait instruction        : yes
  microsecond timers      : yes
  tlb_entries             : 32
  extra interrupt vector  : no
  hardware watchpoint     : no
  ASEs implemented        :
  shadow register sets    : 1
  core                    : 0
  VCED exceptions         : not available
  VCEI exceptions         : not available
  
  unaligned exceptions            : 3
  processor               : 1
  cpu model               : Broadcom4350 V8.0
  BogoMIPS                : 402.43
  wait instruction        : yes
  microsecond timers      : yes
  tlb_entries             : 32
  extra interrupt vector  : no
  hardware watchpoint     : no
  ASEs implemented        :
  shadow register sets    : 1
  core                    : 0
  VCED exceptions         : not available
  VCEI exceptions         : not available
  </code></pre>
  <p>I downloaded the Linux kernel version 2.6.30 from <a href="https://mirrors.edge.kernel.org/pub/linux/kernel/v2.6/" rel="nofollow noreferrer">here</a> and checked if in the <code>arch/mips</code> folder there was an architecture which supports both SMP, MIPS32_R1 and BIG ENDIAN, but there was no one. So I opened the <code>Kconfig</code> file inside <code>arch/mips</code> and updated the MIPS_MALTA architecture by adding the option <code>select SYS_SUPPORTS_SMP</code>. After that I cross compiled the kernel by using the toolchain provided by Openwrt called <code>OpenWrt-Toolchain-brcm63xx-for-mips-gcc-4.3.3+cs_uClibc-0.9.30.1</code>. The compilation was successful and I was able to load the kernel module, but when inserting a ftdi USB cable in the USB port of the modem it crashes and dmesg provides an error that says:</p>
  <pre><code>[  561.429000] Process khubd (pid: 69, threadinfo=8793c000, task=8790add0, tls=00000000)
  [  561.429000] Stack : 00000001 c448fdd4 c4494780 866a0980 87b7c000 00000001 c448fdd4 c44901c0
  [  561.429000]         00000000 80348ac8 000003e0 80117a68 802e97f0 866e6b80 8793fbb8 87820e00
  [  561.429000]         8111b93c 800db590 853a0bf8 80340000 85a947a8 800a5a84 802a52e8 80076f0c
  [  561.429000]         866e57d8 866ba63c 87820e00 800db590 853a0bf8 853a0bf8 00000001 800a5b4c
  [  561.429000]         0000a1ff 800dbe84 866e57ac 85a947a0 8793fc50 866ba63c 8793fc50 800dbc68
  [  561.429000]         00000000 866ba63c 866e57d8 853a0bf8 00000001 85a947a8 802e97f0 00000000
  [  561.429000]         87b7c068 800dd010 87b7c000 85a94780 85a94780 c0cd47e8 c0cd474c 85a947a0
  [  561.429000]         87b7c000 85a947a8 802e97f0 00000000 87b7c068 80181168 85a94780 80154664
  [  561.429000]         00000000 00000000 ffffffed 85a947a0 c0cd4780 85a947a0 87b7c000 801547d8
  [  561.429000]         802e1a70 8793fce8 866e6700 00000000 00000000 8793fcc8 80154944 80153be8
  [  561.429000]         870583c0 866b0000 802e2650 85a947a8 878dd650 86fd44b8 878de000 802e9820
  [  561.429000]         85a947a0 85a947d4 802ab200 80154a48 802e1a70 802ac7ec 00000000 00000000
  [  561.429000]         802e9820 85a947a0 00000000 801539ac 00000000 802ab200 87b7c000 85a947a8
  [  561.429000]         802e97f0 85a94780 85a947a0 801523f4 00000001 00000000 00000002 00000000
  [  561.429000]         00000001 00000028 85a947a0 85a94780 85a94780 00000000 866e6a08 802ab200
  [  561.429000]         87b7c000 866e6a00 00000001 00000001 85836e04 801803d8 00000002 87b7c070
  [  561.429000]         00000002 87b7c004 00000001 00000000 00000000 00000000 00001388 87b7c070
  [  561.429000]         85836e00 87a82c04 87b7c068 00000001 87a82c00 87b7c004 00000001 87b7c000
  [  561.429000]         802e9e54 87b7c068 00000002 87b7c070 802e9674 00000000 87a66868 80187370
  [  561.429000]         00000002 80154664 fffffffe 866e6700 8793fe10 87828438 ffffffed 87b7c068
  [  561.429000]         802e9e54 801547d8 802e1a70 8793fe50 866e6700 00000000 00000000 8793fe30
  [  561.429000]         80154944 80153be8 866bb2e0 866b0000 802e2650 87b7c070 878dd650 87828438
  [  561.429000]         878de000 802e9820 87b7c068 87b7c09c 87a5fd80 80154a48 802e1a70 802ac7ec
  [  561.429000]         00000000 00000000 802e9820 87b7c068 00000000 801539ac 00000000 87a5fd80
  [  561.429000]         00000002 87b7c070 802e9674 8793fea0 87b7c068 801523f4 87a66800 00000000
  [  561.429000]         000000bd 00000081 3138393a 31323900 00000000 87b7c000 87b7c068 00000000
  [  561.429000]         87b7c000 87a5fd80 00000002 00000000 87a66800 00000001 87a66800 80179aec
  [  561.429000]         0000000a 87b7c000 85348380 87a5fd80 00000000 87b7c000 85348380 8017b05c
  [  561.429000]         87a5fd80 8002b9b4 00000001 8793ff28 0000000a 00000001 00000000 00000000
  [  561.429000]         000003e8 803280d0 80327884 01010001 00000101 00000000 8790add0 8004fa04
  [  561.429000]         8793ff38 8793ff38 87a66800 87a5fd80 00000000 87a66c00 87a5fe1c 87a5fea0
  [  561.429000]         00000002 87a5fd88 87a6689c 87a5fdc8 87a5fdc4 87a5fdc0 87a5fea0 00000000
  [  561.429000]         00000001 87a669e0 00000000 8017a5d0 00000000 00000000 00000000 00000000
  [  561.429000]         00000000 00000000 00000000 8004f610 00000000 00000000 00000000 00000000
  [  561.429000]         8793c000 00000000 00000000 80014d34 10008d03 00000000 00000000 00000000
  [  561.429000]         00000000 00000000 45551450 75455555 054d0555 1d555544 54115154 555dd155
  [  561.429000]         15195545 05547516
  [  561.429000] Call Trace:(--Raw--[&lt;c448fdd4&gt;] 0xc448fdd4
  ....
  </code></pre>