domingo, 17 de mayo de 2015

Xilinx MIG for spartan 6 example

This is an example about how to use the Xilinx Memory Interface Generator for Spartan 6 in an sp605 board.

Although the documentation is very clear, there are not many simple examples available on internet, so I'm publishing this one that is very straightforward: and mig instance is generated with two ports, one port for reading and another port for writing. For writing, data is fetched from a switch and a button triggers the write operation. For reading, a button queues a read operation and, when available, its transferred to a led array. Both operations are done explicitly, so you can debug signals and have a better understanding of the functions.

A few notes about the MIG's core usage:

  • For reading, you queue a read command and wait for the data, If your reading port is c3_p2, use "c3_p2_rd_empty = '0'" as a data valid signal for its data port.
  • For writing, you first write to the data FIFO and just then queue the write command.

Here are the steps for the configuration of the MIG generator:













Source code (vhdl and constraints) can be found here: https://drive.google.com/folderview?id=0B64FjViHrZqpfkl1dE5Eb0QzWXBRRDFzVkZrX3F4ZFR2eVlJN3hFT1k4UWxLOE1CMzlKekk&usp=sharing.

Happy coding!

sábado, 28 de marzo de 2015

Creando un servicio TCP con systemd en el Intel Edison


Hola!

No hace mucho en el trabajo me encargaron desarrollar un par de servicios que corrieran en Ubuntu. Yo conocía UpStart, que era, y aún es, el sistema oficial para cargar todos los procesos de Ubuntu, incluyendo los servicios de fondo. Y empecé a desarrollar pensando en él hasta que leyendo me enteré de que Ubuntu va a abandonar ese sistema por systemd. Ya llevaba bastante avanzado mi proyecto y quería saber si valdría la pena volver a cambiarlo para usar systemd. El artículo que más me sirvió para entender fue este de Lennart Poettering y lo que más me llamó la atención fue el Socket Activation Protocol. Es una excelente forma de arrancar servicios de forma paralela. Ya que un "servicio" puede ser tanto un servidor HTTP como cualquier programa que no requiera interfaz gráfica, quería saber si lo podía usar en mi Intel Edison... y sí pude! Aquí están los pasos de cómo lo hice.

El servicio de prueba consiste en lo siguiente: Un servidor que crea un hilo por cada cliente conectado. Estos sólo envían un mensaje y cierran la conexión. El código está basado en el artículo mencionado. Los pasos a resaltar son:
  1. Detección de la señal SIGTERM.- Esta señal la usa systemd para indicarle a los servicios de fondo cuando deben finalizar.
  2. Detectar si el socket de escucha lo provee systemd ó debemos crearlo nosotros. Lo crea systemd cuando el programa se inicia como un servicio de fondo. Se debe crear uno por nuestra cuenta si el programa se lanza de forma explícita(ej: línea de comando)
  3. Escuchar conexiones y crear un hilo por cada cliente.
  4. Cuando se reciban la señal SIGTERM: cerrar el socket de escucha, esperar que acaben los hilos de los clientes y finalizar el programa.

El mismo código fuente funciona en Ubuntu 14.04 y en el Linux del Intel Edison. Sólo hay una diferencia al momento de construir el proyecto:

En Ubuntu tienes que enlazar con:
-lsystemd-journal -lsystemd-daemon -lpthread
Para el Intel edison, al enlazar usas:
-lsystemd -lpthread

El código, el archivo CMake y los scripts de systemd para usar el proyecto lo pueden descargar del sgte. enlace:
https://drive.google.com/file/d/0B64FjViHrZqpLWxnanpVSmpXOU0/view?usp=sharing

Cualquier consulta en lo comentarios.
Happy Coding! :)







sábado, 9 de febrero de 2013

NFC-fy me!

Hola!

Ya que ya tengo mi lumia he estado haciendo un montón de programas-juguete con él. Sin embargo uno me pareció muy útil y, después de varios rechazos, finalmente lo logré subir a la Windows Phone Store. Se llama NFC-fy me.


Su función es bastante sencilla. Simplemente a tus audífonos bluetooth normales le da superpoderes para poder emparejarse de forma automáticamente con cualquier otro celular con NFC.¿Has visto los bellísimos Nokia-Purity? pues bueno, ahora tus audífonos bluetooth también vana a tener la misma funcionalidad.

Aqui está el video de como funciona:

http://www.youtube.com/watch?v=GhTbu0tVPEQ

Y por supuesto, esta aplicación es gratuita.

Aqui está el link para su descarga:
http://www.windowsphone.com/es-pe/store/app/nfc-fy-me/6c3cbf3d-4847-469e-aa68-38332a4173a1

Y el código fuente lo pueden obtener a través de codeplex:
http://nfcfyme.codeplex.com/

Hasta luego! diviértanse!
Happy coding!



lunes, 17 de diciembre de 2012

First OpenGL experiments with the Pandaboard


Hello!

It's been a long time since my last udpate. But hopefully i'm going to post more  frequently from now on since i've got more toys this chritsmas. One of this is my new pandaboard, ES revB2. I bought it because it was already time for me to learn OpenGL ES more deeply, and since I'm not very fan of android(or any non native platform) i chose this beacuse i can program it with direct acces to the hardware.

