linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: "machael thailer" <dony.he@huawei.com>
To: "Wolfgang Denk" <wd@denx.de>, "Dan Malek" <dan@mvista.com>,
	"Cort Dougan" <cort@fsmlabs.com>
Cc: <linuxppc-embedded@lists.linuxppc.org>
Subject: Uncompress Ok, but cannot run linux kernel...
Date: Sun, 6 May 2001 09:01:59 +0800	[thread overview]
Message-ID: <001d01c0d5c8$27ae8c60$8021690a@huawei.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1591 bytes --]

Hello:

    I have a 750-based custom board. I want to port linux-2.4.2 on it. The
bootrom code which initialized the hardware is working OK. I want to
download the linux kernel via TFTP(and it is OK now) and run it. But I met
some urgent problems ...
    I modified the bootloader codes according to arch/ppc/mbxboot/head.S and
other "printf" functions to suit my cases. And it runs like the following:

################################
Loading... 611056
Starting at 0x400000...

loaded at:     00400000 004952F0
zimage at:     004062C8 0048F994
avail ram:     004952F0 10000000

Linux/PPC load:
Uncompressing Linux...done.
Now booting the kernel
###################################

Then nothing happens(I have added a serial output code at the very begining
of arch/ppc/kernel/head.S and  have nothing output.). By printing the code
from 0x0 to 0x400000 I find the uncompressed code is right. After
uncompressing it jumps to 0x0(arch/ppc/mbxboot/head.S), but it cannot run .
Why?
Then I write a simple HelloWorld program  and compile it with -Ttext=0x0
compiling options, then use it to replace /usr/src/linux/vmlinux and
recompile the kernel.This time it works OK like the following:
################################
Loading... 4326
Starting at 0x400000...

loaded at:     ..........
zimage at:     ..........
avail ram:     ..........

Linux/PPC load:
Uncompressing Linux...done.
Now booting the kernel

Hello world
###################################

Here I attach my .config and arch/ppc/mbxboot/head.S. Hope you can help me
if you are free.

Thank you very much.

machael thailer



