Compiling a Kernel for Ad-Hoc Wireless Networking Support

625 views
Skip to first unread message

mala...@gmail.com

unread,
Feb 17, 2013, 2:48:40 PM2/17/13
to spa...@googlegroups.com
Hi,

I'm interested in running these apps on a Galaxy Tab 2 which has the BCM4330 chip. Using iwconfig it appears there is wext support but I'm having a lot of trouble recompiling the kernel to support wireless adhoc mode.

Here's my environment for compiling the kernel:

Ubuntu 12.04 64 bit
Sourcery G++ Lite 2010q1-202 for ARM GNU/Linux
Kernel source from here: http://opensource.samsung.com/reception/receptionSub.do?method=search&searchValue=GT-P3113 (NA JellyBean)

With this setup I've been running into a lot of cross compilation issues even when trying to compile the raw source without any modifications. Do you have any recommendations on what you use to recompile kernel sources?

Thanks,

- Mustafa

stoker

unread,
Feb 17, 2013, 8:07:01 PM2/17/13
to spa...@googlegroups.com, mala...@gmail.com
Hi Mustafa,

I'm still using the arm-2009q3 CodeSourcery Toolchain on Ubuntu 11.04 to compile Android kernels. I haven't tried any of the more recent versions of CodeSourcery. I should probably upgrade to a supported version of Ubuntu, but I haven't bothered to yet.

I haven't compiled the kernel for your specific device, so I don't know if there's something strange with the kernel source. Maybe you can try compiling the kernel source for another device just to see if it's an issue with your toolchain / dev. environment or the source itself.

Attached is the build script I used to compile the Nexus 7 kernel. I dump the zImage and kernel modules into an Anykernel file structure and flash via ClockworkMod Recovery. Also attached is the .config file I used. The config is based on the one I pulled from the device with modifications to add wext support.

Specifically, here's how I got the Nexus 7 source:
cd tegra
git checkout android-tegra3-grouper-3.1-jb-mr0

I could build that source without any problems.

- stoker
build.sh
.config.txt

stoker

unread,
Feb 17, 2013, 8:31:39 PM2/17/13
to spa...@googlegroups.com, mala...@gmail.com
Also, when I compiled the Galaxy Nexus kernel I used the prebuilt toolchain that was part of the AOSP (Gingerbread):

CROSS_COMPILER=/home/dev/Desktop/PROJECTS/ANDROID_PLATFORM_GINGERBREAD/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-

- stoker

mala...@gmail.com

unread,
Feb 18, 2013, 2:53:32 PM2/18/13
to spa...@googlegroups.com, mala...@gmail.com
Thanks stoker. That build script is very useful and should work with the device I'm using with a few modifications. I'll let you know if I succeed and post the results.

Corey Wallis

unread,
Feb 18, 2013, 6:36:00 PM2/18/13
to spa...@googlegroups.com
Hi,

I'm very interested in getting adhoc mode working on this device,
specifically I have 20 GT-P3110 tablets I need to get into a mesh.

We're using CyanogenMod 9.1 with the devices so the kernel I'm most
interested in is here:

http://www.github.com/cyanogenmod/android_kernel_samsung_espresso10

It appears that the code for the wifi driver is here:

https://github.com/CyanogenMod/android_kernel_samsung_espresso10/tree/cm-10.1/drivers/net/wireless/bcmdhd

However I can't find the function that stoker mentions in this thread:

https://groups.google.com/forum/#!search/NL80211_IFTYPE_ADHOC/spandev/q_K7ELMTnjg/q44GfsCA51IJ

I haven't done any C programming so I'm not sure what I should be
looking for as alternatives

Any thoughts you may have will be very welcome.

-Corey
> --
> You received this message because you are subscribed to the Google Groups "Smart Phone Ad-Hoc Networks" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to spandev+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Jeffrey Robble

unread,
Feb 18, 2013, 6:49:28 PM2/18/13
to spa...@googlegroups.com
If you look here:
https://github.com/CyanogenMod/android_kernel_samsung_espresso10/blob/cm-10.1/drivers/net/wireless/bcmdhd/wl_cfg80211.c

I think you're looking for:
static s32 wl_setup_wiphy(struct wireless_dev *wdev, struct device
*sdiofunc_dev)

