EihiS

January 8, 2015

raspberry pi kernel cross-compilation from a ubuntu’s X86-64 machine

Filed under: Raspberry 3.14 — admin @ 5:24 pm
(using gcc 4.8 for ARM)

setup GIT if needed :
apt-get install git-core

setup gcc 4.8 for arm (as for 7th january, 2015)
sudo apt-get install gcc-4.8-arm-linux-gnueabi

create symlink for this
sudo ln -s /usr/bin/arm-linux-gnueabihf-gcc-4.8 /usr/bin/arm-linux-gnueabihf-gcc

create a dir for our needs from the user's home dir:
mkdir raspberrypi_target

get into
cd raspberrypi_target

clone dirs using GIT clone command (go make a big coffee)
git clone https://github.com/raspberrypi/tools.git
git clone https://github.com/raspberrypi/linux.git
---------------- NOTA :
(when using a bad connection, try to get the linux clone using )
git clone --depth=1 https://github.com/raspberrypi/linux.git
then
cd linux
then:
for m in `seq 1 100`;do git fetch --depth=$m;done
----------------- end NOTA

now from linux directory(cd linux if not done)

make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- bcmrpi_cutdown_defconfig

Checking the current kernel configuration before build : (customization here)
make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- menuconfig

Run the compilation :
make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabihf- -k -j5

(successfull.. )
mkdir ../modules
make modules_install ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabihf- INSTALL_MOD_PATH=../modules/  

then using the python tool , for the RPI kernel image setup:
cd ../tools/mkimage/
and
./imagetool-uncompressed.py ../../linux/arch/arm/boot/Image

now, plug the target SD card into the computer, rename old kernel.img file for backup if desired,
and copy the new one onto the SD , on the BOOT part of the SD :
sudo mv kernel.img /media/<user>/<SD-boot-partition-uuid>/

now rename for backup the /lib/modules and /lib/firmware directories of the ROOT FS part of the SD
( for example : rename to /lib/modules_old and /lib/firmware_old )

back to modules directory for linux built:
cd ../../modules

then copy the new firmware + modules directories onto the SD
sudo cp -a lib/modules/ /media/<user>/<root filesystem partition uuid>/lib/
sudo cp -a lib/firmware/ /media/<user>/<root filesystem partition uuid>/lib/

then (flush writing on the SD)
sync

Additional notes :
Boot LOGO modification :
located into /linux/drivers/video/logo

using Gimp, logo export as <logoname>.ppm ,(raw) 

then using netpbm ( if not installed, sudo apt-get install netpbm ) :
reduce color count to 224 (mandatory) :
> ppmquant 224 <logoname>.ppm > <logoname>_224.ppm
some messages outputs :
ppmquant: making histogram...
ppmquant: 1866 colors found
ppmquant: choosing 224 colors...
ppmquant: mapping image to new colors...

Now convert it now to ascII format :
> pnmnoraw <logoname>224.ppm > <logoname>_ascii_224.ppm
now copy the the linux kernel build directory (using the one from this post) :
cp <logoname>_ascii_224.ppm /home/<username>/raspberrypi_target/linux/drivers/video/logo/<logoname>_clut224.ppm

the simpliest path now is to overwrite the existing LOGO_LINUX_CLUT224 .c file , using a script located in:
/linux/scripts/pnmtologo
do :
rename logo_linux_clut224.ppm to logo_linux_clut224_original.ppm
replace with your .ppm file , with the same name.
Generate the C file ( test : output is on stdout ) , from /linux/scripts directory :
./pnmtologo /home/<username>/raspberrypi_target/linux/drivers/video/logo/logo_linux_clut224.ppm -t clut224

you can compare the generated output to the /linux/drivers/video/logo/logo_linux_clut224.c original file.
now, do it again with output to a file  with naming :

./pnmtologo /home/<username>/raspberrypi_target/linux/drivers/video/logo/logo_linux_clut224.ppm -t clut224 -n logo_linux_clut224 -o /home/<username>/raspberrypi_target/linux/drivers/video/logo/logo_linux_clut224.c

-> next kernel build will rebuild the logo from the .c file. keep the 'Standard 224-color Linux logo' from menuconfig's options
314159265358979323846264338327950288
419716939937510582097494459230781640
628620899862803482534211706798214808

August 27, 2014

August news

Filed under: Raspberry 3.14, linux — Tags: , , , , — admin @ 9:49 am

Pi slave board for model B is under built and test.
some pictures of the prototype PCB, routed for model B :

The mainboard bare PCB

The optional 20x4 LCD display module

