yashsingh1/xdaforums huggingface dataset:
[Galaxy Note 4 General] gekkehenkie11:
So I think this should work. copy mhi files to hardware/qcom/mhi and mod makefile to look like:

mhidir	= $(prefix)/mhi
KERNEL_FLAGS ?= ARCH=arm CFLAGS_MODULE=-fno-pic CROSS_COMPILE=$(KERNEL_TOOLCHAIN)/$(KERNEL_TOOLCHAIN_PREFIX)
module = mhi.ko
kmake = $(MAKE) $(KERNEL_FLAGS) -C $(KERNEL_OUT) M=$(CURDIR)

$(module):
$(kmake) modules

all-local: $(module)

install-exec-local: $(module)
$(kmake) INSTALL_MOD_PATH=$(DESTDIR)$(prefix)/modules modules_install

# "make distclean" will always run clean-local in this directory,
# regardless of the KERNELMODULES conditional. Therefore, ensure
# KERNEL_DIR exists before running clean. Further, don't fail even
# if there is a problem.
clean-local:
-test ! -d "$(KERNEL_DIR)" || $(kmake) clean

And then add this to the boardconfig:

MHI_MODULE:
make -C hardware/qcom/mhi/
mv hardware/qcom/mhi/mhi.ko $(KERNEL_MODULES_OUT)
TARGET_KERNEL_MODULES := MHI_MODULE

Going to see myself if this works, but it needs to build the whole thing I guess, so will take a while ...
[Galaxy Note 4 General] vogli:
I don't actually see why it has to be that complicated. The module is part of the kernel from Samsung and therefore not out of tree.

Or do I get this completely wrong?
[Galaxy Note 4 General] gekkehenkie11:
You mean it's inside the Samsung kernel tree ?
[Galaxy Note 4 General] fattire:
Sorry-- i'm lost. What is it you're trying to do?

if you're trying to build a regular android module, you just add the name of the module to the device.mk file like this:

PRODUCT_PACKAGES += \
module_name

Built modules should appear in /system/lib/modules. Or, if you're trying to build an external kernel module that's part of the kernel source, just add

CONFIG_THE_MODULE_NAME=m

to the appropriate defconfig in arch/arm/configs in the kernel source.

If you're trying to build a module that is NOT part of the kernel source, use something like this in BoardConfig.mk. (The example comes from the Nook Color, which needs to build its own wifi driver kernel module.)

TARGET_MODULES_SOURCE := "hardware/ti/wlan/mac80211/compat_wl12xx"
wifi_modules:
make -C $(TARGET_MODULES_SOURCE) KERNEL_DIR=$(KERNEL_OUT) KLIB=$(KERNEL_OUT) KLIB_BUILD=$(KERNEL_OUT) ARCH=$(TARGET_ARCH) $(ARM_CROSS_COMPILE)
mv hardware/ti/wlan/mac80211/compat_wl12xx/net/mac80211/mac80211.ko $(KERNEL_MODULES_OUT)
mv hardware/ti/wlan/mac80211/compat_wl12xx/net/wireless/cfg80211.ko $(KERNEL_MODULES_OUT)
mv hardware/ti/wlan/mac80211/compat_wl12xx/drivers/net/wireless/wl12xx/wl12xx.ko $(KERNEL_MODULES_OUT)
mv hardware/ti/wlan/mac80211/compat_wl12xx/drivers/net/wireless/wl12xx/wl12xx_sdio.ko $(KERNEL_MODULES_OUT)
$(ARM_EABI_TOOLCHAIN)/arm-eabi-strip --strip-debug $(KERNEL_MODULES_OUT)/mac80211.ko $(KERNEL_MODULES_OUT)/cfg80211.ko $(KERNEL_MODULES_OUT)/wl12xx.ko $(KERNEL_MODULES_OUT)/wl12xx_sdio.ko
TARGET_KERNEL_MODULES := wifi_modules