First thing i tried was the Linaro Ubuntu distribution. I was very impressed after watching this board booting Ubuntu, and not a 'lite' version, it was the complete desktop environment with the same applications and tools that I use in my PC, wifi and bluetooth. It didn't have the same speed of course, but everything was runing almost flawlessly, almost.... I managed to compile a program from the Imagination technologies OpenGLESSDK, the 'Hello World' and, although functional, i realized that the rendering was being done in software, through MESA. 

OK..., after that i tried GeexBox, XBMC for the pandaboard. It worked very very well and finally i saw the pandaboard doing a very good job ta rendering the UI and 1080p video decoding.

After that, now I'm trying wth the Ubuntu image available from pandabaord.org . I tested the previous executable and the program ran correctly creating an OpenGL ES 2 context with hardware acceleration. So, my cross compilation method is correct and there maybe something that i missed configuring the linaro image. Anyway, I think that from now I'll make the rest of my experiments with this distribution.

For cross compilation I'm using the linaro toolchain. It is working correctly, i only had to copy some '.so's from the pandaboard and now I'm compiling everything in my Ubuntu desktop, with Netbeans. Here is an example of hos to write a qmake file to build programs for the pandaboard:

TEMPLATE = app
CONFIG += console
CONFIG -= qt
SOURCES += \
main.cpp
#El SDK de PowerVR
INCLUDEPATH += /opt/Imagination/PowerVR/GraphicsSDK/SDK_3.0/Builds
INCLUDEPATH += /opt/Imagination/PowerVR/GraphicsSDK/SDK_3.0/Builds/OGLES2/Include/
QMAKE_LIBDIR += /opt/Imagination/PowerVR/GraphicsSDK/SDK_3.0/Builds/OGLES2/Linux_armv7/Lib
QMAKE_LIBDIR += /home/rhuertas/PandaBoard/TargetLibs
LIBS += -lEGL
LIBS += -lGLESv2
LIBS += -lX11
LIBS += -lxcb
LIBS += -lXau
LIBS += -lXdmcp
#El SDK de LinaroQMAKE_CXX = arm-linux-gnueabihf-g++
QMAKE_CC = arm-linux-gnueabihf-gcc
QMAKE_LINK = arm-linux-gnueabihf-g++
In the 'TargetLibs' directory are the following '.so' files, extracted from the image: libX11.so.6.3.0, libXau.so.6.0.0, libxcb.so.1.1.0, libXdmcp.so.6.0.0. Also there are the softlinks to remove any version specific linkage(ej. libX11.so)

Even more awesome is that, since OpenGL 4.1, you have full OpenGL ES available in your PC, so you can develop and test your programs in your PC for functionality and correcteness of your shaders, and then just test how well it performs on the pandaboard. The setup is easy, I'm attaching a sample project made with netbeans to show you how you can use this ideas to quickly develop OpenGL ES apps from your PC.


An finally, some photos of the toy:


My setup, a bluetooth keyboard, an USB hub and a mouse. Wifi for networking. video output to my TV, because I don't want to buy another monitor

The pandaboard running an OpenGL application with hardware acceleration enabled



The same program from above running on my desktop. i just need to select the current
configuration in the Netbeans project to generate each target.(ej: DebugPC, ReleasePC, DebugPanda, ReleasePanda...)

My main aim is to develop an open gaming-enertainment platform that I can use with the pandaboard, beagle boards o raspberry pis. Since now Ubuntu si being ported the those wonderful android phones and tablets, i hope soon we can get rid of thet virtual machine and have more applications working directly with the OS, like in iOS and Windows Phone platforms.

More ideas and help is welcome.
Happy coding!

lunes, 22 de agosto de 2011

Osciloscopio PIC18F Starter Kit

こんいちは!
Hola a todos!
No hace mucho necesitaba refrescar mis conocimientos sobre PICs y decidí comprarme el maravilloso kit PIC18F Starter Kit de Microchip. Es totalmente fascinante! Tiene acelerómetro, sensores capacitivos, interfaz USB, sensor de temperatura, tarjeta SD y depurador integrado! Además tiene una cabecera con acceso a los pines del PIC por lo que se puede conectar a otras tarjetas o circuitos y lograr cosas interesantes. Una de las principales razones por las que compre este kit es proque funciona a 3.3V, el estándar que usan la mayoría de tarjetas de ahora.

Aún por si solo, es super divertido! Aquí uno de los primeros proyectos que he hecho, un osciloscopio de bolsillo:



Pueden descargar el código en este enlace:

http://dl.dropbox.com/u/26756381/OSCI1_0.rar

Nos vemos!

sábado, 23 de abril de 2011

Creando periféricos con la interfaz AXI

Este es mi primer apunte para el blog. Aquí describo la manera de como crear un periférico que implemente las interfaces AXI y que sea reconocido por el Xilinx Platform Studio. Cualquier consulta, duda, aporte o crítica es muy bien recibida:

Perifericos con interfaz AXI

Bienvenidos a mi blog

Hola visitantes.

He empezado a escribir este blog como una forma de compartir los conocimientos que he adquirido, pues, ya que soy un 99% autodidacta,  los he obtenido en gran parte gracias a la colaboración de mucha gente que decide publicar lo que sabe en sus propios blogs y/o páginas, necesitaba de algún modo devolver el favor :D.

Aquí escribiré notas técnicas sobre cosas relacionadas con la electrónica que me ha costado mucho esfuerzo encontrar y quiero que el resto de ustedes se vena beneficiados por mis investigaciones. Estoy abierto a preguntas, consultas y críticas de todos ustedes para hacer de este blog uno de los más interesantes que haya en la web.

Asi que... a bloggear! =D