Huawei P Smart (huawei-figo)

== Contributors ==
* Pentiumpro
== Users owning this device ==
== How to enter flash mode ==
Flashing can be done through TWRP (flash with fastboot. Fastboot can be entered by pressing power and volume down while connected to a computer. TWRP can be entered by pressing volume up and power while not connected to a computer.
== Installation ==
Since Huawei changed the partition layout, there is no more boot partition, turning it into a single kernel partition, forcing us to use erecovery kernel and ramdisk partition.
# Get mkbootimg and unpackbootimg i.e. from here
# You can extract the kernel-image and ramdisk from the created boot.img with unpackbootimg. 
#:
$ # copy created boot image to current directory 
$ cp ~/.local/var/pmbootstrap/chroot_rootfs_huawei-figo/boot/boot.img .
$ # extract the created boot.img
$ mkdir pmos-boot-huawei-figo
$ ./android-unpackbootimg/unpackbootimg -i boot.img -o pmos-boot-huawei-figo/ 
#: Use the extracted files in the following steps.
# Create ramdisk image:
#:
$ # create new ramdisk image with empty kernel (/dev/null) 
$ ./android-unpackbootimg/mkbootimg.py --kernel /dev/null --ramdisk pmos-boot-huawei-figo/boot.img-ramdisk.gz --cmdline 'buildvariant=user' --os_version 9.0.0 --os_patch_level 2019-06-05 -o pmos-figo.ramdisk.img 
# Create kernel image:
#:
$ # kernel (with empty ramdisk via /dev/null):
$ # make sure boot.img-huawei-figo-zImage is gzipped or do it manually before mkbootimg.py
$ gzip -c pmos-boot-huawei-figo/boot.img-zImage > pmos-boot-huawei-figo/boot.img-zImage.gz
$ ./android-unpackbootimg/mkbootimg.py --kernel pmos-boot-huawei-figo/boot.img-zImage.gz --ramdisk /dev/null --cmdline 'loglevel=4 coherent_pool=512K page_tracker=on slub_min_objects=12 unmovable_isolate1=2:192M,3:224M,4:256M printktimer=0xfff0a000,0x534,0x538 androidboot.selinux=enforcing buildvariant=user' --base 0x00478000 --kernel_offset 0x00008000 --ramdisk_offset 0x0ff88000 --second_offset 0x00e88000 --tags_offset 0x07988000 --os_version 9.0.0 --os_patch_level 2019-12 --pagesize 2048 -o pmos-figo.kernel.img
# Transfer to device with adb:
#:
$ adb push pmos-figo* /
# Flash ramdisk and kernel with dd inside twrp:
#:
# dd if=pmos-figo.kernel.img of=/dev/block/mmcblk0p28
# dd if=pmos-figo.ramdisk.img of=/dev/block/mmcblk0p29
# Flash rootfs to sdcard to boot it
== Additional Info ==
The display brightness can be set by writing a value between 0 and 4095 to /sys/class/leds/lcd_backlight0/brightness. 
$ sudo -i
# echo 1024 > /sys/class/leds/lcd_backlight0/brightness 
The torch/camera flash can be set by writing a value between 0 and 8 to /sys/class/leds/torch/brightness
$ sudo -i
# echo 5 > /sys/class/leds/torch/brightness
The vibration motor can be set by writing a value between 0 and 255 to /sys/class/leds/vibrator/brightness. Seems to also be additional values like duration, vibrator_min_timeout, state, and activate. Unknown what they do.
$ sudo -i
# echo 1 > /sys/class/leds/vibrator/brightness
Status LED at top of device can be set to red, green, blue, or a combination of those 3 by setting /sys/class/leds/(red green blue)/brightness to a value between 0 and 255. Delay in which the led is on can be changed by setting /sys/class/leds/(red green blue)/delay_off or /sys/class/leds/(red green blue)/delay_on to any value in milliseconds (seems to control all 3 colors at the same time).
$ sudo -i
# echo 100 > /sys/class/leds/red/brightness
# echo 100 > /sys/class/leds/green/brightness
# echo 100 > /sys/class/leds/blue/brightness
# echo 500 > /sys/class/leds/blue/delay_on
# echo 1000 > /sys/class/leds/red/delay_off
== See also ==
* aa13q's Honor 9 Lite
* Ignapk's P10 Lite
* Kernel sources