嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
1 x% k4 O& r! G* g& ^1 G
核心板2:DDR2 256M Byte NAND FLASH 8G bit
# M- Z1 o7 {4 k* C$ f7 |
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
6 R2 T4 L y& ]4 H9 ?. |3 j
3 w/ |" e& ~' `) W- Y' `; `# Z) k
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
) T$ R% E6 w9 ?/ k8 Q t
B' I- `( d1 C d* Q1 T
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
. a8 r& F) ~. a3 ~; g% o
/*
2 w# T$ ], Y0 |0 H2 V" n7 L
* Check memory range for valid RAM. A simple memory test determines
+ J' M8 {) ^) j
* the actually available RAM size between addresses `base' and
" _! W2 J0 j' l2 _8 o. g- S
* `base + maxsize'.
8 |1 w. |; Q' ]
*/
/ J( q0 Y7 P8 J: k
long get_ram_size(long *base, long maxsize)
' I2 ]$ E$ Y* o
{
5 x! `9 R* Z+ r5 a' ]% p6 [& O
volatile long *addr;
4 a9 f7 A: d" o; E! j( }" M
long save[32];
8 L0 b% Q8 Q$ T/ p0 [1 f: b9 |
long cnt;
2 k7 E; P8 ~* n+ f, W+ f8 I; w
long val;
3 e' F8 c% M r6 C. v. }% k
long size;
P4 V7 w' B2 ?8 Y+ e; B* H0 Z
int i = 0;
6 O3 I$ x4 D" M/ \/ s( D3 c
% h" A7 ]0 q R
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
3 \! ~: G* `: O! w
addr = base + cnt; /* pointer arith! */
& j& _0 ~( _( X
sync ();
9 g" O* e) f, L5 ?0 U- X) t# I2 g
save[i++] = *addr;
0 A; M9 E" ]& E( f4 P4 z" F
sync ();
6 t/ e. f& f; e
*addr = ~cnt;
& d+ }3 U# ^5 V* e; b
}
5 q1 n2 K0 `/ e6 B
/ Y' S9 q/ M( p- {% ?2 \/ Y) S" M, h7 r
addr = base;
$ a7 d' H/ @4 S$ e) f' y
sync ();
$ \3 P v7 `4 i* A `
save
= *addr;
9 E) d; p+ d' t
sync ();
+ K4 h: [% @# y4 A" f* b
*addr = 0;
; m) s4 ]3 A+ Y) d3 V
2 o! T( R# w4 Y7 R3 B8 u
sync ();
. T3 F# t) m* S+ A, @
if ((val = *addr) != 0) {
- z3 x( B" @9 V7 N% I* g, J3 ]: G
/* Restore the original data before leaving the function.
$ ?4 M, f( w: \$ y
*/
' w5 g- H/ B* g! ]# ~8 H1 _
sync ();
9 P! [( n1 Y/ {" I2 v7 d% U3 Q
*addr = save
;
# X4 r) U) P$ ~4 G' C, U
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
w$ `; o8 P, r+ i& U& J
addr = base + cnt;
' n* P' z, F6 C2 P0 k6 W
sync ();
, A: j8 y) Z: K
*addr = save[--i];
# J0 V9 x# R9 o; H
}
; b) s" \* Y1 a/ Q& P9 V0 b
return (0);
; v8 l+ j' Q8 O2 i# V
}
; m) c. o$ l0 j8 S; ?1 `
- r# r3 G5 |" {0 o% [" j. n- H: m; b
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
5 ~! g- V+ _$ L/ Y7 s
addr = base + cnt; /* pointer arith! */
% [% p$ n5 \. {3 p5 M
val = *addr;
! a; R+ i" ~+ b8 v
*addr = save[--i];
5 v ?, }4 x, E, j
if (val != ~cnt) {
: z+ S6 ?: B- C9 e# q, e( F
size = cnt * sizeof (long);
1 S3 w$ B) C6 @7 a
/* Restore the original data before leaving the function.
* T" o& _5 U5 w
*/
& [2 a$ d+ J' s) R% Z/ r( A
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
% K3 j+ @& u3 `. \7 M
addr = base + cnt;
4 ?; t6 t4 w$ l& k
*addr = save[--i];
9 N( v! {3 j7 b [; {4 W) E; L
}
: n) ~0 {2 |- M9 M8 T* F6 R
return (size);
- C! A( O6 e: n
}
1 k# F* I. }& O: L+ ^
}
6 I, i! K/ `- m/ u+ J5 n
& p, t, ]0 z8 D8 n
return (maxsize);
& p- }) ]5 E2 ~4 a" A+ H5 z/ c
}
7 q" z, K" o0 v, Z, B; e
int dram_init(void)
; v/ X# y/ K. _: z$ Y- m- G
{
( Y: [& `9 @5 p: x
/* dram_init must store complete ramsize in gd->ram_size */
: F4 n( V8 D+ M
gd->ram_size = get_ram_size(
5 G( x1 k4 W! ?# O% G2 i8 e' e
(void *)CONFIG_SYS_SDRAM_BASE,
4 R2 M( o# J2 ^5 v7 W
CONFIG_MAX_RAM_BANK_SIZE);
3 v A0 t' P0 B3 ^# S
return 0;
$ ], h p$ x3 W) N8 o' P
}
! c y1 C6 L9 [
/ a' K2 Y: r/ |/ p, H
L* A3 W% ~! Z" l
- R `8 Q* C' z( _
4 E6 ?: D0 j3 w" ^. `0 \9 v
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
$ q. m% x4 G* S
) X9 F9 U* c2 _& V
# b. _- r: I3 F
' N! p6 {$ ?- X, l- }& E
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4