Getting Working Wifi for Kernel builds

Search This thread

sleshepic

Inactive Recognized Themer
Oct 18, 2011
3,915
7,030
PA
I have been buliding some kernels recently, but have been unable to get the wifi working.

I have tried it having the modules included in initramfs/lib/modules when ramdisk is created and i do mkbootimg, and have also tried just putting all the modules in the flash zip in /system/lib/modules, and excluded it from build process. Both result in no Wifi [Edit, putting the newly built correct modules in my working folders /lib/modules fixed wifi, must not have done it correctly before)

basic overview of what I've done (after zImage compile)

I use "./unpack-bootimg.pl boot.img" to pull the "ramdisk-contents" from the stock kernel, I renamed that folder "initramfs" and threw it in a folder along with my mkbootimg binary, and my zImage I just compiled.

I put the newly created modules from zImage build in my initramfs/libs/modules with

find -name '*.ko' -exec cp -av {} [path to desired folder] \;

I navigate to the initramfs folder and

find .|cpio -o -H newc > ../ramdisk
cd ..
gzip ramdisk

./mkbootimg --kernel ./zImage --ramdisk ./ramdisk.gz --board smdk4x12 --base 0x10000000 --pagesize 2048 --ramdiskaddr 0x11000000 -o boot.img

the resultant boot.img boots fine and shows all other changes, just cant seem to get the wifi working. Anyone have idea for getting wifi working on our Note 2 kernel builds?


Edit: I re-tried and this time it worked. Not sure what was different. Copied the newly created modules into my ramdisk folder (for me was /initramfs/lib/modules) and created my ramdisk.gz etc. made the boot.img and it's all good. The difference must've been having the correct modules in place prior to creating the ramdisk.cpio(then .cpio.gz).
Mods please move if you feel this is in wrong section now etc. Found the answer, thank you
 
Last edited:

Droidzone

Inactive Recognized Developer
Sep 24, 2010
5,531
2,283
Kochi
www.droidzone.in
OnePlus 9 Pro
Facing an almost similiar issue over here with the wifi modules. For me, I found that my boot.img is itself too large for initramfs to accomodate the compiled modules (optimization was off). So I put them in system/lib/modules and tried to insmod them.

Using the sbin's insmod gives me this:
Code:
[droidzone@supernova android]$adb shell
shell@android:/ $ su
shell@android:/ # insmod /system/lib/modules/dhd.ko                                                
insmod: init_module '/system/lib/modules/dhd.ko' failed (No such file or directory)
255|shell@android:/ # busybox insmod /system/lib/modules/dhd.ko                
insmod: can't insert '/system/lib/modules/dhd.ko': unknown symbol in module, or unknown parameter
2|shell@android:/ #

I've turned off module versioning, and am not sure why there's a symbol error.
 
Last edited:
  • Like
Reactions: sleshepic

AndreiLux

Senior Member
Jul 9, 2011
3,209
14,598
Facing an almost similiar issue over here with the wifi modules. For me, I found that my boot.img is itself too large for initramfs to accomodate the compiled modules (optimization was off). So I put them in system/lib/modules and tried to insmod them.

Using the sbin's insmod gives me this:
Code:
[droidzone@supernova android]$adb shell
shell@android:/ $ su
shell@android:/ # insmod /system/lib/modules/dhd.ko                                                
insmod: init_module '/system/lib/modules/dhd.ko' failed (No such file or directory)
255|shell@android:/ # busybox insmod /system/lib/modules/dhd.ko                
insmod: can't insert '/system/lib/modules/dhd.ko': unknown symbol in module, or unknown parameter
2|shell@android:/ #

I've turned off module versioning, and am not sure why there's a symbol error.
Add --strip-debug into the LDFLAGS_MODULE of the main makefile and make sure the modules went through second stage compilation. The OS probably forwards some parameters and you can't just insmod it.
 
Last edited:

Droidzone

Inactive Recognized Developer
Sep 24, 2010
5,531
2,283
Kochi
www.droidzone.in
OnePlus 9 Pro
I fixed that issue..

The real reason is something queer and interesting. It was because I'd defined GREP_OPTIONS defined as '--color -in'. This seemed to interfere with the kernel scripts. Once the var was unset, problem was solved.

However the inability to load the module persists.

My main kernel has the version name "3.0.31-g5d44d80-dirty", and the vermagic of module seems to be "3.0.31-gc299ec6 SMP preempt mod_unload modversions ARMv7 p2v8".

This obviously leads to version mismatch, and inability to load the module. Do you know why this happens? The kernel and module were used from the same compilation session. In fact I havent even changed the version name in .config.

