Monday, December 14, 2009

Piklab e pk2cmd integrare gli strumenti

Nella prededente post "pk2cmd PicKit2 microchip con Linux ubuntu" abbiamo preso in considerazione il PICkit 2 di microchip per programmare una vasta serie di CHIP di MicroChip della serie PIC.

Il tools di piklab integrato con sdcc e con pk2cmd diventa un ottimo strumento per lo sviluppo rapido di applicazioni in linguaggio C e ASM per Pic. Il problema maggiormente sentito è che il rapido sviluppo di prodotti propietari mal si concila con lo sviluppo opensource affidato da un volontariato di sempre meno mani esperte che modificano e seguono il codice sorgente opensource di prodotti specifici. Pare che le case di produzioni abbiano anche poco interesse a pagare chi potrebbe dare piattaforme alternative a sviluppatori di microchip o silicon slide programmabili. Tra queste possiamo fare un lungo elenco di produttori di Chip programmabilie che vendono o sponsorizzano semi free tools di programazione ma solo per piattaforma Windows, senza tener conto che ampliando l'offerta di software anche con licenza proprietaria ma ben supportata e disponibile per il free of download farebbe crescere il mercato di vendita del loro prodotto (silicio) programmabile e dei tools di programmazione e/o debug.

Bando alle polemiche e passiamo al problema della integrazione del comando descritto nel precedente post con l'interfaccia grafica di piklab.

Nel sito di piklab non ho trovato indicazioni su come "custom comand" prendendo variabili dal programma (es: tipo processore, nome file, eccc....) pertanto vi faccio vedere come ho usato delle stringhe per la customizzazione del programma a mio vantaggio per il PICKit 2.

Come vedete dalla seguente schermata le impostazioni interne al piklab per Pickit2 non vedono neppure il probe installato sulla USB ( problemi con ID e revision del SW del probe).




Selezionate la voce "programmatore->configuratore" e selezionate il pannello come segue:





Ora chiudete questo pannello e da comandi posizionate il file dati in modo che sia ricercabile dal pk2cmd. Piklab ignora il vostro path di percorso in .bashrc e qundi con questo comando risolviamo il problema.

ln -s /usr/share/pk2/PK2DeviceFile.dat /usr/local/bin/PK2DeviceFile.dat

questo link fa credere a pk2cmd che il file sia corretamente posizionato quando richiamato da pikLab.

ora provate a programmare il vostro Pic come qui sotto ottendo il success del comando.



Spero di essere stato utile alla sistemazione dell'itegrazione tra piklab e pk2cmd di microchip. La ricerca continua e spero di rendere autonomo il sistema di stringhe per allinearlo automaticamente al nome del file *.hex e al tipo di processore in conformita con il file di progetto aperto e i vari setup impostati.

Thursday, December 03, 2009

pk2cmd PicKit2 microchip con linux

Dopo aver comperato il pickit2 ho verificato con mano che non sempre un probe di programmazione propietario sono supportati nativamente nell'ambiente Linux, tool come piklab eccezionali per semplicita' ed immediatezza sono penalizzati per funzionalita' quando interagiscono con prodotti proprietari, spingendo gli utenti all'autocostruzioni di programmatori seriali e paralleli.

Ho trovato conveniente non investire tempo per autocostruire un programmatore e ho acquistato un PICkit 2 di microchip per 35,00 euro, convinto che comunque sarebbe stato facile implementarlo nel ciclo di programmazione e sviluppo prodotto.

Naturalmente i driver ed il CD sono rigorosamante per Windows dell'uso con linux nessuna indicazione. Con un po' di ricerche sono arrivato al programma opensource da compilare per MAC osx e Linux distribuito dalla MicroChip.

Procedete scaricando questo file pk2cmdv1.20LinuxMacSource.tar.gz (click qui)

Scompattate nella directory che selezionate o direttamente sulla Scrivania (Desktop) il file qui sopra.

Aprite un terminale seguendo il menu alto a sinistra Applicazioni-->Accessory-->Terminale

Andate nella cartella dei sorgenti per compilare,

$ cd Scrivania/pk2cmdv1.20LinuxMacSource/
$ sudo su
# make linux

Se non compila probabilmente dovete installare il tool base per compilare da sorgenti.

# apt-get install build-essential

Poi ripetete il comando di make linux che crea il comando pk2cmd.
Completate l'installazione come prescritto nel file
ReadmeForPK2CMDLinux2-6.txt

