Archive

Posts Tagged ‘linux’

Valkertown en planeta linux y el planeta en identica

December 7th, 2008

Recientemente descubri que mi blog hace parte del Planeta Linux que es una comunidad latinoamericana de blogs que hablan sobre GNU/Linux, personalmente trato de apoyar tanto como pueda a esta clase de iniciativas.

Cuando visite el sitio del planeta vi que teanian una cuenta en Twitter, esto me sorprendio un poco, pensé que seria más interesante promover identi.ca. En ese momento decidi escribir un correo para solicitar los feeds del planeta en identi.ca. Desafortuandamente no recibi una respuesta tan pronta como lo esperaba y me apresure a resolver la situación por cuenta propia.

Ahora el servicio corre por cuenta de Valkertown, se puede seguir el Planeta Linux en identi.ca.

Por ahora lo que hace es redirigir el feed rss del Universo a identica haciendo polling cada 5 minutos. Sin embargo lo mejor seria tener información en tiempo real de los envios, yo utilizo un
Identica Tools Para enviar la información de mis envios, esto podria eliminar totalmente la necesidad de hacer polling y mejoraria inmensamente la idea de los planetas.

Bueno queda todo listo y espero comentarios sobre la configuración

Enlaces y noticias , , , , ,

Finally publishing DS1M12 python code

November 26th, 2008
Well it’s done, I have published my work on the DS1M12 Python Swig Wrapper.

It’s located on the mercurial repos, it’s hosting two files that maybe I will have to delete since they come from the original source that I do not own. Also everything is build around Python 2.5, going to try building it for Python 2.6

It requires two downloads one from USB Instruments itself and another from a thirdparty driver

You have to use these before compiling anything of the code and also remember to update your LD_LIBRARY_PATH to poing where you placed the .so files. On my code everything is supposed to be on the same directory as the project. You will also need the .rbf files, the linux packages comes with one file that means it will use 1K buffer but the windows package comes with several files for 1K,2K,4K and 8 K buffers. These files are used to program some FPGA inside the osciloscope and set the buffer size for the capture and output, one should do some testing to find the optimum buffer for the application.

I have some bad luck now since I no longer own one of these osciloscopes and can’t continue testing and improving the code.

What I found is that there’s still some bugs, I think there’s a buffer overun that leads to a segfault when the code it’s run over continued periods of time but I don’t know what is causing it exactly. My main suspects are the numpy arrays being passed to the ds1m12 libraries but I didn’t have enough time with the device so I could investigate it further. I also tried almost every configuration parameter and operation mode and seems to be working, then, I was able to use the signal generator, external trigger and all the options you can set for each one of the channels even turning on/off each channel individually.

I did several testing and found that the kernel I was using had some really big impacts, 2.6.26 kernels worked fine for me, with 2.6.27 kernels it didn’t work at all. So if you experience some problems with the code try downgrading or upgrading the linux kernel you are using.

Good luck and please let me know how it goes for you.

Enlaces y noticias , , , , , ,

Goodbye Slackware

November 22nd, 2008
Slackware Powered

Well, after having spent all my time with GNU/Linux using my favorite distro, which is almost 8 years, I finally moved away from Slackware. Not that I have any problem with it, it’s just I found a distro that I like even more.

My new distro of choice is now Archlinux, which happens to be a quite updated distribution contrary to slackware, I have yet to see the stability and all that, but after a week of using it I have found I can spend less time fiddling with source installs and still don’t being bothered by excesive system automation. As far as binary builds Arch respects the source and will not alter the stuff that’s installed also I have seen very few patches applied to the source.

My favorite part of Archlinux are the PKGBUILDS which are smart enough to create packages from source code coming from git/svn/mercurial/darcs/etc… checkouts and handle the packaging and still gives me full control of the build process and patching. This is pretty important for me since I happen to run most of my day to day software from version control checkouts with custom patches and compilation and this is the first non-slackware distro that I can do that without fighting at all with the distribution.