(in the above example note that the leading spaces in the description (I think it's called a recipe) of wifi_modules must be TABS.)

If you're trying to copy a PREBUILT kernel module to the device, add to device.mk:

PRODUCT_COPY_FILES += \
device/samsung/trlteintl/modules/themodule.ko:system/lib/modules/themodule.ko

There are other possibilities, but if this is kernel related, I would definitely re-review Integrated Kernel Building at the wiki.
[Galaxy Note 4 General] gekkehenkie11:
Automate mhi.ko building via CM12. I previously build it manually, but it should be auto compiled when somebody buils CM12. mhi is not part of the kernel., so:

That's exactly what I've been doing above :)

But there should still be a makefile in that module directory, correct ? And if so, what should it look like ? Anyway, that's what I did above, I specified what part I thought should be added to the boardconfig (pretty similar to what you did above) and how the makefile should look like IMHO.
[Galaxy Note 4 General] vogli:
I will look at the kernel from Samsung this evening.
[Galaxy Note 4 General] fattire:
Take a look at the ti compat module that nookcolor uses for inspiration... Different module but basically you want to put the steps in the recipe that you used to build from the command line... Right in the boardconfig. Like a little script that the build system should run. Remember to star each line with a tab and don't use absolute path names because you don't know the full name for other users.. (Also look in github to see if anyone has done it already..)
[Galaxy Note 4 General] gekkehenkie11:
So then you're saying there should be no makefile in the module's directory and it should be built using those commands, right into the boardconfig.mk ? Is that what you're saying ?
[Galaxy Note 4 General] fattire:
I don't know the specifics of your module.. I assume there already is a Makefile to build the module, but whatever the steps are you used to build it should be in your recipe...
[Galaxy Note 4 General] gekkehenkie11:
Hmmmm ... Going to try some things then ...
[Galaxy Note 4 General] gekkehenkie11:
Is this even correct ? Shouldn't it state 'CROSS_COMPILE=' before that ARM_CROSS_COMPILE ?
[Galaxy Note 4 General] gekkehenkie11:
This is the original makefile:

mhidir	= $(prefix)/mhi
KERNEL_FLAGS ?= ARCH=arm
module = mhi.ko
kmake = $(MAKE) $(KERNEL_FLAGS) -C $(KERNEL_DIR) M=$(CURDIR)

$(module):
$(kmake) modules

all-local: $(module)

install-exec-local: $(module)
$(kmake) INSTALL_MOD_PATH=$(DESTDIR)$(prefix)/modules modules_install

And there's also an Android.mk, not sure if we need that too ?
[Galaxy Note 4 General] gekkehenkie11:
Got it ! I think it works now, changed that crosscompile line to what I just suggested, I've used the original makefile and it builds now :)
[Galaxy Note 4 General] Preaper:
For anybody experiencing Kernel build errors due to the forbidden "wsizeof-pointer-memaccess" warning.

Change this in the kernel makefile:

KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
-fno-strict-aliasing -fno-common \
-Werror-implicit-function-declaration \
-Wno-format-security \
-fno-delete-null-pointer-checks \
-Wno-sizeof-pointer-memaccess

The change is that I added "-Wno-sizeof-pointer-memaccess" to the build flags. My guess is, is that Samsung has been using an old gcc compiler which was less strict on these messages, while the latest CM toolchain is.
[Galaxy Note 4 General] utopiate:
C:\adb>adb shell

shell@trlte:/ $ fastboot devices

fastboot devices

/system/bin/sh: fastboot: not found

127|shell@trlte:/ $
[Galaxy Note 4 General] gekkehenkie11:
no, fastboot is a dos command, not a shell command, so just type

fastboot devices

directly from your dosprompt, with your note connected
[Galaxy Note 4 General] gekkehenkie11:
BTW, build of CM now breaks with all kinds of errors in surface_test.cpp, gotta go right now but will investigate later ...

What is created thus far:

boot.img

ramdisk.img

ramdisk-recovery.img

recovery.img

system.img

userdata.img

so yes, it has even created a system.img already (containing the whole system directory!), so it seems it's close to a first test boot to me ... Anyway brb
[Galaxy Note 4 General] utopiate:
nothing is returned
[Galaxy Note 4 General] gekkehenkie11:
Ok guys, it seems I've build everything succesfully :D At this point I think it's best to wait and see if I'm receiving my Note 4 tomorrow so I can flash the files myself. I don't want anybody to run the risk of bricking their phone and am really unsure what this file will do so I'd rather try it myself :) I'd be surprised if it would go beyond the bootanimation anyway (but who knows !). If somebody really is desperate to try it out though, accepts all risks and has a CWM recovery installed, send me a PM :)
[Galaxy Note 4 General] kman79:
Stock firmware for backup and recovery?

