yashsingh1/xdaforums huggingface dataset:
[Desire Android Development] theGanymedes:
exec at init.rc? Are you kidding me? Exec swaps all the application data with the loaded one, this is very dangerous. Instead, run using bash and "&" (background).

I don't need it now, anyway..

Busybox can be integrated to RAMDISK, not kernel, but why you want to do that? I can integrate ANYTHING there, but this is unnecessary, because this is why we have root filesystem :D

I've installed Debian btw. Phone features doesn't work and there is so much to do there, so I don't really think native Debian is necessary (it's very cool tho :) - screenshot in a minute)
[Desire Android Development] Droidzone:
To take advantage of the full options available for mounting FS. And also beacause I'd like to swap /system to a dir on the sdcard.. Then swap DK to NAND, and finally use another part of ext for /data. So I'd need to mount with all ext4 options before the /system is mounted (because it is /system that I want to mount with busybox).. Ideas for Data2SD 2.0.. ;)

Ramdisk is fine. I want to invoke from init.rc anyway
[Desire Android Development] theGanymedes:
Then what you should is clear:

Prepare a script or a C/C++ application that can make this stuff you want. Init process is actually kinda similar to bash itself, it can run your scripts (with /system/bin/sh <scriptname>", executables and such...

If you want to modify system itself: either build a "static" (with --static directive of GCC) busybox, or shell; put it into ramdisk's some folder (bin, let's say), and then call your script from there...

Even though I'm not sure, I'd say test with init first. It does support some directives like "ln" "mkdir" "mount" etc, maybe it supports scripting (basic if's and such) as well?

BTW: The DebianDesire : ;)
[Desire Android Development] Csharpe:
Would be really cool if you made a guide for that :) or at least some steps in order to get it booted.

Great job
[Desire Android Development] Droidzone:
You know people would be jumping fences and madly rushing to flash it if you opened a thread for that:

[ROM] Debian on Desire [WIP]

;)
[Desire Android Development] Droidzone:
Btw...wish you'd have another guide for setting up a toolchain for the host pc (to make stuff for use on linux)

I'm still having issues at the "Installing C headers" step
[Desire Android Development] Droidzone:
Could you give some steps with command examples please? Couldnt it be done with ct-ng itself?

I tried installing Glibc like this:

Extracted the tar to a folder glibc

From another folder,

glibc/configure

make

droidzone@supernova:~/compile/glibc$ ./glibc-2.14/configure -prefix=/home/droidzone/compile/glibc/headers

make

make fails always at this point. I tried different versions of glibc. If I understand it right, the header install should be done after one successful initial make.