While installing Archlinux I found that my old lvm schema that used root as vg and one lv was a big mistake since it interfered with kinit,udev and some scripts during the boot process. On slackware I didn’t had any trouble since I had modified my boot to handle that, yet on arch kinit simply will not work if that schema persisted, so I had to change my vg and lv names (not a big deal but I wasted so much time figuring out)

So far being very happy with it, no more compiling a lot of packages I didn’t like and can keep kernel compilations to the minimum since Archlinux software list is really up to date. This really helps when you use new software or happend to be dealing with really recent hardware.

Archlinux Powered

Finally I really doubt I ditch Slackware at all, since I have a load of projects that still runs over the slackware platform and ideas but with time I will update them all to arch, including my microwulf cluster that I have on the CIF’s basement.

EOP

Enlaces y noticias , , , ,

DS1M12 usb osciloscope in linux and python

October 1st, 2008
Well, today in the afternoon I was given a task, make the Usb Instruments DS1M12 usb osciloscope in linux, it was quite a surprise
to find out it had some kind of support for Linux and I started my work with their sources.

I found it requires two downloads one from USB Instruments itself and another from a thirdparty driver

Well, those two comes with some .so files you need to link your programs so you need to make sure
they have proper names like libDS1M12.so, libftd2xx.so and they can be found in the LD_LIBRARY_PATH or something like that, this is important.

After you get this solved it’s pretty straightforward with the USB Instruments package comes a good example you can use to understand their library, this took a bit of time since we(called some one to help me pinpoint some problems) could get it working and seeing the data flow quite fast, yet, it took us some time to discover that the sample code enabled the testmode and instead of real sampling, after that we could see the two channels sampling also the signal generator send out the example signals.

After this we agreed that it would be good to have a python interface to this osciloscope and I started working with swig to generare a proper wrapper around the USB Instruments library, around an hour ago I finished what we could call the first release of the interface and I’m being able to plot some data using matlplot lib. It took me a bit to figure how to manage to wrap some of the functions yet in the end swig and numpy solved all my issues.

I’m not really sure If I can release everything at the moment, I think I’ll have to ask USB Instruments since I use one of their headers to build the swig wrapper and it requires some minor modifications to make it work nicely so I would have to publish the modified header. If i get permission or any idea how I should publish the repository, it will be here at valkertown Mercurial Repositories

For now you have to beleive me that now the use of this osciloscope it’s reduced to something like this

  1.  
  2. """
  3.   Author: Carlos Andres Perilla
  4.   Centro Internacional de Física, Bogotá-Colombia.
  5.  
  6.   This program is free software: you can redistribute it and/or
  7.   modify it under the terms of the GNU Affero General Public License
  8.   as published by the Free Software Foundation, either version 3 of
  9.   the License, or (at your option) any later version.
  10.  
  11.   This program is distributed in the hope that it will be useful, but
  12.   WITHOUT ANY WARRANTY; without even the implied warranty of
  13.   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.   Affero General Public License for more details.
  15.  
  16.   You should have received a copy of the GNU Affero General Public
  17.   License along with this program.  If not, see
  18.   <http://www.gnu.org/licenses/>.
  19.  
  20. """
  21.  
  22. from Osciloscope import UsbOsciloscope
  23. from pylab import *
  24. import time
  25.  
  26. o = UsbOsciloscope()
  27. # Load the firmare into the osciloscope FPGA, this the RFB that comes in the USBI pack.
  28. o.program()
  29. # Enables both channels for sampling
  30. o.set_channels()
  31.  
  32. while True:
  33.     # Start signal, it gets some other params like
  34.     # triggering configuration, port conf and a lot of other things
  35.     o.start_scan()
  36.     status = -1
  37.     while status != 0:
  38.         # Do the actual reading of a single frame
  39.         retval = o.get_data()
  40.         status = retval[0]
  41.         if status != 0:
  42.             # Since the buffers can be large and the according
  43.             # to the sampling rate we may need to wait a bit
  44.             time.sleep(0.01)
  45.         else:
  46.             # If we got the data successfully we can now plot what we got using
  47.             # matplot lib.
  48.             values = retval[5].dwNumValuesReturned
  49.             x_axis = arange(0,values,1)
  50.             plot(x_axis ,retval[2][0:values],‘r–’,x_axis,retval[3][0:values],‘bs’)
  51.             show()
  52.  

