./facedetect --cascade="/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml" lena.jpg
実行結果を下に示す。./facedetect --cascade="/usr/local/share/OpenCV/haarcascades/haarcascade_eye.xml" lena.jpg
でやってみたが、haarcascade_eye.xml と同様な結果になった。./facedetect --cascade="/usr/local/share/OpenCV/haarcascades/haarcascade_eye_tree_eyeglasses.xml" lena.jpg
顔は検出されたが、ネクタイ部分も顔として検出されてしまった。(お見苦しい点があるため画像の一部を加工していますw)./facedetect --cascade="/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml" marsee.jpg
したが、make の途中でエラーになってしまう。make clean
cmake ..
make
これで、レナ像の顔検出をすることができた。apt-get install libcv-dev
apt-get install libcv1
apt-get install libcvaux-dev
apt-get install libcvaux1
apt-get install libhighgui-dev
apt-get install libhighgui1
apt-get install opencv-doc
./facedetect --cascade="/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml" lena.jpg
dpkg: error processing package texlive-latex-base (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of texlive-latex-recommended:
texlive-latex-recommended depends on texlive-latex-base (>= 2013.20130512); however:
Package texlive-latex-base is not configured yet.
texlive-latex-recommended depends on tex-common (>= 3); however:
Package tex-common is not configured yet.
のみを行った。それでも消えないパッケージは逆に apt-get install でインストールを行った。また、手動で削除しろというファイルもあって、それは rm コマンドで削除した。sudo dpkg --purge texlive-latex-base
root@linaro-ubuntu-desktop:~# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/root 7443384 6348376 693856 91% /
devtmpfs 187692 4 187688 1% /dev
none 4 0 4 0% /sys/fs/cgroup
none 50668 520 50148 2% /run
none 5120 0 5120 0% /run/lock
none 253328 0 253328 0% /run/shm
none 102400 0 102400 0% /run/user
root@linaro-ubuntu-desktop:~# sudo apt-get clean
root@linaro-ubuntu-desktop:~# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/root 7443384 5018196 2024036 72% /
devtmpfs 187692 4 187688 1% /dev
none 4 0 4 0% /sys/fs/cgroup
none 50668 520 50148 2% /run
none 5120 0 5120 0% /run/lock
none 253328 0 253328 0% /run/shm
none 102400 0 102400 0% /run/user
U-Boot 2014.01-00005-gc29bed9-dirty (Sep 13 2014 - 20:33:09)
I2C: ready
Memory: ECC disabled
DRAM: 512 MiB
MMC: zynq_sdhci: 0
SF: Detected S25FL128S_64K with page size 256 Bytes, erase size 64 KiB, total 16 MiB
*** Warning - bad CRC, using default environment
In: serial
Out: serial
Err: serial
Net: Gem.e000b000
Hit any key to stop autoboot: 0
Device: zynq_sdhci
Manufacturer ID: 3
OEM: 5344
Name: SL08G
Tran Speed: 50000000
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 7.4 GiB
Bus Width: 4-bit
reading uEnv.txt
117 bytes read in 11 ms (9.8 KiB/s)
Loaded environment from uEnv.txt
Importing environment from SD ...
Running uenvcmd ...
reading uImage
3987160 bytes read in 347 ms (11 MiB/s)
reading devicetree.dtb
7762 bytes read in 15 ms (504.9 KiB/s)
## Booting kernel from Legacy Image at 03000000 ...
Image Name: Linux-3.14.0-xilinx-13567-g906a2
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 3987096 Bytes = 3.8 MiB
Load Address: 00008000
Entry Point: 00008000
Verifying Checksum ... OK
## Flattened Device Tree blob at 02a00000
Booting using the fdt blob at 0x2a00000
Loading Kernel Image ... OK
Loading Device Tree to 1fb29000, end 1fb2de51 ... OK
Starting kernel ...
Uncompressing Linux... done, booting the kernel.
[ 0.000000] Booting Linux on physical CPU 0x0
[ 0.000000] Linux version 3.14.0-xilinx-13567-g906a2c9-dirty (masaaki@masaaki-VirtualBox) (gcc version 4.6.3 (Sourcery CodeBench Lite 2012.03-79) ) #9 SMP PREEMPT Sun Oct 5 04:32:36 JST 2014
[ 0.000000] CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=18c5387d
[ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[ 0.000000] Machine model: Xilinx Zynq
[ 0.000000] bootconsole [earlycon0] enabled
[ 0.000000] cma: CMA: reserved 128 MiB at 17800000
[ 0.000000] Memory policy: Data cache writealloc
[ 0.000000] PERCPU: Embedded 8 pages/cpu @dfb9e000 s10752 r8192 d13824 u32768
[ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 130048
[ 0.000000] Kernel command line: console=ttyPS0,115200 root=/dev/mmcblk0p2 rw earlyprintk rootfstype=ext4 rootwait devtmpfs.mount=1 coherent_pool=16M
[ 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: 375388K/524288K available (5144K kernel code, 319K rwdata, 1900K rodata, 202K init, 5339K bss, 148900K reserved, 0K highmem)
[ 0.000000] Virtual kernel memory layout:
[ 0.000000] vector : 0xffff0000 - 0xffff1000 ( 4 kB)
[ 0.000000] fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB)
[ 0.000000] vmalloc : 0xe0800000 - 0xff000000 ( 488 MB)
[ 0.000000] lowmem : 0xc0000000 - 0xe0000000 ( 512 MB)
[ 0.000000] pkmap : 0xbfe00000 - 0xc0000000 ( 2 MB)
[ 0.000000] modules : 0xbf000000 - 0xbfe00000 ( 14 MB)
[ 0.000000] .text : 0xc0008000 - 0xc06e9600 (7046 kB)
[ 0.000000] .init : 0xc06ea000 - 0xc071ca00 ( 203 kB)
[ 0.000000] .data : 0xc071e000 - 0xc076dde0 ( 320 kB)
[ 0.000000] .bss : 0xc076ddec - 0xc0ca4c88 (5340 kB)
[ 0.000000] Preemptible hierarchical RCU implementation.
[ 0.000000] RCU lockdep checking is enabled.
[ 0.000000] Dump stacks of tasks blocking RCU-preempt GP.
[ 0.000000] RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=2.
[ 0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2
[ 0.000000] NR_IRQS:16 nr_irqs:16 16
[ 0.000000] ps7-slcr mapped to e0802000
[ 0.000000] zynq_clock_init: clkc starts at e0802100
[ 0.000000] Zynq clock init
[ 0.000016] sched_clock: 64 bits at 325MHz, resolution 3ns, wraps every 3383112499200ns
[ 0.008494] ps7-ttc #0 at e0804000, irq=43
[ 0.013536] Console: colour dummy device 80x30
[ 0.017873] Lock dependency validator: Copyright (c) 2006 Red Hat, Inc., Ingo Molnar
[ 0.025927] ... MAX_LOCKDEP_SUBCLASSES: 8
[ 0.029947] ... MAX_LOCK_DEPTH: 48
[ 0.034117] ... MAX_LOCKDEP_KEYS: 8191
[ 0.038538] ... CLASSHASH_SIZE: 4096
[ 0.042889] ... MAX_LOCKDEP_ENTRIES: 16384
[ 0.047359] ... MAX_LOCKDEP_CHAINS: 32768
[ 0.051865] ... CHAINHASH_SIZE: 16384
[ 0.056305] memory used by lock dependency info: 3695 kB
[ 0.061755] per task-struct memory footprint: 1152 bytes
[ 0.067198] Calibrating delay loop... 1292.69 BogoMIPS (lpj=6463488)
[ 0.110953] pid_max: default: 32768 minimum: 301
[ 0.116270] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[ 0.122808] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[ 0.137373] CPU: Testing write buffer coherency: ok
[ 0.143607] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
[ 0.149243] Setting up static identity map for 0x4de8d0 - 0x4de928
[ 0.155615] L310 cache controller enabled
[ 0.159575] l2x0: 8 ways, CACHE_ID 0x410000c8, AUX_CTRL 0x72760000, Cache size: 512 kB
[ 0.240411] CPU1: Booted secondary processor
[ 0.328277] CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
[ 0.329389] Brought up 2 CPUs
[ 0.342252] SMP: Total of 2 processors activated.
[ 0.346952] CPU: All CPU(s) started in SVC mode.
[ 0.354955] devtmpfs: initialized
[ 0.365694] VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4
[ 0.379870] regulator-dummy: no parameters
[ 0.392699] NET: Registered protocol family 16
[ 0.429419] DMA: preallocated 16384 KiB pool for atomic coherent allocations
[ 0.443249] cpuidle: using governor ladder
[ 0.447231] cpuidle: using governor menu
[ 0.474412] syscon f8000000.ps7-slcr: regmap [mem 0xf8000000-0xf8000fff] registered
[ 0.488774] hw-breakpoint: found 5 (+1 reserved) breakpoint and 1 watchpoint registers.
[ 0.496625] hw-breakpoint: maximum watchpoint size is 4 bytes.
[ 0.502995] zynq-ocm f800c000.ps7-ocmc: ZYNQ OCM pool: 256 KiB @ 0xe0880000
[ 0.573803] bio: create slab <bio-0> at 0
[ 0.583427] vgaarb: loaded
[ 0.587951] SCSI subsystem initialized
[ 0.594167] usbcore: registered new interface driver usbfs
[ 0.599984] usbcore: registered new interface driver hub
[ 0.605789] usbcore: registered new device driver usb
[ 0.612304] media: Linux media interface: v0.10
[ 0.617154] Linux video capture interface: v2.00
[ 0.622395] pps_core: LinuxPPS API ver. 1 registered
[ 0.627234] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[ 0.637141] PTP clock support registered
[ 0.642039] EDAC MC: Ver: 3.0.0
[ 0.648371] Advanced Linux Sound Architecture Driver Initialized.
[ 0.663848] DMA-API: preallocated 4096 debug entries
[ 0.668767] DMA-API: debugging enabled by kernel config
[ 0.674482] Switched to clocksource arm_global_timer
[ 0.737698] NET: Registered protocol family 2
[ 0.744615] TCP established hash table entries: 4096 (order: 2, 16384 bytes)
[ 0.751721] TCP bind hash table entries: 4096 (order: 5, 147456 bytes)
[ 0.760297] TCP: Hash tables configured (established 4096 bind 4096)
[ 0.766777] TCP: reno registered
[ 0.769908] UDP hash table entries: 256 (order: 2, 20480 bytes)
[ 0.776091] UDP-Lite hash table entries: 256 (order: 2, 20480 bytes)
[ 0.783578] NET: Registered protocol family 1
[ 0.789613] RPC: Registered named UNIX socket transport module.
[ 0.795487] RPC: Registered udp transport module.
[ 0.800129] RPC: Registered tcp transport module.
[ 0.804891] RPC: Registered tcp NFSv4.1 backchannel transport module.
[ 0.812706] hw perfevents: enabled with ARMv7 Cortex-A9 PMU driver, 7 counters available
[ 0.826575] futex hash table entries: 512 (order: 3, 32768 bytes)
[ 0.840444] jffs2: version 2.2. (NAND) (SUMMARY) c 2001-2006 Red Hat, Inc.
[ 0.848005] msgmni has been set to 989
[ 0.853245] io scheduler noop registered
[ 0.857183] io scheduler deadline registered
[ 0.861451] io scheduler cfq registered (default)
[ 0.885946] dma-pl330 f8003000.ps7-dma: Loaded driver for PL330 DMAC-2364208
[ 0.892852] dma-pl330 f8003000.ps7-dma: DBUFF-128x8bytes Num_Chans-8 Num_Peri-4 Num_Events-16
[ 0.905104] e0001000.serial: ttyPS0 at MMIO 0xe0001000 (irq = 82, base_baud = 3125000) is a xuartps
[ 0.914351] console [ttyPS0] enabled
[ 0.914351] console [ttyPS0] enabled
[ 0.921559] bootconsole [earlycon0] disabled
[ 0.921559] bootconsole [earlycon0] disabled
[ 0.932690] xdevcfg f8007000.ps7-dev-cfg: ioremap 0xf8007000 to e0866000
[ 0.942547] [drm] Initialized drm 1.1.0 20060810
[ 0.980710] brd: module loaded
[ 1.003034] loop: module loaded
[ 1.018849] m25p80 spi0.0: found s25fl128s1, expected n25q128
[ 1.025065] m25p80 spi0.0: s25fl128s1 (16384 Kbytes)
[ 1.030089] 4 ofpart partitions found on MTD device spi0.0
[ 1.036204] Creating 4 MTD partitions on "spi0.0":
[ 1.040923] 0x000000000000-0x000000400000 : "qspi-fsbl-uboot"
[ 1.054328] 0x000000400000-0x000000900000 : "qspi-linux"
[ 1.064666] 0x000000900000-0x000000920000 : "qspi-device-tree"
[ 1.075473] 0x000000920000-0x000001000000 : "qspi-user"
[ 1.095356] e1000e: Intel(R) PRO/1000 Network Driver - 2.3.2-k
[ 1.101107] e1000e: Copyright(c) 1999 - 2013 Intel Corporation.
[ 1.112951] libphy: XEMACPS mii bus: probed
[ 1.119068] xemacps e000b000.ps7-ethernet: invalid address, use assigned
[ 1.126272] xemacps e000b000.ps7-ethernet: MAC updated 56:fa:f7:fe:d3:b4
[ 1.133446] xemacps e000b000.ps7-ethernet: pdev->id -1, baseaddr 0xe000b000, irq 54
[ 1.148608] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[ 1.155665] ehci-pci: EHCI PCI platform driver
[ 1.160743] ULPI transceiver vendor/product ID 0x0424/0x0007
[ 1.166425] Found SMSC USB3320 ULPI transceiver.
[ 1.170985] ULPI integrity check: passed.
[ 1.175939] zynq-ehci zynq-ehci.0: Xilinx Zynq USB EHCI Host Controller
[ 1.183203] zynq-ehci zynq-ehci.0: new USB bus registered, assigned bus number 1
[ 1.214605] zynq-ehci zynq-ehci.0: irq 53, io mem 0x00000000
[ 1.234538] zynq-ehci zynq-ehci.0: USB 2.0 started, EHCI 1.00
[ 1.247261] hub 1-0:1.0: USB hub found
[ 1.251239] hub 1-0:1.0: 1 port detected
[ 1.259195] usbcore: registered new interface driver usb-storage
[ 1.268054] mousedev: PS/2 mouse device common for all mice
[ 1.275757] i2c /dev entries driver
[ 1.288482] zynq-edac f8006000.ps7-ddrc: ecc not enabled
[ 1.294740] cpufreq_cpu0: failed to get cpu0 regulator: -19
[ 1.303096] Xilinx Zynq CpuIdle Driver started
[ 1.309564] sdhci: Secure Digital Host Controller Interface driver
[ 1.315727] sdhci: Copyright(c) Pierre Ossman
[ 1.320008] sdhci-pltfm: SDHCI platform and OF driver helper
[ 1.327296] mmc0: no vqmmc regulator found
[ 1.331319] mmc0: no vmmc regulator found
[ 1.374478] mmc0: SDHCI controller on e0100000.ps7-sdio [e0100000.ps7-sdio] using ADMA
[ 1.393511] usbcore: registered new interface driver usbhid
[ 1.401124] usbhid: USB HID core driver
[ 1.418094] TCP: cubic registered
[ 1.421340] NET: Registered protocol family 17
[ 1.426504] Registering SWP/SWPB emulation handler
[ 1.433816] regulator-dummy: disabling
[ 1.438362] drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
[ 1.457043] mmc0: new high speed SDHC card at address aaaa
[ 1.465348] mmcblk0: mmc0:aaaa SL08G 7.40 GiB
[ 1.473066] ALSA device list:
[ 1.476457] No soundcards found.
[ 1.476666] mmcblk0: p1 p2
[ 5.836091] EXT4-fs (mmcblk0p2): recovery complete
[ 5.843404] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[ 5.851583] VFS: Mounted root (ext4 filesystem) on device 179:2.
[ 5.866317] devtmpfs: mounted
[ 5.869599] Freeing unused kernel memory: 200K (c06ea000 - c071c000)
Mount failed for selinuxfs on /sys/fs/selinux: No such file or directory
[ 6.706293] init: plymouth-upstart-bridge main process (591) terminated with [ 6.875380] init: plymouth-upstart-bridge main process (601) terminated with [ 7.887878] random: nonblocking pool is initializedinated with status 5
* Starting Mount filesystems on boot [ OK ]
* Starting Signal sysvinit that the rootfs is mounted [ OK ]
* Starting Populate /dev filesystem [ OK ]
* Stopping Populate /dev filesystem [ OK ]
* Starting Clean /tmp directory [ OK ]
* Starting Populate and link to /run filesystem [ OK ]
* Stopping Clean /tmp directory [ OK ]
* Stopping Populate and link to /run filesystem [ OK ]
* Stopping Track if upstart is running in a container [ OK ]
* Starting Initialize or finalize resolvconf [ OK ]
* Starting set console keymap [ OK ]
* Starting Signal sysvinit that virtual filesystems are mounted [ OK ]
* Starting Signal sysvinit that virtual filesystems are mounted [ OK ]
* Stopping set console keymap [ OK ]
* Starting Signal sysvinit that local filesystems are mounted [ OK ]
* Starting Bridge udev events into upstart [ OK ]
* Starting Signal sysvinit that remote filesystems are mounted [ OK ]
* Starting device node and kernel event manager [ OK ]
modprobe: FATAL: Could not load /lib/modules/3.14.0-xilinx-13567-g906a2c9-dirty/modules.dep: No such file or directory
* Starting OpenSSH server [ OK ]
* Starting Load gator driver module and launch gator daemon [ OK ]
* Starting flush early job output to logs [ OK ]
* Starting Load gator driver module and launch gator daemon [fail]
* Stopping Mount filesystems on boot [ OK ]
* Stopping flush early job output to logs [ OK ]
* Starting load modules from /etc/modules [ OK ]
* Starting cold plug devices [ OK ]
* Starting log initial device creation [ OK ]
* Stopping load modules from /etc/modules [ OK ]
modprobe: FATAL: Could not load /lib/modules/3.14.0-xilinx-13567-g906a2c9-dirty/modules.dep: No such file or directory
modprobe: FATAL: Could not load /lib/modules/3.14.0-xilinx-13567-g906a2c9-dirty/modules.dep: No such file or directory
* Starting system logging daemon [ OK ]
* Starting D-Bus system message bus [ OK ]
* Starting modem connection manager [ OK ]
* Starting configure network device security [ OK ]
* Starting network connection manager [ OK ]
* Starting configure network device security [ OK ]
* Starting configure network device [ OK ]
* Stopping cold plug devices [ OK ]
* Stopping log initial device creation [ OK ]
* Starting mDNS/DNS-SD daemon [ OK ]
* Starting enable remaining boot-time encrypted block devices [ OK ]
* Starting configure network device security [ OK ]
* Starting configure virtual network devices [ OK ]
* Starting CUPS printing spooler/server [ OK ]
* Stopping enable remaining boot-time encrypted block devices [ OK ]
* Stopping configure virtual network devices [ OK ]
* Starting userspace bootsplash [ OK ]
* Stopping userspace bootsplash [ OK ]
* Starting Send an event to indicate plymouth is up [ OK ]
* Starting System V initialisation compatibility [ OK ]
* Starting configure network device security [ OK ]
* Starting bluetooth daemon [ OK ]
* Starting configure network device [ OK ]
* Setting up X socket directories... [ OK ]
* Starting Mount network filesystems [ OK ]
* Starting Failsafe Boot Delay [ OK ]
* Stopping Mount network filesystems [ OK ]
* Stopping System V initialisation compatibility [ OK ]
Last login: Thu Jan 1 00:00:29 UTC 1970 on tty1
Welcome to Ubuntu 14.04 LTS (GNU/Linux 3.14.0-xilinx-13567-g906a2c9-dirty armv7l)
* Documentation: https://help.ubuntu.com/
speech-dispatcher disabled; edit /etc/default/speech-dispatcher
saned disabled; edit /etc/default/saned
* Starting System V runlevel compatibility [ OK ]
* Starting automatic crash report generation [ OK ]
* Starting save kernel messages [ OK ]
* Starting anac(h)ronistic cron [ OK ]
* Starting crash report submission daemon [ OK ]
* Starting regular background program processing daemon [ OK ]
* Stopping save kernel messages [ OK ]
* Stopping anac(h)ronistic cron [ OK ]
Error in function update
E: Unknown Error: '<type 'exceptions.TypeError'>' (update() takes exactly 2 arguments (1 given))run-parts: /etc/update-motd.d/90-updates-available exited with return code 255
root@linaro-ubuntu-desktop:~#
が書いてあれば良いそうだが、上の2つは書かれていたので、X11UseLocalhost yes のみを追加した。X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost yes
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.3.131
network 192.168.3.0
netmask 255.255.255.0
broadcast 192.168.3.255
gateway 192.168.3.1
dns-nameservers 192.168.3.1
みみず工房掲示板 kernel 3.8.4 +rt-1 patch - t-ta
256 KiB atomic DMA coherent pool is too small! #170
Linuxでのメモリ確保
bootargs = "console=ttyPS0,115200 root=/dev/mmcblk0p2 rw earlyprintk rootfstype=ext4 rootwait devtmpfs.mount=1 coherent_pool=16M";
だったのが、、[ 0.401437] DMA: preallocated 256 KiB pool for atomic coherent allocations
になった。[ 0.429427] DMA: preallocated 16384 KiB pool for atomic coherent allocations
が表示された。ether が落ちてしまったようだ。[ 166.816932] xemacps e000b000.ps7-ethernet: TX error 0x138
を信じてやってきたが、top コマンドの表示の[ 0.000000] cma: CMA: reserved 128 MiB at 17800000
は、128MBをCMA領域に割り振られているにしては、Free メモリが多すぎる。Mem: 506664k total, 68264k used, 438400k free
/* * draw_disp_uio.c * * Created on: 2014/10/03 * Author: Masaaki */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
#include <sys/mman.h>
#include <fcntl.h>
#define VIDEO_BUFFER_START_ADDRESS 0x17800000
#define HORIZONTAL_PIXEL 800
#define ALL_CHAR_OF_1LINE (HORIZONTAL_PIXEL/8)
#define VERTICAL_PIXEL 600
#define ALL_CHAR_OF_ROW (VERTICAL_PIXEL/8)
#define ALL_DISP_ADDRESS (HORIZONTAL_PIXEL*VERTICAL_PIXEL*4)
#define ALL_DISP_CHARACTOR HORIZONTAL_PIXEL*VERTICAL_PIXEL
// char_draw: Draw the character to receive a character code and address
// addr : Start address at drawing charactor
// char_code : drawing charactor code
// char_color : color of drawing charactor, represented by 32-bit, oRGB (8bits)
// return value :show a drawing start address of the next character
unsigned int *char_draw(unsigned *addr, unsigned *char_rom_axi_lite, unsigned char char_code, unsigned int char_color){
int i,j;
unsigned int char_pattern;
unsigned int char_code_int;
unsigned int *cal_char_addr;
unsigned int *return_addr;
char_code_int = (unsigned int)(char_code);
return_addr = addr + 8;
cal_char_addr = (unsigned int *)((unsigned)char_rom_axi_lite+((char_code_int<<3)<<2)); // Data of the character generator ROM is 32 bits wide, valid only 8 bits of the least significant
for(i=0; i<8; i++){
char_pattern = *(volatile unsigned int *)(cal_char_addr); // Reads the pattern of the character
for(j=0; j<8; j++){
if(char_pattern & 0x1) // Drawing a dot when 7th bit is one
*(volatile unsigned int *)((unsigned int)addr ^ 4) = char_color;
else
*(volatile unsigned int *)((unsigned int)addr ^ 4) = 0; // drawing black
addr++;
char_pattern >>= 1; // 1bit shift right
}
addr -= 8; // Return to the address of the beginning of the line
addr += HORIZONTAL_PIXEL; // Down one line
cal_char_addr++;
}
return return_addr;
}
int main() {
unsigned char char_code;
unsigned *ddr2_addr;
unsigned int coler_code;
unsigned int char_cnt;
int i, j, k;
int fd0, fd1, fd3;
volatile unsigned *bmdc_axis_lite;
volatile unsigned *char_rom_axi_lite;
volatile unsigned *bmdc_axim;
// Bitmap Display Controller AXI4 Lite Slave (UIO0)
fd0 = open("/dev/uio0", O_RDWR); // bitmap_display_controller axi4 lite
if (fd0 < 1){
fprintf(stderr, "/dev/uio0 open error\n");
exit(-1);
}
bmdc_axis_lite = (volatile unsigned *)mmap(NULL, 0x10000, PROT_READ|PROT_WRITE, MAP_SHARED, fd0, 0);
if (!bmdc_axis_lite){
fprintf(stderr, "mmap error\n");
exit(-1);
}
bmdc_axis_lite[0] = VIDEO_BUFFER_START_ADDRESS; // Bitmap Display Controller start
munmap((void *)bmdc_axis_lite, 0x10000);
// Charactor Generate ROM UIO1
fd1 = open("/dev/uio1", O_RDWR); // char_rom_axi4 lite
if (fd1 < 1){
fprintf(stderr, "/dev/uio1 open error\n");
exit(-1);
}
char_rom_axi_lite = (volatile unsigned *)mmap(NULL, 0x10000, PROT_READ|PROT_WRITE, MAP_SHARED, fd1, 0);
if (!char_rom_axi_lite){
fprintf(stderr, "mmap error\n");
exit(-1);
}
// Bitmap Display Controller AXI4 Master UIO3
fd3 = open("/dev/uio3", O_RDWR); // bitmap_display_controller FB
if (fd3 < 1){
fprintf(stderr, "/dev/uio3 open error\n");
exit(-1);
}
bmdc_axim = (volatile unsigned *)mmap(NULL, 0x1000000, PROT_READ|PROT_WRITE, MAP_SHARED, fd3, 0);
if (!bmdc_axim){
fprintf(stderr, "mmap error\n");
exit(-1);
}
// Clean display
for (k=0; k < ALL_DISP_CHARACTOR; k++){
bmdc_axim[k] = 0;
}
// Charactor output
ddr2_addr = (unsigned *)bmdc_axim;
char_cnt = 0;
for(j=0; j<((ALL_CHAR_OF_1LINE*ALL_CHAR_OF_ROW)/((128-33)*7))+1; j++){
for(i=1; i<8; i++){
switch(i){
case 1 :
coler_code = 0xff; // blue
break;
case 2 :
coler_code = 0xff00; // Green
break;
case 3 :
coler_code = 0xffff; // Cyan
break;
case 4 :
coler_code = 0xff0000; // Red
break;
case 5 :
coler_code = 0xff00ff; // Magenta
break;
case 6 :
coler_code = 0xffff00; // Yellow
break;
case 7 :
coler_code = 0xffffff; // Write
break;
}
for(char_code=0x21; char_code<0x80; char_code++){
if(char_code >= 0x80) // Character code has reached the upper limit, back into the bottom
char_code = 0x21;
if (char_cnt!=0 && char_cnt%ALL_CHAR_OF_1LINE==0)
ddr2_addr = (unsigned *)((unsigned int)ddr2_addr + HORIZONTAL_PIXEL*4*7); // Having finished writing a single line, the line below, the address HORIZONTAL_PIXELx1 pixel 4 bytes x7 line
ddr2_addr = char_draw(ddr2_addr, (unsigned int *)char_rom_axi_lite, char_code, coler_code); // Draw charactor
char_cnt++;
}
}
}
munmap((void *)char_rom_axi_lite, 0x10000);
munmap((void *)bmdc_axim, 0x1000000);
return 0;
}
0 : ビットマップ・ディスプレイ・コントローラのアドレス設定用AXI4 Lite Slave(これを設定すると画面が表示される)
1 : キャラクタ・ジェネレータ ROM AXI4 Lite Slave (キャラクタのラスタ・データがアドレスを与えると出力される)
2 : LEDの表示する値を設定する
3 : ビットマップ・ディスプレイ・コントローラのフレーム・バッファ(アドレスを与えて、Read/Write
/* * dips_test.c * * Created on: 2014/09/28 * Author: Masaaki */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
#include <sys/mman.h>
#include <fcntl.h>
int main(int argc, char *argv[]) {
int c;
int in_val=0;
int index=0;
int inout=1;
int fd0, fd1, fd2, fd3;
int device;
volatile unsigned *bmdc_axis_lite;
volatile unsigned *char_rom_axi_lite;
volatile unsigned *led_gpio;
volatile unsigned *bmdc_axim;
while ((c = getopt(argc, argv, "d:a:i:o")) != -1){
switch(c){
case 'd' :
device = (int)strtol(optarg, 0, 0);
break;
case 'a' :
index = ((int)strtol(optarg, 0, 0))/sizeof(int);
break;
case 'i' :
in_val = (int)strtol(optarg, 0, 0);
inout = 0;
break;
case 'o' :
default :
inout = 1;
}
}
switch(device){
case 0 :
fd0 = open("/dev/uio0", O_RDWR); // bitmap_display_controller axi4 lite
if (fd0 < 1){
fprintf(stderr, "/dev/uio0 open error\n");
exit(-1);
}
bmdc_axis_lite = (volatile unsigned *)mmap(NULL, 0x10000, PROT_READ|PROT_WRITE, MAP_SHARED, fd0, 0);
if (!bmdc_axis_lite){
fprintf(stderr, "mmap error\n");
exit(-1);
}
break;
case 1 :
fd1 = open("/dev/uio1", O_RDWR); // char_rom_axi4 lite
if (fd1 < 1){
fprintf(stderr, "/dev/uio1 open error\n");
exit(-1);
}
char_rom_axi_lite = (volatile unsigned *)mmap(NULL, 0x10000, PROT_READ|PROT_WRITE, MAP_SHARED, fd1, 0);
if (!char_rom_axi_lite){
fprintf(stderr, "mmap error\n");
exit(-1);
}
break;
case 2 :
fd2 = open("/dev/uio2", O_RDWR);
if (fd2 < 1){
fprintf(stderr, "/dev/uio2 open error\n");
exit(-1);
}
led_gpio = (volatile unsigned *)mmap(NULL, 0x10000, PROT_READ|PROT_WRITE, MAP_SHARED, fd2, 0);
if (!led_gpio){
fprintf(stderr, "mmap error\n");
exit(-1);
}
break;
default :
fd3 = open("/dev/uio3", O_RDWR); // bitmap_display_controller FB
if (fd3 < 1){
fprintf(stderr, "/dev/uio3 open error\n");
exit(-1);
}
bmdc_axim = (volatile unsigned *)mmap(NULL, 0x10000000, PROT_READ|PROT_WRITE, MAP_SHARED, fd3, 0);
if (!bmdc_axim){
fprintf(stderr, "mmap error\n");
exit(-1);
}
}
if (inout == 0){
switch(device){
case 0 :
bmdc_axis_lite[0] = in_val;
break;
case 2 :
led_gpio[1] = 0xf; // Channel1 AXI GPIO 3-state Control Register (output mode)
led_gpio[0] = in_val;
break;
default :
bmdc_axim[index] = in_val;
}
} else {
switch(device){
case 0 :
printf("bmdc_axis_lite = %x\n", bmdc_axis_lite[0]);
break;
case 1 :
printf("char_rom_axi_lite[%x] = %x\n", index, char_rom_axi_lite[index]);
break;
case 2 :
printf("led_gpio = %x\n", led_gpio[0]);
printf("led_gpio_tri = %x\n", led_gpio[1]);
break;
default :
printf("bmdc_axim[%x] = %x\n", index, bmdc_axim[index]);
}
}
switch(device){
case 0 :
munmap((void *)bmdc_axis_lite, 0x10000);
break;
case 1 :
munmap((void *)char_rom_axi_lite, 0x10000);
break;
case 2 :
munmap((void *)led_gpio, 0x10000);
break;
default :
munmap((void *)bmdc_axim, 0x10000000);
}
return 0;
}
日 | 月 | 火 | 水 | 木 | 金 | 土 |
---|---|---|---|---|---|---|
- | - | - | 1 | 2 | 3 | 4 |
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 | - |