I had bought the AT&T version of this phone and quicly realized its locked down, so its on ebay right now. I ordered the N910F version of the phone and its suppose to be delivered some time next week. I'll gladly test out the ROM you've cooked up.

With that said, do we have a stock firmware thats flashable in case we screw up our phones? Would like to have it on hand just in case.

Great job with this so far, thanks for putting in your time and effort.
[Galaxy Note 4 General] pbedard:
I actually tested on from irc it was made for tmobile but worked fIne on mine
[Galaxy Note 4 General] emann56:
You tested Cm12 on your Note 4? Screenshots?
[Galaxy Note 4 General] pbedard:
Ill re install it now. N post it
[Galaxy Note 4 General] emann56:
please screenshots bro! and a review !
[Galaxy Note 4 General] jdidtht:
So did it boot or what.
[Galaxy Note 4 General] pbedard:
Second round no
[Galaxy Note 4 General] jdidtht:
Can you share the tmo version you booted before via pm. Curious to try myself. Won't share with anyone.
[Galaxy Note 4 General] gekkehenkie11:
Yeah please drop me a copy too, will surely be helpful in getting my own version up and running !!

Hopefully receiving my Note 4 tomorrow, can't wait to try what I've cooked up :)
[Galaxy Note 4 General] pbedard:
Pm me
[Galaxy Note 4 General] utopiate:
@ gekkehenkie11 ,

hey dude did your note arrive?

and could you answer a noob question for me, would it not be easier to port the nexus 6 rom given the similarities in specs on both devices. lol there is probably a really simple reason that I'm failing to see lol
[Galaxy Note 4 General] gekkehenkie11:
Just called my shipper, they said they didnt unload the container yet, maybe end of the day but it sounds like it's going to be monday :(

Well I already built CM12 it seems ...
[Galaxy Note 4 General] jdidtht:
Can I try to boot it?
[Galaxy Note 4 General] gekkehenkie11:
Just got word from my shipper, my package is ready, going to pick it up now :) And oh yeah, got some PM's from several people saying they want to try it. As I'll have my note 4 in my hands later today I'm going to try first to see what it does before releasing it out to you guys. At this point it seems unlikely it will boot anyway, I think it needs some tweaking and fixing. Will let you guys know soon !
[Galaxy Note 4 General] Charper99:
Thank You!

Thank you so very much gekkehenkie ive been waiting ages for CM11/12 let us know how it turns out . Good luck
[Galaxy Note 4 General] fattire:
Yes! As you can see here, we had to do the same thing to the kernel source itself.
[Galaxy Note 4 General] Preaper:
Wait what? O sweet! I was so confused - I thought i pretty much scrutinised your commit history. Turns out I never switched the branch to CM-12.0.

I'm such a dummy some times.
[Galaxy Note 4 General] gekkehenkie11:
Ok guys, this is how it should be: use original mhi (make)files, put the mhi files in /hardware/qcom/mhi/ and then add this to the boardconfig:

MHI_MODULE:
make -C hardware/qcom/mhi/ CFLAGS_MODULE=-fno-pic KERNEL_DIR=$(KERNEL_OUT) KLIB=$(KERNEL_OUT) KLIB_BUILD=$(KERNEL_OUT) ARCH=$(TARGET_ARCH) $(ARM_CROSS_COMPILE)
mv hardware/qcom/mhi/mhi.ko $(KERNEL_MODULES_OUT)
TARGET_KERNEL_MODULES := MHI_MODULE

Although I haven't tested the resulting mhi.ko, it builds and since it took into account that fno-pic flag, it should be ok. Thanks [MENTION=3041959]fattire[/MENTION] ! :)

*EDIT* tested it, it works ;)
[Galaxy Note 4 General] Preaper:
I'm pretty sure Android.mk is all the android build system uses. All other .mk files are only used if included somehow.