And specially need to modify this part:

wdev->wiphy->interface_modes =
BIT(NL80211_IFTYPE_STATION)
#if !(defined(WLP2P) && defined(WL_ENABLE_P2P_IF))
| BIT(NL80211_IFTYPE_MONITOR)
#endif
| BIT(NL80211_IFTYPE_AP);

As such:

wdev->wiphy->interface_modes =
BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_ADHOC)
#if !(defined(WLP2P) && defined(WL_ENABLE_P2P_IF))
| BIT(NL80211_IFTYPE_MONITOR)
#endif
| BIT(NL80211_IFTYPE_AP);

- stoker
Message has been deleted

mala...@gmail.com

unread,
Feb 18, 2013, 7:18:28 PM2/18/13
to spa...@googlegroups.com
Corey,

I'm actually working on the P3113 model but the changes should be very similar. I made that change in the same file that stoker mentioned and will let you know if it's enough to get ad hoc working.

- Mustafa

mala...@gmail.com

unread,
Feb 20, 2013, 12:14:22 PM2/20/13
to spa...@googlegroups.com, mala...@gmail.com
Hey stoker can you post what your myupdate.zip looks like so I can compare? I want to make sure I'm not bricking my device by accident!

Also, did you need to modify the AnyKernal file structure for all of your builds or just the Nexus 7?

Thanks!

mala...@gmail.com

unread,
Feb 20, 2013, 12:17:53 PM2/20/13
to spa...@googlegroups.com, mala...@gmail.com
Nevermind! I found the my-update.zip on the github page.

Jeffrey Robble

unread,
Feb 20, 2013, 12:29:59 PM2/20/13
to spa...@googlegroups.com, mala...@gmail.com
Glad you found it. In general the basic AnyKernel file structure is
the same for different devices. The first thing to note is what's
being done in mkbootimg.sh. Sometimes people use hard-coded values for
the kernel base address. If you use the wrong base adress for your
device you can hard brick it. I did that once and learned my lesson.

Also, note that some of the AnyKernels I've posted have a
myboot.img-ramdisk.gz and others don't. That's because some devices
store kernel modules in the ramdisk (/lib/modules) while others store
them in the system partition (/system/lib/modules).

- stoker

mala...@gmail.com

unread,
Feb 20, 2013, 1:46:03 PM2/20/13
to spa...@googlegroups.com, mala...@gmail.com
I noticed that the Tab 2 has a /system/lib/modules so does that mean I can removed the ramdisk code or should I just leave it in?

Thanks again for all your help. My group can't wait to get their hands on these devices so they can start coding using your MANET code.

mala...@gmail.com

unread,
Feb 20, 2013, 2:01:00 PM2/20/13
to spa...@googlegroups.com, mala...@gmail.com
Ok it looks like the kernal flashed ok but I'm still having trouble getting Ad-Hoc to work.

./iwconfig shows that wlan0 is active

How do I confirm that my changes were actually made? Do you have any debugging steps that might be helpful?

Mustafa Al-Ammar

unread,
Feb 20, 2013, 9:03:13 PM2/20/13
to spa...@googlegroups.com, mala...@gmail.com
Here's my /cache/recovery/last_log file:

-- Installing: /sdcard/myupdate.zip
Finding update package...
I:Update location: /sdcard/myupdate.zip
I:using /data/media for /sdcard/myupdate.zip.
Opening update package...
Installing update...
AnyKernel Updater by Koush.mount: no mtd partition named "system"minzip: Extracted file "/system/lib/modules/ansi_cprng.ko"

minzip: Extracted file "/system/lib/modules/batman-adv.ko"
Extracting System Files...
minzip: Extracted file "/system/lib/modules/cifs.ko"
minzip: Extracted file "/system/lib/modules/dhd.ko"
minzip: Extracted file "/system/lib/modules/scsi_wait_scan.ko"
minzip: Extracted file "/system/lib/modules/tiwlan_drv.ko"
minzip: Extracted file "/system/modules/ansi_cprng.ko"
minzip: Extracted file "/system/modules/batman-adv.ko"
minzip: Extracted file "/system/modules/cifs.ko"
minzip: Extracted file "/system/modules/dhd.ko"
minzip: Extracted file "/system/modules/scsi_wait_scan.ko"
unmount of /system failed; no such volume
Extracting Kernel files...minzip: Extracted file "/tmp/dump_image"

