Forum: Digitale Signalverarbeitung / DSP / Machine Learning Blackfin uClinux nutzt nicht den ganzen RAM


von Robert L. (robi-wan)


Lesenswert?

Hallo,
Ich nutze das SRV-1 Board um mit uClinux und der Opencv Bildanalysen 
durchzuführen.

Da die Opencv-Bibliotheken zu groß sind um sie in das Image für den 
Flash zu integrieren, gehe im Moment folgendermassen vor:

Nach dem kompilieren des uClinux wird das erstellte Image (ohne opencv 
und meine Programme) in den Flash geschrieben. Den Inhalt von 
rootfs.ext2 kopiere ich auf eine SD-Karte und kopiere dann die 
bibliotheken nach '.../SD-Karte/libs' bzw die Programme nach 
'.../SD-karte/bin'. Im Moment werden nur auf der SD-Karte gespeicherte 
Bilder Analysiert, da mein SRV-1 leider mit dem OV7725 Kameramodul kam 
und ich bisher nur Treiber für den OV9655 gefunden habe.
Zum Booten wird dann das Image aus dem Flash in den RAM entpackt, und 
von dort gebootet, mit der SD-Karte als root.

Auf dem Blackfin siehts nach dem Booten so aus:

#cat /proc/meminfo

MemTotal:          14048 kB
MemFree:           11532 kB

Da die Opencv-Bibliotheken allerdings schon rund 10MB groß sind, bleibt 
da net mehr viel Luft für den Rest. Wenn die zu analysierenden Bilder 
eine gewisse Größe überschreiten (320x240 geht noch 640x480 nicht mehr), 
reicht der RAM nicht mehr aus.

Der Komplette Bootvorgang sieht folgendermassen aus:
1
CPU:   ADSP BF537 Rev.: 0.3
2
Board: ADI BF537 stamp board
3
       Support: http://blackfin.uclinux.org/
4
Clock: VCO: 442 MHz, Core: 442 MHz, System: 88 MHz
5
SDRAM: 32 MB
6
FLASH:   4 MB
7
In:    serial
8
Out:   serial
9
Err:   serial
10
Net:  ADI BF537 EMAC
11
I2C:   ready
12
Hit any key to stop autoboot:  1  0 
13
14
EEPROM @0x0 read: addr 01000000  off 30000  count 2646053 ... ........................................done
15
16
## Booting image at 01000000 ...
17
18
   Image Name:   uClinux Kernel and ext2
19
   Created:      2010-06-01   6:29:11 UTC
20
   Image Type:   Blackfin Linux Kernel Image (gzip compressed)
21
   Data Size:    2645989 Bytes =  2.5 MB
22
   Load Address: 00400000
23
   Entry Point:  0052c2e0
24
   Verifying Checksum ... OK
25
   Uncompressing Kernel Image ... OK
26
Starting Kernel at = 52c2e0
27
28
Linux version 2.6.28.10-ADI-2009R1 (robi-wan@Robolab) (gcc version 4.1.2 (ADI svn)) #44 Tue Jun 1 08:28:22 CEST 2010
29
Board Memory: 32MB
30
Kernel Managed Memory: 32MB
31
Memory map:
32
  fixedcode = 0x00000400-0x00000490
33
  text      = 0x00400000-0x004bc270
34
  rodata    = 0x004bc270-0x00501da4
35
  bss       = 0x00502000-0x0051bb00
36
  data      = 0x0051bb00-0x0052a000
37
    stack   = 0x00528000-0x0052a000
38
  init      = 0x0052a000-0x0053a000
39
  available = 0x0053a000-0x01600000
40
  rootfs    = 0x01600000-0x02000000