Con
nano editate il file /home/vostronomeutente/.bashrc ed in fondo al file aggiungete queste due righe.

...
PATH=$PATH:/usr/share/pk2
export PATH

Salvate ed uscite completate l'installazione con il comando che installa il nuovo comando nella apposita cartella dei programmi di linux.

#make install

Ora siamo pronti per usare il nostro PICKit2

Aprite un nuovo terminale
( cosi il sistema carica la definizione inserita in .bashrc), chiudete quello usato per compilare il package ora potete anche rimuovere la cartella dalla vostra scrivania mettendola nel cestino.

Inserite nella interfaccia USB il vostro PICKit2 e verificate se e' in linea con il comando
lsusb

$ lsusb
...
Bus 007 Device 002: ID 04d8:0033 Microchip Technology, Inc.
...

Poi digitare per verificare se funziona la connessione del dispositivo vi a USB.

$ pk2cmd ?V

Executable Version: 1.20.00
Device File Version: 1.55.00
OS Firmware Version: 2.32.00

Se avete il chip PIC 16F690 inserito nello zoccolo del vostro demokit:

# pk2cmd -PPIC16F690 -I
Device ID = 1400
Revision = 0006
Device Name = PIC16F690

Come si puo' vedere il dispositivo funziona correttamente ed identifica il chip installato correttamente.

Passiamo ora alla gestione utile all'impiego del dispositivo con le nostre applicazioni.

Leggiamo il chip e mettiamo i dati in un file

$ pk2cmd -PPIC16F690 -GF test.hex

-GF legge tuttoil contenuto RAM/EEPROM e zone di configurazione

Cancelliamo il chip:

$ pk2cmd -PPIC16F690 -E

Verifichiamo che il chip sia cancellato

$ pk2cmd -PPIC16F690 -C

Scriviamo il nostro programma nel chip

$ pk2cmd -PPIC16F690 -F test.hex -M

Verifichiamo che il chip sia programmato

$ pk2cmd -PPIC16F690 -F test.hex -Y

Ora attraverso il probe siamo pronti ad alimentare la nostra applicazione ( sempre che sia compatibile con il livello di tensione e assorbimento, se no staccate il probe evitando di danneggialo)

$ pk2cmd -PPIC16F690 -T

Ora potete spegnete l'alimentazione attraverso il probe.

$ pk2cmd -PPIC16F690 -W

Bene ora abbiamo un probe di programmazione perfettamente funzionante e pronto per l'impiego. Visto il costo della probe e visto che e' semplice implementare il comando nel vostro sistema linux diciamo che il compromesso e' accettabile senza dover costruire un probe che rispetto a questo potrebbe essere limitato dal numero di dispositivi compatibili alla programmazione di MicroChip. Provate digitando questo comando e leggete quanti sono i device che programma il probe.


$ pk2cmd -?P

Sto vedendo se e' possibile una integrazione di questo command attraverso il sistema di piklab in maniera da non dover impiegare i comandi ed eseguire tutto attraverso l'interfaccia grafica di piklab.


Buon Lavoro.

Thursday, March 12, 2009

Ubuntu Festival il computer che parla

Dopo avere provato il nuovo Apple Shuffle ho pensato che il sistema Ubuntu aveva bisogno di una Voce simile per pilotare alcune applicazioni lisp sulla quale sto lavorando.

Ecco i passi per installare Festival e farlo funzionare in italiano:

  • Installa il pacchetto tramite apt-get:
apt-get install festival

apt-get install festlex-ifd festvox-italp16k

Cosi avrete una voce femminile simpatica
  • Viene installato nella cartella /usr/share/festival )
  • Crea nella cartella home personale il file .festivalvarsrc con il seguente contenuto:

    (set! main-path "/usr/share/festival")
    (set! load-path (cons main-path load-path))
  • Inserisci il seguente testo nel file .festivalrc (nella cartella home personale):

    (set! main-path "/usr/share/festival")
    (set! libdir main-path)
    (set! lexdir (path-append libdir "dicts"))
    (set! voice_default 'voice_lp_diphone)

A questo punto si può provare il funzionamento:

  • Avvia festival:

    festival
  • Facciamogli dire qualcosa:

    (SayText "Ciao sono il tuo computer Viki")
  • Oppure da linea comandi per i vostri script in shell mode

    $ festival -b italiandef.scm '(SayText "Ciao sono il tuo computer Viki")'

Potete scaricare altre matrici vocali oltre all'italiano ( inglese, americano, francese, tedesco,ecc....)
Sentite una "calda" (!) voce femminile che si presenta? Ora il vostro Linux Ubuntu parla in italiano ;)

