Wink Saville’s Blog

December 10, 2007

Git submodule and “how-to combine muliple git-repos”

Filed under: programming, scm — wink @ 2:47 am

Ok, I leaned what git submodule is for, well at least I think so. Apparently its primary use to as a mechanism for tagging a set of repositories, see my post here, which starts here. What help the most was looking at the tutorial here.

The as it indicates in the Title my original goal was to have some way of combining multiple git-repos. git-submodule doesn’t really do that and there doesn’t seem any easy way to do it. But Daniel Barkalow provided me with the instructions below which did combine them with linear history which is just fine. I do not understand why it works and I also wonder how the instructions might be changed if there were multiple branches in one of the repository and I had wanted to get that history also? Anyway, questions for the future.

Ah, okay. I was assuming that you wanted them to maintain their original identities (so you'd send stuff off for each of them separately, for example). I think you can do what you want by doing: # Set up the new line: $ mkdir x; cd x $ git init $ touch README $ git add README $ git commit # Add a project "foo" $ git fetch ../foo refs/heads/master:refs/heads/foo $ git merge --no-commit foo $ git read-tree --reset -u HEAD $ git read-tree -u --prefix=foo/ foo $ git commit And repeat for all of the other projects. What's going on here is that you're merging in each project, except that you're moving all of the files from that project into a subdirectory as you pull in the content. The resulting repository has one recent dull initial commit, and then merges in each of the other projects with their history, with only the slight oddity that they don't go back to the same initial commit, and the merge renames all of the project's files. I think there may be a more obvious way of doing this (it's essentially how gitweb and git-gui got into the git history), but I'm not sure what it is, if there is one. -Daniel

After this post, Daniel came back with a nice explanation for what each line did, you can see the post here.

December 9, 2007

How-to move a Eclipse project?

Filed under: Android, programming — wink @ 8:28 pm

Here was the link which helped me move an Eclipse project to a different directory. I had had the android projects in ~/prgs/android and wanted to move them to ~/workspace/android.  Turns out you use Eclipse menu “File/import/Existing Projects into Workspace” to do that.

December 8, 2007

Android Debugging – getting more info

Filed under: Android, programming — wink @ 12:58 am

In trying to diagnose where my Annotation problem was I wasn’t getting the full stack trace and hence didn’t know exactly where the problem was. After stumbling around one why I found a way to get the full stack trace; run the application from Eclipse in Run mode rather than Debug Mode:

% emulator &
% adb logcat

Then in Eclipse ran the application the application using Run. A message on the emulator UI says; “An error has occurred in process com.saville.tests … <Force Quit>”. And then in the logcat trace we see the full backtrace.

I/ActivityThread(  537): Loading code package com.saville.tests (in com.saville.tests)
D/ActivityThread(  537): Performing launch of ActivityRecord{4001cda0 {com.saville.tests/com.saville.tests.testAnnotation}}
V/testAnnotation(  537): onCreate: E
V/testAnnotation(  537): testAnno: E
V/testAnnotation(  537): Declared names: onCreate
V/testAnnotation(  537): Declared names: testAnno
V/testAnnotation(  537): cl.getAnnotation dies with 'native method not implemented'
D/dalvikvm(  537): Exception java/lang/RuntimeException from Looper.java:76 not caught locally
D/dalvikvm(  537): Exception java/lang/RuntimeException from ZygoteInit.java:1176 not caught locally
D/AndroidRuntime(  537): Shutting down VM
W/dalvikvm(  537): threadid=3: thread exiting with uncaught exception (group=0x4000e648)
E/AndroidRuntime(  537): Uncaught handler: thread Main exiting due to uncaught exception
E/AndroidRuntime(  537): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.saville.tests/com.saville.tests.testAnnotation}: java.lang.UnsupportedOperationException: native method not implemented
E/AndroidRuntime(  537):        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1397)
E/AndroidRuntime(  537):        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1410)
E/AndroidRuntime(  537):        at android.app.ActivityThread.access$1200(ActivityThread.java:76)
E/AndroidRuntime(  537):        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:980)
E/AndroidRuntime(  537):        at android.os.Handler.dispatchMessage(Handler.java:80)
E/AndroidRuntime(  537):        at android.os.Looper.loop(Looper.java:71)
E/AndroidRuntime(  537):        at android.app.ActivityThread.main(ActivityThread.java:2506)
E/AndroidRuntime(  537):        at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(  537):        at java.lang.reflect.Method.invoke(Method.java:380)
E/AndroidRuntime(  537):        at android.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1170)
E/AndroidRuntime(  537):        at android.os.ZygoteInit.main(ZygoteInit.java:1121)
E/AndroidRuntime(  537):        at android.dalvik.NativeStart.main(Native Method)
E/AndroidRuntime(  537): Caused by: java.lang.UnsupportedOperationException: native method not implemented
E/AndroidRuntime(  537):        at java.lang.Class.getDeclaredAnnotations(Native Method)
E/AndroidRuntime(  537):        at java.lang.Class.getAnnotations(Class.java:202)
E/AndroidRuntime(  537):        at java.lang.Class.getAnnotation(Class.java:185)
E/AndroidRuntime(  537):        at com.saville.tests.testAnnotation.testAnno(testAnnotation.java:33)
E/AndroidRuntime(  537):        at com.saville.tests.testAnnotation.onCreate(testAnnotation.java:19)
E/AndroidRuntime(  537):        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:786)
E/AndroidRuntime(  537):        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1367)
E/AndroidRuntime(  537):        ... 11 more
I/Process (  461): Sending signal. PID: 537 SIG: 3
I/dalvikvm(  537): threadid=7: reacting to signal 3
I/dalvikvm(  537): DALVIK THREADS:
I/dalvikvm(  537): "Main" prio=5 tid=3 NATIVE
I/dalvikvm(  537):   | group="main" sCount=1 dsCount=0 s=0 obj=0x4000eca0
I/dalvikvm(  537):   | sysTid=450 nice=0 sched=0/0 handle=-1090962004
I/dalvikvm(  537):   at android/os/BinderProxy.transact(Native Method)
I/dalvikvm(  537):   at android/app/ActivityManagerProxy.handleApplicationError(ActivityManagerNative.java:1205)
I/dalvikvm(  537):   at android/os/RuntimeInit.crash(RuntimeInit.java:234)
I/dalvikvm(  537):   at android/os/RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:53)
I/dalvikvm(  537):   at java/lang/ThreadGroup.uncaughtException(ThreadGroup.java:853)
I/dalvikvm(  537):   at java/lang/ThreadGroup.uncaughtException(ThreadGroup.java:850)
I/dalvikvm(  537):   (break frame)
I/dalvikvm(  537):   at android/dalvik/NativeStart.main(Native Method)
I/dalvikvm(  537):   (break frame)