41
Hardware Trace Off and Disabled
42
Boot Mode: 3
43
Blackfin support (C) 2004-2009 Analog Devices, Inc.
44
Compiled for ADSP-BF537 Rev 0.3
45
Blackfin Linux support by http://blackfin.uclinux.org/
46
Processor Speed: 442 MHz core clock and 88 MHz System Clock
47
MPU: setting up cplb tables with memory protection
48
Instruction Cache Enabled for CPU0
49
Data Cache Enabled for CPU0 (write-back)
50
Built 1 zonelists in Zone order, mobility grouping off.  Total pages: 5588
51
Kernel command line: root=/dev/mmcblk0p1 rw rootdelay=2 earlyprintk=serial,uart0,115200 console=ttyBF0,115200 mem=32M
52
Configuring Blackfin Priority Driven Interrupts
53
PID hash table entries: 128 (order: 7, 512 bytes)
54
console [ttyBF0] enabled
55
Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
56
Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)
57
Memory available: 14048k/32768k RAM, (64k init code, 752k kernel code, 440k data, 0k dma, 7224k reserved)
58
Calibrating delay loop... 882.68 BogoMIPS (lpj=1765376)
59
Security Framework initialized
60
Mount-cache hash table entries: 512
61
Blackfin Scratchpad data SRAM: 4 KB
62
Blackfin L1 Data A SRAM: 16 KB (10 KB free)
63
Blackfin L1 Data B SRAM: 32 KB (32 KB free)
64
Blackfin L1 Instruction SRAM: 48 KB (38 KB free)
65
Blackfin DMA Controller
66
stamp_init(): registering device resources
67
msgmni has been set to 27
68
io scheduler noop registered
69
io scheduler anticipatory registered (default)
70
io scheduler cfq registered
71
bfin-dma: initialized
72
Serial: Blackfin serial driver
73
bfin-uart.1: ttyBF0 at MMIO 0xffc00400 (irq = 18) is a BFIN-UART
74
Linux video capture interface: v2.00
75
OV9655: i2c driver ready
76
uclinux[mtd]: RAM probe address=0x1600000 size=0xa00000
77
Creating 1 MTD partitions on "RAM":
78
0x00000000-0x00a00000 : "ROMfs"
79
bfin-spi bfin-spi.0: Blackfin on-chip SPI Controller Driver, Version 1.0, regs_base@ffc00500, dma channel@7
80
i2c /dev entries driver
81
i2c-bfin-twi i2c-bfin-twi.0: Blackfin BF5xx on-chip I2C TWI Contoller, regs_base@ffc01400
82
mmc_spi spi0.2: ASSUMING 3.2-3.4 V slot power
83
mmc_spi spi0.2: SD/MMC host mmc0, no DMA, no WP, no poweroff
84
Waiting 2sec before mounting root device...
85
mmc_spi spi0.2: requested mode not fully supported
86
mmc_spi spi0.2: can't change chip-select polarity
87
mmc0: host does not support reading read-only switch. assuming write-enable.
88
mmc0: new SD card on SPI
89
mmcblk0: mmc0:0000 SD064 59.5 MiB 
90
 mmcblk0: p1
91
EXT2-fs warning: mounting unchecked fs, running e2fsck is recommended
92
VFS: Mounted root (ext2 filesystem).
93
No usable address families found.
94
socket: Function not implemented
95
modprobe: Module blackfin_cam not found.
96
97
Welcome to:
98
         _________                       _____ ____ _    _____
99
  __  __/ ____/ (_)___  __  ___  __     / ___// __ \ |  / <  /
100
 / / / / /   / / / __ \/ / / / |/_/_____\__ \/ /_/ / | / // / 
101
/ /_/ / /___/ / / / / / /_/ />  </_____/__/ / _, _/| |/ // /  
102
\__,_/\____/_/_/_/ /_/\__,_/_/|_|     /____/_/ |_| |___//_/   
103
104
For further information see:
105
http://www.surveyor.com/
106
107
108
BusyBox v1.13.4 (2010-06-01 08:27:05 CEST) built-in shell (msh)
109
Enter 'help' for a list of built-in commands.
110
111
# cat /proc/meminfo
112
cat /proc/meminfo
113
114
MemTotal:          14048 kB
115
MemFree:           11532 kB
116
Buffers:              72 kB
117
Cached:              476 kB
118
SwapCached:            0 kB
119
Active:              380 kB
120
Inactive:            124 kB
121
Active(anon):          0 kB
122
Inactive(anon):        0 kB
123
Active(file):        380 kB
124
Inactive(file):      124 kB
125
SwapTotal:             0 kB
126
SwapFree:              0 kB
127
Dirty:                 4 kB
128
Writeback:             0 kB
129
AnonPages:             0 kB
130
Mapped:                0 kB
131
Slab:                516 kB
132
SReclaimable:        160 kB
133
SUnreclaim:          356 kB
134
PageTables:            0 kB
135
NFS_Unstable:          0 kB
136
Bounce:                0 kB
137
WritebackTmp:          0 kB
138
CommitLimit:        7024 kB
139
Committed_AS:          0 kB
140
VmallocTotal:          0 kB
141
VmallocUsed:           0 kB
142
VmallocChunk:          0 kB
143
# #

