|
- 5.增加函数实现
- (1)common/cmd_load.c
- 【1】增加函数声明
- /* support xmodem*/
- static ulong load_serial_xmodem (ulong offset);
- 并后面添加其函数实现:
- /* support xmodem */
- static ulong load_serial_xmodem (ulong offset)
- {
- int size;
- char buf[32];
- int err;
- int res;
- connection_info_t info;
- char xmodemBuf[1024];
- ulong store_addr = ~0;
- ulong addr = 0;
- size = 0;
- info.mode = xyzModem_xmodem;
- res = xyzModem_stream_open (&info, &err);
- if (!res) {
- while ((res =
- xyzModem_stream_read (xmodemBuf, 1024, &err)) > 0) {
- store_addr = addr + offset;
- size += res;
- addr += res;
- #ifndef CFG_NO_FLASH
- if (addr2info (store_addr)) {
- int rc;
- rc = flash_write ((char *) xmodemBuf,
- store_addr, res);
- if (rc != 0) {
- flash_perror (rc);
- return (~0);
- }
- } else
- #endif
- {
- memcpy ((char *) (store_addr), xmodemBuf,
- res);
- }
- }
- } else {
- printf ("%s\n", xyzModem_error (err));
- }
- xyzModem_stream_close (&err);
- xyzModem_stream_terminate (false, &getcxmodem);
- flush_cache (offset, size);
- printf ("## Total Size = 0x%08x = %d Bytes\n", size, size);
- sprintf (buf, "%X", size);
- setenv ("filesize", buf);
- return offset;
- }
- 【2】增加UBOOT命令
- /* support xmodem */
- U_BOOT_CMD(
- loadx, 3, 0, do_load_serial_bin,
- "loadx - load binary file over serial line (xmodem mode)\n",
- "[ off ] [ baud ]\n"
- " - load binary file over serial line"
- " with offset 'off' and baudrate 'baud'\n"
- );
- 【3】在
- printf ("## Ready for binary (ymodem) download "
- "to 0x%08lX at %d bps...\n",
- offset,
- load_baudrate);前添加
- /* support xmodem */
- if (strcmp(argv[0],"loadx")==0) {
- printf ("## Ready for binary (xmodem) download "
- "to 0x%08lX at %d bps...\n",
- offset,
- load_baudrate);
- addr = load_serial_xmodem (offset);
- } else if (strcmp(argv[0],"loady")==0) {
- (2)common/cmd_nand.c
- 【1】U_BOOT_CMD(nand, 5, 1, do_nand,中, 增加
- "nand read.yaffs addr off size - read the `size' byte yaffs image starting\n"
- " at offset `off' to memory address `addr'\n"
- "nand write.yaffs addr off size - write the `size' byte yaffs image starting\n"
- " at offset `off' from memory address `addr'\n"
- 【2】在
- } else {
- /* write */
- nand_write_options_t opts;
- memset(&opts, 0, sizeof(opts));
- opts.buffer = (u_char*) addr;
- opts.length = size;
- opts.offset = off;
- /* opts.forcejffs2 = 1; */
- opts.pad = 1;
- opts.blockalign = 1;
- opts.quiet = quiet;
- ret = nand_write_opts(nand, &opts);
- }后面添加
- }else if ( s != NULL && !strcmp(s, ".yaffs")){
- if (read) {
- /* read */
- nand_read_options_t opts;
- memset(&opts, 0, sizeof(opts));
- opts.buffer = (u_char*) addr;
- opts.length = size;
- opts.offset = off;
- opts.readoob = 1;
- opts.quiet = quiet;
- ret = nand_read_opts(nand, &opts);
- } else {
- /* write */
- nand_write_options_t opts;
- memset(&opts, 0, sizeof(opts));
- opts.buffer = (u_char*) addr;
- opts.length = size;
- opts.offset = off;
- /* opts.forceyaffs = 1; */
- opts.noecc = 1;
- opts.writeoob = 1;
- opts.blockalign = 1;
- opts.quiet = quiet;
- opts.skipfirstblk = 1;
- ret = nand_write_opts(nand, &opts);
- }
- (3)common/main.c
- // run_command (s, 0);此句注释,并添加
- boot_zImage(0x4c000,0x200000);
- (4)drivers/dm9000x.c
- 【1】修改
- for (i = 0; i < 6; i++)
- ((u16 *) bd->bi_enetaddr)[i] = read_srom_word(i); char *tmp = getenv("ethaddr");
- 为:
- char *end;
- for (i = 0; i < 6; i++)
- // ((u16 *) bd->bi_enetaddr)[i] = read_srom_word(i);
- {
- bd->bi_enetaddr[i] = tmp ? simple_strtoul(tmp, &end, 16) : 0;
- if(tmp)
- tmp = (*end) ? end+1 : end;
- }
- 【2】 DM9000_iow(DM9000_IMR, IMR_PAR); /* Enable TX/RX interrupt mask */前添加#if 0
- return 0;前添加#endif
- (5) drivers/nand/nand_base.c
- 最后return this->scan_bbt (mtd);
- 修改为 return 0;
- (6) drivers/nand/nand_util.c
- 【1】 u_char *buffer = opts->buffer;
- size_t written;
- int result;后面添加
- int skipfirstblk = opts->skipfirstblk;
- 【2】在
- readlen = meminfo->oobblock;
- if (opts->pad && (imglen < readlen)) {前面添加
- /* skip the first good block when wirte yaffs image */
- if (skipfirstblk) {
- mtdoffset += erasesize_blockalign;
- skipfirstblk = 0;
- continue;
- }
- (7)增加新文件 lib_arm/boot_zImage.c
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- #include "asm-arm/mach-types.h"
- #define LINUX_KERNEL_OFFSET 0x8000
- #define LINUX_PARAM_OFFSET 0x100
- #define LINUX_PAGE_SIZE 0x00001000
- #define LINUX_PAGE_SHIFT 12
- #define LINUX_ZIMAGE_MAGIC 0x016f2818
- #define DRAM_SIZE 0x04000000
- extern int nand_read_ll_lcd(unsigned char*, unsigned long, int);
- /*
- * Disable IRQs
- */
- #define local_irq_disable() \
- ({ \
- unsigned long temp; \
- __asm__ __volatile__( \
- "mrs %0, cpsr @ local_irq_disable\n" \
- " orr %0, %0, #128\n" \
- " msr cpsr_c, %0" \
- : "=r" (temp) \
- : \
- : "memory", "cc"); \
- })
- static inline void cpu_arm920_cache_clean_invalidate_all(void)
- {
- __asm__(
- " mov r1, #0\n"
- " mov r1, #7 << 5\n" /* 8 segments */
- "1: orr r3, r1, #63 << 26\n" /* 64 entries */
- "2: mcr p15, 0, r3, c7, c14, 2\n" /* clean & invalidate D index */
- " subs r3, r3, #1 << 26\n"
- " bcs 2b\n" /* entries 64 to 0 */
- " subs r1, r1, #1 << 5\n"
- " bcs 1b\n" /* segments 7 to 0 */
- " mcr p15, 0, r1, c7, c5, 0\n" /* invalidate I cache */
- " mcr p15, 0, r1, c7, c10, 4\n" /* drain WB */
- );
- }
- void cache_clean_invalidate(void)
- {
- cpu_arm920_cache_clean_invalidate_all();
- }
- static inline void cpu_arm920_tlb_invalidate_all(void)
- {
- __asm__(
- "mov r0, #0\n"
- "mcr p15, 0, r0, c7, c10, 4\n" /* drain WB */
- "mcr p15, 0, r0, c8, c7, 0\n" /* invalidate I & D TLBs */
- );
- }
- void tlb_invalidate(void)
- {
- cpu_arm920_tlb_invalidate_all();
- }
- void call_linux(long a0, long a1, long a2)
- {
- local_irq_disable();
- cache_clean_invalidate();
- tlb_invalidate();
- __asm__(
- "mov r0, %0\n"
- "mov r1, %1\n"
- "mov r2, %2\n"
- "mov ip, #0\n"
- "mcr p15, 0, ip, c13, c0, 0\n" /* zero PID */
- "mcr p15, 0, ip, c7, c7, 0\n" /* invalidate I,D caches */
- "mcr p15, 0, ip, c7, c10, 4\n" /* drain write buffer */
- "mcr p15, 0, ip, c8, c7, 0\n" /* invalidate I,D TLBs */
- "mrc p15, 0, ip, c1, c0, 0\n" /* get control register */
- "bic ip, ip, #0x0001\n" /* disable MMU */
- "mcr p15, 0, ip, c1, c0, 0\n" /* write control register */
- "mov pc, r2\n"
- "nop\n"
- "nop\n"
- : /* no outpus */
- : "r" (a0), "r" (a1), "r" (a2)
- : "r0","r1","r2","ip"
- );
- }
- /*
- * pram_base: base address of linux paramter
- */
- static void setup_linux_param(ulong param_base)
- {
- struct param_struct *params = (struct param_struct *)param_base;
- char *linux_cmd;
- // printk("Setup linux parameters at 0x%08lx\n", param_base);
- memset(params, 0, sizeof(struct param_struct));
- params->u1.s.page_size = LINUX_PAGE_SIZE;
- params->u1.s.nr_pages = (DRAM_SIZE >> LINUX_PAGE_SHIFT);
- /* set linux command line */
- linux_cmd = getenv ("bootargs");
- if (linux_cmd == NULL) {
- printk("Wrong magic: could not found linux command line\n");
- } else {
- memcpy(params->commandline, linux_cmd, strlen(linux_cmd) + 1);
- // printk("linux command line is: "%s"\n", linux_cmd);
- }
- }
- /*
- * dst: destination address
- * src: source
- * size: size to copy
- * mt: type of storage device
- */
- static inline int copy_kernel_img(ulong dst, const char *src, size_t size)
- {
- int ret = 0;
- ret = nand_read_ll((unsigned char *)dst,
- (unsigned long)src, (int)size);
- return ret;
- }
- int boot_zImage(ulong from, size_t size)
- {
- int ret;
- ulong boot_mem_base; /* base address of bootable memory 鍢庡敱? */
- ulong to;
- ulong mach_type;
- boot_mem_base = 0x30000000;
- /* copy kerne image */
- to = boot_mem_base + LINUX_KERNEL_OFFSET;
- printk("Copy linux kernel from 0x%08lx to 0x%08lx, size = 0x%08lx ... ",
- from, to, size);
- ret = copy_kernel_img(to, (char *)from, size);
- if (ret) {
- printk("failed\n");
- return -1;
- } else {
- printk("Copy Kernel to SDRAM done,");
- }
- if (*(ulong *)(to + 9*4) != LINUX_ZIMAGE_MAGIC) {
- printk("Warning: this binary is not compressed linux kernel image\n");
- printk("zImage magic = 0x%08lx\n", *(ulong *)(to + 9*4));
- } else {
- // printk("zImage magic = 0x%08lx\n", *(ulong *)(to + 9*4));
- ;
- }
- /* Setup linux parameters and linux command line */
- setup_linux_param(boot_mem_base + LINUX_PARAM_OFFSET);
- /* Get machine type */
- mach_type = MACH_TYPE_S3C2440;
- // printk("MACH_TYPE = %d\n", mach_type);
- /* Go Go Go */
- printk("NOW, Booting Linux......\n");
- call_linux(0, mach_type, to);
- return 0;
- }
- int do_boot_zImage (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
- {
- boot_zImage(0x4c000,0x200000);
- return 0;
- }
- U_BOOT_CMD(
- boot_zImage, 3, 0, do_boot_zImage,
- "boot_zImage - boot Linux 's zImage\n",
- " - boot Linux 's zImage"
- );
- int boot_noos(ulong from, size_t size)
- {
- int ret;
- ulong boot_mem_base; /* base address of bootable memory 鍢庡敱? */
- ulong to;
- boot_mem_base = 0x30000000;
- /* copy kerne image */
- to = boot_mem_base;
- printk("Copy code from 0x%08lx to 0x%08lx, size = 0x%08lx ... ",
- from, to, size);
- ret = copy_kernel_img(to, (char *)from, size);
- if (ret) {
- printk("failed\n");
- return -1;
- } else {
- printk("Copy code to SDRAM done,");
- }
- /* Go Go Go */
- printk("NOW, Booting code......\n");
- run_command("go 0x30000000", 0);
- return 0;
- }
- int do_boot_noos (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
- {
- boot_noos(0x4c000,0x200000);
- return 0;
- }
- U_BOOT_CMD(
- boot_noos, 3, 0, do_boot_noos,
- "boot_noos - boot SKY2440_test\n",
- " - boot SKY2440_test"
- );
复制代码 |
|