Posts tagged “GCC”

Change splash screen on HTC Magic

Some of these phones are branded and come with an ugly splash screen from the carrier, and you might want to change that into your own. The only things you need is a Engeneering SPL or a Hard SPL, which you should how to get from the previous blog posts I made, and either a Linux operating system with Imagemagick installed and this application for Windows or this application for Linux (has to be build from source) to create your own splash images.

First step is to convert an existing image with the dimensions 320×480 pixels. The image file has to be supported by imagemagick, so it has to be either gif, jpg, png, bmp or whatever is supported. This image file has to be converted into a 256 colour 8-bit raw image file:

convert -depth 8 splash.png rgb:splash.raw

Check that the splash.raw file is exactly 460800 bytes.
When you have the raw with the correct size, we need to compile the rgb2565 application it is done by running:

gcc -O2 -Wall -Wno-unused-parameter -o rgb2565 to565.c

When you have the application compiled the raw image has to be converted to a format the phone understands:

rgb2565 < splash.raw > splash.raw565

Check that this new file is 307200 bytes, otherwise do not flash it to the phone. We have now created the splash image for the phone. You can do the same in a Windows environment with the application mentioned in the start of this blog post. It should be obvious how to use it.

Second step is to flash the splash image to the phone. Start the phone in fastboot mode by holding back+end/power, also make sure you have the AndroidSDK on you computer installed and have the tools in your PATH.

Then make sure that the fastboot device shows up on you computer:

fastboot devices

cd to the folder where the splash.raw565 is and execute the following commands:

fastboot flash splash1 splash.raw565
fastboot reboot

If you want it to show up for longer (only for pre-cupcake):

fastboot flash splash1 splash.raw565
fastboot flash splash2 splash.raw565
fastboot reboot

The phone reboots and you should now see your splashscreen, enjoy :)

This is how my current splash looks like:

Splash image on my HTC Magic

Splash image on my HTC Magic

My own converted splash screens can be found here: http://ostebaronen.dk/android/splash/

Credit goes to: Android-dls.com Wiki

How to check what CFLAGS are suited for your system.

I recently discovered that the newer GCC versions now support using -march=native which is pretty cool, because GCC will then find the CFLAGS which suit your system. Here is how I found out which CFLAGS, GCC finds best for my system:


echo 'int main(){return 0;}' > test.c && gcc -v -Q -march=native -O2 test.c -o test && rm test.c test

This command should be executed from the terminal, and make sure you are using GCC >= 4.2.0:


