Thank you, I will try to understand how to create an extension or how to compile the library as last step of this project.
In the meantime, everything is finally working. I managed to install Python and its libraries, the script loads at startup with no problems, and X11 forwarding is working as well (while I am waiting for the HDMI cable to arrive). Thank you all for the great support!
Now I am trying to reduce the boot time, that seems to be much longer since I installed Xorg.tcz, Xprogs.tcz, Xlibs.tcz, xorg-server.tcz. Here the results of dmesg:
[ 0.000000] Booting Linux on physical CPU 0x0
[ 0.000000] Linux version 4.9.22-piCore (root@box) (gcc version 6.3.0 (piCore) ) #1 Sat Apr 15 15:30:03 UTC 2017
[ 0.000000] CPU: ARMv6-compatible processor [410fb767] revision 7 (ARMv7), cr=00c5387d
[ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
[ 0.000000] OF: fdt:Machine model: Raspberry Pi Zero Rev 1.3
[ 0.000000] cma: Reserved 8 MiB at 0x1b000000
[ 0.000000] Memory policy: Data cache writeback
[ 0.000000] On node 0 totalpages: 114688
[ 0.000000] free_area_init_node: node 0, pgdat c0931188, node_mem_map dac10000
[ 0.000000] Normal zone: 1008 pages used for memmap
[ 0.000000] Normal zone: 0 pages reserved
[ 0.000000] Normal zone: 114688 pages, LIFO batch:31
[ 0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[ 0.000000] pcpu-alloc: [0] 0
[ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 113680
[ 0.000000] Kernel command line: bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2708_fb.fbswap=1 vc_mem.mem_base=0x1ec00000 vc_mem.mem_size=0x20000000 dwc_otg.lpm_enable=0 console=ttyAMA0,115200 root=/dev/ram0 elevator=deadline rootwait quiet nortc loglevel=3 noembed waitusb=1 printk.time=1 syslog
[ 0.000000] PID hash table entries: 2048 (order: 1, 8192 bytes)
[ 0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
[ 0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
[ 0.000000] Memory: 431364K/458752K available (6035K kernel code, 492K rwdata, 1968K rodata, 400K init, 739K bss, 19196K reserved, 8192K cma-reserved)
[ 0.000000] Virtual kernel memory layout:
[ 0.000000] vector : 0xffff0000 - 0xffff1000 ( 4 kB)
[ 0.000000] fixmap : 0xffc00000 - 0xfff00000 (3072 kB)
[ 0.000000] vmalloc : 0xdc800000 - 0xff800000 ( 560 MB)
[ 0.000000] lowmem : 0xc0000000 - 0xdc000000 ( 448 MB)
[ 0.000000] modules : 0xbf000000 - 0xc0000000 ( 16 MB)
[ 0.000000] .text : 0xc0008000 - 0xc05ecef4 (6036 kB)
[ 0.000000] .init : 0xc085c000 - 0xc08c0000 ( 400 kB)
[ 0.000000] .data : 0xc08c0000 - 0xc093b038 ( 493 kB)
[ 0.000000] .bss : 0xc093b038 - 0xc09f3e60 ( 740 kB)
[ 0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[ 0.000000] NR_IRQS:16 nr_irqs:16 16
[ 0.000028] sched_clock: 32 bits at 1000kHz, resolution 1000ns, wraps every 2147483647500ns
[ 0.000058] clocksource: timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1911260446275 ns
[ 0.000150] bcm2835: system timer (irq = 27)
[ 0.000592] Console: colour dummy device 80x30
[ 0.000623] Calibrating delay loop... 697.95 BogoMIPS (lpj=3489792)
[ 0.060289] pid_max: default: 32768 minimum: 301
[ 0.060703] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[ 0.060717] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[ 0.061775] Disabling cpuset control group subsystem
[ 0.061975] CPU: Testing write buffer coherency: ok
[ 0.062033] ftrace: allocating 21825 entries in 65 pages
[ 0.180353] Setting up static identity map for 0x8200 - 0x8238
[ 0.182348] devtmpfs: initialized
[ 0.191309] VFP support v0.3: implementor 41 architecture 1 part 20 variant b rev 5
[ 0.191734] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[ 0.191758] futex hash table entries: 256 (order: -1, 3072 bytes)
[ 0.193032] pinctrl core: initialized pinctrl subsystem
[ 0.194462] NET: Registered protocol family 16
[ 0.197058] DMA: preallocated 1024 KiB pool for atomic coherent allocations
[ 0.207014] hw-breakpoint: found 6 breakpoint and 1 watchpoint registers.
[ 0.207029] hw-breakpoint: maximum watchpoint size is 4 bytes.
[ 0.207134] Serial: AMBA PL011 UART driver
[ 0.209884] bcm2835-mbox 2000b880.mailbox: mailbox enabled
[ 0.258825] bcm2835-dma 20007000.dma: DMA legacy API manager at dc80d000, dmachans=0x1
[ 0.261585] SCSI subsystem initialized
[ 0.261851] usbcore: registered new interface driver usbfs
[ 0.262005] usbcore: registered new interface driver hub
[ 0.262201] usbcore: registered new device driver usb
[ 0.270415] raspberrypi-firmware soc:firmware: Attached to firmware from 2017-04-04 18:41
[ 0.272340] clocksource: Switched to clocksource timer
[ 0.326859] VFS: Disk quotas dquot_6.6.0
[ 0.326974] VFS: Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
[ 0.327267] FS-Cache: Loaded
[ 0.327629] CacheFiles: Loaded
[ 0.347160] NET: Registered protocol family 2
[ 0.348492] TCP established hash table entries: 4096 (order: 2, 16384 bytes)
[ 0.348579] TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
[ 0.348651] TCP: Hash tables configured (established 4096 bind 4096)
[ 0.348745] UDP hash table entries: 256 (order: 0, 4096 bytes)
[ 0.348771] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[ 0.349061] NET: Registered protocol family 1
[ 0.349796] RPC: Registered named UNIX socket transport module.
[ 0.349807] RPC: Registered udp transport module.
[ 0.349811] RPC: Registered tcp transport module.
[ 0.349816] RPC: Registered tcp NFSv4.1 backchannel transport module.
[ 0.350269] Trying to unpack rootfs image as initramfs...
[ 0.994005] Freeing initrd memory: 4464K (dbb94000 - dbff0000)
[ 1.025862] hw perfevents: enabled with armv6_1176 PMU driver, 3 counters available
[ 1.028216] workingset: timestamp_bits=14 max_order=17 bucket_order=3
[ 1.044619] zbud: loaded
[ 1.048765] FS-Cache: Netfs 'nfs' registered for caching
[ 1.050470] NFS: Registering the id_resolver key type
[ 1.050529] Key type id_resolver registered
[ 1.050535] Key type id_legacy registered
[ 1.059972] jitterentropy: Initialization failed with host not compliant with requirements: 2
[ 1.060147] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 251)
[ 1.060520] io scheduler noop registered
[ 1.060532] io scheduler deadline registered (default)
[ 1.060994] io scheduler cfq registered
[ 1.067298] BCM2708FB: allocated DMA memory 5b100000
[ 1.067359] BCM2708FB: allocated DMA channel 0 @ dc80d000
[ 1.075085] Console: switching to colour frame buffer device 82x26
[ 1.082531] bcm2835-rng 20104000.rng: hwrng registered
[ 1.082706] vc-cma: Videocore CMA driver
[ 1.082716] vc-cma: vc_cma_base = 0x00000000
[ 1.082724] vc-cma: vc_cma_size = 0x00000000 (0 MiB)
[ 1.082729] vc-cma: vc_cma_initial = 0x00000000 (0 MiB)
[ 1.083149] vc-mem: phys_addr:0x00000000 mem_base=0x1ec00000 mem_size:0x20000000(512 MiB)
[ 1.108524] brd: module loaded
[ 1.120949] loop: module loaded
[ 1.120969] Loading iSCSI transport class v2.0-870.
[ 1.121944] usbcore: registered new interface driver smsc95xx
[ 1.121972] dwc_otg: version 3.00a 10-AUG-2012 (platform bus)
[ 1.348142] Core Release: 2.80a
[ 1.348158] Setting default values for core params
[ 1.348195] Finished setting default values for core params
[ 1.548546] Using Buffer DMA mode
[ 1.548560] Periodic Transfer Interrupt Enhancement - disabled
[ 1.548565] Multiprocessor Interrupt Enhancement - disabled
[ 1.548574] OTG VER PARAM: 0, OTG VER FLAG: 0
[ 1.548662] Dedicated Tx FIFOs mode
[ 1.549318] WARN::dwc_otg_hcd_init:1053: FIQ DMA bounce buffers: virt = 0xdb114000 dma = 0x5b114000 len=9024
[ 1.549345] FIQ FSM acceleration enabled for :
[ 1.549345] Non-periodic Split Transactions
[ 1.549345] Periodic Split Transactions
[ 1.549345] High-Speed Isochronous Endpoints
[ 1.549345] Interrupt/Control Split Transaction hack enabled
[ 1.549357] dwc_otg: Microframe scheduler enabled
[ 1.549441] WARN::hcd_init_fiq:459: FIQ on core 0 at 0xc0466f8c
[ 1.549455] WARN::hcd_init_fiq:460: FIQ ASM at 0xc0467268 length 36
[ 1.549480] WARN::hcd_init_fiq:486: MPHI regs_base at 0xdc8a5000
[ 1.549551] dwc_otg 20980000.usb: DWC OTG Controller
[ 1.549615] dwc_otg 20980000.usb: new USB bus registered, assigned bus number 1
[ 1.549699] dwc_otg 20980000.usb: irq 56, io mem 0x00000000
[ 1.549753] Init: Port Power? op_state=1
[ 1.549757] Init: Power Port (0)
[ 1.550139] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[ 1.550156] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 1.550165] usb usb1: Product: DWC OTG Controller
[ 1.550175] usb usb1: Manufacturer: Linux 4.9.22-piCore dwc_otg_hcd
[ 1.550184] usb usb1: SerialNumber: 20980000.usb
[ 1.551418] hub 1-0:1.0: USB hub found
[ 1.551510] hub 1-0:1.0: 1 port detected
[ 1.552559] dwc_otg: FIQ enabled
[ 1.552569] dwc_otg: NAK holdoff enabled
[ 1.552574] dwc_otg: FIQ split-transaction FSM enabled
[ 1.552596] Module dwc_common_port init
[ 1.553101] usbcore: registered new interface driver usb-storage
[ 1.553565] mousedev: PS/2 mouse device common for all mice
[ 1.555150] bcm2835-wdt 20100000.watchdog: Broadcom BCM2835 watchdog timer
[ 1.555670] bcm2835-cpufreq: min=700000 max=1000000
[ 1.557052] sdhci: Secure Digital Host Controller Interface driver
[ 1.557059] sdhci: Copyright(c) Pierre Ossman
[ 1.557397] sdhost-bcm2835 20202000.sdhost: could not get clk, deferring probe
[ 1.557618] sdhci-pltfm: SDHCI platform and OF driver helper
[ 1.558132] ledtrig-cpu: registered to indicate activity on CPUs
[ 1.558281] hidraw: raw HID events driver (C) Jiri Kosina
[ 1.558482] usbcore: registered new interface driver usbhid
[ 1.558487] usbhid: USB HID core driver
[ 1.559405] vchiq: vchiq_init_state: slot_zero = 0xdb180000, is_master = 0
[ 1.561503] Initializing XFRM netlink socket
[ 1.561545] NET: Registered protocol family 17
[ 1.561681] Key type dns_resolver registered
[ 1.563549] registered taskstats version 1
[ 1.563698] zswap: loaded using pool lzo/zbud
[ 1.648506] Key type encrypted registered
[ 1.648790] vc-sm: Videocore shared memory driver
[ 1.648801] [vc_sm_connected_init]: start
[ 1.649712] [vc_sm_connected_init]: end - returning 0
[ 1.654797] 20201000.serial: ttyAMA0 at MMIO 0x20201000 (irq = 81, base_baud = 0) is a PL011 rev2
[ 1.654875] console [ttyAMA0] enabled
[ 1.656631] sdhost: log_buf @ db113000 (5b113000)
[ 1.732384] mmc0: sdhost-bcm2835 loaded - DMA enabled (>1)
[ 1.752589] of_cfs_init
[ 1.752693] of_cfs_init: OK
[ 1.753164] uart-pl011 20201000.serial: no DMA platform data
[ 1.754230] Freeing unused kernel memory: 400K (c085c000 - c08c0000)
[ 1.754235] This architecture does not have kernel memory protection.
[ 1.790208] Indeed it is in host mode hprt0 = 00021501
[ 1.853088] random: fast init done
[ 1.973978] mmc0: host does not support reading read-only switch, assuming write-enable
[ 1.976681] mmc0: new high speed SDHC card at address aaaa
[ 1.982748] mmcblk0: mmc0:aaaa SL16G 14.8 GiB
[ 1.985746] mmcblk0: p1 p2
[ 2.082460] usb 1-1: new full-speed USB device number 2 using dwc_otg
[ 2.082702] Indeed it is in host mode hprt0 = 00021501
[ 2.394538] usb 1-1: New USB device found, idVendor=0fe6, idProduct=9700
[ 2.394554] usb 1-1: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[ 2.394561] usb 1-1: Product: USB 2.0 10/100M Ethernet Adaptor
[ 3.559613] gpiomem-bcm2835 20200000.gpiomem: Initialised: Registers at 0x20200000
[ 4.098168] zram: Added device: zram0
[ 4.145310] zram0: detected capacity change from 0 to 106336256
[ 4.167847] Adding 103840k swap on /dev/zram0. Priority:-1 extents:1 across:103840k SSFS
[ 4.472794] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[ 5.540568] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[ 5.656487] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[ 20.406856] random: crng init done
[ 51.337636] i2c /dev entries driver
[ 53.442653] sr9700 1-1:1.0 (unnamed net_device) (uninitialized): Error reading MAC address
[ 53.442896] usbcore: registered new interface driver sr9700
[ 53.463731] dm9601 1-1:1.0 eth0: register 'dm9601' at usb-20980000.usb-1, Davicom DM96xx USB 10/100 Ethernet, 00:e0:4c:53:44:58
[ 53.466023] usbcore: registered new interface driver dm9601
[ 53.609404] dm9601 1-1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0xFFFF
[ 53.695936] dm9601 1-1:1.0 eth0: kevent 4 may have been dropped
[ 53.725864] dm9601 1-1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0xFFFF
[ 53.820238] dm9601 1-1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0xFFFF
I still have to remove the command waitusb=1 from cmdline.txt. However I can't understand the log very well. Up to 5.656487 seconds everything seems ok, probably I can reduce the boot time furthermore only by compiling the python libraries (right now I am restoring a backup). After that, I don't know what is happening till 20.406856 seconds and afterwards.
Just to note, in the final configuration the Pi0 will not be connected to the ethernet cable. Can I disable somehow the ethernet connection?