minzip: Extracted file "/tmp/kernel"
minzip: Extracted file "/tmp/mkbootimg"
minzip: Extracted file "/tmp/mkbootimg.sh"
minzip: Extracted file "/tmp/unpackbootimg"
minzip: Extracted file "/tmp/zImage"
Installing kernel...about to run program [/tmp/dump_image] with 3 args
run_program: child exited with status 255
about to run program [/tmp/unpackbootimg] with 3 args
run_program: child terminated by signal 11
about to run program [/tmp/mkbootimg.sh] with 1 args
cat: can't open '/tmp/boot.img-cmdline': No such file or directory
cat: can't open '/tmp/boot.img-base': No such file or directory
Segmentation fault
run_program: child exited with status 139
script result was [Done!]

Done!

Install from sdcard complete.

Jeffrey Robble

unread,
Feb 20, 2013, 9:34:53 PM2/20/13
to spa...@googlegroups.com, mala...@gmail.com
Hi Mustafa,

If the modules are in /system/lib/modules then you don't need to mess
with the ramdisk.

Try to execute the following command:
/data/data/org.span/bin/iwconfig wlan0 mode ad-hoc

What do you get?

If wlan0 goes into ad-hoc mode then I believe you need to update the
following files in the Manet Manager app to support your device.

https://github.com/ProjectSPAN/android-manet-manager/blob/master/AndroidManetManager/src/org/span/service/system/DeviceConfig.java
- You will need to create a static variable for your device. Then
update getDeviceType() to return that variable based on your device's
build model (which is under Settings --> About phone --> Model
number). Then update getWifiInterface() to return the wifi interface
for your device.

https://github.com/ProjectSPAN/android-manet-manager/blob/master/AndroidManetManager/res/raw/adhoc_edify
- Search for "galaxys3gti9300". You probably need to add your device
identifier to the end of the conditional check for that code block. I
assume the Galaxy Tab 2 works like the original.

- stoker

Mustafa Al-Ammar

unread,
Feb 20, 2013, 9:57:20 PM2/20/13
to spa...@googlegroups.com, mala...@gmail.com
The command showed that ad-hoc mode was not available. Can you upload the anykernal folder structure you used? It seems that the one on koush's github page has some syntax errors in the build script near when it's mounting the system directory.

Mustafa Al-Ammar

unread,
Feb 20, 2013, 11:18:23 PM2/20/13
to spa...@googlegroups.com, mala...@gmail.com
I looked at the Nexus 7 AnyKernal structure and script and fixed the mount line to match my device.

My updater-script now looks like this:

ui_print("SPAN Kernel for Galaxy Tab 2 Wifi GT-P3113.");
set_progress(1.000000);
ui_print("");
ui_print("AnyKernel Updater by Koush.");
ui_print("");
ui_print("Installing kernel...");
mount("ext4", "EMMC", "/dev/block/platform/omap/omap_hsmmc.1/by-name/FACTORYFS", "/system");
package_extract_dir("system", "/system");
unmount("/system");
ui_print("Extracting Kernel files...");
package_extract_dir("kernel", "/tmp");
set_perm(0, 0, 0777, "/tmp/dump_image");
set_perm(0, 0, 0777, "/tmp/mkbootimg.sh");
set_perm(0, 0, 0777, "/tmp/mkbootimg");
set_perm(0, 0, 0777, "/tmp/unpackbootimg");
run_program("/tmp/dump_image", "boot", "/tmp/boot.img");
run_program("/tmp/unpackbootimg", "/tmp/boot.img", "/tmp/");
run_program("/tmp/mkbootimg.sh");
write_raw_image("/tmp/newboot.img", "boot");
ui_print("");
ui_print("Done!");

Unfortunately that seems to have disabled the wifi completely. I think this updater script still needs to be modified to run correctly on the Tab 2.

Here is the output of "mount" in adb shell:

