From 75a279c8f28539f560a23425073d97ffee746716 Mon Sep 17 00:00:00 2001 From: Gabor Juhos Date: Sun, 6 Jan 2013 00:54:20 +0000 Subject: MIPS: bootm.c: use debug macro to print debug message The '## Transferring control ...' message is printed only if DEBUG is enabled. Get rid of the 'ifdef DEBUG' statement and use the debug macro instead. Signed-off-by: Gabor Juhos --- arch/mips/lib/bootm.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c index 608c1a7..4ac712a 100644 --- a/arch/mips/lib/bootm.c +++ b/arch/mips/lib/bootm.c @@ -59,10 +59,8 @@ int do_bootm_linux(int flag, int argc, char * const argv[], bootstage_mark(BOOTSTAGE_ID_RUN_OS); -#ifdef DEBUG - printf("## Transferring control to Linux (at address %08lx) ...\n", + debug("## Transferring control to Linux (at address %08lx) ...\n", (ulong) theKernel); -#endif linux_params_init(UNCACHED_SDRAM(gd->bd->bi_boot_params), commandline); -- cgit v1.1 From e08634c7bfdb5fcda2541a8845d44888538d6178 Mon Sep 17 00:00:00 2001 From: Gabor Juhos Date: Mon, 7 Jan 2013 02:53:40 +0000 Subject: MIPS: bootm.c: separate linux jump code Move the actual jump code into a separate function. This make the code reusable for bootm subcommands. Signed-off-by: Gabor Juhos Cc: Daniel Schwierzeck --- arch/mips/lib/bootm.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c index 4ac712a..689d17b 100644 --- a/arch/mips/lib/bootm.c +++ b/arch/mips/lib/bootm.c @@ -43,10 +43,27 @@ static int linux_env_idx; static void linux_params_init(ulong start, char *commandline); static void linux_env_set(char *env_name, char *env_val); +static void boot_jump_linux(bootm_headers_t *images) +{ + void (*theKernel) (int, char **, char **, int *); + + /* find kernel entry point */ + theKernel = (void (*)(int, char **, char **, int *))images->ep; + + debug("## Transferring control to Linux (at address %08lx) ...\n", + (ulong) theKernel); + + bootstage_mark(BOOTSTAGE_ID_RUN_OS); + + /* we assume that the kernel is in place */ + printf("\nStarting kernel ...\n\n"); + + theKernel(linux_argc, linux_argv, linux_env, 0); +} + int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *images) { - void (*theKernel) (int, char **, char **, int *); char *commandline = getenv("bootargs"); char env_buf[12]; char *cp; @@ -54,14 +71,6 @@ int do_bootm_linux(int flag, int argc, char * const argv[], if ((flag != 0) && (flag != BOOTM_STATE_OS_GO)) return 1; - /* find kernel entry point */ - theKernel = (void (*)(int, char **, char **, int *))images->ep; - - bootstage_mark(BOOTSTAGE_ID_RUN_OS); - - debug("## Transferring control to Linux (at address %08lx) ...\n", - (ulong) theKernel); - linux_params_init(UNCACHED_SDRAM(gd->bd->bi_boot_params), commandline); #ifdef CONFIG_MEMSIZE_IN_BYTES @@ -95,10 +104,7 @@ int do_bootm_linux(int flag, int argc, char * const argv[], if (cp) linux_env_set("eth1addr", cp); - /* we assume that the kernel is in place */ - printf("\nStarting kernel ...\n\n"); - - theKernel(linux_argc, linux_argv, linux_env, 0); + boot_jump_linux(images); /* does not return */ return 1; -- cgit v1.1 From 0ea7213f63f580aa679a36795831dabd35d786aa Mon Sep 17 00:00:00 2001 From: Gabor Juhos Date: Mon, 7 Jan 2013 02:53:41 +0000 Subject: MIPS: bootm.c: separate environment initialization Move the environment initialization code into a separate function. This make the code reusable for bootm subcommands. Signed-off-by: Gabor Juhos Cc: Daniel Schwierzeck --- arch/mips/lib/bootm.c | 50 +++++++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c index 689d17b..8c2e508 100644 --- a/arch/mips/lib/bootm.c +++ b/arch/mips/lib/bootm.c @@ -43,34 +43,12 @@ static int linux_env_idx; static void linux_params_init(ulong start, char *commandline); static void linux_env_set(char *env_name, char *env_val); -static void boot_jump_linux(bootm_headers_t *images) -{ - void (*theKernel) (int, char **, char **, int *); - - /* find kernel entry point */ - theKernel = (void (*)(int, char **, char **, int *))images->ep; - - debug("## Transferring control to Linux (at address %08lx) ...\n", - (ulong) theKernel); - - bootstage_mark(BOOTSTAGE_ID_RUN_OS); - - /* we assume that the kernel is in place */ - printf("\nStarting kernel ...\n\n"); - - theKernel(linux_argc, linux_argv, linux_env, 0); -} - -int do_bootm_linux(int flag, int argc, char * const argv[], - bootm_headers_t *images) +static void boot_prep_linux(bootm_headers_t *images) { char *commandline = getenv("bootargs"); char env_buf[12]; char *cp; - if ((flag != 0) && (flag != BOOTM_STATE_OS_GO)) - return 1; - linux_params_init(UNCACHED_SDRAM(gd->bd->bi_boot_params), commandline); #ifdef CONFIG_MEMSIZE_IN_BYTES @@ -103,7 +81,33 @@ int do_bootm_linux(int flag, int argc, char * const argv[], cp = getenv("eth1addr"); if (cp) linux_env_set("eth1addr", cp); +} + +static void boot_jump_linux(bootm_headers_t *images) +{ + void (*theKernel) (int, char **, char **, int *); + + /* find kernel entry point */ + theKernel = (void (*)(int, char **, char **, int *))images->ep; + + debug("## Transferring control to Linux (at address %08lx) ...\n", + (ulong) theKernel); + + bootstage_mark(BOOTSTAGE_ID_RUN_OS); + + /* we assume that the kernel is in place */ + printf("\nStarting kernel ...\n\n"); + + theKernel(linux_argc, linux_argv, linux_env, 0); +} + +int do_bootm_linux(int flag, int argc, char * const argv[], + bootm_headers_t *images) +{ + if ((flag != 0) && (flag != BOOTM_STATE_OS_GO)) + return 1; + boot_prep_linux(images); boot_jump_linux(images); /* does not return */ -- cgit v1.1 From 9c170e2ef4ad2bd246c22c93824d754224c4929a Mon Sep 17 00:00:00 2001 From: Gabor Juhos Date: Mon, 7 Jan 2013 02:53:42 +0000 Subject: MIPS: bootm.c: add support for 'prep' and 'go' subcommands The bootm command supports subcommands since long time however those subcommands are not yet usable on MIPS. The patch is based on the ARM implementation, and it adds support for the 'prep' and 'go' subcommands only. Signed-off-by: Gabor Juhos Cc: Daniel Schwierzeck --- arch/mips/lib/bootm.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c index 8c2e508..a36154a 100644 --- a/arch/mips/lib/bootm.c +++ b/arch/mips/lib/bootm.c @@ -104,8 +104,19 @@ static void boot_jump_linux(bootm_headers_t *images) int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *images) { - if ((flag != 0) && (flag != BOOTM_STATE_OS_GO)) - return 1; + /* No need for those on MIPS */ + if (flag & BOOTM_STATE_OS_BD_T || flag & BOOTM_STATE_OS_CMDLINE) + return -1; + + if (flag & BOOTM_STATE_OS_PREP) { + boot_prep_linux(images); + return 0; + } + + if (flag & BOOTM_STATE_OS_GO) { + boot_jump_linux(images); + return 0; + } boot_prep_linux(images); boot_jump_linux(images); -- cgit v1.1 From 0f17f59c8ae4b9acf436485ed28a3d4706e91e7d Mon Sep 17 00:00:00 2001 From: Gabor Juhos Date: Tue, 8 Jan 2013 02:22:50 +0000 Subject: MIPS: qemu-mips: fix a typo in README The 'Limitations & comments' section refers to the '-m mips' switch which is not valid. The '-m' switch can be used for setting the virtual RAM size: $qemu-system-mips --help | grep '^-m ' -m megs set virtual RAM size to megs MB [default=128] $ The correct switch for specifying the machine type is '-M'. Fix the text to refer to that. Signed-off-by: Gabor Juhos Cc: Daniel Schwierzeck Cc: Vlad Lungu --- board/qemu-mips/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/qemu-mips/README b/board/qemu-mips/README index 9fd97e1..b2c2b54 100644 --- a/board/qemu-mips/README +++ b/board/qemu-mips/README @@ -6,7 +6,7 @@ http://www.nongnu.org/qemu/ Limitations & comments ---------------------- -Supports the "-m mips" configuration of qemu: serial,NE2000,IDE. +Supports the "-M mips" configuration of qemu: serial,NE2000,IDE. Support is big endian only for now (or at least this is what I tested). Derived from au1x00 with a lot of things cut out. -- cgit v1.1 From 3567e4ef115dc129b4f8720b5abd65262f32f0f9 Mon Sep 17 00:00:00 2001 From: Gabor Juhos Date: Tue, 8 Jan 2013 02:22:51 +0000 Subject: MIPS: qemu-mips: add '-M mips' switch to the example usage command Using the example command from the README file does not work as expected. qemu shows a text similar to the one below and it hangs. $ qemu-system-mips -L . -nographic Could not open option rom 'pxe-pcnet.rom': No such file or directory qemu-system-mips: pci_add_option_rom: failed to find romfile "vgabios-cirrus.bin" qemu: terminating on signal 15 from pid 19726 This happens because qemu emulates a Malta board by default if the machine type is not defined explicitely on the command line. For a working test, the '-M mips' switch is required: $ qemu-system-mips -M mips -L . -nographic Could not open option rom 'vgabios.bin': No such file or directory U-Boot 2013.01-rc2-00132-g1e8e648-dirty (Jan 08 2013 - 09:06:42) Board: Qemu -M mips CPU: 24Kf proc_id=0x19300 DRAM: 128 MiB ## Unknown flash on Bank 1 - Size = 0x00000000 = 0 MB Flash: 0 Bytes *** Warning - bad CRC, using default environment In: serial Out: serial Err: serial Net: NE2000 Hit any key to stop autoboot: 0 qemu-mips # Signed-off-by: Gabor Juhos Cc: Daniel Schwierzeck Cc: Vlad Lungu --- board/qemu-mips/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/qemu-mips/README b/board/qemu-mips/README index b2c2b54..ec58ce4 100644 --- a/board/qemu-mips/README +++ b/board/qemu-mips/README @@ -23,7 +23,7 @@ I) Example usage: # ln -s u-boot.bin mips_bios.bin start it: -qemu-system-mips -L . /dev/null -nographic +qemu-system-mips -M mips -L . /dev/null -nographic or -- cgit v1.1 From 2b086ce4a1e7bb35a885b1455239d1b1ee814f97 Mon Sep 17 00:00:00 2001 From: Daniel Schwierzeck Date: Tue, 8 Jan 2013 17:51:11 +0100 Subject: MIPS: qemu-mips: update and fix example usage in README By now U-Boot supports Qemu MIPS for little and big endian as well as 32 bit and 64 bit. Update and fix the example usage in the README to reflect this. Signed-off-by: Daniel Schwierzeck --- board/qemu-mips/README | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/board/qemu-mips/README b/board/qemu-mips/README index ec58ce4..1fdfbab 100644 --- a/board/qemu-mips/README +++ b/board/qemu-mips/README @@ -7,7 +7,7 @@ http://www.nongnu.org/qemu/ Limitations & comments ---------------------- Supports the "-M mips" configuration of qemu: serial,NE2000,IDE. -Support is big endian only for now (or at least this is what I tested). +Supports little and big endian as well as 32 bit and 64 bit. Derived from au1x00 with a lot of things cut out. Supports emulated flash (patch Jean-Christophe PLAGNIOL-VILLARD) with @@ -21,19 +21,33 @@ Notes for the Qemu MIPS port I) Example usage: -# ln -s u-boot.bin mips_bios.bin -start it: -qemu-system-mips -M mips -L . /dev/null -nographic +Using u-boot.bin as ROM (replaces Qemu monitor): -or +32 bit, big endian: +# make qemu_mips +# qemu-system-mips -M mips -bios u-boot.bin -nographic + +32 bit, little endian: +# make qemu_mipsel +# qemu-system-mipsel -M mips -bios u-boot.bin -nographic + +64 bit, big endian: +# make qemu_mips64 +# qemu-system-mips64 -cpu MIPS64R2-generic -M mips -bios u-boot.bin -nographic + +64 bit, little endian: +# make qemu_mips64el +# qemu-system-mips64el -cpu MIPS64R2-generic -M mips -bios u-boot.bin -nographic + +or using u-boot.bin from emulated flash: if you use a qemu version after commit 4224 create image: # dd of=flash bs=1k count=4k if=/dev/zero # dd of=flash bs=1k conv=notrunc if=u-boot.bin -start it: -# qemu-system-mips -M mips -pflash flash -monitor null -nographic +start it (see above): +# qemu-system-mips[64][el] [-cpu MIPS64R2-generic] -M mips -pflash flash -nographic 2) Download kernel + initrd -- cgit v1.1 From 3ed75b6f7415332f4f6c57b1d84ca720b803aed4 Mon Sep 17 00:00:00 2001 From: Daniel Schwierzeck Date: Sat, 12 Jan 2013 18:58:54 +0100 Subject: README.qemu-mips: move README file from board to doc directory Signed-off-by: Daniel Schwierzeck --- board/qemu-mips/README | 196 ------------------------------------------------- doc/README.qemu-mips | 196 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 196 insertions(+), 196 deletions(-) delete mode 100644 board/qemu-mips/README create mode 100644 doc/README.qemu-mips diff --git a/board/qemu-mips/README b/board/qemu-mips/README deleted file mode 100644 index 1fdfbab..0000000 --- a/board/qemu-mips/README +++ /dev/null @@ -1,196 +0,0 @@ -By Vlad Lungu vlad.lungu@windriver.com 2007-Oct-01 ----------------------------------------- -Qemu is a full system emulator. See - -http://www.nongnu.org/qemu/ - -Limitations & comments ----------------------- -Supports the "-M mips" configuration of qemu: serial,NE2000,IDE. -Supports little and big endian as well as 32 bit and 64 bit. -Derived from au1x00 with a lot of things cut out. - -Supports emulated flash (patch Jean-Christophe PLAGNIOL-VILLARD) with -recent qemu versions. When using emulated flash, launch with --pflash and erase mips_bios.bin. - - - -Notes for the Qemu MIPS port ----------------------------- - -I) Example usage: - -Using u-boot.bin as ROM (replaces Qemu monitor): - -32 bit, big endian: -# make qemu_mips -# qemu-system-mips -M mips -bios u-boot.bin -nographic - -32 bit, little endian: -# make qemu_mipsel -# qemu-system-mipsel -M mips -bios u-boot.bin -nographic - -64 bit, big endian: -# make qemu_mips64 -# qemu-system-mips64 -cpu MIPS64R2-generic -M mips -bios u-boot.bin -nographic - -64 bit, little endian: -# make qemu_mips64el -# qemu-system-mips64el -cpu MIPS64R2-generic -M mips -bios u-boot.bin -nographic - -or using u-boot.bin from emulated flash: - -if you use a qemu version after commit 4224 - -create image: -# dd of=flash bs=1k count=4k if=/dev/zero -# dd of=flash bs=1k conv=notrunc if=u-boot.bin -start it (see above): -# qemu-system-mips[64][el] [-cpu MIPS64R2-generic] -M mips -pflash flash -nographic - -2) Download kernel + initrd - -On ftp://ftp.denx.de/pub/contrib/Jean-Christophe_Plagniol-Villard/qemu_mips/ -you can downland - -#config to build the kernel -qemu_mips_defconfig -#patch to fix mips interrupt init on 2.6.24.y kernel -qemu_mips_kernel.patch -initrd.gz -vmlinux -vmlinux.bin -System.map - -4) Generate uImage - -# tools/mkimage -A mips -O linux -T kernel -C gzip -a 0x80010000 -e 0x80245650 -n "Linux 2.6.24.y" -d vmlinux.bin.gz uImage - -5) Copy uImage to Flash -# dd if=uImage bs=1k conv=notrunc seek=224 of=flash - -6) Generate Ide Disk - -# dd of=ide bs=1k cout=100k if=/dev/zero - -# sfdisk -C 261 -d ide -# partition table of ide -unit: sectors - - ide1 : start= 63, size= 32067, Id=83 - ide2 : start= 32130, size= 32130, Id=83 - ide3 : start= 64260, size= 4128705, Id=83 - ide4 : start= 0, size= 0, Id= 0 - -7) Copy to ide - -# dd if=uImage bs=512 conv=notrunc seek=63 of=ide - -8) Generate ext2 on part 2 on Copy uImage and initrd.gz - -# Attached as loop device ide offset = 32130 * 512 -# losetup -o 16450560 -f ide -# Format as ext2 ( arg2 : nb blocks) -# mke2fs /dev/loop0 16065 -# losetup -d /dev/loop0 -# Mount and copy uImage and initrd.gz to it -# mount -o loop,offset=16450560 -t ext2 ide /mnt -# mkdir /mnt/boot -# cp {initrd.gz,uImage} /mnt/boot/ -# Umount it -# umount /mnt - -9) Set Environment - -setenv rd_start 0x80800000 -setenv rd_size 2663940 -setenv kernel BFC38000 -setenv oad_addr 80500000 -setenv load_addr2 80F00000 -setenv kernel_flash BFC38000 -setenv load_addr_hello 80200000 -setenv bootargs 'root=/dev/ram0 init=/bin/sh' -setenv load_rd_ext2 'ide res; ext2load ide 0:2 ${rd_start} /boot/initrd.gz' -setenv load_rd_tftp 'tftp ${rd_start} /initrd.gz' -setenv load_kernel_hda 'ide res; diskboot ${load_addr} 0:2' -setenv load_kernel_ext2 'ide res; ext2load ide 0:2 ${load_addr} /boot/uImage' -setenv load_kernel_tftp 'tftp ${load_addr} /qemu_mips/uImage' -setenv boot_ext2_ext2 'run load_rd_ext2; run load_kernel_ext2; run addmisc; bootm ${load_addr}' -setenv boot_ext2_flash 'run load_rd_ext2; run addmisc; bootm ${kernel_flash}' -setenv boot_ext2_hda 'run load_rd_ext2; run load_kernel_hda; run addmisc; bootm ${load_addr}' -setenv boot_ext2_tftp 'run load_rd_ext2; run load_kernel_tftp; run addmisc; bootm ${load_addr}' -setenv boot_tftp_hda 'run load_rd_tftp; run load_kernel_hda; run addmisc; bootm ${load_addr}' -setenv boot_tftp_ext2 'run load_rd_tftp; run load_kernel_ext2; run addmisc; bootm ${load_addr}' -setenv boot_tftp_flash 'run load_rd_tftp; run addmisc; bootm ${kernel_flash}' -setenv boot_tftp_tftp 'run load_rd_tftp; run load_kernel_tftp; run addmisc; bootm ${load_addr}' -setenv load_hello_tftp 'tftp ${load_addr_hello} /examples/hello_world.bin' -setenv go_tftp 'run load_hello_tftp; go ${load_addr_hello}' -setenv addmisc 'setenv bootargs ${bootargs} console=ttyS0,${baudrate} rd_start=${rd_start} rd_size=${rd_size} ethaddr=${ethaddr}' -setenv bootcmd 'run boot_tftp_flash' - -10) Now you can boot from flash, ide, ide+ext2 and tfp - -# qemu-system-mips -M mips -pflash flash -monitor null -nographic -net nic -net user -tftp `pwd` -hda ide - -II) How to debug U-Boot - -In order to debug U-Boot you need to start qemu with gdb server support (-s) -and waiting the connection to start the CPU (-S) - -# qemu-system-mips -S -s -M mips -pflash flash -monitor null -nographic -net nic -net user -tftp `pwd` -hda ide - -in an other console you start gdb - -1) Debugging of U-Boot Before Relocation - -Before relocation, the addresses in the ELF file can be used without any problems -by connecting to the gdb server localhost:1234 - -# mipsel-unknown-linux-gnu-gdb u-boot -GNU gdb 6.6 -Copyright (C) 2006 Free Software Foundation, Inc. -GDB is free software, covered by the GNU General Public License, and you are -welcome to change it and/or distribute copies of it under certain conditions. -Type "show copying" to see the conditions. -There is absolutely no warranty for GDB. Type "show warranty" for details. -This GDB was configured as "--host=i486-linux-gnu --target=mipsel-unknown-linux-gnu"... -(gdb) target remote localhost:1234 -Remote debugging using localhost:1234 -_start () at start.S:64 -64 RVECENT(reset,0) /* U-boot entry point */ -Current language: auto; currently asm -(gdb) b board.c:289 -Breakpoint 1 at 0xbfc00cc8: file board.c, line 289. -(gdb) c -Continuing. - -Breakpoint 1, board_init_f (bootflag=) at board.c:290 -290 relocate_code (addr_sp, id, addr); -Current language: auto; currently c -(gdb) p/x addr -$1 = 0x87fa0000 - -2) Debugging of U-Boot After Relocation - -For debugging U-Boot after relocation we need to know the address to which -U-Boot relocates itself to 0x87fa0000 by default. -And replace the symbol table to this offset. - -(gdb) symbol-file -Discard symbol table from `/private/u-boot-arm/u-boot'? (y or n) y -Error in re-setting breakpoint 1: -No symbol table is loaded. Use the "file" command. -No symbol file now. -(gdb) add-symbol-file u-boot 0x87fa0000 -add symbol table from file "u-boot" at - .text_addr = 0x87fa0000 -(y or n) y -Reading symbols from /private/u-boot-arm/u-boot...done. -Breakpoint 1 at 0x87fa0cc8: file board.c, line 289. -(gdb) c -Continuing. - -Program received signal SIGINT, Interrupt. -0xffffffff87fa0de4 in udelay (usec=) at time.c:78 -78 while ((tmo - read_c0_count()) < 0x7fffffff) diff --git a/doc/README.qemu-mips b/doc/README.qemu-mips new file mode 100644 index 0000000..1fdfbab --- /dev/null +++ b/doc/README.qemu-mips @@ -0,0 +1,196 @@ +By Vlad Lungu vlad.lungu@windriver.com 2007-Oct-01 +---------------------------------------- +Qemu is a full system emulator. See + +http://www.nongnu.org/qemu/ + +Limitations & comments +---------------------- +Supports the "-M mips" configuration of qemu: serial,NE2000,IDE. +Supports little and big endian as well as 32 bit and 64 bit. +Derived from au1x00 with a lot of things cut out. + +Supports emulated flash (patch Jean-Christophe PLAGNIOL-VILLARD) with +recent qemu versions. When using emulated flash, launch with +-pflash and erase mips_bios.bin. + + + +Notes for the Qemu MIPS port +---------------------------- + +I) Example usage: + +Using u-boot.bin as ROM (replaces Qemu monitor): + +32 bit, big endian: +# make qemu_mips +# qemu-system-mips -M mips -bios u-boot.bin -nographic + +32 bit, little endian: +# make qemu_mipsel +# qemu-system-mipsel -M mips -bios u-boot.bin -nographic + +64 bit, big endian: +# make qemu_mips64 +# qemu-system-mips64 -cpu MIPS64R2-generic -M mips -bios u-boot.bin -nographic + +64 bit, little endian: +# make qemu_mips64el +# qemu-system-mips64el -cpu MIPS64R2-generic -M mips -bios u-boot.bin -nographic + +or using u-boot.bin from emulated flash: + +if you use a qemu version after commit 4224 + +create image: +# dd of=flash bs=1k count=4k if=/dev/zero +# dd of=flash bs=1k conv=notrunc if=u-boot.bin +start it (see above): +# qemu-system-mips[64][el] [-cpu MIPS64R2-generic] -M mips -pflash flash -nographic + +2) Download kernel + initrd + +On ftp://ftp.denx.de/pub/contrib/Jean-Christophe_Plagniol-Villard/qemu_mips/ +you can downland + +#config to build the kernel +qemu_mips_defconfig +#patch to fix mips interrupt init on 2.6.24.y kernel +qemu_mips_kernel.patch +initrd.gz +vmlinux +vmlinux.bin +System.map + +4) Generate uImage + +# tools/mkimage -A mips -O linux -T kernel -C gzip -a 0x80010000 -e 0x80245650 -n "Linux 2.6.24.y" -d vmlinux.bin.gz uImage + +5) Copy uImage to Flash +# dd if=uImage bs=1k conv=notrunc seek=224 of=flash + +6) Generate Ide Disk + +# dd of=ide bs=1k cout=100k if=/dev/zero + +# sfdisk -C 261 -d ide +# partition table of ide +unit: sectors + + ide1 : start= 63, size= 32067, Id=83 + ide2 : start= 32130, size= 32130, Id=83 + ide3 : start= 64260, size= 4128705, Id=83 + ide4 : start= 0, size= 0, Id= 0 + +7) Copy to ide + +# dd if=uImage bs=512 conv=notrunc seek=63 of=ide + +8) Generate ext2 on part 2 on Copy uImage and initrd.gz + +# Attached as loop device ide offset = 32130 * 512 +# losetup -o 16450560 -f ide +# Format as ext2 ( arg2 : nb blocks) +# mke2fs /dev/loop0 16065 +# losetup -d /dev/loop0 +# Mount and copy uImage and initrd.gz to it +# mount -o loop,offset=16450560 -t ext2 ide /mnt +# mkdir /mnt/boot +# cp {initrd.gz,uImage} /mnt/boot/ +# Umount it +# umount /mnt + +9) Set Environment + +setenv rd_start 0x80800000 +setenv rd_size 2663940 +setenv kernel BFC38000 +setenv oad_addr 80500000 +setenv load_addr2 80F00000 +setenv kernel_flash BFC38000 +setenv load_addr_hello 80200000 +setenv bootargs 'root=/dev/ram0 init=/bin/sh' +setenv load_rd_ext2 'ide res; ext2load ide 0:2 ${rd_start} /boot/initrd.gz' +setenv load_rd_tftp 'tftp ${rd_start} /initrd.gz' +setenv load_kernel_hda 'ide res; diskboot ${load_addr} 0:2' +setenv load_kernel_ext2 'ide res; ext2load ide 0:2 ${load_addr} /boot/uImage' +setenv load_kernel_tftp 'tftp ${load_addr} /qemu_mips/uImage' +setenv boot_ext2_ext2 'run load_rd_ext2; run load_kernel_ext2; run addmisc; bootm ${load_addr}' +setenv boot_ext2_flash 'run load_rd_ext2; run addmisc; bootm ${kernel_flash}' +setenv boot_ext2_hda 'run load_rd_ext2; run load_kernel_hda; run addmisc; bootm ${load_addr}' +setenv boot_ext2_tftp 'run load_rd_ext2; run load_kernel_tftp; run addmisc; bootm ${load_addr}' +setenv boot_tftp_hda 'run load_rd_tftp; run load_kernel_hda; run addmisc; bootm ${load_addr}' +setenv boot_tftp_ext2 'run load_rd_tftp; run load_kernel_ext2; run addmisc; bootm ${load_addr}' +setenv boot_tftp_flash 'run load_rd_tftp; run addmisc; bootm ${kernel_flash}' +setenv boot_tftp_tftp 'run load_rd_tftp; run load_kernel_tftp; run addmisc; bootm ${load_addr}' +setenv load_hello_tftp 'tftp ${load_addr_hello} /examples/hello_world.bin' +setenv go_tftp 'run load_hello_tftp; go ${load_addr_hello}' +setenv addmisc 'setenv bootargs ${bootargs} console=ttyS0,${baudrate} rd_start=${rd_start} rd_size=${rd_size} ethaddr=${ethaddr}' +setenv bootcmd 'run boot_tftp_flash' + +10) Now you can boot from flash, ide, ide+ext2 and tfp + +# qemu-system-mips -M mips -pflash flash -monitor null -nographic -net nic -net user -tftp `pwd` -hda ide + +II) How to debug U-Boot + +In order to debug U-Boot you need to start qemu with gdb server support (-s) +and waiting the connection to start the CPU (-S) + +# qemu-system-mips -S -s -M mips -pflash flash -monitor null -nographic -net nic -net user -tftp `pwd` -hda ide + +in an other console you start gdb + +1) Debugging of U-Boot Before Relocation + +Before relocation, the addresses in the ELF file can be used without any problems +by connecting to the gdb server localhost:1234 + +# mipsel-unknown-linux-gnu-gdb u-boot +GNU gdb 6.6 +Copyright (C) 2006 Free Software Foundation, Inc. +GDB is free software, covered by the GNU General Public License, and you are +welcome to change it and/or distribute copies of it under certain conditions. +Type "show copying" to see the conditions. +There is absolutely no warranty for GDB. Type "show warranty" for details. +This GDB was configured as "--host=i486-linux-gnu --target=mipsel-unknown-linux-gnu"... +(gdb) target remote localhost:1234 +Remote debugging using localhost:1234 +_start () at start.S:64 +64 RVECENT(reset,0) /* U-boot entry point */ +Current language: auto; currently asm +(gdb) b board.c:289 +Breakpoint 1 at 0xbfc00cc8: file board.c, line 289. +(gdb) c +Continuing. + +Breakpoint 1, board_init_f (bootflag=) at board.c:290 +290 relocate_code (addr_sp, id, addr); +Current language: auto; currently c +(gdb) p/x addr +$1 = 0x87fa0000 + +2) Debugging of U-Boot After Relocation + +For debugging U-Boot after relocation we need to know the address to which +U-Boot relocates itself to 0x87fa0000 by default. +And replace the symbol table to this offset. + +(gdb) symbol-file +Discard symbol table from `/private/u-boot-arm/u-boot'? (y or n) y +Error in re-setting breakpoint 1: +No symbol table is loaded. Use the "file" command. +No symbol file now. +(gdb) add-symbol-file u-boot 0x87fa0000 +add symbol table from file "u-boot" at + .text_addr = 0x87fa0000 +(y or n) y +Reading symbols from /private/u-boot-arm/u-boot...done. +Breakpoint 1 at 0x87fa0cc8: file board.c, line 289. +(gdb) c +Continuing. + +Program received signal SIGINT, Interrupt. +0xffffffff87fa0de4 in udelay (usec=) at time.c:78 +78 while ((tmo - read_c0_count()) < 0x7fffffff) -- cgit v1.1 From 54b08efcf2f4ff532ce99c53f341a59c193331a5 Mon Sep 17 00:00:00 2001 From: Daniel Schwierzeck Date: Sat, 12 Jan 2013 19:09:11 +0100 Subject: README.mips: update known issues and TODOs Signed-off-by: Daniel Schwierzeck --- doc/README.mips | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/doc/README.mips b/doc/README.mips index 85dea40..f4f770b 100644 --- a/doc/README.mips +++ b/doc/README.mips @@ -16,11 +16,6 @@ Toolchains Known Issues ------------ - * Little endian build problem - - If use non-ELDK toolchains, -EB will be set to CPPFLAGS. Therefore all - objects will be generated in big-endian format. - * Cache incoherency issue caused by do_bootelf_exec() at cmd_elf.c Cache will be disabled before entering the loaded ELF image without @@ -55,3 +50,9 @@ TODOs * Due to cache initialization issues, the DRAM on board must be initialized in board specific assembler language before the cache init code is run -- that is, initialize the DRAM in lowlevel_init(). + + * get rid of CONFIG_MANUAL_RELOC + + * centralize/share more CPU code of MIPS32, MIPS64 and XBurst + + * support Qemu Malta -- cgit v1.1