Android does not implement runtime Annotations

Filed under: Android, programming — wink @ 12:47 am

I posted a message here lamenting that runtime Annotations aren’t supported and that I couldn’t find a place to submit bug reports/feature requests. In any case I was hoping to use runtime Annotations for my StateMachine class but I guess I’ll try source only.

December 7, 2007

Android – application debug logging

Filed under: Android, programming — wink @ 10:04 pm

Here and Here are a couple of places that got me started. First the standard java logging mechanism doesn’t work. In addition System.out.print doesn’t work. You need to use the android.util.log.

package com.saville.tests;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;

@StateMachine
public class test extends Activity
{

    /** Called with the activity is first created. */
    @Override
    public void onCreate(Bundle icicle)
    {
        super.onCreate(icicle);

        Log.v(TAG, "onCreate: E");
        setContentView(R.layout.main);
        Log.v(TAG, "onCreate: X");
    }

    private static final String TAG = "test";
}

The Log class supports various levels (VERBOSE, DEBUG, INFO, WARN, ERROR, ASSERT) the low-level routine is Log.println(int priority, String tag, String msg). But typically the v, d, i, w, e and a convince routines would be used. So that’s half the game, the other half is to be able to see the output. For that you use “logcat”. In Eclipse if you goto menu “Window/Show View/other/Android/logcat” or if your in the Debug perspective it will be in “Window/Show View/logcat”. Apparently, its not very reliable in Eclipse and executing:

adb logcat

Allows you to see it from a command line, but in Eclipse the log also includes a Date stamp which makes it nice. I was able to get the Eclipse/logcat going by closing than reopening. Of course you mileage may very:) If you look at the links above it appears you can use ddms, but I haven’t used that yet.

