[ROM][7.1.2_r36][27Jan2018 LineageOS-14.1] Custom Roms

Status
Not open for further replies.
Search This thread

daniel_hk

Inactive Recognized Contributor
Nov 12, 2012
1,634
5,344
Hong Kong
Realme X2
Nougat ROM and beyond?
It's been almost three months that I started the development of K3-Note, challenging and funny. The last few minor issues are also fixed now. Since all the major issues are fixed, it's time to move on to other devices. I might take another look when I find something or when new Android arrive. ;)
As a promise at the beginning, I built another custom ROM -- SlimRom. With the Lineage's setup, it only took me a hour to prepare and patch the platform. After the ROM was out, I polished a few things. I built the CarbonROM too. I also have DU in my hard drive but DU-team had forbidden releasing in xda earlier. My 1T hard drive is almost full and there is no room for another ROM. If anyone interest in taking over any of these, please let me know and I might guide you through. The requirement is simple -- you need to share your work too. :D

The objective of this project is not releasing a particular ROM. With the solutions to the issues, I hope it would enlighten more people to join our development.
After releasing the kernel, I'm glad there are new kernels come. I was hoping many custom ROM would follow. Sadly, seems Lenovo and Mediatek are not friendly to custom ROM developers. I don't think it's intentional. The changes in the AOSP source by MTK and each manufacturer would likely be the reason. Even if we have the full source, it would probably for LP or MM. Making the proprietary blobs to work for Nougat is not a simple task. I think that's the reason why devices with MTK chips haven't received Nougat updates yet. Most of the manufacturer might be waiting for the update from MTK too.
When I finished the job in hand earlier last month, I decided to try it myself. I already had the Carbon CR-5.1 (Android 7.1.1) source ready so I started with it first. Building it out and made it boot was not too difficult. With a few attempts, my first custom ROM for k3-note was out. Some of the features were not working as expected. RILD not started, no audio and GPS, camera crash, etc... RIL logs are disabled by default so I started fixing the camera which I thought would be easier. That was proved over optimistic soon. My experience told me CM always one step ahead so I downloaded the source when I stated. It's time switching to CM. In a week or two, I finally built a barely presentable ROM. There were questions from a few guys from time to time. All I heard were camera not a problem, audio not a problem, etc... I'm new to K3-note and I just can't imagine how "easy". I don't think I'm that good. I also don't have the patience and experience to try all the blobs. Therefore I upload the test builds for those guys to try. Sadly, up to this moment, no respond yet. :(
Although there is no complete source from Lenovo, other devices might provide something here and there. Fortunately, only a few pieces are required. The source we can found are for LP and for other devices. Make if work for us would be quite a challenge. I finally managed to fix a few things. I seldom release anything that early but there are just so many requests. I don't think I have enough time to make everything work soon. Seeking for other opinions is never a bad move.
I'm now sharing my experiences again. You are welcome to use and share my works. All I asked is "don't keep it to yourself, share yours too!" ;)
If possible, I'll build a few different ROMs later. However, there won't be any weekly or monthly in schedule. This thread is more or less a stepping stone.
At this stage, report is not essential. You don't have to repeat what already mentioned. Thanks!:D
Existing issues:
I. Missing symbols
To deal with missing smybols (usually name space changed in platform upgrade), we may use a shim library and assigned it to LD_PRELOAD at init. GCC doesn't care who provide it. As long as it was loaded, others can access it. The up side is, this way would not touch the original source. The down side is it would be loaded/checked whenever a dlopen() is called. Clearly, it would increase overheads and affect the performance. For our K3-Note, there are also some missing symbols in blobs.
I personally don't like LD_PRELOAD libraries. I would usually add a build flag to Android.mk and add a new file if possible.
**In CM14.1, it already added the build flag BOARD_USES_MTK_HARDWARE in vendor_cm.
Set it to true would define a global flag MTK_HARDWARE.**

The patches are grouped in the device tree. At this moment, there are 4 group of patches:-
1. system_core
1.1 liblog (add the xlog function __xlog_buf_printf() and override the RLOG, see following section)
1.2 libnetutils (required by thermal and RIL). Can use the blob from stock ROM.
2. framework_av
2.1 a file mtkaudio_stubs.cpp was added
2.2 missing CameraParameteres
2.3 add extra profiles to AudioPolicy (2016/12/17)
2.4 fix audio recording in AudioFlinger (2016/12/17)
3. framework_native
3.1 Add a few symbols for backward compatible with MM calls.
4. sepolicy. - not compulsory
Mediatek never takes sepolicy seriously. They use permissive all the time. I planed to use enforcing eventually so I dealt with all the sepolicy from day one.

II. The RIL
Tool: To find out what's wrong, the logs are essential. I had made a patch to liblog. A new property "persist.ril.log" is added. Set it to 1 will push all RLOGs to main.
1. A missing symbol in mtkrild
With this help, I found a missing symbol in mtkrild. This symbol is in libnetutils.so. You may either use the file in stock ROM as a blob or rebuilt it.
2. The ccc_util
During debugging, I noticed there were garbage in the ccc_util logs. A source can be found for mt6595. After disassembled the binary blob, I found a few differences. I rewrote some part and added support for the two new properties. The final sources are grouped in the new project android_hardware_lenovo_aio_otfp
3. Default modem selection
There are two modem binaries in stock ROMs -- 5 (LWG) and 6 (LTG). They are in /system/etc/firware. In stock ROMs, the default modem is read from nvram. For some unknown reason (seems protection issue), ccci_mdinit can't get this value from nvram in custom ROMs. It would use the default value in Kernel (was 6). I noticed LWG was shown in About of stock ROM so I changed the kernel default to 5. Other areas might required this to be 6. Check the Modem in About for your area. If it is LTG, you may either swap the names of the two modems or change the kernel default. I wanted to use a build.prop but turn out that ccci_dminit is a blob from Mediatek. There are only binaries available. No way to add anything.
4. Custom RIL Class
This class is to handle MTK specific modem messages. Usually its for emergency dialling and modem info. It is not handled in AOSP. CM14.1 already taken care of it and that's one of the reason I switched to CM for testing.
A Custom class can be found in CM's device tree for mt6735. I think its too much to handle the emergency number list but don't want to waste time rewriting it. With a few modifications, it can work for us in Nougat. Seems there are unused/unhandled messages. **Need to verify it later.**

III. The Camera
After my first ROM was out, the most eye catching in the log would be the stack corruption in libcam.halsensor.so.
Code:
11-24 21:53:55.967   490   490 F DEBUG   :     #08 pc 00017459  /system/lib/libcam.halsensor.so (_ZN12ImgSensorDrv13getResolutionEPP34ACDK_SENSOR_RESOLUTION_INFO_STRUCT+60)
After study the source for mt6735, I found it was called within the blob libcam.halsensor.so. In the function ImgSensorDrv::getResolution(), an ioctl() call was passed to the kernel. I was thinking it was caused by user space data handling in the kernel. After a series of trials and dumping, I remarked that part of code from the kernel. The crash persisted. That means it was from the blob itself. I tried a shim library to replace the function ImgSensorDrv::getResolution() but the result is the same. That means the callee was responsible.
After some digging, I was pretty sure it was caused by the alignment (address sanitize) of struct addresses. The latest blob from Lenovo dev.1631 (also the latest for mt6752 devices) were built with gcc 4.9 Clang 3.6. Nougat now use Clang 3.8 by default. Those blob already have alignment support in Clang 3.6 might have issues with the new Clang 3.8.
What is address alignment? In short, a 32 bit processor can handle 32 bit at a time. It would be a easier for the register to locate memories in 32 bits (4 bytes) cells (aligned). If the head or tail for a block of memory is not aligned, extra code would required to separately handle those loose ends. The new clang compiler would fill leading bytes with its own algorithm to make the pointer or variable aligned. Why is ImgSensorDrv::getResolution() being "affected"? The argument of it is a pointer to ACDK_SENSOR_RESOLUTION_INFO_STRUCT. Its definition can be found in the kernel. It is a struct of an array of pointers to another struct. The source from Mediatek use direct reference to the address of struct variables all the time. This is inappropriate in sense of address alignment. Early compilers didn't handle alignments and won't have problem with that. Newer compiler would use its own algorithm to align the structs and pointers. I guess Clang 3.6 didn't handle the above complex struct as argument well. Nougat linker and loader are all built with Clang 3.8. Local variables are allocated at load time which might be handled differently. Thus a call to ImgSensorDrv::getResolution() would cause the stack corruption. :eek:
** Those interested may read this article for detail. **
1. Work around
Using older blobs built by gcc 4.8 or earlier might work. Jiayu S3's AOSP were using those old blobs. I'm new to K3-note. I don't think I have the patience and experience to test all the existing blobs. That's the main reason I uploaded the last two test ROM. Trying blobs and hoping some combination would work is passive. Stlport is also obsolete for some time now. I rather deal with the problem directly. :cowboy:
2. The solution
Without the source, building the whole blob is impossible. Even if we have the source from other devices, those custom parameters are unique to each image sensor. It's impossible to guess or back engineer... :(
If we can change the way ImgSensorDrv::getResolution() is being called or didn't touch the argument within the function. It would avoid the crash. Unfortunately, the function need to fill a local struct within the ImgSensorDrv class. That means it is not seen outside ImgSensorDrv. The only way is to replace the whole ImgSensorDrv class. Fortunately, it is self contained. We can write a wrapper to replace the ImgSensorDrv class only. The source from mt6735 or mt6595 are a bit different and obviously can't be used directly. Most of the struct can be cross referenced to the kernel source. There are two local sturct left unknown. One is for the commands sent to the kernel. The other is some info. collected from the kernel.
With the wrapper, the crash was gone but still no preview. I wrote a test HAL to dump the values in stock ROM. Guessing the values against the names was not a decent job. Fortunately, there were only a few differences. After nights of trial and error, I finally pulled everything together. Camera is working now! Video recording is still not working. Seems codec related. Some say it's not a problem "again". Hoping there will be some real solutions and helps soon...
TODO: HDR crashed

IV. GPS
While comparing my log to the stock's, I found all daemons are working properly. It must be the problem of the interface. The java interface of GPS was changed in Nougat. Seems there were transitions from GPS struct to GNSS struct. I accidentally noticed a line in the thousands lines of log.
Code:
gps_mtk : copy_GpsCallbacks_mtk: line = 4124Bad callback, size: 96, expected: 88 or 80
This showed some proof for my guess. After comparing the hardware/gps.h from MM and Nougat, I think the main problem is the difference in callbacks. There were a few ways in my mind. We can change the JNI and handle MTK differently to adopt the old style. Or, use another wrapper to shield the GPS HAL.
The solution
The best way is naturally to rebuild the GPS HAL. The sources I had were outdated. After another intensive search, I found the source for mt6795 from xiaomi and another source for mt6753 from ulefone. They were almost identical and matched all the symbols in the blob from Vibeui 3.5 1631. Their contents were quite standard GPS HAL but a lot had to patch for Nougat. Mediatek already handled some transitions to GNSS which made things a bit easier. The last piece left was the prebuilt libepos. There was no 64 bit library from xioami but there were a few from other devices. Nougat already have the open source curl in extension so everything seemed ready. In a few attempts, I managed to build the new HAL out. I also include Mediatek's apk YGPS for testing. Another reason is the uniqueness of GPS from MTK. Common GPS utilities like GPS Status doesn't work. Anyway, GPS is working now! Cheers! :D
update (2017/2/17): I was using a mt6795 source from github. Turn out that it was already modified. There were something missing. I rewrote the HAL from the official mt6797 source. Now it is fully support GPS, GLONASS and BEIDOU. It is also backward compatible with the AOSP callbacks. Most of the GPS apks (eg. GPS status which was not working in stock MM) would be working now.
update (2017/6/5): For some unknown reason, the country code can not be read from nvram. Thus mnld would use default value which disabled the GLONASS access. I made a patch in post #520. It would generate the file /data/misc/gps/mnl.prop. This is the default property file which never been used. Read the comment inside this file for detail. There are other default settings available. Anyone interested may PM me for detail.

V. Audio recording
After checking with a few test apks, I'm pretty sure the issue was the audio recording solely not Mic. related. Actually, I already fixed it for some time but I didn't know. I was mislead by the pause feature in CM's SoundRecorder apk. That pause feature is unique to CM. MTK's (probably some others) HAL didn't handle it at all. Whenever I pressed the pause, it would call the missing function in HAL and hang. I wrote a test apk myself and found that it worked! I then looked into the source of AOSP. That cleared things up immediately. I don't want to modify CM's apk so I replace it with the one from AOSP.
The solution
The definition of the struct audio_stream_in has changed in Nougat. The function get_capture_position() was added. It's just for reporting the time stamp. The audio HAL blob from MTK didn't have this function. When the input streams were loaded, it would crash. I reinstated the untouched BOARD_USES_LEGACY_MTK_AV_BLOB flag and made a patch in AudioFlinger service. I added the specific header "audio.h" in device tree. Check the source on my github for detal.
One less thing on the list now! Cheers!

VI. MTK Codec
Codecs are essential for recording and playback. Although we can use the software codec from CM or Google for playback, video recording normally required the codec from the manufacturer. That's why I spent a lot of time to make them work first. Samsung and Qcom usually put the codecs in kernel drivers but Mediatek didn't. MTK's codec use the gralloc_ext, ui_ext and gui_ext helper libraries to "assist" the allocations and queries. Unfortunately, platform changes arose some issues in these blobs.
The solution
Naturally, to make it fully support Nougat, we have to rebuild it. I found the sources for mt6797. They are small but have some dependencies. Only minor changes would make them Nougat compliant. Both depend on the dpframework and gralloc.mt6752 which are proprietary. I already rebuilt gralloc_ext from source. Proved to be the right move now. I grouped them into the graphics folder in the hardware_lenovo_aio_otfp project. With these newly built libraries, all codecs are working now. ;)
update (2017/3/18): Found the latest codecs for mt6750t. They work for YouTube, Snapchat, etc. Check the attachment in post #272.
TODO: WVM not handled