---------- Post added at 09:18 PM ---------- Previous post was at 09:17 PM ----------

I'm using this. :) Thanks.

---------- Post added at 09:30 PM ---------- Previous post was at 09:18 PM ----------

Next step: Figure out how the ramdisk comes to be.
[Galaxy Note 4 General] fattire:
generally speaking, the stuff in $OUT/root gets made, along with the kernel, into the boot.img with mkbootimg, which is flashed into the boot partition.

Format for the boot.img file is described in mkbootimg's header: https://github.com/CyanogenMod/android_system_core/blob/cm-12.0/mkbootimg/bootimg.h#L57

Also see:

http://xdaforums.com/showthread.php?t=1477845
[Galaxy Note 4 General] vogli:
I did a repo sync today and now it completely fails when building Gallery2. Do you guys have the same thing or did I mess something up?

---------- Post added at 10:02 PM ---------- Previous post was at 09:59 PM ----------

I have pushed my version of trltexx and trlte-common to github:

https://github.com/twendt/android_device_samsung_trlte-common.git

https://github.com/twendt/android_device_samsung_trltexx.git
[Galaxy Note 4 General] Preaper:
I'm currently building a new CM build with an integrated environment. The kernel, and trlte device are set up. The mhi.ko module should be automatically compiled and copied to the rom.

If you put this inside .repo/local_manifests/roomservice.xml you should be able to get a glimps of the progress. Besides it contains the links to my various git repos

<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<project name="jaapp/android_kernel_samsung_trlte" path="kernel/samsung/trlte" remote="github" />
<project name="jaapp/android_device_samsung_trlte-common" path="device/samsung/trlte-common" remote="github" />
<project name="jaapp/proprietary_vendor_samsung" path="vendor/samsung" remote="github" />
<project name="jaapp/android_device_samsung_trlte" path="device/samsung/trlte" remote="github" />
<project name="jaapp/android_hardware_qcom_mhi" path="hardware/qcom/mhi" remote="github" />
<project name="CyanogenMod/android_device_qcom_common" path="device/qcom/common" remote="github" />
<project name="CyanogenMod/android_device_samsung_qcom-common" path="device/samsung/qcom-common" remote="github" />
<project name="CyanogenMod/android_hardware_qcom_display" path="hardware/qcom/display-caf/apq8084" remote="github" revision="cm-12.0-caf-8084" />
<project name="CyanogenMod/android_hardware_qcom_audio" path="hardware/qcom/audio-caf/apq8084" remote="github" revision="cm-12.0-caf-8084" />
<project name="CyanogenMod/android_hardware_qcom_media" path="hardware/qcom/media-caf/apq8084" remote="github" revision="cm-12.0-caf-8084" />
</manifest>

Next focus is the ramdisk stuff. Without that automatically set up the mdm_helper won't be started.

---------- Post added at 10:50 PM ---------- Previous post was at 10:29 PM ----------

Is there any reason not to upload all the proprietary blobs onto the git repo? Stuff such as libmodemdetect.so and all the other stuff we extract using the extract-files.sh script.

It would make it so much easier for other people. If it's all up in the repo, a rep sync is enough to get building.
[Galaxy Note 4 General] Preaper:
Ok, this is my cook book to start building your own Cyanogenmod package with the official N910F kernel. It is based on ubuntu 14.04.

If you follow these steps you'll install docker, and create a docker container in which the cyanogenmod toolchain is installed. So it won't 'pollute' your machine.

# install docker
sudo apt-get install docker.io
sudo useradd -G YOUR-LINUX-USERNAME docker
# You might have to log out to apply the above command

# Install the docker CM-build image + run container
git clone https://github.com/jaapp/docker-cyanogenmod.git
cd docker-cyanogenmod

# in order to give non root access to adb. Make sure to replace YOUR-LINUX-USERNAME
# create a file /lib/udev/rules.d/10-adb.rules with the content:
# SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0600", OWNER="YOUR-LINUX-USERNAME"

# run to apply:
sudo service udev restart

# finally we can fire up the container
./run.sh