Wednesday, January 14, 2009

Virtual Lisp Machine on Linux

Emulator on 64Bit kernel Linux of Aplha Core

Contents

[hide]

Running VLM on Linux

This file gives some additional hints on running the Symbolics Virtual Lisp Machine (VLM) port to Linux/x86_64 by Brad Parker. I am running the VLM on a Ubuntu 6.06.1 host, so whatever I describe here may not work with other distributions. My background is FreeBSD, so some things I describe may be obvious to those with a Linux background. The configuration I describe in this file does not try to provide "security", so by following it, you will potentially expose all files on your Linux host as well as all passwords you may enter into this configuration to the Internet, and beyond.

What is the VLM?

The VLM is a development by Symbolics that, in a way, represents the last Lisp machine built before Symbolics went bankrupt. It was originally written for the DEC Alpha processor, which was the first 64 Bit CPU that was commercially available. A software implementation of the Lisp machine required a 64 Bit CPU to attain acceptable performance. The VLM implements the full Lisp machine architecture, so it is largely software compatible to the "real" Symbolics Lisp machines (36xx, Ivory).

Brad Parker wrote an implementation of the VLM for Linux. It is based on the Symbolics software, and there is some uncertainty about its legal status as well as the legal status of the rest of Symbolics intellectual property. This seems to mean that redistribution of the software or using it in a commercial context is not possible at the moment.

The VLM program is an emulator, it implements the environment for the Lisp machine operating system, Genera, that looks like real hardware from the Lisp side. It supports a virtual ethernet interface and a console. The screen is implemented using the X Window System, so you need to have X11 running on your host.

Presently, the ethernet interface is hardwired to use the address 10.0.0.1 for the Linux host and 10.0.0.2 for the VLM. This cannot be changed. See the section on "Networking the VLM" in this file for some information on how to work with this.

Using the snap4 Port

First of all, you need to get the VLM for Linux tar ball from http://www.unlambda.com/download/genera/snap4.tar.gz - There may be a newer version, so please check out the base directory and read this file with extra care if you are using a newer version. Unpack the snap4 distribution on your Ubuntu host system. Make sure that you have read the README file in the distribution, at least briefly. This file supplies additional information you'll need.

You also want the OpenGenera 2.0 distribution tarball which includes the system sources as well as additional software packages and example files. There is no official distribution site for this tar ball, so you will have to ask around for this. If you have it, unpack it in a directory that you wish to be accessed by the VLM, for example /vlm.

My starting point is a plain Ubuntu installation from the 6.06.1 boot CD without any special options. A few packages need to be added in order to make the Linux host system provide the neccessary service to the VLM. Some of these services are found in auxilary package source which need to be enabled in /etc/apt/sources.list (I uncommented all commented-out package sources).

$ sudo apt-get update

needs to be run after the sources have been enabled in order to refresh the local cache of package names.

The following packages are required in addition to the base system:

$ sudo apt-get install inetd nfs-common nfs-user-server

If "inetd" doesn't work for you, try "netkit-inetd". If "nfs-user-server" doesn't work for you, you probably didn't uncomment the package sources in /etc/apt/sources.list as described above.

inetd

The Internet superserver is used to provide the VLM with the system date and time during startup. After installation, the following entries in /etc/inetd.conf need to be added or uncommented:

$ cat /etc/inetd.conf
daytime stream tcp nowait root internal
daytime dgram udp wait root internal
time stream tcp nowait root internal
time dgram udp wait root internal

After the file has been updated, restart inetd with

$ sudo /etc/init.d/inetd restart

nfs-user-server

The NFS file server is used to give the VLM access to a file system. In theory, the kernel mode NFS server should give better performance, but I had difficulties getting it to run. After installation, /etc/exports needs to be updated in order to export the host's file system to the VLM by adding a line like:

$ cat /etc/exports
/ 10.0.0.2(rw,no_root_squash)

Depending on NFS server flavour, you may want to add also the following options after the no_root_squash option to squelch some warnings

sync,subtree_check

After this has been done, restart the NFS server using

$ sudo /etc/init.d/nfs-user-server restart