dmesg during insmod gives this error code which narrows down the issue:
Code:
c0 dhd: version magic '3.0.31-gc299ec6 SMP preempt mod_unload modversions ARMv7 p2v8 ' should be '3.0.31-g5d44d80-dirty SMP preempt mod_unload ARMv7 '

EDIT:
Maybe I had made a script error and forgot to replace the original kernel/module..That error has disappeared to be replaced by the former issue-unable to insert module. Module was compiled with debug symbols.

Insmod reports:
insmod: init_module '/system/lib/modules/dhd.ko' failed (No such file or directory)
Modprobe reports:
modprobe: chdir(3.0.31-ge52b835-dirty): No such file or directory

Kernel reports:
Code:
c0 dhd: Unknown symbol _GLOBAL_OFFSET_TABLE_ (err 0)

Trying to narrow it down to the source file. I'm expecting that some function has 'forgotten' to export symbol.

I'm wondering whether this is just me, or is Samsung source dump supposed to have these kind of errors on defconfig. First they "forget" to include cypress drivers. Now errors related to symbol export.

EDIT2:
Still no more closer to finding the cause of the error. Did a grep and these are the only things I found:

Code:
[droidzone@supernova kernel_IN]$grep --color -inr '_GLOBAL_OFFSET_TABLE_' * | grep -v 'Binary file'
arch/powerpc/boot/crt0.S:42:    addis   r11,r10,(_GLOBAL_OFFSET_TABLE_-p_base)@ha
arch/powerpc/boot/crt0.S:43:    lwz     r11,(_GLOBAL_OFFSET_TABLE_-p_base)@l(r11)
arch/m32r/boot/compressed/head.S:39:    seth    r3, #high(_GLOBAL_OFFSET_TABLE_+8)
arch/m32r/boot/compressed/head.S:40:    or3     r3, r3, #low(_GLOBAL_OFFSET_TABLE_+12)
arch/s390/kernel/module.c:149:                     "_GLOBAL_OFFSET_TABLE_") == 0)
arch/avr32/kernel/module.c:104:                    "_GLOBAL_OFFSET_TABLE_") == 0)
scripts/mod/modpost.c:565:      if (strcmp(symname, "_GLOBAL_OFFSET_TABLE_") == 0)
System.map:49417:c0b4f468 d _GLOBAL_OFFSET_TABLE_

The relevant segment of scripts/mod/modpost.c:
Code:
static int ignore_undef_symbol(struct elf_info *info, const char *symname)
{
	/* ignore __this_module, it will be resolved shortly */
	if (strcmp(symname, MODULE_SYMBOL_PREFIX "__this_module") == 0)
		return 1;
	/* ignore global offset table */
	if (strcmp(symname, "_GLOBAL_OFFSET_TABLE_") == 0)
		return 1;

Edit3: Solved.
 
Last edited:

garwynn

Retired Forum Mod / Inactive Recognized Developer
Jul 30, 2011
5,179
8,589
NE Ohio
www.extra-life.org
Add --strip-debug into the LDFLAGS_MODULE of the main makefile and make sure the modules went through second stage compilation. The OS probably forwards some parameters and you can't just insmod it.

I'd like to thank you for this information - this cut my dhd.ko from 4.6 MB to around 550 kB - and my resulting kernel as a result. Fully expect this will now get my kernel working as it should.
 

wctliu

Member
Feb 15, 2013
41
2
China
I fixed that issue..

The real reason is something queer and interesting. It was because I'd defined GREP_OPTIONS defined as '--color -in'. This seemed to interfere with the kernel scripts. Once the var was unset, problem was solved.

However the inability to load the module persists.

My main kernel has the version name "3.0.31-g5d44d80-dirty", and the vermagic of module seems to be "3.0.31-gc299ec6 SMP preempt mod_unload modversions ARMv7 p2v8".

This obviously leads to version mismatch, and inability to load the module. Do you know why this happens? The kernel and module were used from the same compilation session. In fact I havent even changed the version name in .config.

dmesg during insmod gives this error code which narrows down the issue:
Code:
c0 dhd: version magic '3.0.31-gc299ec6 SMP preempt mod_unload modversions ARMv7 p2v8 ' should be '3.0.31-g5d44d80-dirty SMP preempt mod_unload ARMv7 '

EDIT:
Maybe I had made a script error and forgot to replace the original kernel/module..That error has disappeared to be replaced by the former issue-unable to insert module. Module was compiled with debug symbols.

Insmod reports:
insmod: init_module '/system/lib/modules/dhd.ko' failed (No such file or directory)
Modprobe reports:
modprobe: chdir(3.0.31-ge52b835-dirty): No such file or directory

Kernel reports:
Code:
c0 dhd: Unknown symbol _GLOBAL_OFFSET_TABLE_ (err 0)

Trying to narrow it down to the source file. I'm expecting that some function has 'forgotten' to export symbol.

I'm wondering whether this is just me, or is Samsung source dump supposed to have these kind of errors on defconfig. First they "forget" to include cypress drivers. Now errors related to symbol export.

EDIT2:
Still no more closer to finding the cause of the error. Did a grep and these are the only things I found:

Code:
[droidzone@supernova kernel_IN]$grep --color -inr '_GLOBAL_OFFSET_TABLE_' * | grep -v 'Binary file'
arch/powerpc/boot/crt0.S:42:    addis   r11,r10,(_GLOBAL_OFFSET_TABLE_-p_base)@ha
arch/powerpc/boot/crt0.S:43:    lwz     r11,(_GLOBAL_OFFSET_TABLE_-p_base)@l(r11)
arch/m32r/boot/compressed/head.S:39:    seth    r3, #high(_GLOBAL_OFFSET_TABLE_+8)
arch/m32r/boot/compressed/head.S:40:    or3     r3, r3, #low(_GLOBAL_OFFSET_TABLE_+12)
arch/s390/kernel/module.c:149:                     "_GLOBAL_OFFSET_TABLE_") == 0)
arch/avr32/kernel/module.c:104:                    "_GLOBAL_OFFSET_TABLE_") == 0)
scripts/mod/modpost.c:565:      if (strcmp(symname, "_GLOBAL_OFFSET_TABLE_") == 0)
System.map:49417:c0b4f468 d _GLOBAL_OFFSET_TABLE_

