Changeset 12310
- Timestamp:
- 06/17/09 22:22:05 (4 years ago)
- Location:
- ar5315_microredboot/microredboot/boot/src
- Files:
-
- 5 added
- 4 deleted
- 6 edited
-
Makefile (modified) (2 diffs)
-
head-ar5315.S (modified) (1 diff)
-
head-ar531x.S (modified) (6 diffs)
-
head.S (modified) (1 diff)
-
lib/lib.c (added)
-
lib/print.c (added)
-
lib/print.h (added)
-
lib/printf.c (added)
-
lib/printf.h (added)
-
misc_lzma.c (modified) (17 diffs)
-
print.c (deleted)
-
print.h (deleted)
-
printf.c (deleted)
-
printf.h (deleted)
-
uncompress-ar531x.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
ar5315_microredboot/microredboot/boot/src/Makefile
r12303 r12310 27 27 LD = /xfs/toolchains/staging_dir_mips/bin/mips-linux-ld 28 28 OBJCOPY = /xfs/toolchains/staging_dir_mips/bin/mips-linux-objcopy 29 CFLAGS = -Os -G 0 -mabi=32 -mno-abicalls -fno-pic -pipe -msoft-float -ffreestanding -march=mips32 -Iinclude -I include/asm-mips/mach-atheros -Iinclude/asm/mach-generic -DMIPSEB -D_MIPSEB -D__MIPSEB -D__MIPSEB__ -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS32 -D__KERNEL__29 CFLAGS = -Os -G 0 -mabi=32 -mno-abicalls -fno-pic -pipe -msoft-float -ffreestanding -march=mips32 -Iinclude -I. -Iinclude/asm-mips/mach-atheros -Iinclude/asm/mach-generic -DMIPSEB -D_MIPSEB -D__MIPSEB -D__MIPSEB__ -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS32 -D__KERNEL__ 30 30 CFLAGS+= -DCONFIG_MIPS_L1_CACHE_SHIFT=5 -DCONFIG_PAGE_SIZE_4KB -DCONFIG_32BIT -DCONFIG_BOOTLOADER 31 31 AFLAGS = -Os -D__ASSEMBLY__ -G 0 -mabi=32 -mno-abicalls -fno-pic -pipe -msoft-float -ffreestanding -march=mips32 -Iinclude -Iinclude/asm-mips/mach-atheros -Iinclude/asm/mach-generic -DMIPSEB -D_MIPSEB -D__MIPSEB -D__MIPSEB__ -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS32 … … 46 46 47 47 HEAD = head.o 48 OBJS = misc_lzma.o 48 OBJS = misc_lzma.o lib/lib.o lib/print.o lib/printf.o 49 49 MEMCPY = memcpy.o memset.o 50 50 # CFLAGS = $(CPPFLAGS) -O2 -DSTDC_HEADERS $(CFLAGS_BOOT) -
ar5315_microredboot/microredboot/boot/src/head-ar5315.S
r12281 r12310 1 1 /* 2 * lzma_misc.c2 * head-ar5315.S 3 3 * originally written for xscale based linux kernel decompression 4 4 * now adapted for AR531X based redboot stub and kernel loader -
ar5315_microredboot/microredboot/boot/src/head-ar531x.S
r12281 r12310 1 1 /* 2 * linux/arch/mips/boot/compressed/head-ar531x.S2 * head-ar531x.S 3 3 * 4 * Copyright (C) 2009 NewMedia-NET GmbH (derived from linux boot code) 4 5 * Copyright (C) 2003 Instant802 Networks, Inc. 5 6 * Copyright (C) 2001 Atheros Communications, Inc., All Rights Reserved. 6 7 * 7 * License: 8 * originally written for xscale based linux kernel decompression 9 * now adapted for AR531X based redboot stub and kernel loader 10 * copyright 2009 Sebastian Gottschall / NewMedia-NET GmbH / DD-WRT.COM 11 * licensed under GPL conditions 12 * based on Vxworks sources from Atheros Communications, Inc. 13 * 14 * 15 * License: GPL 8 16 */ 9 17 … … 24 32 #include "mips4Kx.h" 25 33 #include "ar531xreg.h" 34 #include "ar531xSio.h" 26 35 27 36 /* … … 217 226 218 227 /* Want this fairly early in output file */ 219 .asciz " Copyright 2009DD-WRT.COM"228 .asciz "MicroRedBoot Copyright 2009 NewMedia-NET GmbH / DD-WRT.COM" 220 229 .align 4 221 230 … … 627 636 mtc0 zero, CP0_COMPARE 628 637 638 li a0, KSEG1|AR531X_RESET 639 lw t0, 0(a0) 640 and t0, ~RESET_APB 641 or t0, RESET_UART0 642 sw t0, 0(a0) 643 lw zero, 0(a0) # flush 644 645 and t0, ~RESET_UART0 646 sw t0, 0(a0) 647 lw zero, 0(a0) # flush 648 649 1: /* Use internal clocking */ 650 li a0, KSEG1|AR531X_CLOCKCTL 651 lw t0, 0(a0) 652 and t0, ~CLOCKCTL_UART0 653 sw t0, 0(a0) 654 655 /* put UART CLOCK RATE into a0 */ 656 li a0, KSEG1|AR5312_SCRATCH 657 lw a0, 0(a0) 658 bnez a0, 3f # CPU Clock freq specified? 659 li a0, 180000000 # No: assume 180MHz 660 3: srl a0, 2 # derive UART freq 661 div a0, 115200 662 div a0, 16 663 srl t2, a0, 8 664 andi t1, a0, 0xff # AR531X_NS16550_DLL_VALUE 665 andi t2, 0xff # AR531X_NS16550_DLM_VALUE 666 667 2: 668 669 /* Init UART @ 115200 baud */ 670 li a0, KSEG1|AR531X_UART0 671 li t0, LCR_DLAB # access divisor latch 672 sw t0, LCR<<2(a0) 673 sw t1, DLL<<2(a0) # divisor low 674 sw t2, DLM<<2(a0) # divisor high 675 li t0, CHAR_LEN_8 # 8b mode 676 sw t0, LCR<<2(a0) 677 sw zero, IER<<2(a0) # disable interrupts 678 li t0, FCR_EN|FCR_RXCLR|FCR_TXCLR 679 680 sw t0, FCR<<2(a0) # reset and enable fifos 681 682 683 629 684 /* Set watchpoint for low memory to debug null pointers */ 630 685 li t0, 0x40000ff8 # G + Ignore 11:3 in check … … 661 716 bal romCacheInit # init/invalidate cache tags 662 717 718 nop 719 la t0,_text # dest addr 720 # la t1,_text # source addr 721 # lar t1,__AR531X_start 722 la t1,_text-0x80400000+BOOTBASE # source addr 723 la t3,_text+0x10000 # end dest addr 724 3: 725 lw v0,0(t1) # get word 726 sw v0,0(t0) # write word 727 addiu t1,t1,4 728 addiu t0,t0,4 729 bne t0,t3,3b 730 nop 731 la v0,4f # RAM address to go to 732 jr v0 733 nop 734 4: 735 nop 736 663 737 /* Want to switch to cached segment now... */ 664 738 … … 721 795 nop 722 796 bal ramCacheInit # init/invalidate cache tags 797 nop 798 799 la t0,_text # dest addr 800 # la t1,_text # source addr 801 # lar t1,__AR531X_start 802 la t1,_text-0x80400000+BOOTBASE # source addr 803 la t3,_text+0x10000 # end dest addr 804 3: 805 lw v0,0(t1) # get word 806 sw v0,0(t0) # write word 807 addiu t1,t1,4 808 addiu t0,t0,4 809 bne t0,t3,3b 810 nop 811 la v0,4f # RAM address to go to 812 jr v0 813 nop 814 4: 723 815 nop 724 816 -
ar5315_microredboot/microredboot/boot/src/head.S
r12281 r12310 68 68 69 69 /* Jump to the kernel's entry point */ 70 la t1, bootoffset 70 la t1, bootoffset 71 71 nop 72 72 lw t0, 0(t1) -
ar5315_microredboot/microredboot/boot/src/misc_lzma.c
r12303 r12310 66 66 * Do the lzma decompression 67 67 */ 68 69 static void print_hex(int val)70 {71 static char *xlate = "0123456789abcdef";72 int i;73 74 puts("0x");75 76 for (i = 28; i >= 0; i -= 4) {77 putc(xlate[(val >> i) & 0xf]);78 }79 }80 68 81 69 static int disaster = 0; … … 106 94 if (disaster) { 107 95 error 108 ("\ r\ndata corrupted in recovery RedBoot too, this is a disaster condition. please re-jtag\r\n");96 ("\ndata corrupted in recovery RedBoot too, this is a disaster condition. please re-jtag\n"); 109 97 } 110 98 disaster = 1; 111 puts("\ r\ndata corrupted!\r\nswitching to recovery RedBoot\r\nloading");99 puts("\ndata corrupted!\nswitching to recovery RedBoot\nloading"); 112 100 inbuf = input_data; 113 101 insize = &input_data_end[0] - &input_data[0]; … … 129 117 if (disaster) { 130 118 error 131 ("data corrupted in recovery RedBoot too, this is a disaster condition. please re-jtag\ r\n");119 ("data corrupted in recovery RedBoot too, this is a disaster condition. please re-jtag\n"); 132 120 } 133 121 disaster = 1; 134 puts("\ r\ndata corrupted!\r\nswitching to recovery RedBoot\r\nloading");122 puts("\ndata corrupted!\nswitching to recovery RedBoot\nloading"); 135 123 inbuf = input_data; 136 124 insize = &input_data_end[0] - &input_data[0]; … … 168 156 *buffer = &val; 169 157 if (icnt++ % (1024 * 10) == 0) 170 put s(".");158 putc('.'); 171 159 return LZMA_RESULT_OK; 172 160 } … … 201 189 || !strncmp(fis->name, "vmlinux", 7) 202 190 || !strcmp(fis->name, "kernel")) { 203 puts("found bootable image: "); 204 puts(fis->name); 205 puts(" at "); 206 print_hex(fis->flash_base); 207 puts(" entrypoint "); 208 print_hex(fis->entry_point); 209 puts("\r\n"); 191 printf 192 ("found bootable image: [%s] at [0x%08X] EP [0x%08X]\n", 193 fis->name, fis->flash_base, fis->entry_point); 210 194 bootoffset = fis->entry_point; 211 195 output_data = (uch *) fis->mem_base; … … 219 203 count++; 220 204 } 221 puts("no bootable image found, try default location 0xbfc10000\ r\n");205 puts("no bootable image found, try default location 0xbfc10000\n"); 222 206 bootoffset = 0x80041000; 223 207 output_data = (uch *) 0x80041000; … … 260 244 arch_error(x); 261 245 262 puts("\r\n\r\n"); 263 puts(x); 264 puts("\r\n\r\n -- System halted"); 246 printf("\n\n%s\n\n -- System halted", x); 265 247 266 248 while (1) ; /* Halt */ … … 336 318 337 319 /* 338 * 320 * udelay implementation based on cpu cycle counter 339 321 */ 340 322 static void udelay(int us) … … 498 480 __u32 cs_addrmask; 499 481 } static flashconfig_tbl[MAX_FLASH] = { 500 { 501 0, 0, 0, 0}, { 502 STM_1MB_BYTE_COUNT, STM_1MB_SECTOR_COUNT, 503 STM_1MB_SECTOR_SIZE, 0x0}, 504 { 505 STM_2MB_BYTE_COUNT, STM_2MB_SECTOR_COUNT, STM_2MB_SECTOR_SIZE, 0x0}, 506 { 507 STM_4MB_BYTE_COUNT, STM_4MB_SECTOR_COUNT, STM_4MB_SECTOR_SIZE, 0x0}, 508 { 509 STM_8MB_BYTE_COUNT, STM_8MB_SECTOR_COUNT, STM_8MB_SECTOR_SIZE, 0x0}, 510 { 511 STM_16MB_BYTE_COUNT, STM_16MB_SECTOR_COUNT, 512 STM_16MB_SECTOR_SIZE, 0x0} 482 {0, 0, 0, 0}, // 483 {STM_1MB_BYTE_COUNT, STM_1MB_SECTOR_COUNT,STM_1MB_SECTOR_SIZE, 0x0},// 484 {STM_2MB_BYTE_COUNT, STM_2MB_SECTOR_COUNT, STM_2MB_SECTOR_SIZE, 0x0},// 485 {STM_4MB_BYTE_COUNT, STM_4MB_SECTOR_COUNT, STM_4MB_SECTOR_SIZE, 0x0},// 486 {STM_8MB_BYTE_COUNT, STM_8MB_SECTOR_COUNT, STM_8MB_SECTOR_SIZE, 0x0},// 487 {STM_16MB_BYTE_COUNT, STM_16MB_SECTOR_COUNT,STM_16MB_SECTOR_SIZE, 0x0}// 513 488 }; 514 489 … … 518 493 __s8 rx_cnt; 519 494 } static stm_opcodes[] = { 520 { 521 STM_OP_WR_ENABLE, 1, 0}, { 522 STM_OP_WR_DISABLE, 1, 0}, { 523 STM_OP_RD_STATUS, 524 1, 1}, { 525 STM_OP_WR_STATUS, 526 1, 0}, { 527 STM_OP_RD_DATA, 528 4, 529 4}, 530 { 531 STM_OP_FAST_RD_DATA, 5, 0}, { 532 STM_OP_PAGE_PGRM, 8, 0}, { 533 STM_OP_SECTOR_ERASE, 534 4, 0}, { 535 STM_OP_BULK_ERASE, 536 1, 0}, { 537 STM_OP_DEEP_PWRDOWN, 538 1, 539 0}, 540 { 541 STM_OP_RD_SIG, 4, 1}, 495 {STM_OP_WR_ENABLE, 1, 0}, // 496 {STM_OP_WR_DISABLE, 1, 0}, // 497 {STM_OP_RD_STATUS, 1, 1}, // 498 {STM_OP_WR_STATUS, 1, 0}, // 499 {STM_OP_RD_DATA, 4, 4}, // 500 {STM_OP_FAST_RD_DATA, 5, 0}, // 501 {STM_OP_PAGE_PGRM, 8, 0}, // 502 {STM_OP_SECTOR_ERASE, 4, 0}, // 503 {STM_OP_BULK_ERASE, 1, 0}, // 504 {STM_OP_DEEP_PWRDOWN, 1, 0}, // 505 {STM_OP_RD_SIG, 4, 1}, // 542 506 }; 543 507 … … 634 598 break; 635 599 default: 636 puts("Read of flash device signature failed!\ r\n");600 puts("Read of flash device signature failed!\n"); 637 601 return (0); 638 602 } … … 647 611 struct opcodes *ptr_opcode; 648 612 __u32 temp, reg; 649 puts("erasing nvram at "); 650 print_hex(flashbase + offset); 651 puts("\r\n"); 613 printf("erasing nvram at [0x%08X]\n", flashbase + offset); 652 614 653 615 ptr_opcode = &stm_opcodes[SPI_SECTOR_ERASE]; … … 666 628 busy_wait(spiflash_sendcmd(SPI_RD_STATUS, 0) & SPI_STATUS_WIP, 20); 667 629 668 puts("done\ r\n");630 puts("done\n"); 669 631 return 0; 670 632 } 671 633 634 static int flashdetected = 0; 672 635 static int flashdetect(void) 673 636 { 637 if (flashdetected) 638 return 0; 674 639 flashsize = 8 * 1024 * 1024; 675 640 flashbase = 0xa8000000; 676 641 int index = 0; 677 642 if (!(index = spiflash_probe_chip())) { 678 puts("Found no serial flash device, cannot reset to factory defaults\ r\n");643 puts("Found no serial flash device, cannot reset to factory defaults\n"); 679 644 return -1; 680 645 } else { 681 646 flashsize = flashconfig_tbl[index].byte_cnt; 682 647 sectorsize = flashconfig_tbl[index].sector_size; 683 puts("Found Flash device SIZE=");684 print_hex(flashsize);685 puts(" SECTORSIZE=");686 print_hex(sectorsize);687 puts(" FLASHBASE=");688 648 if (flashsize == 8 * 1024 * 1024) 689 649 flashbase = 0xa8000000; 690 650 else 691 651 flashbase = 0xbfc00000; 692 print_hex(flashbase); 693 puts("\r\n"); 694 } 652 printf 653 ("Found Flash device SIZE=0x%08X SECTORSIZE=0x%08X FLASHBASE=0x%08X\n", 654 flashsize, sectorsize, flashbase); 655 } 656 flashdetected = 1; 695 657 return 0; 696 658 659 } 660 661 struct nvram_header { 662 __u32 magic; 663 __u32 len; 664 __u32 crc_ver_init; /* 0:7 crc, 8:15 ver, 16:27 init, mem. test 28, 29-31 reserved */ 665 __u32 config_refresh; /* 0:15 config, 16:31 refresh */ 666 __u32 config_ncdl; /* ncdl values for memc */ 667 }; 668 669 struct nvram_tuple { 670 char *name; 671 char *value; 672 struct nvram_tuple *next; 673 }; 674 675 #define NVRAM_SPACE 0x10000 676 #define NVRAM_MAGIC 0x48534C46 /* 'NVFL' */ 677 678 static char nvram_buf[65536] __attribute__((aligned(4096))) = {0};// 679 680 /* 681 * simple dd-wrt nvram implementation (read only) 682 */ 683 static void nvram_init(void) 684 { 685 struct nvram_header *header; 686 __u32 off, lim; 687 int i; 688 flashdetect(); 689 690 header = 691 (struct nvram_header *)(flashbase + flashsize - (sectorsize * 3)); 692 if (header->magic == NVRAM_MAGIC && header->len > 0 693 && header->len <= NVRAM_SPACE) { 694 printf("DD-WRT nvram with size = %d found\n", header->len); 695 memcpy(nvram_buf, header, NVRAM_SPACE); 696 } 697 } 698 699 static char *nvram_get(const char *name) 700 { 701 char *var, *value, *end, *eq; 702 703 if (!name) 704 return NULL; 705 706 if (!nvram_buf[0]) 707 nvram_init(); 708 709 /* Look for name=value and return value */ 710 var = &nvram_buf[sizeof(struct nvram_header)]; 711 end = nvram_buf + sizeof(nvram_buf) - 2; 712 end[0] = end[1] = '\0'; 713 for (; *var; var = value + strlen(value) + 1) { 714 if (!(eq = strchr(var, '='))) 715 break; 716 value = eq + 1; 717 if ((eq - var) == strlen(name) 718 && strncmp(var, name, (eq - var)) == 0) 719 return value; 720 } 721 722 return NULL; 697 723 } 698 724 … … 705 731 706 732 arch_decomp_setup(); 707 708 puts("MicroRedBoot v1.2, (c) 2009 DD-WRT.COM ("); 709 puts(__DATE__); 710 puts(")\r\n"); 711 if (resetTouched()) { 712 puts("Reset Button triggered\r\nBooting Recovery RedBoot\r\n"); 733 printf("MicroRedBoot v1.2, (c) 2009 DD-WRT.COM (%s)\n", __DATE__); 734 nvram_init(); 735 char *resetbutton = nvram_get("resetbutton_enable"); 736 if (resetTouched() || (resetbutton && !strcmp(resetbutton, "1"))) { 737 puts("Reset Button triggered\nBooting Recovery RedBoot\n"); 713 738 int count = 5; 714 739 while (count--) { … … 718 743 } 719 744 if (count <= 0) { 720 puts("reset button 5 seconds pushed, erasing nvram\ r\n");745 puts("reset button 5 seconds pushed, erasing nvram\n"); 721 746 if (!flashdetect()) 722 747 flash_erase_nvram(flashsize, sectorsize); … … 728 753 flashdetect(); 729 754 linuxaddr = getLinux(); 730 puts("Booting Linux\ r\n");755 puts("Booting Linux\n"); 731 756 resettrigger = 1; 732 757 /* initialize clock */ … … 759 784 puts("loading"); 760 785 lzma_unzip(); 761 puts("\ r\n\r\n\r\n");786 puts("\n\n\n"); 762 787 763 788 return output_ptr; -
ar5315_microredboot/microredboot/boot/src/uncompress-ar531x.h
r12281 r12310 76 76 77 77 while ((c = *s++)) { 78 if (c=='\n') 79 putc('\r'); 78 80 putc(c); 79 81 }
Note: See TracChangeset
for help on using the changeset viewer.