VII. Video Recording
For my Samsung devices and Tilapia, I can make the cameraservice work on both camera and camcorder. I don't need the HAL1 flag reverting to the mediaserver. After fixing the extra allocation libraries for my K3-note, I could record the video to a mp4 file. Audio was normal but video wasn't. I had studied for a while. I thought it was colour format related but I don't know why yet. There would be too much changes to the original source so I decided to put aside first.
The solution
Although it's not my wish, I compromised. Everything went well when I use the HAL1 flag switching back to mediaserver. It's time to move on to the WifiHAL now. Would return to this part later. Anyway, it's kinda fixed now! ;)
TODO: Reinstate Cameraserver

VIII. WifiHAL for Nougat
WifiHAL has been introduced for a few generations. It provides another way to access the WiFi in the frameworks. MediaTek's WifiHAL was clearly derived from Broadcom's source. LP and MM only used a small portion of the callbacks. Nougat uses a few more and some of them haven't supported in the kernel driver yet. I used a patched Brodcom's WifiHAL in my earlier builds. It could only be loaded to pass the check. Things like hotspot, 5G, hidden ssid, etc. were not handled. I then ported the sources from mt6795 and mt6797 to my early WiFiHAL. It took me a few days to handle most of the Wifi commands and queries. Together with the minor patch in netd, hotspot is working. An immediate issue arose -- WiFi wouldn't auto reconnect. It required to turn on manually. Hidden ssid was still not working. When a network was manually added, Wifi would fail to scan for APs. Clearly it was another major problem I overlooked... :(
A long road to the solution
I enabled the logs in all the relevant java and c files. Nothing seemed special pop up. I then added my own extra logs. An odd scenario appeared on the channel list. I traced back to the callee in libwifi-service. It was a query message for the available channel lists for 2.4G, 5G and 5G DFS bands. However, the lists to all bands were the same. There were 3 channels all started with 2412 (which is the 1st channel of 2.4G band). The default log in GetChannelListCommand only dump the first entry so I add a for loop to dump all. I got 2412,2413 and 2414! That was definitely impossible. I realized there must be something wrong with this vendor data. Clearly the firmware and proprietary blobs won't be the problem. There were also nothing similar in the nvram. I then traced back to its source -- the kernel driver. Following the defconfig and Makefiles, I found the handler for this message in drivers/misc/mediatek/connectivity/conn_soc/drv_wlan/mt_wifi/wlan/os/linux/gl_cfg80211.c.
Looking at the function mtk_cfg80211_vendor_get_channel_list() made me cry and laugh...
Code:
	kalMemZero(channels, sizeof(wifi_channel) * 4);
	/*rStatus = kalIoctl(prGlueInfo,
	   wlanoidQueryStatistics,
	   &channel,
	   sizeof(channel),
	   TRUE,
	   TRUE,
	   TRUE,
	   FALSE,
	   &u4BufLen); */

	/* only for test */
	num_channel = 3;
	channels[0] = 2412;
	channels[1] = 2413;
	channels[2] = 2414;
	NLA_PUT_U32(skb, GSCAN_ATTRIBUTE_NUM_CHANNELS, num_channel);
	NLA_PUT(skb, GSCAN_ATTRIBUTE_CHANNEL_LIST, (sizeof(wifi_channel) * num_channel), channels);
It was clearly not handled! I found similar codes among all mt67xx and mt65xx devices. The latest MTK's 3.18 kernel, however, paid back. The codes seemed promising. Only minor adjustments were required but this time I got nothing...:eek: I then dumped all the arguments and results after each function calls. Things were clear instantly. Platform used band 1,2,4 for 2.4G, 5G and 5G DFS respectively but MTK use 0 for 2.4G which was also different from its own enum definition (which is similar to the platform). I believed they didn't test it in 3.18 too! I used the parameter band directly. Then simplified the code to have both 2.4G and 5G sharing the same call. After that the channels were reported correctly to the platform. As a bonus, I found the part handled 5G which was disabled by default. I enabled it in the kernel now. As expected, both 2.4G and 5G channels are reported correctly now. After this fix, WiFi can now auto reconnect. To avoid further land mines, I checked all the WiFi commands in the WifiHAL. Turn out that only a handful was actually handled in the kernel. Most of the useless codes are removed and the rest are properly handled now. It took me over a week! The WifiHAL turn out to be a big chapter!
The next and more annoyed issue was Hidden SSID. I'm pretty sure the WifiHAL was OK so I looked into the vendor lib lib_driver_cmd_mt66xx. Enabled a few MTK flags and started with a very limited code all resulted the same. Finally, the following line in log caught my attention:
Code:
 E wpa_supplicant: wlan0: nl80211: Scan trigger failed: ret=-22 (Invalid argument)
A block of similar lines show repeatedly when a network was manually added. I believed wrong arguments were sent to wpa_supplicant. I downloaded the full wpa_supplicant manual and redirected the wpa_supplicants commands to the console. Nothing seemed special but I noticed there was an empty entry being pushed to the argument list. The error only occured when the added SSID appeared. With the empty entry, the arguments were one less. Even if its MTK's problem, wpa_supplicant should take care that. I saw a potential problem and I decided to add a check first. It really really paid back! That's the reason why hidden ssid not working! After two sweaty weeks of work, I would said WiFi is fully working now.... ;)
update (2017/6/22): p2p and WiFi-display is working.

VIII. FM radio
update (2017/2/27): After taking another look, I found that the FM radio was already fixed. Probably after the audio recording fix. So everything is more or less working now. Cheers! :D

Credits:
- With no doublt the LineageOS community should have most of the credits
- The CarbonROM, OmniROM, SlimROM and many other custom ROM teams who bring us the alternatives.
- Those who release the sources for MTK devices.
- And finally Lenovo who had released a castrated kernel source which motivate us to DIY.

Sources: https://github.com/danielhk

Download: AFH LineageOS, AFH SlimRoms, AFH CarbonROM
(百度网盘)LineageOS , (百度网盘)SlimRoms, (百度网盘)CarbonROM
My version of TWRP-3.1.1

Installation:

