• Like
TuxIsAlive
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Published

TuxIsAlive was a workshop presented at AcmeSystems that introduce the use of OpenWrt on Acme devices.

TuxIsAlive was a workshop presented at AcmeSystems that introduce the use of OpenWrt on Acme devices.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
130
On SlideShare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
0
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. OpenWrt from scratch Installare OpenWrt Espandere OpenWrt Ricompilare OpenWrt da zero Applicazioni con OpenWrtAutore: Claudio Mignanti c.mignanti<at>gmail.com
  • 2. Perche OpenWrt● Sistema integrato di sviluppo● Distribuzione pensata per dispositiviembedded (nasce per i router)● Boot in meno di 10 secondi● Utilizzo ottimizzato elle risorse● uClibc/glibc/eglibc
  • 3. Partizionare la SDCard ● Aprire Gparted; Sistema → Amministrazione → Gparted ● Selezionare la periferica; ● Aggiungere le due partizioni. La prima FAT32 (anche con pochi MB) la seconda EXT2 3
  • 4. Copiare il filesystemAttualmente:wget http://downloads.openwrt.org/snapshots/trunk/at91/openwrt-at91-uImagewget http://downloads.openwrt.org/snapshots/trunk/at91/openwrt-at91-rootfs.tar.gzmv openwrt-at91-uImage /media/<fat32>/sudo tar xvzf openwrt-at91-rootfs.tar.gz -C /media/<ext2>umount /media/<fat32>umount /media/<ext2>In futuro probabilmente:wget http://downloads.openwrt.org/snapshots/trunk/at91/openwrt-at91-rootfs.tar.gzsudo tar xvzf openwrt-at91-rootfs.tar.gz -C /media/<ext2>umount /media/<ext2> 4
  • 5. Incontro ravvicinato$ sudo ifconfig eth0 192.168.1.2 && telnet 192.168.1.1BusyBox v1.16.2 (2010­07­15 14:32:26 CEST) built­in shell (ash)Enter help for a list of built­in commands.  _______                     ________        __ |       |.­­­­­.­­­­­.­­­­­.|  |  |  |.­­­­.|  |_ |   ­   ||  _  |  ­__|     ||  |  |  ||   _||   _| |_______||   __|_____|__|__||________||__|  |____|          |__| W I R E L E S S   F R E E D O M KAMIKAZE (bleeding edge, r22176) ­­­­­­­­­­­­­­­­­­  * 10 oz Vodka       Shake well with ice and strain  * 10 oz Triple sec  mixture into 10 shot glasses.  * 10 oz lime juice  Salute! ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­root@OpenWrt:~#  5 Il numero di revisione (r22176 nellesempio) è molto utile per debug!
  • 6. Opkgopkg update – aggiorna i pacchetti dai repository definiti in /etc/opkg.confopkg list – visualizza la lista dei pacchetti installabiliopkg install <nome|link|file> opkg install pyserial ← Installa dal feed opkg install ftp://myurl.it/pkg/python-mini_2.6.4-3_at91.ipk. opkg install /tmp/zlib_1.2.3-5_at91.ipk ← installa file localeopkg flag hold <nome> - blocca la versione corrente del pacchetto <nome>opkg upgrade – usate a vostro rischio !!! 6
  • 7. root@OpenWrt:~# opkg update OpkgDownloading http://downloads.openwrt.org/snapshots/trunk/at91/packages/Packages.gz.Inflating http://downloads.openwrt.org/snapshots/trunk/at91/packages/Packages.gz.Updated list of available packages in /var/opkg­lists/snapshots.root@OpenWrt:~# opkg install python Installing python (2.6.4­3) to root...Downloading http://downloads.openwrt.org/snapshots/trunk/at91/packages/python_2.6.4­3_at91.ipk.Installing libpthread (0.9.30.1­50) to root...Downloading http://downloads.openwrt.org/snapshots/trunk/at91/packages/libpthread_0.9.30.1­50_at91.ipk.Installing librt (0.9.30.1­50) to root...Downloading http://downloads.openwrt.org/snapshots/trunk/at91/packages/librt_0.9.30.1­50_at91.ipk.Installing zlib (1.2.3­5) to root...Downloading http://downloads.openwrt.org/snapshots/trunk/at91/packages/zlib_1.2.3­5_at91.ipk.Installing libffi (3.0.9­1) to root...Downloading http://downloads.openwrt.org/snapshots/trunk/at91/packages/libffi_3.0.9­1_at91.ipk.Installing python­mini (2.6.4­3) to root...Downloading http://downloads.openwrt.org/snapshots/trunk/at91/packages/python­mini_2.6.4­3_at91.ipk.Configuring librt.Configuring libpthread.Configuring zlib.Configuring libffi.Configuring python­mini. 7Configuring python.root@OpenWrt:~# 
  • 8. Ricominciamo da zero...Sviluppare con OpenWrt 8
  • 9. Scaricare lSDKOpenWrt è una distribuzione linux unica nel suo genere.LSDK è un ambiente di sviluppo nel quale TUTTI icomponenti necessari confluiscono per crearelambiente finale.● Host tools● toolchain● kernel linux● rootfs 9
  • 10. SDK Introsvn co svn://svn.openwrt.org/openwrt/trunk openwrt scarica lsdkmake menuconfig configura lsdkmake kernel_menuconfig configura il kernel per larchitettura selezionatasvn up----------------------------------------------------------------------------------- Espandere lSDKAggiungi/modifica feed in feeds.conf./scripts/feeds install -a./scripts/feeds update -a 10
  • 11. Compilaremake compila lintero firmwaremake clean ripulisci lsdk (host tools, toolchain, e configurazioni escluse)make target/linux/{compile|clean} compila/ripulisci il kernelmake <path>/<nome_pkg>/{compile|clean} compila/ripulisci il pacchetto <nome_pkg> 11
  • 12. Compilare 2Il processo di compilazione dentro openwrt passa per iseguenti stadi:Prepare (del codice sorgente)1. Download del sorgente dal web (http, ftp, svn, git, hg)2. Si copia il contenuto della directory files allinterno della directory di compilazione (solo per il kernel)Patch Si applicano le patch al sorgenteCompile (no comment)Install (del pacchetto) Si realizza il pacchetto ipkg 12
  • 13. Compilare 3Esempi:https://dev.openwrt.org/browser/packages/admin/sudo Download sorgenti dal web, configurazione, installhttps://dev.openwrt.org/browser/trunk/package/opkg/Makefile Download sorgenti dal web, configurazione, install e installdevhttp://sourceforge.net/apps/trac/acme-dev/browser/packages/zz-acmeconf Meta-pacchetto, notare le dipendenzehttp://sourceforge.net/apps/trac/acme-dev/browser/packages/at91-adc/Makefile Kernel module 13
  • 14. KernelIl punto forte di OpenWrt è senza dubbio la gestione del kernel. https://dev.openwrt.org/browser/trunk/target/linux 14
  • 15. Modificare il kernelmake target/linux/cleanmodificare target/linux/generic/{patches|files}o target/linux/at91/{patches|files}make target/linux/installEsempio: https://dev.openwrt.org/changeset/21800 15
  • 16. GPIO usando SYSFSecho 82 > /sys/class/gpio/exportecho out > /sys/class/gpio/gpio82/directionecho 1 > /sys/class/gpio/gpio82/valuesleep 1echo 0 > /sys/class/gpio/gpio82/value 16
  • 17. GPIO usando il C #include <stdio.h> #include <gpio_dev.h> int main (void) { fd = open (“/dev/gpio”); ioctl (fd, GPIO_REQUEST, 82); ioctl (fd, GPIO_DIR_OUT); ioctl (fd, GPIO_SET, 1); sleep(1); ioctl (fd, GPIO_SET, 0); } 17trunk/target/linux/generic/files/include/linux/gpi_dev.h
  • 18. GPIO e stepper motor PYTHON CLASS USER SPACE STEPPER PROGRAM /DEV/GPIO SYSFS /DEV/MOTORn STEPPER DRIVER GPIO API PWM CPU 18http://sourceforge.net/apps/trac/acme-dev/browser/kernel-stuff/stepper-driver/stepper-drv.c
  • 19. Seguite lo sviluppo suhttp://sourceforge.net/apps/trac/acme-dev/timelin https://dev.openwrt.org/search?q=claudio 19
  • 20. EOF ? Claudio Mignanti c.mignanti<at>gmail.com - OpenWrt Developer - Hardware designer - 20pub 1024D/0DFD7CBB C94D 759A 2EF0 172F 9673 65E4 C4C1 8627 0DFD 7CBB