|
|
Строка 319: |
Строка 319: |
| zynq_gpio e000a000.ps7-gpio: gpio at 0xe000a000 mapped to 0xd0850000 | | zynq_gpio e000a000.ps7-gpio: gpio at 0xe000a000 mapped to 0xd0850000 |
| </source> | | </source> |
| + | |
| + | == Hello world == |
| + | |
| + | На моей linux-машине предварительно установлен ISE 14.7, причем в Embedded-конфигурации. Традиционно в терминале определяем переменные: |
| + | <source lang="bash"> |
| + | source /opt/Xilinx/14.7/ISE_DS/settings64.sh |
| + | </source> |
| + | |
| + | Теперь bash знает, где искать кросскомпиляторы arm-xilinx-linux-gnueabi-gcc и arm-xilinx-linux-gnueabi-g++. Начнем с программы на Си, создаем файл <code>hello.c</code>: |
| + | <source lang="C"> |
| + | #include <stdio.h> |
| + | |
| + | int main(void) |
| + | { |
| + | printf("Hello, world\n"); |
| + | return 0; |
| + | } |
| + | </source> |
| + | |
| + | Компилируем |
| + | <source lang="bash"> |
| + | arm-xilinx-linux-gnueabi-gcc hello.c -o hello |
| + | </source> |
| + | |
| + | Копируем на девайс |
| + | <source lang="bash"> |
| + | scp ./hello root@192.168.0.156:/root/ |
| + | </source> |
| + | |
| + | Запускаем |
| + | <source lang="bash"> |
| + | root@plda:~# ./hello |
| + | Hello, world |
| + | </source> |
| + | |
| | | |
| [[Категория:HOWTO]] | | [[Категория:HOWTO]] |
| [[Категория:Impala]] | | [[Категория:Impala]] |
| {{wl-publish: 2014-08-14 19:35:28 +0400 | Korogodin }} | | {{wl-publish: 2014-08-14 19:35:28 +0400 | Korogodin }} |
Версия 11:28, 15 августа 2014
Пора пощупать новую игрушку
Вводные
В комплекте идет блок питания на 12 В. Питание возможно как от него, так и от USB OTG.
Стартер-кит поставляется с микро-SD флеш-картой, содержащей два раздела - boot и debian rootfs. Попробуем поработать с этим bsp. На плате bootsel есть переключатель источника загрузки - SD или QSPI. Выбираем SD.
В качестве интерфейса с внешним миром имеем Ethernet, достучаться до которого с ходу не получилось, и RS-USB в виде разъема USB B-type. При подключении USB к PC udev добавляет /dev/ttyUSB0
, через который с помощью ckermit мы можем получить терминал. Для этого воспользуемся традиционным скриптом:
#!/usr/bin/kermit
set line /dev/ttyUSB0
set FLOW none
set speed 115200
set serial 8n1
SET CARRIER-WATCH Off
connect
Не забываем chmod +x
.
После запуска скрипта имеем приветственное окно Debian с запросом логина и пароля:
WARNING: Last line of command file lacks terminator
Connecting to /dev/ttyUSB0, speed 115200
Escape character: Ctrl-\ (ASCII 28, FS): enabled
Type the escape character followed by C to get back,
or followed by ? to see other options.
----------------------------------------------------
Debian GNU/Linux 7 plda ttyPS0
plda login: root
Password:
Методом перебора найдена нужная комбинация: логин root, пароль plda:
Last login: Thu Jan 1 00:00:12 UTC 1970 on ttyPS0
Linux plda 3.12.0-somz-dirty #7 SMP PREEMPT Tue Mar 11 10:46:29 EET 2014 armv7l
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
root@plda:~# ls -la
total 24
drwx------ 3 root root 4096 Jan 1 00:01 .
drwxrwxr-x 23 1000 1000 4096 Jan 1 00:03 ..
-rw------- 1 root root 340 Jan 1 1970 .bash_history
-rw-r--r-- 1 root root 570 Mar 11 2014 .bashrc
drwx------ 3 root root 4096 Jan 1 00:01 .config
-rw-r--r-- 1 root root 140 Mar 11 2014 .profile
root@plda:~# ifconfig
eth0 Link encap:Ethernet HWaddr d0:d1:d2:d3:d4:d5
inet addr:172.20.2.162 Bcast:172.20.255.255 Mask:255.255.0.0
inet6 addr: fe80::d2d1:d2ff:fed3:d4d5/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:84 errors:0 dropped:1 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:6947 (6.7 KiB) TX bytes:648 (648.0 B)
Interrupt:54 Base address:0xb000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Прокинуть ssh до 172.20.2.162 не удается, пинг не идет, nmap утверждает, что все порты закрыты.
Установка static IP
Добавляем в /etc/network/interfaces
:
auto eth0
iface eth0 inet static
address 192.168.0.156
netmask 255.255.255.0
gateway 192.168.0.1
Даем команду на рестарт сетевых интерфейсов:
/etc/init.d/networking restart
...и теперь у девайса IP из нашей подсети:
root@plda:/etc/network# ifconfig
eth0 Link encap:Ethernet HWaddr d0:d1:d2:d3:d4:d5
inet addr:192.168.0.156 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::d2d1:d2ff:fed3:d4d5/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:100 errors:0 dropped:1 overruns:0 frame:0
TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:8951 (8.7 KiB) TX bytes:1296 (1.2 KiB)
Interrupt:54 Base address:0xb000
SSH
Девайс пингуется:
ofei@Diod:/dev/serial/by-id$ ping 192.168.0.156
PING 192.168.0.156 (192.168.0.156) 56(84) bytes of data.
64 bytes from 192.168.0.156: icmp_seq=1 ttl=64 time=2.41 ms
64 bytes from 192.168.0.156: icmp_seq=2 ttl=64 time=1.17 ms
64 bytes from 192.168.0.156: icmp_seq=3 ttl=64 time=1.84 ms
...и у него открыт только 22 порт, т.е. SSH:
ofei@Diod:~$ sudo nmap -sS -P0 -sV -O 192.168.0.156
Starting Nmap 6.40 ( http://nmap.org ) at 2014-08-15 10:39 MSK
Nmap scan report for 192.168.0.156
Host is up (0.0012s latency).
Not shown: 999 closed ports
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 6.0p1 Debian 4 (protocol 2.0)
MAC Address: D0:D1:D2:D3:D4:D5 (Unknown)
Удается зайти на устройство по SSH, жизнь налаживается:
ofei@Diod:~$ ssh root@192.168.0.156
Linux plda 3.12.0-somz-dirty #7 SMP PREEMPT Tue Mar 11 10:46:29 EET 2014 armv7l
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Thu Jan 1 00:29:16 1970
root@plda:~# uname -r
3.12.0-somz-dirty
Лог загрузки
После перезагрузки девайса настройки остаются в силе. От момента включения до ответа на пинг проходит около 10 секунд.
Лог загрузки (справка кнопка "показать" разворачивает спойлер):
root@plda:~# dmesg
Booting Linux on physical CPU 0x0
Linux version 3.12.0-somz-dirty (software@software-PC1) (gcc version 4.6.1 (Sourcery CodeBench Lite 2011.09-50) ) #7 SMP PREEMPT Tue Mar 11 10:46:29 EET 2014
CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=18c5387d
CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
Machine: Xilinx Zynq Platform, model: Xilinx Zynq
bootconsole [earlycon0] enabled
Memory policy: Data cache writealloc
On node 0 totalpages: 65536
free_area_init_node: node 0, pgdat c05e6ac0, node_mem_map c061d000
Normal zone: 512 pages used for memmap
Normal zone: 0 pages reserved
Normal zone: 65536 pages, LIFO batch:15
PERCPU: Embedded 8 pages/cpu @c0823000 s8320 r8192 d16256 u32768
pcpu-alloc: s8320 r8192 d16256 u32768 alloc=8*4096
pcpu-alloc: [0] 0 [0] 1
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 65024
Kernel command line: console=ttyPS0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 rw mem=256M ip=172.20.2.162:somz:eth0 earlyprintk
PID hash table entries: 1024 (order: 0, 4096 bytes)
Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)
Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
Memory: 253504K/262144K available (4199K kernel code, 250K rwdata, 1408K rodata, 172K init, 184K bss, 8640K reserved, 0K highmem)
Virtual kernel memory layout:
vector : 0xffff0000 - 0xffff1000 ( 4 kB)
fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB)
vmalloc : 0xd0800000 - 0xff000000 ( 744 MB)
lowmem : 0xc0000000 - 0xd0000000 ( 256 MB)
pkmap : 0xbfe00000 - 0xc0000000 ( 2 MB)
modules : 0xbf000000 - 0xbfe00000 ( 14 MB)
.text : 0xc0008000 - 0xc0582118 (5609 kB)
.init : 0xc0583000 - 0xc05ae080 ( 173 kB)
.data : 0xc05b0000 - 0xc05eeb78 ( 251 kB)
.bss : 0xc05eeb84 - 0xc061cba8 ( 185 kB)
Preemptible hierarchical RCU implementation.
Dump stacks of tasks blocking RCU-preempt GP.
RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=2.
NR_IRQS:16 nr_irqs:16 16
ps7-slcr mapped to d0802000
Zynq clock init
sched_clock: 16 bits at 54kHz, resolution 18432ns, wraps every 1207ms
ps7-ttc #0 at d0804000, irq=43
Console: colour dummy device 80x30
Calibrating delay loop... 1325.46 BogoMIPS (lpj=6627328)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
Setting up static identity map for 0xc03f8c88 - 0xc03f8cbc
L310 cache controller enabled
l2x0: 8 ways, CACHE_ID 0x410000c8, AUX_CTRL 0x72360000, Cache size: 512 kB
CPU1: Booted secondary processor
CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
Brought up 2 CPUs
SMP: Total of 2 processors activated.
CPU: All CPU(s) started in SVC mode.
devtmpfs: initialized
VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4
NET: Registered protocol family 16
DMA: preallocated 256 KiB pool for atomic coherent allocations
zynq_gpio e000a000.ps7-gpio: gpio at 0xe000a000 mapped to 0xd0850000
hw-breakpoint: found 5 (+1 reserved) breakpoint and 1 watchpoint registers.
hw-breakpoint: maximum watchpoint size is 4 bytes.
zynq_ocm f800c000.ps7-ocmc: ZYNQ OCM pool: 256 KiB @ 0xd0880000
bio: create slab <bio-0> at 0
vgaarb: loaded
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
media: Linux media interface: v0.10
Linux video capture interface: v2.00
pps_core: LinuxPPS API ver. 1 registered
pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
PTP clock support registered
EDAC MC: Ver: 3.0.0
Switched to clocksource ttc_clocksource
NET: Registered protocol family 2
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP: reno registered
UDP hash table entries: 256 (order: 1, 8192 bytes)
UDP-Lite hash table entries: 256 (order: 1, 8192 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
PCI: CLS 0 bytes, default 64
hw perfevents: enabled with ARMv7 Cortex-A9 PMU driver, 7 counters available
jffs2: version 2.2. (NAND) (SUMMARY) \xffffffc2\xffffffa9 2001-2006 Red Hat, Inc.
msgmni has been set to 495
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
dma-pl330 f8003000.ps7-dma: unable to set the seg size
dma-pl330 f8003000.ps7-dma: Loaded driver for PL330 DMAC-2364208
dma-pl330 f8003000.ps7-dma: DBUFF-128x8bytes Num_Chans-8 Num_Peri-4 Num_Events-16
e0000000.serial: ttyPS0 at MMIO 0xe0000000 (irq = 59, base_baud = 6249999) is a xuartps
console [ttyPS0] enabled, bootconsole disabled
xdevcfg f8007000.ps7-dev-cfg: ioremap 0xf8007000 to d0866000
brd: module loaded
loop: module loaded
xqspips e000d000.ps7-qspi: master is unqueued, this is deprecated
xqspips e000d000.ps7-qspi: at 0xE000D000 mapped to 0xD0868000, irq=51
e1000e: Intel(R) PRO/1000 Network Driver - 2.3.2-k
e1000e: Copyright(c) 1999 - 2013 Intel Corporation.
libphy: XEMACPS mii bus: probed
xemacps e000b000.ps7-ethernet: pdev->id -1, baseaddr 0xe000b000, irq 54
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
ehci-pci: EHCI PCI platform driver
ULPI transceiver vendor/product ID 0x0424/0x0006
Found SMSC USB331x ULPI transceiver.
ULPI integrity check: passed.
xusbps-ehci xusbps-ehci.0: Xilinx PS USB EHCI Host Controller
xusbps-ehci xusbps-ehci.0: new USB bus registered, assigned bus number 1
xusbps-ehci xusbps-ehci.0: irq 53, io mem 0x00000000
xusbps-ehci xusbps-ehci.0: USB 2.0 started, EHCI 1.00
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected
usbcore: registered new interface driver usb-storage
mousedev: PS/2 mouse device common for all mice
i2c /dev entries driver
usbcore: registered new interface driver uvcvideo
USB Video Class driver (1.1.1)
xadcps f8007100.ps7-xadc: enabled: yes reference: external
zynq_wdt f8005000.ps7-wdt: Xilinx Watchdog Timer at d0874000 with timeout 10s
zynq-edac f8006000.ps7-ddrc: ecc not enabled
sdhci: Secure Digital Host Controller Interface driver
sdhci: Copyright(c) Pierre Ossman
sdhci-pltfm: SDHCI platform and OF driver helper
mmc0: SDHCI controller on e0100000.ps7-sdio [e0100000.ps7-sdio] using ADMA
mmc0: new high speed SDHC card at address 0002
mmc1: SDHCI controller on e0101000.ps7-sdio [e0101000.ps7-sdio] using ADMA
mmcblk0: mmc0:0002 00000 7.32 GiB
mmcblk0: p1 p2
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
TCP: cubic registered
NET: Registered protocol family 17
Registering SWP/SWPB emulation handler
drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
xvdma xvdma.0: Xilinx VDMA probe successful
xvdma xvdma.0: Devices Scanned 0
Configuring Ethernet phy KSZ9021 for SOMZ V2.0
IP-Config: Guessing netmask 255.255.0.0
IP-Config: Gateway not on directly connected network
EXT4-fs (mmcblk0p2): recovery complete
EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
VFS: Mounted root (ext4 filesystem) on device 179:2.
devtmpfs: mounted
Freeing unused kernel memory: 172K (c0583000 - c05ae000)
udevd[627]: starting version 175
EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
EXT4-fs (mmcblk0p2): re-mounted. Opts: errors=remount-ro
xemacps e000b000.ps7-ethernet: Set clk to 124999998 Hz
xemacps e000b000.ps7-ethernet: link up (1000/FULL)
FAT-fs (mmcblk0p1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
NET: Registered protocol family 10
Из интересного - у нас 256 Мб ОЗУ, rootfs на ext4 и строчка:
zynq_gpio e000a000.ps7-gpio: gpio at 0xe000a000 mapped to 0xd0850000
Hello world
На моей linux-машине предварительно установлен ISE 14.7, причем в Embedded-конфигурации. Традиционно в терминале определяем переменные:
source /opt/Xilinx/14.7/ISE_DS/settings64.sh
Теперь bash знает, где искать кросскомпиляторы arm-xilinx-linux-gnueabi-gcc и arm-xilinx-linux-gnueabi-g++. Начнем с программы на Си, создаем файл hello.c
:
#include <stdio.h>
int main(void)
{
printf("Hello, world\n");
return 0;
}
Компилируем
arm-xilinx-linux-gnueabi-gcc hello.c -o hello
Копируем на девайс
scp ./hello root@192.168.0.156:/root/
Запускаем
root@plda:~# ./hello
Hello, world
[ Хронологический вид ]Комментарии
Войдите, чтобы комментировать.