The optional 20x4 LCD display module

In the same time, a real time 3D user interface’s library is under development ( early stage picture of 3 surfaces acting like console’s char displays on the raspberry pi :

small window at back: 80x20 chars, wide window : 80x20 chars, a 3D object at top, and finally a rotating cube composed of 4 faces (12x8 chars) : about 6500 openGL polygons drawn and update in 13ms

August 28 : first assembly tests:
The assembly is ok , and the first tests to the development GUI are all ok also.

Some pictures of the device follows..

the LCD module stacked onto for the I/O mainboard.The LCD module is used for debugging purposes when code for the mainboard needs to be tested

the LCD module stacked onto for the I/O mainboard.The LCD module is used for debugging purposes when code for the mainboard needs to be tested

The back side of the mainboard. the PI is plugged there using the GPIO port connector.The mainboard powers the PI. the mainboard's internal regulator generates 5V @1amp max from a DC source in the range 7 to 35V

The back side of the mainboard. the PI is plugged there using the GPIO port connector.The mainboard powers the PI. the mainboard's internal regulator generates 5V @1amp max from a DC source in the range 7 to 35V

For now, the application used to develop and test programs on the mainboard is using the SDL layer ( but a 3D gui is under development ).The upper window is the mainboard's program editor. the middle 2 window are dumps of the the 'compiled' code of the program on the upper window. finally, 4 little windows on the bottom are dumps of the mainboard's RAM datas, wich include 4 blocs : _PROG, _BLOCA ,_BLOCB, and _PARAM.

For now, the application used to develop and test programs on the mainboard is using the SDL layer ( but a 3D gui is under development ).The upper window is the mainboard's program editor. the middle 2 window are dumps of the the 'compiled' code of the program on the upper window. finally, 4 little windows on the bottom are dumps of the mainboard's RAM datas, wich include 4 blocs : _PROG, _BLOCA ,_BLOCB, and _PARAM.

314159265358979323846264338327950288
419716939937510582097494459230781640
628620899862803482534211706798214808

June 26, 2014

Blender 2.69 python script for vertex,normals, and UV coords export

Filed under: Raspberry 3.14, linux — Tags: , , , , , , — admin @ 11:36 am

A simple script that can be run from a ‘text’ window in blender 2.69.
This a raw script,up to you to get what’s useful from it.

Obviously ,the script assumes the mesh is called ‘Cube’.
It writes to the file each vertices composing a face of the mesh, with each vertice’s normal and each face’s normal plus the face’s vertices group number + the face’s material number.
a face’s description is 3 lines, with the start char beein ‘A’,'B’ or ‘C’, corresponding to the 3 vertices of the face.

If a vertex is in multiple groups, the script takes the first group’s number for that vertex.
Groups and Materials output are Numbers, from 0…n , directly linked to the Material or Group’s blender - SLOT , whatever the name is.
Vertices are treated as individual (the real vertices coords are used , assuming the user’s program wich will use this output file will make it’s own ‘indexing’ of vertices wich have same coords  in common )
Finally, faces have to be triangulated :the script outputs only the 3 first vertices of a meshe’s face .

Hope this helps!

#!BPY

import bpy

cubedata = bpy.data.meshes['Cube']
v=cubedata.vertices
f=cubedata.polygons
print("\n\n-------------------------------------\n\n")
out = open("/home/path_to_your_dir/custom_output.txt", "w")
idx=0
for f in cubedata.polygons :
    # FACES MUST BE TRIANGULATED
    g=cubedata.vertices[f.vertices[0]]
    uvx=0
    uvy=0
    if cubedata.uv_layers.active!=None:
        uvx=cubedata.uv_layers.active.data[idx].uv.x
        uvy=cubedata.uv_layers.active.data[idx].uv.y
    else:
        print("UV error,face vertex[0]\n")
    out.write("A=%3.3f %3.3f %3.3f VN=%2.5f %2.5f %2.5f FN=%2.5f %2.5f %2.5f G=%u M=%u U=%2.5f V=%2.5f\n" % (g.co.x,g.co.y,g.co.z,g.normal.x,g.normal.y,g.normal.z,f.normal[0],f.normal[1],f.normal[2],g.groups[0].group,f.material_index,uvx,uvy))
    print("A=%3.3f %3.3f %3.3f VN=%2.5f %2.5f %2.5f FN=%2.5f %2.5f %2.5f G=%u M=%u U=%2.5f V=%2.5f\n" % (g.co.x,g.co.y,g.co.z,g.normal.x,g.normal.y,g.normal.z,f.normal[0],f.normal[1],f.normal[2],g.groups[0].group,f.material_index,uvx,uvy))
    g=cubedata.vertices[f.vertices[1]]
    uvx=0
    uvy=0
    if cubedata.uv_layers.active!=None:
        uvx=cubedata.uv_layers.active.data[idx+1].uv.x
        uvy=cubedata.uv_layers.active.data[idx+1].uv.y
    else:
        print("UV error,face vertex[1]\n")  
    out.write("B=%3.3f %3.3f %3.3f VN=%2.5f %2.5f %2.5f FN=%2.5f %2.5f %2.5f G=%u M=%u U=%2.5f V=%2.5f\n" % (g.co.x,g.co.y,g.co.z,g.normal.x,g.normal.y,g.normal.z,f.normal[0],f.normal[1],f.normal[2],g.groups[0].group,f.material_index,uvx,uvy))
    print("B=%3.3f %3.3f %3.3f VN=%2.5f %2.5f %2.5f FN=%2.5f %2.5f %2.5f G=%u M=%u U=%2.5f V=%2.5f\n" % (g.co.x,g.co.y,g.co.z,g.normal.x,g.normal.y,g.normal.z,f.normal[0],f.normal[1],f.normal[2],g.groups[0].group,f.material_index,uvx,uvy))
    g=cubedata.vertices[f.vertices[2]]
    uvx=0
    uvy=0
    if cubedata.uv_layers.active!=None:
        uvx=cubedata.uv_layers.active.data[idx+2].uv.x
        uvy=cubedata.uv_layers.active.data[idx+2].uv.y
    else:
        print("UV error,face vertex[2]\n")
    out.write("C=%3.3f %3.3f %3.3f VN=%2.5f %2.5f %2.5f FN=%2.5f %2.5f %2.5f G=%u M=%u U=%2.5f V=%2.5f\n" % (g.co.x,g.co.y,g.co.z,g.normal.x,g.normal.y,g.normal.z,f.normal[0],f.normal[1],f.normal[2],g.groups[0].group,f.material_index,uvx,uvy))
    print("C=%3.3f %3.3f %3.3f VN=%2.5f %2.5f %2.5f FN=%2.5f %2.5f %2.5f G=%u M=%u U=%2.5f V=%2.5f\n" % (g.co.x,g.co.y,g.co.z,g.normal.x,g.normal.y,g.normal.z,f.normal[0],f.normal[1],f.normal[2],g.groups[0].group,f.material_index,uvx,uvy))
    #
    idx=idx+3
    #   
out.close()

The output file (ascii) will look like :

A=0.351 -0.679 0.733 VN=0.93976 -0.23081 0.25208 FN=0.88620 -0.21390 0.41097 G=0 M=9 U=0.74219 V=0.25781
B=0.349 -0.221 0.975 VN=0.93954 -0.07318 0.33445 FN=0.88620 -0.21390 0.41097 G=0 M=9 U=0.74219 V=0.50000
C=0.249 -0.311 1.144 VN=0.41011 0.22208 0.88455 FN=0.88620 -0.21390 0.41097 G=0 M=9 U=0.74219 V=0.50000
A=0.245 1.119 -0.397 VN=0.41014 0.89917 0.15235 FN=-0.00437 0.84659 -0.53222 G=0 M=0 U=0.50781 V=0.49219
B=0.246 0.843 -0.835 VN=0.41194 0.25422 -0.87500 FN=-0.00437 0.84659 -0.53222 G=0 M=0 U=0.50781 V=0.74219
C=-0.251 1.116 -0.397 VN=-0.41353 0.89776 0.15146 FN=-0.00437 0.84659 -0.53222 G=0 M=0 U=0.25781 V=0.49219
A=-0.345 -0.957 0.295 VN=-0.93915 -0.32841 0.10056 FN=-0.00010 0.03756 0.99929 G=0 M=9 U=0.00000 V=1.00000
B=-0.245 -1.148 0.302 VN=-0.41090 -0.65740 0.63161 FN=-0.00010 0.03756 0.99929 G=0 M=9 U=0.00000 V=1.00000
C=0.251 -1.146 0.302 VN=0.41246 -0.65545 0.63262 FN=-0.00010 0.03756 0.99929 G=0 M=9 U=0.25781 V=1.00000
A=0.352 -0.954 0.295 VN=0.93982 -0.32621 0.10154 FN=0.88526 -0.46476 0.01753 G=0 M=9 U=0.25781 V=1.00000
B=0.251 -1.146 0.302 VN=0.41246 -0.65545 0.63262 FN=0.88526 -0.46476 0.01753 G=0 M=9 U=0.25781 V=1.00000
C=0.251 -1.165 -0.215 VN=0.41252 -0.70116 -0.58150 FN=0.88526 -0.46476 0.01753 G=0 M=9 U=0.25781 V=0.75000
A=0.247 0.216 -1.166 VN=0.41008 0.58296 -0.70138 FN=0.00010 -0.03762 -0.99929 G=0 M=0 U=1.00781 V=0.75781
314159265358979323846264338327950288
419716939937510582097494459230781640
628620899862803482534211706798214808

Linux : Reading the Mouse events datas from /dev/input/mouse0

Filed under: Raspberry 3.14, linux — Tags: , , , — admin @ 8:53 am

A simple program to check the /dev/input/mouse0 datas

Tested on the raspberry PI with GPM installed

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <linux/input.h>

#define MOUSEFILE "/dev/input/mouse0"
//
int main()
{
    int fd;
    struct input_event ie;
    //
    unsigned char button,bLeft,bMiddle,bRight;
    char x,y;
    int absolute_x,absolute_y;

    if((fd = open(MOUSEFILE, O_RDONLY)) == -1) {
        printf("Device open ERROR\n");
        exit(EXIT_FAILURE);
    }
    else
    {
        printf("Device open OK\n");
    }
    //
    printf("right-click to set absolute x,y coordinates origin (0,0)\n");
    while(read(fd, &ie, sizeof(struct input_event)))
    {
        unsigned char *ptr = (unsigned char*)&ie;
        int i;       
        //
        button=ptr[0];
        bLeft = button & 0x1;
        bMiddle = ( button & 0x4 ) > 0;
        bRight = ( button & 0x2 ) > 0;
        x=(char) ptr[1];y=(char) ptr[2];
        printf("bLEFT:%d, bMIDDLE: %d, bRIGHT: %d, rx: %d  ry=%d\n",bLeft,bMiddle,bRight, x,y);
        //
        absolute_x+=x;
        absolute_y-=y;
        if (bRight==1)
        {
            absolute_x=0;
            absolute_y=0;
            printf("Absolute x,y coords origin recorded\n");
        }
        //
        printf("Absolute coords from TOP_LEFT= %i %i\n",absolute_x,absolute_y);
        //
        // comment to disable the display of raw event structure datas
        //
        for(i=0; i<sizeof(ie); i++)
        {
            printf("%02X ", *ptr++);
        }
        printf("\n");
    }

return 0;
}

The read() command is blocking for now.
The following C code does almost the same thing, with non-blocking option enabled this time:

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <linux/input.h>

#define MOUSEFILE "/dev/input/mouse0\0"
//
int main()
{
    int fd;
    struct input_event ie;
    unsigned char *ptr = (unsigned char*)&ie;
    //
    unsigned char button,bLeft,bMiddle,bRight;
    char x,y;                                                            // the relX , relY datas
    int absolute_x,absolute_y;

    if((fd = open(MOUSEFILE, O_RDONLY | O_NONBLOCK )) == -1)
    {
        printf("NonBlocking %s open ERROR\n",MOUSEFILE);
        exit(EXIT_FAILURE);
    }
    else
    {
        printf("NonBlocking %s open OK\n",MOUSEFILE);
    }
    //
    printf("--------------------------------------------------------\n");
    printf("right-click to set absolute x,y coordinates origin (0,0)\n");
    printf("left+right click to EXIT\n");
    printf("--------------------------------------------------------\n");
    //
    while(1)
    {       
        if(read(fd, &ie, sizeof(struct input_event))!=-1)
        {
            //
            button=ptr[0];
            bLeft = button & 0x1;
            bMiddle = ( button & 0x4 ) > 0;
            bRight = ( button & 0x2 ) > 0;
            x=(char) ptr[1];y=(char) ptr[2];
            if(bLeft&bRight) { printf("\nright+left ,EXIT\n");break;}
            // computes absolute x,y coordinates
            absolute_x+=x;
            absolute_y-=y;
            // set absolute reference ?
            if (bRight==1)
            {
                absolute_x=0;
                absolute_y=0;
                printf("Absolute x,y coords origin recorded\n");
            }
            // show it!
            printf("X%i Y%i\n",absolute_x,absolute_y);
            fflush(stdout);
        }
    }
    //
    close(fd);
return 0;
}
314159265358979323846264338327950288
419716939937510582097494459230781640
628620899862803482534211706798214808
« Newer PostsOlder Posts »

cat{ 50 } { post_572 } { } 2009-2015 EIhIS Powered by WordPress