6 -I../nptl/sysdeps/i386/i486 -I../sysdeps/i386/fpu -I../nptl/sysdeps/i386 -I../sysdeps/i386 -I../sysdeps/wordsize-32 -I../sysdeps/ieee754/ldbl-96 -I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754/flt-32 -I../sysdeps/ieee754 -I../sysdeps/generic/elf -I../sysdeps/generic -I../nptl -I.. -I../libio -I. -D_LIBC_REENTRANT -include ../include/libc-symbols.h -DPIC -DSHARED -DASSEMBLER -DGAS_SYNTAX -g -Wa,--noexecstack -Wa,-mtune=i686 -o /home/droidzone/compile/glibc/math/s_frexp.os -MD -MP -MF /home/droidzone/compile/glibc/math/s_frexp.os.dt -MT /home/droidzone/compile/glibc/math/s_frexp.os
../sysdeps/i386/fpu/s_frexp.S: Assembler messages:
../sysdeps/i386/fpu/s_frexp.S:66: Error: invalid identifier for ".ifdef"
../sysdeps/i386/fpu/s_frexp.S:66: Error: junk at end of line, first unrecognized character is `1'
../sysdeps/i386/fpu/s_frexp.S:66: Error: junk at end of line, first unrecognized character is `1'
../sysdeps/i386/fpu/s_frexp.S:66: Error: Missing symbol name in directive
../sysdeps/i386/fpu/s_frexp.S:66: Error: junk at end of line, first unrecognized character is `1'
../sysdeps/i386/fpu/s_frexp.S:66: Error: Missing symbol name in directive
../sysdeps/i386/fpu/s_frexp.S:66: Error: junk at end of line, first unrecognized character is `.'
../sysdeps/i386/fpu/s_frexp.S:66: Error: junk at end of line, first unrecognized character is `1'
../sysdeps/i386/fpu/s_frexp.S:66: Error: expected comma after name `' in .size directive
../sysdeps/i386/fpu/s_frexp.S:66: Error: ".endif" without ".if"
../sysdeps/i386/fpu/s_frexp.S:66: Error: junk `.get_pc_thunk.dx' after expression
make[2]: *** [/home/droidzone/compile/glibc/math/s_frexp.os] Error 1
make[2]: Leaving directory `/home/droidzone/compile/glibc/glibc-2.14/math'
make[1]: *** [math/subdir_lib] Error 2
make[1]: Leaving directory `/home/droidzone/compile/glibc/glibc-2.14'
make: *** [all] Error 2
droidzone@supernova:~/compile/glibc$ ./glibc-2.14/configure -prefix=/home/droidzone/compile/glibc/headers
[Desire Android Development] theGanymedes:
Well, actually, CT-NG already did that. The headers are at /home/<username>/x-tools/arm-<whatever>-linux-gnueabi/arm-<whatever>-linux-gnueabi/sysroot/usr/include folder, along with your necessary kernel headers (like unistd.h).

I said bloat, because these are not just C/LibC headers, also some GCC headers. If you're to use them for inclusion, that's better; but if you're to use them at Desire itself, there are so many headers you're not gonna need there ..

I can make both of your requests, but I have Operating Systems Design exam tomorrow; so, later..

I think I'm not going to upload Debian till it's actually usable. No phone features, no button keys (screensaver was nice though :P ).. And since I don't have time to implement-port-copy those, it had to wait.

I'm going to make a test today for co-existence of Xorg with LibStageFright (android gui) - gonna see if it'll clash or work well..
[Desire Android Development] theGanymedes:
Well, we're back online :)

@Droidzone and @Csharpe, may you please send me a PM about what you want me to do? It becomes easier for me to know my next step that way - sometimes I cannot read all posts carefully..

About Android and Xorg: there have been a funny stuff there. For since Android and Xorg both trying to handle inputs and screen, the screen becomes weird merge of the outputs ( :) ), the same is valid for the inputs (like touching the screen) as well.

As a workaround, I thought , we can make a dummy window which will cover the whole screen, and then direct the inputs and the outputs from this dummy window to Xorg.

Another thing to ask: do you thing we need a window manager? They are really huge and I really doubt if we need any - nearly every application has File->Quit option anyway..

NOTE: Unlike some linux ports found everywhere, I could manage to make Touchscreen work as Touchscreen (not as Touchpad). Do you think it's a big deal? Should I post it there? It wasn't that "hard-to-see" but..
[Desire Android Development] theGanymedes:
The reason for this is, it requires some GCC/GLIBC functionality to install GlibC itself, which is missing or for ARM platform in your system. Try giving host=arm-<vendor>-linux-gnueabi to configure parameter.

Note that, even with that, it's going to fail because you're trying to compile whole GlibC now - which requires some other parameters to be sent to be compiled successfully. If you just need headers, use the following directives:

BTW: Header installation should be done prior to actual GlibC installation. This is precisely where GlibC installation becames Chicken-Egg problem, actually... Follow the steps only if you do have a working toolchain now.

1- Preparation

a) First, we have to download two tarbals: Glibc library, and GlibC Ports. (Can be found at Gnu FTP at "glibc" folder. Files are at this format for glibc: "glibc-<version>" and glibc-ports: "glibc-ports-<version>". Note that the

versions should match

.

b) Extract GlibC first. it's going to make a folder named "glibc-<version>" at the extraction destination.

c) Extract Glibc Ports now. It's going to make a folder named "glibc-ports-<version>" at the extraction destination.

d) Rename glibc-ports-<version> to "ports" (just "ports", yes). And move it to glibc-<version> folder. Now we made ports just a folder inside the GlibC folder.

e) Make another folder for building - say "buildglibc" . GlibC and GCC requires to be configured/built outside source tree to keep sources untouched for building again. Keep this directory in mind, we shall use it again. (Will be referred as <builddir> in the future).

f) Hope you didn't erase the kernel sources we modified before for toolchain. If you did, go to Post #5 and do the steps there (just kernel modification steps, not everything :) ). I'm going to refer this folder as <kernel dir> in the future.

2- Configuration

a) Change into <builddir>, and run the following configure line:

../<glibc directory>/configure --host=arm-<whatever>-linux-gnueabi --prefix= --enable-addons="nptl,ports" --with-arch="armv7-a" --with-tls --with-headers=<kernel dir>/include

Note that the prefix is empty. This is done to make headers unaware of location (not sure if exactly necessary, but just to be safe ;) )

3 - Installing the headers

a) Make a directory to where you want headers installed. We're going to refer this directory as <target dir>.

b) Now, run this command:

make cross-compiling=yes install-headers install_root=<target dir>

Don't forget install_root line, otherwise it'll try to install to your host system which may be catastrophic if you're root (why are you root, anyway :) )

Now you have all the headers..
[Desire Android Development] Droidzone:
Hmm..I'll try that out..But I'm trying this for my PC, not the toolchain for the device
[Desire Android Development] cdesai:
I think you got me wrong, np thats

I meant something else, will explain properly when i have access to a comp

Nice work btw, and i m sure a Debian thread would generate great respone
[Desire Android Development] theGanymedes:
Look at the post #110 for directives for headers :http://xdaforums.com/showpost.php?p=19019096&postcount=110

PS: If you need for these headers for your pc to compile pc applications, just omit the "host" directive. If you need the headers for your pc to compile Desire applications, keep the host directive!.
[Desire Android Development] theGanymedes:
Yeah, I got it wrong. I thought you meant linux command "exec", not bash one :)

Note that, your solution won't work for Droidzone, because he wants stuff done before the mounting of system (he want to mount it elsewhere :) ) and normal Android Ramdisk doesn't have /sbin/sh there - you need to put a statically linked (the one at the /system needs bionic C library, and the one I provided needs GlibC, so you need to compile it yourself) bash (or busybox) there.
[Desire Android Development] theGanymedes:
Well, these are my findings:

a) To send "HOME" key event:

adb shell sendevent /dev/input/event5 1 102 1;
adb shell sendevent /dev/input/event5 1 102 0;

b) To send "POWER" key event:

adb shell sendevent /dev/input/event5 1 116 1;
adb shell sendevent /dev/input/event5 1 116 0;

c) To send "Trackball Click" key event:

adb shell sendevent /dev/input/event8 1 272 1;
adb shell sendevent /dev/input/event8 1 272 0;

d) To send "Trackball swipe down" event (do it in a bash script):

for((i=1; i<= 2; ++i));
do
adb shell sendevent /dev/input/event8 2 1 1
adb shell sendevent /dev/input/event8 0 0 0
done

e) To send "Trackball swipe up" event (do it in a bash script):

for((i=1; i<= 2; ++i));
do
adb shell sendevent /dev/input/event8 2 1 4294967295
adb shell sendevent /dev/input/event8 0 0 0
done

f) To send "Trackball swipe left" event (do it in a bash script):

for((i=1; i<= 2; ++i));
do
adb shell sendevent /dev/input/event8 2 0 4294967295
adb shell sendevent /dev/input/event8 0 0 0
done

g) To send "Trackball swipe right" event (do it in a bash script):

for((i=1; i<= 2; ++i));
do
adb shell sendevent /dev/input/event8 2 0 1
adb shell sendevent /dev/input/event8 0 0 0
done

There are other key codes and stuff too. You can debug them by examining output of

cat /proc/bus/input/devices

and with the help of "getevent" command
[Desire Android Development] Droidzone:
That's extremely :cool:

Thanks for sharing! Btw..Credits added on SuperNova thread for your help with the toolchain.. I've released my kernel compiled with the new toolchain :D
[Desire Android Development] theGanymedes:
No problem! I really am going to develop a remote-control software based on this, after my Xorg project. Most users did develop VNC-based ones which are quite slow on Android, whilst this is "the native" way :)

BTW; Maybe I should compile "apt" and then put all the stuff I compiled to some repository compatible with it - then the user wouldn't need recovery every time (if rooted, of course ;) ) and it would be so much easier to track dependencies ( actually, I love "autoclean" feature most :) )

Damn, I need to learn Java-Android programming to write nice GUI for that too.. Got a lot of to do, eh? :)

AND A HUGE THANKS FOR YOUR CREDITS, man, I really felt honored...
[Desire Android Development] Droidzone:
If I could donate, I'd do that gladly. Your work is awesome. Stupid Paypal has restrictions for Indian users. We can receive but not send! :)
[Desire Android Development] cdesai:
yea

what i meant:

take current ramdisk

rename init to something else( init_original - anything else )

make a file init.sh(contents below)

#!/sbin/busybox sh

/sbin/pre-init.sh > /res/pre-init.log 2>&1

Now make a link to this file, name it init

and make a file in sbin(pre-init.sh - use busybox sh) and then add ur stuff in it

and at the end of the pre-init.sh file

add this :

exec /init_original

this way you can do anything before init, also dual/multiboot or convert filesystems (anything!)

@Droidzone

bhai

any improvements in ur kernel when using your new toolchain

if so, i might also take the time to build one

sounds fun :D
[Desire Android Development] Droidzone:
Oh yes, no more reboots! :P

It's fun reading all the code that goes on behind the screen, and trying to modify them. An issue which I always had with other kernels was that the kernel would disable battery stats when the phone is rebooted while on extended battery (you have to shutdown first). My first obj is to fix that. :)
[Desire Android Development] theGanymedes:
Still wouldn't work though, there is no "/sbin/busybox" when machine first booted.. You have to compile it yourself and add to ramdisk. (I think it was around 2.8 MB when compiled statically, with all the tools, but I think if you trim most commands, it can be around 1 MB)

The important thing is, the ramdisk at the kernel + boot image shouldn't be larger than 3 MB, because this is the size of boot partition ;)
[Desire Android Development] Droidzone:
Damn..my statically linked bbox is 1.8MB and boot.img was 2.1 MB before adding it! Where (subfolder) in ramdisk do I put it ideally?
[Desire Android Development] Droidzone:
Ah..I got it.

Also compiled bbox at 630 KB. Should fit boot. It contains only mount and umount with support for only ext. :)

Old Boot - 1.9 MB

New-2.2 MB

:D
[Desire Android Development] cdesai:
An easier way to do so would be to grab the kernel sources and then rebuild, with lzma compression, giving more room for stuff

Also, you can get the latest busybox binary here :

http://busybox.net/downloads/binaries/latest/

its about 1mb, should fit in
[Desire Android Development] Droidzone:
That's easily possible. Already have sources. Hmm..lzma compression.. I built the latest busybox from sources.. Since I need only mount and umount, it's fine.

The vexing problem is how to add if/else blocks to init.rc. I do need to check whether /dev/block/mmcbkl0p2 exists. If it does, I have to mount ext4, else I have to mount MTD.
[Desire Android Development] cdesai:
Add a place holder in the init.rc

E.g.

Replace the mount path with something like this

mount_path

Then, use the pre-init way I described above and let that script do the if and then...

Easy ain't it? :P
[Desire Android Development] Droidzone:
Init.rc:

/sbin/busybox sh /sbin/initcheck.sh

Sounds like a great idea. Ought to work! :)

One query though. On /system/bin, sh ->bash. Is it the same in kernel init?
[Desire Android Development] theGanymedes:
@Droidzone; only a few programs and kernel compilation uses "ARCH" and "CROSS_COMPILE" variables - especially programs that are shipped without ./configure ...

Thus, if you can see "configure" file when you list the contents of a directory; always use configure! More info can be found at "AutoConf" manuals.
[Desire Android Development] theGanymedes:
Guys, you're really confusing me. Why are you making a big confusion about that, it's quite simple!

On boot, machine automatically runs init executable at ramdisk and after that, init runs every command in init.rc with it's tag associated with it (you see there are some lines line "on init" "on fs" "after fs" - these are commands to init to make them run whenever they should).

At the first line (on init: line) you see that init.rc calls "/sbin/ueventd" - which is actually a link to init itself (In Android kernels, ueventd binary is also embedded into init executable - I think it's a deamon for event handlers). If you add your command right after this line, it shall do work on a freshly booted machine! You can do anything here!

Even on this level, kernel attaches devices to /dev nodes. (like /dev/block/mmcblk0p2 is available there if there is a second partition there ;) ). You can simply check in a shell script and make mounting here.

-- NOTE that there is a section "on fs" at init.rc too. It's probably better for you to call your script there, instead of "on init" if you're interested in mountings. Otherwise your changes might be overwritten at "on fs" section.. Watch out! ;)

Now, the problem was "there is no bash" at ramdisk level! As far as I think, init executable do have some "bash" capabilities - like mounting file systems, making linkages and such. I'm not sure if it can run a shell script - this should be tested. Possible outcomes of this is as follows:

a)

Init can run shell scripts:

Nothing should be done then! just write your shell script and put it into the ramdisk, and then make init call it in an appropriate location with "/init myscript.sh"

b)

Init cannot run scripts:

Most likely scenario. Then, simply compile a busybox binary with bash (csh and ksh support is unnecessary), mount (and other stuff you plan to use) support and take everything else out.

--- NOTE: I noticed that saying "Make static busybox binary" menuconfig option doesn't always yields correct results (when you run "arm-linux-readelf -d <busybox> | grep NEEDED", you will see libm, libc and such there; which you shouldn't). In order to overcome this, when you're building busybox, build it with

make CC=arm-linux-gcc -static

and it should be done ;)

At this scenario, you can put busybox to (say) sbin folder at ramdisk and then call it at init.rc with "/sbin/busybox sh myscript.sh" and you're done.

EDIT: I attached the README file of init executable. It shows the capabilities of it. Check if there is something you can use ;)
[Desire Android Development] theGanymedes:
Wow.. Just had an amazing idea!

Currently, we cannot hibernate our devices with data2* system, right? Because hibernation un-mounts the data partition and when we wake up the system, instead or sd-data, mtd data becomes mounted and it becomes a problem for the system..

What if we were to write a very simple daemon process that shall mount sd-data instead of the MTD one and activate this daemon at init.rc? Since if we don't say "oneshot", it shall respawn when it's shutdown; we can always make sure that the correct data is mounted! We have to make this a small daemon tho, we don't want to make it bring a burden to the system, right?

I'm going to work on this, let Xorg wait a little bit.. I'll publish the results from here guys ! ;)

EDIT: Hmm, this might be unnecessary if we give the ability to run init scripts at ramdisk level. Because, I think, Vold daemon remounts everything based on "on fs" at init.rc - which will mount the correct partitions when we give it the ability to do correct mountings. Let me work on this thing as well.
[Desire Android Development] theGanymedes:
And here is my busybox with a very limited support - suitable for Ramdisk ;)

It's 750 KB Only (extracted .. only 300 when compressed :) ).. I also added ch_root functionality and stuff (in case you really want to meddle with your system :) )
[Desire Android Development] Droidzone:
Actually you can easily hibernate with Data2SD..No problems there :)
[Desire Android Development] theGanymedes:
How come? :S Init scripts don't work on wake from hibernation; how do you make sure it's mounted?

BTW: Bad news: at init.rc level, /dev/block/mmcblk0p2 seems like doesn't exist somehow :/
[Desire Android Development] Droidzone:
Error again

droidzone@supernova:~/Downloads/glibc-2.14/glibc$ /home/droidzone/Downloads/glibc-2.14/configure --host="$TARGET" --with-ports="nptl, ports" --with-tls --with-headers="$HEADERS" --prefix="/data/lib"
configure: WARNING: if you wanted to set the --build type, don't use --host.
If a cross compiler is detected then cross compile mode will be used
checking build system type... i686-pc-linux-gnu
checking host system type... arm-msm-linux-gnueabi
checking for arm-msm-linux-gnueabi-gcc... arm-msm-linux-gnueabi-gcc
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether arm-msm-linux-gnueabi-gcc accepts -g... yes
checking for arm-msm-linux-gnueabi-gcc option to accept ISO C89... none needed
checking for gcc... gcc
checking how to run the C preprocessor... arm-msm-linux-gnueabi-gcc -E
checking for arm-msm-linux-gnueabi-g++... arm-msm-linux-gnueabi-g++
checking whether we are using the GNU C++ compiler... yes
checking whether arm-msm-linux-gnueabi-g++ accepts -g... yes
configure: running configure fragment for add-on libidn
configure: running configure fragment for add-on nptl
checking for assembler gnu_indirect_function symbol type support... yes
checking whether .text pseudo-op must be used... yes
checking for assembler global-symbol directive... .globl
checking for assembler .type directive prefix... %
checking sysdep dirs... configure: [B][COLOR="Red"]error: The arm is not supported.[/COLOR][/B]
[Desire Android Development] theGanymedes:
You forgot to add (or rename) your glibc-ports.. Be careful ;)

Also, I think /data/lib is not a good prefix; just /data is better - because it's going to create "lib" "sbin" and "bin" folders itself ;) --this is just an opinion though, you do whatever you want :D
[Desire Android Development] theGanymedes:
Apparently Android init executable doesn't enumerate block devices (vold does); ergo you cannot mount your SD-Card partitions at init level with Android init..

The reason is not kernel though - I could mount Debian successfully with a command line parameter to kernel; so..
[Desire Android Development] Droidzone:
Your compiled bash of 3.8 MB is linked to your glibc right? How big does it get if you make it static?

This chicken-egg problem is getting to me.. ;P
[Desire Android Development] theGanymedes:
Definitely bigger :) Using busybox is much better for small purposes I think - there are so much stuff under bash executable which they didn't include in Busybox..

Still didn't compile? I could do one, while I was writing those instructions :S (Glibc upgraded to 0.5v - 2.14 thanks to that :) )