The relevant segment of scripts/mod/modpost.c:
Code:
static int ignore_undef_symbol(struct elf_info *info, const char *symname)
{
	/* ignore __this_module, it will be resolved shortly */
	if (strcmp(symname, MODULE_SYMBOL_PREFIX "__this_module") == 0)
		return 1;
	/* ignore global offset table */
	if (strcmp(symname, "_GLOBAL_OFFSET_TABLE_") == 0)
		return 1;

Edit3: Solved.


How to Solved? Too detailed can you tell us a little bit?
 

sleshepic

Inactive Recognized Themer
Oct 18, 2011
3,915
7,030
PA
another toolchain????

Which version?

I uesd these:

/home/wctliu/toolchains/arm-eabi-4.4.3/bin/arm-eabi-

/home/wctliu/arm-2009q3/bin/arm-none-linux-gnueabi-

Which will cause the problem to occur?

Did you see and do the changes AndreiLux mentioned above to the makefile. That can be the difference of whether you get useable wifi modules. Simple place to start if your getting a working kernel but no wifi

Sent from my SPH-L900 using xda premium
 
Last edited:

Entropy512

Senior Recognized Developer
Aug 31, 2007
14,088
25,086
Owego, NY

ffolkes

Senior Member
Oct 18, 2006
1,338
2,108
New Jersey
I cannot get Wifi to work either. I have the same exact problem as Droidzone with the "_GLOBAL_OFFSET_TABLE_" error.

I have checked that:

"LDFLAGS_MODULE = --strip-debug" is set in Makefile.

I'm using the 4.7 toolchain, but just tried the 4.6 to no avail.

Any help would be much appreciated.

Update: I was able to get it working by using CFLAGS_MODULE=-fno-pic as suggested in this guide.
 
Last edited:

sleshepic

Inactive Recognized Themer
Oct 18, 2011
3,915
7,030
PA
I was running in the same issues. I solved my problem adding these to my kernel makefile:
LDFLAGS_MODULE = --strip-debug
CFLAGS_MODULE = -fno-pic

There must be something else goin on in my setup as this does not work for me to getting working WiFi. What is your build process?



Edit: or if you wouldn't mind shoot in me your kernel I'd be interested if it something small I'm missing like updater script etc

Edit2: I feel sometimes in android doing the same thing twice results in separate results. Crazy :D thx

 
Last edited:
  • Like
Reactions: ztotherad

DroidFreak32

Senior Member
Jul 24, 2013
1,270
2,516
Mangalore
Sony Xperia SP
Google Nexus 5
Hey sorry to bump this. Not sure if anyone still remembers :p I have the same problem with my GT-B5330.
Even though I set in my kernel/Makefile :
CFLAGS_MODULE = -fno-pic
LDFLAGS_MODULE = --strip-debug

After building the kernel from source I get the dhd.ko file, copy it to ramdisk/lib/modules and then repack it with the zimage generated by the build.
Then i dd the newly created boot.img to the kernel partition.
lsmod doesnt show dhd.ko
and the file exists in system/lib/modules/dhd.ko

Toolchain arm-eabi-4.6
 

garwynn

Retired Forum Mod / Inactive Recognized Developer
Jul 30, 2011
5,179
8,589
NE Ohio
www.extra-life.org
Hey sorry to bump this. Not sure if anyone still remembers :p I have the same problem with my GT-B5330.
Even though I set in my kernel/Makefile :
CFLAGS_MODULE = -fno-pic
LDFLAGS_MODULE = --strip-debug

After building the kernel from source I get the dhd.ko file, copy it to ramdisk/lib/modules and then repack it with the zimage generated by the build.
Then i dd the newly created boot.img to the kernel partition.
lsmod doesnt show dhd.ko
and the file exists in system/lib/modules/dhd.ko

Toolchain arm-eabi-4.6

Are you able to test manually starting using insmod? If so, what is the result?
 

Top Liked Posts

  • There are no posts matching your filters.
  • 7
    Facing an almost similiar issue over here with the wifi modules. For me, I found that my boot.img is itself too large for initramfs to accomodate the compiled modules (optimization was off). So I put them in system/lib/modules and tried to insmod them.

    Using the sbin's insmod gives me this:
    Code:
    [droidzone@supernova android]$adb shell
    shell@android:/ $ su
    shell@android:/ # insmod /system/lib/modules/dhd.ko                                                
    insmod: init_module '/system/lib/modules/dhd.ko' failed (No such file or directory)
    255|shell@android:/ # busybox insmod /system/lib/modules/dhd.ko                
    insmod: can't insert '/system/lib/modules/dhd.ko': unknown symbol in module, or unknown parameter
    2|shell@android:/ #

    I've turned off module versioning, and am not sure why there's a symbol error.
    Add --strip-debug into the LDFLAGS_MODULE of the main makefile and make sure the modules went through second stage compilation. The OS probably forwards some parameters and you can't just insmod it.
    3
    Add --strip-debug into the LDFLAGS_MODULE of the main makefile and make sure the modules went through second stage compilation. The OS probably forwards some parameters and you can't just insmod it.

    That is correct, the OS does pass parameters to the module when loading.

    An example (from CM) can be seen at: https://github.com/CyanogenMod/andr...common/blob/cm-10.1/BoardCommonConfig.mk#L122
    2
    I have been buliding some kernels recently, but have been unable to get the wifi working.

    I have tried it having the modules included in initramfs/lib/modules when ramdisk is created and i do mkbootimg, and have also tried just putting all the modules in the flash zip in /system/lib/modules, and excluded it from build process. Both result in no Wifi [Edit, putting the newly built correct modules in my working folders /lib/modules fixed wifi, must not have done it correctly before)

    basic overview of what I've done (after zImage compile)

    I use "./unpack-bootimg.pl boot.img" to pull the "ramdisk-contents" from the stock kernel, I renamed that folder "initramfs" and threw it in a folder along with my mkbootimg binary, and my zImage I just compiled.

    I put the newly created modules from zImage build in my initramfs/libs/modules with

    find -name '*.ko' -exec cp -av {} [path to desired folder] \;

    I navigate to the initramfs folder and

    find .|cpio -o -H newc > ../ramdisk
    cd ..
    gzip ramdisk

    ./mkbootimg --kernel ./zImage --ramdisk ./ramdisk.gz --board smdk4x12 --base 0x10000000 --pagesize 2048 --ramdiskaddr 0x11000000 -o boot.img

    the resultant boot.img boots fine and shows all other changes, just cant seem to get the wifi working. Anyone have idea for getting wifi working on our Note 2 kernel builds?


    Edit: I re-tried and this time it worked. Not sure what was different. Copied the newly created modules into my ramdisk folder (for me was /initramfs/lib/modules) and created my ramdisk.gz etc. made the boot.img and it's all good. The difference must've been having the correct modules in place prior to creating the ramdisk.cpio(then .cpio.gz).
    Mods please move if you feel this is in wrong section now etc. Found the answer, thank you
    2
    Solved

    I was running in the same issues. I solved my problem adding these to my kernel makefile:
    LDFLAGS_MODULE = --strip-debug
    CFLAGS_MODULE = -fno-pic
    2
    I cannot get Wifi to work either. I have the same exact problem as Droidzone with the "_GLOBAL_OFFSET_TABLE_" error.

    I have checked that:

    "LDFLAGS_MODULE = --strip-debug" is set in Makefile.

    I'm using the 4.7 toolchain, but just tried the 4.6 to no avail.

    Any help would be much appreciated.

    Update: I was able to get it working by using CFLAGS_MODULE=-fno-pic as suggested in this guide.