[-- Attachment #2: config --]
[-- Type: application/octet-stream, Size: 6857 bytes --]

#
# Automatically generated make config: don't edit
#
# CONFIG_UID16 is not set

#
# Code maturity level options
#
# CONFIG_EXPERIMENTAL is not set

#
# Loadable module support
#
CONFIG_MODULES=y
# CONFIG_MODVERSIONS is not set
# CONFIG_KMOD is not set

#
# Platform support
#
CONFIG_PPC=y
CONFIG_6xx=y
# CONFIG_4xx is not set
# CONFIG_POWER3 is not set
# CONFIG_POWER4 is not set
# CONFIG_8xx is not set
# CONFIG_8260 is not set
CONFIG_ALL_PPC=y
# CONFIG_APUS is not set
# CONFIG_PPC601_SYNC_FIX is not set
# CONFIG_SMP is not set
# CONFIG_ALTIVEC is not set

#
# General setup
#
# CONFIG_HIGHMEM is not set
# CONFIG_MOL is not set
# CONFIG_ISA is not set
# CONFIG_EISA is not set
# CONFIG_SBUS is not set
# CONFIG_MCA is not set
CONFIG_PCI=y
CONFIG_NET=y
CONFIG_SYSCTL=y
CONFIG_SYSVIPC=y
# CONFIG_BSD_PROCESS_ACCT is not set
CONFIG_KCORE_ELF=y
CONFIG_BINFMT_ELF=y
CONFIG_KERNEL_ELF=y
# CONFIG_BINFMT_MISC is not set
CONFIG_PCI_NAMES=y
# CONFIG_HOTPLUG is not set
# CONFIG_PCMCIA is not set

#
# Parallel port support
#
# CONFIG_PARPORT is not set
# CONFIG_PPC_RTC is not set
CONFIG_PROC_DEVICETREE=y
CONFIG_PPC_RTAS=y
# CONFIG_BOOTX_TEXT is not set
# CONFIG_PREP_RESIDUAL is not set
# CONFIG_CMDLINE_BOOL is not set

#
# Memory Technology Devices (MTD)
#
# CONFIG_MTD is not set

#
# Plug and Play configuration
#
# CONFIG_PNP is not set

#
# Block devices
#
# CONFIG_BLK_DEV_FD is not set
# CONFIG_BLK_CPQ_DA is not set
# CONFIG_BLK_CPQ_CISS_DA is not set
# CONFIG_BLK_DEV_DAC960 is not set
# CONFIG_BLK_DEV_LOOP is not set
# CONFIG_BLK_DEV_NBD is not set
CONFIG_BLK_DEV_RAM=y
CONFIG_BLK_DEV_RAM_SIZE=4096
# CONFIG_BLK_DEV_INITRD is not set

#
# Multi-device support (RAID and LVM)
#
# CONFIG_MD is not set

#
# Networking options
#
# CONFIG_PACKET is not set
# CONFIG_NETLINK is not set
# CONFIG_NETFILTER is not set
# CONFIG_FILTER is not set
CONFIG_UNIX=y
CONFIG_INET=y
# CONFIG_IP_MULTICAST is not set
# CONFIG_IP_ADVANCED_ROUTER is not set
CONFIG_IP_PNP=y
# CONFIG_IP_PNP_BOOTP is not set
# CONFIG_IP_PNP_RARP is not set
# CONFIG_NET_IPIP is not set
# CONFIG_NET_IPGRE is not set
# CONFIG_INET_ECN is not set
# CONFIG_SYN_COOKIES is not set

#
#  
#
# CONFIG_IPX is not set
# CONFIG_ATALK is not set
# CONFIG_DECNET is not set
# CONFIG_BRIDGE is not set

#
# QoS and/or fair queueing
#
# CONFIG_NET_SCHED is not set

#
# ATA/IDE/MFM/RLL support
#
# CONFIG_IDE is not set
# CONFIG_BLK_DEV_IDE_MODES is not set
# CONFIG_BLK_DEV_HD is not set

#
# SCSI support
#
# CONFIG_SCSI is not set

#
# Network device support
#
CONFIG_NETDEVICES=y

#
# ARCnet devices
#
# CONFIG_ARCNET is not set
# CONFIG_DUMMY is not set
# CONFIG_BONDING is not set
# CONFIG_EQUALIZER is not set
# CONFIG_TUN is not set
# CONFIG_NET_SB1000 is not set

#
# Ethernet (10 or 100Mbit)
#
CONFIG_NET_ETHERNET=y
# CONFIG_MACE is not set
# CONFIG_BMAC is not set
# CONFIG_GMAC is not set
# CONFIG_NCR885E is not set
# CONFIG_OAKNET is not set
# CONFIG_NET_VENDOR_3COM is not set
# CONFIG_NET_VENDOR_SMC is not set
# CONFIG_NET_VENDOR_RACAL is not set
# CONFIG_DEPCA is not set
# CONFIG_HP100 is not set
CONFIG_NET_PCI=y
# CONFIG_PCNET32 is not set
# CONFIG_APRICOT is not set
# CONFIG_TULIP is not set
# CONFIG_DE4X5 is not set
# CONFIG_DGRS is not set
CONFIG_EEPRO100=y
# CONFIG_NATSEMI is not set
# CONFIG_NE2K_PCI is not set
# CONFIG_8139TOO is not set
# CONFIG_SIS900 is not set
# CONFIG_EPIC100 is not set
# CONFIG_SUNDANCE is not set
# CONFIG_TLAN is not set
# CONFIG_VIA_RHINE is not set
# CONFIG_WINBOND_840 is not set
# CONFIG_HAPPYMEAL is not set
# CONFIG_NET_POCKET is not set

#
# Ethernet (1000 Mbit)
#
# CONFIG_ACENIC is not set
# CONFIG_HAMACHI is not set
# CONFIG_SK98LIN is not set
# CONFIG_FDDI is not set
# CONFIG_PPP is not set
# CONFIG_SLIP is not set

#
# Wireless LAN (non-hamradio)
#
# CONFIG_NET_RADIO is not set

#
# Token Ring devices
#
# CONFIG_TR is not set
# CONFIG_NET_FC is not set

#
# Wan interfaces
#
# CONFIG_WAN is not set

#
# Amateur Radio support
#
# CONFIG_HAMRADIO is not set

#
# IrDA (infrared) support
#
# CONFIG_IRDA is not set

#
# ISDN subsystem
#
# CONFIG_ISDN is not set

#
# Old CD-ROM drivers (not SCSI, not IDE)
#
# CONFIG_CD_NO_IDESCSI is not set

#
# Console drivers
#
# CONFIG_VGA_CONSOLE is not set

#
# Frame-buffer support
#
# CONFIG_FB is not set

#
# Input core support
#
# CONFIG_INPUT is not set

#
# Macintosh device drivers
#
# CONFIG_ADB_CUDA is not set
# CONFIG_ADB_PMU is not set
# CONFIG_MAC_FLOPPY is not set
# CONFIG_MAC_SERIAL is not set
# CONFIG_ADB is not set

#
# Character devices
#
# CONFIG_VT is not set
CONFIG_SERIAL=y
CONFIG_SERIAL_CONSOLE=y
# CONFIG_SERIAL_EXTENDED is not set
# CONFIG_SERIAL_NONSTANDARD is not set
# CONFIG_UNIX98_PTYS is not set

#
# I2C support
#
# CONFIG_I2C is not set

#
# Mice
#
# CONFIG_BUSMOUSE is not set
# CONFIG_MOUSE is not set

#
# Joysticks
#

#
# Game port support
#

#
# Gameport joysticks
#

#
# Serial port support
#

#
# Serial port joysticks
#

#
# Parallel port joysticks
#

#
#   Parport support is needed for parallel port joysticks
#
# CONFIG_QIC02_TAPE is not set

#
# Watchdog Cards
#
# CONFIG_WATCHDOG is not set
# CONFIG_INTEL_RNG is not set
# CONFIG_NVRAM is not set
# CONFIG_RTC is not set
# CONFIG_DTLK is not set
# CONFIG_R3964 is not set
# CONFIG_APPLICOM is not set

#
# Ftape, the floppy tape device driver
#
# CONFIG_FTAPE is not set
# CONFIG_AGP is not set
# CONFIG_DRM is not set

#
# Multimedia devices
#
# CONFIG_VIDEO_DEV is not set

#
# File systems
#
# CONFIG_QUOTA is not set
# CONFIG_AUTOFS_FS is not set
# CONFIG_AUTOFS4_FS is not set
# CONFIG_FAT_FS is not set
CONFIG_JFFS_FS_VERBOSE=0
# CONFIG_CRAMFS is not set
# CONFIG_RAMFS is not set
# CONFIG_ISO9660_FS is not set
# CONFIG_MINIX_FS is not set
# CONFIG_NTFS_FS is not set
# CONFIG_HPFS_FS is not set
CONFIG_PROC_FS=y
# CONFIG_ROMFS_FS is not set
CONFIG_EXT2_FS=y
# CONFIG_SYSV_FS is not set
# CONFIG_UDF_FS is not set
# CONFIG_UFS_FS is not set

#
# Network File Systems
#
# CONFIG_CODA_FS is not set
CONFIG_NFS_FS=y
# CONFIG_NFS_V3 is not set
CONFIG_ROOT_NFS=y
# CONFIG_NFSD is not set
CONFIG_SUNRPC=y
CONFIG_LOCKD=y
# CONFIG_SMB_FS is not set
# CONFIG_NCP_FS is not set

#
# Partition Types
#
# CONFIG_PARTITION_ADVANCED is not set
CONFIG_MSDOS_PARTITION=y
# CONFIG_SMB_NLS is not set
# CONFIG_NLS is not set

#
# Sound
#
# CONFIG_SOUND is not set

#
# USB support
#
# CONFIG_USB is not set

#
# Kernel hacking
#
# CONFIG_MAGIC_SYSRQ is not set
# CONFIG_KGDB is not set
# CONFIG_XMON is not set

[-- Attachment #3: head.S --]
[-- Type: application/octet-stream, Size: 6238 bytes --]

#include "../kernel/ppc_defs.h"
#include "../kernel/ppc_asm.tmpl"
#include <asm/processor.h>
#include <asm/cache.h>

	.text

/*
 * $Id: head_750.S,v 1.1 2001/04/27 01:27:32 gujianxin Exp $
 *	
 * Boot loader philosophy:
 *
 *      ROM loads us to some arbitrary location
 *      ROM loads these registers:
 *	
 *          R3 = Pointer to the board configuration data
 *          R5 = Pointer to Open Firmware data 	
 *		 	
 *      ROM jumps to start/start_
 *      Move the boot code to the link address (4 MB)
 *      Call decompress_kernel()
 *         Relocate the initrd, zimage and residual data to 4 MB
 *         Decompress the kernel to 0
 *      Jump to the kernel entry
 *            -- Cort
 */
	.globl	start
start:

	bl	start_
start_:

	li 	r3,0x0
	li 	r5,0x0

	mr	r11,r3		/* Save pointer to residual/board data */
	mr      r25,r5          /* Save OFW pointer */
	li	r3,MSR_IP	/* Establish default MSR value */
	mtmsr	r3

/* check if we need to relocate ourselves to the link addr or were we
   loaded there to begin with -- Cort */
	lis	r4,start@h
	ori	r4,r4,start@l
	mflr	r3
	subi	r3,r3,4		/* we get the nip, not the ip of the branch */
	mr	r8,r3
	cmp	0,r3,r4
	bne	1010f
/* compute size of whole image in words.  this should be moved to
 * start_ldr() -- Cort
 */
	lis	r4,start@h
	ori	r4,r4,start@l
	lis	r5,end@h
	ori	r5,r5,end@l
	addi	r5,r5,3		/* round up */
	sub	r5,r5,r4
	srwi	r5,r5,2
	mr	r7,r5
	b	start_ldr
1010:
/* 
 * no matter where we're loaded, move ourselves to -Ttext address
 */
relocate:
	mflr	r3		/* Compute code bias */
	subi	r3,r3,4
	mr	r8,r3
	lis	r4,start@h
	ori	r4,r4,start@l
	lis	r5,end@h
	ori	r5,r5,end@l
	addi	r5,r5,3			/* Round up - just in case */
	sub	r5,r5,r4		/* Compute # longwords to move */
	srwi	r5,r5,2
	mtctr	r5
	mr	r7,r5
	li	r6,0
	subi	r3,r3,4			/* Set up for loop */
	subi	r4,r4,4
00:	lwzu	r5,4(r3)
	stwu	r5,4(r4)
	xor	r6,r6,r5
	bdnz	00b
  	lis	r3,start_ldr@h
	ori	r3,r3,start_ldr@l
	mtlr	r3			/* Easiest way to do an absolute jump */
	blr
start_ldr:
/* Clear all of BSS */
	lis	r3,edata@h
	ori	r3,r3,edata@l
	lis	r4,end@h
	ori	r4,r4,end@l
	subi	r3,r3,4
	subi	r4,r4,4
	li	r0,0
50:	stwu	r0,4(r3)
	cmp	0,r3,r4
	bne	50b
90:	mr	r9,r1			/* Save old stack pointer (in case it matters) */
	lis	r1,.stack@h
	ori	r1,r1,.stack@l
	addi	r1,r1,4096*2
	subi	r1,r1,256
	li	r2,0x000F		/* Mask pointer to 16-byte boundary */
	andc	r1,r1,r2

	/* Speed us up a little.
	*/
	bl	flush_instruction_cache

/* Run loader */
	mr	r3,r8			/* Load point */
	mr	r4,r7			/* Program length */
	mr	r5,r6			/* Checksum */
	mr	r6,r11			/* Residual data */
	mr      r7,r25                  /* OFW interfaces */
	bl	decompress_kernel

	
	
	/* changed to use r3 (as firmware does) for kernel
	   as ptr to residual -- Cort*/
	lis	r6,cmd_line@h
	ori	r6,r6,cmd_line@l
	lwz	r6, 0(r6)
	subi	r7,r6,1
00:	lbzu	r2,1(r7)
	cmpi	0,r2,0
	bne	00b

	/* r4,r5 have initrd_start, size */
	lis	r2,initrd_start@h
	ori	r2,r2,initrd_start@l
	lwz	r4,0(r2)
	lis	r2,initrd_end@h
	ori	r2,r2,initrd_end@l
	lwz	r5,0(r2)
	
	/* tell kernel we're prep */
	/* 
	 * get start address of kernel code which is stored as a coff
	 * entry.  see boot/head.S -- Cort 
	 */
	li	r9,0x4
	mtlr	r9
	lis	r10,0xdeadc0de@h
	ori	r10,r10,0xdeadc0de@l
	li	r9,0
	stw	r10,0(r9)


#if 1	 
/*
 * The Radstone firmware maps PCI memory at 0xc0000000 using BAT2
 * so disable BATs before setting this to avoid a clash
 */
	li      r8,0
	mtspr   DBAT0U,r8
	isync
	mtspr   DBAT0L,r8
	isync
	mtspr   DBAT1U,r8
	isync
	mtspr   DBAT1L,r8
	isync
	mtspr   DBAT2U,r8
	isync
	mtspr   DBAT2L,r8
	isync
	mtspr   DBAT3U,r8
	isync
	mtspr   DBAT3L,r8
	isync
	mtspr   IBAT0U,r8
	isync
	mtspr   IBAT0L,r8
	isync
	mtspr   IBAT1U,r8
	isync
	mtspr   IBAT1L,r8
	isync
	mtspr   IBAT2U,r8
	isync
	mtspr   IBAT2L,r8
	isync
	mtspr   IBAT3U,r8
	isync
	mtspr   IBAT3L,r8
	isync

    xor	    r0,r0,r0		
    mfspr   r8,HID0
    sync
    addi    r9,r0,0x0800
    or      r8,r9,r8
    mtspr   HID0,r8         /* set ICFI (bit 20) */
    sync

    andc    r8,r8,r9
    mtspr   HID0,r8         /* clear ICFI (bit 20) */
    sync

    addi    r9,r0,0x2000    /* Clear ILOCK (bit 18) (instr sign extends) */
    andc     r8,r8,r9 
    mtspr   HID0,r8
    sync

    addi    r9,r0,0x7fff   
    and     r8,r8,r9    /* CLear ICE (bit 16) */
    mtspr   HID0,r8
    sync
#endif    


	blr
hang:
	b	hang	

/*
 * Delay for a number of microseconds
 * -- Use the BUS timer (assumes 66MHz)
 */
	.globl	udelay
udelay:		
	mfspr	r4,PVR
	srwi	r4,r4,16
	cmpi	0,r4,1		/* 601 ? */
	bne	.udelay_not_601
00:	li	r0,86	/* Instructions / microsecond? */
	mtctr	r0
10:	addi	r0,r0,0 /* NOP */
	bdnz	10b
	subic.	r3,r3,1
	bne	00b
	blr

.udelay_not_601:		
	mulli	r4,r3,1000	/* nanoseconds */
	addi	r4,r4,59
	li	r5,60
	divw	r4,r4,r5	/* BUS ticks */
1:	mftbu	r5
	mftb	r6
	mftbu	r7
	cmp	0,r5,r7
	bne	1b		/* Get [synced] base time */
	addc	r9,r6,r4	/* Compute end time */
	addze	r8,r5
2:	mftbu	r5
	cmp	0,r5,r8
	blt	2b
	bgt	3f
	mftb	r6
	cmp	0,r6,r9
	blt	2b
3:	blr		

.globl _get_HID0
_get_HID0:		
	mfspr	r3,HID0
	blr

.globl _put_HID0
_put_HID0:		
	mtspr	HID0,r3
	blr
		
.globl _get_MSR
_get_MSR:		
	mfmsr	r3
	blr
	
.globl _put_MSR
_put_MSR:		
	mtmsr	r3
	blr

/*
 * Flush instruction cache
 * *** I'm really paranoid here!
 */
_GLOBAL(flush_instruction_cache)
	mflr	r5
	bl	flush_data_cache
	mfspr	r3,HID0	/* Caches are controlled by this register */
	li	r4,0
	ori	r4,r4,(HID0_ICE|HID0_ICFI)
	or	r3,r3,r4	/* Need to enable+invalidate to clear */
	mtspr	HID0,r3
	andc	r3,r3,r4
	ori	r3,r3,HID0_ICE	/* Enable cache */
	mtspr	HID0,r3
	mtlr	r5
	blr
	
#define NUM_CACHE_LINES 128*8
#define CACHE_LINE_SIZE 32 
#define cache_flush_buffer 0x1000

/*
 * Flush data cache
 * *** I'm really paranoid here!
 */
_GLOBAL(flush_data_cache)
	lis	r3,cache_flush_buffer@h
	ori	r3,r3,cache_flush_buffer@l
	li	r4,NUM_CACHE_LINES
	mtctr	r4
00:	lwz	r4,0(r3)
	addi	r3,r3,CACHE_LINE_SIZE	/* Next line, please */
	bdnz	00b	
10:	blr
	.comm	.stack,4096*2,4

             reply	other threads:[~2001-05-06  1:01 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-05-06  1:01 machael thailer [this message]
2001-05-07 19:10 ` Uncompress Ok, but cannot run linux kernel Dan Malek
2001-05-08  1:36   ` machael thailer
2001-05-10  3:08   ` machael thailer
2001-05-10 10:45     ` Matt Porter
2001-05-08  0:58 ` Michael Habermann
2001-05-08  1:16   ` Dan Malek
2001-05-08  8:02     ` Michael Habermann
2001-05-08  8:06       ` machael thailer
2001-05-08  8:43         ` Wolfgang Denk
2001-05-08 10:06           ` machael thailer
  -- strict thread matches above, loose matches on Subject: below --
2001-05-08 10:43 Zehetbauer Thomas
2001-05-08 11:51 ` machael thailer
     [not found] <439B3F1E9095D41193DE00D0B74FF30601CE7900@xpr01.prd.hp.com>
2001-05-08 13:50 ` Freddy Lugo
2001-05-08 15:21   ` Wolfgang Denk
2001-05-08 21:21     ` Freddy Lugo
2001-05-10  3:40 machael thailer
2001-05-10  4:16 ` Paul White

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='001d01c0d5c8$27ae8c60$8021690a@huawei.com' \
    --to=dony.he@huawei.com \
    --cc=cort@fsmlabs.com \
    --cc=dan@mvista.com \
    --cc=linuxppc-embedded@lists.linuxppc.org \
    --cc=wd@denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).