Enlaces y noticias , , , , , , ,

Xenomai, Slax y Linux Kernel 2.6.22.1 Parte 1

August 27th, 2007

La tarea consiste en mezclar una distribución “Live” de GNU/linux en conjunto con un kernel reciente y especialmente parchado y configurado para tiempo real. La idea básicamente es proveer un sistema base para desplieges de los sistemas embebidos en producción. La principal ventaja de utilizar esta aproximación es que el sistema de desarrollo y el sistema final son practicamente identicos, ya que todo el desarrollo se realiza sobre Slackware, y el despliegue se realiza sobre Slax.

Ahora la tarea no resulta sencilla, Slax 5.1.8 utiliza un kernel 2.6.16.x y queremos utilizar un kernel 2.6.22.1, esto implica vivir con los serios cambios que se dieron en las series 2.6.20 y 2.6.21. Ahora el núcleo de Slax y su excelente sistema de paquetes .mo radica en dos parches adicionales para el kernel vanilla: Squashfs+lzma y unionfs.

Tanto Squashfs+lzma y unionfs son el pilar central de Slax, estos dos sistemas de archivos proveen un rendimiento y flexibilidad excelentes a Slax. Y por la experiencia del CIF, no tengo queja alguna aún sobre su estabilidad.

Xenomai por su parte requiere del parche de ipipe de adeos y provee tambien su propio set de parches.

Con esto quedan definidos todos los elementos que se requieren para preparar un kernel capaz de tener tiempo real provisto por Xenomai y que puede ser utilizado por Slax. Desafortunadamente la tarea no es trivial y la explicaré en la segunda parte.

Eso es todo por ahora, quizá adicione a esta parte luego que carajos es cada parche y programa que mencione aquí.

EOP

Enlaces y noticias , , , , , , ,

Dos excelentes fuentes de documentación para Drivers Linux y USB

February 6th, 2007

Voy a realizar una pequeña reseña de dos documentos sumamente utiles para el desarrollo de drivers USB para Linux.

Linux Device Drivers, Third Edition

Este libro es uno de aquellos que no se pueden omitir como referencia en cada desarrollo, contiene casi todo lo que se necesita saber para crear drivers de toda clase, con un estilo muy particular.

El libro presenta la documentación necesaria para crear las tres clases principales de dispositivos en linux, character, block y net. Así como los mecanismos necesarios para registrar memoria, manejar dispositivos USB y PCI, enumeración mayor/minor automatica(nuevo para Kernel 2.6).

En general el libro destaca por presentar una fuente de información de las particularidades de los últimos cambios en la linea 2.6 del kernel de linux, y un gran número de valiosos consejos muy útiles para escribir drivers mucho más limpios y eficientes.

Programming Guide for Linux USB Device Drivers

Este segundo libro se trata más de una referencia particular a los drivers USB; contiene la información concreta de la implementación de dispositivos de carácteres y presenta una información más detallada sobre las diferentes formas de realizar transferencias en el USB.

EOP

Enlaces y noticias , , , ,

AT90USB128 Actualización

December 26th, 2006

OK, hoy volvi a trabajar un rato con este chip:

Logre compilar el código de ejemplo de Atmel con algunos inconvenientes por que este código viene para windoze y toco cambiar unos \ por /, me tomo demasiado tiempo darme cuenta de eso -_-, para futura referencia.
Luego cargue el .hex que genero de este ejemplo con mi uisp modificado y en el dmesg de mi kernel, sale lo siguiente:

usb 2-1: new low speed USB device using ohci_hcd and address 2
usb 2-1: device descriptor read/64, error -110
usb 2-1: device descriptor read/64, error -110
usb 2-1: new low speed USB device using ohci_hcd and address 3
usb 2-1: device descriptor read/64, error -110
usb 2-1: device descriptor read/64, error -110
usb 2-1: new low speed USB device using ohci_hcd and address 4
usb 2-1: device not accepting address 4, error -110
usb 2-1: new low speed USB device using ohci_hcd and address 5