echo 'int main(){return 0;}' > test.c && gcc -v -Q -march=native -O2 test.c -o test && rm test.c test
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-4.3.1/work/gcc-4.3.1/configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/4.3.1 --includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/4.3.1 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/4.3.1/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/4.3.1/info --with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/include/g++-v4 --host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --enable-secureplt --disable-multilib --enable-libmudflap --disable-libssp --enable-cld --disable-libgcj --with-arch=i686 --enable-languages=c,c++,treelang,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.3.1 p1.0'
Thread model: posix
gcc version 4.3.1 (Gentoo 4.3.1 p1.0)
COLLECT_GCC_OPTIONS='-v' '-Q' '-O2' '-o' 'test'
/usr/libexec/gcc/i686-pc-linux-gnu/4.3.1/cc1 -v test.c -march=prescott --param l1-cache-size=32 --param l1-cache-line-size=64 -mtune=generic -dumpbase test.c -auxbase test -O2 -version -o /tmp/cc8FolQd.s
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/include
/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/include-fixed
/usr/include
End of search list.
GNU C (Gentoo 4.3.1 p1.0) version 4.3.1 (i686-pc-linux-gnu)
compiled by GNU C version 4.3.1, GMP version 4.2.2, MPFR version 2.3.1.
GGC heuristics: --param ggc-min-expand=98 --param ggc-min-heapsize=127766
options passed: -v test.c -march=prescott --param l1-cache-size=32
--param l1-cache-line-size=64 -mtune=generic -O2
options enabled: -falign-labels -falign-loops -fargument-alias
-fauto-inc-dec -fbranch-count-reg -fcaller-saves -fcommon
-fcprop-registers -fcrossjumping -fcse-follow-jumps -fdefer-pop
-fdelete-null-pointer-checks -fearly-inlining
-feliminate-unused-debug-types -fexpensive-optimizations
-fforward-propagate -ffunction-cse -fgcse -fgcse-lm
-fguess-branch-probability -fident -fif-conversion -fif-conversion2
-finline-functions-called-once -finline-small-functions -fipa-pure-const
-fipa-reference -fivopts -fkeep-static-consts -fleading-underscore
-fmath-errno -fmerge-constants -fmerge-debug-strings
-fmove-loop-invariants -foptimize-register-move -foptimize-sibling-calls
-fpcc-struct-return -fpeephole -fpeephole2 -fregmove -freorder-blocks
-freorder-functions -frerun-cse-after-loop -fsched-interblock -fsched-spec
-fsched-stalled-insns-dep -fschedule-insns2 -fsigned-zeros
-fsplit-ivs-in-unroller -fsplit-wide-types -fstrict-aliasing
-fstrict-overflow -fthread-jumps -ftoplevel-reorder -ftrapping-math
-ftree-ccp -ftree-ch -ftree-copy-prop -ftree-copyrename -ftree-cselim
-ftree-dce -ftree-dominator-opts -ftree-dse -ftree-fre -ftree-loop-im
-ftree-loop-ivcanon -ftree-loop-optimize -ftree-parallelize-loops=
-ftree-pre -ftree-reassoc -ftree-salias -ftree-scev-cprop -ftree-sink
-ftree-sra -ftree-store-ccp -ftree-ter -ftree-vect-loop-version -ftree-vrp
-funit-at-a-time -fvar-tracking -fvect-cost-model
-fzero-initialized-in-bss -m32 -m80387 -m96bit-long-double
-maccumulate-outgoing-args -malign-stringops -mcld -mfancy-math-387
-mfp-ret-in-387 -mfused-madd -mglibc -mieee-fp -mmmx -mno-red-zone
-mno-sse4 -mpush-args -msahf -msse -msse2 -msse3 -mtls-direct-seg-refs
Compiler executable checksum: 11cc1d92ac4cc0eab595215165f2ebd2
main
Analyzing compilation unit
Performing interprocedural optimizations
Assembling functions:
main
Execution times (seconds)
expand : 0.01 (100%) usr 0.00 ( 0%) sys 0.01 ( 1%) wall 3 kB ( 1%) ggc
scheduling 2 : 0.00 ( 0%) usr 0.00 ( 0%) sys 0.74 (87%) wall 0 kB ( 0%) ggc
TOTAL : 0.01 0.00 0.85 584 kB
Internal checks disabled; compiler is not suited for release.
Configure with --enable-checking=release to enable checks.
COLLECT_GCC_OPTIONS='-v' '-Q' '-O2' '-o' 'test'
/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/../../../../i686-pc-linux-gnu/bin/as -V -Qy -o /tmp/cc4KdoRg.o /tmp/cc8FolQd.s
GNU assembler version 2.18 (i686-pc-linux-gnu) using BFD version (GNU Binutils) 2.18
COMPILER_PATH=/usr/libexec/gcc/i686-pc-linux-gnu/4.3.1/:/usr/libexec/gcc/i686-pc-linux-gnu/4.3.1/:/usr/libexec/gcc/i686-pc-linux-gnu/:/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/:/usr/lib/gcc/i686-pc-linux-gnu/:/usr/libexec/gcc/i686-pc-linux-gnu/4.3.1/:/usr/libexec/gcc/i686-pc-linux-gnu/:/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/:/usr/lib/gcc/i686-pc-linux-gnu/:/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/../../../../i686-pc-linux-gnu/bin/
LIBRARY_PATH=/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/:/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/:/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/../../../../i686-pc-linux-gnu/lib/:/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-Q' '-O2' '-o' 'test'
/usr/libexec/gcc/i686-pc-linux-gnu/4.3.1/collect2 --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o test /usr/lib/gcc/i686-pc-linux-gnu/4.3.1/../../../crt1.o /usr/lib/gcc/i686-pc-linux-gnu/4.3.1/../../../crti.o /usr/lib/gcc/i686-pc-linux-gnu/4.3.1/crtbegin.o -L/usr/lib/gcc/i686-pc-linux-gnu/4.3.1 -L/usr/lib/gcc/i686-pc-linux-gnu/4.3.1 -L/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/../../../../i686-pc-linux-gnu/lib -L/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/../../.. /tmp/cc4KdoRg.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/i686-pc-linux-gnu/4.3.1/crtend.o /usr/lib/gcc/i686-pc-linux-gnu/4.3.1/../../../crtn.o

The options that passed for my system are:


options passed: -v test.c -march=prescott --param l1-cache-size=32 --param l1-cache-line-size=64 -mtune=generic -O2

Crickey!