[Q] [sailfish] Problem with SIM: qmuxd trouble connecting to /dev/hsicctl0 - Xperia Z Q&A, Help & Troubleshooting

Hey guys!
Any Qualcomm gurus out here?
I'm trying to get Sailfish running on my yuga. So far, not much works, thus there is nothing to share. At the moment, I'm stuck at getting my SIM card/phone to work.
As far as I've learned the ril-daemon talks to qmuxd. Stracing qmuxd, I realized that it's stuck at opening /dev/hsicctl0:
[pid 27784] open("/sys/power/wake_lock", O_WRONLY|O_APPEND|O_LARGEFILE) = 4
[pid 27784] open("/sys/power/wake_unlock", O_WRONLY|O_APPEND|O_LARGEFILE) = 5
[pid 27784] open("/sys/module/f_rmnet/parameters/rmnet_ctl_ch", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
[pid 27784] open("/sys/module/rmnet/parameters/rmnet_ctl_ch", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
[pid 27784] open("/sys/devices/virtual/smdpkt/smdcntl0/open_timeout", O_WRONLY|O_LARGEFILE) = 6
[pid 27784] write(6, "20\0", 3) = 3
[pid 27784] open("/sys/devices/virtual/hsicctl/hsicctl0/modem_wait", O_WRONLY|O_LARGEFILE) = 7
[pid 27784] write(7, "60\0", 3) = 3
[pid 27784] close(6) = 0
[pid 27784] close(7) = 0
[pid 27784] brk(0xb8cc8000) = 0xb8cc8000
[pid 27784] open("/dev/hsicctl0", O_RDWR|O_LARGEFILE <unfinished ...>
Click to expand...
Click to collapse
while on Cyanogenmod11, whose binaries are used, I get:
[pid 3110] open("/sys/power/wake_lock", O_WRONLY|O_APPEND) = 10
[pid 3110] open("/sys/power/wake_unlock", O_WRONLY|O_APPEND) = 11
[pid 3110] open("/sys/module/f_rmnet/parameters/rmnet_ctl_ch", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid 3110] open("/sys/module/rmnet/parameters/rmnet_ctl_ch", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid 3110] open("/sys/devices/virtual/smdpkt/smdcntl0/open_timeout", O_WRONLY) = 12
[pid 3110] write(12, "20\0", 3) = 3
[pid 3110] open("/sys/devices/virtual/hsicctl/hsicctl0/modem_wait", O_WRONLY) = 13
[pid 3110] write(13, "60\0", 3) = 3
[pid 3110] close(12) = 0
[pid 3110] close(13) = 0
[pid 3110] brk(0xb7d0b000) = 0xb7d0b000
[pid 3110] open("/dev/hsicctl0", O_RDWR) = 12
[pid 3110] mmap2(NULL, 1040384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0xb6b7c000
[pid 3110] madvise(0xb6b7c000, 1040384, 0xc /* MADV_??? */) = -1 EINVAL (Invalid argument)
[pid 3111] mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0 <unfinished ...>
[pid 3110] mprotect(0xb6b7c000, 4096, PROT_NONE <unfinished ...>
[pid 3111] <... mmap2 resumed> ) = 0xb6b7a000
[pid 3110] <... mprotect resumed> ) = 0
[pid 3111] madvise(0xb6b7a000, 8192, 0xc /* MADV_??? */ <unfinished ...>
[pid 3110] clone( <unfinished ...>
[pid 3111] <... madvise resumed> ) = -1 EINVAL (Invalid argument)
Process 3112 attached
[...]
Click to expand...
Click to collapse
In the kernel log, I find:
hsicctl hsicctl0: rmnet_ctl_open: Error waiting for hsicctl0
Click to expand...
Click to collapse
What could cause this issue?

Related

Pushing for MIUI

Hi all
Tonight (1 Dec) I have time. Lets see how far we can get with MIUI (with whoever is keen).
Check here:
http://forum.xda-developers.com/showthread.php?t=1371428
What my approach this time is is to "dependency inject" MIUI into CM7. That is, start with CM7 base and then add the jars + apks + libs of MIUI from LG's Optimus2X one for one. This is different than starting with MIUI and then changing it with CM files one for one.
Right
Attached is the file list of CM7 nightly and MIUI 1.11.25.
Differences of note:
lgdrmserver
libbridge
liblgdrm
/system/media/gadget files
I'll keep updating on progress! Please do hop on the development, I'm doing all the "beta" testing on my side (thus press thank you and don't post I'll help you test).
Does one need to compile from source <github> or can we just grab files from LG's Optimus2X zip'd MIUI and overwrite the CM7 files? I will also spend some time on this see if I can make some leeway!
Thank you for your help and hard work!!
What does all this mean ?
If I can help with anything? please let me know!! Thanks so much for your efforts!
ssmr2t said:
Thank you for your help and hard work!!
What does all this mean ?
If I can help with anything? please let me know!! Thanks so much for your efforts!
Click to expand...
Click to collapse
Means it might be over your head and should wait till a stable comes out.
Sent from my Inspire
dascope said:
Does one need to compile from source <github> or can we just grab files from LG's Optimus2X zip'd MIUI and overwrite the CM7 files? I will also spend some time on this see if I can make some leeway!
Click to expand...
Click to collapse
Yes, binary files - no compiling. That is, however, what I'm up to.
First up, /system/bin/app_process : zygote, main system daemon.
/system/bin/app_process : No difference in startup.
Next up: framework.jar : The whole platform (will break a lot of things, I'm sure - we'll see)
Ladies and gents, our first boot loop:
W/dalvikvm( 1830): ERROR: Unable to find decl for native Landroid/content/res/AssetManager;.splitThemePackageLjava/lang/String;Ljava/lang/String;[Ljava/lang/StringI
W/dalvikvm( 1830): ERROR: Unable to find decl for native Landroid/content/res/AssetManager;.detachThemePathLjava/lang/String;I)Z
W/dalvikvm( 1830): ERROR: Unable to find decl for native Landroid/content/res/AssetManager;.attachThemePathLjava/lang/StringI
W/dalvikvm( 1830): ERROR: Unable to find decl for native Landroid/content/res/AssetManager;.getBasePackageCount)I
W/dalvikvm( 1830): ERROR: Unable to find decl for native Landroid/content/res/AssetManager;.getBasePackageNameI)Ljava/lang/String;
W/dalvikvm( 1830): ERROR: Unable to find decl for native Landroid/content/res/AssetManager;.getBasePackageIdI)I
W/dalvikvm( 1830): ERROR: Unable to find decl for native Landroid/content/res/AssetManager;.addRedirectionsNativeI)V
W/dalvikvm( 1830): ERROR: Unable to find decl for native Landroid/content/res/AssetManager;.clearRedirectionsNative)V
W/dalvikvm( 1830): ERROR: Unable to find decl for native Landroid/content/res/AssetManager;.generateStyleRedirectionsIII)Z
Seems like a .so that is missing or a .so that needs replacing.
/system/lib/libutils.so is a match - checking.
Solved previous error, now getting this:
I/Netd ( 1741): Netd 1.0 starting
repeatedly.
Getting strace output:
writev(3, [{"\4", 1}, {"Netd\0", 5}, {"Netd 1.0 starting\0", 18}], 3) = 24
brk(0x13000) = 0x13000
socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 9
getpid() = 2106
socket(PF_NETLINK, SOCK_DGRAM, 15) = 10
setsockopt(10, SOL_SOCKET, 0x21 /* SO_??? */, [65536], 4) = 0
setsockopt(10, SOL_SOCKET, SO_PASSCRED, [1], 4) = 0
bind(10, {sa_family=AF_NETLINK, pid=2106, groups=ffffffff}, 12) = 0
mmap2(NULL, 69632, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40009000
getsockopt(10, SOL_SOCKET, SO_PEERCRED, "\0\0\0\0��������", [12]) = 0
pipe([11, 12]) = 0
mmap2(0x10000000, 1048576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x10000000
mprotect(0x10000000, 4096, PROT_NONE) = 0
clone(Process 2108 attached
child_stack=0x100fff00, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_DETACHED) = 2108
[pid 2106] writev(6, [{"\6", 1}, {"SocketListener\0", 15}, {"Obtaining file descriptor socket"..., 79}], 3) = 95
[pid 2106] writev(3, [{"\6", 1}, {"Netd\0", 5}, {"Unable to start DnsProxyListener"..., 61}], 3) = 67
Not entirely helpful. Sockets for system services are normally "premade" in Android in the init.rc file. Will look around, otherwise will check for MIUI version.
service zygote /system/xbin/strace -f -tt -o /cache/debug/boot.strace /system/bin/app_process -Xzygote /system/bin --zygote --start-system-server
Will make strace put out debug of zygote.
Yay for more debug...
No help, make strace of just netd be put out. Argh.
Code:
1697 19:43:35.612710 open("/dev/log/main", O_WRONLY) = 3
1697 19:43:35.612897 open("/dev/log/radio", O_WRONLY) = 4
1697 19:43:35.613083 open("/dev/log/events", O_WRONLY) = 5
1697 19:43:35.625796 open("/dev/log/system", O_WRONLY) = 6
1697 19:43:35.626018 writev(3, [{"\4", 1}, {"Netd\0", 5}, {"Netd 1.0 starting\0", 18}], 3) = 24
1697 19:43:35.626365 brk(0x13000) = 0x13000
1697 19:43:35.626509 socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 7
1697 19:43:35.626663 getpid() = 1697
1697 19:43:35.626785 socket(PF_NETLINK, SOCK_DGRAM, 15) = 11
1697 19:43:35.626952 setsockopt(11, SOL_SOCKET, 0x21 /* SO_??? */, [65536], 4) = 0
1697 19:43:35.627099 setsockopt(11, SOL_SOCKET, SO_PASSCRED, [1], 4) = 0
1697 19:43:35.627234 bind(11, {sa_family=AF_NETLINK, pid=1697, groups=ffffffff}, 12) = 0
1697 19:43:35.627397 mmap2(NULL, 69632, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40009000
1697 19:43:35.627557 getsockopt(11, SOL_SOCKET, SO_PEERCRED, "\0\0\0\0��������", [12]) = 0
1697 19:43:35.627718 pipe([12, 13]) = 0
1697 19:43:35.627891 mmap2(0x10000000, 1048576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x10000000
1697 19:43:35.628027 mprotect(0x10000000, 4096, PROT_NONE) = 0
1697 19:43:35.628173 clone(child_stack=0x100fff00, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_DETACHED) = 1698
1697 19:43:35.628371 listen(9, 4) = 0
1697 19:43:35.628495 pipe([14, 15]) = 0
1697 19:43:35.628648 mmap2(0x10000000, 1048576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x4001a000
1697 19:43:35.628782 mprotect(0x4001a000, 4096, PROT_NONE) = 0
1697 19:43:35.628923 clone(child_stack=0x40119f00, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_DETACHED) = 1699
1697 19:43:35.629080 listen(10, 4) = 0
1697 19:43:35.629203 pipe([16, 17]) = 0
1697 19:43:35.629356 mmap2(0x10000000, 1048576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x4011a000
1697 19:43:35.629521 mprotect(0x4011a000, 4096, PROT_NONE) = 0
1697 19:43:35.629667 clone(child_stack=0x40219f00, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_DETACHED) = 1700
1697 19:43:35.629820 nanosleep({1000, 0}, <unfinished ...>
1698 19:43:35.629966 syscall_983045(0x100fff00, 0x125c8, 0, 0x40, 0x100fff00, 0xaef01e71, 0x40009008, 0xf0005, 0x10000000, 0xaef01e71, 0x100000, 0x40009008, 0, 0x100ffee8, 0xafd120a0, 0xafd0c80c, 0x60000010, 0x100fff00, 0xb729, 0x7665642f, 0x676f6c2f, 0x7379732f, 0x6d6574, 0x64544800, 0x64696f72, 0x6f732e, 0, 0x6f, 0, 0, 0, 0) = 0
1698 19:43:35.630125 select(13, [11 12], NULL, NULL, NULL <unfinished ...>
1699 19:43:35.630262 syscall_983045(0x40119f00, 0x12728, 0, 0x40, 0x40119f00, 0xaef01e71, 0x12678, 0xf0005, 0x4001a000, 0xaef01e71, 0x100000, 0x12678, 0, 0x40119ee8, 0xafd120a0, 0xafd0c80c, 0x60000010, 0x40119f00, 0xb729, 0x7665642f, 0x676f6c2f, 0x7379732f, 0x6d6574, 0x64544800, 0x64696f72, 0x6f732e, 0, 0x6f, 0, 0, 0, 0) = 0
1699 19:43:35.630421 select(15, [9 14], NULL, NULL, NULL <unfinished ...>
1700 19:43:35.630553 syscall_983045(0x40219f00, 0x12768, 0, 0x40, 0x40219f00, 0xaef01e71, 0x112d8, 0xf0005, 0x4011a000, 0xaef01e71, 0x100000, 0x112d8, 0, 0x40219ee8, 0xafd120a0, 0xafd0c80c, 0x60000010, 0x40219f00, 0xb729, 0x7665642f, 0x676f6c2f, 0x7379732f, 0x6d6574, 0x64544800, 0x64696f72, 0x6f732e, 0, 0x6f, 0, 0, 0, 0) = 0
1700 19:43:35.630712 select(17, [10 16], NULL, NULL, NULLULL^C
Before netd fs off into oblivion.
Right, replacing netd then. Not keen - this is suppose to work out of the box.
Did not help. What I can gather:
It loads its libraries fine, and then starts to listen for a connection. Then, a system call syscall_983045 goes unfinished.
Prompting the crash in netd.
Library dependencies for netd seems (so far from strace):
c,sysutils,log,stdc++,m,cutils,netutils,crypto,z,hardware_legacy,utils,binder,wpa_client,bluedroid
Guessing who is the culprit:
Not c (C lib),stdc++ (standard c++ lib),wpa_client(WiFi),bluedroid (BT),hardware_legacy (lights),log (log),m (math), z (compression),crypto (crypto)
Either cutils, sysutils, netutils, binder
Utils ldd:
arm-none-eabi-ld: warning: libz.so, needed by libutils.so, not found (try using -rpath or -rpath-link)
arm-none-eabi-ld: warning: liblog.so, needed by libutils.so, not found (try using -rpath or -rpath-link)
arm-none-eabi-ld: warning: libcutils.so, needed by libutils.so, not found (try using -rpath or -rpath-link)
arm-none-eabi-ld: warning: libc.so, needed by libutils.so, not found (try using -rpath or -rpath-link)
arm-none-eabi-ld: warning: libstdc++.so, needed by libutils.so, not found (try using -rpath or -rpath-link)
arm-none-eabi-ld: warning: libm.so, needed by libutils.so, not found (try using -rpath or -rpath-link)
arm-none-eabi-ld: warning: cannot find entry symbol _start; defaulting to 00008188
Replacing liblog and libcutils with MIUI versions. Lets have a look what breaks next
liblog added the following error:
1973 20:13:37.926040 open("/dev/log/libra", O_WRONLY) = -1 ENOENT (No such file or directory)
Still no change in netd.
Trying libc, see if netd will budge
Googled for syscall_983045
Apparently used to spawn a service. Part of binder.
Replacing binder as well. Crikey
Well if things break due to syscalls not going through, then we've hit a snag on kernel levels.
Anyone got privy on where they hide the MIUI Optimus 2X kernel source?

[Q] How to create an image from a stock KDZ file for nvflashing

Good day to all dev and to the community,
first of, i know this is not the right thread to post but im kinda desperate now.
i purchase a phone which is optimus ex su880 (nearest family is su660)
i tried updating using the LG updater but unfortunately i bricked my phone.
right now, i can no longer boot to S/w / normal mode and my only solution is to flash it via NVflash.
but my problem is, because of the lack of support for this phone. i cant find any image or .bat file to re install the ICS rom back.
now, my question is if we can create a .bat file/image from a Stock KDZ rom?
i can boot to APX but i have no firmware to flash.
your exeperties is highly appreciated.
i already spent 3 days looking for an answer but to no avail...hope you can enlighten me.
Hi alamatnitotoy,
seems that you have to deal with Tegra 250 AP20H a.k.a. Ventana.
In the first place, have you managed to read your partition table?
Can you send me link where I can download the rom for your phone?
Edit: I managed to download v10m kdz. I am flashing to my p990. Hopefuly i could get the necessary files this way to make you an nvflash rom
Edit2: Download my attachment, please. Extract the rar, then run flash.bat. It should flash the bootloader to your phone after that you can put your phone into S/W download mode to flash any original rom.
I hope it is going to work.
thanks
thank you very much sir.. you save my day...
Click, click, click....
How to create, or, can you create it for me?
tryin said:
Click, click, click....
How to create, or, can you create it for me?
Click to expand...
Click to collapse
If you have su880 it will work for you as well, but if your partition layout got damaged it won't.
When I get home I will make a tutorial how to obtain bootloader.
bitdomo said:
If you have su880 it will work for you as well, but if your partition layout got damaged it won't.
When I get home I will make a tutorial how to obtain bootloader.
Click to expand...
Click to collapse
No no sorry, I have been misunderstood, I wanted to say that this posts don't explain how to create an nvflash image from a stock KDZ file, but only have the solution handed on a plate, or better, in an archive , which is not very educational I think...
But if all goes well for alamatnitotoy....
Thanks anyway for your thought, don't worry...
Well, let the tutorial begin!
Download a kdz rom. In my case I downloaded v10m
Download AIO-toolkit for p990
Start AIO-toolkit select option number 5, then select option number 1. Drag and drop the kdz file to the AIO-toolkit window and hit enter. It will convert the kdz file into smartflash format. When the process finished (the smartflash files are in the root directory of the AIO-toolkit in the v10m folder), you can choose to extract the smartflash file. Choose yes. Then select option number 2. On the next screen select option A or E, it does not matter which you choose because the partitions are in a different order in a su880 smartflash file. So, you have to figure out which partition is which after the extraction. I choosed option A. The extracted files will be in the root directory of AIO-toolkit in the extracted_files folder.
Compare the extracted files with any other bootloader file from p990 or su660 to find out which file is the bootloader, but hopefully the file named bootloader.img is truly the bootlader.
SU880 is the brother phone of P990 and SU660, therefore I suggested that the bootloader partition for SU880 is the 4th partition just like for SU660 and P990
Open bootloader.img in hex editor, delete the bunch of FF hex values from the end of the file then save it.
Now you have to download nvflash and copy the bootloader.img to the nvflash folder.
Create a flash.bat file. fill it with this content:
Code:
nvflash.exe --bl bootloader.img --download 4 bootloader.img
Connet your phone in nvflash mode
Double click on flash.bat and hope the best
After the flashing is done restart your phone to S/W download mode and smartflash the previously converted rom to smarthflash format
Now you have a working su880 with a bootloader which you can use with nvflash
To create an nvflash rom, you need the following files:
bootloader (we have it already)
partition table configuration file
bct file (Binary Configuration Table)
system.img
boot.img (kernel)
recovery.img
Obtaining partition table:
Connect phone in nvflash mode and run nvflash with the following command:
Code:
nvflash.exe --bl bootloader.img --getpartitiontable su880_pt_table.txt
Now you have to convert it by hand to a partition config file. Use su660 or p990 config files as a sample to create it for su880.
Rename the file to partition.cfg
The rest of the files:
You have 2 ways to get the rest of the files by figuring out which extraded files are which files, or use nvflash.
If you choose nvflash then you can read back the partitions from your phone to your computer by this command:
Code:
nvflash.exe --bl bootloader.img --read N FILENAME
N is for the number of the partition and FILENAME is for the name of the file you want to save. After the firt partition read use this command to save the rest of the partitions
Code:
nvflash.exe -r --download N FILENAME
Check the partition config file for which partition has which number.
Name of the partition you need:
APP: system.img
LNX: boot.img (kernel)
SOS: recovery.img
When you read back all partition on the list above (or figured whcih extracted partition file is which partition) then you have to obtain the bct file.
Obtaining bct file:
Run nvflash with this command:
Code:
nvflash.exe --bct su880.bct --getbct --bl bootloader.img
After the command got execudet you will have the btc file on your computer.
Now you have everything. Just one thing left.
Create a flash.bat file and fill it with this content:
Code:
nvflash.exe --bct su880.bct --setbct --odmdata 0xC8000 --configfile partition.cfg --create --bl bootloader.img --go
I haven't tested it yet, because I don't have su880 phone. The only thing which bothers is that I am not 100% sure that my partition config file is correct. I am uploading my work, maybe you can test, but there is a high chance it will brick your phone. I beleive you can still smartflash any rom if you try it and it bricks your phone. I tried it on my p990 just for testing every script is written correctly and I don't made a typo. So it flashed correctly, but since my phone is not a su880 I can not tell is it going to work.
Finally my work is uploaded. Download here
Very good work bitdomo!
Sure very instructive!
Only one question, what's the meaning of
Code:
--odmdata 0xC8000
? Why that address?
tryin said:
Very good work bitdomo!
Sure very instructive!
Only one question, what's the meaning of
Code:
--odmdata 0xC8000
? Why that address?
Click to expand...
Click to collapse
Actually I don't know what is that, I would love to know it as well. This addres is there in every nvflash rom for su660 and p990. To get this information you have to extract the bct file.
The program which extract bct file is here. You have to compile it on linux. At the end of this read me there is an example how to use this program.
Performing that command for su880.btc will lead you to a file like this:
Code:
Version = 0x00020001;
BlockSize = 0x00004000;
PageSize = 0x00000200;
PartitionSize = 0x01000000;
OdmData = 0x000c8000;
# Bootloader used = 1;
# Bootloaders max = 4;
# BCT size = 4080;
# Hash size = 16;
# Crypto offset = 16;
# Crypto length = 4064;
# Max BCT search blocks = 64;
#
# These values are set by cbootimage using the
# bootloader provided by the Bootloader=...
# configuration option.
#
# Bootloader[0].Version = 0x00000001;
# Bootloader[0].Start block = 384;
# Bootloader[0].Start page = 0;
# Bootloader[0].Length = 923444;
# Bootloader[0].Load address = 0x00108000;
# Bootloader[0].Entry point = 0x00108000;
# Bootloader[0].Attributes = 0x00000004;
SDRAM[0].MemoryType = NvBootMemoryType_LpDdr2;
SDRAM[0].PllMChargePumpSetupControl = 0x00000008;
SDRAM[0].PllMLoopFilterSetupControl = 0x00000000;
SDRAM[0].PllMInputDivider = 0x0000000c;
SDRAM[0].PllMFeedbackDivider = 0x000002f8;
SDRAM[0].PllMPostDivider = 0x00000000;
SDRAM[0].PllMStableTime = 0x0000012c;
SDRAM[0].EmcClockDivider = 0x00000001;
SDRAM[0].EmcAutoCalInterval = 0x00000000;
SDRAM[0].EmcAutoCalConfig = 0xe0a61111;
SDRAM[0].EmcAutoCalWait = 0x00000000;
SDRAM[0].EmcPinProgramWait = 0x00000000;
SDRAM[0].EmcRc = 0x00000017;
SDRAM[0].EmcRfc = 0x00000032;
SDRAM[0].EmcRas = 0x00000010;
SDRAM[0].EmcRp = 0x00000007;
SDRAM[0].EmcR2w = 0x00000008;
SDRAM[0].EmcW2r = 0x00000005;
SDRAM[0].EmcR2p = 0x00000003;
SDRAM[0].EmcW2p = 0x0000000b;
SDRAM[0].EmcRrd = 0x00000004;
SDRAM[0].EmcRdRcd = 0x00000007;
SDRAM[0].EmcWrRcd = 0x00000007;
SDRAM[0].EmcRext = 0x00000003;
SDRAM[0].EmcWdv = 0x00000003;
SDRAM[0].EmcQUseExtra = 0x00000006;
SDRAM[0].EmcQUse = 0x00000007;
SDRAM[0].EmcQRst = 0x00000004;
SDRAM[0].EmcQSafe = 0x0000000a;
SDRAM[0].EmcRdv = 0x0000000e;
SDRAM[0].EmcRefresh = 0x0000059f;
SDRAM[0].EmcBurstRefreshNum = 0x00000000;
SDRAM[0].EmcPdEx2Wr = 0x00000004;
SDRAM[0].EmcPdEx2Rd = 0x00000004;
SDRAM[0].EmcPChg2Pden = 0x00000007;
SDRAM[0].EmcAct2Pden = 0x00000008;
SDRAM[0].EmcAr2Pden = 0x00000001;
SDRAM[0].EmcRw2Pden = 0x00000011;
SDRAM[0].EmcTxsr = 0x00000036;
SDRAM[0].EmcTcke = 0x00000003;
SDRAM[0].EmcTfaw = 0x00000013;
SDRAM[0].EmcTrpab = 0x00000008;
SDRAM[0].EmcTClkStable = 0x00000007;
SDRAM[0].EmcTClkStop = 0x00000002;
SDRAM[0].EmcTRefBw = 0x0000062d;
SDRAM[0].EmcFbioCfg1 = 0x00000000;
SDRAM[0].EmcFbioDqsibDlyMsb = 0x00000000;
SDRAM[0].EmcFbioDqsibDly = 0x2c2c2c2c;
SDRAM[0].EmcFbioQuseDlyMsb = 0x00000000;
SDRAM[0].EmcFbioQuseDly = 0x14141414;
SDRAM[0].EmcFbioCfg5 = 0x00000282;
SDRAM[0].EmcFbioCfg6 = 0x00000003;
SDRAM[0].EmcFbioSpare = 0x00000000;
SDRAM[0].EmcMrsResetDllWait = 0x00000000;
SDRAM[0].EmcMrsResetDll = 0x00000000;
SDRAM[0].EmcMrsDdr2DllReset = 0x00000000;
SDRAM[0].EmcMrs = 0x00000000;
SDRAM[0].EmcEmrsEmr2 = 0x00000000;
SDRAM[0].EmcEmrsEmr3 = 0x00000000;
SDRAM[0].EmcEmrsDdr2DllEnable = 0x00000000;
SDRAM[0].EmcEmrsDdr2OcdCalib = 0x00000000;
SDRAM[0].EmcEmrs = 0x00000000;
SDRAM[0].EmcMrw1 = 0x0001008a;
SDRAM[0].EmcMrw2 = 0x00020004;
SDRAM[0].EmcMrw3 = 0x00030002;
SDRAM[0].EmcMrwResetCommand = 0x003f0000;
SDRAM[0].EmcMrwResetNInitWait = 0x0000000a;
SDRAM[0].EmcAdrCfg1 = 0x00070303;
SDRAM[0].EmcAdrCfg = 0x01070303;
SDRAM[0].McEmemCfg = 0x00100000;
SDRAM[0].McLowLatencyConfig = 0x80000003;
SDRAM[0].EmcCfg2 = 0x00000403;
SDRAM[0].EmcCfgDigDll = 0xf0000413;
SDRAM[0].EmcCfgClktrim0 = 0x00000000;
SDRAM[0].EmcCfgClktrim1 = 0x00000000;
SDRAM[0].EmcCfgClktrim2 = 0x00000000;
SDRAM[0].EmcCfg = 0x0001ff00;
SDRAM[0].EmcDbg = 0x01000020;
SDRAM[0].AhbArbitrationXbarCtrl = 0x00010000;
SDRAM[0].EmcDllXformDqs = 0x00000010;
SDRAM[0].EmcDllXformQUse = 0x00000008;
SDRAM[0].WarmBootWait = 0x00000001;
SDRAM[0].EmcCttTermCtrl = 0x00000802;
SDRAM[0].EmcOdtWrite = 0x00000000;
SDRAM[0].EmcOdtRead = 0x00000000;
SDRAM[0].EmcZcalRefCnt = 0x00000000;
SDRAM[0].EmcZcalWaitCnt = 0x00000023;
SDRAM[0].EmcZcalMrwCmd = 0x000a0056;
SDRAM[0].EmcMrwZqInitDev0 = 0x800a00ff;
SDRAM[0].EmcMrwZqInitDev1 = 0x400a00ff;
SDRAM[0].EmcMrwZqInitWait = 0x00000001;
SDRAM[0].EmcDdr2Wait = 0x00000000;
SDRAM[0].PmcDdrPwr = 0x00000000;
SDRAM[0].ApbMiscGpXm2CfgAPadCtrl = 0x77ffc000;
SDRAM[0].ApbMiscGpXm2CfgCPadCtrl2 = 0x08080040;
SDRAM[0].ApbMiscGpXm2CfgCPadCtrl = 0x77fffff8;
SDRAM[0].ApbMiscGpXm2CfgDPadCtrl2 = 0x00000000;
SDRAM[0].ApbMiscGpXm2CfgDPadCtrl = 0x77fffff8;
SDRAM[0].ApbMiscGpXm2ClkCfgPadCtrl = 0x77ffc000;
SDRAM[0].ApbMiscGpXm2CompPadCtrl = 0x01f1f008;
SDRAM[0].ApbMiscGpXm2VttGenPadCtrl = 0x00005500;
For p990:
Code:
Version = 0x00020001;
BlockSize = 0x00004000;
PageSize = 0x00000200;
PartitionSize = 0x01000000;
OdmData = 0x000c8000;
# Bootloader used = 0;
# Bootloaders max = 4;
# BCT size = 4080;
# Hash size = 16;
# Crypto offset = 16;
# Crypto length = 4064;
# Max BCT search blocks = 64;
DevType[0] = NvBootDevType_Sdmmc;
DeviceParam[0].SdmmcParams.ClockDivider = 0x0000000c;
DeviceParam[0].SdmmcParams.DataWidth = NvBootSdmmcDataWidth_8Bit;
DeviceParam[0].SdmmcParams.MaxPowerClassSupported = 0x00000000;
DevType[1] = NvBootDevType_Sdmmc;
DeviceParam[1].SdmmcParams.ClockDivider = 0x0000000c;
DeviceParam[1].SdmmcParams.DataWidth = NvBootSdmmcDataWidth_8Bit;
DeviceParam[1].SdmmcParams.MaxPowerClassSupported = 0x00000000;
DevType[2] = NvBootDevType_Sdmmc;
DeviceParam[2].SdmmcParams.ClockDivider = 0x0000000c;
DeviceParam[2].SdmmcParams.DataWidth = NvBootSdmmcDataWidth_8Bit;
DeviceParam[2].SdmmcParams.MaxPowerClassSupported = 0x00000000;
DevType[3] = NvBootDevType_Sdmmc;
DeviceParam[3].SdmmcParams.ClockDivider = 0x0000000c;
DeviceParam[3].SdmmcParams.DataWidth = NvBootSdmmcDataWidth_8Bit;
DeviceParam[3].SdmmcParams.MaxPowerClassSupported = 0x00000000;
SDRAM[0].MemoryType = NvBootMemoryType_LpDdr2;
SDRAM[0].PllMChargePumpSetupControl = 0x00000008;
SDRAM[0].PllMLoopFilterSetupControl = 0x00000000;
SDRAM[0].PllMInputDivider = 0x0000000c;
SDRAM[0].PllMFeedbackDivider = 0x00000258;
SDRAM[0].PllMPostDivider = 0x00000000;
SDRAM[0].PllMStableTime = 0x0000012c;
SDRAM[0].EmcClockDivider = 0x00000001;
SDRAM[0].EmcAutoCalInterval = 0x00000000;
SDRAM[0].EmcAutoCalConfig = 0xe0a61111;
SDRAM[0].EmcAutoCalWait = 0x00000000;
SDRAM[0].EmcPinProgramWait = 0x00000000;
SDRAM[0].EmcRc = 0x00000012;
SDRAM[0].EmcRfc = 0x00000027;
SDRAM[0].EmcRas = 0x0000000d;
SDRAM[0].EmcRp = 0x00000006;
SDRAM[0].EmcR2w = 0x00000007;
SDRAM[0].EmcW2r = 0x00000005;
SDRAM[0].EmcR2p = 0x00000003;
SDRAM[0].EmcW2p = 0x0000000b;
SDRAM[0].EmcRrd = 0x00000003;
SDRAM[0].EmcRdRcd = 0x00000006;
SDRAM[0].EmcWrRcd = 0x00000006;
SDRAM[0].EmcRext = 0x00000003;
SDRAM[0].EmcWdv = 0x00000003;
SDRAM[0].EmcQUseExtra = 0x00000006;
SDRAM[0].EmcQUse = 0x00000007;
SDRAM[0].EmcQRst = 0x00000004;
SDRAM[0].EmcQSafe = 0x00000009;
SDRAM[0].EmcRdv = 0x0000000d;
SDRAM[0].EmcRefresh = 0x0000045f;
SDRAM[0].EmcBurstRefreshNum = 0x00000000;
SDRAM[0].EmcPdEx2Wr = 0x00000004;
SDRAM[0].EmcPdEx2Rd = 0x00000004;
SDRAM[0].EmcPChg2Pden = 0x00000006;
SDRAM[0].EmcAct2Pden = 0x00000008;
SDRAM[0].EmcAr2Pden = 0x00000001;
SDRAM[0].EmcRw2Pden = 0x0000000f;
SDRAM[0].EmcTxsr = 0x0000002a;
SDRAM[0].EmcTcke = 0x00000003;
SDRAM[0].EmcTfaw = 0x0000000f;
SDRAM[0].EmcTrpab = 0x00000007;
SDRAM[0].EmcTClkStable = 0x00000007;
SDRAM[0].EmcTClkStop = 0x00000002;
SDRAM[0].EmcTRefBw = 0x000004e0;
SDRAM[0].EmcFbioCfg1 = 0x00000000;
SDRAM[0].EmcFbioDqsibDlyMsb = 0x00000000;
SDRAM[0].EmcFbioDqsibDly = 0x34343434;
SDRAM[0].EmcFbioQuseDlyMsb = 0x00000000;
SDRAM[0].EmcFbioQuseDly = 0x00000000;
SDRAM[0].EmcFbioCfg5 = 0x00000282;
SDRAM[0].EmcFbioCfg6 = 0x00000002;
SDRAM[0].EmcFbioSpare = 0x00000000;
SDRAM[0].EmcMrsResetDllWait = 0x00000000;
SDRAM[0].EmcMrsResetDll = 0x00000000;
SDRAM[0].EmcMrsDdr2DllReset = 0x00000000;
SDRAM[0].EmcMrs = 0x00000000;
SDRAM[0].EmcEmrsEmr2 = 0x00000000;
SDRAM[0].EmcEmrsEmr3 = 0x00000000;
SDRAM[0].EmcEmrsDdr2DllEnable = 0x00000000;
SDRAM[0].EmcEmrsDdr2OcdCalib = 0x00000000;
SDRAM[0].EmcEmrs = 0x00000000;
SDRAM[0].EmcMrw1 = 0x0001008a;
SDRAM[0].EmcMrw2 = 0x00020004;
SDRAM[0].EmcMrw3 = 0x00030002;
SDRAM[0].EmcMrwResetCommand = 0x003f0000;
SDRAM[0].EmcMrwResetNInitWait = 0x0000000a;
SDRAM[0].EmcAdrCfg1 = 0x00060302;
SDRAM[0].EmcAdrCfg = 0x01060302;
SDRAM[0].McEmemCfg = 0x00080000;
SDRAM[0].McLowLatencyConfig = 0x80000003;
SDRAM[0].EmcCfg2 = 0x00000403;
SDRAM[0].EmcCfgDigDll = 0xe0000413;
SDRAM[0].EmcCfgClktrim0 = 0x00000000;
SDRAM[0].EmcCfgClktrim1 = 0x00000000;
SDRAM[0].EmcCfgClktrim2 = 0x00000000;
SDRAM[0].EmcCfg = 0x0001ff00;
SDRAM[0].EmcDbg = 0x01000020;
SDRAM[0].AhbArbitrationXbarCtrl = 0x00010000;
SDRAM[0].EmcDllXformDqs = 0x00000010;
SDRAM[0].EmcDllXformQUse = 0x00000008;
SDRAM[0].WarmBootWait = 0x00000001;
SDRAM[0].EmcCttTermCtrl = 0x00000802;
SDRAM[0].EmcOdtWrite = 0x00000000;
SDRAM[0].EmcOdtRead = 0x00000000;
SDRAM[0].EmcZcalRefCnt = 0x00000000;
SDRAM[0].EmcZcalWaitCnt = 0x0000001b;
SDRAM[0].EmcZcalMrwCmd = 0x000a0056;
SDRAM[0].EmcMrwZqInitDev0 = 0x800a00ff;
SDRAM[0].EmcMrwZqInitDev1 = 0x400a00ff;
SDRAM[0].EmcMrwZqInitWait = 0x00000001;
SDRAM[0].EmcDdr2Wait = 0x00000000;
SDRAM[0].PmcDdrPwr = 0x00000000;
SDRAM[0].ApbMiscGpXm2CfgAPadCtrl = 0x77ffc000;
SDRAM[0].ApbMiscGpXm2CfgCPadCtrl2 = 0x08080040;
SDRAM[0].ApbMiscGpXm2CfgCPadCtrl = 0x77fffff8;
SDRAM[0].ApbMiscGpXm2CfgDPadCtrl2 = 0x00000000;
SDRAM[0].ApbMiscGpXm2CfgDPadCtrl = 0x77fffff8;
SDRAM[0].ApbMiscGpXm2ClkCfgPadCtrl = 0x77ffc000;
SDRAM[0].ApbMiscGpXm2CompPadCtrl = 0x01f1f008;
SDRAM[0].ApbMiscGpXm2VttGenPadCtrl = 0x00005500;
If you check the begining of the su880.bct config you can see the odmdata is the same as in the p990.bct config.
That is why I put that --odmdata 0xc8000.
I downloaded bct_dump some time ago, from here, but this is my BCT file:
Version = 0x00020001;
BlockSize = 0x00004000;
PageSize = 0x00000200;
PartitionSize = 0x01000000;
# Bootloader used = 1;
# Bootloaders max = 4;
# BCT size = 4080;
# Hash size = 16;
# Crypto offset = 16;
# Crypto length = 4064;
# Max BCT search blocks = 64;
#
# These values are set by cbootimage using the
# bootloader provided by the Bootloader=...
# configuration option.
#
# Bootloader[0].Version = 0x00000001;
# Bootloader[0].Start block = 288;
# Bootloader[0].Start page = 0;
# Bootloader[0].Length = 891020;
# Bootloader[0].Load address = 0x00108000;
# Bootloader[0].Entry point = 0x00108000;
# Bootloader[0].Attributes = 0x00000004;
DevType[0] = NvBootDevType_Sdmmc;
DeviceParam[0].SdmmcParams.ClockDivider = 0x0000000c;
DeviceParam[0].SdmmcParams.DataWidth = NvBootSdmmcDataWidth_8Bit;
DeviceParam[0].SdmmcParams.MaxPowerClassSupported = 0x00000000;
DevType[1] = NvBootDevType_Sdmmc;
DeviceParam[1].SdmmcParams.ClockDivider = 0x0000000c;
DeviceParam[1].SdmmcParams.DataWidth = NvBootSdmmcDataWidth_8Bit;
DeviceParam[1].SdmmcParams.MaxPowerClassSupported = 0x00000000;
DevType[2] = NvBootDevType_Sdmmc;
DeviceParam[2].SdmmcParams.ClockDivider = 0x0000000c;
DeviceParam[2].SdmmcParams.DataWidth = NvBootSdmmcDataWidth_8Bit;
DeviceParam[2].SdmmcParams.MaxPowerClassSupported = 0x00000000;
DevType[3] = NvBootDevType_Sdmmc;
DeviceParam[3].SdmmcParams.ClockDivider = 0x0000000c;
DeviceParam[3].SdmmcParams.DataWidth = NvBootSdmmcDataWidth_8Bit;
DeviceParam[3].SdmmcParams.MaxPowerClassSupported = 0x00000000;
SDRAM[0].MemoryType = NvBootMemoryType_LpDdr2;
SDRAM[0].PllMChargePumpSetupControl = 0x00000008;
SDRAM[0].PllMLoopFilterSetupControl = 0x00000000;
SDRAM[0].PllMInputDivider = 0x0000000c;
SDRAM[0].PllMFeedbackDivider = 0x00000258;
SDRAM[0].PllMPostDivider = 0x00000000;
SDRAM[0].PllMStableTime = 0x0000012c;
SDRAM[0].EmcClockDivider = 0x00000001;
SDRAM[0].EmcAutoCalInterval = 0x00000000;
SDRAM[0].EmcAutoCalConfig = 0xe0a61111;
SDRAM[0].EmcAutoCalWait = 0x00000000;
SDRAM[0].EmcPinProgramWait = 0x00000000;
SDRAM[0].EmcRc = 0x00000012;
SDRAM[0].EmcRfc = 0x00000027;
SDRAM[0].EmcRas = 0x0000000d;
SDRAM[0].EmcRp = 0x00000006;
SDRAM[0].EmcR2w = 0x00000007;
SDRAM[0].EmcW2r = 0x00000005;
SDRAM[0].EmcR2p = 0x00000003;
SDRAM[0].EmcW2p = 0x0000000b;
SDRAM[0].EmcRrd = 0x00000003;
SDRAM[0].EmcRdRcd = 0x00000006;
SDRAM[0].EmcWrRcd = 0x00000006;
SDRAM[0].EmcRext = 0x00000003;
SDRAM[0].EmcWdv = 0x00000003;
SDRAM[0].EmcQUseExtra = 0x00000006;
SDRAM[0].EmcQUse = 0x00000007;
SDRAM[0].EmcQRst = 0x00000004;
SDRAM[0].EmcQSafe = 0x00000009;
SDRAM[0].EmcRdv = 0x0000000d;
SDRAM[0].EmcRefresh = 0x0000045f;
SDRAM[0].EmcBurstRefreshNum = 0x00000000;
SDRAM[0].EmcPdEx2Wr = 0x00000004;
SDRAM[0].EmcPdEx2Rd = 0x00000004;
SDRAM[0].EmcPChg2Pden = 0x00000006;
SDRAM[0].EmcAct2Pden = 0x00000008;
SDRAM[0].EmcAr2Pden = 0x00000001;
SDRAM[0].EmcRw2Pden = 0x0000000f;
SDRAM[0].EmcTxsr = 0x0000002a;
SDRAM[0].EmcTcke = 0x00000003;
SDRAM[0].EmcTfaw = 0x0000000f;
SDRAM[0].EmcTrpab = 0x00000007;
SDRAM[0].EmcTClkStable = 0x00000007;
SDRAM[0].EmcTClkStop = 0x00000002;
SDRAM[0].EmcTRefBw = 0x000004e0;
SDRAM[0].EmcFbioCfg1 = 0x00000000;
SDRAM[0].EmcFbioDqsibDlyMsb = 0x00000000;
SDRAM[0].EmcFbioDqsibDly = 0x34343434;
SDRAM[0].EmcFbioQuseDlyMsb = 0x00000000;
SDRAM[0].EmcFbioQuseDly = 0x00000000;
SDRAM[0].EmcFbioCfg5 = 0x00000282;
SDRAM[0].EmcFbioCfg6 = 0x00000002;
SDRAM[0].EmcFbioSpare = 0x00000000;
SDRAM[0].EmcMrsResetDllWait = 0x00000000;
SDRAM[0].EmcMrsResetDll = 0x00000000;
SDRAM[0].EmcMrsDdr2DllReset = 0x00000000;
SDRAM[0].EmcMrs = 0x00000000;
SDRAM[0].EmcEmrsEmr2 = 0x00000000;
SDRAM[0].EmcEmrsEmr3 = 0x00000000;
SDRAM[0].EmcEmrsDdr2DllEnable = 0x00000000;
SDRAM[0].EmcEmrsDdr2OcdCalib = 0x00000000;
SDRAM[0].EmcEmrs = 0x00000000;
SDRAM[0].EmcMrw1 = 0x0001008a;
SDRAM[0].EmcMrw2 = 0x00020004;
SDRAM[0].EmcMrw3 = 0x00030002;
SDRAM[0].EmcMrwResetCommand = 0x003f0000;
SDRAM[0].EmcMrwResetNInitWait = 0x0000000a;
SDRAM[0].EmcAdrCfg1 = 0x00060302;
SDRAM[0].EmcAdrCfg = 0x01060302;
SDRAM[0].McEmemCfg = 0x00080000;
SDRAM[0].McLowLatencyConfig = 0x80000003;
SDRAM[0].EmcCfg2 = 0x00000403;
SDRAM[0].EmcCfgDigDll = 0xe0000413;
SDRAM[0].EmcCfgClktrim0 = 0x00000000;
SDRAM[0].EmcCfgClktrim1 = 0x00000000;
SDRAM[0].EmcCfgClktrim2 = 0x00000000;
SDRAM[0].EmcCfg = 0x0001ff00;
SDRAM[0].EmcDbg = 0x01000020;
SDRAM[0].AhbArbitrationXbarCtrl = 0x00010000;
SDRAM[0].EmcDllXformDqs = 0x00000010;
SDRAM[0].EmcDllXformQUse = 0x00000008;
SDRAM[0].WarmBootWait = 0x00000001;
SDRAM[0].EmcCttTermCtrl = 0x00000802;
SDRAM[0].EmcOdtWrite = 0x00000000;
SDRAM[0].EmcOdtRead = 0x00000000;
SDRAM[0].EmcZcalRefCnt = 0x00000000;
SDRAM[0].EmcZcalWaitCnt = 0x0000001b;
SDRAM[0].EmcZcalMrwCmd = 0x000a0056;
SDRAM[0].EmcMrwZqInitDev0 = 0x800a00ff;
SDRAM[0].EmcMrwZqInitDev1 = 0x400a00ff;
SDRAM[0].EmcMrwZqInitWait = 0x00000001;
SDRAM[0].EmcDdr2Wait = 0x00000000;
SDRAM[0].PmcDdrPwr = 0x00000000;
SDRAM[0].ApbMiscGpXm2CfgAPadCtrl = 0x77ffc000;
SDRAM[0].ApbMiscGpXm2CfgCPadCtrl2 = 0x08080040;
SDRAM[0].ApbMiscGpXm2CfgCPadCtrl = 0x77fffff8;
SDRAM[0].ApbMiscGpXm2CfgDPadCtrl2 = 0x00000000;
SDRAM[0].ApbMiscGpXm2CfgDPadCtrl = 0x77fffff8;
SDRAM[0].ApbMiscGpXm2ClkCfgPadCtrl = 0x77ffc000;
SDRAM[0].ApbMiscGpXm2CompPadCtrl = 0x01f1f008;
SDRAM[0].ApbMiscGpXm2VttGenPadCtrl = 0x00005500;
tryin said:
I downloaded bct_dump some time ago, from here, but this is my BCT file:
Version = 0x00020001;
BlockSize = 0x00004000;
PageSize = 0x00000200;
PartitionSize = 0x01000000;
# Bootloader used = 1;
# Bootloaders max = 4;
# BCT size = 4080;
# Hash size = 16;
# Crypto offset = 16;
# Crypto length = 4064;
# Max BCT search blocks = 64;
#
# These values are set by cbootimage using the
# bootloader provided by the Bootloader=...
# configuration option.
#
# Bootloader[0].Version = 0x00000001;
# Bootloader[0].Start block = 288;
# Bootloader[0].Start page = 0;
# Bootloader[0].Length = 891020;
# Bootloader[0].Load address = 0x00108000;
# Bootloader[0].Entry point = 0x00108000;
# Bootloader[0].Attributes = 0x00000004;
DevType[0] = NvBootDevType_Sdmmc;
DeviceParam[0].SdmmcParams.ClockDivider = 0x0000000c;
DeviceParam[0].SdmmcParams.DataWidth = NvBootSdmmcDataWidth_8Bit;
DeviceParam[0].SdmmcParams.MaxPowerClassSupported = 0x00000000;
DevType[1] = NvBootDevType_Sdmmc;
DeviceParam[1].SdmmcParams.ClockDivider = 0x0000000c;
DeviceParam[1].SdmmcParams.DataWidth = NvBootSdmmcDataWidth_8Bit;
DeviceParam[1].SdmmcParams.MaxPowerClassSupported = 0x00000000;
DevType[2] = NvBootDevType_Sdmmc;
DeviceParam[2].SdmmcParams.ClockDivider = 0x0000000c;
DeviceParam[2].SdmmcParams.DataWidth = NvBootSdmmcDataWidth_8Bit;
DeviceParam[2].SdmmcParams.MaxPowerClassSupported = 0x00000000;
DevType[3] = NvBootDevType_Sdmmc;
DeviceParam[3].SdmmcParams.ClockDivider = 0x0000000c;
DeviceParam[3].SdmmcParams.DataWidth = NvBootSdmmcDataWidth_8Bit;
DeviceParam[3].SdmmcParams.MaxPowerClassSupported = 0x00000000;
SDRAM[0].MemoryType = NvBootMemoryType_LpDdr2;
SDRAM[0].PllMChargePumpSetupControl = 0x00000008;
SDRAM[0].PllMLoopFilterSetupControl = 0x00000000;
SDRAM[0].PllMInputDivider = 0x0000000c;
SDRAM[0].PllMFeedbackDivider = 0x00000258;
SDRAM[0].PllMPostDivider = 0x00000000;
SDRAM[0].PllMStableTime = 0x0000012c;
SDRAM[0].EmcClockDivider = 0x00000001;
SDRAM[0].EmcAutoCalInterval = 0x00000000;
SDRAM[0].EmcAutoCalConfig = 0xe0a61111;
SDRAM[0].EmcAutoCalWait = 0x00000000;
SDRAM[0].EmcPinProgramWait = 0x00000000;
SDRAM[0].EmcRc = 0x00000012;
SDRAM[0].EmcRfc = 0x00000027;
SDRAM[0].EmcRas = 0x0000000d;
SDRAM[0].EmcRp = 0x00000006;
SDRAM[0].EmcR2w = 0x00000007;
SDRAM[0].EmcW2r = 0x00000005;
SDRAM[0].EmcR2p = 0x00000003;
SDRAM[0].EmcW2p = 0x0000000b;
SDRAM[0].EmcRrd = 0x00000003;
SDRAM[0].EmcRdRcd = 0x00000006;
SDRAM[0].EmcWrRcd = 0x00000006;
SDRAM[0].EmcRext = 0x00000003;
SDRAM[0].EmcWdv = 0x00000003;
SDRAM[0].EmcQUseExtra = 0x00000006;
SDRAM[0].EmcQUse = 0x00000007;
SDRAM[0].EmcQRst = 0x00000004;
SDRAM[0].EmcQSafe = 0x00000009;
SDRAM[0].EmcRdv = 0x0000000d;
SDRAM[0].EmcRefresh = 0x0000045f;
SDRAM[0].EmcBurstRefreshNum = 0x00000000;
SDRAM[0].EmcPdEx2Wr = 0x00000004;
SDRAM[0].EmcPdEx2Rd = 0x00000004;
SDRAM[0].EmcPChg2Pden = 0x00000006;
SDRAM[0].EmcAct2Pden = 0x00000008;
SDRAM[0].EmcAr2Pden = 0x00000001;
SDRAM[0].EmcRw2Pden = 0x0000000f;
SDRAM[0].EmcTxsr = 0x0000002a;
SDRAM[0].EmcTcke = 0x00000003;
SDRAM[0].EmcTfaw = 0x0000000f;
SDRAM[0].EmcTrpab = 0x00000007;
SDRAM[0].EmcTClkStable = 0x00000007;
SDRAM[0].EmcTClkStop = 0x00000002;
SDRAM[0].EmcTRefBw = 0x000004e0;
SDRAM[0].EmcFbioCfg1 = 0x00000000;
SDRAM[0].EmcFbioDqsibDlyMsb = 0x00000000;
SDRAM[0].EmcFbioDqsibDly = 0x34343434;
SDRAM[0].EmcFbioQuseDlyMsb = 0x00000000;
SDRAM[0].EmcFbioQuseDly = 0x00000000;
SDRAM[0].EmcFbioCfg5 = 0x00000282;
SDRAM[0].EmcFbioCfg6 = 0x00000002;
SDRAM[0].EmcFbioSpare = 0x00000000;
SDRAM[0].EmcMrsResetDllWait = 0x00000000;
SDRAM[0].EmcMrsResetDll = 0x00000000;
SDRAM[0].EmcMrsDdr2DllReset = 0x00000000;
SDRAM[0].EmcMrs = 0x00000000;
SDRAM[0].EmcEmrsEmr2 = 0x00000000;
SDRAM[0].EmcEmrsEmr3 = 0x00000000;
SDRAM[0].EmcEmrsDdr2DllEnable = 0x00000000;
SDRAM[0].EmcEmrsDdr2OcdCalib = 0x00000000;
SDRAM[0].EmcEmrs = 0x00000000;
SDRAM[0].EmcMrw1 = 0x0001008a;
SDRAM[0].EmcMrw2 = 0x00020004;
SDRAM[0].EmcMrw3 = 0x00030002;
SDRAM[0].EmcMrwResetCommand = 0x003f0000;
SDRAM[0].EmcMrwResetNInitWait = 0x0000000a;
SDRAM[0].EmcAdrCfg1 = 0x00060302;
SDRAM[0].EmcAdrCfg = 0x01060302;
SDRAM[0].McEmemCfg = 0x00080000;
SDRAM[0].McLowLatencyConfig = 0x80000003;
SDRAM[0].EmcCfg2 = 0x00000403;
SDRAM[0].EmcCfgDigDll = 0xe0000413;
SDRAM[0].EmcCfgClktrim0 = 0x00000000;
SDRAM[0].EmcCfgClktrim1 = 0x00000000;
SDRAM[0].EmcCfgClktrim2 = 0x00000000;
SDRAM[0].EmcCfg = 0x0001ff00;
SDRAM[0].EmcDbg = 0x01000020;
SDRAM[0].AhbArbitrationXbarCtrl = 0x00010000;
SDRAM[0].EmcDllXformDqs = 0x00000010;
SDRAM[0].EmcDllXformQUse = 0x00000008;
SDRAM[0].WarmBootWait = 0x00000001;
SDRAM[0].EmcCttTermCtrl = 0x00000802;
SDRAM[0].EmcOdtWrite = 0x00000000;
SDRAM[0].EmcOdtRead = 0x00000000;
SDRAM[0].EmcZcalRefCnt = 0x00000000;
SDRAM[0].EmcZcalWaitCnt = 0x0000001b;
SDRAM[0].EmcZcalMrwCmd = 0x000a0056;
SDRAM[0].EmcMrwZqInitDev0 = 0x800a00ff;
SDRAM[0].EmcMrwZqInitDev1 = 0x400a00ff;
SDRAM[0].EmcMrwZqInitWait = 0x00000001;
SDRAM[0].EmcDdr2Wait = 0x00000000;
SDRAM[0].PmcDdrPwr = 0x00000000;
SDRAM[0].ApbMiscGpXm2CfgAPadCtrl = 0x77ffc000;
SDRAM[0].ApbMiscGpXm2CfgCPadCtrl2 = 0x08080040;
SDRAM[0].ApbMiscGpXm2CfgCPadCtrl = 0x77fffff8;
SDRAM[0].ApbMiscGpXm2CfgDPadCtrl2 = 0x00000000;
SDRAM[0].ApbMiscGpXm2CfgDPadCtrl = 0x77fffff8;
SDRAM[0].ApbMiscGpXm2ClkCfgPadCtrl = 0x77ffc000;
SDRAM[0].ApbMiscGpXm2CompPadCtrl = 0x01f1f008;
SDRAM[0].ApbMiscGpXm2VttGenPadCtrl = 0x00005500;
Click to expand...
Click to collapse
I tested the cbootimg you sent. It does not show OdmData line for me too, but the cbootimg from the nvidia git site shows it.
bitdomo said:
I tested the cbootimg you sent. It does not show OdmData line for me too, but the cbootimg from the nvidia git site shows it.
Click to expand...
Click to collapse
Many thanks for your test, I'll try the nvidia one when i have a minute...
dear bitdomo,
My phone too stuck on logo LG. I try extracting KDZ su880 rom. I have got img files. ( recovery.img, bootloader.img...)
I want to flash them via NVflash but i dont know command... Can you help me command to flash recovery.img & bootloadet.img ?
*my bootloader.img was extracted from su880 KDZ , i think no need EDIT with HEX Editor & delete the bunch of FF hex values from the end of the file.
i try using bootloader.bin in bootloader_installer ultility. Run install_gb_bootloader.bat. Seem all was complete. But cannot connect to S/W mode
Thanks !
Copy every img file to your nvflash folder (bootloader.img, recovery.img, boot.img (kernel) )
Open a cmd.
Go to your nvflash folder in cmd.
Connect phone in APX mode to PC
Type these commands in cmd:
Code:
nvflash.exe --bl bootloader.img --download 4 bootloader.img
nvflash.exe -r --download 6 recovery.img
nvflash.exe -r --download 12 boot.img
nvflash.exe -r --go
(-r = --resume)
Wait until the screen goes off or wait 15-20 seconds then unplug your phone.
If the sending bootloader hangs up at some point then delete the FF hex valuess from the end of the bootloader.img and try again.
You can find a bootloader in my attachment of this post which already has FF hex values removed.
bitdomo said:
Copy every img file to your nvflash folder (bootloader.img, recovery.img, boot.img (kernel) )
Open a cmd.
Go to your nvflash folder in cmd.
Connect phone in APX mode to PC
Type these commands in cmd:
Code:
nvflash.exe --bl bootloader.img --download 4 bootloader.img
nvflash.exe -r --download 6 recovery.img
nvflash.exe -r --download 12 boot.img
nvflash.exe -r --go
(-r = --resume)
Wait until the screen goes off or wait 15-20 seconds then unplug your phone.
If the sending bootloader hangs up at some point then delete the FF hex valuess from the end of the bootloader.img and try again.
You can find a bootloader in my attachment of this post which already has FF hex values removed.
Click to expand...
Click to collapse
There are no words to show my gratitude! I reallythrilling now. My phone was rescued, my friend !
Seem Those commands not working with imgs extract from v19c, bitdomo ? I flash v19c KDZ via MartFlash---> Root---> Install Recovery ( but failed )----> Phone stuck logo LG...
I cannot flash bootloader.img,although i delete the FF hex valuess from the end of the bootloader.img.
I am a bit lost. To make things clear please anwser these questions:
1. If I understand well you were able to unbrick your phone with the instruction I wrote to you. Right?
2. What recovery do you want to flash and how? Send me a link for that recovery or the app which flashes the recovery.
3. Can you post here what error message appears when you try to nvflash bootloader? Copy the content of the whole cmd window here, please.
There is a final version of ics rom v20c for su880. v19c is a beta rom if I am not mistaken. I can send you a link if you are intrested in v20c
Edit: v19c is an ics rom and ics rom has locked bootloader therefore it cannot be used with nvflash. You have to use the bootloader from my attachment to flash v19c bootloader.
nvflash.exe --bl mybootloader.img --download 4 v19cbootloader.img
Sent from my LG-P990 using xda app-developers app
bitdomo said:
I am a bit lost. To make things clear please anwser these questions:
...
Click to expand...
Click to collapse
Thanks for help, bitdomo !
1. I unbricked phone with the instruction you wrote , in the previous with v10m kdz. Then I reflash with v19c KDZ & install recovery ( below tut) , Phone brick.
2. I want to install any recovery to flash a custom rom (Jelly Bean). And i folow this link: http://forum.xda-developers.com/showthread.php?t=2281636
3. cmd window when i flash booloader & recovery img file with the contruction you wrote ( with img files extract from v19c kdz )---> view attachment picture.
4. I use the bootloader from your attachment with edit in BAT file [ nvflash.exe --bl mybootloader.img --download 4 v19cbootloader.img ],then run new BAT file, a cmd window appear in the moment ( about 1/3 second) and disappear. nothing is happend...
If v19c cannot be used with nvflash, can you creat BAT file to run & flash stock recovery v19c ?
picture cmd window

[Q] Need Help

I've tried rooting my lg 4xhd for a few days but every time I try it it just says:
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
DON'T TOUCH THE DEVICE OR UNPLUG WHILE ROOTING!
PUSH FILES
failed to copy 'busybox' to '/data/local/busybox': No such file or direc
failed to copy 'su' to '/data/local/su': No such file or directory
failed to copy 'Superuser.apk' to '/data/local/Superuser.apk': No such f
irectory
- exec '/system/bin/sh' failed: No such file or directory (2) -
read NV size = 4, offset = 0
read NV ret = 4
read NV offset = 0, message = (0)[0]
check_LGE_official: nvdata_buf = , , .
check_LGE_official: enable_root = 1
- exec '/system/bin/sh' failed: No such file or directory (2) -
read NV size = 4, offset = 0
read NV ret = 4
read NV offset = 0, message = (0)[0]
check_LGE_official: nvdata_buf = , , .
check_LGE_official: enable_root = 1
- exec '/system/bin/sh' failed: No such file or directory (2) -
read NV size = 4, offset = 0
read NV ret = 4
read NV offset = 0, message = (0)[0]
check_LGE_official: nvdata_buf = , , .
check_LGE_official: enable_root = 1
- exec '/system/bin/sh' failed: No such file or directory (2) -
read NV size = 4, offset = 0
read NV ret = 4
read NV offset = 0, message = (0)[0]
check_LGE_official: nvdata_buf = , , .
check_LGE_official: enable_root = 1
- exec '/system/bin/sh' failed: No such file or directory (2) -
read NV size = 4, offset = 0
read NV ret = 4
read NV offset = 0, message = (0)[0]
check_LGE_official: nvdata_buf = , , .
check_LGE_official: enable_root = 1
REBOOT
/system/bin/sh: can't create /data/local.prop: Permission denied
AGAIN REBOOT
AGAIN!?
mount: Operation not permitted
mount: Operation not permitted
/system/bin/sh: can't create /system/xbin/busybox: Read-only file system
Unable to chmod /system/xbin/busybox: No such file or directory
/system/bin/sh: /system/xbin/busybox: not found
/system/bin/sh: busybox: not found
/system/bin/sh: busybox: not found
Unable to chown /system/xbin/su: No such file or directory
Unable to chmod /system/xbin/su: No such file or directory
Unable to chmod /system/app/Superuser.apk: No such file or directory
rm failed for /data/local.prop, No such file or directory
rm failed for /data/local/tmp, Permission denied
failed on '/data/local/tmp.bak' - No such file or directory
Now I am not really an expert with complicated stuff but I DID install all the drivers properly. It would be nice if someone could help me in a awnser that I can hopefully understand. Thanks in advance
As the log implies quite clearly, it isn't finding the files to push
Check out you have all required files and that you unpacked everything correctly in proper directories

[TOOL][MOD][WIN] Change Your Splash Screen And Various Graphics v.97B

This is a hybrid batch and C program that I wrote to decode and encode the MotoLogo image container. It will allow you to edit or replace any of the 23 images in your logo partition. Click here to see all of the images. This will also work with any Motorola device utilizing this current format.
The logo partition has nothing to do with your boot animation. Your boot animation actually comes right after the static image, that in this case says "Google" in catull font; and if you have an unlocked bootloader, additionally there will be a little lock that appears to be open (aka "dummy locked") in the bottom center of the screen. Your boot animation follows after this screen goes away, your boot animation is typically animated or dynamic. The static screen with "Google" is known as your splash screen to some, or boot screen to others. This tool allows you to change the static image (splash screen) and not your boot animation.​Thanks to GrayBoltWolf for making this video!!
Download the "MotoLogo Injector v.97b" zip file at the bottom of this post.
Extract the zip file to a new folder.
To use just drag any file that you think might have a MotoLogo container in it onto the batch file "MotoLogo_Injectorv97b.bat" (I have included your Nexus 6 71.05 bootloader image in the zip, so just drag it onto the batch script)
The program will then find the Container in the file, extract it and validate every byte in it, and output it in the "Projects" folder.
A newly created folder will pop up that contains the raw image files, PNG image files, some identification files, and your extracted "logo.bin"
There will also be two new batch files in the folder that will make it easy to close the program, edit the images, then just click one of the batch files to get back into the program to re-encode the images. The difference in the two batch files is that one of them will re-encode the logo bin in a "Strict" way, and the other way is "Non-Strict"
Strict goes in the exact same order that the images were encoded in the first place.
Strict will fail if there are any more or any less images.
Strict will fail if any of the image names are changed.
Strict will check the resolution.
Strict will not let you have a Jpg, Bmp, ....any other format mixed in with the Pngs. (If you prefer to work with another image format, you can change that in the settings but you still can't mix them up inside of the "Images" folder; they should all be of the same type.
If an images resolution doesn't match the original images, it will warn you and give you options to resize or disregard the size difference.
Non-Strict simply goes through every file in the "Images" folder in alphanumerical order and makes it a raw file, encodes it, and puts the MotoLogo container together.
Non-Strict will take all kinds of differently formatted images.
The only reason I can see someone wanting to use Non-Strict is to delete images from a MotoLogo container.
In your "Images" folder is where you either edit or replace the PNG images. You can make them bigger, but I don't know what implications this may have as I do not have a Nexus 6. You must keep the names the exact same as the images, it is okay to change the image or even replace it (that's the whole point) but you have to keep the names the same for Strict mode, which I encourage you to use.
When you are finished editing your images:
You can open up the Original batch program if you haven't used it anymore (it remembers the last file loaded that had a successful validated container in it, so you don't have to drag and drop everytime). And then hit 1 "Rebuild Images Directory (Strict-In Order_Resolution Checks)"
Or you can click on the "Make MotoLogo Bin From Images Folder.bat" to go directly there.
After the program has rebuilt it, it will re validate the container, and then reconvert the container into view-able Pngs again. A new folder will automatically open. This contains your modified container called "build.bin". You can flash it from there.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
This is a beta version, because I do not have a device to test on. So, the things I would normally know, i don't know. For instance:
I don't know if you can change all 23 images in the Nexus 6 bootloader, I assume you can, as they are all stored in the Logo partition. If you can, you can theme your bootloader
I also don't know if you can make certain graphics bigger that may overlap another, like the "Start" button interfering with the "arrows" for the rocker buttons.
You need to stay under the size of your "Logo" partition, I'm pretty sure fastboot just errors out if you try to write more data than a partition can hold. But I would like to know how big the partition mmcblk0p30 is. You could find out by executing the following, and posting the size of the C:\LogoPartition.raw file
Code:
adb shell
su
dd if=/dev/block/mmcblk0p30 of=/mnt/sdcard/LogoPartition.raw
exit
exit
adb pull /sdcard/LogoPartition.raw "C:\LogoPartition.raw"
adb kill-server
You may not need the 'mnt' before the "/sdcard/LogoPartition.raw" in the DD command. Please do not try this if you are not familiar with the command, because you could mess some stuff up if you accidentally reverse the "if" and "of" ​
Thanks to @grim489 for testing changing the logo_boot "Google" image!
I am not responsible for any damage done to your device!! Source is in Posts 2 & 3!
SOURCE:
MotoLogoCodec.c
Code:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#define OUT_FILE "logo.bin"
#define MOTOLOGO_BARE_HEADER 13
#define MOTOLOGO_IMG_BLK_SIZE 32
#define BIT_SET 0x8000
#define IS_BIT_SET(x) (x & BIT_SET)
#define COLORS 3
#define SWAP(x) (((x & 0xFF00) >> 8) | ((x & 0x00FF) << 8))
typedef struct {
unsigned short count;
unsigned char color[COLORS];
} motoSet;
typedef struct {
char header[8];
unsigned short width;
unsigned short height;
} motoHead;
typedef struct {
char name[24];
unsigned long offset;
unsigned long size;
unsigned short totalBlocks;
unsigned long totalSize;
motoHead imageHead;
} imageHead;
typedef struct {
unsigned char r;
unsigned char g;
unsigned char b;
} pixel;
void MotoRunEncode(void);
int FindMotoLogo(void);
int ParseHeader(unsigned long, int);
void CutMRImageOut(int, char*, unsigned long);
unsigned long int BlockIt(unsigned long int);
void MotoDecode(int, char*, unsigned short, unsigned short, unsigned long, int);
unsigned short pad = 1;
unsigned short addDetails = 0;
unsigned short cutMR = 0;
unsigned short decode = 0, encode = 0;
unsigned short blockSize = 512;
unsigned short pos = 0;
unsigned short filesFound = 0;
unsigned short logoOutput = 1;
unsigned short width = 0, height = 0;
char *inputFile, *base, *path;
char *motoLogoHeader;
unsigned long start, end;
FILE *inStream;
FILE *outStream;
char command[512];
char padByte = 0xff;
void MotoRunEncode(void)
{
unsigned int i,ind, m;
pixel line[width];
unsigned short count;
motoHead motoRunHeader;
if ((inStream = fopen(inputFile, "rb")) == NULL){
fclose(inStream);
fprintf(stderr, "\n%s\nCould not be opened.", inputFile);
return;
}
if ((outStream = fopen(base, "wb")) == NULL){
fclose(inStream);
fclose(outStream);
fprintf(stderr, "\n%s\nCould not be opened.", base);
return;
}
motoRunHeader.header[0] = 0x4D;
motoRunHeader.header[1] = 0x6F;
motoRunHeader.header[2] = 0x74;
motoRunHeader.header[3] = 0x6F;
motoRunHeader.header[4] = 0x52;
motoRunHeader.header[5] = 0x75;
motoRunHeader.header[6] = 0x6E;
motoRunHeader.header[7] = 0x00;
motoRunHeader.width = SWAP(width);
motoRunHeader.height = SWAP(height);
fwrite(&motoRunHeader, 1, sizeof(motoRunHeader), outStream);
for (i = 1; i <= height; i++){
fread(line, COLORS, width, inStream);
for (ind = 0, count = 0 ; ind <= width - 1; ){
if ((memcmp(&line[ind], &line[ind+1], 3) == 0)){
ind++;
count = 1;
while((ind <= width - 2) && ((memcmp(&line[ind], &line[ind+1], 3))== 0)){
count++;
ind++;
}
if (count == 1){
count++;
ind++;
goto LOOP;
} else {
count++;
count |= BIT_SET;
count = SWAP(count);
fwrite(&count, 1, 2, outStream);
fwrite(&line[ind], 1, 3, outStream);
}
ind++;
} else {
count = 1;
ind++;
LOOP:
while (((ind >= width -2)&&(ind <= width -1)) || ((ind <= width - 2) && (memcmp(&line[ind], &line[ind+1], 3) != 0)) || ((ind <= width - 3) && (memcmp(&line[ind+1], &line[ind+2], 3) != 0))){
count++;
ind++;
}
count = SWAP(count);
fwrite(&count, 1, 2, outStream);
fwrite(&line[ind - SWAP(count)], SWAP(count), COLORS, outStream);
continue;
}
}
}
return;
}
int FindMotoLogo(void)
{
char header[] = {0x4D,0x6F,0x74,0x6F,0x4C,0x6F,0x67,0x6F,0x00};
unsigned long int firstOffset;
int readByte;
char string[9];
if ((inStream = fopen(inputFile, "rb")) == NULL){
fclose(inStream);
fprintf(stderr, "\n%s\nCould not be opened.", inputFile);
return;
}
int inNumber = fileno(inStream);
while ((readByte = fgetc(inStream)) != EOF){
if (readByte == header[pos]){
if (pos == 8){
start = (ftell(inStream) - 9);
fseek(inStream, start + 9, SEEK_SET);
read(inNumber, &end, 4);
fseek(inStream, start + 9 + 4 + 24, SEEK_SET );
read(inNumber, &firstOffset, 4);
fseek(inStream, start + firstOffset, SEEK_SET );
read(inNumber, &string, 9);
if (strcmp(string, "MotoRun") == 0){
fseek(inStream, start + 13, SEEK_SET );
return (ParseHeader(end, inNumber));
} else {
pos = 0;
fseek(inStream, start + 9, SEEK_SET );
continue;
}
} else {
pos++;
continue;
}
}
pos = 0;
}
close(inNumber);
fprintf(stderr,"\n%d MotoLogo (logo.bin) files found.", filesFound);
return;
}
int ParseHeader(unsigned long end, int inNumber)
{
unsigned int imageCounter = (end - MOTOLOGO_BARE_HEADER) / MOTOLOGO_IMG_BLK_SIZE;
imageHead motomoto[imageCounter];
int i;
unsigned long logoSize, pos;
for(i=0; i < imageCounter; i++){
read(inNumber, &motomoto[i], 32);
motomoto[i].totalSize = BlockIt(motomoto[i].size);
motomoto[i].totalBlocks = (motomoto[i].totalSize /blockSize);
fprintf(stdout,"\nName: %s\nOffset in Logo.bin: %ld\nImage Data Size: %ld",motomoto[i].name, motomoto[i].offset, motomoto[i].size);
fprintf(stdout,"\nTotal Size: %ld",motomoto[i].totalSize);
fprintf(stdout,"\nTotal Blocks: %d",motomoto[i].totalBlocks);
pos = ftell(inStream);
fseek(inStream, start + motomoto[i].offset, SEEK_SET);
if (cutMR){
CutMRImageOut(inNumber, motomoto[i].name, motomoto[i].size);
fseek(inStream, start + motomoto[i].offset, SEEK_SET); //moved this line inside the parentheses
}
read(inNumber, &motomoto[i].imageHead, 12);
motomoto[i].imageHead.width = SWAP(motomoto[i].imageHead.width);
motomoto[i].imageHead.height = SWAP(motomoto[i].imageHead.height);
fprintf(stdout,"\nWidth x Height: %dx%d",motomoto[i].imageHead.width,motomoto[i].imageHead.height);
fprintf(stdout,"\nHeader: %s\n\n",motomoto[i].imageHead.header);
if (decode){
MotoDecode(inNumber, motomoto[i].name, motomoto[i].imageHead.width, motomoto[i].imageHead.height, motomoto[i].size , i+1);
}
fseek(inStream, pos, SEEK_SET);
}
logoSize = motomoto[imageCounter-1].offset + motomoto[imageCounter-1].totalSize;
fprintf(stdout,"\nLogo.bin contains %ld image files and is %ld bytes in size", i, logoSize);
if (!(logoOutput)){
return 0;
}
sprintf(command,"%s\\%s", path , OUT_FILE );
if ((outStream = fopen(command, "wb")) == NULL){
fclose(outStream);
fprintf(stderr, "\n%s\\%s could not be opened.", path, OUT_FILE);
return 1;
}
int outNumber = fileno(outStream);
fseek(inStream, start, SEEK_SET );
char* logobin = malloc(logoSize);
read(inNumber, logobin, logoSize);
write(outNumber, logobin, logoSize);
close(outNumber);
free(logobin);
return 0;
}
void CutMRImageOut(int inNumber, char* name, unsigned long size){
char newName[26];
FILE *txt;
sprintf(command,"%s\\%s.mr", path , name );
if ((txt = fopen("build.ID", "a")) == NULL){
fclose(txt);
fprintf(stderr, "\nBuild.ID could not be opened.\n");
return;
}
if ((outStream = fopen(command, "wb")) == NULL){
fclose(outStream);
fclose(txt);
fprintf(stderr, "\n%s\\%s.mr could not be opened", path, name);
return;
}
sprintf(command,"%s\n", command );
sprintf(newName, "%s?", name);
fwrite(newName, strlen(newName), 1, txt);
fwrite(command, strlen(command), 1, txt);
fclose(txt);
int outNumber = fileno(outStream);
char *dataStream = malloc(size);
read(inNumber, dataStream, size);
write(outNumber, dataStream, size);
if (pad){
if ((size % blockSize) != 0){
unsigned int max = blockSize - (size % blockSize ), i;
for (i = 0; i < max; i++){
write(outNumber, &padByte , 1);
}
fprintf(stdout,"\n%d bytes padded to %s", max, name);
}
}
close(outNumber);
free(dataStream);
return;
}
unsigned long int BlockIt(unsigned long int isize){
if ((isize % blockSize) == 0){
return isize;
}else{
return isize + (blockSize - (isize %blockSize));
}
}
void MotoDecode(int inNumber, char* name, unsigned short width, unsigned short height, unsigned long size, int index)
{
unsigned short repeats, count;
unsigned char color[3];
unsigned long counter = 0;
motoSet data;
if (addDetails){
sprintf(command, "%s\\%03d_%dx%d_%s.bgr24", path , index, width, height, name);
} else {
sprintf(command, "%s\\%s.bgr24", path, name);
}
if ((outStream = fopen(command, "wb")) == NULL){
fclose(outStream);
fprintf(stderr, "\n%s\nCould not be opened.", command);
return;
}
int outNumber = fileno(outStream);
while((read(inNumber, &data, 5) != EOF) && (counter < size)){
counter += 5;
if ((counter >= size ) || (data.count == 0xffff)){
close(outNumber);
return;
}
data.count = SWAP(data.count);
if (IS_BIT_SET(data.count)){
data.count &= ~BIT_SET;
for (repeats = 0;repeats < data.count; repeats++){
write(outNumber, &data.color, COLORS);
}
} else {
write(outNumber, &data.color, COLORS);
for (repeats = 0; repeats < data.count -1; repeats++){
counter += COLORS;
if ((read(inNumber, color, COLORS) == EOF) || counter >= size){
write(outNumber, &color, COLORS);
close(outNumber);
return;
}
write(outNumber, &color, COLORS);
}
}
}
close(outNumber);
return;
}
int main(int argc, char **argv)
{
int c;
while ((c = getopt (argc, argv, "i:o:p:b:w:h:cdezna")) != -1){
switch(c)
{
case 'a':
addDetails = 1;
break; //add index number and resolution to decoded filenames
case 'i':
inputFile = optarg;
break;
case 'o':
base = optarg;
break;
case 'p':
path = optarg;
break;
case 'b':
blockSize = atoi(optarg);
break;
case 'c':
cutMR = 1;
break;
case 'd':
decode = 1;
break;
case 'e':
encode = 1;
break;
case 'z':
pad = 0;
break;
case 'n':
logoOutput = 0;
break;
case 'w':
width = atoi(optarg);
break;
case 'h':
height = atoi(optarg);
break;
}
}
if (encode == 1){
MotoRunEncode();
return;
}
return(FindMotoLogo());
}
MotoLogoValidator.c
Code:
/*
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#define MOTOLOGO_BARE_HEADER 13
#define MOTOLOGO_IMG_BLK_SIZE 32
#define BIT_SET 0x8000
#define IS_BIT_SET(x) (x & BIT_SET)
#define COLORS 3
#define SWAP(x) (((x & 0xFF00) >> 8) | ((x & 0x00FF) << 8))
typedef struct {
unsigned short count;
unsigned char color[COLORS];
} motoSet;
typedef struct {
char header[8];
unsigned short width;
unsigned short height;
} motoHead;
typedef struct {
char name[24];
unsigned long offset;
unsigned long size;
unsigned short totalBlocks;
unsigned long totalSize;
motoHead imageHead;
} imageHead;
typedef struct {
unsigned char r;
unsigned char g;
unsigned char b;
} pixel;
int FindMotoLogo();
int ValidateMotoLogoHeader();
unsigned long int BlockIt(unsigned long int);
int VerifyImages(char*, unsigned short, unsigned short, unsigned long);
unsigned short pos, inNumber, blockSize = 512;
char *inputFile;
unsigned long start, end;
FILE *inStream;
FILE *txt;
char command[512];
char padByte = 0xff;
int FindMotoLogo()
{
char header[] = {0x4D,0x6F,0x74,0x6F,0x4C,0x6F,0x67,0x6F,0x00};
unsigned long int firstOffset;
int readByte;
char string[9];
for (pos = 0 ; pos <= 8 ; pos++ ){
if ((readByte = fgetc(inStream)) == header[pos]){
fprintf(stdout,"\nHeader:\n%d %02x",pos, header[pos]);
if (pos == 8){
fprintf(stdout, "\nHeader Match");
start = 0;
fseek(inStream, start + 9, SEEK_SET);
read(inNumber, &end, 4);
fseek(inStream, start + 9 + 4 + 24, SEEK_SET );
read(inNumber, &firstOffset, 4);
fseek(inStream, start + firstOffset, SEEK_SET );
read(inNumber, &string, 9);
if (strcmp(string, "MotoRun") == 0){
fseek(inStream, start + 13, SEEK_SET );
fprintf(stdout,"\nEnd of MotoLogo Header is byte %d.\n", end);
return 0;
} else {
fprintf(stderr,"\nFirst offset in MotoLogo header doesn't point to an image header.");
return 1;
}
} else {
continue;
}
} else {
fprintf(stderr,"\nFile: %s\ndoes not start with a valid MotoLogo header.", inputFile);
return 1;
}
}
return 1;
}
int ValidateMotoLogoHeader()
{
unsigned int imageCounter = (end - MOTOLOGO_BARE_HEADER) / (MOTOLOGO_IMG_BLK_SIZE);
fprintf(stdout,"\n%d images referenced in header.\nChecking Images.\n", imageCounter);
imageHead motomoto[imageCounter];
int i;
char motoRunHeader[] = "MotoRun\0";
fseek(inStream, 13, SEEK_SET);
for(i=0; i < imageCounter; i++){
read(inNumber, &motomoto[i], 32); //add an if parameter switch for the last element not to include the padding
motomoto[i].totalSize = BlockIt(motomoto[i].size);
motomoto[i].totalBlocks = (motomoto[i].totalSize /blockSize);
fprintf(stdout,"\nName: \"%s\"\nOffset In File: %ld\nImage Data Size: %ld",motomoto[i].name, motomoto[i].offset, motomoto[i].size);
fprintf(stdout,"\nTotal Size With Padding: %ld",motomoto[i].totalSize);
fprintf(stdout,"\nTotal Blocks: %d",motomoto[i].totalBlocks);
if (i != 0){
if ((motomoto[i-1].offset + motomoto[i-1].totalSize) == (motomoto[i].offset)){
fprintf(stdout, "\nOffsets match!");
} else {
fprintf(stderr, "\nOffsets do not match between %s and %s.\nVALIDATION FAILURE!\n", motomoto[i-1].name, motomoto[i].name);
return 1;
}
} else {
if (motomoto[i].offset == BlockIt(end)){
fprintf(stdout, "\nOffsets Match!");
} else {
fprintf(stderr, "\n%d is offset and %d is the end of the MotoLogo Header\nVALIDATION FAILURE!\n", motomoto[i].offset, BlockIt(end));
return 1;
}
}
pos = ftell(inStream);
fseek(inStream, motomoto[i].offset, SEEK_SET);
read(inNumber, &motomoto[i].imageHead, 12);
motomoto[i].imageHead.width = SWAP(motomoto[i].imageHead.width);
motomoto[i].imageHead.height = SWAP(motomoto[i].imageHead.height);
fprintf(stdout,"\nWidth x Height: %dx%d",motomoto[i].imageHead.width,motomoto[i].imageHead.height);
fprintf(stdout,"\nExpected Pixels: %d", (motomoto[i].imageHead.width * motomoto[i].imageHead.height));
if(strcmp(motoRunHeader, motomoto[i].imageHead.header) != 0){
fprintf(stderr, "\nHeader Should be \"%s\", not \"%s\"\nVALIDATION FAILED!\n", motoRunHeader, motomoto[i].imageHead.header);
return 1;
}
fprintf(stdout,"\nHeader: \"%s\"",motomoto[i].imageHead.header);
if (!VerifyImages(motomoto[i].name, motomoto[i].imageHead.width, motomoto[i].imageHead.height, motomoto[i].size - 12)){
fseek(inStream, pos, SEEK_SET);
continue;
} else {
return 1;
}
}
if ((txt = fopen("MoID.ID", "w")) == NULL){
fclose(txt);
fprintf(stderr, "\nMoID.ID could not be opened.\n");
return 1;
}
for(i=0; i < imageCounter; i++){
fprintf(txt, "%s,%d,%d,%d,%d,", motomoto[i].name, motomoto[i].imageHead.width, motomoto[i].imageHead.height, motomoto[i].totalSize, motomoto[i].totalBlocks);
fprintf(txt, "%d,%d\n", motomoto[i].offset, motomoto[i].size);
}
fclose(txt);
return 0;
}
unsigned long int BlockIt(unsigned long int isize){
if ((isize % blockSize) == 0){
return isize;
}else{
return isize + (blockSize - (isize %blockSize));
}
}
int VerifyImages(char* name, unsigned short width, unsigned short height, unsigned long size)
{
unsigned short line = 0, pixelsonline = 0;
unsigned long pixelsDecoded = 0, totalPixels = 0, bytesRead = 0;
motoSet data;
unsigned long posi;
while(bytesRead < size){
if ((bytesRead += read(inNumber, &data, 5)) == EOF){
return 0;
}
data.count = SWAP(data.count);
if (IS_BIT_SET(data.count)){
data.count &= ~BIT_SET;
pixelsonline += data.count;
} else {
posi = ftell(inStream);
fseek(inStream, (posi + (COLORS * (data.count - 1))), SEEK_SET);
pixelsonline += data.count;
bytesRead = bytesRead + (COLORS * (data.count - 1));
}
if (pixelsonline == width){
line++;
pixelsDecoded += pixelsonline;
pixelsonline = 0;
}
if ((pixelsonline == width) && ((pixelsDecoded / line) == pixelsonline)){
line++;
pixelsonline = 0;
}
}
fprintf(stdout,"\nPixels Decoded: %d\nBytes Read: %d\nSize Minus Header: %d\nLines Properly Terminated: %d", pixelsDecoded, bytesRead, size , line);
if ((pixelsDecoded == width * height) && (bytesRead == size) && (height == line )){
fprintf(stdout,"\n\"%s\" Is Encoded Correctly\n", name);
return 0;
}
if (pixelsDecoded != (width * height)){
fprintf(stderr, "\nThe total pixels decoded, %d, doesn't equal the resolution: %dx%d=%d",pixelsDecoded, width, height, (width * height));
}
if (bytesRead != size){
fprintf(stderr, "\nThe total bytes read, %d, is not equal to the encoded size, %d.", bytesRead, size);
}
if (height != line ){
fprintf(stderr, "\nAt least one run in the encoding runs past the edge of the screen.\nThis will not work.");
}
fprintf(stderr, "\n%s is not encoded correctly\nVALIDATION FAILURE!\n", name);
return 1;
}
int main(int argc, char **argv)
{
int c;
while ((c = getopt (argc, argv, "i:b:")) != -1){
switch(c)
{
case 'i':
inputFile = optarg;
break;
case 'b':
blockSize = atoi(optarg);
break;
}
}
if ((inStream = fopen(inputFile, "rb")) == NULL){
fclose(inStream);
fprintf(stderr, "\n%s\nCould not be opened.\n", inputFile);
return 1;
}
inNumber = fileno(inStream);
if (!FindMotoLogo()){
if (!ValidateMotoLogoHeader()){
fclose(inStream);
return 0;
}
}
fclose(inStream);
return 1;
}
BuildMotoLogo.c
[code[#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
typedef struct {
char name[24];
unsigned long offset;
unsigned long size;
unsigned long sizeWithPadding;
} imageHead;
unsigned long int ReadList(void);
unsigned int GetHeaderSize(void);
unsigned long int BlockIt(unsigned long int);
char *txtFileName;
FILE *inFile;
FILE *outFile;
char *outputFileName;
unsigned short images = 0;
unsigned short blockSize = 512;
unsigned long int ReadList(void){
char header[] = {0x4D,0x6F,0x74,0x6F,0x4C,0x6F,0x67,0x6F,0x00};
char line[512];
int readByte;
imageHead Item[images];
unsigned long int totalDataSize = 0;
int i = 0 , k = 0 , l = 0;
unsigned char padByte = 255;
unsigned long sizes[images];
char *s = "?";
char *tok;
unsigned long int hs;
if ((outFile = fopen (outputFileName, "wb")) == NULL){
perror("\nError opening output file:");
fclose(outFile);
}
hs = GetHeaderSize();
for ( i = 0 ; i < hs ; i++){
fputc(padByte, outFile);
}
i = 0;
hs = (images * 32) + 13;
while(fgets(line, sizeof line , stdin) != NULL){
tok = strtok(line, s);
sprintf(Item.name, "%s",tok);
tok = strtok(NULL, s);
for ( l = 24 ; l - strlen(Item.name) > 0 ; l-- ){
Item.name[l] = '\0';
}
for (k = 0; k < strlen(tok); k++){
if (( tok[k] == '\n') || (tok[k] == '\r' )){
tok[k] = '\0';
}
}
if ((inFile = fopen( tok , "rb")) == NULL){
perror("\nError opening mr file:");
fclose(inFile);
return 0;
}
while( ( readByte = fgetc(inFile) ) != EOF ){
fputc(readByte, outFile);
}
Item.size = ftell(inFile);
fprintf(stdout, "\n%d" , Item.size);
for ( k = 0 ; k < (blockSize - (Item.size % blockSize)) ; k++){
fputc(padByte, outFile);
}
Item.sizeWithPadding = BlockIt(Item.size);
totalDataSize += Item.sizeWithPadding;
if (i == 0){
Item.offset = BlockIt(hs);
} else {
Item.offset = ((Item[ i - 1 ].sizeWithPadding) + (Item[ i - 1 ].offset));
}
fprintf(stdout, "\n%ld", Item.offset);
i++;
fclose(inFile);
}
fseek(outFile, 0 , SEEK_SET);
fwrite(&header, sizeof header, 1 , outFile);
fwrite(&hs, 4, 1 ,outFile);
fprintf(stdout, "\n Size of Header is %d.", hs);
for (i = 0 ; i < images ; i++ ){
fwrite(&Item.name, 1 , 24 , outFile);
fwrite(&Item.offset, 4, 1 , outFile);
fwrite(&Item.size, 4, 1, outFile);
}
fclose(outFile);
fclose(inFile);
return totalDataSize;
}
unsigned int GetHeaderSize(void){
unsigned int ret = BlockIt(13 + ( 32 * images));
return ret;
}
unsigned long int BlockIt(unsigned long int isize){
if ((isize % blockSize) == 0){
return isize;
}else{
return isize + (blockSize - (isize %blockSize));
}
}
int main(int argc, char **argv){
int c;
while ((c = getopt (argc, argv, "o:n:")) != -1){
switch(c)
{
case 'o':
outputFileName = optarg;
break;
case 'n':
images = atoi(optarg);
break;
}
}
ReadList();
return;
}[/code]
SOURCE:
MotoLogo_Injectorv.97b.bat
Code:
@echo off&setlocal enabledelayedexpansion
MODE CON:COLS=78 LINES=1024&set "vers=.97b"
title BETA BETA BETA BETA BETA Motorola Image Injector v%vers% BETA BETA BETA BETA BETA
cd /d "%~dp0"
set "file=%~1"
set /a "aspectMultiplier=100000"
set "useDefaultViewer="
set "syslog=>>"%~dp0sys\log.txt""
set "ffmpeglog="
set "validlog="
set "codeclog="
set "rawBGRDir=Raw_BGR_Files"
set "imagesDir=Images"
set "mrDir=Raw_MR_Files"
set "workHere=Projects"
set "IDfile=MoID.ID"
set "buildFile=build.ID"
set "dontShowInfo=1"
set "autoOpenFolders=1"
set "prevailExt=Png"
if not exist "%~dp0sys\" mkdir "%~dp0sys"
if exist "%~dp0sys\settings.cfg" (call :LoadSetFile)
if "%dontShowInfo%"=="1" set "validlog=>>"%~dp0sys\validation_log.txt" 2>&1" &set "codeclog=>>"%~dp0sys\codec_log.txt" 2>&1" &set "ffmpeglog=>>"%~dp0sys\ffmpeg_log.txt" 2>&1"
if exist "%~dp0sys\last_file" if "[%file%]"=="[]" call :Existing
if /i "[%file%]" equ "[$$$convert$$$]" set "file=%~2" &set "home=%~3" &call :SaveSettings &goto :ConvertFolder
if /i "[%file%]" equ "[$$notstrict$$]" set "file=%~2" &set "home=%~3" &call :SaveSettings &goto :NotStrictConvert
if "[%file%]" neq "[]" if exist "%file%" call :New &goto :Menu
call :help
:Settings
call :DrawHead
echo( ____________________________________________________________________________
echo(
if %dontShowInfo%==1 (
echo( 1 - Show Info On The Screen ^(currently data is logged^)) else (echo( 1 - Log Info To A Text File ^(currently data is shown on screen^))
)
echo(
if %autoOpenFolders%==1 (
echo( 2 - Auto Open Folders After A New File Is Created ^(currently is On^)) else (echo( 2 - Auto Open Folders After A New File Is Created ^(currently is Off^))
echo(
echo( 3 - Change Which Image Format To Use ^(currently it is %prevailExt%^)
echo(
echo( 4 - Clear Logs In Sys Folder
echo(
echo( 5 - Exit
echo(
choice /n /m " Please Select A Menu Number:" /c:12345
if errorlevel 1 set k=1
if errorlevel 2 set k=2
if errorlevel 3 set k=3
if errorlevel 4 set k=4
if errorlevel 5 set k=5
if %k%==1 if %dontShowInfo%==1 (set "dontShowInfo=0") else (set "dontShowInfo=1")
if %k%==2 if %autoOpenFolders%==1 (set "autoOpenFolders=0") else (set "autoOpenFolders=1")
if %k%==3 call :ImageFormat
if %k%==4 2>nul del /q "%~dp0sys\*log*.txt
if %k%==5 goto :Menu
call :SaveSetFile
goto :Settings
:ImageFormat
call :DrawHead
echo(&echo( If you change the extension used in the program, you will no longer
echo( be able to edit older project folders that used the current image extension.
echo( You would have to switch back to what ever image format was used if you wanted
echo( to open an older project. Unless you rebuild a folder in Non Strict, which
echo( would allow you to use all different image types.
echo(&echo( Enter The Extension ^(without the "."^) That You Want To Use.
echo( Currently it is %prevailExt%
set /p prevailExt=: || set "prevailExt=Png"
call :SaveSetFile
goto :eof
:LoadSetFile
<"%~dp0sys\settings.cfg" (
set /p dontShowInfo=
set /p autoOpenFolders=
set /p prevailExt=
)
goto :eof
:SaveSetFile
>"%~dp0sys\settings.cfg" (
echo(%dontShowInfo%
echo(%autoOpenFolders%
echo(%prevailExt%
)
goto :eof
:Existing
call :LoadSettings
call :SaveSettings
if not exist "%file%" call :NotThere
if not exist "%home%\%IDfile%" call :NotThere
if not exist "%home%\%buildFile%" call :NotThere
call :LoadDetails "%home%\%IDfile%"
goto :menu
pause
:New
call :DrawHead
call :LoadNewFile
%codeclog% "%~dp0bin\MotoLogoCodec.exe" -i "%file%" -o "%name%" -p "%home%" || (if defined "%home%" if exist "%home%\" rd /q "%home%" &call :NoLogo)
echo(&echo( MotoLogo container found, validating data...
%validlog% "%~dp0bin\MotoLogoValidator.exe" -i "%file%" || (
if exist "%home%\logo.bin" (
set "file=%home%\Logo.bin"
%validlog% "%~dp0bin\MotoLogoValidator.exe" -i "!file!" || (if defined home if exist "%home%\" del /q "%home%\*.bin" &rd /q "%home%" &call :ValidFail)
) else (if defined home if exist "%home%\" del /q "%home%\*.bin" &rd /q "%home%" &call :ValidFail)
)
set "file=%home%\logo.bin"
call :SaveSettings
echo(&echo( VALIDATION SUCCESSFUL&echo(
%syslog% move "%~dp0%IDfile%" "%home%\"
call :LoadDetails "%home%\%IDfile%"
call :MakeFolders
echo(&echo( Extracting images....Please wait...&echo(
%codeclog% "%~dp0bin\MotoLogoCodec.exe" -z -c -d -i "%file%" -o "%name%" -p "%home%\%mrDir%"
%syslog% move "%~dp0%buildFile%" "%home%\"
%syslog% move "%home%\%mrDir%\*.bgr24" "%home%\%rawBGRDir%\"
call :ffmpegit "%home%\%rawBGRDir%" "%home%\%imagesDir%"
goto :eof
:ValidFail
call :DrawHead
echo(&echo(&echo( Container Failed Validataion..
echo( Press any key to exit.
pause>nul
exit
goto :eof
:MakeFolders
2>nul mkdir "%home%\%rawBGRDir%"
2>nul mkdir "%home%\%mrDir%"
2>nul mkdir "%home%\%imagesDir%"
goto :eof
:Menu
call :DrawHead
call :DrawDetails
echo( ____________________________________________________________________________
echo(
echo( 1 - Rebuild %imagesDir% Directory ^(Strict-In Order-Resolution Checks^)
echo(
echo( 2 - Rebuild %imagesDir% Directory ^(Not Strict^)
echo(
echo( 3 - Open Current Project Folder
echo(
echo( 4 - Settings
echo(
echo( 5 - Fastboot Flash Current File
echo(
echo( 6 - Exit
echo(
choice /n /m " Please Select A Menu Number:" /c:123456
if errorlevel 1 set k=1
if errorlevel 2 set k=2
if errorlevel 3 set k=3
if errorlevel 4 set k=4
if errorlevel 5 set k=5
if errorlevel 6 set k=6
if %k%==1 call :ConvertFolder
if %k%==2 call :NotStrictConvert
if %k%==3 start "" "%home%"
if %k%==4 call :Settings
if %k%==5 call :Fla****
if %k%==6 goto :finish
goto :Menu
:Fla****
call :DrawHead
call :DrawDetails
echo(&echo( Your logo is ready to be flashed.&echo( File:%file%
echo(&echo( Make sure that your device is connected and in Bootloader Mode.
echo(&echo( The following command will be issued:
echo( fastboot flash logo "%file%"
echo(&echo( Press 1 to flash the logo partition, or 2 to go back.&echo(
echo(&echo( 1 - Flash
echo(&echo( 2 - Go Back
echo(
choice /n /m " Please select a menu number:" /c:12
if errorlevel 1 set k=1
if errorlevel 2 set k=2
if !k!==1 (call )
if !k!==2 goto :Menu
"%~dp0bin\fastboot.exe" flash logo "%file%" &&echo. Finished..Press any key to Reboot your device.&&pause>nul&&"%~dp0bin\fastboot.exe" reboot
goto :eof
:NotStrictConvert
call :DrawHead
echo(&echo( This will rebuild all images in the %imageDir% folder.
echo( It will rebuild in alphabetical order while disregarding
echo( original width, height, position in bin file. You can pretty
echo( much put any image format in here and get an encoded bin file.
echo( Press 1 to Continue or 2 to Go Back
echo(&echo( 1 - Continue
echo(&echo( 2 - Go Back
echo(
choice /n /m "please select a menu number:" /c:12
if errorlevel 1 set k=1
if errorlevel 2 set k=2
if !k!==1 (call )
if !k!==2 goto :Menu
if exist "%home%\errors.txt" del /q "%home%\errors.txt"
if not exist "%home%\%IDfile%" call :NotThere
if not exist "%home%\%buildFile%" call :NotThere
call :LoadDetails "%home%\%IDfile%"
if defined home if exist "%home%\" rd /s /q "%home%\Not_Strict_Modified\" 2>nul
2>nul md "%home%\Not_Strict_Modified"
2>nul md "%home%\Not_Strict_Modified\%rawBGRDir%"
2>nul md "%home%\Not_Strict_Modified\%mrDir%"
set /a imageCount=0
2>nul del /q "%home%\%imagesDir%\Thumbs.db"
for /f %%a in ('dir /b /a-d-h "%home%\%imagesDir%\*.*"') do (
set /a imageCount=!imageCount!+1
echo( Converting: %%a
set "name=%%~na"
set name=!name:~0,24!
for /f "tokens=1-8* delims=," %%A in ('bin\ffmpeg -hide_banner -i "%home%\%imagesDir%\%%a" -f rawvideo -vcodec rawvideo -pix_fmt bgr24 -y "%home%\Not_Strict_Modified\%rawBGRDir%\!name!.bgr24" 2^>^&1^|findstr /rxic:".*stream #0:0.*[0-9]x[0-9].*"') do (
echo(%%A >"%home%\imageres"
echo(%%B >>"%home%\imageres"
echo(%%C >>"%home%\imageres"
echo(%%D >>"%home%\imageres"
echo(%%E >>"%home%\imageres"
echo(%%F >>"%home%\imageres"
echo(%%G >>"%home%\imageres"
echo(%%H >>"%home%\imageres"
)
for /f "tokens=1-3 delims=x " %%I in ('type "%home%\imageres"^|findstr /rxic:".*[0-9]x[0-9].*"') do set /a width=%%I &set /a height=%%J
if not defined width echo( Error: "Width undefined in %%a">>"%home%\errors.txt"
if not defined height echo( Error: "Height undefined in %%a">>"%home%\errors.txt"
if not exist "%home%\Not_Strict_Modified\%rawBGRDir%\!name!.bgr24" echo( Error: "%home%\Not_Strict_Modified\%rawBGRDir%\!name!.bgr24" Was not created.>>"%home%\errors.txt"
echo( Encoding: !name!.bgr24
%codeclog% "%~dp0bin\MotoLogoCodec.exe" -e -i "%home%\Not_Strict_Modified\%rawBGRDir%\!name!.bgr24" -o "%home%\Not_Strict_Modified\%mrDir%\!name!.mr" -w !width! -h !height!
if not exist "%home%\Not_Strict_Modified\%mrDir%\!name!.mr" echo( Error: "%home%\Not_Strict_Modified\%mrDir%\!name!.mr" Was not sucessfully encoded.>>"%home%\errors.txt"
echo(!name!?%home%\Not_Strict_Modified\%mrDir%\!name!.mr>>"%home%\Not_Strict_Modified\%buildFile%"
set check=
)
del /q "%home%\imageres"
if exist "%home%\errors.txt" call :Error
echo( Rebuilding Encoded Files...
"%~dp0bin\BuildMotoLogo.exe" <"%home%\Not_Strict_Modified\%buildFile%" -o "%home%\Not_Strict_Modified\build.bin" -n %imageCount%
%validlog% "%~dp0bin\MotoLogoValidator.exe" -i "%home%\Not_Strict_Modified\build.bin" || goto :RebuildError
set "file=%home%\Not_Strict_Modified\build.bin"
set "home=%home%\Not_Strict_Modified"
call :SaveSettings
%syslog% move "%~dp0%IDfile%" "%home%\"
call :LoadDetails "%home%\%IDfile%"
echo( Validation succesful
2>nul md "%home%\%imagesDir%"
call :ffmpegit
goto :Menu
:ConvertFolder
call :DrawHead
if exist "%home%\errors.txt" del /q "%home%\errors.txt"
if not exist "%home%\%IDfile%" call :NotThere
if not exist "%home%\%buildFile%" call :NotThere
call :LoadDetails "%home%\%IDfile%"
echo(&echo( Checking Resolutions..
if defined home if exist "%home%\" rd /s /q "%home%\Modified\" 2>nul
2>nul md "%home%\Modified"
2>nul md "%home%\Modified\%rawBGRDir%"
2>nul md "%home%\Modified\%mrDir%"
for /l %%a in (1,1,%images%) do (
echo( Converting: !logoName[%%a]!
if not exist "%home%\%imagesDir%\!logoName[%%a]!.%prevailExt%" (
call :DrawHead
echo(&echo( An image for !logoName[%%a]! is missing in the %imagesDir% folder.
echo(&echo( If you are trying to remove an image from you bin file, you need
echo( to rebuild the %imagesDir% folder in Non Strict Mode.
echo(&echo( Press any key to return to the menu.
pause>nul
goto :Menu
)
for /f "tokens=1-8* delims=," %%A in ('bin\ffmpeg -hide_banner -i "%home%\%imagesDir%\!logoName[%%a]!.%prevailExt%" -f rawvideo -vcodec rawvideo -pix_fmt bgr24 -y "%home%\Modified\%rawBGRDir%\!logoName[%%a]!.bgr24" 2^>^&1^|findstr /rxic:".*stream #0:0.*[0-9]x[0-9].*"') do (
echo(%%A >"%home%\imageres"
echo(%%B >>"%home%\imageres"
echo(%%C >>"%home%\imageres"
echo(%%D >>"%home%\imageres"
echo(%%E >>"%home%\imageres"
echo(%%F >>"%home%\imageres"
echo(%%G >>"%home%\imageres"
echo(%%H >>"%home%\imageres"
)
for /f "tokens=1-3 delims=x " %%I in ('type "%home%\imageres"^|findstr /rxic:".*[0-9]x[0-9].*"') do set /a width=%%I &set /a height=%%J
if not defined width echo( Error: "Width undefined in !logoName[%%a]!.%prevailExt%">>"%home%\errors.txt"
if not defined height echo( Error: "Height undefined in !logoName[%%a]!.%prevailExt%">>"%home%\errors.txt"
if !width! neq !logoWidth[%%a]! set check=1
if !height! neq !logoHeight[%%a]! set check=1
if defined check call :Aspect !width! !height! !logoWidth[%%a]! !logoHeight[%%a]! "%home%\%imagesDir%\!logoName[%%a]!.%prevailExt%" "%home%\Modified\%rawBGRDir%\!logoName[%%a]!.bgr24" "!logoName[%%a]!"
if not exist "%home%\Modified\%rawBGRDir%\!logoName[%%a]!.bgr24" echo( Error: "%home%\Modified\%rawBGRDir%\!logoName[%%a]!.bgr24" Was not created.>>"%home%\errors.txt"
echo( Encoding: !logoName[%%a]!
%codeclog% "%~dp0bin\MotoLogoCodec.exe" -e -i "%home%\Modified\%rawBGRDir%\!logoName[%%a]!.bgr24" -o "%home%\Modified\%mrDir%\!logoName[%%a]!.mr" -w !width! -h !height!
if not exist "%home%\Modified\%mrDir%\!logoName[%%a]!.mr" echo( Error: "%home%\Modified\%mrDir%\!logoName[%%a]!.mr" Was not sucessfully encoded.>>"%home%\errors.txt"
echo(!logoName[%%a]!?%home%\Modified\%mrDir%\!logoName[%%a]!.mr>>"%home%\Modified\%buildFile%"
set check=
set width=
set height=
)
del /q "%home%\imageres"
if exist "%home%\errors.txt" call :Error
echo( Rebuilding Encoded Files...
"%~dp0bin\BuildMotoLogo.exe" <"%home%\Modified\%buildFile%" -o "%home%\Modified\build.bin" -n %images%
%validlog% "%~dp0bin\MotoLogoValidator.exe" -i "%home%\Modified\build.bin" || goto :RebuildError
set "file=%home%\Modified\build.bin"
set "home=%home%\Modified"
call :SaveSettings
%syslog% move "%~dp0%IDfile%" "%home%\"
call :LoadDetails "%home%\%IDfile%"
echo( Validation succesful
2>nul md "%home%\%imagesDir%"
call :ffmpegit
goto :Menu
:Aspect
set check=
set /a border=5
set /a border2=2*%border%
echo(&echo( Image: %~7
set /a newAspect=%aspectMultiplier%*%1/%2
set /a originalAspect=%aspectMultiplier%*%3/%4
echo(
echo( The resolution for %7 is different from the original image.
echo( New : %1x%2
echo( Original: %3x%4
echo(
echo( ____________________________________________________________________________
if "%originalAspect%"=="%newAspect%" (
echo(
echo( 1 - Stretch Or Shrink The Image To Fit The Original Size
echo(
echo( 2 - Do Nothing And Continue
echo(
choice /n /m "please select a menu number:" /c:12
if errorlevel 1 set k=1
if errorlevel 2 set k=2
if !k!==1 set "videoFilters=-vf "scale=%3:%4""
if !k!==2 goto :eof
) else (
echo(
if %3 gtr %4 (echo( 1 - Resize And Crop While Keeping The Original Aspect And Size ^(Upper Image^)) else (echo( 1 - Resize And Crop While Keeping The Original Aspect And Size ^(Left Image^))
echo(
if %3 gtr %4 (echo( 2 - Stretch Or Shrink The Image To Fit The Original Size ^(Lower Image^)) else (echo( 2 - Stretch Or Shrink The Image To Fit The Original Size ^(Right Image^))
echo(
echo( 3 - Do Nothing And Continue With %1x%2 Image
echo(
if %4 lss %3 (set /a ffw=%3+2*%border%&set /a ffh=%4*2+3*%border%&set "overlay=overlay=%border%:h+%border2%") else (set /a ffw=%3*2+3*%border%&set /a ffh=%4+2*%border%&set "overlay=overlay=w+%border2%:%border%")
if %originalAspect% lss %newAspect% (set "scale=scale=-1:%4") else (set "scale=scale=%3:-1")
"%~dp0bin\ffmpeg.exe" -loglevel fatal -i "%~5" -i "%~5" -filter_complex "color=red:!ffw!x!ffh!:1[bg];[0]!scale!, crop=%3:%4[sc0];[1]scale=%3:%4[sc1];[bg][sc0]overlay=%border%:%border%[x];[x][sc1]!overlay!" -y "%home%\test.png"%ffmpeglog%
if exist "%home%\test.png" if defined useDefaultViewer (start "" "%home%\test.png") else (rundll32 "%ProgramFiles%\Windows Photo Viewer\PhotoViewer.dll", ImageView_Fullscreen %home%\test.png)
choice /n /m "please select a menu number:" /c:123
if errorlevel 1 set k=1
if errorlevel 2 set k=2
if errorlevel 3 set k=3
if !k!==1 (
if %originalAspect% gtr %newAspect% set "videoFilters=-vf "scale=%3:-1, crop=%3:%4""
if %originalAspect% lss %newAspect% set "videoFilters=-vf "scale=-1:%4, crop=%3:%4""
)
if !k!==2 set "videoFilters=-vf "scale=%3:%4""
if !k!==3 goto :eof
2>nul del /q "%home%\test.png"
)
set /a width=%3
set /a height=%4
%ffmpeglog% "%~dp0bin\ffmpeg.exe" %ffdebug% %ffshowb% -i "%~5" !videoFilters! -f rawvideo -vcodec rawvideo -pix_fmt bgr24 -y "%~6"
goto :eof
:RebuildError
echo( There was a problem rebuilding the images..
echo( Press any key to exit.
pause>nul
goto :Finish
:Error
call :DrawHead
echo(&type "%home%\errors.txt"
echo(&echo( Press any key to exit..
pause >nul
goto :Finish
:DrawHead
cls echo( _________________________________________________________________________-_-
echo( Motorola Image Injector v%vers%
echo(
echo( written by Makers_Mark
echo( ____________________________________________________________________________
goto :eof
:DrawFileInfo
echo( File: %file% &echo( Size: %fileSize% Bytes ^(%megaSize%.%megaDeci% MB^)&echo( ____________________________________________________________________________
goto :eof
:DrawDetails
call :DrawFileInfo
"%~dp0bin\DrawDetails.exe" <"%home%\%IDfile%"
goto :eof
:NoLogo
call :DrawHead
echo(&echo( No Motorola Logo Images were found in the file.
echo( Press any key to exit....
pause>nul
exit
:LoadDetails
set /a images=0
for /f "tokens=1-7 delims=," %%t in ('type "%~1"') do (
set /a images+=1
set "logoName[!images!]=%%t" &set /a logoOffset[!images!]=%%y &set /a logoSize[!images!]=%%z &set /a logoSizeTotal[!images!]=%%w
set /a logoBlocks[!images!]=%%x &set /a logoWidth[!images!]=%%u &set /a logoHeight[!images!]=%%v
)
goto :eof
:dupename
if not exist "%~dp0%workhere%\!%~1!\" (goto :eof)
set /a unique=1
:dupe
if not exist "%~dp0%workhere%\!%~1!.%unique%\" (
set "%~1=!%~1!.%unique%"
goto :eof
) else (
set /a unique+=1
goto :dupe
)
goto :eof
:LoadNewFile
for %%? in ("%file%") do set /a "size=%%~z?" &set "filename=%%~nx?" &set "ext=%%~x?" &set "name=%%~n?"
set "newDir=%name%"
call :dupename "newDir"
set "home=%~dp0%workHere%\%newDir%"
2>nul mkdir "%home%"
goto :eof
:LoadSettings
<"%~dp0sys\last_file" (
set /p file=
set /p home=
set /p fileSize=
)
call :StripQuotes %file% %home%
goto :eof
:StripQuotes
set "file=%~1"
set "home=%~2"
goto :eof
:SaveSettings
for %%? in ("%file%") do set fileSize=%%~z?
set /a fileSize
set /a megaSize=%fileSize%/(1024*1024)
set /a remain=%fileSize% %% (1024*1024)
set /a megaDeci=(%remain%*1000)/(1024*1024)
>"%~dp0sys\last_file" (
echo("%file%"
echo("%home%"
echo(%fileSize%
)
goto :eof
:ffmpegit
echo( Converting Images Into %prevailExt% Images...
(for /f %%a in ('dir /b/a-d "%home%\%rawBGRDir%\*.bgr24"') do (
for /l %%? in (1, 1, %images%) do (
if "%%~na"=="!logoName[%%?]!" (
call set /a width=!logoWidth[%%?]!"
call set /a height=!logoHeight[%%?]!
)
)
"%~dp0bin\ffmpeg.exe" %ffdebug% %ffshowb% -loglevel fatal -f rawvideo -vcodec rawvideo -s !width!x!height! -pix_fmt bgr24 -i "%home%\%rawBGRDir%\%%~nxa" -y "%home%\%imagesDir%\%%~na.%prevailExt%"
))%ffmpeglog%
>"%home%\Make MotoLogo Bin From %imagesDir% Folder.bat" (
echo(@echo off
echo(cmd ^/c ^""%~dpnx0" $$$convert$$$ "%file%" "%home%"^"
echo(
)
>"%home%\Make MotoLogo Bin (Not Strict) From %imagesDir% Folder.bat" (
echo(@echo off
echo(cmd ^/c ^""%~dpnx0" $$notstrict$$ "%file%" "%home%"^"
echo(
)
if %autoOpenFolders%==1 start "" "%home%\"
goto :eof
:help
call :DrawHead
echo(&echo(
echo( You have to drag a file onto this batch file,
echo( in order to load a file into it.
echo( Press a key to close this window and exit.
pause >nul
goto :finish
:NotThere
call :Drawhead
echo(&echo(
echo( File^(s^) are missing. Reload File by dragging and dropping onto
echo( this batch file again.
echo( Press a key to close this window and exit.
pause>nul
goto :finish
:Finish
cls&exit
goto :eof
DrawDetails.c
Code:
#include <string.h>
#include <stdio.h>
#include <windows.h>
int main()
{
char *s = "," ;
char *token ;
int i , j = 1 , k , color ;
char line[80];
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO consoleInfo;
WORD originalColor;
GetConsoleScreenBufferInfo(hConsole, &consoleInfo);
originalColor = consoleInfo.wAttributes;
printf(" ____________________________________________________________________________\n");
printf(" Image Name WxH Size+ Blocks Offset Raw Size \n");
printf(" _________________________________________________________________________-_-\n");
while(fgets(line, sizeof line, stdin) != NULL){
if (( j % 2 ) == 0) {
color = 0x0B;
} else {
color = 0xB0;
}
SetConsoleTextAttribute(hConsole, color);
token = strtok(line, s);
for ( i = 0; i < 7; i++){
if (i==0){
printf(" %2d.%-24s", j,token);
token = strtok(NULL,s);
} else if ( i == 1 ){
printf("%dx", atoi(token));
token = strtok(NULL,s);
} else if ( i == 2 ){
printf("%d\t", atoi(token));
token = strtok(NULL,s);
} else if (( i > 2) && ( i < 6 )){
printf("%d\t", atoi(token));
token = strtok(NULL,s);
} else {
printf("%-13d\r\n", atoi(token));
token = strtok(NULL,s);
}
}
j++;
}
SetConsoleTextAttribute(hConsole, originalColor);
}
It looks to be 8MB. I can't upload though.
grim489 said:
It looks to be 8MB. I can't upload though.
Click to expand...
Click to collapse
Thats cool, no upload needed. Just curious about the filesize. Thanks again!
No problem! I can't help with much else though ?
grim489 said:
No problem! I can't help with much else though ?
Click to expand...
Click to collapse
Hey you've done enough, I almost forgot to thank you for testing my initial image in the other thread, added to the OP.
I'll poke around later with this. Kinda missed having this ability coming from the nexus 5.
any youtube video on the startup animations? i wouldn't mind changing the google screen to saying NeXus 6 logo with the X colored logo
cobyman7035 said:
any youtube video on the startup animations? i wouldn't mind changing the google screen to saying NeXus 6 logo with the X colored logo
Click to expand...
Click to collapse
Thanks fellow XDAlien, almost forgot.. added to OP:
The logo partition has nothing to do with your boot animation. Your boot animation actually comes right after the static image, that in this case says "Google" in catull font; and if you have an unlocked bootloader, additionally there will be a little lock that appears to be open (aka "dummy locked") in the bottom center of the screen. Your boot animation follows after this screen goes away, your boot animation is typically animated or dynamic. The static screen with "Google" is known as your splash screen to some, or boot screen to others. This tool allows you to change the static image (splash screen) and not your boot animation.​
So I got it working. But the bootloader rejects anything that doesn't use the original resolution.
GrayBoltWolf said:
So I got it working. But the bootloader rejects anything that doesn't use the original resolution.
Click to expand...
Click to collapse
Thanks for that information. But for clarification, are you talking about images from just the bootloader screen? For example, if you try to change the logo_boot (the "GOOGLE" splash screen), can you use different resolutions?
makers_mark said:
Thanks for that information. But for clarification, are you talking about images from just the bootloader screen? For example, if you try to change the logo_boot (the "GOOGLE" splash screen), can you use different resolutions?
Click to expand...
Click to collapse
Same for all of them. If it is a higher resolution than the original then the bootloader freaks out and won't flash it.
Here is a video of how to change the boot logo:
Add it to the OP if you want.
Hello,
since I normally try to use as less Google services as possible and buy the Nexus devices always for the "open" HW, I was always a little anoyed by the Google logo on startup.
So thank you very much fpr this great tool. I directly tried it and replaced the Google logo on my Nexus 6 by a white NEXUS logo. I also removed the "UN"LOCK icon from the bootscreen.
Thank you very much again. Everthing works as expected
I attach the NEXUS logo I created for myself if somebody else wants it maybe.
makers_mark said:
Thanks for that information. But for clarification, are you talking about images from just the bootloader screen? For example, if you try to change the logo_boot (the "GOOGLE" splash screen), can you use different resolutions?
Click to expand...
Click to collapse
That's odd. I've changed min several times using all kinds of pictures. I just keep them under 300kb. I use a 1400x2560 photo and flash in TWRP. Never changed it in fastboot mode. I also put a transparent "lock" otherwise it'll show up on splash.
makers_mark said:
Thanks for that information. But for clarification, are you talking about images from just the bootloader screen? For example, if you try to change the logo_boot (the "GOOGLE" splash screen), can you use different resolutions?
Click to expand...
Click to collapse
That's odd. I've changed min several times using all kinds of pictures. I just keep them under 300kb. I use a 1400x2560 photo and flash in TWRP. Never changed it in fastboot mode.
BlockbusterF said:
Hello,
since I normally try to use as less Google services as possible and buy the Nexus devices always for the "open" HW, I was always a little anoyed by the Google logo on startup.
So thank you very much fpr this great tool. I directly tried it and replaced the Google logo on my Nexus 6 by a white NEXUS logo. I also removed the "UN"LOCK icon from the bootscreen.
Thank you very much again. Everthing works as expected
I attach the NEXUS logo I created for myself if somebody else wants it maybe.
Click to expand...
Click to collapse
Did you make this wall? Also how did u remove the " un"lock icon?
---------- Post added at 03:51 PM ---------- Previous post was at 03:20 PM ----------
Can I switch the "un" lock icon with maybe a iron man face?
Yes
---------- Post added at 02:40 PM ---------- Previous post was at 02:38 PM ----------
Galaxysm said:
Did you make this wall? Also how did u remove the " un"lock icon?
---------- Post added at 03:51 PM ---------- Previous post was at 03:20 PM ----------
Can I switch the "un" lock icon with maybe a iron man face?
Click to expand...
Click to collapse
I used a transparent one. So yes you can. I'd keep aspect ratio the same
713brianp27 said:
Yes
---------- Post added at 02:40 PM ---------- Previous post was at 02:38 PM ----------
I used a transparent one. So yes you can. I'd keep aspect ratio the same
Click to expand...
Click to collapse
I was able to do it. And changed the "unlock" icon for a Samus icon. Couldn't find a good iron man face/helmet at 96×96 size.

[MOD][WIN][BOOTLOGO]Change Your Splash Screen and Various Graphics

This is a hybrid batch and C program that I wrote to decode and encode the MotoLogo image container. I originally wrote it for the Nexus 6, but it works on your device too. It will allow you to edit or replace any of the images in your logo partition. This will also work with any Motorola device utilizing this current format.
The logo partition has nothing to do with your boot animation. Your boot animation actually comes right after the static image that is one of the several images you can change with this tool. Your boot animation follows after this screen goes away, your boot animation is typically animated or dynamic. The static screen is known as your splash screen to some, or boot screen to others. This tool allows you to change the static image (splash screen) and not your boot animation!​Thanks to GrayBoltWolf for making this video!!
This video was made using a Nexus 6, but the encoding of the logo.bin is identical. When I made this program, I made it with the mindset of being able to use it to edit ANY MotoLogo image container, even if it's an electronic billboard. I did not include the Nexus 6 bootlader in this version for obvious reasons. But you will just drag and drop your logo.bin from your phone, or if you have an unzipped bootloader (like I provided for the Nexus 6), you can just drag that. The program will find the MotoLogo container in it and cut it out.
Download the "MotoLogo Injector v.1.1" zip file at the bottom of this post.
Extract the zip file to a new folder.
To use just drag any file (your "logo.bin") that you think might have a MotoLogo container in it onto the batch file "MotoLogo_Injectorv1.1.bat"
The program will then find the Container in the file, extract it and validate every byte in it, and output it in the "Projects" folder.
A newly created folder will pop up that contains the raw image files, PNG image files, some identification files, and your extracted "logo.bin"
There will also be two new batch files in the folder that will make it easy to close the program, edit the images, then just click one of the batch files to get back into the program to re-encode the images. The difference in the two batch files is that one of them will re-encode the logo bin in a "Strict" way, and the other way is "Non-Strict"
Strict goes in the exact same order that the images were encoded in the first place.
Strict will fail if there are any more or any less images.
Strict will fail if any of the image names are changed.
Strict will check the resolution.
Strict will not let you have a Jpg, Bmp, ....any other format mixed in with the Pngs. (If you prefer to work with another image format, you can change that in the settings but you still can't mix them up inside of the "Images" folder; they should all be of the same type.
If an images resolution doesn't match the original images, it will warn you and give you options to resize or disregard the size difference.
Non-Strict simply goes through every file in the "Images" folder in alphanumerical order and makes it a raw file, encodes it, and puts the MotoLogo container together.
Non-Strict will take all kinds of differently formatted images.
The only reason I can see someone wanting to use Non-Strict is to delete images from a MotoLogo container.
In your "Images" folder is where you either edit or replace the PNG images. You can make them bigger, but I don't know what implications this may have as I do not have a device to test on. You must keep the names the exact same as the images, it is okay to change the image or even replace it (that's the whole point) but you have to keep the names the same for Strict mode, which I encourage you to use.
When you are finished editing your images:
You can open up the Original batch program if you haven't used it anymore (it remembers the last file loaded that had a successful validated container in it, so you don't have to drag and drop everytime). And then hit 1 "Rebuild Images Directory (Strict-In Order_Resolution Checks)"
Or you can click on the "Make MotoLogo Bin From Images Folder.bat" to go directly there.
After the program has rebuilt it, it will re validate the container, and then reconvert the container into view-able Pngs again. A new folder will automatically open. This contains your modified container called "build.bin". You can flash it from there.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
v.97b Initial Release
v.1.0
Fixed error with Moto X Style bg encoded image size being evenly divisible by 512
Made logging to the screen default so you can tell it's working and not hung up
Changed default image extension from "Png" to "png"
v.1.1
Fixed Settings Bug
I am not responsible for any damage done to your device!! Source is in Posts 2 & 3!
SOURCE:
SOURCE:
MotoLogo_Injectorv1.1.bat
Code:
@echo off&setlocal enabledelayedexpansion
MODE CON:COLS=78 LINES=1024&set "vers=1.1"
color 0b
title Motorola Image Injector v%vers%
cd /d "%~dp0"
set "file=%~1"
set /a "aspectMultiplier=100000"
set "useDefaultViewer="
set "syslog=>>"%~dp0sys\log.txt""
set "ffmpeglog="
set "validlog="
set "codeclog="
set "rawBGRDir=Raw_BGR_Files"
set "imagesDir=Images"
set "mrDir=Raw_MR_Files"
set "workHere=Projects"
set "IDfile=MoID.ID"
set "buildFile=build.ID"
set "dontShowInfo=0"
set "autoOpenFolders=1"
set "prevailExt=png"
if not exist "%~dp0sys\" mkdir "%~dp0sys"
if exist "%~dp0sys\settings.cfg" (call :LoadSetFile)
if "%dontShowInfo%"=="1" set "validlog=>>"%~dp0sys\validation_log.txt" 2>&1" &set "codeclog=>>"%~dp0sys\codec_log.txt" 2>&1" &set "ffmpeglog=>>"%~dp0sys\ffmpeg_log.txt" 2>&1"
if exist "%~dp0sys\last_file" if "[%file%]"=="[]" call :Existing
if /i "[%file%]" equ "[$$$convert$$$]" set "file=%~2" &set "home=%~3" &call :SaveSettings &goto :ConvertFolder
if /i "[%file%]" equ "[$$notstrict$$]" set "file=%~2" &set "home=%~3" &call :SaveSettings &goto :NotStrictConvert
if "[%file%]" neq "[]" if exist "%file%" call :New &goto :Menu
call :help
:Settings
call :DrawHead
echo( ____________________________________________________________________________
echo(
if %dontShowInfo%==1 (
echo( 1 - Show Info On The Screen ^(currently data is logged^)) else (echo( 1 - Log Info To A Text File ^(currently data is shown on screen^))
)
echo(
if %autoOpenFolders%==1 (
echo( 2 - Auto Open Folders After A New File Is Created ^(currently is On^)) else (echo( 2 - Auto Open Folders After A New File Is Created ^(currently is Off^))
echo(
echo( 3 - Change Which Image Format To Use ^(currently it is %prevailExt%^)
echo(
echo( 4 - Clear Logs In Sys Folder
echo(
echo( 5 - Exit
echo(
choice /n /m " Please Select A Menu Number:" /c:12345
if errorlevel 1 set k=1
if errorlevel 2 set k=2
if errorlevel 3 set k=3
if errorlevel 4 set k=4
if errorlevel 5 set k=5
if %k%==1 if %dontShowInfo%==1 (set "dontShowInfo=0") else (set "dontShowInfo=1")
if %k%==2 if %autoOpenFolders%==1 (set "autoOpenFolders=0") else (set "autoOpenFolders=1")
if %k%==3 call :ImageFormat
if %k%==4 2>nul del /q "%~dp0sys\*log*.txt
if %k%==5 goto :Menu
call :SaveSetFile
goto :Settings
:ImageFormat
call :DrawHead
echo(&echo( If you change the extension used in the program, you will no longer
echo( be able to edit older project folders that used the current image extension.
echo( You would have to switch back to what ever image format was used if you wanted
echo( to open an older project. Unless you rebuild a folder in Non Strict, which
echo( would allow you to use all different image types.
echo(&echo( Enter The Extension ^(without the "."^) That You Want To Use.
echo( Currently it is %prevailExt%
set /p prevailExt=: || set "prevailExt=png"
call :SaveSetFile
goto :eof
:LoadSetFile
<"%~dp0sys\settings.cfg" (
set /p dontShowInfo=
set /p autoOpenFolders=
set /p prevailExt=
)
goto :eof
:SaveSetFile
>"%~dp0sys\settings.cfg" (
echo(%dontShowInfo%
echo(%autoOpenFolders%
echo(%prevailExt%
)
goto :eof
:Existing
call :LoadSettings
call :SaveSettings
if not exist "%file%" call :NotThere
if not exist "%home%\%IDfile%" call :NotThere
if not exist "%home%\%buildFile%" call :NotThere
call :LoadDetails "%home%\%IDfile%"
goto :menu
pause
:New
call :DrawHead
call :LoadNewFile
%codeclog% "%~dp0bin\MotoLogoCodec.exe" -i "%file%" -o "%name%" -p "%home%" || (if defined "%home%" if exist "%home%\" rd /q "%home%" &call :NoLogo)
echo(&echo( MotoLogo container found, validating data...
%validlog% "%~dp0bin\MotoLogoValidator.exe" -i "%file%" || (
if exist "%home%\logo.bin" (
set "file=%home%\Logo.bin"
%validlog% "%~dp0bin\MotoLogoValidator.exe" -i "!file!" || (if defined home if exist "%home%\" del /q "%home%\*.bin" &rd /q "%home%" &call :ValidFail)
) else (if defined home if exist "%home%\" del /q "%home%\*.bin" &rd /q "%home%" &call :ValidFail)
)
set "file=%home%\logo.bin"
call :SaveSettings
echo(&echo( VALIDATION SUCCESSFUL&echo(
%syslog% move "%~dp0%IDfile%" "%home%\"
call :LoadDetails "%home%\%IDfile%"
call :MakeFolders
echo(&echo( Extracting images....Please wait...&echo(
"%~dp0bin\MotoLogoCodec.exe" -z -c -d -i "%file%" -o "%name%" -p "%home%\%mrDir%"
%syslog% move "%~dp0%buildFile%" "%home%\"
%syslog% move "%home%\%mrDir%\*.bgr24" "%home%\%rawBGRDir%\"
call :ffmpegit "%home%\%rawBGRDir%" "%home%\%imagesDir%"
goto :eof
:ValidFail
echo(&echo(&echo( Container Failed Validataion..
echo( Press any key to exit.
pause>nul
exit
goto :eof
:MakeFolders
2>nul mkdir "%home%\%rawBGRDir%"
2>nul mkdir "%home%\%mrDir%"
2>nul mkdir "%home%\%imagesDir%"
goto :eof
:Menu
call :DrawHead
call :DrawDetails
echo( ____________________________________________________________________________
echo(
echo( 1 - Rebuild %imagesDir% Directory ^(Strict-In Order-Resolution Checks^)
echo(
echo( 2 - Rebuild %imagesDir% Directory ^(Not Strict^)
echo(
echo( 3 - Open Current Project Folder
echo(
echo( 4 - Settings
echo(
echo( 5 - Fastboot Flash Current File
echo(
echo( 6 - Exit
echo(
choice /n /m " Please Select A Menu Number:" /c:123456
if errorlevel 1 set k=1
if errorlevel 2 set k=2
if errorlevel 3 set k=3
if errorlevel 4 set k=4
if errorlevel 5 set k=5
if errorlevel 6 set k=6
if %k%==1 call :ConvertFolder
if %k%==2 call :NotStrictConvert
if %k%==3 start "" "%home%"
if %k%==4 call :Settings
if %k%==5 call :Fla****
if %k%==6 goto :finish
goto :Menu
:Fla****
call :DrawHead
call :DrawDetails
echo(&echo( Your logo is ready to be flashed.&echo(
echo(&echo( Make sure that your device is connected and in Bootloader Mode.
echo(&echo( The following command will be issued:
echo( fastboot flash logo "%file%"
echo(&echo( Press 1 to flash the logo partition, or 2 to go back.&echo(
echo(&echo( 1 - Flash
echo(&echo( 2 - Go Back
echo(
choice /n /m " Please select a menu number:" /c:12
if errorlevel 1 set k=1
if errorlevel 2 set k=2
if !k!==1 (call )
if !k!==2 goto :Menu
"%~dp0bin\fastboot.exe" flash logo "%file%" &&echo. Finished..Press any key to Reboot your device.&&pause>nul&&"%~dp0bin\fastboot.exe" reboot
goto :eof
:NotStrictConvert
call :DrawHead
echo(&echo( This will rebuild all images in the %imageDir% folder.
echo( It will rebuild in alphabetical order while disregarding
echo( original width, height, position in bin file. You can pretty
echo( much put any image format in here and get an encoded bin file.
echo( Press 1 to Continue or 2 to Go Back
echo(&echo( 1 - Continue
echo(&echo( 2 - Go Back
echo(
choice /n /m "please select a menu number:" /c:12
if errorlevel 1 set k=1
if errorlevel 2 set k=2
if !k!==1 (call )
if !k!==2 goto :Menu
if exist "%home%\errors.txt" del /q "%home%\errors.txt"
if not exist "%home%\%IDfile%" call :NotThere
if not exist "%home%\%buildFile%" call :NotThere
call :LoadDetails "%home%\%IDfile%"
if defined home if exist "%home%\" rd /s /q "%home%\Not_Strict_Modified\" 2>nul
2>nul md "%home%\Not_Strict_Modified"
2>nul md "%home%\Not_Strict_Modified\%rawBGRDir%"
2>nul md "%home%\Not_Strict_Modified\%mrDir%"
set /a imageCount=0
2>nul del /q "%home%\%imagesDir%\Thumbs.db"
for /f %%a in ('dir /b /a-d-h "%home%\%imagesDir%\*.*"') do (
set /a imageCount=!imageCount!+1
echo( Converting: %%a
set "name=%%~na"
set name=!name:~0,24!
for /f "tokens=1-8* delims=," %%A in ('bin\ffmpeg -hide_banner -i "%home%\%imagesDir%\%%a" -f rawvideo -vcodec rawvideo -pix_fmt bgr24 -y "%home%\Not_Strict_Modified\%rawBGRDir%\!name!.bgr24" 2^>^&1^|findstr /rxic:".*stream #0:0.*[0-9]x[0-9].*"') do (
echo(%%A >"%home%\imageres"
echo(%%B >>"%home%\imageres"
echo(%%C >>"%home%\imageres"
echo(%%D >>"%home%\imageres"
echo(%%E >>"%home%\imageres"
echo(%%F >>"%home%\imageres"
echo(%%G >>"%home%\imageres"
echo(%%H >>"%home%\imageres"
)
for /f "tokens=1-3 delims=x " %%I in ('type "%home%\imageres"^|findstr /rxic:".*[0-9]x[0-9].*"') do set /a width=%%I &set /a height=%%J
if not defined width echo( Error: "Width undefined in %%a">>"%home%\errors.txt"
if not defined height echo( Error: "Height undefined in %%a">>"%home%\errors.txt"
if not exist "%home%\Not_Strict_Modified\%rawBGRDir%\!name!.bgr24" echo( Error: "%home%\Not_Strict_Modified\%rawBGRDir%\!name!.bgr24" Was not created.>>"%home%\errors.txt"
echo( Encoding: !name!.bgr24
%codeclog% "%~dp0bin\MotoLogoCodec.exe" -e -i "%home%\Not_Strict_Modified\%rawBGRDir%\!name!.bgr24" -o "%home%\Not_Strict_Modified\%mrDir%\!name!.mr" -w !width! -h !height!
if not exist "%home%\Not_Strict_Modified\%mrDir%\!name!.mr" echo( Error: "%home%\Not_Strict_Modified\%mrDir%\!name!.mr" Was not sucessfully encoded.>>"%home%\errors.txt"
echo(!name!?%home%\Not_Strict_Modified\%mrDir%\!name!.mr>>"%home%\Not_Strict_Modified\%buildFile%"
set check=
)
del /q "%home%\imageres"
if exist "%home%\errors.txt" call :Error
echo( Rebuilding Encoded Files...
"%~dp0bin\BuildMotoLogo.exe" <"%home%\Not_Strict_Modified\%buildFile%" -o "%home%\Not_Strict_Modified\build.bin" -n %imageCount%
%validlog% "%~dp0bin\MotoLogoValidator.exe" -i "%home%\Not_Strict_Modified\build.bin" || goto :RebuildError
set "file=%home%\Not_Strict_Modified\build.bin"
set "home=%home%\Not_Strict_Modified"
call :SaveSettings
%syslog% move "%~dp0%IDfile%" "%home%\"
call :LoadDetails "%home%\%IDfile%"
echo( Validation succesful
2>nul md "%home%\%imagesDir%"
call :ffmpegit
goto :Menu
:ConvertFolder
call :DrawHead
if exist "%home%\errors.txt" del /q "%home%\errors.txt"
if not exist "%home%\%IDfile%" call :NotThere
if not exist "%home%\%buildFile%" call :NotThere
call :LoadDetails "%home%\%IDfile%"
echo(&echo( Checking Resolutions..
if defined home if exist "%home%\" rd /s /q "%home%\Modified\" 2>nul
2>nul md "%home%\Modified"
2>nul md "%home%\Modified\%rawBGRDir%"
2>nul md "%home%\Modified\%mrDir%"
for /l %%a in (1,1,%images%) do (
echo( Converting: !logoName[%%a]!
if not exist "%home%\%imagesDir%\!logoName[%%a]!.%prevailExt%" (
call :DrawHead
echo(&echo( An image for !logoName[%%a]! is missing in the %imagesDir% folder.
echo(&echo( If you are trying to remove an image from you bin file, you need
echo( to rebuild the %imagesDir% folder in Non Strict Mode.
echo(&echo( Press any key to return to the menu.
pause>nul
goto :Menu
)
for /f "tokens=1-8* delims=," %%A in ('bin\ffmpeg -hide_banner -i "%home%\%imagesDir%\!logoName[%%a]!.%prevailExt%" -f rawvideo -vcodec rawvideo -pix_fmt bgr24 -y "%home%\Modified\%rawBGRDir%\!logoName[%%a]!.bgr24" 2^>^&1^|findstr /rxic:".*stream #0:0.*[0-9]x[0-9].*"') do (
echo(%%A >"%home%\imageres"
echo(%%B >>"%home%\imageres"
echo(%%C >>"%home%\imageres"
echo(%%D >>"%home%\imageres"
echo(%%E >>"%home%\imageres"
echo(%%F >>"%home%\imageres"
echo(%%G >>"%home%\imageres"
echo(%%H >>"%home%\imageres"
)
for /f "tokens=1-3 delims=x " %%I in ('type "%home%\imageres"^|findstr /rxic:".*[0-9]x[0-9].*"') do set /a width=%%I &set /a height=%%J
if not defined width echo( Error: "Width undefined in !logoName[%%a]!.%prevailExt%">>"%home%\errors.txt"
if not defined height echo( Error: "Height undefined in !logoName[%%a]!.%prevailExt%">>"%home%\errors.txt"
if !width! neq !logoWidth[%%a]! set check=1
if !height! neq !logoHeight[%%a]! set check=1
if defined check call :Aspect !width! !height! !logoWidth[%%a]! !logoHeight[%%a]! "%home%\%imagesDir%\!logoName[%%a]!.%prevailExt%" "%home%\Modified\%rawBGRDir%\!logoName[%%a]!.bgr24" "!logoName[%%a]!"
if not exist "%home%\Modified\%rawBGRDir%\!logoName[%%a]!.bgr24" echo( Error: "%home%\Modified\%rawBGRDir%\!logoName[%%a]!.bgr24" Was not created.>>"%home%\errors.txt"
echo( Encoding: !logoName[%%a]!
%codeclog% "%~dp0bin\MotoLogoCodec.exe" -e -i "%home%\Modified\%rawBGRDir%\!logoName[%%a]!.bgr24" -o "%home%\Modified\%mrDir%\!logoName[%%a]!.mr" -w !width! -h !height!
if not exist "%home%\Modified\%mrDir%\!logoName[%%a]!.mr" echo( Error: "%home%\Modified\%mrDir%\!logoName[%%a]!.mr" Was not sucessfully encoded.>>"%home%\errors.txt"
echo(!logoName[%%a]!?%home%\Modified\%mrDir%\!logoName[%%a]!.mr>>"%home%\Modified\%buildFile%"
set check=
set width=
set height=
)
del /q "%home%\imageres"
if exist "%home%\errors.txt" call :Error
echo( Rebuilding Encoded Files...
"%~dp0bin\BuildMotoLogo.exe" <"%home%\Modified\%buildFile%" -o "%home%\Modified\build.bin" -n %images%
%validlog% "%~dp0bin\MotoLogoValidator.exe" -i "%home%\Modified\build.bin" || goto :RebuildError
set "file=%home%\Modified\build.bin"
set "home=%home%\Modified"
call :SaveSettings
%syslog% move "%~dp0%IDfile%" "%home%\"
call :LoadDetails "%home%\%IDfile%"
echo( Validation succesful
2>nul md "%home%\%imagesDir%"
call :ffmpegit
goto :Menu
:Aspect
set check=
set /a border=5
set /a border2=2*%border%
echo(&echo( Image: %~7
set /a newAspect=%aspectMultiplier%*%1/%2
set /a originalAspect=%aspectMultiplier%*%3/%4
echo(
echo( The resolution for %7 is different from the original image.
echo( New : %1x%2
echo( Original: %3x%4
echo(
echo( ____________________________________________________________________________
if "%originalAspect%"=="%newAspect%" (
echo(
echo( 1 - Stretch Or Shrink The Image To Fit The Original Size
echo(
echo( 2 - Do Nothing And Continue
echo(
choice /n /m "please select a menu number:" /c:12
if errorlevel 1 set k=1
if errorlevel 2 set k=2
if !k!==1 set "videoFilters=-vf "scale=%3:%4""
if !k!==2 goto :eof
) else (
echo(
if %3 gtr %4 (echo( 1 - Resize And Crop While Keeping The Original Aspect And Size ^(Upper Image^)) else (echo( 1 - Resize And Crop While Keeping The Original Aspect And Size ^(Left Image^))
echo(
if %3 gtr %4 (echo( 2 - Stretch Or Shrink The Image To Fit The Original Size ^(Lower Image^)) else (echo( 2 - Stretch Or Shrink The Image To Fit The Original Size ^(Right Image^))
echo(
echo( 3 - Do Nothing And Continue With %1x%2 Image
echo(
if %4 lss %3 (set /a ffw=%3+2*%border%&set /a ffh=%4*2+3*%border%&set "overlay=overlay=%border%:h+%border2%") else (set /a ffw=%3*2+3*%border%&set /a ffh=%4+2*%border%&set "overlay=overlay=w+%border2%:%border%")
if %originalAspect% lss %newAspect% (set "scale=scale=-1:%4") else (set "scale=scale=%3:-1")
"%~dp0bin\ffmpeg.exe" -loglevel fatal -i "%~5" -i "%~5" -filter_complex "color=red:!ffw!x!ffh!:1[bg];[0]!scale!, crop=%3:%4[sc0];[1]scale=%3:%4[sc1];[bg][sc0]overlay=%border%:%border%[x];[x][sc1]!overlay!" -y "%home%\test.png"%ffmpeglog%
if exist "%home%\test.png" if defined useDefaultViewer (start "" "%home%\test.png") else (rundll32 "%ProgramFiles%\Windows Photo Viewer\PhotoViewer.dll", ImageView_Fullscreen %home%\test.png)
choice /n /m "please select a menu number:" /c:123
if errorlevel 1 set k=1
if errorlevel 2 set k=2
if errorlevel 3 set k=3
if !k!==1 (
if %originalAspect% gtr %newAspect% set "videoFilters=-vf "scale=%3:-1, crop=%3:%4""
if %originalAspect% lss %newAspect% set "videoFilters=-vf "scale=-1:%4, crop=%3:%4""
)
if !k!==2 set "videoFilters=-vf "scale=%3:%4""
if !k!==3 goto :eof
2>nul del /q "%home%\test.png"
)
set /a width=%3
set /a height=%4
%ffmpeglog% "%~dp0bin\ffmpeg.exe" %ffdebug% %ffshowb% -i "%~5" !videoFilters! -f rawvideo -vcodec rawvideo -pix_fmt bgr24 -y "%~6"
goto :eof
:RebuildError
echo( There was a problem rebuilding the images..
echo( Press any key to exit.
pause>nul
goto :Finish
:Error
call :DrawHead
echo(&type "%home%\errors.txt"
echo(&echo( Press any key to exit..
pause >nul
goto :Finish
:DrawHead
cls echo( _________________________________________________________________________-_-
echo( Motorola Image Injector v%vers%
echo(
echo( written by Makers_Mark
echo( ____________________________________________________________________________
goto :eof
:DrawFileInfo
echo( File: %file% &echo( Size: %fileSize% Bytes ^(%megaSize%.%megaDeci% MB^)&echo( ____________________________________________________________________________
goto :eof
:DrawDetails
call :DrawFileInfo
"%~dp0bin\DrawDetails.exe" <"%home%\%IDfile%"
goto :eof
:NoLogo
call :DrawHead
echo(&echo( No Motorola Logo Images were found in the file.
echo( Press any key to exit....
pause>nul
exit
:LoadDetails
set /a images=0
for /f "tokens=1-7 delims=," %%t in ('type "%~1"') do (
set /a images+=1
set "logoName[!images!]=%%t" &set /a logoOffset[!images!]=%%y &set /a logoSize[!images!]=%%z &set /a logoSizeTotal[!images!]=%%w
set /a logoBlocks[!images!]=%%x &set /a logoWidth[!images!]=%%u &set /a logoHeight[!images!]=%%v
)
goto :eof
:dupename
if not exist "%~dp0%workhere%\!%~1!\" (goto :eof)
set /a unique=1
:dupe
if not exist "%~dp0%workhere%\!%~1!.%unique%\" (
set "%~1=!%~1!.%unique%"
goto :eof
) else (
set /a unique+=1
goto :dupe
)
goto :eof
:LoadNewFile
for %%? in ("%file%") do set /a "size=%%~z?" &set "filename=%%~nx?" &set "ext=%%~x?" &set "name=%%~n?"
set "newDir=%name%"
call :dupename "newDir"
set "home=%~dp0%workHere%\%newDir%"
2>nul mkdir "%home%"
goto :eof
:LoadSettings
<"%~dp0sys\last_file" (
set /p file=
set /p home=
set /p fileSize=
)
call :StripQuotes %file% %home%
goto :eof
:StripQuotes
set "file=%~1"
set "home=%~2"
goto :eof
:SaveSettings
for %%? in ("%file%") do set fileSize=%%~z?
set /a fileSize
set /a megaSize=%fileSize%/(1024*1024)
set /a remain=%fileSize% %% (1024*1024)
set /a megaDeci=(%remain%*1000)/(1024*1024)
>"%~dp0sys\last_file" (
echo("%file%"
echo("%home%"
echo(%fileSize%
)
goto :eof
:ffmpegit
echo( Converting Images Into %prevailExt% Images...
(for /f %%a in ('dir /b/a-d "%home%\%rawBGRDir%\*.bgr24"') do (
for /l %%? in (1, 1, %images%) do (
if "%%~na"=="!logoName[%%?]!" (
call set /a width=!logoWidth[%%?]!"
call set /a height=!logoHeight[%%?]!
)
)
"%~dp0bin\ffmpeg.exe" %ffdebug% %ffshowb% -loglevel fatal -f rawvideo -vcodec rawvideo -s !width!x!height! -pix_fmt bgr24 -i "%home%\%rawBGRDir%\%%~nxa" -y "%home%\%imagesDir%\%%~na.%prevailExt%"
))%ffmpeglog%
>"%home%\Make MotoLogo Bin From %imagesDir% Folder.bat" (
echo(@echo off
echo(cmd ^/c ^""%~dpnx0" $$$convert$$$ "%file%" "%home%"^"
echo(
)
>"%home%\Make MotoLogo Bin (Not Strict) From %imagesDir% Folder.bat" (
echo(@echo off
echo(cmd ^/c ^""%~dpnx0" $$notstrict$$ "%file%" "%home%"^"
echo(
)
if %autoOpenFolders%==1 start "" "%home%\"
goto :eof
:help
call :DrawHead
echo(&echo(
echo( You have to drag a file onto this batch file,
echo( in order to load a file into it.
echo( Press a key to close this window and exit.
pause >nul
goto :finish
:NotThere
call :Drawhead
echo(&echo(
echo( File^(s^) are missing. Reload File by dragging and dropping onto
echo( this batch file again.
echo( Press a key to close this window and exit.
pause>nul
goto :finish
:Finish
cls&exit
goto :eof
DrawDetails.c
Code:
#include <string.h>
#include <stdio.h>
#include <windows.h>
int main()
{
char *s = "," ;
char *token ;
int i , j = 1 , k , color ;
char line[80];
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO consoleInfo;
WORD originalColor;
GetConsoleScreenBufferInfo(hConsole, &consoleInfo);
originalColor = consoleInfo.wAttributes;
printf(" ____________________________________________________________________________\n");
printf(" Image Name WxH Size+ Blocks Offset Raw Size \n");
printf(" _________________________________________________________________________-_-\n");
while(fgets(line, sizeof line, stdin) != NULL){
if (( j % 2 ) == 0) {
color = 0x0B;
} else {
color = 0xB0;
}
SetConsoleTextAttribute(hConsole, color);
token = strtok(line, s);
for ( i = 0; i < 7; i++){
if (i==0){
printf(" %2d.%-24s", j,token);
token = strtok(NULL,s);
} else if ( i == 1 ){
printf("%dx", atoi(token));
token = strtok(NULL,s);
} else if ( i == 2 ){
printf("%d\t", atoi(token));
token = strtok(NULL,s);
} else if (( i > 2) && ( i < 6 )){
printf("%d\t", atoi(token));
token = strtok(NULL,s);
} else {
printf("%-13d\r\n", atoi(token));
token = strtok(NULL,s);
}
}
j++;
}
SetConsoleTextAttribute(hConsole, originalColor);
}
SOURCE:
MotoLogoCodec.c
Code:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#define OUT_FILE "logo.bin"
#define MOTOLOGO_BARE_HEADER 13
#define MOTOLOGO_IMG_BLK_SIZE 32
#define BIT_SET 0x8000
#define IS_BIT_SET(x) (x & BIT_SET)
#define COLORS 3
#define SWAP(x) (((x & 0xFF00) >> 8) | ((x & 0x00FF) << 8))
typedef struct {
unsigned short count;
unsigned char color[COLORS];
} motoSet;
typedef struct {
char header[8];
unsigned short width;
unsigned short height;
} motoHead;
typedef struct {
char name[24];
unsigned long offset;
unsigned long size;
unsigned short totalBlocks;
unsigned long totalSize;
motoHead imageHead;
} imageHead;
typedef struct {
unsigned char r;
unsigned char g;
unsigned char b;
} pixel;
void MotoRunEncode(void);
int FindMotoLogo(void);
int ParseHeader(unsigned long, int);
void CutMRImageOut(int, char*, unsigned long);
unsigned long int BlockIt(unsigned long int);
void MotoDecode(int, char*, unsigned short, unsigned short, unsigned long, int);
unsigned short pad = 1;
unsigned short addDetails = 0;
unsigned short cutMR = 0;
unsigned short decode = 0, encode = 0;
unsigned short blockSize = 512;
unsigned short pos = 0;
unsigned short filesFound = 0;
unsigned short logoOutput = 1;
unsigned short width = 0, height = 0;
char *inputFile, *base, *path;
char *motoLogoHeader;
unsigned long start, end;
FILE *inStream;
FILE *outStream;
char command[512];
char padByte = 0xff;
void MotoRunEncode(void)
{
unsigned int i,ind, m;
pixel line[width];
unsigned short count;
motoHead motoRunHeader;
if ((inStream = fopen(inputFile, "rb")) == NULL){
fclose(inStream);
fprintf(stderr, "\n%s\nCould not be opened.", inputFile);
return;
}
if ((outStream = fopen(base, "wb")) == NULL){
fclose(inStream);
fclose(outStream);
fprintf(stderr, "\n%s\nCould not be opened.", base);
return;
}
motoRunHeader.header[0] = 0x4D;
motoRunHeader.header[1] = 0x6F;
motoRunHeader.header[2] = 0x74;
motoRunHeader.header[3] = 0x6F;
motoRunHeader.header[4] = 0x52;
motoRunHeader.header[5] = 0x75;
motoRunHeader.header[6] = 0x6E;
motoRunHeader.header[7] = 0x00;
motoRunHeader.width = SWAP(width);
motoRunHeader.height = SWAP(height);
fwrite(&motoRunHeader, 1, sizeof(motoRunHeader), outStream);
for (i = 1; i <= height; i++){
fread(line, COLORS, width, inStream);
for (ind = 0, count = 0 ; ind <= width - 1; ){
if ((memcmp(&line[ind], &line[ind+1], 3) == 0)){
ind++;
count = 1;
while((ind <= width - 2) && ((memcmp(&line[ind], &line[ind+1], 3))== 0)){
count++;
ind++;
}
if (count == 1){
count++;
ind++;
goto LOOP;
} else {
count++;
count |= BIT_SET;
count = SWAP(count);
fwrite(&count, 1, 2, outStream);
fwrite(&line[ind], 1, 3, outStream);
}
ind++;
} else {
count = 1;
ind++;
LOOP:
while (((ind >= width -2)&&(ind <= width -1)) || ((ind <= width - 2) && (memcmp(&line[ind], &line[ind+1], 3) != 0)) || ((ind <= width - 3) && (memcmp(&line[ind+1], &line[ind+2], 3) != 0))){
count++;
ind++;
}
count = SWAP(count);
fwrite(&count, 1, 2, outStream);
fwrite(&line[ind - SWAP(count)], SWAP(count), COLORS, outStream);
continue;
}
}
}
return;
}
int FindMotoLogo(void)
{
char header[] = {0x4D,0x6F,0x74,0x6F,0x4C,0x6F,0x67,0x6F,0x00};
unsigned long int firstOffset;
int readByte;
char string[9];
if ((inStream = fopen(inputFile, "rb")) == NULL){
fclose(inStream);
fprintf(stderr, "\n%s\nCould not be opened.", inputFile);
return;
}
int inNumber = fileno(inStream);
while ((readByte = fgetc(inStream)) != EOF){
if (readByte == header[pos]){
if (pos == 8){
start = (ftell(inStream) - 9);
fseek(inStream, start + 9, SEEK_SET);
read(inNumber, &end, 4);
fseek(inStream, start + 9 + 4 + 24, SEEK_SET );
read(inNumber, &firstOffset, 4);
fseek(inStream, start + firstOffset, SEEK_SET );
read(inNumber, &string, 9);
if (strcmp(string, "MotoRun") == 0){
fseek(inStream, start + 13, SEEK_SET );
return (ParseHeader(end, inNumber));
} else {
pos = 0;
fseek(inStream, start + 9, SEEK_SET );
continue;
}
} else {
pos++;
continue;
}
}
pos = 0;
}
close(inNumber);
fprintf(stderr,"\n%d MotoLogo (logo.bin) files found.", filesFound);
return;
}
int ParseHeader(unsigned long end, int inNumber)
{
unsigned int imageCounter = (end - MOTOLOGO_BARE_HEADER) / MOTOLOGO_IMG_BLK_SIZE;
imageHead motomoto[imageCounter];
int i;
unsigned long logoSize, pos;
for(i=0; i < imageCounter; i++){
read(inNumber, &motomoto[i], 32);
motomoto[i].totalSize = BlockIt(motomoto[i].size);
motomoto[i].totalBlocks = (motomoto[i].totalSize /blockSize);
fprintf(stdout,"\nName: %s\nOffset in Logo.bin: %ld\nImage Data Size: %ld",motomoto[i].name, motomoto[i].offset, motomoto[i].size);
fprintf(stdout,"\nTotal Size: %ld",motomoto[i].totalSize);
fprintf(stdout,"\nTotal Blocks: %d",motomoto[i].totalBlocks);
pos = ftell(inStream);
fseek(inStream, start + motomoto[i].offset, SEEK_SET);
if (cutMR){
CutMRImageOut(inNumber, motomoto[i].name, motomoto[i].size);
fseek(inStream, start + motomoto[i].offset, SEEK_SET); //moved this line inside the parentheses
}
read(inNumber, &motomoto[i].imageHead, 12);
motomoto[i].imageHead.width = SWAP(motomoto[i].imageHead.width);
motomoto[i].imageHead.height = SWAP(motomoto[i].imageHead.height);
fprintf(stdout,"\nWidth x Height: %dx%d",motomoto[i].imageHead.width,motomoto[i].imageHead.height);
fprintf(stdout,"\nHeader: %s\n\n",motomoto[i].imageHead.header);
if (decode){
MotoDecode(inNumber, motomoto[i].name, motomoto[i].imageHead.width, motomoto[i].imageHead.height, motomoto[i].size , i+1);
}
fseek(inStream, pos, SEEK_SET);
}
logoSize = motomoto[imageCounter-1].offset + motomoto[imageCounter-1].totalSize;
fprintf(stdout,"\nLogo.bin contains %ld image files and is %ld bytes in size", i, logoSize);
if (!(logoOutput)){
return 0;
}
sprintf(command,"%s\\%s", path , OUT_FILE );
if ((outStream = fopen(command, "wb")) == NULL){
fclose(outStream);
fprintf(stderr, "\n%s\\%s could not be opened.", path, OUT_FILE);
return 1;
}
int outNumber = fileno(outStream);
fseek(inStream, start, SEEK_SET );
char* logobin = malloc(logoSize);
read(inNumber, logobin, logoSize);
write(outNumber, logobin, logoSize);
close(outNumber);
free(logobin);
return 0;
}
void CutMRImageOut(int inNumber, char* name, unsigned long size){
char newName[26];
FILE *txt;
sprintf(command,"%s\\%s.mr", path , name );
if ((txt = fopen("build.ID", "a")) == NULL){
fclose(txt);
fprintf(stderr, "\nBuild.ID could not be opened.\n");
return;
}
if ((outStream = fopen(command, "wb")) == NULL){
fclose(outStream);
fclose(txt);
fprintf(stderr, "\n%s\\%s.mr could not be opened", path, name);
return;
}
sprintf(command,"%s\n", command );
sprintf(newName, "%s?", name);
fwrite(newName, strlen(newName), 1, txt);
fwrite(command, strlen(command), 1, txt);
fclose(txt);
int outNumber = fileno(outStream);
char *dataStream = malloc(size);
read(inNumber, dataStream, size);
write(outNumber, dataStream, size);
if (pad){
if ((size % blockSize) != 0){
unsigned int max = blockSize - (size % blockSize ), i;
for (i = 0; i < max; i++){
write(outNumber, &padByte , 1);
}
fprintf(stdout,"\n%d bytes padded to %s", max, name);
}
}
close(outNumber);
free(dataStream);
return;
}
unsigned long int BlockIt(unsigned long int isize){
if ((isize % blockSize) == 0){
return isize;
}else{
return isize + (blockSize - (isize %blockSize));
}
}
void MotoDecode(int inNumber, char* name, unsigned short width, unsigned short height, unsigned long size, int index)
{
unsigned short repeats, count;
unsigned char color[3];
unsigned long counter = 0;
motoSet data;
if (addDetails){
sprintf(command, "%s\\%03d_%dx%d_%s.bgr24", path , index, width, height, name);
} else {
sprintf(command, "%s\\%s.bgr24", path, name);
}
if ((outStream = fopen(command, "wb")) == NULL){
fclose(outStream);
fprintf(stderr, "\n%s\nCould not be opened.", command);
return;
}
int outNumber = fileno(outStream);
while((read(inNumber, &data, 5) != EOF) && (counter < size)){
counter += 5;
if ((counter >= size ) || (data.count == 0xffff)){
close(outNumber);
return;
}
data.count = SWAP(data.count);
if (IS_BIT_SET(data.count)){
data.count &= ~BIT_SET;
for (repeats = 0;repeats < data.count; repeats++){
write(outNumber, &data.color, COLORS);
}
} else {
write(outNumber, &data.color, COLORS);
for (repeats = 0; repeats < data.count -1; repeats++){
counter += COLORS;
if ((read(inNumber, color, COLORS) == EOF) || counter >= size){
write(outNumber, &color, COLORS);
close(outNumber);
return;
}
write(outNumber, &color, COLORS);
}
}
}
close(outNumber);
return;
}
int main(int argc, char **argv)
{
int c;
while ((c = getopt (argc, argv, "i:o:p:b:w:h:cdezna")) != -1){
switch(c)
{
case 'a':
addDetails = 1;
break; //add index number and resolution to decoded filenames
case 'i':
inputFile = optarg;
break;
case 'o':
base = optarg;
break;
case 'p':
path = optarg;
break;
case 'b':
blockSize = atoi(optarg);
break;
case 'c':
cutMR = 1;
break;
case 'd':
decode = 1;
break;
case 'e':
encode = 1;
break;
case 'z':
pad = 0;
break;
case 'n':
logoOutput = 0;
break;
case 'w':
width = atoi(optarg);
break;
case 'h':
height = atoi(optarg);
break;
}
}
if (encode == 1){
MotoRunEncode();
return;
}
return(FindMotoLogo());
}
MotoLogoValidator.c
Code:
/*
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#define MOTOLOGO_BARE_HEADER 13
#define MOTOLOGO_IMG_BLK_SIZE 32
#define BIT_SET 0x8000
#define IS_BIT_SET(x) (x & BIT_SET)
#define COLORS 3
#define SWAP(x) (((x & 0xFF00) >> 8) | ((x & 0x00FF) << 8))
typedef struct {
unsigned short count;
unsigned char color[COLORS];
} motoSet;
typedef struct {
char header[8];
unsigned short width;
unsigned short height;
} motoHead;
typedef struct {
char name[24];
unsigned long offset;
unsigned long size;
unsigned short totalBlocks;
unsigned long totalSize;
motoHead imageHead;
} imageHead;
typedef struct {
unsigned char r;
unsigned char g;
unsigned char b;
} pixel;
int FindMotoLogo();
int ValidateMotoLogoHeader();
unsigned long int BlockIt(unsigned long int);
int VerifyImages(char*, unsigned short, unsigned short, unsigned long);
unsigned short pos, inNumber, blockSize = 512;
char *inputFile;
unsigned long start, end;
FILE *inStream;
FILE *txt;
char command[512];
char padByte = 0xff;
int FindMotoLogo()
{
char header[] = {0x4D,0x6F,0x74,0x6F,0x4C,0x6F,0x67,0x6F,0x00};
unsigned long int firstOffset;
int readByte;
char string[9];
for (pos = 0 ; pos <= 8 ; pos++ ){
if ((readByte = fgetc(inStream)) == header[pos]){
fprintf(stdout,"\nHeader:\n%d %02x",pos, header[pos]);
if (pos == 8){
fprintf(stdout, "\nHeader Match");
start = 0;
fseek(inStream, start + 9, SEEK_SET);
read(inNumber, &end, 4);
fseek(inStream, start + 9 + 4 + 24, SEEK_SET );
read(inNumber, &firstOffset, 4);
fseek(inStream, start + firstOffset, SEEK_SET );
read(inNumber, &string, 9);
if (strcmp(string, "MotoRun") == 0){
fseek(inStream, start + 13, SEEK_SET );
fprintf(stdout,"\nEnd of MotoLogo Header is byte %d.\n", end);
return 0;
} else {
fprintf(stderr,"\nFirst offset in MotoLogo header doesn't point to an image header.");
return 1;
}
} else {
continue;
}
} else {
fprintf(stderr,"\nFile: %s\ndoes not start with a valid MotoLogo header.", inputFile);
return 1;
}
}
return 1;
}
int ValidateMotoLogoHeader()
{
unsigned int imageCounter = (end - MOTOLOGO_BARE_HEADER) / (MOTOLOGO_IMG_BLK_SIZE);
fprintf(stdout,"\n%d images referenced in header.\nChecking Images.\n", imageCounter);
imageHead motomoto[imageCounter];
int i;
char motoRunHeader[] = "MotoRun\0";
fseek(inStream, 13, SEEK_SET);
for(i=0; i < imageCounter; i++){
read(inNumber, &motomoto[i], 32); //add an if parameter switch for the last element not to include the padding
motomoto[i].totalSize = BlockIt(motomoto[i].size);
motomoto[i].totalBlocks = (motomoto[i].totalSize /blockSize);
fprintf(stdout,"\nName: \"%s\"\nOffset In File: %ld\nImage Data Size: %ld",motomoto[i].name, motomoto[i].offset, motomoto[i].size);
fprintf(stdout,"\nTotal Size With Padding: %ld",motomoto[i].totalSize);
fprintf(stdout,"\nTotal Blocks: %d",motomoto[i].totalBlocks);
if (i != 0){
if ((motomoto[i-1].offset + motomoto[i-1].totalSize) == (motomoto[i].offset)){
fprintf(stdout, "\nOffsets match!");
} else {
fprintf(stderr, "\nOffsets do not match between %s and %s.\nVALIDATION FAILURE!\n", motomoto[i-1].name, motomoto[i].name);
return 1;
}
} else {
if (motomoto[i].offset == BlockIt(end)){
fprintf(stdout, "\nOffsets Match!");
} else {
fprintf(stderr, "\n%d is offset and %d is the end of the MotoLogo Header\nVALIDATION FAILURE!\n", motomoto[i].offset, BlockIt(end));
return 1;
}
}
pos = ftell(inStream);
fseek(inStream, motomoto[i].offset, SEEK_SET);
read(inNumber, &motomoto[i].imageHead, 12);
motomoto[i].imageHead.width = SWAP(motomoto[i].imageHead.width);
motomoto[i].imageHead.height = SWAP(motomoto[i].imageHead.height);
fprintf(stdout,"\nWidth x Height: %dx%d",motomoto[i].imageHead.width,motomoto[i].imageHead.height);
fprintf(stdout,"\nExpected Pixels: %d", (motomoto[i].imageHead.width * motomoto[i].imageHead.height));
if(strcmp(motoRunHeader, motomoto[i].imageHead.header) != 0){
fprintf(stderr, "\nHeader Should be \"%s\", not \"%s\"\nVALIDATION FAILED!\n", motoRunHeader, motomoto[i].imageHead.header);
return 1;
}
fprintf(stdout,"\nHeader: \"%s\"",motomoto[i].imageHead.header);
if (!VerifyImages(motomoto[i].name, motomoto[i].imageHead.width, motomoto[i].imageHead.height, motomoto[i].size - 12)){
fseek(inStream, pos, SEEK_SET);
continue;
} else {
return 1;
}
}
if ((txt = fopen("MoID.ID", "w")) == NULL){
fclose(txt);
fprintf(stderr, "\nMoID.ID could not be opened.\n");
return 1;
}
for(i=0; i < imageCounter; i++){
fprintf(txt, "%s,%d,%d,%d,%d,", motomoto[i].name, motomoto[i].imageHead.width, motomoto[i].imageHead.height, motomoto[i].totalSize, motomoto[i].totalBlocks);
fprintf(txt, "%d,%d\n", motomoto[i].offset, motomoto[i].size);
}
fclose(txt);
return 0;
}
unsigned long int BlockIt(unsigned long int isize){
if ((isize % blockSize) == 0){
return isize;
}else{
return isize + (blockSize - (isize %blockSize));
}
}
int VerifyImages(char* name, unsigned short width, unsigned short height, unsigned long size)
{
unsigned short line = 0, pixelsonline = 0;
unsigned long pixelsDecoded = 0, totalPixels = 0, bytesRead = 0;
motoSet data;
unsigned long posi;
while(bytesRead < size){
if ((bytesRead += read(inNumber, &data, 5)) == EOF){
return 0;
}
data.count = SWAP(data.count);
if (IS_BIT_SET(data.count)){
data.count &= ~BIT_SET;
pixelsonline += data.count;
} else {
posi = ftell(inStream);
fseek(inStream, (posi + (COLORS * (data.count - 1))), SEEK_SET);
pixelsonline += data.count;
bytesRead = bytesRead + (COLORS * (data.count - 1));
}
if (pixelsonline == width){
line++;
pixelsDecoded += pixelsonline;
pixelsonline = 0;
}
if ((pixelsonline == width) && ((pixelsDecoded / line) == pixelsonline)){
line++;
pixelsonline = 0;
}
}
fprintf(stdout,"\nPixels Decoded: %d\nBytes Read: %d\nSize Minus Header: %d\nLines Properly Terminated: %d", pixelsDecoded, bytesRead, size , line);
if ((pixelsDecoded == width * height) && (bytesRead == size) && (height == line )){
fprintf(stdout,"\n\"%s\" Is Encoded Correctly\n", name);
return 0;
}
if (pixelsDecoded != (width * height)){
fprintf(stderr, "\nThe total pixels decoded, %d, doesn't equal the resolution: %dx%d=%d",pixelsDecoded, width, height, (width * height));
}
if (bytesRead != size){
fprintf(stderr, "\nThe total bytes read, %d, is not equal to the encoded size, %d.", bytesRead, size);
}
if (height != line ){
fprintf(stderr, "\nAt least one run in the encoding runs past the edge of the screen.\nThis will not work.");
}
fprintf(stderr, "\n%s is not encoded correctly\nVALIDATION FAILURE!\n", name);
return 1;
}
int main(int argc, char **argv)
{
int c;
while ((c = getopt (argc, argv, "i:b:")) != -1){
switch(c)
{
case 'i':
inputFile = optarg;
break;
case 'b':
blockSize = atoi(optarg);
break;
}
}
if ((inStream = fopen(inputFile, "rb")) == NULL){
fclose(inStream);
fprintf(stderr, "\n%s\nCould not be opened.\n", inputFile);
return 1;
}
inNumber = fileno(inStream);
if (!FindMotoLogo()){
if (!ValidateMotoLogoHeader()){
fclose(inStream);
return 0;
}
}
fclose(inStream);
return 1;
}
BuildMotoLogo.c v1.1
Code:
/* Version 1.1
Fixed error with encoded files that have a file size that is
evenly divisible by 512
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
typedef struct {
char name[24];
unsigned long offset;
unsigned long size;
unsigned long sizeWithPadding;
} imageHead;
unsigned long int ReadList(void);
unsigned int GetHeaderSize(void);
unsigned long int BlockIt(unsigned long int);
char *txtFileName;
FILE *inFile;
FILE *outFile;
char *outputFileName;
unsigned short images = 0;
unsigned short blockSize = 512;
unsigned long int ReadList(void){
char header[] = {0x4D,0x6F,0x74,0x6F,0x4C,0x6F,0x67,0x6F,0x00};
char line[512];
int readByte;
imageHead Item[images];
unsigned long int totalDataSize = 0;
int i = 0 , k = 0 , l = 0;
unsigned char padByte = 255;
unsigned long sizes[images];
char *s = "?";
char *tok;
unsigned long int hs;
if ((outFile = fopen (outputFileName, "wb")) == NULL){
perror("\nError opening output file:");
fclose(outFile);
}
hs = GetHeaderSize();
for ( i = 0 ; i < hs ; i++){
fputc(padByte, outFile);
}
i = 0;
hs = (images * 32) + 13;
while(fgets(line, sizeof line , stdin) != NULL){
tok = strtok(line, s);
sprintf(Item[i].name, "%s",tok);
tok = strtok(NULL, s);
for ( l = 24 ; l - strlen(Item[i].name) > 0 ; l-- ){
Item[i].name[l] = '\0';
}
for (k = 0; k < strlen(tok); k++){
if (( tok[k] == '\n') || (tok[k] == '\r' )){
tok[k] = '\0';
}
}
if ((inFile = fopen( tok , "rb")) == NULL){
perror("\nError opening mr file:");
fclose(inFile);
return 0;
}
while( ( readByte = fgetc(inFile) ) != EOF ){
fputc(readByte, outFile);
}
Item[i].size = ftell(inFile);
fprintf(stdout, "\n%d" , Item[i].size);
if ((Item[i].size % 512) != 0){
for ( k = 0 ; k < (blockSize - (Item[i].size % blockSize)) ; k++){
fputc(padByte, outFile);
}
}
Item[i].sizeWithPadding = BlockIt(Item[i].size);
totalDataSize += Item[i].sizeWithPadding;
if (i == 0){
Item[i].offset = BlockIt(hs);
} else {
Item[i].offset = ((Item[ i - 1 ].sizeWithPadding) + (Item[ i - 1 ].offset));
}
fprintf(stdout, "\n%ld", Item[i].offset);
i++;
fclose(inFile);
}
fseek(outFile, 0 , SEEK_SET);
fwrite(&header, sizeof header, 1 , outFile);
fwrite(&hs, 4, 1 ,outFile);
fprintf(stdout, "\n Size of Header is %d.", hs);
for (i = 0 ; i < images ; i++ ){
fwrite(&Item[i].name, 1 , 24 , outFile);
fwrite(&Item[i].offset, 4, 1 , outFile);
fwrite(&Item[i].size, 4, 1, outFile);
}
fclose(outFile);
fclose(inFile);
return totalDataSize;
}
unsigned int GetHeaderSize(void){
unsigned int ret = BlockIt(13 + ( 32 * images));
return ret;
}
unsigned long int BlockIt(unsigned long int isize){
if ((isize % blockSize) == 0){
return isize;
}else{
return isize + (blockSize - (isize %blockSize));
}
}
int main(int argc, char **argv){
int c;
while ((c = getopt (argc, argv, "o:n:")) != -1){
switch(c)
{
case 'o':
outputFileName = optarg;
break;
case 'n':
images = atoi(optarg);
break;
}
}
ReadList();
return;
}
nice it's very important
Does this really work for Moto G 2015? i dont wanna break my phone
how does the bootlogo look
and can you post a pic
@makers_mark Would it be possible to get this as a bash script to run on Ubuntu?
Excellent, works beautifully.
dustin_b said:
@makers_mark Would it be possible to get this as a bash script to run on Ubuntu?
Click to expand...
Click to collapse
Yeah, it's possible, but what I think you're asking is if I can do it, and I'm not proficient enough to write a bash script to do everything my batch script does. You're probably better off running a Windows vm, or if you know what you want to replace with what, send me the images and I'll do it for you.
makers_mark said:
Yeah, it's possible, but what I think you're asking is if I can do it, and I'm not proficient enough to write a batch script to do everything my that batch script does. You're probably better off running a Windows vm, or if you know what you want to replace with what, send me the images and I'll do it for you.
Click to expand...
Click to collapse
Yeah, that's what I was getting at. I know nothing about it or I would do it so I just thought I would ask. I have a Windows laptop( a cheap one though that is slow), and I'm able to use your script on it. It works great by the way! But I prefer my Ubuntu laptop and try not to use the other if possible. I will just use it on Windows or check out the VM like you suggested. Thanks for replying though and for the script!
Sent from my XT1575 using Tapatalk
edit moto x pure .bin
I cannot get v1.1 to validate my logo.bin file and open it to edit. Im pretty sure it is valid because I flashed it and am currently using it. phone is a moto x pure. any tips?
etmidust said:
I cannot get v1.1 to validate my logo.bin file and open it to edit. Im pretty sure it is valid because I flashed it and am currently using it. phone is a moto x pure. any tips?
Click to expand...
Click to collapse
You probably downloaded a logo.bin that was altered. The popular thing to do is simply use a hex editor and edit the offset of the logo unlocked image so that it points to the logo boot image. These will fall validation with my program because I check that the offset of an image meets exactly at the tail end of the previous image. It may work on your phone, but it's a safety I put there to check mainly the modified logo that is produced. I may change that though for the initial validation.
makers_mark said:
You probably downloaded a logo.bin that was altered. The popular thing to do is simply use a hex editor and edit the offset of the logo unlocked image so that it points to the logo boot image. These will fall validation with my program because I check that the offset of an image meets exactly at the tail end of the previous image. It may work on your phone, but it's a safety I put there to check mainly the modified logo that is produced. I may change that though for the initial validation.
Click to expand...
Click to collapse
Thanks, ill keep looking for one I can actually edit then.
etmidust said:
Thanks, ill keep looking for one I can actually edit then.
Click to expand...
Click to collapse
You have one on your phone ☺ I don't have a device, so I don't know the exact location of your logo partition. But follow this guide and you can grab yours off of your phone.
EDIT :
Unless the one there is the already modified one. In that case, try dragging your whole downloaded system image (from Motorola) onto the program. If it is unzipped, the program will find it and cut it out.
etmidust said:
Thanks, ill keep looking for one I can actually .edit then.
Click to expand...
Click to collapse
in the Moto X pure forums, development thread there is a return to stock tool that contains an unmodified boot logo.
NEVERMIND I'm stupid, it's in the development section for the Moto X threads.
Could anybody upload the stock logo.bin? I already have an altered one so I can't rip mine from my phone and my internet (yes, at home) has a data cap so I can't really download the stock image and extract the logo.bin from there. Thanks.
bigfunkychiken said:
NEVERMIND I'm stupid, it's in the development section for the Moto X threads.
Could anybody upload the stock logo.bin? I already have an altered one so I can't rip mine from my phone and my internet (yes, at home) has a data cap so I can't really download the stock image and extract the logo.bin from there. Thanks.
Click to expand...
Click to collapse
Sure, but what is your device model? XT1540?
Thank you for this. It works perfect for my Droid Turbo and is VERY user friendly!
very good. It was very useful.
Can you also add a stock boot image that we can use as a template? All others are from the same modified source that fail validation.

Categories

Resources