嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
* E9 c: J5 d! C8 v
核心板2:DDR2 256M Byte NAND FLASH 8G bit
3 U+ x3 x; y+ E" X7 p+ X
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
! W, I+ c$ H8 j3 m. {% `
1 W; d9 a6 `1 i e f8 u
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
* E* G" n4 K4 H1 i/ D
6 F* [ `' D# t, r. I! i
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
) I" G% ?9 X& q6 {) j- \
/*
- L: s. _# M* L& b$ V/ d* X
* Check memory range for valid RAM. A simple memory test determines
% n3 `$ `" d' I) x) l4 Q% n: Q
* the actually available RAM size between addresses `base' and
2 \( L2 J F# a8 r! `, w( g- A
* `base + maxsize'.
. g4 b! J$ a0 T3 H" @5 X
*/
6 m X4 ~ B% T
long get_ram_size(long *base, long maxsize)
' v$ k0 |- B& X1 A7 R8 `. z: G' [2 w
{
- k8 u9 O* g9 x: ^$ r) L+ h
volatile long *addr;
! h# [$ a7 M+ P, i0 z1 `# V. s
long save[32];
6 ]! P# f; {4 _2 C! E$ i {" P
long cnt;
$ _0 {2 j, e2 a a/ T( v: N
long val;
! `: E# o0 Q: ]6 T- H$ n; Z* [1 O
long size;
) ~5 {+ P+ I+ \! f+ F& R/ D
int i = 0;
. w. L7 J) W- d2 j+ M, l
) t5 n. K. `( Y4 D+ s2 n* r
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
" J }) R# |+ C- w: m, ?
addr = base + cnt; /* pointer arith! */
' F1 M; I! ~! g/ S( ^
sync ();
: G% s* s3 Z. D
save[i++] = *addr;
! y; D% N' S* N! y3 H: u
sync ();
" i& S3 S: b0 a
*addr = ~cnt;
1 D" w! ?. {0 h* Y' K8 \- n0 B2 P
}
+ ?/ T: U% g9 J, J- |0 }
" h. ]+ I/ e. `! e% C' v
addr = base;
/ G6 i! J1 E2 `7 @' R/ U7 W! W8 p
sync ();
# l9 B& |" @9 ?% I$ x" v
save
= *addr;
, ]$ r1 ?4 b0 C' Y/ ^8 d
sync ();
0 u/ f- B I' n0 U6 I) X* [' a
*addr = 0;
7 V4 G' R1 Q. c, s
- Z9 `: p" b0 U5 r2 b6 K; t. `
sync ();
2 k Q3 d, B4 C# G) I7 n8 s" Q2 ~0 N
if ((val = *addr) != 0) {
1 j5 \4 e0 I) v; V. w- \
/* Restore the original data before leaving the function.
5 A/ Z+ N5 v- j# r$ G
*/
% l J9 k7 w+ [3 @. A$ a
sync ();
& I+ V* R1 ~. S' R/ @/ k
*addr = save
;
, \4 b$ `0 N" d
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
+ k5 A6 z9 I9 t7 r! z
addr = base + cnt;
: y( ~" l9 `4 E( I
sync ();
7 J+ Z+ ~" z& ` ?$ ?/ d' T
*addr = save[--i];
" E5 K3 d% R* P
}
4 A5 [' B) n, _
return (0);
! n0 D6 g* V. i: F& Y! f+ c) f
}
) A* \* ^, Q+ w, Z. C
3 _. V6 |% B( G9 H! h
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
* Q: Z3 o' I1 L3 z+ v
addr = base + cnt; /* pointer arith! */
3 Q O/ O* ~8 U, Y, y
val = *addr;
7 U) o/ j: v$ E& A' ^$ p& C
*addr = save[--i];
& |# u1 e- _ B1 X" O& w; d2 L
if (val != ~cnt) {
0 L5 o$ i9 E C
size = cnt * sizeof (long);
# }7 [$ M) O% `% W3 Y
/* Restore the original data before leaving the function.
; I( K4 w! P& {; ~( P2 O
*/
. x1 u H! O: V. ?, S, m/ Q
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
& h( ], K6 a; f3 z h( a6 }
addr = base + cnt;
- N S1 F5 b# d5 Q& W
*addr = save[--i];
: e; L" o3 S4 s
}
' Q! p2 W2 @% k: Z% A0 Z8 n$ `
return (size);
, ?. k1 d1 s o( Z4 C& t
}
6 g; G# X8 V3 z* o1 Z! H* J
}
& \" ` n7 X' \3 U
+ @% |" }1 G- ?4 T2 f
return (maxsize);
" P$ K$ f" f5 V, s
}
4 W! Z& \+ |0 w6 A5 S6 q- n' q6 i
int dram_init(void)
- V) e1 X1 y; C
{
U$ x# h/ z {+ e4 K
/* dram_init must store complete ramsize in gd->ram_size */
/ P0 T H' n9 ?0 r7 o4 }. `
gd->ram_size = get_ram_size(
3 T* [6 D) _& g& u- t/ F
(void *)CONFIG_SYS_SDRAM_BASE,
. F; D2 v2 n6 l3 ]
CONFIG_MAX_RAM_BANK_SIZE);
: e, u/ |* R! R6 v7 e
return 0;
# d7 e( ~# s z6 n
}
# u9 t* }: J; i) N
2 C7 ^5 E" h" G& v) M
5 L a0 H2 Q! @9 Z& z! t$ O
" q/ L: e$ X" B
* v3 e$ d ]+ E: S+ D2 n' w: |
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
# a7 j' K; A$ O5 q. A G
$ z2 @$ z. @) r# S6 |
) s6 e7 k" F# @" c7 z, A
# x, P( q: o3 {
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4