Ja, ich nutze ein altes U-Boot Image, allerdings wurde das vom 
Hersteller geliefert und funktioniert. Ich wollte erstmal das mit dem 
selbstgebauten uClinux hinbekommen, bevor ich mich ans U-Boot wage.

zu meinen Fragen:
Wenn ich ein neues U-Boot baue, das von SD-Karte booten kann (über SPI), 
muss ich nicht mehr das Image aus dem Flash in den RAM entpacken, 
sondern würde nur den Kernel laden. Da sollte ich ca 10MB rausholen 
können.
Muss dafür die uClinux-Config geändert werden, bzw was kann noch (und 
wie) optimiert werden?
Hat schon jemand ein neues U-Boot mit SPI-MMC/SD Unterstützung für den 
SRV-1 gebaut und/oder könnte dazu Tipps geben?

--> Eigentlich brauch ich doch nur mehr RAM.

Für jegliche Hilfe / Winks mit Zaunpfählen bin ich Dankbar.

Gruss,
Robert

von Martin S. (strubi)


Lesenswert?

Hi Robert,

beim SRV1 ist in der Tat das Speicheroptimieren knifflig.
Folgendes hilft:

* Kernel vom rootfs trennen, oder rootfs minimal klein machen (nur 
busybox)
* Weitere Partition, z.B. /opt als JFFS2 hinzufuegen. Dazu muss die 
arch/blackfin/mach-bf537/boards/srv1.c angepasst werden (in deiner 
uClinux-Version koennte das noch eine minotaur.c sein, da die Boards 
sehr aehnlich sind). Dann speicherst du alle externen user-programme auf 
die jffs2
* Wenn im FLAT-Format compiliert, sparst du ev. weiter Platz, wenn Du 
nur die busybox und ein paar wenige kleine tools benutzt. ELF-FDPIC 
lohnt oft nur, wenn Du einige grosse Programme installierst, die die 
libc und andere extensiv nutzen. Muss man ausprobieren.

Die meisten Tricks oben sind unter docs.blackfin.uclinux.org 
dokumentiert. Vermutlich steht in deiner .config noch 
CONFIG_MTD_UCLINUX=y, schau mal nach
CONFIG_BLK_DEV_INITRD, usw.
Wichtig ist, dass man im u-boot das Root-Device nach solchen aenderungen 
anpassen muss (root=/dev/mtdblockX), sonst gibt's den ueblichen panic(), 
wenn er das Rootdevice nicht findet.

Viel Erfolg & Gruesse,

- Strubi

von Robert L. (robi-wan)


Lesenswert?

Ich würde sehr gerne den Kernel vom rootfs trennen, dann muss ich das 
rootfs nicht mehr unnütz in den ram entpacken, das soll ja eh auf der 
SD-Karte bleiben.

Ich habe das STAMP-Board ausgewählt, da mit dem Minotaur make nicht 
durchgelaufen ist. Beim STAMP musste ich lediglich den Chipselect vom 
MMC-Teil anpassen und es ging wie geplant.

Wenn ich allerdings MTD in der config rausnehme, bekomme ich zwar ein 
Kernelimage, allerdings wenn ich dieses boote, mit der SD-Karte als 
rootfs, bekomme ich immer die Fehlermeldung, das er kein INIT ausführen 
kann.

Ein INITRD-Image hab ich nicht konfiguriert, war bisher auch nicht 
nötig.

Was kommt denn normalerweise in das INITRD-Image rein (auswahl bei make 
menuconfig)?

Hast du denn eine .../boards/srv1.c ?
Bei der 2009R1-RC6 war zumindest keine dabei.

Gruss,
Robert

von Strubi (Gast)


Lesenswert?

Hi Robert,

sorry, hat etwas gedauert -- es gibt einen bald offiziellen Port und 
auch Support von surveyor.com, erste Sourcecode-Snippets zum 
2009R1.1-RC4 gibt es hier:

http://code.google.com/p/srv1-linux/

Allerdings fruehes Stadium, da verschiedene Implementationen und 
Sensoren bei uns vorherrschen, ist die Video-Sache noch nicht getestet.

Gruesse,

- Strubi

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.