嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
7 D4 z' T) M" [; f
核心板2:DDR2 256M Byte NAND FLASH 8G bit
) T6 T7 N; f( `# t( A& ?# N
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
$ V: l. \9 i; S1 @3 R6 ]
3 `- X* z+ m9 t5 ~1 U
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
2 Z3 d6 H* d7 {: F8 N) n
+ ^7 F. D+ n! _" u
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
- }6 x1 y, ?$ S2 P( k1 z5 S
/*
9 X+ @! y1 K" r9 _* h
* Check memory range for valid RAM. A simple memory test determines
; v) c6 h1 b H$ A: b: x9 T
* the actually available RAM size between addresses `base' and
% ?) w& P# ]' j: E% W& [9 _. H
* `base + maxsize'.
8 x; m/ x" z! j/ D+ y" @7 u
*/
) o. q$ O; G* |9 n! [
long get_ram_size(long *base, long maxsize)
" y2 e5 Q! v; L3 \8 r! @5 c
{
; Y: [# Q' o6 ]4 s$ d' _) i) g
volatile long *addr;
$ g7 P$ |4 J4 n2 G) U
long save[32];
- W9 e& i* P1 p
long cnt;
- ? ?" } t4 ^
long val;
: L, S$ M A& F; P1 ]$ P
long size;
+ u" O9 R' @: F% g
int i = 0;
2 N3 I. D2 |! o0 O N
$ |* I0 |! x4 ^% |( r ^
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
% G+ d/ Q3 E8 _
addr = base + cnt; /* pointer arith! */
0 r3 A9 x9 j2 O& K8 p* s
sync ();
/ |* ~' S0 C- Q7 ]1 W
save[i++] = *addr;
9 u; P4 o- K2 h; @! C* L4 N! Y
sync ();
$ P, `. q# X, O& \: H5 j7 G q* O
*addr = ~cnt;
3 y' a! K/ h# T1 d1 w! x& ^# s
}
( M. `3 e/ S# {% T/ W0 H. [+ G- @
8 ^( K- i) _& ]) @: e
addr = base;
1 s: N9 r; g3 G" \
sync ();
4 ? Z* T1 A6 X. [/ m! t
save
= *addr;
- d, j0 ?1 r5 H
sync ();
" r$ {7 d( a. J$ {% z$ B
*addr = 0;
/ R3 @# i: N- g
: [! o1 I/ G. i: k1 ^
sync ();
5 p! T; h- F! A9 J
if ((val = *addr) != 0) {
1 e/ ]0 k. U. n, h7 I
/* Restore the original data before leaving the function.
- _' y! @& v) h+ I# H2 F) S
*/
# Y% {/ a0 N* V5 i9 F' R" |
sync ();
7 ]" Y: U8 m! h% w
*addr = save
;
$ I1 V {) `. F! U2 g
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
2 {7 u. X" D2 Q/ T+ ?+ L
addr = base + cnt;
3 b$ H- P4 F4 z
sync ();
9 B& d V) @' Z2 S1 Z3 ^
*addr = save[--i];
3 N6 d; ]: f* B
}
$ {" \( i Y# P, s
return (0);
: t* l- m! X, s4 D5 J; `
}
4 \( Y7 f+ P4 Q' o/ s+ D) M/ o
R! \) m3 x6 Q" d/ g/ S/ `
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
s3 U3 }, n5 g5 H
addr = base + cnt; /* pointer arith! */
2 G0 `4 A! ~& q: d
val = *addr;
* e7 D7 k n/ p4 f7 T
*addr = save[--i];
/ Q b. Q8 {$ ?( ^5 {
if (val != ~cnt) {
. f: x+ q5 S( z$ G
size = cnt * sizeof (long);
0 V- ~9 o" q1 J# t" ^. d0 B
/* Restore the original data before leaving the function.
/ p9 W( Q5 y6 \2 Y
*/
7 ?3 @ O3 U5 `# Y
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
6 J6 @" x m) R7 o1 q
addr = base + cnt;
3 ^# F9 g/ `7 ]2 t
*addr = save[--i];
' |$ o5 x! ?+ k) M
}
3 m& Z N. I$ b$ x9 k' ~4 Z/ G% p
return (size);
$ L* A( \- |4 a/ d! n B' _
}
) O& c' g+ _8 I
}
+ K- L+ Y' t+ B3 c4 I! {7 P1 F2 m% D$ s
; i. x" i+ {% a
return (maxsize);
4 P% h5 o) \/ K! s
}
! G6 l- \! R6 E# l
int dram_init(void)
4 S/ t7 b5 @% v. x* r3 ]
{
7 d6 h1 u2 c6 G
/* dram_init must store complete ramsize in gd->ram_size */
- X) L( I; h& W$ L4 O
gd->ram_size = get_ram_size(
4 @5 y7 |3 }+ z4 {
(void *)CONFIG_SYS_SDRAM_BASE,
" w% Z/ p5 X; X K% \
CONFIG_MAX_RAM_BANK_SIZE);
) x' s1 f6 M) o1 v$ |# s$ Y
return 0;
6 q- ^3 y+ H( _; g+ O
}
: @/ E$ { x) L6 [! C+ v
9 Y5 I% A2 |5 d5 [6 r# \
% @) ?0 K: J2 s2 s
$ z# }4 z) b# Y" q* J
0 @$ n p4 d2 L9 `
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
* p* C/ _/ |9 f
, i6 O& i7 f& }8 C* C" Y
; U4 R/ x8 P7 O0 e* j& G
+ p% @3 p. G4 L5 z( U
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4