Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. On the host activate the development environment (refer to Installing and Activating Cross Development Environment ):

    Code Block
    $ . ./ACTIVATE.sh
  2. Create a simple fpu C application on the host:

    Code Block
    $ cd /tmp
    $ vi check_float.c
    #include <stdio.h>
    #include <stdlib.h>
    #include <sys/time.h>
    #include <err.h>
    
    int main(int argc, char **argv)
    {
            register int n;
            register int i;
            struct timeval start, end;
            float x = 0.3f, y = 2.0f, z = 0.0f;
    
            n = atoi(argv[1] ? argv[1] : "");
            if (n <= 0)
                    n = 50000000;
    
            if (gettimeofday(&start, NULL))
                    err(1, "gettimeofday");
    
            for (i = 0; i < n; i++) {
                    z += x * y;
                    x += 0.00001f;
                    y -= 0.00001f;
            }
    
            if (gettimeofday(&end, NULL))
                    err(1, "gettimeofday");
    
            long usecs = (end.tv_sec - start.tv_sec) * 1000000 + 
            end.tv_usec - start.tv_usec;
            printf("%i loops: x=%f, y=%f, z=%f time spent: %ld.%06ld\n",
                            n, x, y, z,
                            usecs / 1000000,
                            usecs % 1000000
                            );
            return 0;
    }
  3. Build the application for the target with the -mfloat-abi=soft GCC flag:

    Code Block
    $ ${CROSS_COMPILE_APPS}gcc -o check_float_soft check_float.c -Wall -mfloat-abi=soft -Os
  4. Build the application for the target with the -mfloat-abi=softfp GCC flag:

    Code Block
    $ ${CROSS_COMPILE_APPS}gcc -o check_float_softfp check_float.c -Wall -mfloat-abi=softfp -Os
  5. Copy the binaries to the directory exported via NFS:

    Code Block
    $ cp check_float_soft check_float_softfp /home/your/nfs/
  6. Run the application binaries on the target. One easy way to do that is to have an NFS share mounted on the target, which immediately provides access to the host development directory:

    Code Block
    / # mount -o nolock 192.168.1.41:/home/yur/nfs /mnt/nfs
    / # /mnt/nfs/check_float_soft
    50000000 loops: x=256.000000, y=-256.000000, z=-1099511627776.000000 
    time spent: 7.243095
    
    / # /mnt/nfs/check_float_softfp
    50000000 loops: x=256.000000, y=-256.000000, z=-1099511627776.000000 
    time spent: 0.402088
    / #
    

...