# You're now in the container. All steps from here on are to be executed from within said container.
# Start by collecting sources

# config git and sync repo
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
repo init -u git://github.com/CyanogenMod/android.git -b cm-12.0

# Put the roomservice.xml in .repo/local_manifests/roomservice.xml then run the next command
repo sync

. build/envsetup.sh

breakfast trlte

# Now we need to copy the blobs from your device.
# Connect your phone to the computer. Start CWM recovery(you cant use Android otherwise you'll have permission problems copy some of the files), mount the /system partition and then do the following:
cd /home/cmbuild/android/device/samsung/trlte
./extract-files.sh
# alternatively you can mount an official ROM somewhere and copy the files from there. Example if you extracted the rom into /home/cmbuild/android/official-rom
# ./extract-files.sh /home/cmbuild/android/official-rom

# You'll get an error that 'libdetectmodem.so' can't be copied. Get a copy of this blob from the shamu firmware or get the one attached to this post
# copy to vendor/samsung/trlte-common/proprietary/lib/libdetectmodem.so

# Now the fun part - build!
# The output of the build is redirected into /home/cmbuild/brunchoutput.txt
croot
brunch trltetmo > /home/cmbuild/brunchoutput.txt 2>&1

# If you want to watch the build taking place, start another screen session (ctrl+a c) and execute:
tail -f /home/cmbuild/brunchoutput.txt

Do mind - the ramdisk stuff isn't in yet. My time is extremely limited the rest of the week so I can't say for sure when I can have that in as well.
[Galaxy Note 4 General] vogli:
Did you find a solution for the libtime_genoff.so?
[Galaxy Note 4 General] vogli:
I did another compile, but still no homescreen. This seems to be the issue:

E/System ( 1840): ******************************************
E/System ( 1840): ************ Failure starting system services
E/System ( 1840): java.lang.NullPointerException: Attempt to invoke virtual method 'void com.android.server.wm.WindowManagerService.showBootMessage(java.lang.CharSequence, boolean)' on a null object reference
E/System ( 1840):	at com.android.server.am.ActivityManagerService.showBootMessage(ActivityManagerService.java:6384)
E/System ( 1840):	at com.android.server.SystemServer.startOtherServices(SystemServer.java:602)
E/System ( 1840):	at com.android.server.SystemServer.run(SystemServer.java:281)
E/System ( 1840):	at com.android.server.SystemServer.main(SystemServer.java:182)
E/System ( 1840):	at java.lang.reflect.Method.invoke(Native Method)
E/System ( 1840):	at java.lang.reflect.Method.invoke(Method.java:372)
E/System ( 1840):	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)
E/System ( 1840):	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
D/AndroidRuntime( 1840): Shutting down VM
E/AndroidRuntime( 1840): *** FATAL EXCEPTION IN SYSTEM PROCESS: main
E/AndroidRuntime( 1840): java.lang.NullPointerException: Attempt to invoke virtual method 'void com.android.server.wm.WindowManagerService.showBootMessage(java.lang.CharSequence, boolean)' on a null object reference
E/AndroidRuntime( 1840):	at com.android.server.am.ActivityManagerService.showBootMessage(ActivityManagerService.java:6384)
E/AndroidRuntime( 1840):	at com.android.server.SystemServer.startOtherServices(SystemServer.java:602)
E/AndroidRuntime( 1840):	at com.android.server.SystemServer.run(SystemServer.java:281)
E/AndroidRuntime( 1840):	at com.android.server.SystemServer.main(SystemServer.java:182)
E/AndroidRuntime( 1840):	at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 1840):	at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime( 1840):	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)
E/AndroidRuntime( 1840):	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
[Galaxy Note 4 General] vogli:
[MENTION=346046]Preaper[/MENTION] You are using the kernel for the 910F, which is a good thing. As we are still using the repo from slayher which is using the kernel sources for the 910F. Unfortunately they had to implement a lot of fixes as the kernel doesn't seem to compile out of the box. This fix here is addressing your issue. I am not sure how we can easily get all the changes from slayher into your repo. Maybe you could try to add slayhers repo as another remote to the git repo and then ckerry pick the commit into your repo.

