1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
--- git/board/toradex/common/board.c 2012-06-02 21:16:34.000000000 +0200
+++ git/board/toradex/common/board.c 2012-06-03 19:04:03.000000000 +0200
@@ -263,9 +271,7 @@
};
#ifdef BOARD_LATE_INIT
-#ifdef CONFIG_TRDX_CFG_BLOCK_OFFSET
-static unsigned char *config_block;
-#endif
+static unsigned char *config_block = NULL;
#endif
#ifdef CONFIG_HW_WATCHDOG
@@ -504,7 +510,8 @@
#ifdef BOARD_LATE_INIT
int board_late_init(void)
{
- char env_str[64];
+ char env_str[256 ];
+
#ifdef CONFIG_TRDX_CFG_BLOCK_OFFSET
int do_saveenv = 0;
char *addr_str, *end;
@@ -517,6 +524,9 @@
unsigned char toradex_oui[3] = { 0x00, 0x14, 0x2d };
int valid = 0;
+ unsigned int offset;
+ int ret;
+
/* Allocate RAM area for config block */
config_block = malloc(size);
if (!config_block) {
@@ -525,9 +535,6 @@
}
for (i = 0; i < 2; i++) {
- unsigned int offset;
- int ret;
-
if (i == 0)
offset = CONFIG_TRDX_CFG_BLOCK_OFFSET;
else
@@ -699,6 +706,10 @@
unsigned short major = 0, minor = 0, release = 0;
size_t size = 4096;
+ if(config_block == NULL) {
+ return 0;
+ }
+
/* Parse revision information in config block */
for (i = 0; i < (size - 8); i++) {
if (config_block[i] == 0x02 && config_block[i+1] == 0x40 &&
@@ -731,6 +742,12 @@
unsigned int serial = 0;
unsigned int serial_offset = 11;
+ if(config_block == NULL) {
+ serialnr->low = 0;
+ serialnr->high = 0;
+ return;
+ }
+
/* Get MAC address from config block */
memcpy(&serial, config_block + serial_offset, 3);
serial = ntohl(serial);
|