嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
% w' y) q4 z; z6 |% z8 \0 _
核心板2:DDR2 256M Byte NAND FLASH 8G bit
" d0 w" }. v; e6 k$ S4 }: g) n
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
! n* m+ ^% c( H/ z: a- A
; ]$ |* S$ S' ?+ u: }* N
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
7 O" u' A, h1 M4 L! N( v
' `0 a: b( d: c3 w5 A
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
' x* C w$ R+ M
/*
5 R; P3 k" _' F, G+ }/ o! l- Y. u6 \
* Check memory range for valid RAM. A simple memory test determines
3 c7 z5 X+ a0 [- u
* the actually available RAM size between addresses `base' and
$ q' g% e9 X. d; M
* `base + maxsize'.
& z% O* k4 m6 o* x4 g+ O3 f
*/
! S$ j: b( b- o
long get_ram_size(long *base, long maxsize)
. M) E+ y; H! X5 e6 S
{
D/ ^$ O" X4 Z! M1 z* [7 L
volatile long *addr;
$ e# [2 |1 T* a5 |' @* X4 O+ q" f
long save[32];
9 D y, d) h9 @0 o2 l2 D
long cnt;
8 u7 E! v- Q- X. e
long val;
; _" B( }! b X& @
long size;
7 u% X4 ?4 g a0 a& {* _
int i = 0;
$ T( A( r; c$ w6 g
$ A8 d2 P. w) m" G- ^' H4 [
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
9 Q9 R8 a7 j4 M* [
addr = base + cnt; /* pointer arith! */
0 ]( T6 _0 _6 ?% f5 Y, s3 q
sync ();
: K- k3 e, |1 C# `9 |0 P: J
save[i++] = *addr;
7 P: Q! |% H6 |/ A
sync ();
$ \' n) x; ]# Y1 }+ D9 B
*addr = ~cnt;
2 Z* r' V9 @$ f
}
! e. b/ [ |2 }* ^
4 v9 ^0 S% p1 Y% _4 C/ s) F- @( L
addr = base;
, F8 j9 f& X: \; [
sync ();
$ ~8 o0 z& l) X
save
= *addr;
. w% R. X% ^, F
sync ();
) r9 W. O7 _5 K+ [( ^& O( K
*addr = 0;
/ H2 Y3 T! b: |) u5 v' Y( b
( ?; r/ E }6 W" u
sync ();
3 l2 y' p7 Y# `0 p7 d0 e6 U- D
if ((val = *addr) != 0) {
7 C! ~8 v* o8 A+ o
/* Restore the original data before leaving the function.
6 W. I+ ]8 i9 s) n8 ]
*/
7 w, b9 a9 }9 {3 B, M+ l/ k3 N1 q
sync ();
% T' x0 `4 O1 D s" O2 z( M
*addr = save
;
2 z2 Q$ v9 Z4 r; u+ y! P2 F! S
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
( G, e7 |9 w; c& B4 W" l
addr = base + cnt;
1 }0 j/ y# A+ K1 ^ l
sync ();
5 Y! e: K9 K7 N+ p- `9 L
*addr = save[--i];
1 q/ w0 ]5 e% \: `
}
! x( X7 c, [5 G. S; o
return (0);
a& P4 x4 w) M) i3 J$ T
}
+ U: C! E5 g2 F& l: i
" L9 ^# @% Z5 H) Q) C; z4 ` x: |* ]# h
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
2 _2 Y; ]+ O8 K0 O# f+ G( x
addr = base + cnt; /* pointer arith! */
: O: A4 R9 J9 U( c
val = *addr;
6 P2 E: l4 l* K1 @9 j6 i/ J- y
*addr = save[--i];
! o4 E' w2 p0 a! [
if (val != ~cnt) {
& l" E: s4 J+ O* g& H
size = cnt * sizeof (long);
/ n5 M8 Z: e& x& v" Q! ^
/* Restore the original data before leaving the function.
( w& z# U( t+ Y6 g9 S9 F
*/
, m! c1 n5 n% N! l. }
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
# a, @! ^9 u/ c7 u Y/ V z: g
addr = base + cnt;
- H8 l' v1 w a6 e+ |
*addr = save[--i];
/ v; n2 C, H/ p1 m1 ~
}
1 e# }" ]% H0 ~9 p6 q& {0 g
return (size);
1 z1 C9 X3 E9 M7 l, I! p' B
}
& ]% f( r' Y+ _! @
}
6 v+ @% H$ o! P+ A- X) x
( i$ H) _) V1 W6 t
return (maxsize);
5 }: e; R1 ^7 j; [, D- q
}
: ]9 Y' A& a T- I2 K7 z
int dram_init(void)
: F9 f! m8 \1 |1 @: Q
{
7 @7 i/ T% ]5 s. @% Z7 i7 @/ D
/* dram_init must store complete ramsize in gd->ram_size */
# Y* J( K# ^8 \) a
gd->ram_size = get_ram_size(
) u, Z0 R# Z* F1 X: U) f. [1 o
(void *)CONFIG_SYS_SDRAM_BASE,
. j, [ F5 O- C
CONFIG_MAX_RAM_BANK_SIZE);
. I* ^5 o4 d, Q5 t' a
return 0;
- u! e$ q- M: D. W" R; v( p' ^
}
# T8 ?" n, Z$ @4 i9 t
: z6 j3 \: M1 u2 S+ ]4 ]
/ Q" }9 G i) }$ L' n9 U; a3 A
, i4 J$ H7 R: Y! c3 e! A
/ |, z8 g0 @2 _, U& G4 d
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
4 d5 Y+ l: s& _" Y/ [2 C) z
# t$ X" M# o) M3 Z$ l
. b' T" x1 E1 l5 M2 U% [
8 v1 t. y( i2 W/ n
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4