December 6, 2007

Android – adding busybox

Filed under: Android, programming — wink @ 10:59 pm

Here is a link to Beno’s blog on how to install BusyBox. He’s also got lots of good stuff on Android on his blog.

Not using eclipse and removing an Android app

Filed under: Android, programming — wink @ 10:10 pm

As a test I followed the instructions here, to test how easy it was to not use eclipse. It wasn’t hard at all except for figuring out how to remove an app. First I put the <andriod_sdk>/tools directory on my path so the tools were easily accessible (<android_sdk> respresents the full path to where I install the sdk). Since I had already installed one app, when using eclipse, and the second app I installed had the same name I didn’t know which app was running. I snooped around the debugger, adb, and saw that there was a shell command:

adb shell

I then used the ls command and found data/com.saville.tests and deleted it but the app was still there. While playing with the emulator I also found the the right most icon (yellow folder icon) on the home page (press the house button on the emulator), was the “Applications” folder where applications can be run.

Another important location was the “Dev Tools” icon, which is the silver folder icon with the gear on the right. Here I found by navigating to “Dev Tools/Package Browser/com.saville.tests” I saw that the “Source” of my app was in /data/app/test1.apk. I deleted that and bye-bye test1 from the “Applications” folder.

Further more if I deleted the /data/data/com.saville.tests the information in “Dev Tools/Package Browser” disappeared.

How to create a New Android Project

Filed under: Android, programming — wink @ 5:52 pm

I installed Android and then tried to follow the instructions on how to develop a new application here. I tried Create new project in workspace and added the ‘test1′ to “Project name:”, then tabbed to “Package name:”. At the top of the dialog the help line said; “Package name must be specified”. I typed a character, the help line said; “Package name must have at least tw o identifiers.”. If I then type two identifiers “a b” it says; “‘a b’ is not a valid java identifier”.

I wasn’t making much progress, I then googled around and found this, so the Package name must be a reverse DNS type name of two identifiers. So I used ‘com.saville’. The the help line changed to, “Activity name must be specified.”, I added “test1″ to Activity name: and pressed Finnish.

This created the project file in /home/wink/workspace/test1 with assets/ bin/ res/ and src/ and AndroidManifest.xml plus a bunch of other files in the subdirectories. In particular the source is in test1/src/com/saville/test1.java along with R.java.

After that far, I asked my self; how do I print out “hello, world”? The HelloActivity in the samples seem to be missing the R.java file. Anyway I googled for <android hello world> and found this.

November 15, 2007

Making a mips cross compiler

Filed under: programming — wink @ 9:05 pm

Followed instructions for ‘Roll your own’ cross compiler at http://www.linux-mips.org/wiki/Toolchains. The minor difference was in the exports:

export WDIR=~/foss/mips/wdir
export TARGET=mipsel-unknown-linux-gnu
export PREFIX=/opt/mips

It then only took less than 5 minutes to build the binutils and gcc.

It looks like I then need to compile the kernel so that glibc has the appropriate headers. So I grabbed the nxp-2.6.19.1 git-repo and ran into some problems because I don’t have the full environment. So using menuconfig on the current nxp config file I disabled:

/Device Drivers/NXP Drivers
/Device Drivers/pnx-sata driver
**/Device Drivers/Graphics support/Support for Video Denc devices
/Device Drivers/Multimedia devices/Digital Video Broadcasting Devices/DVB For Linux

After 30 minutes I gave up on getting the nxp version working. Instead I started with linux-2.6.19.1.tar.bz2. I menuconfig using:

make ARCH=mips CROSS_COMPILE=mipsel-unknown-linux-gnu menuconfig

I selected:

/Machine selection/Qemu
/Endianess selection/Little endian

and then deselected everything else except

/Exectuable file formats/Kernel support for ELF binaries

To then built using:

make ARCH=mips CROSS_COMPILE=mipsel-unknown-linux-gnu

Using time on the above and the kernel took 42.771 seconds to build on ic2d1 and vmlinux is 995,404 bytes long and arch/mips/boot/mvlinux.bin is 843,909 bytes long.