** backup your current /boot, /data and /system partition first **
TWRP 3.0.x is the only recovery tested. There are many TWRP using different device names out there. I already included a few but there would be more. If you got error (6) at flashing, you may change the line in updater-script or use different TWRP.
1. Do a factory reset (wipe /data and /cache)
2. Flash the ROM
3. Flash the Gapps
4. Flash latest SuperSU
Step 1. is essential if you are from other ROMs, otherwise you might get ERROR:7.
Reboot and hoping its not a night mare... :D
** Note: you don't need to wipe other partitions. Some important device specific data are in nvram and misc. **
Change Log:
Code:
[COLOR="Blue"][B]2018/1/27 - LineageOS-14.1[/B][/COLOR]
[INDENT]- The latest LineageOS-14.1 source, Android-7.1.2_r36 (NJH47F)
- Security patch Dec. 5,2017
- Kernel: New Bluetooth driver
- Bluetooth HAL build from source
- Adjust some Heap and VM settings[/INDENT]
[COLOR="Blue"][B]2018/1/2 - [COLOR="Black"]CarbonRom[/COLOR] CR-5.1[/B][/COLOR]
[INDENT]- The latest Carbon CR-5.1 source, Android-7.1.2_r36 (NJH47F??)
- Kernel: a few minor patches
- Fix Hotspot issue in the last build[/INDENT]
[B]2017/12/29 - [COLOR="Black"]CarbonRom[/COLOR] CR-5.1[/B][/COLOR]
[INDENT]- The latest Carbon CR-5.1 source, Android-7.1.2_r36 (NJH47F??)
- Cumulated patches from my previous Lineage-15.1 builds
- Kernel: a few drivers update
- Adjust some Heap and VM settings
- Security patch Dec. 5, 2017[/INDENT]
[COLOR="Blue"][B]2017/12/16 - LineageOS-14.1[/B][/COLOR]
[INDENT]- The latest LineageOS-14.1 source, Android-7.1.2_r36 (NJH47F)
- Security patch Dec. 5,2017[/INDENT]
[COLOR="Blue"][B]2017/12/3 - LineageOS-14.1[/B][/COLOR]
[INDENT]- The latest LineageOS-14.1 source, Android-7.1.2_r29 (NJH47F)
- Update SELinux rules[/INDENT]
[COLOR="Blue"][B]2017/10/31 - LineageOS-14.1[/B][/COLOR]
[INDENT]- The latest LineageOS-14.1 source, Android-7.1.2_r29 (NJH47F)
- Fix Sim settings crash
- Kernel: binder update[/INDENT]
[COLOR="Blue"][B]2017/10/15 - [COLOR="Black"]CarbonRom[/COLOR] CR-5.1[/B][/COLOR]
[INDENT]- The latest Carbon CR-5.1 source, Android-7.1.2_r29 (NJH47F)
- Kernel: binder update[/INDENT]
[COLOR="Blue"][B]2017/10/1 - LineageOS-14.1[/B][/COLOR]
[INDENT]- The latest LineageOS-14.1 source, Android-7.1.2_r29 (NJH47F)
- Fix PicoTTS from Lineage
- Security patch Aug. 5,2017[/INDENT]
[COLOR="Blue"][B]2017/9/9 - [COLOR="Black"]CarbonRom[/COLOR] CR-5.1[/B][/COLOR]
[INDENT]- The latest Carbon CR-5.1 source, Android-7.1.2_r29 (NJH47F)
- Security patch Aug. 5,2017[/INDENT]
[COLOR="Blue"][B]2017/8/20 - LineageOS-14.1[/B][/COLOR]
[INDENT]- The latest LineageOS-14.1 source, Android-7.1.2_r29 (NJH47F)
- Clean up unused RIL daemon and services
- Security patch Aug. 5,2017[/INDENT]
[COLOR="Blue"][B]2017/8/13 - [COLOR="Black"]CarbonRom[/COLOR] CR-5.1[/B][/COLOR]
[INDENT]- The latest Carbon CR-5.1 source, Android-7.1.2_r29 (NJH47F)
- Clean up unused RIL daemon and services
- Settings: Enable the Ambient Display switch
- Security patch Aug. 5,2017[/INDENT]
[COLOR="Blue"][B]2017/7/29 - LineageOS-14.1[/B][/COLOR]
[INDENT]- The latest LineageOS-14.1 source, Android-7.1.2_r24 (NJH47D)
- Kernel: a few minor patches (mainly for O ready)
- Settings: Enable the Ambient Display switch
- Security patch July 5,2017[/INDENT]
[COLOR="Blue"][B]2017/7/21 - [COLOR="Black"]CarbonRom[/COLOR] CR-5.1[/B][/COLOR]
[INDENT]- The latest Carbon CR-5.1 source, Android-7.1.2_r24 (NJH47D)
- Security patch July 5,2017[/INDENT]
[COLOR="Blue"][B]2017/7/2 - LineageOS-14.1[/B][/COLOR]
[INDENT]- The latest LineageOS-14.1 source, Android-7.1.2_r17 (NJH47B)
- With all patches from the last Carbon.
- AudioFX is removed. Seems useless now.
- PerformanceControl: With Arabic translation from @ziad shawki 
- PerformanceControl: Improve the battery interface to report the battery voltage from MTK devices
- Kernel: fix a bug in Lenovo's code.
- Kernel: Further simplify the code in the touchscreen driver.[/INDENT]
[COLOR="Blue"][B]2017/6/29 - [COLOR="Black"]CarbonRom[/COLOR] CR-5.1[/B][/COLOR]
[INDENT]- The latest Carbon CR-5.1 source, Android-7.1.2_r17 (NJH47B)
- Kernel: enable native gesture support
- Kernel: new touchscreen interface for gesture
- Kernel: enter pocket mode when gesture wakeup enabled
- PerformanceControl: upgrade to version 2.1.7
- PerformanceControl: New MediaTek settings with Slide and Gesture O and V handler
- PerformanceControl: fix a bug in drawer
- PerformanceControl: Filter out unnecessary system apps in Freezer[/INDENT]
[COLOR="Blue"][B]2017/6/20 - Kernel update[/B][/COLOR]
[INDENT]- Touchscreen: driver patch and clean up
- enable native gesture support
- enable native DT2W support, add double tap Home key to wakeup
- Enter low power mode at suspend
- pocket mode automatically enabled in native driver[/INDENT]
[COLOR="Blue"][B]2017/6/16 - LineageOS-14.1[/B][/COLOR]
[INDENT]- The latest LineageOS-14.1 source, Android-7.1.2_r17 (NJH47B)
- all patches/fixes from CR-5.1 are included
- Security patch June 5,2017[/INDENT]
[COLOR="Blue"][B]2017/6/14 - [COLOR="Black"]CarbonRom[/COLOR] CR-5.1[/B][/COLOR]
[INDENT]- The latest Carbon CR-5.1 source, Android-7.1.2_r17 (NJH47B)
- Rewrite fstab 
- Kernel: patches to a few drivers
- Bug fixes in CarbonFibers
- Security patch June 5,2017[/INDENT]
[COLOR="Blue"][B]2017/6/2 - [COLOR="Black"]CarbonRom[/COLOR] CR-5.1[/B][/COLOR]
[INDENT]- The latest Carbon CR-5.1 source, Android-7.1.2_r8 (N2G47O)
- Default Carbon Browser
- Bug fixes in CarbonFibers
- Security patch May 5,2017[/INDENT]
[COLOR="Blue"][B]2017/5/3 - [COLOR="Black"]CarbonRom[/COLOR] CR-5.1[/B][/COLOR]
[INDENT]- The latest Carbon CR-5.1 source, Android-7.1.2_r8 (N2G47O)
- Fixes from latest LOS-14.1
- codec update
- Fix longpress and doubletap behaviour of nav buttons[/INDENT]
[COLOR="Blue"][B]2017/4/30 - LineageOS-14.1[/B][/COLOR]
[INDENT]- The latest LineageOS-14.1 source, Android-7.1.2_r2 (N2G47E)
- kernel: default at 1.8G now
- New HDR approach[/INDENT]
[COLOR="Blue"][B]2017/4/12 - AOSP-7.1.2_r6[/B][/COLOR]
[INDENT]- The Android-7.1.2_r6 (NHG47K) source
- All fixes from previous builds
- PerformanceControl is included
- Equipped with the O/C kernel, default at 1.8G now
- Fix the Camera crash in 7.1.2
[COLOR="Red"][B]***  see [URL="https://xdaforums.com/showpost.php?p=71828345&postcount=330"]post #330[/URL] for how to install and download link ***[/B][/COLOR][/INDENT]
[COLOR="Blue"][B]2017/4/8 - LineageOS 14.1[/B][/COLOR]
[INDENT]- The latest LineageOS-14.1 source, Android-7.1.1_r25 (NOF27B)
- All fixes from previous builds
- Workaround for HDR. Don't know if its better but faster than stock algorithm
- Equipped with the O/C kernel
- PerformanceControl is included
- Update codecs
- Include App Switch (Recent) in button settings.[/INDENT]
[COLOR="Blue"][B]2017/3/30 - [COLOR="Black"]CarbonRom[/COLOR] CR-5.1[/B][/COLOR]
[INDENT]- The latest Carbon CR-5.1 source, Android-7.1.1_r25 (NOF27B)
- All fixes from previous builds
- patches to adapt the new Carbon build scripts.
- Fix the flashlight while taking picture
- Fix the custom key definition for menu key.
- The O/C kernel is equipped[/INDENT]
[COLOR="Blue"][B]2017/3/19 Kernel update, see [URL="https://xdaforums.com/showpost.php?p=71490161&postcount=275"]post#275[/URL] [/B][/COLOR] for detail and download link.
[INDENT]- O/C for CPU upto 2GHz (Adjustable with PerformanceControl and other kernel tools)
- Voltage table control (Adjustable with PerformanceControl and other kernel tools)
[COLOR="Red"]*** The default values are already optimized for the PLL and power chip.
Don't mess with them if you don't know how. I already set the upper and lower limits.
Should there be any damage caused, it would be at your own risk ***[/COLOR]
- OC for GPU upto 819MHz.
- Work for most (hoping all, including stock) Roms with the VibeUI dev. 1631(and s433) blobs.[/INDENT]
[COLOR="Blue"][B]2017/3/18 Codec update, see [URL="https://xdaforums.com/showpost.php?p=71476388&postcount=272"]post#272[/URL] [/B][/COLOR] and download link.
[INDENT]- Fix YouTube zooming issue
- Fix SnapChat recording.[/INDENT]
[COLOR="Blue"][B]2017/3/12 - [COLOR="Navyblue"]SlimRoms[/COLOR] build 0.15[/B][/COLOR]
[INDENT]- The latest SlimRom 0.15 source, Android-7.1.1_r26 (NOF27C)
- All patches/fixes in my 20170312 LineageOS-14.1
- Add long press AppSwitch (Recent) key for menu[/INDENT]
[COLOR="Blue"][B]2017/3/12 - LineageOS 14.1[/B][/COLOR]
[INDENT]- The latest LineageOS-14.1 source, Android-7.1.1_r25 (NOF27B)
- The latest GPS HAL from CarbonROM
- FMRadio: Fixed
- Media Profiles: update to support common video formats.
- Limit background processes to increase available RAM
- Camera app: replaced with Snap by Lineage
- [COLOR="Red"]Lineage is not ROOTED[/COLOR] by default now[/INDENT]
[COLOR="Blue"][B]2017/2/18 - [COLOR="Black"]CarbonRom[/COLOR] CR-5.1[/B][/COLOR]
[INDENT]- The latest Carbon CR-5.1 source, Android-7.1.1_r21 (NOF26W)
- Initial beta release
- New GPS HAL (fully working and faster)
- Add long press AppSwitch (Recent) key for menu
- All fixes from LineageOS-14.1[/INDENT]
[COLOR="Blue"][B]2017/2/14 - [COLOR="Navyblue"]SlimRoms[/COLOR] build 0.11[/B][/COLOR]
[INDENT]- The latest SlimRom 0.11 source, Android-7.1.1_r21 (NOF26W)
- Initial alpha test build 0.11
- All fixes from LineageOS-14.1
- Add prebuilt Chromium (from CarbonROM)[/INDENT]
[COLOR="Blue"][B]2017/2/14 - LineageOS 14.1[/B][/COLOR]
[INDENT]- The latest LineageOS-14.1 source, Android-7.1.1_r9 (NMF26V)
- Libstagefright: Add fixes to media streaming (Don't know if it work or not)
- LiveDisplay: Add support and settings
- RIL: Handle a few more MTK specific messages (WIP)
- GPS: Add backwards support for MM and earlier
- GPS: Fill up the extra fields in GNSS struct
- GPS: Add a override property to select GPS mode (GNSS/GPS) (Testing only)
- Fixed Power off charging screen
- kpoc_charger: keep the stock images (which are in the LOGO partition)
- Fixed LED notifications
- liblight: Rewrite the lights HAL for better support in Nougats and beyond (WIP)
- liblight: Add dual color support (WIP) [/INDENT]
[COLOR="Blue"][B]2017/1/17 - LineageOS 14.1[/B][/COLOR]
[INDENT]- The latest LineageOS-14.1 source, Android-7.1.1_r9 (NMF26V)
- RIL: Add a fix in custom RIL class (thx. @Moyster for the tip), don't know if it helps.
- hostap: build from source
- netd: a minor patch (wlan0 to ap0) for hotspot
- WifiHAL: Rewrite a new one (almost from scratch...)
- WifiHAL: Handle extra callbacks for Nougat
- Kernel: Handle the mtk_cfg80211_vendor_get_channel_list() correctly
- Kernel: Enabled 5G by default
- wpa_supplicant: Fix a potential bug (which fixed MTK's hidden SSID issue)[/INDENT]
[COLOR="Blue"][B]2017/1/5 - LineageOS 14.1[/B][/COLOR]
[INDENT]- The latest LineageOS-14.1 source, Android-7.1.1_r6 (NMF26Q)
- RIL: use the full set of blobs from S433 (newer than dev. 1631)
- MTKCodec: Fix the storage issue in MTK Codec
- MTKCodec: Include the complete set of MTK codec in dev. 1631
- media_profiles.xml: Include the vorbis decoder
- libion: Rebuilt with open source libion
- VideoRecording: Fix video recording
- SEPolicy: update for codec and media server
- kpoc_charger: rebuilt kpoc_charger from source [WIP][/INDENT]
[COLOR="Blue"][B]2016/12/17 - CM14.1[/B][/COLOR]
[INDENT]- The latest CM-14.1 source, Android-7.1.1_r6 (NMF26Q)
- Camera: Fix the flashlight in taking picture
- AudioRecording:Fix audio recording
- SoundRecorder: Replaced with the one from AOSP
- SEPolicy: update for 7.1.1_r6
- media_profiles.xml: Rewrote with the values in stock log
- AudioPolicy: Add extra profiles
- OMX: Fix the crash of nativeHandle in video recording (WIP)
- libhealthd: fix a few things (WIP)
- WifiHAL: Rewrote a new one for Nougat (WIP)[/INDENT]
[COLOR="Blue"][B]2016/12/11 - CM14.1[/B][/COLOR]
[INDENT]- The latest CM-14.1 source, Android-7.1.1_r4 (NMF26O)
- init.mt6752.rc: A few patches
- gps.mt6752.so: Rebuilt the GPS HAL from source
- libcurl.so: Use opensource curl
- YGPS: Include MTK's test apk for GPS
- SEPolicy: Further patches
- Built-in VPN is working now
- healthd: Add standard charging routines to (WIP)[/INDENT]
[COLOR="Blue"][B]2016/12/6 - CM14.1[/B][/COLOR]
[INDENT]- The latest DC-MTK kernel
- Kernel: Enable UID CPU time
- Kernel: Emulate the hardware random sysfs
- Kernel: Treat all A/C chargers the same (same charging current and limits)
- Kernel: rename led sysfs to AOSP defaults
- Kernel: set default modem to 5
- Handle all extra SEPolicy
- Fix the audio output
- Add the RLOG override and xlog suppress properties
- Fix RIL and mobile data
- Fix all sensors
- Add libhealthd.mt6752 to report battery status
- Fix the camera[/INDENT]

Known Issues:
Code:
 - may be more...
Donations:

2m8C9z7xQ5_src.png

show.htm


XDA:DevDB Information
Nougat and beyond?, ROM for the Lenovo K3 Note

Contributors
daniel_hk
Source Code: https://github.com/danielhk

ROM OS Version: 7.x Nougat
ROM Kernel: Linux 3.10.x
Based On: AOSP, LineageOS, SlimRoms, CarbonROM

Version Information
Status: Stable
Stable Release Date: 2017-06-14
Beta Release Date: 2017-06-03

Created 2016-12-05
Last Updated 2018-01-27
 
Last edited:
F

Flypast

Guest
Never bear more than one kind of trouble at a time. Some people bear three kinds of trouble - the ones they've had, the ones they have, and the ones they expect to have.

- Everett Hale
I might just know who that person is...
Cheers mate :)
 
Last edited:

agdroubi

Senior Member
Dec 14, 2010
273
101
Beirut
Maybe you can ask Jiayu S3 developers to provide you with the source code, as they have nougat 7.1.1 already with everything working. Jiayu S3 is very similar to our device's hardware with MT6752 chipset.
Thanks for your hard work.
 

Dead-Shot

Member
Dec 12, 2016
18
8
Thanks for the effort . I am able to use jio4gvoice in this ROM mic is accessible and Gapps are also working fine, but as described in issue section wifi tethering , video recording is not working I tried so many apps but no success and also battery is draining fast so Best of luck for next release
 

SID_BAN

Member
Mar 24, 2016
34
2
not working

sir,
i have lenovo k3 note k50a40, india version, at first have installed miui 8 rom from gooddeath version 6.11.24, and was working fine with rom version 5.0.1 blispop, but i wanted to upgrade so i tried urs but it is not working i have downloaded ur last 11 dec file with 400mb approx and have installed twrp 3.0.2.7 with SuperSU v2.78 SR5, but ur rom is not installing the error says "e3004:THIS PACKAGE IS FOR DEVICE :K50-T5.AIO_M,K3NOTE;THIS DEVICE IS AIO_O.FP"
ERROR 7 , SO PLEASE HELP AND I HAVE ALSO TRIED TO INSTALL GAPPS FROM OPENGAPPS NANO FILE IT GENERATES ERROR TOO WITH "INCOMPATIBLE ROM DETECTED, THIS GAPS IS FOR 7.1.X ONLY BUT THIS IS 5.1.1 SDK 22" SO PLS HELP....
 

ezhome2046

Senior Member
Dec 10, 2015
123
14
use other twrp ver to try.

---------- Post added at 11:39 AM ---------- Previous post was at 11:37 AM ----------

twrp 3.0.0-2 couco92 maybe work for you. any idea broda
 

daniel_hk

Inactive Recognized Contributor
Nov 12, 2012
1,634
5,344
Hong Kong
Realme X2
sir,
i have lenovo k3 note k50a40, india version, at first have installed miui 8 rom from gooddeath version 6.11.24, and was working fine with rom version 5.0.1 blispop, but i wanted to upgrade so i tried urs but it is not working i have downloaded ur last 11 dec file with 400mb approx and have installed twrp 3.0.2.7 with SuperSU v2.78 SR5, but ur rom is not installing the error says "e3004:THIS PACKAGE IS FOR DEVICE :K50-T5.AIO_M,K3NOTE;THIS DEVICE IS AIO_O.FP"
ERROR 7 , SO PLEASE HELP AND I HAVE ALSO TRIED TO INSTALL GAPPS FROM OPENGAPPS NANO FILE IT GENERATES ERROR TOO WITH "INCOMPATIBLE ROM DETECTED, THIS GAPS IS FOR 7.1.X ONLY BUT THIS IS 5.1.1 SDK 22" SO PLS HELP....

use other twrp ver to try.

---------- Post added at 11:39 AM ---------- Previous post was at 11:37 AM ----------

twrp 3.0.0-2 couco92 maybe work for you. any idea broda

There are just too many versions of TWRP and each carry different device names. Of course, it's up to the builders' will. But, I think the stock recovery's device name would be the best compromise for everyone. It would also work for official updates. I hope most of the fellow developers would accept and make the life of everyone easier. ;)

For the time being, you have to edit the updater-script manually or use another TWRP....

The new CM-14.1 Android-7.1.1_r6 is out now.
Audio recording is fixed in this build. Cheers!
 

ziad shawki

Senior Member
Dec 11, 2016
76
20
alexandria
Plz help me iam a7000 plus user when I flash the modem my sim can't be detected but i can receive calls but I can't make calls plz reply
Thank you for your work you are amazing
 

daniel_hk

Inactive Recognized Contributor
Nov 12, 2012
1,634
5,344
Hong Kong
Realme X2
Plz help me iam a7000 plus user when I flash the modem my sim can't be detected but i can receive calls but I can't make calls plz reply
Thank you for your work you are amazing

This is the 2nd time I saw your post. I seldom ignore anyone but I honestly don't know what you meant. I was thinking someone wiser would know and answer you.

You flash the modem? I never mention any modem in my entire thread. What modem?

You don't need the correct grammar or even nice words. If you want help, please help others understand first. Having problem is frustrated but you need to list the detail so that anyone might help. A few word normally won't tell your story. You need to slow down and have some patience to describe your situation in detail first.

At least you have to tell.
1. Where are you? If you are not in my area, it's out of my reach. Hoping someone in your region might help.
2.. What else have you flashed or installed? It would let someone in your region to understand your problem clearer.

This would be my final answer. No one would have time and patience to ask again and again. You ask for help, it's your basic responsibility to provide the detail. Otherwise, you left others no choice but ignore you. ;)
Good luck.
 
  • Like
Reactions: emptywordsss

ziad shawki

Senior Member
Dec 11, 2016
76
20
alexandria
Hi daniel_hk

Lenovo a7000 plus have another baseband version from k3 note so there's a modem patch zip that make lenovo k3 note custom ROMs works on lenovo a7000 plus and to make the SIM card detected but when I flashed with your ROM i get SIM card not detected but I can receive calls and massages only but i can't make calls so can you make a fix for that
Thank you for reply
By the way I am from Egypt :laugh:
 

ezhome2046

Senior Member
Dec 10, 2015
123
14
hello daniel_hk ,
does internet video/audio call for whatsapp work?
hows the battery backup?
can work for ext access read/write?
thank you for your hardwork, itwill be the great if all bugs free.
is it port from Jiayu S3
 

selfisher

Senior Member
Sep 29, 2015
61
12
You're doing such a great job with this rom! Thank you so much, really apreciate your effort and keep it up!
 
Status
Not open for further replies.

Top Liked Posts

  • There are no posts matching your filters.
  • 78
    Nougat ROM and beyond?
    It's been almost three months that I started the development of K3-Note, challenging and funny. The last few minor issues are also fixed now. Since all the major issues are fixed, it's time to move on to other devices. I might take another look when I find something or when new Android arrive. ;)
    As a promise at the beginning, I built another custom ROM -- SlimRom. With the Lineage's setup, it only took me a hour to prepare and patch the platform. After the ROM was out, I polished a few things. I built the CarbonROM too. I also have DU in my hard drive but DU-team had forbidden releasing in xda earlier. My 1T hard drive is almost full and there is no room for another ROM. If anyone interest in taking over any of these, please let me know and I might guide you through. The requirement is simple -- you need to share your work too. :D

    The objective of this project is not releasing a particular ROM. With the solutions to the issues, I hope it would enlighten more people to join our development.
    After releasing the kernel, I'm glad there are new kernels come. I was hoping many custom ROM would follow. Sadly, seems Lenovo and Mediatek are not friendly to custom ROM developers. I don't think it's intentional. The changes in the AOSP source by MTK and each manufacturer would likely be the reason. Even if we have the full source, it would probably for LP or MM. Making the proprietary blobs to work for Nougat is not a simple task. I think that's the reason why devices with MTK chips haven't received Nougat updates yet. Most of the manufacturer might be waiting for the update from MTK too.
    When I finished the job in hand earlier last month, I decided to try it myself. I already had the Carbon CR-5.1 (Android 7.1.1) source ready so I started with it first. Building it out and made it boot was not too difficult. With a few attempts, my first custom ROM for k3-note was out. Some of the features were not working as expected. RILD not started, no audio and GPS, camera crash, etc... RIL logs are disabled by default so I started fixing the camera which I thought would be easier. That was proved over optimistic soon. My experience told me CM always one step ahead so I downloaded the source when I stated. It's time switching to CM. In a week or two, I finally built a barely presentable ROM. There were questions from a few guys from time to time. All I heard were camera not a problem, audio not a problem, etc... I'm new to K3-note and I just can't imagine how "easy". I don't think I'm that good. I also don't have the patience and experience to try all the blobs. Therefore I upload the test builds for those guys to try. Sadly, up to this moment, no respond yet. :(
    Although there is no complete source from Lenovo, other devices might provide something here and there. Fortunately, only a few pieces are required. The source we can found are for LP and for other devices. Make if work for us would be quite a challenge. I finally managed to fix a few things. I seldom release anything that early but there are just so many requests. I don't think I have enough time to make everything work soon. Seeking for other opinions is never a bad move.
    I'm now sharing my experiences again. You are welcome to use and share my works. All I asked is "don't keep it to yourself, share yours too!" ;)
    If possible, I'll build a few different ROMs later. However, there won't be any weekly or monthly in schedule. This thread is more or less a stepping stone.
    At this stage, report is not essential. You don't have to repeat what already mentioned. Thanks!:D
    Existing issues:
    I. Missing symbols
    To deal with missing smybols (usually name space changed in platform upgrade), we may use a shim library and assigned it to LD_PRELOAD at init. GCC doesn't care who provide it. As long as it was loaded, others can access it. The up side is, this way would not touch the original source. The down side is it would be loaded/checked whenever a dlopen() is called. Clearly, it would increase overheads and affect the performance. For our K3-Note, there are also some missing symbols in blobs.
    I personally don't like LD_PRELOAD libraries. I would usually add a build flag to Android.mk and add a new file if possible.
    **In CM14.1, it already added the build flag BOARD_USES_MTK_HARDWARE in vendor_cm.
    Set it to true would define a global flag MTK_HARDWARE.**

    The patches are grouped in the device tree. At this moment, there are 4 group of patches:-
    1. system_core
    1.1 liblog (add the xlog function __xlog_buf_printf() and override the RLOG, see following section)
    1.2 libnetutils (required by thermal and RIL). Can use the blob from stock ROM.
    2. framework_av
    2.1 a file mtkaudio_stubs.cpp was added
    2.2 missing CameraParameteres
    2.3 add extra profiles to AudioPolicy (2016/12/17)
    2.4 fix audio recording in AudioFlinger (2016/12/17)
    3. framework_native
    3.1 Add a few symbols for backward compatible with MM calls.
    4. sepolicy. - not compulsory
    Mediatek never takes sepolicy seriously. They use permissive all the time. I planed to use enforcing eventually so I dealt with all the sepolicy from day one.

    II. The RIL
    Tool: To find out what's wrong, the logs are essential. I had made a patch to liblog. A new property "persist.ril.log" is added. Set it to 1 will push all RLOGs to main.
    1. A missing symbol in mtkrild
    With this help, I found a missing symbol in mtkrild. This symbol is in libnetutils.so. You may either use the file in stock ROM as a blob or rebuilt it.
    2. The ccc_util
    During debugging, I noticed there were garbage in the ccc_util logs. A source can be found for mt6595. After disassembled the binary blob, I found a few differences. I rewrote some part and added support for the two new properties. The final sources are grouped in the new project android_hardware_lenovo_aio_otfp
    3. Default modem selection
    There are two modem binaries in stock ROMs -- 5 (LWG) and 6 (LTG). They are in /system/etc/firware. In stock ROMs, the default modem is read from nvram. For some unknown reason (seems protection issue), ccci_mdinit can't get this value from nvram in custom ROMs. It would use the default value in Kernel (was 6). I noticed LWG was shown in About of stock ROM so I changed the kernel default to 5. Other areas might required this to be 6. Check the Modem in About for your area. If it is LTG, you may either swap the names of the two modems or change the kernel default. I wanted to use a build.prop but turn out that ccci_dminit is a blob from Mediatek. There are only binaries available. No way to add anything.
    4. Custom RIL Class
    This class is to handle MTK specific modem messages. Usually its for emergency dialling and modem info. It is not handled in AOSP. CM14.1 already taken care of it and that's one of the reason I switched to CM for testing.
    A Custom class can be found in CM's device tree for mt6735. I think its too much to handle the emergency number list but don't want to waste time rewriting it. With a few modifications, it can work for us in Nougat. Seems there are unused/unhandled messages. **Need to verify it later.**

    III. The Camera
    After my first ROM was out, the most eye catching in the log would be the stack corruption in libcam.halsensor.so.
    Code:
    11-24 21:53:55.967   490   490 F DEBUG   :     #08 pc 00017459  /system/lib/libcam.halsensor.so (_ZN12ImgSensorDrv13getResolutionEPP34ACDK_SENSOR_RESOLUTION_INFO_STRUCT+60)
    After study the source for mt6735, I found it was called within the blob libcam.halsensor.so. In the function ImgSensorDrv::getResolution(), an ioctl() call was passed to the kernel. I was thinking it was caused by user space data handling in the kernel. After a series of trials and dumping, I remarked that part of code from the kernel. The crash persisted. That means it was from the blob itself. I tried a shim library to replace the function ImgSensorDrv::getResolution() but the result is the same. That means the callee was responsible.
    After some digging, I was pretty sure it was caused by the alignment (address sanitize) of struct addresses. The latest blob from Lenovo dev.1631 (also the latest for mt6752 devices) were built with gcc 4.9 Clang 3.6. Nougat now use Clang 3.8 by default. Those blob already have alignment support in Clang 3.6 might have issues with the new Clang 3.8.
    What is address alignment? In short, a 32 bit processor can handle 32 bit at a time. It would be a easier for the register to locate memories in 32 bits (4 bytes) cells (aligned). If the head or tail for a block of memory is not aligned, extra code would required to separately handle those loose ends. The new clang compiler would fill leading bytes with its own algorithm to make the pointer or variable aligned. Why is ImgSensorDrv::getResolution() being "affected"? The argument of it is a pointer to ACDK_SENSOR_RESOLUTION_INFO_STRUCT. Its definition can be found in the kernel. It is a struct of an array of pointers to another struct. The source from Mediatek use direct reference to the address of struct variables all the time. This is inappropriate in sense of address alignment. Early compilers didn't handle alignments and won't have problem with that. Newer compiler would use its own algorithm to align the structs and pointers. I guess Clang 3.6 didn't handle the above complex struct as argument well. Nougat linker and loader are all built with Clang 3.8. Local variables are allocated at load time which might be handled differently. Thus a call to ImgSensorDrv::getResolution() would cause the stack corruption. :eek:
    ** Those interested may read this article for detail. **
    1. Work around
    Using older blobs built by gcc 4.8 or earlier might work. Jiayu S3's AOSP were using those old blobs. I'm new to K3-note. I don't think I have the patience and experience to test all the existing blobs. That's the main reason I uploaded the last two test ROM. Trying blobs and hoping some combination would work is passive. Stlport is also obsolete for some time now. I rather deal with the problem directly. :cowboy:
    2. The solution
    Without the source, building the whole blob is impossible. Even if we have the source from other devices, those custom parameters are unique to each image sensor. It's impossible to guess or back engineer... :(
    If we can change the way ImgSensorDrv::getResolution() is being called or didn't touch the argument within the function. It would avoid the crash. Unfortunately, the function need to fill a local struct within the ImgSensorDrv class. That means it is not seen outside ImgSensorDrv. The only way is to replace the whole ImgSensorDrv class. Fortunately, it is self contained. We can write a wrapper to replace the ImgSensorDrv class only. The source from mt6735 or mt6595 are a bit different and obviously can't be used directly. Most of the struct can be cross referenced to the kernel source. There are two local sturct left unknown. One is for the commands sent to the kernel. The other is some info. collected from the kernel.
    With the wrapper, the crash was gone but still no preview. I wrote a test HAL to dump the values in stock ROM. Guessing the values against the names was not a decent job. Fortunately, there were only a few differences. After nights of trial and error, I finally pulled everything together. Camera is working now! Video recording is still not working. Seems codec related. Some say it's not a problem "again". Hoping there will be some real solutions and helps soon...
    TODO: HDR crashed

    IV. GPS
    While comparing my log to the stock's, I found all daemons are working properly. It must be the problem of the interface. The java interface of GPS was changed in Nougat. Seems there were transitions from GPS struct to GNSS struct. I accidentally noticed a line in the thousands lines of log.
    Code:
    gps_mtk : copy_GpsCallbacks_mtk: line = 4124Bad callback, size: 96, expected: 88 or 80
    This showed some proof for my guess. After comparing the hardware/gps.h from MM and Nougat, I think the main problem is the difference in callbacks. There were a few ways in my mind. We can change the JNI and handle MTK differently to adopt the old style. Or, use another wrapper to shield the GPS HAL.
    The solution
    The best way is naturally to rebuild the GPS HAL. The sources I had were outdated. After another intensive search, I found the source for mt6795 from xiaomi and another source for mt6753 from ulefone. They were almost identical and matched all the symbols in the blob from Vibeui 3.5 1631. Their contents were quite standard GPS HAL but a lot had to patch for Nougat. Mediatek already handled some transitions to GNSS which made things a bit easier. The last piece left was the prebuilt libepos. There was no 64 bit library from xioami but there were a few from other devices. Nougat already have the open source curl in extension so everything seemed ready. In a few attempts, I managed to build the new HAL out. I also include Mediatek's apk YGPS for testing. Another reason is the uniqueness of GPS from MTK. Common GPS utilities like GPS Status doesn't work. Anyway, GPS is working now! Cheers! :D
    update (2017/2/17): I was using a mt6795 source from github. Turn out that it was already modified. There were something missing. I rewrote the HAL from the official mt6797 source. Now it is fully support GPS, GLONASS and BEIDOU. It is also backward compatible with the AOSP callbacks. Most of the GPS apks (eg. GPS status which was not working in stock MM) would be working now.
    update (2017/6/5): For some unknown reason, the country code can not be read from nvram. Thus mnld would use default value which disabled the GLONASS access. I made a patch in post #520. It would generate the file /data/misc/gps/mnl.prop. This is the default property file which never been used. Read the comment inside this file for detail. There are other default settings available. Anyone interested may PM me for detail.

    V. Audio recording
    After checking with a few test apks, I'm pretty sure the issue was the audio recording solely not Mic. related. Actually, I already fixed it for some time but I didn't know. I was mislead by the pause feature in CM's SoundRecorder apk. That pause feature is unique to CM. MTK's (probably some others) HAL didn't handle it at all. Whenever I pressed the pause, it would call the missing function in HAL and hang. I wrote a test apk myself and found that it worked! I then looked into the source of AOSP. That cleared things up immediately. I don't want to modify CM's apk so I replace it with the one from AOSP.
    The solution
    The definition of the struct audio_stream_in has changed in Nougat. The function get_capture_position() was added. It's just for reporting the time stamp. The audio HAL blob from MTK didn't have this function. When the input streams were loaded, it would crash. I reinstated the untouched BOARD_USES_LEGACY_MTK_AV_BLOB flag and made a patch in AudioFlinger service. I added the specific header "audio.h" in device tree. Check the source on my github for detal.
    One less thing on the list now! Cheers!

    VI. MTK Codec
    Codecs are essential for recording and playback. Although we can use the software codec from CM or Google for playback, video recording normally required the codec from the manufacturer. That's why I spent a lot of time to make them work first. Samsung and Qcom usually put the codecs in kernel drivers but Mediatek didn't. MTK's codec use the gralloc_ext, ui_ext and gui_ext helper libraries to "assist" the allocations and queries. Unfortunately, platform changes arose some issues in these blobs.
    The solution
    Naturally, to make it fully support Nougat, we have to rebuild it. I found the sources for mt6797. They are small but have some dependencies. Only minor changes would make them Nougat compliant. Both depend on the dpframework and gralloc.mt6752 which are proprietary. I already rebuilt gralloc_ext from source. Proved to be the right move now. I grouped them into the graphics folder in the hardware_lenovo_aio_otfp project. With these newly built libraries, all codecs are working now. ;)
    update (2017/3/18): Found the latest codecs for mt6750t. They work for YouTube, Snapchat, etc. Check the attachment in post #272.
    TODO: WVM not handled

    VII. Video Recording
    For my Samsung devices and Tilapia, I can make the cameraservice work on both camera and camcorder. I don't need the HAL1 flag reverting to the mediaserver. After fixing the extra allocation libraries for my K3-note, I could record the video to a mp4 file. Audio was normal but video wasn't. I had studied for a while. I thought it was colour format related but I don't know why yet. There would be too much changes to the original source so I decided to put aside first.
    The solution
    Although it's not my wish, I compromised. Everything went well when I use the HAL1 flag switching back to mediaserver. It's time to move on to the WifiHAL now. Would return to this part later. Anyway, it's kinda fixed now! ;)
    TODO: Reinstate Cameraserver

    VIII. WifiHAL for Nougat
    WifiHAL has been introduced for a few generations. It provides another way to access the WiFi in the frameworks. MediaTek's WifiHAL was clearly derived from Broadcom's source. LP and MM only used a small portion of the callbacks. Nougat uses a few more and some of them haven't supported in the kernel driver yet. I used a patched Brodcom's WifiHAL in my earlier builds. It could only be loaded to pass the check. Things like hotspot, 5G, hidden ssid, etc. were not handled. I then ported the sources from mt6795 and mt6797 to my early WiFiHAL. It took me a few days to handle most of the Wifi commands and queries. Together with the minor patch in netd, hotspot is working. An immediate issue arose -- WiFi wouldn't auto reconnect. It required to turn on manually. Hidden ssid was still not working. When a network was manually added, Wifi would fail to scan for APs. Clearly it was another major problem I overlooked... :(
    A long road to the solution
    I enabled the logs in all the relevant java and c files. Nothing seemed special pop up. I then added my own extra logs. An odd scenario appeared on the channel list. I traced back to the callee in libwifi-service. It was a query message for the available channel lists for 2.4G, 5G and 5G DFS bands. However, the lists to all bands were the same. There were 3 channels all started with 2412 (which is the 1st channel of 2.4G band). The default log in GetChannelListCommand only dump the first entry so I add a for loop to dump all. I got 2412,2413 and 2414! That was definitely impossible. I realized there must be something wrong with this vendor data. Clearly the firmware and proprietary blobs won't be the problem. There were also nothing similar in the nvram. I then traced back to its source -- the kernel driver. Following the defconfig and Makefiles, I found the handler for this message in drivers/misc/mediatek/connectivity/conn_soc/drv_wlan/mt_wifi/wlan/os/linux/gl_cfg80211.c.
    Looking at the function mtk_cfg80211_vendor_get_channel_list() made me cry and laugh...
    Code:
    	kalMemZero(channels, sizeof(wifi_channel) * 4);
    	/*rStatus = kalIoctl(prGlueInfo,
    	   wlanoidQueryStatistics,
    	   &channel,
    	   sizeof(channel),
    	   TRUE,
    	   TRUE,
    	   TRUE,
    	   FALSE,
    	   &u4BufLen); */
    
    	/* only for test */
    	num_channel = 3;
    	channels[0] = 2412;
    	channels[1] = 2413;
    	channels[2] = 2414;
    	NLA_PUT_U32(skb, GSCAN_ATTRIBUTE_NUM_CHANNELS, num_channel);
    	NLA_PUT(skb, GSCAN_ATTRIBUTE_CHANNEL_LIST, (sizeof(wifi_channel) * num_channel), channels);
    It was clearly not handled! I found similar codes among all mt67xx and mt65xx devices. The latest MTK's 3.18 kernel, however, paid back. The codes seemed promising. Only minor adjustments were required but this time I got nothing...:eek: I then dumped all the arguments and results after each function calls. Things were clear instantly. Platform used band 1,2,4 for 2.4G, 5G and 5G DFS respectively but MTK use 0 for 2.4G which was also different from its own enum definition (which is similar to the platform). I believed they didn't test it in 3.18 too! I used the parameter band directly. Then simplified the code to have both 2.4G and 5G sharing the same call. After that the channels were reported correctly to the platform. As a bonus, I found the part handled 5G which was disabled by default. I enabled it in the kernel now. As expected, both 2.4G and 5G channels are reported correctly now. After this fix, WiFi can now auto reconnect. To avoid further land mines, I checked all the WiFi commands in the WifiHAL. Turn out that only a handful was actually handled in the kernel. Most of the useless codes are removed and the rest are properly handled now. It took me over a week! The WifiHAL turn out to be a big chapter!
    The next and more annoyed issue was Hidden SSID. I'm pretty sure the WifiHAL was OK so I looked into the vendor lib lib_driver_cmd_mt66xx. Enabled a few MTK flags and started with a very limited code all resulted the same. Finally, the following line in log caught my attention:
    Code:
     E wpa_supplicant: wlan0: nl80211: Scan trigger failed: ret=-22 (Invalid argument)
    A block of similar lines show repeatedly when a network was manually added. I believed wrong arguments were sent to wpa_supplicant. I downloaded the full wpa_supplicant manual and redirected the wpa_supplicants commands to the console. Nothing seemed special but I noticed there was an empty entry being pushed to the argument list. The error only occured when the added SSID appeared. With the empty entry, the arguments were one less. Even if its MTK's problem, wpa_supplicant should take care that. I saw a potential problem and I decided to add a check first. It really really paid back! That's the reason why hidden ssid not working! After two sweaty weeks of work, I would said WiFi is fully working now.... ;)
    update (2017/6/22): p2p and WiFi-display is working.

    VIII. FM radio
    update (2017/2/27): After taking another look, I found that the FM radio was already fixed. Probably after the audio recording fix. So everything is more or less working now. Cheers! :D

    Credits:
    - With no doublt the LineageOS community should have most of the credits
    - The CarbonROM, OmniROM, SlimROM and many other custom ROM teams who bring us the alternatives.
    - Those who release the sources for MTK devices.
    - And finally Lenovo who had released a castrated kernel source which motivate us to DIY.

    Sources: https://github.com/danielhk

    Download: AFH LineageOS, AFH SlimRoms, AFH CarbonROM
    (百度网盘)LineageOS , (百度网盘)SlimRoms, (百度网盘)CarbonROM
    My version of TWRP-3.1.1

    Installation:

    ** backup your current /boot, /data and /system partition first **
    TWRP 3.0.x is the only recovery tested. There are many TWRP using different device names out there. I already included a few but there would be more. If you got error (6) at flashing, you may change the line in updater-script or use different TWRP.
    1. Do a factory reset (wipe /data and /cache)
    2. Flash the ROM
    3. Flash the Gapps
    4. Flash latest SuperSU
    Step 1. is essential if you are from other ROMs, otherwise you might get ERROR:7.
    Reboot and hoping its not a night mare... :D
    ** Note: you don't need to wipe other partitions. Some important device specific data are in nvram and misc. **
    Change Log:
    Code:
    [COLOR="Blue"][B]2018/1/27 - LineageOS-14.1[/B][/COLOR]
    [INDENT]- The latest LineageOS-14.1 source, Android-7.1.2_r36 (NJH47F)
    - Security patch Dec. 5,2017
    - Kernel: New Bluetooth driver
    - Bluetooth HAL build from source
    - Adjust some Heap and VM settings[/INDENT]
    [COLOR="Blue"][B]2018/1/2 - [COLOR="Black"]CarbonRom[/COLOR] CR-5.1[/B][/COLOR]
    [INDENT]- The latest Carbon CR-5.1 source, Android-7.1.2_r36 (NJH47F??)
    - Kernel: a few minor patches
    - Fix Hotspot issue in the last build[/INDENT]
    [B]2017/12/29 - [COLOR="Black"]CarbonRom[/COLOR] CR-5.1[/B][/COLOR]
    [INDENT]- The latest Carbon CR-5.1 source, Android-7.1.2_r36 (NJH47F??)
    - Cumulated patches from my previous Lineage-15.1 builds
    - Kernel: a few drivers update
    - Adjust some Heap and VM settings
    - Security patch Dec. 5, 2017[/INDENT]
    [COLOR="Blue"][B]2017/12/16 - LineageOS-14.1[/B][/COLOR]
    [INDENT]- The latest LineageOS-14.1 source, Android-7.1.2_r36 (NJH47F)
    - Security patch Dec. 5,2017[/INDENT]
    [COLOR="Blue"][B]2017/12/3 - LineageOS-14.1[/B][/COLOR]
    [INDENT]- The latest LineageOS-14.1 source, Android-7.1.2_r29 (NJH47F)
    - Update SELinux rules[/INDENT]
    [COLOR="Blue"][B]2017/10/31 - LineageOS-14.1[/B][/COLOR]
    [INDENT]- The latest LineageOS-14.1 source, Android-7.1.2_r29 (NJH47F)
    - Fix Sim settings crash
    - Kernel: binder update[/INDENT]
    [COLOR="Blue"][B]2017/10/15 - [COLOR="Black"]CarbonRom[/COLOR] CR-5.1[/B][/COLOR]
    [INDENT]- The latest Carbon CR-5.1 source, Android-7.1.2_r29 (NJH47F)
    - Kernel: binder update[/INDENT]
    [COLOR="Blue"][B]2017/10/1 - LineageOS-14.1[/B][/COLOR]
    [INDENT]- The latest LineageOS-14.1 source, Android-7.1.2_r29 (NJH47F)
    - Fix PicoTTS from Lineage
    - Security patch Aug. 5,2017[/INDENT]
    [COLOR="Blue"][B]2017/9/9 - [COLOR="Black"]CarbonRom[/COLOR] CR-5.1[/B][/COLOR]
    [INDENT]- The latest Carbon CR-5.1 source, Android-7.1.2_r29 (NJH47F)
    - Security patch Aug. 5,2017[/INDENT]
    [COLOR="Blue"][B]2017/8/20 - LineageOS-14.1[/B][/COLOR]
    [INDENT]- The latest LineageOS-14.1 source, Android-7.1.2_r29 (NJH47F)
    - Clean up unused RIL daemon and services
    - Security patch Aug. 5,2017[/INDENT]
    [COLOR="Blue"][B]2017/8/13 - [COLOR="Black"]CarbonRom[/COLOR] CR-5.1[/B][/COLOR]
    [INDENT]- The latest Carbon CR-5.1 source, Android-7.1.2_r29 (NJH47F)
    - Clean up unused RIL daemon and services
    - Settings: Enable the Ambient Display switch
    - Security patch Aug. 5,2017[/INDENT]
    [COLOR="Blue"][B]2017/7/29 - LineageOS-14.1[/B][/COLOR]
    [INDENT]- The latest LineageOS-14.1 source, Android-7.1.2_r24 (NJH47D)
    - Kernel: a few minor patches (mainly for O ready)
    - Settings: Enable the Ambient Display switch
    - Security patch July 5,2017[/INDENT]
    [COLOR="Blue"][B]2017/7/21 - [COLOR="Black"]CarbonRom[/COLOR] CR-5.1[/B][/COLOR]
    [INDENT]- The latest Carbon CR-5.1 source, Android-7.1.2_r24 (NJH47D)
    - Security patch July 5,2017[/INDENT]
    [COLOR="Blue"][B]2017/7/2 - LineageOS-14.1[/B][/COLOR]
    [INDENT]- The latest LineageOS-14.1 source, Android-7.1.2_r17 (NJH47B)
    - With all patches from the last Carbon.
    - AudioFX is removed. Seems useless now.
    - PerformanceControl: With Arabic translation from @ziad shawki 
    - PerformanceControl: Improve the battery interface to report the battery voltage from MTK devices
    - Kernel: fix a bug in Lenovo's code.
    - Kernel: Further simplify the code in the touchscreen driver.[/INDENT]
    [COLOR="Blue"][B]2017/6/29 - [COLOR="Black"]CarbonRom[/COLOR] CR-5.1[/B][/COLOR]
    [INDENT]- The latest Carbon CR-5.1 source, Android-7.1.2_r17 (NJH47B)
    - Kernel: enable native gesture support
    - Kernel: new touchscreen interface for gesture
    - Kernel: enter pocket mode when gesture wakeup enabled
    - PerformanceControl: upgrade to version 2.1.7
    - PerformanceControl: New MediaTek settings with Slide and Gesture O and V handler
    - PerformanceControl: fix a bug in drawer
    - PerformanceControl: Filter out unnecessary system apps in Freezer[/INDENT]
    [COLOR="Blue"][B]2017/6/20 - Kernel update[/B][/COLOR]
    [INDENT]- Touchscreen: driver patch and clean up
    - enable native gesture support
    - enable native DT2W support, add double tap Home key to wakeup
    - Enter low power mode at suspend
    - pocket mode automatically enabled in native driver[/INDENT]
    [COLOR="Blue"][B]2017/6/16 - LineageOS-14.1[/B][/COLOR]
    [INDENT]- The latest LineageOS-14.1 source, Android-7.1.2_r17 (NJH47B)
    - all patches/fixes from CR-5.1 are included
    - Security patch June 5,2017[/INDENT]
    [COLOR="Blue"][B]2017/6/14 - [COLOR="Black"]CarbonRom[/COLOR] CR-5.1[/B][/COLOR]
    [INDENT]- The latest Carbon CR-5.1 source, Android-7.1.2_r17 (NJH47B)
    - Rewrite fstab 
    - Kernel: patches to a few drivers
    - Bug fixes in CarbonFibers
    - Security patch June 5,2017[/INDENT]
    [COLOR="Blue"][B]2017/6/2 - [COLOR="Black"]CarbonRom[/COLOR] CR-5.1[/B][/COLOR]
    [INDENT]- The latest Carbon CR-5.1 source, Android-7.1.2_r8 (N2G47O)
    - Default Carbon Browser
    - Bug fixes in CarbonFibers
    - Security patch May 5,2017[/INDENT]
    [COLOR="Blue"][B]2017/5/3 - [COLOR="Black"]CarbonRom[/COLOR] CR-5.1[/B][/COLOR]
    [INDENT]- The latest Carbon CR-5.1 source, Android-7.1.2_r8 (N2G47O)
    - Fixes from latest LOS-14.1
    - codec update
    - Fix longpress and doubletap behaviour of nav buttons[/INDENT]
    [COLOR="Blue"][B]2017/4/30 - LineageOS-14.1[/B][/COLOR]
    [INDENT]- The latest LineageOS-14.1 source, Android-7.1.2_r2 (N2G47E)
    - kernel: default at 1.8G now
    - New HDR approach[/INDENT]
    [COLOR="Blue"][B]2017/4/12 - AOSP-7.1.2_r6[/B][/COLOR]
    [INDENT]- The Android-7.1.2_r6 (NHG47K) source
    - All fixes from previous builds
    - PerformanceControl is included
    - Equipped with the O/C kernel, default at 1.8G now
    - Fix the Camera crash in 7.1.2
    [COLOR="Red"][B]***  see [URL="https://xdaforums.com/showpost.php?p=71828345&postcount=330"]post #330[/URL] for how to install and download link ***[/B][/COLOR][/INDENT]
    [COLOR="Blue"][B]2017/4/8 - LineageOS 14.1[/B][/COLOR]
    [INDENT]- The latest LineageOS-14.1 source, Android-7.1.1_r25 (NOF27B)
    - All fixes from previous builds
    - Workaround for HDR. Don't know if its better but faster than stock algorithm
    - Equipped with the O/C kernel
    - PerformanceControl is included
    - Update codecs
    - Include App Switch (Recent) in button settings.[/INDENT]
    [COLOR="Blue"][B]2017/3/30 - [COLOR="Black"]CarbonRom[/COLOR] CR-5.1[/B][/COLOR]
    [INDENT]- The latest Carbon CR-5.1 source, Android-7.1.1_r25 (NOF27B)
    - All fixes from previous builds
    - patches to adapt the new Carbon build scripts.
    - Fix the flashlight while taking picture
    - Fix the custom key definition for menu key.
    - The O/C kernel is equipped[/INDENT]
    [COLOR="Blue"][B]2017/3/19 Kernel update, see [URL="https://xdaforums.com/showpost.php?p=71490161&postcount=275"]post#275[/URL] [/B][/COLOR] for detail and download link.
    [INDENT]- O/C for CPU upto 2GHz (Adjustable with PerformanceControl and other kernel tools)
    - Voltage table control (Adjustable with PerformanceControl and other kernel tools)
    [COLOR="Red"]*** The default values are already optimized for the PLL and power chip.
    Don't mess with them if you don't know how. I already set the upper and lower limits.
    Should there be any damage caused, it would be at your own risk ***[/COLOR]
    - OC for GPU upto 819MHz.
    - Work for most (hoping all, including stock) Roms with the VibeUI dev. 1631(and s433) blobs.[/INDENT]
    [COLOR="Blue"][B]2017/3/18 Codec update, see [URL="https://xdaforums.com/showpost.php?p=71476388&postcount=272"]post#272[/URL] [/B][/COLOR] and download link.
    [INDENT]- Fix YouTube zooming issue
    - Fix SnapChat recording.[/INDENT]
    [COLOR="Blue"][B]2017/3/12 - [COLOR="Navyblue"]SlimRoms[/COLOR] build 0.15[/B][/COLOR]
    [INDENT]- The latest SlimRom 0.15 source, Android-7.1.1_r26 (NOF27C)
    - All patches/fixes in my 20170312 LineageOS-14.1
    - Add long press AppSwitch (Recent) key for menu[/INDENT]
    [COLOR="Blue"][B]2017/3/12 - LineageOS 14.1[/B][/COLOR]
    [INDENT]- The latest LineageOS-14.1 source, Android-7.1.1_r25 (NOF27B)
    - The latest GPS HAL from CarbonROM
    - FMRadio: Fixed
    - Media Profiles: update to support common video formats.
    - Limit background processes to increase available RAM
    - Camera app: replaced with Snap by Lineage
    - [COLOR="Red"]Lineage is not ROOTED[/COLOR] by default now[/INDENT]
    [COLOR="Blue"][B]2017/2/18 - [COLOR="Black"]CarbonRom[/COLOR] CR-5.1[/B][/COLOR]
    [INDENT]- The latest Carbon CR-5.1 source, Android-7.1.1_r21 (NOF26W)
    - Initial beta release
    - New GPS HAL (fully working and faster)
    - Add long press AppSwitch (Recent) key for menu
    - All fixes from LineageOS-14.1[/INDENT]
    [COLOR="Blue"][B]2017/2/14 - [COLOR="Navyblue"]SlimRoms[/COLOR] build 0.11[/B][/COLOR]
    [INDENT]- The latest SlimRom 0.11 source, Android-7.1.1_r21 (NOF26W)
    - Initial alpha test build 0.11
    - All fixes from LineageOS-14.1
    - Add prebuilt Chromium (from CarbonROM)[/INDENT]
    [COLOR="Blue"][B]2017/2/14 - LineageOS 14.1[/B][/COLOR]
    [INDENT]- The latest LineageOS-14.1 source, Android-7.1.1_r9 (NMF26V)
    - Libstagefright: Add fixes to media streaming (Don't know if it work or not)
    - LiveDisplay: Add support and settings
    - RIL: Handle a few more MTK specific messages (WIP)
    - GPS: Add backwards support for MM and earlier
    - GPS: Fill up the extra fields in GNSS struct
    - GPS: Add a override property to select GPS mode (GNSS/GPS) (Testing only)
    - Fixed Power off charging screen
    - kpoc_charger: keep the stock images (which are in the LOGO partition)
    - Fixed LED notifications
    - liblight: Rewrite the lights HAL for better support in Nougats and beyond (WIP)
    - liblight: Add dual color support (WIP) [/INDENT]
    [COLOR="Blue"][B]2017/1/17 - LineageOS 14.1[/B][/COLOR]
    [INDENT]- The latest LineageOS-14.1 source, Android-7.1.1_r9 (NMF26V)
    - RIL: Add a fix in custom RIL class (thx. @Moyster for the tip), don't know if it helps.
    - hostap: build from source
    - netd: a minor patch (wlan0 to ap0) for hotspot
    - WifiHAL: Rewrite a new one (almost from scratch...)
    - WifiHAL: Handle extra callbacks for Nougat
    - Kernel: Handle the mtk_cfg80211_vendor_get_channel_list() correctly
    - Kernel: Enabled 5G by default
    - wpa_supplicant: Fix a potential bug (which fixed MTK's hidden SSID issue)[/INDENT]
    [COLOR="Blue"][B]2017/1/5 - LineageOS 14.1[/B][/COLOR]
    [INDENT]- The latest LineageOS-14.1 source, Android-7.1.1_r6 (NMF26Q)
    - RIL: use the full set of blobs from S433 (newer than dev. 1631)
    - MTKCodec: Fix the storage issue in MTK Codec
    - MTKCodec: Include the complete set of MTK codec in dev. 1631
    - media_profiles.xml: Include the vorbis decoder
    - libion: Rebuilt with open source libion
    - VideoRecording: Fix video recording
    - SEPolicy: update for codec and media server
    - kpoc_charger: rebuilt kpoc_charger from source [WIP][/INDENT]
    [COLOR="Blue"][B]2016/12/17 - CM14.1[/B][/COLOR]
    [INDENT]- The latest CM-14.1 source, Android-7.1.1_r6 (NMF26Q)
    - Camera: Fix the flashlight in taking picture
    - AudioRecording:Fix audio recording
    - SoundRecorder: Replaced with the one from AOSP
    - SEPolicy: update for 7.1.1_r6
    - media_profiles.xml: Rewrote with the values in stock log
    - AudioPolicy: Add extra profiles
    - OMX: Fix the crash of nativeHandle in video recording (WIP)
    - libhealthd: fix a few things (WIP)
    - WifiHAL: Rewrote a new one for Nougat (WIP)[/INDENT]
    [COLOR="Blue"][B]2016/12/11 - CM14.1[/B][/COLOR]
    [INDENT]- The latest CM-14.1 source, Android-7.1.1_r4 (NMF26O)
    - init.mt6752.rc: A few patches
    - gps.mt6752.so: Rebuilt the GPS HAL from source
    - libcurl.so: Use opensource curl
    - YGPS: Include MTK's test apk for GPS
    - SEPolicy: Further patches
    - Built-in VPN is working now
    - healthd: Add standard charging routines to (WIP)[/INDENT]
    [COLOR="Blue"][B]2016/12/6 - CM14.1[/B][/COLOR]
    [INDENT]- The latest DC-MTK kernel
    - Kernel: Enable UID CPU time
    - Kernel: Emulate the hardware random sysfs
    - Kernel: Treat all A/C chargers the same (same charging current and limits)
    - Kernel: rename led sysfs to AOSP defaults
    - Kernel: set default modem to 5
    - Handle all extra SEPolicy
    - Fix the audio output
    - Add the RLOG override and xlog suppress properties
    - Fix RIL and mobile data
    - Fix all sensors
    - Add libhealthd.mt6752 to report battery status
    - Fix the camera[/INDENT]

    Known Issues:
    Code:
     - may be more...
    Donations:


    XDA:DevDB Information
    Nougat and beyond?, ROM for the Lenovo K3 Note

    Contributors
    daniel_hk
    Source Code: https://github.com/danielhk

    ROM OS Version: 7.x Nougat
    ROM Kernel: Linux 3.10.x
    Based On: AOSP, LineageOS, SlimRoms, CarbonROM

    Version Information
    Status: Stable
    Stable Release Date: 2017-06-14
    Beta Release Date: 2017-06-03

    Created 2016-12-05
    Last Updated 2018-01-27
    37
    20170924 LineageOS 15.0 alpha test build

    Finally, I have some breakthrough this weekend. :highfive:
    With a cocktail of the methods I tried, I can have a reliable RIL connection now. There are still a few loose ends but good enough for an alpha test. Therefore, I uploaded my latest test build for those few fellow developers to study. I don't know if its the first ever Oreo for MTK devices but this is just an experiment. Still a long way to go but seems not impossible now, cheers! :D

    For those interested, you may check the experimental folder : https://www.androidfilehost.com/?w=files&flid=131362

    There are still major issues so it is not ready for normal use yet, it just pointless to report anything too. Those who have real idea are welcome but I can't accept any log no more. I just don't have enough time for myself, sorry. It's not just a few patches or fixes would make Oreo work or even boot. If you don't understand what I suggested or posted, you are not ready yet.

    I was planning to build AOSP but the out folder grows rapidly after a few builds. (from 80G to over 160G easy!). A clean build take over 4 hours even with ccache. So I would triple check in every attempt to avoid another build. I just can't have more than two Oreo inside my 500G partition without regularly removing the temp files...

    Anyway, the current status is:
    1. Audio IN/OUT is working.
    2. GPS is working.
    3. Power off charging is working. (With the CM/LOS charging images)
    4. Wifi is working (may be 90%) but hidden ssid is not supported.
    5. Wifi hotspot is working.
    6. All sensors are working.
    7. LED is working. I only tested with missing calls.
    8. FM radio is working.
    9. Torch (Flash light) is working.
    10. DT2W is not working but you may press the back key to wake up the screen. Don't know if its the new feature of Oreo...
    And finally RIL, I would say its 80% working now.
    Dual SIM are supported and both SIM can make/receive phone calls and can connect to data. But, SMS can only be sent not received. I was thinking its APN related but data is working now. It might be IMS related but still have no idea yet.
    SIM settings only work with one SIM in the device. It crashes with dual SIMs presence. I think its a platform bug. There seems no dual SIM device with official Oreo yet so can't verify.

    Other major issues (mostly platform related) are:
    1. Bluetooth hci can't read(I think write too) from the port. Seems CLANG related. It's a tiny but fatal bug. It makes no sense to use the old libc. pending...
    2. Camera can't connect to the frame buffer. I think it needs the HAL1 handling. Let LOS do the job first. pending...
    3. All codecs are successfully loaded but video playback fail. Seems security issues or media player services. pending...

    Oreo is still early. It might be time wasting to deal with those platform issues. At this stage there are still hardware related issues. There is a long holiday ahead. I would take a break and continue later... ;)
    26
    20171001 LineageOS 14.1 update.

    This is the latest Lineage-14.1 I built for personal use.
    - Android 7.1.2_r29 (NJH47F)
    - Lineage has put a fix in the PicoTTS.

    About Oero
    I finally figure out why SMS not received. I would say RIL is 90% working now. Cheers! :D
    The last 10% would be the data setup UI for dual sim and how to reset the modem after a deadlock.
    What left would be mostly the fixes in Android platform. When there are possible solutions, I might start a new thread. ;)
    25
    20171006 LineageOS 15.0 another alpha test build

    After foot loose and fancy free for a few days, my battery is almost fully recharged. :D
    Finally found a local mirror to sync the source from google. It's pretty slow but way better than nothing... :eek:

    I built another LOS-15.0 before bed last night. It's is uploading to the Experimental folder now.
    1. As mentioned earlier SMS receiving is OK. The SIM settings UI is also fixed now. I would say RIL is 95% working (STK crashed) and good enough for daily use. Cheers! :D
    2. I studied the bluetooth again. I just don't know why the basic read write to a standard Linux char device doesn't work now. It just redirect to the net syscalls. I have a few net patches and the sdcardfs patch but nothing seemed would cause that. There are a few ways in mind but I believe there are simpler explanations... Pending...
    3. For the Camera, I took a closer look this time. There is a serious bug in MTK's camera HAL. O required the user handle to register the allocated buffers but all MTK camera blobs I found just conveniently put a NULL to the calls. It was ok before but not Oero. It would cause the interface refuse to allocate buffers. I have a dirty fix but not sure if it would work all the time... Another big issue is the lack of CAMERA_GRALLOC_USAGE in Oero (or I don't know where it is... ), it would make video recording impossible. Media and Camera is not my dish so a lot of reading again... :cyclops: Hoping Lineage or other team would have solution soon.
    4. Haven't studied media playback yet.
    Another point to noted: when the device is in deep sleep. Don't repeatedly press "back key" or power button. Press just once and wait. Otherwise the system would blink and wait for (something like 6s) for another recovery cycle. I would look that the system is dead but actually not. I think its the wake up delay issue.

    Therefore a new thread is pending...
    I spent some time to tidy up the device tree earlier. I'll update to my github shortly. See if anyone have valuable suggestions.
    Kernel and others would follow when ready. ;)

    Seriously, the most annoying are those back seat drivers. If you don't know what it is, it would waste your time and my time sending me useless links and suggestions. Please keep it to yourself or address your views elsewhere. Thanks!
    22
    Android-8.0.0 Oero info. update

    Soon after the launch of 8.0.0 Oero, the sources were also released, cheers!
    It took me a few days to sync and update everything. There come a few typhoon recently and besides the destructions its extra "holidays".
    I have tried a few approaches and almost started all over every time. Eventually, I can make the RIL working to a certain extent.
    The RIL status is:
    1. Can make and receive phone calls.
    2. Can send SMS but not receive (probably APN issue)
    3. Data is not working (probably APN issue again...)
    It's breath-taking when I first saw the signal bars again! It was not stable at first but its kinda stable now. :highfive:
    Anyway, its within my expectation that some function might not working without serious fight... :mad:
    Seems the wrapper approach is workable, at least to a certain extent for daily use. Actually, it started as a wrapper but it handles 95% of the works now. Still can't figure out a few proprietary functions. Hoping the RIL lib can be replaced completely. Still a long way to go...
    Screenshot_20170826-140321.png
    It's time for the new age. I'm cleaning up the device tree and vendor blobs for Nougat. Hoping nothing would be missing.
    I would continue building Nougat for my personal use. There might be updates once a while but no ETA or guarantee. ;)