diff options
author | Björn Stenberg <bjorn@haxx.se> | 2002-03-27 11:21:50 +0000 |
---|---|---|
committer | Björn Stenberg <bjorn@haxx.se> | 2002-03-27 11:21:50 +0000 |
commit | d6023a7adee17628e0ec4bad02e10199c1165bdb (patch) | |
tree | ff133f4507b5c388094401093c224fff22215395 /www/example | |
parent | e8c6b2052b11d85b8836a0c07e493b9562dd11eb (diff) | |
download | rockbox-d6023a7adee17628e0ec4bad02e10199c1165bdb.tar.gz rockbox-d6023a7adee17628e0ec4bad02e10199c1165bdb.zip |
Initial version
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@34 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'www/example')
-rw-r--r-- | www/example/Makefile | 40 | ||||
-rw-r--r-- | www/example/README | 7 | ||||
-rw-r--r-- | www/example/app.lds | 23 | ||||
-rw-r--r-- | www/example/main.c | 102 | ||||
-rw-r--r-- | www/example/start.s | 23 |
5 files changed, 195 insertions, 0 deletions
diff --git a/www/example/Makefile b/www/example/Makefile new file mode 100644 index 0000000000..7d8f2fdefd --- /dev/null +++ b/www/example/Makefile | |||
@@ -0,0 +1,40 @@ | |||
1 | HPATH = /usr/local/sh-gcc/bin | ||
2 | CC = $(HPATH)/sh-elf-gcc | ||
3 | LD = $(HPATH)/sh-elf-ld | ||
4 | AR = $(HPATH)/sh-elf-ar | ||
5 | AS = $(HPATH)/sh-elf-as | ||
6 | OC = $(HPATH)/sh-elf-objcopy | ||
7 | |||
8 | INCLUDES=-I. | ||
9 | |||
10 | CFLAGS = -Os -Wall -m1 -nostdlib -Wstrict-prototypes -fomit-frame-pointer -fschedule-insns $(INCLUDES) | ||
11 | AFLAGS += -small -relax | ||
12 | |||
13 | OBJS= start.o main.o | ||
14 | |||
15 | %.o: %.s | ||
16 | $(CC) -o $@ $(CFLAGS) $(INCLUDES) $(DEFS) -c $< | ||
17 | |||
18 | |||
19 | all : archos.mod # archos.asm | ||
20 | |||
21 | main.o: main.c | ||
22 | |||
23 | archos.elf : $(OBJS) app.lds | ||
24 | $(CC) -nostdlib -o archos.elf $(OBJS) -lgcc -Tapp.lds -Wl,-Map,archos.map | ||
25 | |||
26 | archos.bin : archos.elf | ||
27 | $(OC) -O binary archos.elf archos.bin | ||
28 | |||
29 | archos.asm: archos.bin | ||
30 | sh2d -sh1 archos.bin > archos.asm | ||
31 | |||
32 | archos.mod : archos.bin | ||
33 | scramble archos.bin archos.mod | ||
34 | |||
35 | dist: | ||
36 | tar czvf dist.tar.gz Makefile main.c start.s app.lds | ||
37 | |||
38 | clean: | ||
39 | -rm -f *.x *.i *.o *.elf *.bin *.map *.mod *.bak *~ | ||
40 | |||
diff --git a/www/example/README b/www/example/README new file mode 100644 index 0000000000..ca8ea36c37 --- /dev/null +++ b/www/example/README | |||
@@ -0,0 +1,7 @@ | |||
1 | Rockbox example build | ||
2 | --------------------- | ||
3 | |||
4 | These files are meant to show how to build a simple program for the Archos. | ||
5 | |||
6 | Note that the display code only works on older machines (<4.50) so don't | ||
7 | look too hard on that. | ||
diff --git a/www/example/app.lds b/www/example/app.lds new file mode 100644 index 0000000000..03bd1b2b54 --- /dev/null +++ b/www/example/app.lds | |||
@@ -0,0 +1,23 @@ | |||
1 | ENTRY(_start) | ||
2 | OUTPUT_FORMAT(elf32-sh) | ||
3 | SECTIONS | ||
4 | { | ||
5 | .vectors 0x09000000 : | ||
6 | { | ||
7 | *(.vectors); | ||
8 | . = ALIGN(0x200); | ||
9 | *(.text.start) | ||
10 | *(.text) | ||
11 | *(.rodata) | ||
12 | } | ||
13 | |||
14 | .bss : | ||
15 | { | ||
16 | _stack = . + 0x1000; | ||
17 | } | ||
18 | |||
19 | .pad 0x0900C800 : | ||
20 | { | ||
21 | LONG(0); | ||
22 | } | ||
23 | } | ||
diff --git a/www/example/main.c b/www/example/main.c new file mode 100644 index 0000000000..9188aaf640 --- /dev/null +++ b/www/example/main.c | |||
@@ -0,0 +1,102 @@ | |||
1 | #define PBDR (*((volatile unsigned short *)0x05FFFFC2)) | ||
2 | |||
3 | #define DC 1 | ||
4 | #define CS1 2 | ||
5 | #define SDA 4 | ||
6 | #define SCK 8 | ||
7 | |||
8 | static const unsigned char ascii2lcd[] = { | ||
9 | 0x00,0x01,0x02,0x03,0x00,0x84,0x85,0x89, | ||
10 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
11 | 0xec,0xe3,0xe2,0xe1,0xe0,0xdf,0x15,0x00, | ||
12 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
13 | 0x24,0x25,0x26,0x37,0x06,0x29,0x2a,0x2b, | ||
14 | 0x2c,0x2d,0x2e,0x2f,0x30,0x31,0x32,0x33, | ||
15 | 0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b, | ||
16 | 0x3c,0x3d,0x3e,0x3f,0x40,0x41,0x42,0x43, | ||
17 | 0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b, | ||
18 | 0x4c,0x4d,0x4e,0x4f,0x50,0x51,0x52,0x53, | ||
19 | 0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b, | ||
20 | 0x5c,0x5d,0x5e,0xa9,0x33,0xce,0x00,0x15, | ||
21 | 0x00,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b, | ||
22 | 0x6c,0x6d,0x6e,0x6f,0x70,0x71,0x72,0x73, | ||
23 | 0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b, | ||
24 | 0x7c,0x7d,0x7e,0x24,0x24,0x24,0x24,0x24, | ||
25 | 0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24, | ||
26 | 0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24, | ||
27 | 0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24, | ||
28 | 0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24, | ||
29 | 0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24, | ||
30 | 0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24, | ||
31 | 0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24, | ||
32 | 0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24, | ||
33 | 0x45,0x45,0x45,0x45,0x45,0x45,0x24,0x47, | ||
34 | 0x49,0x49,0x49,0x49,0x4d,0x4d,0x4d,0x4d, | ||
35 | 0x48,0x52,0x53,0x53,0x53,0x53,0x53,0x24, | ||
36 | 0x24,0x59,0x59,0x59,0x59,0x5d,0x24,0x24, | ||
37 | 0x65,0x65,0x65,0x65,0x65,0x65,0x24,0x67, | ||
38 | 0x69,0x69,0x69,0x69,0x6d,0x6d,0x6d,0x6d, | ||
39 | 0x73,0x72,0x73,0x73,0x73,0x73,0x73,0x24, | ||
40 | 0x24,0x79,0x79,0x79,0x79,0x7d,0x24,0x7d | ||
41 | }; | ||
42 | |||
43 | void lcd_write(int byte, int data) | ||
44 | { | ||
45 | int i; | ||
46 | char on,off; | ||
47 | |||
48 | PBDR &= ~CS1; /* enable lcd chip select */ | ||
49 | |||
50 | if ( data ) { | ||
51 | on=~(SDA|SCK); | ||
52 | off=SCK|DC; | ||
53 | } | ||
54 | else { | ||
55 | on=~(SDA|SCK|DC); | ||
56 | off=SCK; | ||
57 | } | ||
58 | /* clock out each bit, MSB first */ | ||
59 | for (i=0x80;i;i>>=1) | ||
60 | { | ||
61 | PBDR &= on; | ||
62 | if (i & byte) | ||
63 | PBDR |= SDA; | ||
64 | PBDR |= off; | ||
65 | } | ||
66 | |||
67 | PBDR |= CS1; /* disable lcd chip select */ | ||
68 | } | ||
69 | |||
70 | void lcd_printxy( char x, char y, unsigned char* string, int len ) | ||
71 | { | ||
72 | int i; | ||
73 | lcd_write(0xb0+y*16+x,0); | ||
74 | for (i=0; string[i] && i<len; i++) | ||
75 | lcd_write(ascii2lcd[string[i]],1); | ||
76 | } | ||
77 | |||
78 | int main(void) | ||
79 | { | ||
80 | lcd_printxy(0,0,"Open Source",11); | ||
81 | |||
82 | /* simple scroll */ | ||
83 | while (1) { | ||
84 | int i,j; | ||
85 | char* string = " Jukebox Jukebox "; | ||
86 | for ( i=0; i<11; i++ ) { | ||
87 | lcd_printxy(0,1,string+i,11); | ||
88 | for (j=0; j<600000; j++); | ||
89 | PBDR ^= 0x40; /* toggle LED (PB6) */ | ||
90 | } | ||
91 | } | ||
92 | } | ||
93 | |||
94 | extern const void stack(void); | ||
95 | |||
96 | const void* vectors[] __attribute__ ((section (".vectors"))) = | ||
97 | { | ||
98 | main, /* Power-on reset */ | ||
99 | stack, /* Power-on reset (stack pointer) */ | ||
100 | main, /* Manual reset */ | ||
101 | stack /* Manual reset (stack pointer) */ | ||
102 | }; | ||
diff --git a/www/example/start.s b/www/example/start.s new file mode 100644 index 0000000000..fd4669db56 --- /dev/null +++ b/www/example/start.s | |||
@@ -0,0 +1,23 @@ | |||
1 | ! note: sh-1 has a "delay cycle" after every branch where you can | ||
2 | ! execute another instruction "for free". | ||
3 | |||
4 | .file "start.s" | ||
5 | .section .text.start | ||
6 | .extern _main | ||
7 | .extern _vectors | ||
8 | .extern _stack | ||
9 | .global _start | ||
10 | .align 2 | ||
11 | |||
12 | _start: | ||
13 | mov.l 1f, r1 | ||
14 | mov.l 3f, r3 | ||
15 | mov.l 2f, r15 | ||
16 | jmp @r3 | ||
17 | ldc r1, vbr | ||
18 | nop | ||
19 | |||
20 | 1: .long _vectors | ||
21 | 2: .long _stack | ||
22 | 3: .long _main | ||
23 | .type _start,@function | ||