diff options
Diffstat (limited to 'flash/minimon')
-rw-r--r-- | flash/minimon/Makefile | 53 | ||||
-rw-r--r-- | flash/minimon/README | 9 | ||||
-rw-r--r-- | flash/minimon/minimon.c | 156 | ||||
-rw-r--r-- | flash/minimon/minimon.h | 24 | ||||
-rw-r--r-- | flash/minimon/minimon.lds | 60 |
5 files changed, 0 insertions, 302 deletions
diff --git a/flash/minimon/Makefile b/flash/minimon/Makefile deleted file mode 100644 index 16b6c2724e..0000000000 --- a/flash/minimon/Makefile +++ /dev/null | |||
@@ -1,53 +0,0 @@ | |||
1 | # __________ __ ___. | ||
2 | # Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
3 | # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
4 | # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
5 | # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
6 | # \/ \/ \/ \/ \/ | ||
7 | # $Id$ | ||
8 | # | ||
9 | |||
10 | CC = sh-elf-gcc | ||
11 | LD = sh-elf-ld | ||
12 | AR = sh-elf-ar | ||
13 | AS = sh-elf-as | ||
14 | OC = sh-elf-objcopy | ||
15 | |||
16 | FIRMWARE := ../../firmware | ||
17 | TOOLSDIR=../../tools | ||
18 | |||
19 | TARGET = minimon | ||
20 | LDS := $(TARGET).lds | ||
21 | |||
22 | INCLUDES= -I$(FIRMWARE)/export -I. -I$(OBJDIR) | ||
23 | OBJDIR := . | ||
24 | |||
25 | CFLAGS = -fpic -O -W -Wall -m1 -nostdlib -ffreestanding -Wstrict-prototypes -fomit-frame-pointer -fschedule-insns $(INCLUDES) $(DEFINES) | ||
26 | AFLAGS += -small -relax | ||
27 | |||
28 | |||
29 | ifdef DEBUG | ||
30 | DEFINES := -DDEBUG | ||
31 | CFLAGS += -g | ||
32 | endif | ||
33 | |||
34 | SRC := $(wildcard *.c) | ||
35 | |||
36 | OBJS := $(SRC:%.c=$(OBJDIR)/%.o) | ||
37 | |||
38 | LINKFILE = $(OBJDIR)/$(TARGET).lds | ||
39 | |||
40 | |||
41 | $(OBJDIR)/$(TARGET).bin : $(OBJDIR)/$(TARGET).elf | ||
42 | $(OC) -O binary $(OBJDIR)/$(TARGET).elf $(OBJDIR)/$(TARGET).bin | ||
43 | $(TOOLSDIR)/sh2d $(OBJDIR)/$(TARGET).bin -o 0x0ffff000 > $(OBJDIR)/$(TARGET).asm | ||
44 | |||
45 | $(OBJDIR)/$(TARGET).elf : $(OBJS) | ||
46 | $(CC) -Os -nostdlib -o $(OBJDIR)/$(TARGET).elf -L$(OBJDIR) -T$(LINKFILE) -Wl,-Map,$(OBJDIR)/$(TARGET).map | ||
47 | |||
48 | |||
49 | clean: | ||
50 | -rm -f $(OBJS) $(OBJDIR)/$(TARGET).asm \ | ||
51 | $(OBJDIR)/$(TARGET).bin \ | ||
52 | $(OBJDIR)/$(TARGET).elf \ | ||
53 | $(OBJDIR)/$(TARGET).map | ||
diff --git a/flash/minimon/README b/flash/minimon/README deleted file mode 100644 index d2dc1707a6..0000000000 --- a/flash/minimon/README +++ /dev/null | |||
@@ -1,9 +0,0 @@ | |||
1 | (c) 2003 by Jörg Hohensohn | ||
2 | |||
3 | MiniMon is the tiny but powerful-enough piece of code that can be loaded | ||
4 | with the UART boot mod. | ||
5 | It allows to read and write memory, flash program, execute code. | ||
6 | This is suitable to reflash the box, load Rockbox or the gdb stub, etc. | ||
7 | |||
8 | The SVN version is linked to 0x0ffff000, i.e. start of IRAM. | ||
9 | This address has to match the address uart_boot downloads it to. \ No newline at end of file | ||
diff --git a/flash/minimon/minimon.c b/flash/minimon/minimon.c deleted file mode 100644 index aca9cb5523..0000000000 --- a/flash/minimon/minimon.c +++ /dev/null | |||
@@ -1,156 +0,0 @@ | |||
1 | // minimalistic monitor | ||
2 | // to be loaded with the UART boot feature | ||
3 | // capable of reading and writing bytes, commanded by UART | ||
4 | |||
5 | #include "sh7034.h" | ||
6 | #include "minimon.h" | ||
7 | |||
8 | // scalar types | ||
9 | typedef unsigned char UINT8; | ||
10 | typedef unsigned short UINT16; | ||
11 | typedef unsigned long UINT32; | ||
12 | |||
13 | typedef void(*tpFunc)(void); // type for exec | ||
14 | typedef int(*tpMain)(void); // type for start vector to main() | ||
15 | |||
16 | |||
17 | // prototypes | ||
18 | int main(void); | ||
19 | |||
20 | // our binary has to start with a vector to the entry point | ||
21 | tpMain start_vector[] __attribute__ ((section (".startvector"))) = {main}; | ||
22 | |||
23 | |||
24 | static UINT8 uart_read(void) | ||
25 | { | ||
26 | UINT8 byte; | ||
27 | while (!(SSR1 & SCI_RDRF)); // wait for char to be available | ||
28 | byte = RDR1; | ||
29 | SSR1 &= ~SCI_RDRF; | ||
30 | return byte; | ||
31 | } | ||
32 | |||
33 | |||
34 | static void uart_write(UINT8 byte) | ||
35 | { | ||
36 | while (!(SSR1 & SCI_TDRE)); // wait for transmit buffer empty | ||
37 | TDR1 = byte; | ||
38 | SSR1 &= ~SCI_TDRE; | ||
39 | } | ||
40 | |||
41 | |||
42 | int main(void) | ||
43 | { | ||
44 | UINT8 cmd; | ||
45 | UINT32 addr; | ||
46 | UINT32 size; | ||
47 | UINT32 content; | ||
48 | volatile UINT8* paddr = 0; | ||
49 | volatile UINT8* pflash = 0; // flash base address | ||
50 | |||
51 | while (1) | ||
52 | { | ||
53 | cmd = uart_read(); | ||
54 | switch (cmd) | ||
55 | { | ||
56 | case BAUDRATE: | ||
57 | content = uart_read(); | ||
58 | uart_write(cmd); // acknowledge by returning the command value | ||
59 | while (!(SSR1 & SCI_TEND)); // wait for empty shift register, before changing baudrate | ||
60 | BRR1 = content; | ||
61 | break; | ||
62 | |||
63 | case ADDRESS: | ||
64 | addr = (uart_read() << 24) | (uart_read() << 16) | (uart_read() << 8) | uart_read(); | ||
65 | paddr = (UINT8*)addr; | ||
66 | pflash = (UINT8*)(addr & 0xFFF80000); // round down to 512k align | ||
67 | uart_write(cmd); // acknowledge by returning the command value | ||
68 | break; | ||
69 | |||
70 | case BYTE_READ: | ||
71 | content = *paddr++; | ||
72 | uart_write(content); // the content is the ack | ||
73 | break; | ||
74 | |||
75 | case BYTE_WRITE: | ||
76 | content = uart_read(); | ||
77 | *paddr++ = content; | ||
78 | uart_write(cmd); // acknowledge by returning the command value | ||
79 | break; | ||
80 | |||
81 | case BYTE_READ16: | ||
82 | size = 16; | ||
83 | while (size--) | ||
84 | { | ||
85 | content = *paddr++; | ||
86 | uart_write(content); // the content is the ack | ||
87 | } | ||
88 | break; | ||
89 | |||
90 | case BYTE_WRITE16: | ||
91 | size = 16; | ||
92 | while (size--) | ||
93 | { | ||
94 | content = uart_read(); | ||
95 | *paddr++ = content; | ||
96 | } | ||
97 | uart_write(cmd); // acknowledge by returning the command value | ||
98 | break; | ||
99 | |||
100 | case BYTE_FLASH: | ||
101 | content = uart_read(); | ||
102 | pflash[0x5555] = 0xAA; // set flash to command mode | ||
103 | pflash[0x2AAA] = 0x55; | ||
104 | pflash[0x5555] = 0xA0; // byte program command | ||
105 | *paddr++ = content; | ||
106 | uart_write(cmd); // acknowledge by returning the command value | ||
107 | break; | ||
108 | |||
109 | case BYTE_FLASH16: | ||
110 | size = 16; | ||
111 | while (size--) | ||
112 | { | ||
113 | content = uart_read(); | ||
114 | pflash[0x5555] = 0xAA; // set flash to command mode | ||
115 | pflash[0x2AAA] = 0x55; | ||
116 | pflash[0x5555] = 0xA0; // byte program command | ||
117 | *paddr++ = content; | ||
118 | } | ||
119 | uart_write(cmd); // acknowledge by returning the command value | ||
120 | break; | ||
121 | |||
122 | case HALFWORD_READ: | ||
123 | content = *(UINT16*)paddr; | ||
124 | paddr += 2; | ||
125 | uart_write(content >> 8); // highbyte | ||
126 | uart_write(content & 0xFF); // lowbyte | ||
127 | break; | ||
128 | |||
129 | case HALFWORD_WRITE: | ||
130 | content = uart_read() << 8 | uart_read(); | ||
131 | *(UINT16*)paddr = content; | ||
132 | paddr += 2; | ||
133 | uart_write(cmd); // acknowledge by returning the command value | ||
134 | break; | ||
135 | |||
136 | case EXECUTE: | ||
137 | { | ||
138 | tpFunc pFunc = (tpFunc)paddr; | ||
139 | pFunc(); | ||
140 | uart_write(cmd); // acknowledge by returning the command value | ||
141 | } | ||
142 | break; | ||
143 | |||
144 | |||
145 | default: | ||
146 | { | ||
147 | volatile UINT16* pPortB = (UINT16*)0x05FFFFC2; | ||
148 | *pPortB |= 1 << 6; // bit 6 is red LED on | ||
149 | uart_write(~cmd); // error acknowledge | ||
150 | } | ||
151 | |||
152 | } // case | ||
153 | } | ||
154 | |||
155 | return 0; | ||
156 | } | ||
diff --git a/flash/minimon/minimon.h b/flash/minimon/minimon.h deleted file mode 100644 index b6e9805ecf..0000000000 --- a/flash/minimon/minimon.h +++ /dev/null | |||
@@ -1,24 +0,0 @@ | |||
1 | #ifndef _MINIMON_H | ||
2 | #define _MINIMON_H | ||
3 | |||
4 | |||
5 | // Commands | ||
6 | // all multibyte values (address, halfwords) are passed as big endian | ||
7 | // (most significant of the bytes first) | ||
8 | |||
9 | // set the address (all read/write commands will auto-increment it) | ||
10 | #define BAUDRATE 0x00 // followed by BRR value; response: command byte | ||
11 | #define ADDRESS 0x01 // followed by 4 bytes address; response: command byte | ||
12 | #define BYTE_READ 0x02 // response: 1 byte content | ||
13 | #define BYTE_WRITE 0x03 // followed by 1 byte content; response: command byte | ||
14 | #define BYTE_READ16 0x04 // response: 16 bytes content | ||
15 | #define BYTE_WRITE16 0x05 // followed by 16 bytes; response: command byte | ||
16 | #define BYTE_FLASH 0x06 // followed by 1 byte content; response: command byte | ||
17 | #define BYTE_FLASH16 0x07 // followed by 16 bytes; response: command byte | ||
18 | #define HALFWORD_READ 0x08 // response: 2 byte content | ||
19 | #define HALFWORD_WRITE 0x09 // followed by 2 byte content; response: command byte | ||
20 | #define EXECUTE 0x0A // response: command byte if call returns | ||
21 | #define VERSION 0x0B // response: version | ||
22 | |||
23 | |||
24 | #endif // _MINIMON_H | ||
diff --git a/flash/minimon/minimon.lds b/flash/minimon/minimon.lds deleted file mode 100644 index 14150b2123..0000000000 --- a/flash/minimon/minimon.lds +++ /dev/null | |||
@@ -1,60 +0,0 @@ | |||
1 | OUTPUT_FORMAT(elf32-sh) | ||
2 | INPUT(minimon.o) | ||
3 | |||
4 | MEMORY | ||
5 | { | ||
6 | IRAM : ORIGIN = 0x0FFFF000, LENGTH = 0x500 | ||
7 | } | ||
8 | |||
9 | SECTIONS | ||
10 | { | ||
11 | .startvector : | ||
12 | { | ||
13 | *(.startvector) | ||
14 | . = ALIGN(0x4); | ||
15 | } > IRAM | ||
16 | |||
17 | .got : | ||
18 | { | ||
19 | *(.got) | ||
20 | } > IRAM | ||
21 | |||
22 | .got.plt : | ||
23 | { | ||
24 | *(.got.plt) | ||
25 | } > IRAM | ||
26 | |||
27 | .rela.got : | ||
28 | { | ||
29 | *(.rela.got) | ||
30 | } > IRAM | ||
31 | |||
32 | .text : | ||
33 | { | ||
34 | . = ALIGN(0x200); | ||
35 | *(.entry) | ||
36 | *(.text) | ||
37 | . = ALIGN(0x4); | ||
38 | } > IRAM | ||
39 | |||
40 | .data : | ||
41 | { | ||
42 | *(.data) | ||
43 | } > IRAM | ||
44 | |||
45 | .rodata : | ||
46 | { | ||
47 | *(.rodata) | ||
48 | . = ALIGN(0x4); | ||
49 | } > IRAM | ||
50 | |||
51 | .bss : | ||
52 | { | ||
53 | *(.bss) | ||
54 | } > IRAM | ||
55 | |||
56 | .stack : | ||
57 | { | ||
58 | *(.stack) | ||
59 | } > IRAM | ||
60 | } | ||