Now verify that your file system is properly exported:

$ showmount -e localhost

Note that the VLM now has full access to the hosts' file system and can overwrite or delete any file. You may restrict access by exporting only part file system, but I have not tried this. Also note that this example exports the file system to 10.0.0.2, which is the compiled-in address of the VLM. Other systems in the network have no access to the hosts' file system.

If you access files from the VLM through NFS using "anonymous" access, the uid 4294967294 and gid 4294967294 will be used. These ids are presumably meant to mean "nobody". Add entries to /etc/passwd and /etc/group for this uid and gid in order to have something better than the numeric uid be displayed when listing files on the host system.

$ grep lispm /etc/passwd /etc/group
/etc/passwd:lispm:x:4294967294:4294967294::/tmp:/bin/false
/etc/group:lispm:x:4294967294:

You now have a basic setup that will allow you to start Genera. Skip to "Starting Genera and defining your site" if you are impatient.

File Server authentication using the NIS

If you want to set up log ins from the VLM to the NFS server on the host system, the VLM needs to get access to the mapping from user ids and group ids to user names and vice versa. When Genera was written, the NIS protocol was commonly used to provide this service within local networks. NIS basically exports the authentication files in the traditional unix format to a local area network.

To run NIS, you need the nis package:

$ sudo apt-get install nis

You need to decide what your NIS domain name will be. This domain name does not need to correspond to your DNS domain name. My NIS domain name is the same as my Genera site name ("pharmacy"), but anything else could be used instead. The NIS domain name must be put into the file /etc/defaultdomain:

$ cat /etc/defaultdomain
pharmacy

You need to set up your system as NIS master in the file /etc/default/nis:

$ grep NISSERVER /etc/default/nis
NISSERVER=master

Your password file needs to use "unix crypt" style passwords instead of the now-common md5 passwords. On Ubuntu with the default installation I use, this is configured in the file /etc/pam.d/common-password by commenting out the string "md5":

$ grep md5 /etc/pam.d/common-password
password required pam_unix.so nullok obscure min=4 max=8 # md5

Note that you will now have to re-set all passwords using the "passwd" command so that they appear in the correct format.

The VLM does not support shadow passwords, so you need to convert your password database:

$ sudo pwunconv
$ sudo grpunconv

Once all this is done, you have to initialize your NIS database:

$ cd /var/yp
$ sudo make

This should leave you with a NIS server that can be used for authentication from the Lisp machine.

Starting Genera and defining your site

Once you have set up a suitable host environment, you need to configure the .VLM file in the snap4/ directory. (Note: Make sure you are using the .VLM file and not the dot.VLM file!) As distributed, it contains two wrong lines:

genera.world: ../symbolics/MIT.vlod
genera.debugger: ../symbolics/VLM_debugger

These should read

genera.world: MIT.vlod
genera.debugger: VLM_debugger

Fix the two lines and save the file. Now you are ready to start the VLM by changing your working directory to the snap4/ directory and type:

$ sudo ./genera

The VLM should start and present you with a welcome screen that asks you to log in. You will then have to define your site, please see the quickstart.text file in the OpenGenera distribution directory for information how to do that.

Once you have defined your site, save your world:

Command: Reset Network
Command: Save World :/tmp/my-genera.vlod

Replace by the name of your Linux host, as defined in the Define Site process. The path you specify needs to be writable from the VLM through NFS. If it is not writeable, the VLM will crash and you'll loose the site definition.

Networking the VLM

As mentioned, the VLM has a fixed network configuration with a private IP address. In order to be able to access hosts in the Internet, your Linux host needs to do network address translation. I used the "firestarter" utility to get a basic configuration running, but this has the drawback that the firewall has to be manually started after the VLM had come up. firestarter creates interface-dependent firewall rules and the tun0 interface, which is used by the VLM, exists only while the VLM runs. I am sure that a better setup can be created by someone who knows more about Linux firewalls, and the best way would be to use a bridge interface in the VLM so that the Linux network stack would be fully circumvented. Maybe in the next release.

Getting a Meta Key

Try

$ xmodmap -e "keysym Alt_L = Meta_L Alt_L"
$ xmodmap -e "add mod1 = Meta_L"

if your left Alt key does not act as a Meta key.

Ps. Setup Your Clock harware to time before 31/12/2000 ( this Image of system have bug of Millenium not set )

(thanks to ecraven)

torrent for test image