/dev/block/platform/omap/omap_hsmmc.1/by-name/FACTORYFS /system ext4 ro,relatime,barrier=1,data=ordered 0 0
/dev/block/platform/omap/omap_hsmmc.1/by-name/DATAFS /data ext4 rw,nosuid,nodev,noatime,barrier=1,data=ordered,noauto_da_alloc,discard 0 0
/dev/block/platform/omap/omap_hsmmc.1/by-name/CACHE /cache ext4 rw,nosuid,nodev,noatime,errors=panic,barrier=1,nomblk_io_submit,data=ordered 0 0
/dev/block/platform/omap/omap_hsmmc.1/by-name/EFS /efs ext4 rw,relatime,barrier=1,data=ordered 0 0

And the output of /cache/recovery/last_log:

SPAN Kernel for Galaxy Tab 2 Wifi GT-P3113

AnyKernel Updater by Koush

Installing kernel..

minzip: Extracted file "/system/modules/ansi_cprng.ko"
minzip: Extracted file "/system/modules/batman-adv.ko"
minzip: Extracted file "/system/modules/cifs.ko"
minzip: Extracted file "/system/modules/dhd.ko"
minzip: Extracted file "/system/modules/scsi_wait_scan.ko"

Extracting Kernel files...

minzip: Extracted file "/tmp/dump_image"
minzip: Extracted file "/tmp/kernel"
minzip: Extracted file "/tmp/mkbootimg"
minzip: Extracted file "/tmp/mkbootimg.sh"
minzip: Extracted file "/tmp/unpackbootimg"
minzip: Extracted file "/tmp/zImage"

about to run program [/tmp/dump_image] with 3 args
run_program: child exited with status 255
about to run program [/tmp/unpackbootimg] with 3 args
run_program: child terminated by signal 11
about to run program [/tmp/mkbootimg.sh] with 1 args
cat: can't open '/tmp/boot.img-cmdline': No such file or directory
cat: can't open '/tmp/boot.img-base': No such file or directory
Segmentation fault
run_program: child exited with status 139
script result was [Done!]

Looks like I'll have to do a little more research on this device and what I need to flash the kernel.

Jeffrey Robble

unread,
Feb 21, 2013, 9:10:01 AM2/21/13
to spa...@googlegroups.com, mala...@gmail.com
Hi Mustafa,

I did not need to put together a custom kernel for the Galaxy Tab 10.1
original. You can find the AnyKernel zips for the other devices here:
https://github.com/monk-dot/SPAN/tree/master/kernels

Specifically, here's my AnyKernel for the Nexus 7:
https://github.com/monk-dot/SPAN/blob/master/kernels/ASUS%20Nexus%207/myupdate-nexus7.zip?raw=true

My updater-script looks as follows:

ui_print("SPAN kernel for Nexus 7");
set_progress(1.000000);
ui_print("");
ui_print("AnyKernel Updater by Koush.");
ui_print("");
ui_print("Installing kernel...");
mount("ext4", "EMMC", "/dev/block/platform/sdhci-tegra.3/by-name/APP",
"/system");
package_extract_dir("system", "/system");
set_perm_recursive(0, 0, 0755, 0755, "/system/etc/init.d");
unmount("/system");
package_extract_dir("kernel", "/tmp");
set_perm(0, 0, 0777, "/tmp/mkbootimg.sh");
set_perm(0, 0, 0777, "/tmp/mkbootimg");
set_perm(0, 0, 0777, "/tmp/unpackbootimg");
set_perm(0, 0, 0777, "/tmp/busybox");
set_perm(0, 0, 0777, "/tmp/unpack_add_init.sh");
run_program("/sbin/busybox", "dd",
"if=/dev/block/platform/sdhci-tegra.3/by-name/LNX",
"of=/tmp/boot.img");
run_program("/tmp/unpackbootimg", "-i", "/tmp/boot.img", "-o", "/tmp/");
run_program("/tmp/mkbootimg.sh");
run_program("/sbin/busybox", "dd", "if=/tmp/newboot.img",
"of=/dev/block/mmcblk0p2");
ui_print("");
ui_print("Done!");

Note that I don't use the "dump_image" program that you're using. That
seems to be your problem. In the end it doesn't seem to find or
extract the boot.img properly. In turn a new boot image can't be
created and your kernel isn't being updated. Try an approach similar
to the one I copy+pasted above.