Este ejemplo según parece maneja una interface USB-USART, utiliza un scheduler sin continuación, esta demasiado bien estructurado parece, pero tiene un reguero de directorios y referencias que hacen molesto seguir el funcionamiento. Me queda una tarea larga para terminar de comprender como se usa el USB en este dispositivo, quiza empieze la siguiente prueba con los HID.

EOT

Enlaces y noticias , , , ,

Modulo Kernel para ARM9

November 13th, 2006

Hace poco compo parte de un proyecto escribi un m’odulo para el kernel de linux, en especial para el target de ARM9 AT91RM9200.

La idea es sencilla, es un driver para el PIO, que debe generar los siguientes dispositivos:
/dev/port[a-g]
/dev/pin[a-g][0-31]

As’i se puede realizar un acceso directo al PIN individual o a cada puerto en conjunto.

Inicialmente estoy trabajando con el puerto A, y es funcional de la siguietne forma.

echo O > /dev/pina14
echo 0 > /dev/pina14
echo 1 > /dev/pina14
echo I > /dev/pina14

Esto saliio como una necesidad y mi poca experiencia con los device drivers de Linux produjo ese driver.
Sin embargo leyendo el libro Linux Device Drivers con bastante juicio, he encontrado que cometi algunas barbaridades en ese código, ya que mezcle arbitrariamente mecanismo y politica. Adem’as de no utilizar los mecanismo estandar para el ctlio. Por esto me he comprometido a crear el driver completamente y con un disegno que debe estar terminado para cuando termine el libro, completamente de acuerdo con las especificaciones de disegno de un buen modulo/driver de Linux.

El motivo para crear tal driver, es simple, con el port de linux para ARM9, queremos tener un ambiente de desarrollo muy sencillo para tareas tipo PLC, donde lo que importa es la gestion y no los tiempos de respuesta.
Este mecanismo en el que un simple echo 0 > /dev/pinxx, echo > /dev/pinxxx controla una salida l’ogica permite disegnos de programas muy simples para el control desde un muy alto nivel.

EOT

Enlaces y noticias , , , ,

Back

October 27th, 2006

Nuevamente voy a continuar la escritura “regular” al web-log, me hace falta pasar m’as del trabajo que realizo, se acumula mucho trabajo y no queda nada por aca. Adem’as que las ‘ultimas entradas son algo irrelevantes.

Supongo que me tomare algunas entradas para actulizar.

De lo m’as antiguo a lo m’as reciente.

+ Esta terminado el LFS para el ARM9 esta ocupando poco menos de 128MB sin utilizar compresi’on, esta en el tintero utilizar sistemas de archivos comprimidos de solo lectura.

EOT

Enlaces y noticias ,

Slax Linux Live

July 24th, 2006
Slax es quizá el mejor Linux live que he usado, sobre todo por que se ajusta a todas mis necesidades, este post va un poco al trabajo que realice recientemente con Slax a modo de no perderlo y compartirlo.

Slax en principio es Slackware GNU/Linux por lo que mi experiencia en Slackware es de provecho a la hora de modificarlo de la forma que lo hice.

Como todos mis envios, no son para principiantes y asumo mucho conocimiento, quizá es una buena guia para saber que estudiar.

Objetivo de Modificación

El principal objetivo es modificar Slax de forma que pueda ser utilizado en una plataforma embedida.
Para esto se requiere:

  • Cambiar el Kernel por un kernel de tiempo real
  • Arranque por memoria USB
  • Mantener la modularidad de Slax

Preparación

Para todo esto es necesario escojer una versión de Slax, por mi parte utilice Slax Frodo por ser la más pequeña y la más suceptible a modificaciones.
La imagen se debe copiar al disco duro para ir modificando las partes y al final volver a generar una imagen final para CDROM, USB o lo que sea.
Es una excelente idea utilizar un emulador de i386 tipo qemu, en las etapas del arranque pues esto lleva un tiempo largo.

Kernel RTAI

La primera tarea sobre Slax es cambiar el kernel por defecto por uno aceptable para las labores del laboratorio y es tiempo real. Por demás la arquitectura i386 es terrible en cuanto a tiempo real se refiere, sin embargo RTAI cumple su función más allá de los 100uS lo cual es aceptable.

