PEOPLE ON ROMS DATED ON OR AFTER JANUARY 2016 PLEASE DO NOT USE THIS. LOOK AT THIS POST FOR MORE INFO
Hey guys.
So, most of us have been using the SP since many months / couple of years by now and majority of us like the beautiful LED bar at the bottom and could probably even be the reason you've bought one.
So this guide here is another guide focused on that aspect of our phone. The LED Illumination bar.
As the title suggest, this guide will definitely help you learn how the Boot LED animation occurs and I will be giving you some tips and hints on how to create your own LED Boot sequence.
Requirements:
1) An Xperia SP rooted, bootloader unlocked, must be running a recent 5.1.1 LP ROM
2) An init.sh replacer template made by @Tomoms using @nosedive 's anykernel template (Which will be found in the attachments to this post)
3) Patience and a working brain and some more patience with a dash of common sense
4) A good editor like notepad ++ (if on windows) or gedit is more than enough for Linux distributions. (Make sure to enable line numbers in your editor. Mostly the option will be in preferences )
Firstly, I shall explain the file we are going to modify. The init.sh file.
(Note that this is my interpretation of the code and is 99% correct, however if at all there are mistakes in what I explain, please do mention so that I can correct it and update this post.)
So where is this init.sh?
This file is inside sbin folder of root directory of our phone. (/sbin/init.sh)
This init.sh is a part of the ramdisk which is in turn a part of our kernel
So to modify this init.sh , we directly need to edit the ramdisk (thus manually pushing edited init.sh into /sbin/ won't work)
Good. Now you know where this file is. So we proceed to the next step.
What is this file anyway?
It is a script file ( *.sh files are script files . Google for more info) that automatically runs at every startup.
Now what you need to do is download the init.sh zip , extract it ( Taken from AdrianDC's repo , attached below as init_sh_original.zip) and open it up with an editor.
Here are some things you need to keep in mind as you start reading it.
The Left LED of our phone is LED3
The Middle LED is LED1 and
The Right LED is LED2
Also
Here the letter in between both the underscores R/G/B stands for Red/Green/Blue colors
BRIGHTNESS_FILE is where we set the maximum brightness value ( value ranges from 0 - 255 so max we generally set is 255)
and CURRENT_FILE is the file where in we set the brightness of the LED at that time.
Now that you know this, let's get to the first important (relative to this guide) lines of the script.
At lines 6-24 ,
So basically, what these lines of codes say is nothing but the file locations for BRIGHTNESS and CURRENT of each LED with it's respective primary color.
Next on
Lines 55 - 126
Here, if the system detects a normal boot and not recovery, then these lines are executed in the script.
So we don't boot into recovery. But just do a normal reboot.
What happens here is
Firstly, see these lines
These basically set the maximum value of the LED's brightness we are going to use to 255
The command echo is one that gives / print if you may say and here > redirects the echo command onto the path given
Example: echo 'a' > abc.txt would make the file abc.txt have a added in it.
So here echo '255' > $LED1_G_BRIGHTNESS_FILE gives a value of 255 into the brightness file of LED1_G and so on.
So once all the LED's we are going to use are activated, it goes to the next path.
The one we're interested in.
The Animation/Sequence of LED's
See lines 65-125
Here we specify which LED gets which brightness and we give the delay in between a few brightness settings
Same as before
echo '64' > $LED3_G_CURRENT_FILE does nothing but give a value 64 to the current file of LED3_G
So what this does is give a definite value with which that respective LED glows
The next command here is
Here busybox, is the same as the busybox we all know. And sleep is a command we give to busybox and the value we give after it is the time in seconds
So the above command is nothing but telling it to sleep for 0.05 seconds. This is same as giving a delay of 0.05 seconds.
Now that the required stuff is cleared out, let's see what's going on in there.
Firstly, all the LED's are given a definite brightness in Green , and the brightness is increased upto a value and then slowly, symmetrically decreased back until zero. Then even the brightness file of Green LED's are given zero because they aren't needed anymore.
So this gives a breathing effect into all of the LED's in a green color.
Same goes for the next part except, Green is replaced with Red, even at the end of this the LED's are given 0 to both Brightness and current files.
Okay that's done for this part of the code.
Next from lines 128 to 135 we see a breakage in our code, why is that?
These lines of code are to check whether we've chosen to boot into system or chosen to boot into recovery.
So incase the keycheck is toggled and the correct button combination is pressed, then it'll execute lines 131-171
Else
It'll go and execute 174 to end. These last two sequences(recovery / boot into android system), you will be able to interpret since I've told the basics above.
Now that you know the required stuff on how init.sh works and how the LED's are programmed into a sequence, the only thing left out is for you to unleash your creativity and change the LED positions, delay, brightness values, give combination of colors to a single LED at the same time to create a new color (other than RGB) and what not.
Hopefully you will be able to make your own custom Boot Sequence now.
It might not be easy and will take multiple tries for it to be quite perfect, but in case you do something wrong, all you need to do is just flash the old kernel and things will be back to normal
You attached a initsh_replacer.zip in the attachments, what am I supposed to do with it?
Simple.
To save the trouble of having to rebuild a kernel on a PC I've asked tomoms to slightly edit his tangerine kernel zip ( Made from nosedive's anykernel template) to suit for just and only replacing init.sh.
So what you've to do once you've made a custom init.sh is to extract that zip, go to the folder tools and delete the init.sh in there and replace that with the one you've made and compress both the META-INF and tools folder back into a zip file and flash it and enjoy your own custom boot sequence
If there are any queries or some part about this guide you didn't understand, please do reply to this thread. Also if you've made any custom boot sequence, please do share it here for everyone else to enjoy
Cheers and have fun
Hey guys.
So, most of us have been using the SP since many months / couple of years by now and majority of us like the beautiful LED bar at the bottom and could probably even be the reason you've bought one.
So this guide here is another guide focused on that aspect of our phone. The LED Illumination bar.
As the title suggest, this guide will definitely help you learn how the Boot LED animation occurs and I will be giving you some tips and hints on how to create your own LED Boot sequence.
Requirements:
1) An Xperia SP rooted, bootloader unlocked, must be running a recent 5.1.1 LP ROM
2) An init.sh replacer template made by @Tomoms using @nosedive 's anykernel template (Which will be found in the attachments to this post)
3) Patience and a working brain and some more patience with a dash of common sense
4) A good editor like notepad ++ (if on windows) or gedit is more than enough for Linux distributions. (Make sure to enable line numbers in your editor. Mostly the option will be in preferences )
Firstly, I shall explain the file we are going to modify. The init.sh file.
(Note that this is my interpretation of the code and is 99% correct, however if at all there are mistakes in what I explain, please do mention so that I can correct it and update this post.)
So where is this init.sh?
This file is inside sbin folder of root directory of our phone. (/sbin/init.sh)
This init.sh is a part of the ramdisk which is in turn a part of our kernel
So to modify this init.sh , we directly need to edit the ramdisk (thus manually pushing edited init.sh into /sbin/ won't work)
Good. Now you know where this file is. So we proceed to the next step.
What is this file anyway?
It is a script file ( *.sh files are script files . Google for more info) that automatically runs at every startup.
Now what you need to do is download the init.sh zip , extract it ( Taken from AdrianDC's repo , attached below as init_sh_original.zip) and open it up with an editor.
Here are some things you need to keep in mind as you start reading it.
The Left LED of our phone is LED3
The Middle LED is LED1 and
The Right LED is LED2
Also
Code:
LED1_R_BRIGHTNESS_FILE
LED2_G_CURRENT_FILE
LED3_B_BRIGHTNESS_FILE
BRIGHTNESS_FILE is where we set the maximum brightness value ( value ranges from 0 - 255 so max we generally set is 255)
and CURRENT_FILE is the file where in we set the brightness of the LED at that time.
Now that you know this, let's get to the first important (relative to this guide) lines of the script.
At lines 6-24 ,
Code:
# leds paths
LED1_R_BRIGHTNESS_FILE="/sys/class/leds/LED1_R/brightness"
LED2_R_BRIGHTNESS_FILE="/sys/class/leds/LED2_R/brightness"
LED3_R_BRIGHTNESS_FILE="/sys/class/leds/LED3_R/brightness"
LED1_R_CURRENT_FILE="/sys/class/leds/LED1_R/led_current"
LED2_R_CURRENT_FILE="/sys/class/leds/LED2_R/led_current"
LED3_R_CURRENT_FILE="/sys/class/leds/LED3_R/led_current"
LED1_G_BRIGHTNESS_FILE="/sys/class/leds/LED1_G/brightness"
LED2_G_BRIGHTNESS_FILE="/sys/class/leds/LED2_G/brightness"
LED3_G_BRIGHTNESS_FILE="/sys/class/leds/LED3_G/brightness"
LED1_G_CURRENT_FILE="/sys/class/leds/LED1_G/led_current"
LED2_G_CURRENT_FILE="/sys/class/leds/LED2_G/led_current"
LED3_G_CURRENT_FILE="/sys/class/leds/LED3_G/led_current"
LED1_B_BRIGHTNESS_FILE="/sys/class/leds/LED1_B/brightness"
LED2_B_BRIGHTNESS_FILE="/sys/class/leds/LED2_B/brightness"
LED3_B_BRIGHTNESS_FILE="/sys/class/leds/LED3_B/brightness"
LED1_B_CURRENT_FILE="/sys/class/leds/LED1_B/led_current"
LED2_B_CURRENT_FILE="/sys/class/leds/LED2_B/led_current"
LED3_B_CURRENT_FILE="/sys/class/leds/LED3_B/led_current"
Next on
Lines 55 - 126
Here, if the system detects a normal boot and not recovery, then these lines are executed in the script.
So we don't boot into recovery. But just do a normal reboot.
What happens here is
Firstly, see these lines
Code:
# LEDs activated
echo '255' > $LED1_G_BRIGHTNESS_FILE
echo '255' > $LED2_G_BRIGHTNESS_FILE
echo '255' > $LED3_G_BRIGHTNESS_FILE
echo '255' > $LED1_R_BRIGHTNESS_FILE
echo '255' > $LED2_R_BRIGHTNESS_FILE
echo '255' > $LED3_R_BRIGHTNESS_FILE
These basically set the maximum value of the LED's brightness we are going to use to 255
The command echo is one that gives / print if you may say and here > redirects the echo command onto the path given
Example: echo 'a' > abc.txt would make the file abc.txt have a added in it.
So here echo '255' > $LED1_G_BRIGHTNESS_FILE gives a value of 255 into the brightness file of LED1_G and so on.
So once all the LED's we are going to use are activated, it goes to the next path.
The one we're interested in.
The Animation/Sequence of LED's
See lines 65-125
Code:
# LEDs starting animation
echo '16' > $LED1_G_CURRENT_FILE
echo '16' > $LED2_G_CURRENT_FILE
echo '16' > $LED3_G_CURRENT_FILE
busybox sleep 0.05
echo '32' > $LED1_G_CURRENT_FILE
echo '32' > $LED2_G_CURRENT_FILE
echo '32' > $LED3_G_CURRENT_FILE
busybox sleep 0.05
echo '64' > $LED1_G_CURRENT_FILE
echo '64' > $LED2_G_CURRENT_FILE
echo '64' > $LED3_G_CURRENT_FILE
busybox sleep 0.05
echo '92' > $LED1_G_CURRENT_FILE
echo '92' > $LED2_G_CURRENT_FILE
echo '92' > $LED3_G_CURRENT_FILE
busybox sleep 1
echo '64' > $LED1_G_CURRENT_FILE
echo '64' > $LED2_G_CURRENT_FILE
echo '64' > $LED3_G_CURRENT_FILE
busybox sleep 0.05
echo '32' > $LED1_G_CURRENT_FILE
echo '32' > $LED2_G_CURRENT_FILE
echo '32' > $LED3_G_CURRENT_FILE
busybox sleep 0.05
echo '0' > $LED1_G_BRIGHTNESS_FILE
echo '0' > $LED2_G_BRIGHTNESS_FILE
echo '0' > $LED3_G_BRIGHTNESS_FILE
echo '0' > $LED1_G_CURRENT_FILE
echo '0' > $LED2_G_CURRENT_FILE
echo '0' > $LED3_G_CURRENT_FILE
echo '16' > $LED1_R_CURRENT_FILE
echo '16' > $LED2_R_CURRENT_FILE
echo '16' > $LED3_R_CURRENT_FILE
busybox sleep 0.05
echo '32' > $LED1_R_CURRENT_FILE
echo '32' > $LED2_R_CURRENT_FILE
echo '32' > $LED3_R_CURRENT_FILE
busybox sleep 0.05
echo '64' > $LED1_R_CURRENT_FILE
echo '64' > $LED2_R_CURRENT_FILE
echo '64' > $LED3_R_CURRENT_FILE
busybox sleep 0.05
echo '92' > $LED1_R_CURRENT_FILE
echo '92' > $LED2_R_CURRENT_FILE
echo '92' > $LED3_R_CURRENT_FILE
busybox sleep 1
echo '64' > $LED1_R_CURRENT_FILE
echo '64' > $LED2_R_CURRENT_FILE
echo '64' > $LED3_R_CURRENT_FILE
busybox sleep 0.05
echo '32' > $LED1_R_CURRENT_FILE
echo '32' > $LED2_R_CURRENT_FILE
echo '32' > $LED3_R_CURRENT_FILE
busybox sleep 0.05
echo '0' > $LED1_R_BRIGHTNESS_FILE
echo '0' > $LED2_R_BRIGHTNESS_FILE
echo '0' > $LED3_R_BRIGHTNESS_FILE
echo '0' > $LED1_R_CURRENT_FILE
echo '0' > $LED2_R_CURRENT_FILE
echo '0' > $LED3_R_CURRENT_FILE
Same as before
echo '64' > $LED3_G_CURRENT_FILE does nothing but give a value 64 to the current file of LED3_G
So what this does is give a definite value with which that respective LED glows
The next command here is
Code:
busybox sleep 0.05
Here busybox, is the same as the busybox we all know. And sleep is a command we give to busybox and the value we give after it is the time in seconds
So the above command is nothing but telling it to sleep for 0.05 seconds. This is same as giving a delay of 0.05 seconds.
Now that the required stuff is cleared out, let's see what's going on in there.
Firstly, all the LED's are given a definite brightness in Green , and the brightness is increased upto a value and then slowly, symmetrically decreased back until zero. Then even the brightness file of Green LED's are given zero because they aren't needed anymore.
So this gives a breathing effect into all of the LED's in a green color.
Same goes for the next part except, Green is replaced with Red, even at the end of this the LED's are given 0 to both Brightness and current files.
Okay that's done for this part of the code.
Next from lines 128 to 135 we see a breakage in our code, why is that?
Code:
# android ramdisk
load_image=/sbin/ramdisk.cpio
# boot decision
if [ -s /dev/keycheck ] || [ ! -z "$RECOVERY_BOOT" ]; then
busybox echo 'RECOVERY BOOT' >>boot.txt
# LEDs for recovery
busybox echo '100' > /sys/class/timed_output/vibrator/enable
So incase the keycheck is toggled and the correct button combination is pressed, then it'll execute lines 131-171
Else
It'll go and execute 174 to end. These last two sequences(recovery / boot into android system), you will be able to interpret since I've told the basics above.
Now that you know the required stuff on how init.sh works and how the LED's are programmed into a sequence, the only thing left out is for you to unleash your creativity and change the LED positions, delay, brightness values, give combination of colors to a single LED at the same time to create a new color (other than RGB) and what not.
Hopefully you will be able to make your own custom Boot Sequence now.
It might not be easy and will take multiple tries for it to be quite perfect, but in case you do something wrong, all you need to do is just flash the old kernel and things will be back to normal
You attached a initsh_replacer.zip in the attachments, what am I supposed to do with it?
Simple.
To save the trouble of having to rebuild a kernel on a PC I've asked tomoms to slightly edit his tangerine kernel zip ( Made from nosedive's anykernel template) to suit for just and only replacing init.sh.
So what you've to do once you've made a custom init.sh is to extract that zip, go to the folder tools and delete the init.sh in there and replace that with the one you've made and compress both the META-INF and tools folder back into a zip file and flash it and enjoy your own custom boot sequence
If there are any queries or some part about this guide you didn't understand, please do reply to this thread. Also if you've made any custom boot sequence, please do share it here for everyone else to enjoy
Cheers and have fun
Attachments
Last edited: