init.config |
13 | 13 | receive driver_gpio / Event = sdmmc_gpio |
14 | 14 | sysreq sysreq |
15 | 15 | |
16 | | driver driver_nand = "nand.elf" |
17 | | receive driver_nand / WBlock = nand |
| 16 | #driver driver_nand = "nand.elf" |
| 17 | #receive driver_nand / WBlock = nand |
18 | 18 | |
19 | | driver driver_ums = "usb-mass-storage.elf" |
20 | | give driver_ums / WBlock = nand |
| 19 | #driver driver_ums = "usb-mass-storage.elf" |
| 20 | #give driver_ums / WBlock = nand |
21 | 21 | |
22 | 22 | #driver driver_boot = "boot.elf" |
23 | 23 | #receive driver_boot / Boot = boot |
... | ... | |
27 | 27 | #give booter / String = kernel |
28 | 28 | #give booter / Boot = boot |
29 | 29 | |
30 | | #driver driver_lcd = "lcd.elf" |
31 | | #receive driver_lcd / Display = display |
32 | | #receive driver_lcd / Setting = display_bright |
| 30 | driver driver_lcd = "lcd.elf" |
| 31 | receive driver_lcd / Display = display |
| 32 | receive driver_lcd / Setting = display_bright |
33 | 33 | |
34 | | #driver driver_buzzer = "buzzer.elf" |
35 | | #receive driver_buzzer / Buzzer = buzzer |
| 34 | driver driver_buzzer = "buzzer.elf" |
| 35 | receive driver_buzzer / Buzzer = buzzer |
36 | 36 | |
37 | | #program alarm = "alarm.elf" |
38 | | #receive alarm / UI = ui |
| 37 | program alarm = "alarm.elf" |
| 38 | receive alarm / UI = ui |
39 | 39 | |
40 | | #program gui = "gui.elf" |
41 | | #give gui / UI = ui |
42 | | #give gui / Display = display |
43 | | #give gui / Setting = display_bright |
44 | | #give gui / Buzzer = buzzer |
45 | | #give gui / Keyboard = keyboard |
| 40 | program gui = "gui.elf" |
| 41 | give gui / UI = ui |
| 42 | give gui / Display = display |
| 43 | give gui / Setting = display_bright |
| 44 | give gui / Buzzer = buzzer |
| 45 | give gui / Keyboard = keyboard |
46 | 46 | |
47 | 47 | #driver sdmmc = "sd+mmc.elf" |
48 | 48 | #receive sdmmc / WString = sdmmc |
mips/nanonote/Makefile.arch |
17 | 17 | |
18 | 18 | start_load = 0x80400000 |
19 | 19 | load = 0x80000000 |
20 | | # Uncomment one of these to select the boot method for the image. |
21 | | #UDC_BOOT = yes |
| 20 | # Uncomment exactly one of these to select the boot method for the image. |
| 21 | UDC_BOOT = yes |
22 | 22 | #SD_BOOT = yes |
23 | | UNBRICK = yes |
| 23 | #UNBRICK = yes |
24 | 24 | |
25 | 25 | arch_iris_sources = mips/interrupts.cc mips/arch.cc |
26 | 26 | boot_sources = mips/init.cc mips/nanonote/board.cc |
... | ... | |
95 | 95 | gzip < $< > $@ |
96 | 96 | |
97 | 97 | nanonote-boot: mips/nanonote/nanonote-boot.cc mips/nanonote/sdram-setup.raw |
98 | | g++ `pkg-config --cflags --libs shevek` $< -o $@ -D'STAGE1="$<"' -lusb |
| 98 | g++ `pkg-config --cflags --libs shevek` $< -o $@ -lusb |
99 | 99 | |
100 | 100 | mips/nanonote/sdram-setup.elf: mips/nanonote/sdram-setup.ld |
101 | 101 | mips/nanonote/sdram-setup.elf: LDFLAGS = --omagic -T mips/nanonote/sdram-setup.ld |
102 | 102 | mips/nanonote/threadlist.o: $(addprefix fs/,$(addsuffix .elf,$(boot_threads))) |
103 | 103 | mips/boot.o: TARGET_FLAGS = -DMEMORY_SIZE="32 << 20" |
104 | | mips/init.o: TARGET_FLAGS = -I/usr/include |
105 | | source/bootinit.o: TARGET_FLAGS = -I/usr/include |
106 | | source/elfrun.o: TARGET_FLAGS = -I/usr/include |
| 104 | mips/init.o: TARGET_FLAGS = -I/usr/mipsel-linux-gnu/include |
| 105 | source/bootinit.o: TARGET_FLAGS = -I/usr/mipsel-linux-gnu/include |
| 106 | source/elfrun.o: TARGET_FLAGS = -I/usr/mipsel-linux-gnu/include |
107 | 107 | source/gpio.ccp: source/nanonote-gpio.ccp |
108 | 108 | ln -s $(subst source/,,$<) $@ |
109 | 109 | $(addprefix fs/,$(addsuffix .elf,$(boot_threads))): TARGET_FLAGS = -I. |
mips/nanonote/jz4740.hhp |
3581 | 3581 | // SDRAM BANK Number: 1, 2 |
3582 | 3582 | unsigned CONFIG_NR_DRAM_BANKS = 1 |
3583 | 3583 | // CAS latency: 2 or 3 |
3584 | | unsigned SDRAM_CASL = 3 |
| 3584 | unsigned SDRAM_CASL = 2 |
3585 | 3585 | // SDRAM Timings, unit: ns |
3586 | 3586 | // RAS# Active Time |
3587 | 3587 | unsigned SDRAM_TRAS = 45 |
... | ... | |
3592 | 3592 | // Write Latency Time |
3593 | 3593 | unsigned SDRAM_TRWL = 7 |
3594 | 3594 | // Refresh period: 4096 refresh cycles/64ms |
3595 | | unsigned SDRAM_TREF = 15625 |
| 3595 | unsigned SDRAM_TREF = 7812 |
3596 | 3596 | unsigned dmcr0, dmcr, sdmode, tmp, cpu_clk, mem_clk, ns |
3597 | 3597 | unsigned cas_latency_sdmr[2] = { EMC_SDMR_CAS_2, EMC_SDMR_CAS_3 } |
3598 | 3598 | unsigned cas_latency_dmcr[2] = { 1 << EMC_DMCR_TCL_BIT, 2 << EMC_DMCR_TCL_BIT } |
... | ... | |
3602 | 3602 | gpio_as_sdram_16bit () |
3603 | 3603 | unsigned SDRAM_BW16 = 0 |
3604 | 3604 | unsigned SDRAM_BANK4 = 1 |
3605 | | unsigned SDRAM_ROW = 13 |
3606 | | unsigned SDRAM_COL = 9 |
| 3605 | unsigned SDRAM_ROW = 12 |
| 3606 | unsigned SDRAM_COL = 8 |
3607 | 3607 | |
3608 | 3608 | mem_clk = cpu_clk * div[cpm_get_cdiv()] / div[cpm_get_mdiv()] |
3609 | 3609 | EMC_BCR = 0 |
mips/nanonote/nand-boot.ccp |
127 | 127 | |
128 | 128 | #include "nand.hh" |
129 | 129 | |
130 | | static void setup_uart (): |
131 | | cpm_start_uart0 () |
132 | | gpio_as_uart0 () |
133 | | UART0_IER = 0 |
134 | | UART0_FCR = 0 |
135 | | UART0_MCR = 0 |
136 | | UART0_SIRCR = 0 |
137 | | UART0_UACR = 0 |
138 | | UART0_UMR = 16 |
139 | | UART0_LCR = UARTLCR_WLEN_8 | UARTLCR_STOP1 | UARTLCR_DLAB |
140 | | unsigned const baud = 57600 |
141 | | unsigned uart_div = 12000000 / 16 / baud |
142 | | UART0_DLHR = (uart_div >> 8) & 0xff |
143 | | UART0_DLLR = uart_div & 0xff |
144 | | UART0_LCR = UARTLCR_WLEN_8 | UARTLCR_STOP1 |
145 | | UART0_FCR = UARTFCR_UUE | UARTFCR_FE | UARTFCR_RFLS | UARTFCR_TFLS |
146 | | debug ("\n\nNand-boot: serial port initialized\n") |
147 | | |
148 | 130 | extern "C": |
149 | 131 | void nandboot_start (): |
150 | 132 | unsigned base = 0x18000000 + 0xa0000000 |
mips/nanonote/sdram-setup.ccp |
22 | 22 | #define dbg_log(x) do {} while (0) |
23 | 23 | #define dbg_log_num(...) do {} while (0) |
24 | 24 | |
25 | | #include "jz4740.hh" |
26 | | |
27 | | void kdebug (unsigned ch): |
28 | | while !(UART0_LSR & UARTLSR_TDRQ): |
29 | | UART0_TDR = ch |
30 | | while !(UART0_LSR & UARTLSR_TEMT): |
31 | | |
| 25 | // Set up gp and sp, jump to start_cpp(). |
| 26 | // This must be the first code in the file, |
| 27 | // so also before include jz4740.hh, |
| 28 | // because that defines some static functions which may not be inlined. |
32 | 29 | asm volatile (".set noreorder\n" |
33 | | "\t.globl __start\n" |
34 | | "\t.text\n" |
| 30 | ".globl __start\n" |
| 31 | ".text\n" |
35 | 32 | "__start:\n" |
36 | 33 | "\tnop\n" |
37 | 34 | "__hack_label:\n" |
38 | | "\tmove $a0, $ra\n" |
| 35 | "\tmove $k0, $ra\n" |
39 | 36 | "\tbal 1f\n" |
40 | 37 | "\tnop\n" |
41 | 38 | "\t.word _gp\n" |
... | ... | |
43 | 40 | "\tlw $gp, 0($ra)\n" |
44 | 41 | "\tla $sp, stack + 0x100\n" |
45 | 42 | "\tla $t9, start_cpp\n" |
46 | | "\tmove $ra, $a0\n" |
| 43 | "\tmove $ra, $k0\n" |
47 | 44 | "\tjr $t9\n" |
48 | 45 | "\tnop\n" |
49 | 46 | ".set reorder") |
50 | 47 | |
| 48 | #include "jz4740.hh" |
| 49 | |
| 50 | void kdebug (unsigned ch): |
| 51 | while !(UART0_LSR & UARTLSR_TDRQ): |
| 52 | UART0_TDR = ch |
| 53 | while !(UART0_LSR & UARTLSR_TEMT): |
| 54 | |
51 | 55 | extern "C": |
52 | 56 | void start_cpp () |
53 | 57 | char stack[0x100] |
54 | 58 | |
55 | 59 | void start_cpp (): |
56 | | //setup_uart () |
57 | | //kdebug ('.') |
58 | | //setup_sdram () |
59 | | //kdebug ('!') |
| 60 | setup_uart () |
| 61 | kdebug ('.') |
| 62 | setup_sdram () |
| 63 | kdebug ('!') |
60 | 64 | // everything is ok now: return to boot loader to load stage 2. |
mips/nanonote/server/usb-server.ccp |
210 | 210 | void pickup (bool is_stdio): |
211 | 211 | keep = is_stdio |
212 | 212 | void read (std::string const &line): |
213 | | shevek::istring l (line) |
| 213 | shevek::ristring l (line) |
214 | 214 | unsigned load, entry |
215 | 215 | std::string filename |
216 | | if l ("reboot %x %x %r%", load, entry, filename): |
| 216 | if l ("reboot %x %x %a%", load, entry, filename): |
217 | 217 | get_server ()->data ()->boot (filename, load, entry) |
218 | 218 | else if l ("shutdown%"): |
219 | 219 | std::cerr << "shutting down\n" |
... | ... | |
332 | 332 | shevek::args::option opts[] = { |
333 | 333 | shevek::args::option ('p', "port", "port to listen for commands", true, port) |
334 | 334 | } |
335 | | shevek::args args (argc, argv, opts, 0, 0, "device server for testing Iris on NanoNote", "2009") |
| 335 | shevek::args args (argc, argv, opts, 0, 0, "device server for testing Iris on NanoNote") |
336 | 336 | data d (port) |
337 | 337 | dump_devices () |
338 | 338 | shevek::loop () |