嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
& E. G' h. C- }2 \
核心板2:DDR2 256M Byte NAND FLASH 8G bit
: L0 c/ k+ p3 e
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
; j+ L7 T6 D$ u4 ? f; U
- {$ r' q# E3 R1 g2 F# R
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
7 }$ l% \! B7 g2 I
: D* }+ _' b6 P
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
4 j# U7 [$ a. g% {
/*
' X" o9 I. d& k
* Check memory range for valid RAM. A simple memory test determines
* R/ N7 J _9 a- c7 B0 ^2 q
* the actually available RAM size between addresses `base' and
- W' T6 U" v% ?( H( d; u! @% I4 c8 i
* `base + maxsize'.
) v( h; \* m/ _& Z- c0 T* Z* m
*/
2 Z9 h- {+ j m# G6 i$ {7 _
long get_ram_size(long *base, long maxsize)
3 h+ Z2 i: `" F. O. P
{
) D4 _# m% _. j; a8 |, ]
volatile long *addr;
" `, T. j0 f* h1 j# }
long save[32];
1 E( C1 D; K6 b
long cnt;
. [+ p: G* a1 Z, Y7 | Q# x n+ a7 l
long val;
; f+ }% {* O3 U! w8 m* S0 @' U, n
long size;
5 |& [8 [% G/ N& ]. V1 _. j; Y
int i = 0;
9 u/ s/ t) m" F2 ]+ i- A; D
3 W5 Z* Q6 ]) m- m" z. F
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
$ n W e; G2 `& m9 s& O/ k2 K. J
addr = base + cnt; /* pointer arith! */
% A/ g* v6 I3 P# r) e* n4 S8 y
sync ();
7 M7 y. f) g' v0 X
save[i++] = *addr;
' {9 L( E% H+ k" J, z7 Q/ H; D
sync ();
% V5 f/ A4 H( C5 `0 m
*addr = ~cnt;
5 d0 J5 y( b# _/ o* r8 L
}
6 Y' c4 Z! d2 B! g' j
) e/ Q+ r$ C& a
addr = base;
* L' C/ r2 l; I& }1 |' j" B# B
sync ();
+ a6 x- ]" G2 ]* m6 k8 H d
save
= *addr;
& }1 @0 Y6 m O( v" ?3 F& q0 {8 V5 l
sync ();
8 t5 c4 z9 @% O, C" T' h
*addr = 0;
% _; ^4 f7 d" h7 C6 [! n
% Q2 _2 U& d2 w+ ~/ A1 B1 r
sync ();
( o1 `: z! U5 Q3 j: h& {
if ((val = *addr) != 0) {
$ A) P, _2 S5 B4 z) b
/* Restore the original data before leaving the function.
8 o; ~/ J! r0 h4 f
*/
8 ? j4 f& z+ T8 l" Y3 R& f( D
sync ();
. ~. E) A& c) S& d8 F9 g# R8 c" Y
*addr = save
;
r! |5 d) _, A# y+ q3 | }+ [/ V
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
3 i" U3 @; {/ Y
addr = base + cnt;
1 G- L) j: ? K+ ` `) X
sync ();
1 W, R, X6 r y9 s9 \1 f& ~, o
*addr = save[--i];
( y+ ?* P1 E, E, ^5 ^9 W' C3 T
}
2 k# S0 ?1 }5 |$ f) N
return (0);
1 M% ?/ c) f! p5 n
}
' G: [9 i, Q5 Z/ `
0 G# A* U) o4 v3 c9 n0 ?8 [; s) c
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
$ l5 ^! e6 l% w& t2 Z% b3 f& v |& s5 G5 m
addr = base + cnt; /* pointer arith! */
' _! |% E/ `; `7 F) }
val = *addr;
$ \/ y2 t: L2 K0 s- x& K
*addr = save[--i];
( M3 g; P- z1 H9 Q0 p4 }% i" [6 f# p- P
if (val != ~cnt) {
`1 L; O; q# o% f' u+ v7 H
size = cnt * sizeof (long);
7 C- a" A- q) a6 Z- v& X% @- n. w
/* Restore the original data before leaving the function.
! y. }2 ^- V G/ F/ F
*/
! X4 a1 p ^* ^: d; h8 \
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
; z4 \ t, h" J' \9 Q" k7 L3 c
addr = base + cnt;
1 G) w1 N9 e. i" b- g% `& b& T& p
*addr = save[--i];
1 |+ ]( |+ V# H v
}
9 D- ?0 f9 J! B" m3 ?% o4 l
return (size);
1 ]5 w! e) C* v+ X
}
/ }( B9 ^0 V9 k! N
}
" W0 W7 z& v! I. E* T
7 G0 i1 z; w4 T @: `' u: V- `" I. B
return (maxsize);
s8 f7 l8 i% d6 ^
}
! G+ Y) E( A- S& u% ], F
int dram_init(void)
* j L8 q! _+ a' ]" j+ b: H# D4 H
{
" C" l# M6 _7 L
/* dram_init must store complete ramsize in gd->ram_size */
) ~. M( G1 K' h$ ^" x9 v- B
gd->ram_size = get_ram_size(
b' w3 k7 S$ \2 W( n! h% g& B# u9 n# a
(void *)CONFIG_SYS_SDRAM_BASE,
) ?! v0 c( G* e. w0 Q X
CONFIG_MAX_RAM_BANK_SIZE);
: z3 J" p1 {$ w* s) B# i6 o
return 0;
3 X. y( N* v# [, h- i- ~8 H
}
5 y9 ^: }9 U* L% \; @
7 }% O* O" p( z v' C1 n$ b0 f
7 C5 J! g' R2 p+ ^! v% E* s
( i. x# Q+ H) \7 P! _: D6 e: @5 M
$ P7 ~ c! p8 p; [7 ~2 d
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
+ ~$ j% v+ c! I, [
0 S/ @" `# z+ E2 N0 z4 q: v
8 r- B: I6 ]8 d9 ?& I7 c
& y, S0 G7 b- H0 E
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4