La presencia de un periferico conocido como APIC marca la diferencia entre latencias de atención a interrupciones y cambios de tareas en el SO. Con APIC la latencia de atención es supera 1uS sin APIC cae por debajo de los 25uS, esto teniendo en cuenta un procesador común x86 a 1Ghz, no me quiero extender en como se realizan estas mediciones y los números estan bastante gruesos.

En la mayoria de procesadores x86 actuales el APIC es un periferico común, sin embargo en el mercado de procesadores embedidos x86 el APIC es un periferico excaso.

La configuración del Kernel RTAI depende en gran medida de la presencia del APIC y los requerimientos particulares de SLAX.

Al momento de escribir este envio SLAX esta trabajando con SquashFS y UnionFS, parches para el Kernel que pronton estarán incluidos en el arbol principal del Kernel de Linux si es que ya no lo estan.

Ahora, son tres parches los que hay que aplicar a un kernel vanilla y cada uno es compatible con una colección diferente de versiones del kernel por lo que la selección del kernel vainilla es algo complicada.

Los enlaces para los tres parches:

Ahora la estabilidad del sistema depende de lo bien que se escoja la combinación de versiones de estos parches, en algunos es posible ir por versiones recientes incluso experimentales y en otros una aproximación más conservadora es la mejor opción.

Cada parche tiene sus instrucciones y sus propias configuración, leer la documentación de cada uno es bastante importante.

La parte critica de la configuración es por parte de RTAI, pues este tiene requerimientos especificos en la configuración en especial la parte del APIC.

Si se tiene APIC seleccionar la familia de procesadores para obtener la mejor optimización mejora bastante el desempeño en el tiempo real. En el caso de no tener APIC la mejor opción es desactivar todo lo referente a él en la configuración y seleccionar la familia i586(o en el caso de una anterior la correspondiente a su familia).

Initrd

Una parte critica del cambio del kernel, en especial si se trata de un kernel 2.6 es mantener un initrd con todo lo necesario para que el sistema arranque limpiamente.

La idea del initrd es tener un sistema base de arranque, por lo general se trata de un ramdisk de solo lectura.

El primer paso es reutilizar el ramdisk que provee Slax y reemplazar los modulos y los archivos correspondientes en /lib/.

UnionFS requiere de unas herramientas en espacio de usuario, estas tambien deben ir en el initrd.

Lograr el arranque completo lleva varios pasos y requiere de un buen entendimiento de los requerimientos del sistema para arrancar via USB, CDROM o el medio necesario, por lo que insisto en utilizar quemu, bochs, vmware.

Arranque

El arranque puede ser complicado, por mi parte utilice syslinux, que es bastante sencillo y funciono perfectamente.

A este hay que indicarle nuestro initrd y la imagen del kernel que se acaba de compilar.

Una vez se logre arrancar el sistema al punto en el que los scripts de arranque de Slax intentan cargar los modulos de Slax, es hora de continuar haciendo cambios.

Algunas cosas para recordar:

  • EL initrd por defecto viene bastante estrecho en espacio libre, es necesario crear uno nuevo
  • El tamaño de ramdisk que se le pasa al kernel por defecto en Slax es bastante pequeño y debe ser ajustado al tamaño del ramdisk que creemos
  • dd if=/dev/zero of=zeros.img bc=xxxx
  • mke2fs zeros.img
  • mv zeros.img initrd
  • gzip initrd
  • gunzip initrd.gz
  • mount initrd /mnt/hd -o loop

De ninguna forma esta información es completa, hace falta leer mucho para entender completamente este envio y en sí, no es merito mio sino la recopilación de la información disponible en cantidad de manuales y mailing list que consulte para lograr hacer esto con conocimiento de causa; sin embargo , me parece una buena guia para saber que buscar en cada uno de estos medios de información.

Me gustaria recibir comentarios sobre que ampliar y preguntas sobre lo que esta expuesto aquí.

Sigo en un próximo(realmente próximo) envio.

EOT

Enlaces y noticias , , ,