summaryrefslogtreecommitdiffstats
path: root/recipes/bootstream/fix-oe-build.patch
blob: c06756daaf3d4d320a35a79ee97d4c37250b001e (plain)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
diff -ur bootstream-1.0-stock/Makefile bootstream-1.0/Makefile
--- bootstream-1.0-stock/Makefile	2010-08-18 13:43:44.386637400 -0700
+++ bootstream-1.0/Makefile	2010-08-18 13:43:27.870626729 -0700
@@ -1,64 +1,16 @@
 # $Id: Makefile 7554 2009-04-30 19:44:17Z scross $
 # source build makefile for bootstream bootloader
 
-include ../config/config.mk
+CFLAGS += -DCHUMBY_CONFIGNAME=\"falconwing\" -DCHUMBY_CONFIGNAME_falconwing
 
-ELFTOSB2_DIR=elftosb2
-ELFTOSB2_BINARIES=elftosb2
-ELFTOSB2_SRC_BINARIES=$(addprefix $(ELFTOSB2_DIR)/,$(ELFTOSB2_BINARIES))
-ELFTOSB2_SOURCES=$(wildcard $(ELFTOSB2_DIR)/*.c $(ELFTOSB2_DIR)/*.h)
-
-SRC_BINARIES=$(ELFTOSB2_SRC_BINARIES)
-HOST_BINARIES=$(ELFTOSB2_BINARIES)
-
-CFLAGS += -DCHUMBY_CONFIGNAME=\"$(CONFIGNAME)\" -DCHUMBY_CONFIGNAME_$(CONFIGNAME)
-
-all: $(SRC_BINARIES) $(HOST_BINARIES) \
-	chumby_factory/chumby_factory chumby_stub/chumby_stub chumby_boot/chumby_boot
-
-
-install: $(SRC_BINARIES) $(HOST_BINARIES) \
-	.src_binaries .chumby-boot .factory-image .chumby-stub
-    #.u-boot-image
-
-chumby_boot/chumby_boot:
-	$(MAKE) -C chumby_boot CROSS_COMPILE=$(TARGET)- LINUX_DIR=$(LINUX_DIR)
-
-chumby_stub/chumby_stub:
-	$(MAKE) -C chumby_stub CROSS_COMPILE=$(TARGET)- LINUX_DIR=$(LINUX_DIR)
-
-chumby_factory/chumby_factory:
-	$(MAKE) -C chumby_factory CROSS_COMPILE=$(TARGET)- LINUX_DIR=$(LINUX_DIR)
-
-
-.factory-image: $(SRC_BINARIES)
-	elftosb2/elftosb2 -z -c ../config/falconwing_factory_sb.db \
-            -o $(INSTALL_DIR)/bootstream-factory.bin
-
-.chumby-boot: $(SRC_BINARIES)
-	cp images/chumby_boot.rom $(INSTALL_DIR)/chumby_boot.bin
-
-.chumby-stub: $(SRC_BINARIES)
-	elftosb2/elftosb2 -c ../config/falconwing_chumby_sb.db \
-            -o $(INSTALL_DIR)/bootstream-chumby.bin
-
-.u-boot-image: $(SRC_BINARIES)
-	elftosb2/elftosb2 -c ../config/falconwing_uboot_sb.db \
-            -o $(INSTALL_DIR)/falconwing_uboot.sb
-
-
-.src_binaries:
-	@echo "Copying src bianries"
-	mkdir -p $(INSTALL_DIR)/host
-	cp --preserve --no-dereference $(SRC_BINARIES) $(INSTALL_DIR)/host/
+all:
+	$(MAKE) -C chumby_factory
+	$(MAKE) -C chumby_stub
+	$(MAKE) -C chumby_boot
+	gcc config_util.cpp -o config_util -lstdc++
 
 clean:
-	-rm -f $(HOST_BINARIES) $(SRC_BINARIES)
-	$(MAKE) -C $(ELFTOSB2_DIR) clean
-
-$(ELFTOSB2_SRC_BINARIES):
-	$(MAKE) -C $(ELFTOSB2_DIR)
-
-../output/$(TARGET)-$(CNPLATFORM):
-	@echo "Creating directory: $@"
-	-mkdir -p $@
+	$(MAKE) -C chumby_factory clean
+	$(MAKE) -C chumby_stub clean
+	$(MAKE) -C chumby_boot clean
+	rm -f config_util
diff -ur bootstream-1.0-stock/chumby_boot/Makefile bootstream-1.0/chumby_boot/Makefile
--- bootstream-1.0-stock/chumby_boot/Makefile	2010-08-18 13:43:44.386637400 -0700
+++ bootstream-1.0/chumby_boot/Makefile	2010-08-18 13:43:27.874670886 -0700
@@ -7,24 +7,14 @@
 # Linker script 
 BASE_ADDR	?= 0x00002000
 BOOT_LAYOUT_IN	= $(SRCDIR)/chumby_boot.ld.in
-BOOT_LAYOUT_OUT	= $(OUTPUTDIR)/chumby_boot.ld
+BOOT_LAYOUT_OUT    = ../output/chumby_boot.ld
 
 
 # Output ELF image
-CHUMBY_BOOT	= $(OUTPUTDIR)/../../images/chumby_boot
+CHUMBY_BOOT    = ../output/chumby_boot
 
 # Output binary image
-CHUMBY_BOOT_ROM	= $(OUTPUTDIR)/../../images/chumby_boot.rom
-
-CROSS_COMPILE ?= arm-linux-
-
-AS	= $(CROSS_COMPILE)as
-CC	= $(CROSS_COMPILE)gcc
-LD	= $(CROSS_COMPILE)ld
-CPP	= $(CROSS_COMPILE)cpp
-STRIP	= $(CROSS_COMPILE)strip
-OBJCOPY	= $(CROSS_COMPILE)objcopy
-OBJDUMP	= $(CROSS_COMPILE)objdump
+CHUMBY_BOOT_ROM    = ../output/chumby_boot.rom
 
 LIBGCCDIR = $(dir $(shell $(CC) -print-libgcc-file-name))
 CFLAGS 	= -Wall -I$(INCLUDEDIR) -I$(LINUX_DIR)/include -fno-builtin -O0 -nostdinc
@@ -91,5 +81,5 @@
 	@nm -n $@ > $@.map
 
 $(BOOT_LAYOUT_OUT): $(BOOT_LAYOUT_IN)
-	$(CPP) -P -DBASE_ADDR=$(BASE_ADDR) -o $@ $<
+	cpp -P -DBASE_ADDR=$(BASE_ADDR) -o $@ $<
 
diff -ur bootstream-1.0-stock/chumby_boot/src/serial.c bootstream-1.0/chumby_boot/src/serial.c
--- bootstream-1.0-stock/chumby_boot/src/serial.c	2010-08-18 13:43:44.386637400 -0700
+++ bootstream-1.0/chumby_boot/src/serial.c	2010-08-18 13:43:27.874670886 -0700
@@ -171,10 +171,10 @@
     return data;
 }
 
-static char hex[] = "0123456789abcdef";
 
 void serial_puthex(u32 c) {
     int i;
+    char hex[] = "0123456789abcdef";
     serial_puts("0x");
     for(i=7; i>=0; i--)
         serial_putc(hex[(c>>(4*i))&0x0f]);
diff -ur bootstream-1.0-stock/chumby_boot/src/shell.c bootstream-1.0/chumby_boot/src/shell.c
--- bootstream-1.0-stock/chumby_boot/src/shell.c	2010-08-18 13:43:44.386637400 -0700
+++ bootstream-1.0/chumby_boot/src/shell.c	2010-08-18 15:12:45.138607841 -0700
@@ -48,8 +48,8 @@
     "shell\n"
 
     // Run the watchdogtimer, set to reboot the device in 20 seconds.
-    "regutil -w HW_RTC_WATCHDOG 0x00004e20\n"
-    "regutil -w HW_RTC_CTRL_SET 0x00000010\n"
+    //"regutil -w HW_RTC_WATCHDOG 0x00004e20\n"
+    //"regutil -w HW_RTC_CTRL_SET 0x00000010\n"
 
     // Prioritize screen DMA over other DMA.  This fixes video tearing issues.
     // Priority is: AXI0, AHB2, AHB1, AHB3
@@ -84,7 +84,7 @@
 
     // Set up the Linux tags, pass the command-line arguments, and run the
     // Linux kernel, located at address 0x40008000.
-    "linux 0x40008000 \"console=ttyAM0,115200 init=/linuxrc root=/dev/mmcblk0p2 rootfstype=ext3 ro rootwait chumbyrev=** ssp1=mmc sysrq_always_enabled logo.brand=" BRAND_PLACEHOLDER "\"\n",
+    "linux 0x40008000 \"console=ttyAM0,115200 root=/dev/mmcblk0p2 rw rootwait chumbyrev=** ssp1=mmc sysrq_always_enabled logo.brand=" BRAND_PLACEHOLDER "\"\n",
 
 ////////////////////////////////////////////////
 
@@ -97,7 +97,7 @@
 
     // Set up the Linux tags, pass the command-line arguments, and run the
     // Linux kernel, located at address 0x40008000.
-    "linux 0x40008000 \"console=ttyAM0,115200 init=/linuxrc root=/dev/mmcblk0p2 rootfstype=ext3 ro rootwait chumbyrev=** ssp1=mmc sysrq_always_enabled partition=recovery logo.brand=" BRAND_PLACEHOLDER "\"\n",
+    "linux 0x40008000 \"console=ttyAM0,115200 root=/dev/mmcblk0p2 rw rootwait chumbyrev=** ssp1=mmc sysrq_always_enabled partition=recovery logo.brand=" BRAND_PLACEHOLDER "\"\n",
 
 ////////////////////////////////////////////////
 
@@ -350,8 +350,8 @@
 }
 
 char **shell_line_to_argv(int argc, char *line) {
-    static char *argv[80];
     int i;
+	static char *argv[10];
     for(i=0; i<=argc; i++) {
         argv[i] = line;
         while(*line)
diff -ur bootstream-1.0-stock/chumby_boot/src/shell_funcs.c bootstream-1.0/chumby_boot/src/shell_funcs.c
--- bootstream-1.0-stock/chumby_boot/src/shell_funcs.c	2010-08-18 13:43:44.386637400 -0700
+++ bootstream-1.0/chumby_boot/src/shell_funcs.c	2010-08-18 15:11:45.984011892 -0700
@@ -42,6 +42,7 @@
 
 	value = eeprom_read(addr, reg);
 	STR("Value: "), HEX(value), STR("\n");
+	return 0;
 }
 
 
@@ -244,7 +245,7 @@
 
 
 
-static int sd_initted = 0;
+int sd_initted;
 char *sd_pmem;
 
 static int my_sd_stop() {
@@ -256,27 +257,28 @@
 
 
 static int my_sd_init() {
-    static rom_BootInit_t init;// = (rom_BootInit_t *)0x40A10000;
+    rom_BootInit_t init;
+
     if(sd_initted) {
         int result;
         result = my_sd_stop();
         if(result) {
-            STR("Error!  Couldn't reset SD.\n");
-            return 0;
+            STR("Error!  Couldn't reset SD: "), HEX(result), STR("\n");
+            return 1;
         }
+		sd_initted = 0;
     }
+
     if(!sd_initted) {
         int result;
         mdelay(10);
         init.size = PMEM_SIZE;
-        init.pMem = sd_pmem;   // Allocated on stack in main().
+        init.pMem = 16384;
         init.mode = 9;         // Set to SSP_PORT_1.
         memset(sd_pmem, 0, PMEM_SIZE);
-        result = sd_init(&init);
-        if(!result)
-            sd_initted = 1;
-        else
+        if((result = sd_init(&init)))
             return result;
+		sd_initted = 1;
     }
     return 0;
 }
@@ -318,17 +320,18 @@
     while(bytes > 0) {
         int chunks_to_read, chunk;
         int read_tries = 0;
+		chunks_to_read = bytes/sizeof(chunk_t);
 
 
         // Perform the read.
-//            STR("Going to try to read "), INT(chunks_to_read), STR(" chunks\n");
+//        STR("Going to try to read "), INT(chunks_to_read), STR(" chunks\n");
         while(read_tries < 1000) {
             read_tries++;
             chunks_to_read = bytes/sizeof(chunk_t);
             chunks = sd_next(&chunks_to_read);
             if(!chunks_to_read) {
-//                    STR("Read 0 chunks.  Trying again...\n");
-//                    mdelay(1000*read_tries);  // XXX need to tune this!
+                STR("Read 0 chunks.  Trying again...\n");
+                mdelay(10*read_tries);  // XXX need to tune this!
                 continue;
             }
             else
@@ -339,15 +342,15 @@
             STR("  Aborting read.\n");
             return 0;
         }
-//            else if(read_tries)
-//                STR("Delayed "), INT(read_tries), STR(" times.\n");
+//        else if(read_tries)
+//            STR("Delayed "), INT(read_tries), STR(" times.\n");
 
         if(chunks_to_read < 0) {
             STR("Error while reading bytes: "), HEX(chunks_to_read), STR("\n");
             return 0;
         }
-//            else
-//                STR("Successfully read "), INT(chunks_to_read), STR(" chunks.\n");
+//        else
+//            STR("Successfully read "), INT(chunks_to_read), STR(" chunks.\n");
 
         // Copy over each of the chunks that was read.
         for(chunk=0; chunk<chunks_to_read; chunk++) {
@@ -367,9 +370,13 @@
 int sd_cfg_loaded = 0;
 static int config_block_load() {
     if(!sd_cfg_loaded) {
-        sd_cfg = (char *)0x45A00000;
-        if(real_load(CFG_OFFSET, (char *)sd_cfg, sizeof(struct config_area)))
-            return 0;
+        sd_cfg = (struct config_area *)0x45A00000;
+        if(real_load(CFG_OFFSET, (char *)sd_cfg, sizeof(struct config_area))) {
+			STR("real_load() returned an error.\n");
+            return 1;
+		}
+		//STR("Dump of config area:\n");
+		//HEXDUMP((unsigned char *)sd_cfg, sizeof(struct config_area));
         sd_cfg_loaded = 1;
     }
     return !sd_cfg_loaded;
@@ -773,14 +780,14 @@
     return 0;
 }
 
-static char hex[] = "0123456789abcdef";
 
 // str must be at least 11 bytes long
 void str_puthex(u32 c, char *str) {
-  int i, j;
+    int i, j;
+    char hex[] = "0123456789abcdef";
     str[0] = '0'; str[1] = 'x';
     for(i=7, j = 0; i>=0; i--, j++)
-      str[2+j] = hex[(c>>(4*i))&0x0f];
+        str[2+j] = hex[(c>>(4*i))&0x0f];
     
     str[10] = '\n';
     str[11] = '\0';
@@ -1058,6 +1065,7 @@
 
 struct shell_command *shell_funcs_init() {
     struct shell_command *cmd_fixup = cmds;
+	sd_initted = 0;
 
     // Fixup the cmd array by adding the base_address value to each pointer.
     while(cmd_fixup->name) {
diff -ur bootstream-1.0-stock/chumby_factory/Makefile bootstream-1.0/chumby_factory/Makefile
--- bootstream-1.0-stock/chumby_factory/Makefile	2010-08-18 13:43:44.386637400 -0700
+++ bootstream-1.0/chumby_factory/Makefile	2010-08-18 13:43:27.874670886 -0700
@@ -1,30 +1,20 @@
 CURRENTDIR	= .
 SRCDIR		= $(CURRENTDIR)/src
-OUTPUTDIR	= $(CURRENTDIR)/output
+OUTPUTDIR	= ../output
 
 INCLUDEDIR	= $(CURRENTDIR)/include
 
 # Linker script 
 BASE_ADDR	?= 0x00002000
 BOOT_LAYOUT_IN	= $(SRCDIR)/chumby_factory.ld.in
-BOOT_LAYOUT_OUT	= $(OUTPUTDIR)/chumby_factory.ld
+BOOT_LAYOUT_OUT	= ../output/chumby_factory.ld
 
 
 # Output ELF image
-CHUMBY_FACTORY	= $(OUTPUTDIR)/../../images/chumby_factory
+CHUMBY_FACTORY	= ../output/chumby_factory
 
 # Output binary image
-CHUMBY_FACTORY_ROM	= $(OUTPUTDIR)/../../images/chumby_factory.rom
-
-CROSS_COMPILE ?= arm-linux-
-
-AS	= $(CROSS_COMPILE)as
-CC	= $(CROSS_COMPILE)gcc
-LD	= $(CROSS_COMPILE)ld
-CPP	= $(CROSS_COMPILE)cpp
-STRIP	= $(CROSS_COMPILE)strip
-OBJCOPY	= $(CROSS_COMPILE)objcopy
-OBJDUMP	= $(CROSS_COMPILE)objdump
+CHUMBY_FACTORY_ROM	= ../output/chumby_factory.rom
 
 LIBGCCDIR = $(dir $(shell $(CC) -print-libgcc-file-name))
 CFLAGS 	= -Wall -I$(INCLUDEDIR) -I$(LINUX_DIR)/include -nostdinc -fno-builtin -O
@@ -90,5 +80,5 @@
 	@nm -n $@ > $@.map
 
 $(BOOT_LAYOUT_OUT): $(BOOT_LAYOUT_IN)
-	$(CPP) -P -DBASE_ADDR=$(BASE_ADDR) -o $@ $<
+	cpp -P -DBASE_ADDR=$(BASE_ADDR) -o $@ $<
 
diff -ur bootstream-1.0-stock/chumby_stub/Makefile bootstream-1.0/chumby_stub/Makefile
--- bootstream-1.0-stock/chumby_stub/Makefile	2010-08-18 13:43:44.386637400 -0700
+++ bootstream-1.0/chumby_stub/Makefile	2010-08-18 13:43:27.874670886 -0700
@@ -1,30 +1,20 @@
 CURRENTDIR	= .
 SRCDIR		= $(CURRENTDIR)/src
-OUTPUTDIR	= $(CURRENTDIR)/output
+OUTPUTDIR	= ../output
 
 INCLUDEDIR	= $(CURRENTDIR)/include
 
 # Linker script 
 BASE_ADDR	?= 0x00002000
 BOOT_LAYOUT_IN	= $(SRCDIR)/chumby_stub.ld.in
-BOOT_LAYOUT_OUT	= $(OUTPUTDIR)/chumby_stub.ld
+BOOT_LAYOUT_OUT	= ../output/chumby_stub.ld
 
 
 # Output ELF image
-CHUMBY_STUB	= $(OUTPUTDIR)/../../images/chumby_stub
+CHUMBY_STUB	= ../images/chumby_stub
 
 # Output binary image
-CHUMBY_STUB_ROM	= $(OUTPUTDIR)/../../images/chumby_stub.rom
-
-CROSS_COMPILE ?= arm-linux-
-
-AS	= $(CROSS_COMPILE)as
-CC	= $(CROSS_COMPILE)gcc
-LD	= $(CROSS_COMPILE)ld
-CPP	= $(CROSS_COMPILE)cpp
-STRIP	= $(CROSS_COMPILE)strip
-OBJCOPY	= $(CROSS_COMPILE)objcopy
-OBJDUMP	= $(CROSS_COMPILE)objdump
+CHUMBY_STUB_ROM	= ../images/chumby_stub.rom
 
 LIBGCCDIR = $(dir $(shell $(CC) -print-libgcc-file-name))
 CFLAGS 	= -Wall -I$(INCLUDEDIR) -I$(LINUX_DIR)/include -nostdinc -fno-builtin -Os
@@ -90,5 +80,5 @@
 	@nm -n $@ > $@.map
 
 $(BOOT_LAYOUT_OUT): $(BOOT_LAYOUT_IN)
-	$(CPP) -P -DBASE_ADDR=$(BASE_ADDR) -o $@ $<
+	cpp -P -DBASE_ADDR=$(BASE_ADDR) -o $@ $<