The above was all good but only built a minimal compiler and the binutils but no runtime library. The toolchain I decided on consisted of; gcc-3.4.4, binutils-2.16.1, glibc-2.3.5 plust glibc-linuxthreads.2.3.5. I chose this set because it looks to be a recommended set from http://linux-mips.org. I also decided on using crosstool as the basis for building a complete tool chain, Dan Kegel and group seem to be relatively active and helpful. Initially I’m only going to use crosstool.sh as I wanted to concentrate on the building phase, but that means a bunch of environment variables need to be setup. So I created a Makefile and a shell script as time went on some patches needed to be applied which is done in the shell script. Anyway, on with the story.

Initially I needed to modify build-glibc/csu/version-info.h by joining lines 2 & 3 and added ‘\n’. But the problem turned out to be my bin/sh was dash not bash. Searching the net for <version-info.h missing terminating> I found that Dan Kagel and helped someone else with this exact problem.

Next was a problem with glibc-2.3.5/Makeconfig; the make file is created had references to gcc_eh which from a search on the net appears not to be needed, I patched it as follows:

— glibc-2.3.5/Makeconfig 2005-02-16 02:50:19.000000000 -0800
+++ Makeconfig 2007-11-15 23:35:51.000000000 -0800
@@ -503,12 +503,12 @@ else
libunwind = -lunwind
endif
ifneq ($(have-as-needed),yes)
- libgcc_eh := -lgcc_eh $(libunwind)
+ libgcc_eh := $(libunwind)
else
libgcc_eh := -Wl,–as-needed -lgcc_s$(libgcc_s_suffix) $(libunwind) -Wl,–no-as-needed
endif
gnulib := -lgcc $(libgcc_eh)
-static-gnulib := -lgcc -lgcc_eh $(libunwind)
+static-gnulib := -lgcc $(libunwind)
libc.so-gnulib := -lgcc
endif
ifeq ($(elf),yes)

Next problem was a use of the attribute always_inline in the file wordexp.c that apparently isn’t supported in gcc 3.4.4 .

+++ glibc-2.3.5/sysdeps/generic/wordexp.c 2005-02-16 02:56:31.000000000 -0800
— ../mips-1/glibc-2.3.5/sysdeps/generic/wordexp.c 2007-11-15 16:47:28.000000000 -0800
@@ -810,7 +810,7 @@ parse_arith (char **word, size_t *word_l

/* Function called by child process in exec_comm() */
static void
-internal_function __attribute__ ((always_inline))
+//internal_function __attribute__ ((always_inline))
exec_comm_child (char *comm, int *fildes, int showerr, int noexec)
{
const char *args[4] = { _PATH_BSHELL, “-c”, comm, NULL };

After these changes I was able to build the compiler and created a hello world program. At that point I didn’t have the MIP machine so I couldn’t test it but hey, if it compiles it runs, actually the next day I did test it and it did run. But in the mean time I refined the Makefile/m.sh files and tried again. Hmm, failed:

# /usr/bin/install: cannot stat `/home/wink/foss/mips-cc/wdir/build-glibc-headers/gnu/lib-names.h’: No such file or directory
# make[2]: *** [/opt/mipsel/mipsel-unknown-linux-gnu/include/gnu/lib-names.h] Error 1
# make[2]: Leaving directory `/home/wink/foss/mips-cc/glibc-2.3.5′
# make[1]: *** [install-headers] Error 2

This error occurs when creating headers, line 448, before the “Build gcc-core” at line 474. At least that’s what I remember. Anyway apparently this sequence isn’t needed and just doing it again seems to work. So I added the notion of doing pass1 & pass2. After this the compiler, binutils and glibc get built and does run helloworld as well as test1 of tmSal.

But it couldn’t build the MIPS stb225 system, I had to apply a couple more patches which I found in the crosstool/patches directory. One was to generate a full syscall.h so the SYS_xxxxx defines were created:

patches/glibc-2.3.5/pr758.patch

The other was to make sure limits.h includes linux/limits.h PATH_MAX gets defined, as well as some other defines:

patches/gcc-3.4.4/fix-fixincl.patch

After figuring these things I successfully built the stb225 system, except for the dsp code which uses some precompiled libraries so and I hope for the moment things will work with those being built with the eldk-4.0 toolchain.

Download here.

« Newer Posts

Powered by WordPress