- stoker

Mustafa Al-Ammar

unread,
Feb 22, 2013, 7:04:53 PM2/22/13
to spa...@googlegroups.com, mala...@gmail.com
Sorry for the late reply (busy week!) but I'll give that a shot.

Correct me if I'm wrong, but that AnyKernal script looks like it's adding busybox to the kernel image.

Can you elaborate on what these lines do?

run_program("/sbin/busybox", "dd", "if=/tmp/newboot.img", 
"of=/dev/block/mmcblk0p2"); 

and

run_program("/sbin/busybox", "dd", 
"if=/dev/block/platform/sdhci-tegra.3/by-name/LNX", 
"of=/tmp/boot.img"); 

- Mustafa

Jeffrey Robble

unread,
Feb 23, 2013, 11:00:28 AM2/23/13
to spa...@googlegroups.com, mala...@gmail.com
Hi Mustafa,

The script is adding busybox to the tmp directory while the device is
in Recovery Mode. The busybox tools will not be available during a
normal boot unless you copy them to the system partition. My script
doesn't do that.

run_program("/sbin/busybox", "dd", "if=/tmp/newboot.img",
"of=/dev/block/mmcblk0p2");

This line uses the dd command to copy the new boot image data (kernel
+ ramdisk) to the proper device partition.

run_program("/sbin/busybox", "dd",
"if=/dev/block/platform/sdhci-tegra.3/by-name/LNX",
"of=/tmp/boot.img");

This line uses the dd command to copy the existing boot image to the
tmp directory.

- stoker

Mustafa Al-Ammar

unread,
Feb 25, 2013, 11:21:30 PM2/25/13
to spa...@googlegroups.com, mala...@gmail.com
Well I think I figured out why I was breaking the wireless and the modification weren't working.

I checked out the cm-10.1 kernel source from the cyanogenmod git repository. Problem is that I installed ics (cm9.1) on the tablet.

:P

Jeffrey Robble

unread,
Feb 26, 2013, 7:37:31 AM2/26/13
to spa...@googlegroups.com, mala...@gmail.com
Ah yes, that could be your problem :)

Mustafa Al-Ammar

unread,
Mar 5, 2013, 8:46:11 PM3/5/13
to spa...@googlegroups.com, mala...@gmail.com
Hi stoker,

I'm making some progress on the custom kernel for the Tab 2 but in the meantime, you mentioned that you did not need a custom kernel for the original  tab 10.1. We happen to have a couple of those around and would like to start developing our application while we get the Tab 2 working.

Can you elaborate on what you meant? Can we just run Manet manager on these devices or do we need to flash one of the provided kernels in the SPAN project?

Thanks,

- Mustafa

Jeffrey Robble

unread,
Mar 5, 2013, 11:05:24 PM3/5/13
to spa...@googlegroups.com
Hi Mustafa,

All you need is root (SuperSU or similar) and the Manet Manager on the
Galaxy Tab 10.1. That's it! No kernel flashing necessary.

- stoker

Mustafa Al-Ammar

unread,
Mar 5, 2013, 11:42:10 PM3/5/13
to spa...@googlegroups.com
That's great to hear! We'll give it a shot tomorrow.
Message has been deleted

Mustafa Al-Ammar

unread,
May 16, 2013, 6:01:50 AM5/16/13
to Eric de Vries, spa...@googlegroups.com

Actually, we eventually did switch to the Tab 10.1s to save time for that exact reason. We also finished writing our app and are now in the testing phase.  I'll eventually integrate our changes (specifically the GPS location addition) into MANET manager itself and share it on Github with everyone.

On May 16, 2013 1:40 AM, "Eric de Vries" <tig...@gmail.com> wrote:

Is that a stock 10.1 ? On which android version does it run ?
Cause if it's "old" stuff (Android 3.1 or 3.2) then that might explain is because then adhoc was supported from Android itself...


Op woensdag 6 maart 2013 02:46:11 UTC+1 schreef Mustafa Al-Ammar het volgende:

Jeffrey Robble

unread,
May 16, 2013, 8:33:10 AM5/16/13
to spa...@googlegroups.com, Eric de Vries
Great! I'm looking forward to your updates.
Reply all
Reply to author
Forward
0 new messages