For the above commit that wold be something like the following:

git remote add slayher https://github.com/slayher/android_kernel_samsung_trlte.git
git fetch slayher
git cherry-pick 29c1efa0b7bc24b4546c828646af33ec3e4838da

EDIT I just tried it and it worked.

---------- Post added at 08:04 AM ---------- Previous post was at 07:41 AM ----------

OK, my error seems to be related to a previous error. I have to flash it again tonight and get the log from the beginning. The error is due to mWindowManager being a null object. So I guess I am missing something related to the display stuff.
[Galaxy Note 4 General] Preaper:
My git repo doesn't share a base with Slayher's repo, since I started it from scratch using the Samsung sources. So I don't know what would happen if I add his as a remote.

The way I've been applying patches is:

wget https://github.com/slayher/android_kernel_samsung_trlte/commit/f3a06f84b203b969e6de346be9a029e710a4017f.patch
git am --signoff < f3a06f84b203b969e6de346be9a029e710a4017f.patch

The trick is that in Github you can access a commit, and add .patch to the url to get a patch file.
[Galaxy Note 4 General] vogli:
The repos don't need a common Base. I tried it with the above patch. I simply extracted the Kernel tar from Samsung and ran git init in it. Then I added the remote and did the cherry pick. In the end it takes a simple patch file and applies it. I prefer doing that on the command line as I can easily correct any conflicts then.
[Galaxy Note 4 General] Preaper:
Ok, cool. Thanks
[Galaxy Note 4 General] gekkehenkie11:
Great seeing you guys work on the repo and git stuff. I guess I need to sit down one day to really dive deep into all that, cause it's still confusing me every now and then. But for now I'll leave that up to you guys :) But just to summarize, if I understood you guys correctly: the directories that we share with trltexxxx should have a common 'base' and update automatically when slayer adds something. And the other patches we should verify by hand if it doesnt break stuff for us ? And then add them manually ? Is that how it works ? Or should we just simply cherry pick all patches ?
[Galaxy Note 4 General] Preaper:
Yes, that is the basic gist of it. Except that no patch of Slayher will automatically appear in my repo. That'll always require a manual merge from my part. Likely though, in the future we'll ask Slayher to merge in our patches and we'll use his repo from then on. At least for the common stuff.
[Galaxy Note 4 General] gekkehenkie11:
To solve it, just add:

vendor/samsung/trlte/proprietary/lib/libtime_genoff.so:vendor/lib/libtime_genoff.so \

to your trlte-vendor-blobs.mk. Of course execute the script to get the blobs again.

*EDIT* since the file exist both on original 910T and 910F and are 100% the same, it would probably be even better to use trlte-common. Besides that, the same problem seems to exist on CM12 910T: http://xdaforums.com/showpost.php?p=57556308&postcount=1037
[Galaxy Note 4 General] vogli:
The thing is that it already is in the list in trlte-common but it has a - in front and therefore does not get copied. It then gets some special handling in another makefile.

---------- Post added at 07:21 PM ---------- Previous post was at 07:20 PM ----------

I will try it tonight by removing the - and see what happens.
[Galaxy Note 4 General] gekkehenkie11:
That should also work (if it's the same file as on original ROM, I cant check now, my virtualbox is compiling but it's in RAM melt down mode, damn, 8 GB system RAM is just not enough to compile, should have brought RAM's)

*EDIT* just checked, compiling aborted, but that file doesn't exist here ...
[Galaxy Note 4 General] Preaper:
I (and [MENTION=3296134]gekkehenkie11[/MENTION] and [MENTION=4748177]vogli[/MENTION] )just received an possible fix for the audio issue via PM from somebody who want to stay anonymous. I don't have the time yet to try it out. Just wanted to give you thread lurkers a heads up.
[Galaxy Note 4 General] lycan_codex:
woohoo..please bring it on! Time to finally ditch touchwhiz!
[Galaxy Note 4 General] shadowsami4:
srsly ? an anonymous dev ^^ okay if it's not a joke please ! Bring it on ! i'd like to use my note 4 without touchiwiz but more with lollipop ! thanks again for your hard work u rocks guys !