* No bzImage target for MIPS
@ 2001-12-14 0:47 Krishna Kondaka
2001-12-14 1:10 ` Pete Popov
0 siblings, 1 reply; 17+ messages in thread
From: Krishna Kondaka @ 2001-12-14 0:47 UTC (permalink / raw)
To: linux-mips
Hi,
There is no "bzImage" target in the mips linux Makefiles. Could
you tell me why this is missing? If I want to generate a
compressed image for linux on MIPS, how do I do it?
Thanks
Krishna
^ permalink raw reply [flat|nested] 17+ messages in thread
* RE: No bzImage target for MIPS
@ 2001-12-14 0:55 Marc Karasek
0 siblings, 0 replies; 17+ messages in thread
From: Marc Karasek @ 2001-12-14 0:55 UTC (permalink / raw)
To: 'Krishna Kondaka ', 'linux-mips@oss.sgi.com '
The support for decompression of a bzImage image is not supported in the
MIPS kernel. If you do just a "make zImage" I believe this will get you a
"zipped" image file.
-----Original Message-----
From: Krishna Kondaka
To: linux-mips@oss.sgi.com
Sent: 12/13/01 7:47 PM
Subject: No bzImage target for MIPS
Hi,
There is no "bzImage" target in the mips linux Makefiles. Could
you tell me why this is missing? If I want to generate a
compressed image for linux on MIPS, how do I do it?
Thanks
Krishna
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: No bzImage target for MIPS
2001-12-14 0:47 Krishna Kondaka
@ 2001-12-14 1:10 ` Pete Popov
2001-12-14 3:28 ` Geoffrey Espin
0 siblings, 1 reply; 17+ messages in thread
From: Pete Popov @ 2001-12-14 1:10 UTC (permalink / raw)
To: Krishna Kondaka; +Cc: linux-mips
On Thu, 2001-12-13 at 16:47, Krishna Kondaka wrote:
> Hi,
>
> There is no "bzImage" target in the mips linux Makefiles. Could
> you tell me why this is missing? If I want to generate a
> compressed image for linux on MIPS, how do I do it?
Download the linux-mips drop-in tree from sourceforge.net. Take a look
at arch/mips/zboot. The only zImage support in that directory is for
the Alchemy Pb1000 board. That's one way to do it and I basically
copied it from the ppc tree. You'll have to do some work to add support
for whatever board you want, but the example should be sufficient, if
you're a developer. If you're a casual user, unfortunately you're out of
luck.
Pete
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: No bzImage target for MIPS
2001-12-14 1:10 ` Pete Popov
@ 2001-12-14 3:28 ` Geoffrey Espin
2001-12-14 3:51 ` Keith Owens
2001-12-14 18:05 ` Pete Popov
0 siblings, 2 replies; 17+ messages in thread
From: Geoffrey Espin @ 2001-12-14 3:28 UTC (permalink / raw)
To: Pete Popov; +Cc: Krishna Kondaka, linux-mips
> > There is no "bzImage" target in the mips linux Makefiles. Could
> > you tell me why this is missing? If I want to generate a
> > compressed image for linux on MIPS, how do I do it?
I guess Bill Gates was right, he practically created the Open
Source movement by "providing" an excellent BIOS. </sarcasm>
One of Embedded Linux's unspoken "problems" is lack of truly
universal boot program. GRUB is as univeral as x86, not!
Ppcboot is one of the best, but notice the 'ppc' in the name?
I gather that PMON is used by many in MIPS... but that is another
secret you won't find revealed, even in Jun Sun's execellent MIPS
Porting Guide. :-)
COming from a certain proprietary RTOS, I believe, using the OS
itself, as the "boot monitor" is best approach. All reusable
code, fastest bootstrap (i.e. no 2nd stage loading), etc... But,
of course, not optimal for size, though my image is 1.3M which
includes a 580K cramfs ramdisk.
> Download the linux-mips drop-in tree from sourceforge.net. Take a look
> at arch/mips/zboot. The only zImage support in that directory is for
> the Alchemy Pb1000 board. That's one way to do it and I basically
I finally did rework this. I have a single 360 line "<board>/misc.c" file,
a <board>/Boot.make included by arch/linux/boot/Makefile, and <board>/boot.S.
There is no cut & pasting of code elsewhere in the linux tree, there are
no new directories (zboot, compressed, blah-blah). Its just glue that
sticks in front of vmlinux.bin.gz. Where <board> is Korva (AKA Markham),
for now. Support for compressed, or not, plus linking a kernel to run
at low memory or high. Running at 'high' allows the kernel to load
another kernel into 'low' memory without burning flash. All selectable
from "make menuconfig".
Keeping up with sf.net is one of my failings... so no patch, sorry.
Attached are the key files, if anyone thinks this is worth pursuing.
Geoff
--
Geoffrey Espin espin@idiom.com
--
=misc.c=========================================================================
/*
* For Korva/Markham MIPS by Geoffrey Espin espin@idiom.com
* Based on numerous predecessors including...
*
* Author: Johnnie Peters <jpeters@mvista.com>
* Editor: Tom Rini <trini@mvista.com>
* Ported by Pete Popov <ppopov@mvista.com> to
* Copyright 2000-2001 MontaVista Software Inc.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <linux/config.h>
#include <stdarg.h>
#include <asm/page.h>
#include "../../../fs/jffs2/zlib.c" /**/
#include "../../../lib/ctype.c"
#undef __HAVE_ARCH_MEMCPY
#undef __HAVE_ARCH_MEMSET
#include "../../../lib/string.c"
#define CONFIG_REMOTE_DEBUG
#include "../korva/dbg_io.c"
extern char _end[]; /* end of bss */
int printk(const char *fmt, ...);
void putc(const char c);
void gunzip(void *, int, unsigned char *, int *);
/* NEC KORVA/MARKHAM */
#define DELAY(n) { volatile int x,y; for (x=0;x<100000*(n);x++) y=x; }
#define LED(n) *(volatile unsigned char*)0xb000001c = (n)
#define ZIMAGE_OFFSET 0x00010000 /* 64k per Makefile/VMA/vrboot */
#define ZIMAGE_SIZE 0x00200000 /* 2M */
#define AVAIL_RAM_START (PAGE_ALIGN((int)_end)) /* scratch area after image */
#define AVAIL_RAM_SIZE 0x00100000 /* 1M */
char *avail_ram; /* used by zalloc */
char *end_avail;
void
decompress_kernel(void)
{
char *zimage_start;
int zimage_size;
int i;
for (i = 0; i < 8; i++) {
LED(1 << (7 - i));
DELAY(5);
}
/* fix for dbg_io.c on Korva/Markham */
*((volatile uint8 *) (0xb0000000 + 0)) |= 0x8; /* GMR = 0x8 UCSEL (uart) */
avail_ram = (char *) AVAIL_RAM_START; /* used by zalloc */
end_avail = (char *) (AVAIL_RAM_START + AVAIL_RAM_SIZE);
zimage_start = (char *) (FLASHADDR + ZIMAGE_OFFSET);
zimage_size = ZIMAGE_SIZE;
printk("\nUncompressing from %#x to %#x\n", zimage_start, LOADADDR);
#if 0
printk("zImage [0-4]: %#x %#x %#x %#x\n",
((unsigned long *) zimage_start)[0],
((unsigned long *) zimage_start)[1],
((unsigned long *) zimage_start)[2],
((unsigned long *) zimage_start)[3]);
#endif
gunzip((void *) LOADADDR, 0x00400000, zimage_start, &zimage_size);
#if 0
printk("entry [0-4]: %#x %#x %#x %#x (at %#x size %d)\n",
((unsigned long *) KERNEL_ENTRY)[0],
((unsigned long *) KERNEL_ENTRY)[1],
((unsigned long *) KERNEL_ENTRY)[2],
((unsigned long *) KERNEL_ENTRY)[3], KERNEL_ENTRY, zimage_size);
#endif
printk("Booting Linux at %#x\n", KERNEL_ENTRY);
for (i = 0; i < 8; i++) {
LED(1 << (i));
DELAY(5);
}
/* XXX returning and letting boot.S jump used to work? */
if (1) {
__asm__ __volatile__("jr\t%0"::"r"(KERNEL_ENTRY));
}
}
void
exit(void)
{
printk("\nexit\n");
while (1) ;
}
void
putc(const char c)
{
#define serial_putc(ch) putDebugChar(ch)
serial_putc(c);
if (c == '\n')
serial_putc('\r');
}
void *
zalloc(void *x, unsigned items, unsigned size)
{
void *p = avail_ram;
size *= items;
size = (size + 7) & -8;
avail_ram += size;
if (avail_ram > end_avail) {
printk("oops... zalloc(%#x, %d, %#x) out of memory\n",
(int) x, items, size);
p = NULL;
}
return p;
}
void
zfree(void *x, void *addr)
{
}
void
gunzip(void *dst, int dstlen, unsigned char *src, int *lenp)
{
#define HEAD_CRC 2
#define EXTRA_FIELD 4
#define ORIG_NAME 8
#define COMMENT 0x10
#define RESERVED 0xe0
#define DEFLATED 8
z_stream s;
int r, i, flags;
/* skip header */
i = 10;
flags = src[3];
if (src[2] != DEFLATED || (flags & RESERVED) != 0) {
printk("bad gzipped data\n");
exit();
}
if ((flags & EXTRA_FIELD) != 0)
i = 12 + src[10] + (src[11] << 8);
if ((flags & ORIG_NAME) != 0)
while (src[i++] != 0) ;
if ((flags & COMMENT) != 0)
while (src[i++] != 0) ;
if ((flags & HEAD_CRC) != 0)
i += 2;
if (i >= *lenp) {
printk("gunzip: ran out of data in header\n");
exit();
}
s.zalloc = zalloc;
s.zfree = zfree;
r = inflateInit2(&s, -MAX_WBITS);
if (r != Z_OK) {
printk("inflateInit2 returned %#x\n", r);
exit();
}
s.next_in = src + i;
s.avail_in = *lenp - i;
s.next_out = dst;
s.avail_out = dstlen;
r = inflate(&s, Z_FINISH);
if (r != Z_OK && r != Z_STREAM_END) {
printk("inflate returned %#x\n", r);
exit();
}
*lenp = s.next_out - (unsigned char *) dst;
inflateEnd(&s);
}
int
_cvt(unsigned long val, char *buf, long radix, char *digits)
{
char temp[80];
char *cp = temp;
int length = 0;
if (val == 0) { /* Special case */
*cp++ = '0';
} else
while (val) {
*cp++ = digits[val % radix];
val /= radix;
}
while (cp != temp) {
*buf++ = *--cp;
length++;
}
*buf = '\0';
return (length);
}
#define is_digit(c) ((c >= '0') && (c <= '9'))
void
_vprintk(void (*putc) (const char), const char *fmt0, va_list ap)
{
char c, sign, *cp = 0;
int left_prec, right_prec, zero_fill, length = 0, pad, pad_on_right;
char buf[32];
long val;
while ((c = *fmt0++)) {
if (c == '%') {
c = *fmt0++;
left_prec = right_prec = pad_on_right = 0;
if (c == '#')
c = *fmt0++; /* ignore alternate fmt */
if (c == '-') {
c = *fmt0++;
pad_on_right++;
}
if (c == '0') {
zero_fill = 1;
c = *fmt0++;
} else {
zero_fill = 0;
}
while (is_digit(c)) {
left_prec = (left_prec * 10) + (c - '0');
c = *fmt0++;
}
if (c == '.') {
c = *fmt0++;
zero_fill++;
while (is_digit(c)) {
right_prec =
(right_prec * 10) + (c - '0');
c = *fmt0++;
}
} else {
right_prec = left_prec;
}
sign = '\0';
switch (c) {
case 'd':
case 'x':
case 'X':
val = va_arg(ap, long);
switch (c) {
case 'd':
if (val < 0) {
sign = '-';
val = -val;
}
length =
_cvt(val, buf, 10, "0123456789");
break;
case 'x':
length =
_cvt(val, buf, 16,
"0123456789abcdef");
break;
case 'X':
length =
_cvt(val, buf, 16,
"0123456789ABCDEF");
break;
}
cp = buf;
break;
case 's':
cp = va_arg(ap, char *);
length = strlen(cp);
break;
case 'c':
c = va_arg(ap, long /*char */ );
(*putc) (c);
continue;
default:
(*putc) ('?');
}
pad = left_prec - length;
if (sign != '\0') {
pad--;
}
if (zero_fill) {
c = '0';
if (sign != '\0') {
(*putc) (sign);
sign = '\0';
}
} else {
c = ' ';
}
if (!pad_on_right) {
while (pad-- > 0) {
(*putc) (c);
}
}
if (sign != '\0') {
(*putc) (sign);
}
while (length-- > 0) {
(*putc) (c = *cp++);
if (c == '\n') {
(*putc) ('\r');
}
}
if (pad_on_right) {
while (pad-- > 0) {
(*putc) (c);
}
}
} else {
(*putc) (c);
if (c == '\n') {
(*putc) ('\r');
}
}
}
}
int
printk(const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
_vprintk(putc, fmt, args);
va_end(args);
return 0;
}
=boot.S=========================================================================
/*
* boot.S
*
* Modified by Geoffrey Espin <espin@idiom.com> for NEC Electronics
*
* Copyright (C) 1999 Bradley D. LaRonde
* Copyright (C) 2001 Dai Itasaka <Daisaku_Itasaka@el.nec.com>
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*/
#include <linux/config.h>
#include <asm/asm.h>
#include <asm/regdef.h>
#include <asm/addrspace.h>
#include <asm/mipsregs.h>
#define FLASH_BEGIN (FLASHADDR+0x00010000) // skip first 64k (this program)
#define FLASH_END (FLASHADDR+0x00400000) // 4M; see Boot.make
/*
EC:7(CPU clock / 1), EP:0(1word/1cycle), AD:0(VR4000 compatible)
M16:0(Disable), BE:1(Big endian), CS:1(+10), IC:4(16K), DC:3(8K)
K0:2(Disable)
31 30 28 27 24 23 22 21 19 18 17 16 15 14 13 12 11 9 8 6 5 3 2 0
+---+-----+-----+---+-----+---+---+---+---+---+-----+---+-----+----+---+----+
| 0 | EC | EP | AD| 0 |M16| 0 | 1 | 0 | BE| 1 0 | CS| IC | DC | 0 | K0 |
+---+-----+-----+---+-----+---+---+---+---+---+-----+---+-----+----+---+----+
EC : Tclock rate, EP : Transfer data pattern setting,
AD : Accelerate data mode, M16 : MIPS16 ISA mode enable
BE : BigEndian, CS : Cache Size mode Indication(fixed to 1)
IC : Instruction Cache Size, DC : Data Cache Size,
K0 : kseg0 coherency algorithm
See uPD98501 Preliminary User's Manual, Chapter 2, page 156.
*/
#define KORVA_CONFIG_INIT_VAL_BE 0x7002d8c2 /*BE*/
#define KORVA_CONFIG_INIT_VAL 0x700258c2 /*LE*/
#define DEBUG
#ifdef DEBUG
#define DEBUG_LED 0xb000001c
#define CHECKPOINT(n) li t4, n; sw t4, DEBUG_LED;
#else
#define CHECKPOINT(n)
#endif
LEAF(__start)
.set mips3
.set noreorder
nop // patched by script if using Kyoto-Micro ROM Emulator
nop
nop
mtc0 zero, CP0_STATUS // disable interrupts
mtc0 zero, CP0_CAUSE // clear interrupts
li t0, KORVA_CONFIG_INIT_VAL
mtc0 t0, CP0_CONFIG // make sure the cache is disabled
mtc0 zero, CP0_WATCHLO
mtc0 zero, CP0_WATCHHI // disable watch exception
CHECKPOINT(0xB1)
/* setup_hardware (was function, now PIC as may be linked at RAM) */
// check if the CPU is running at 66MHz or 100MHz
lui t0, 0xb000
lw t1, 4(t0) // 0xb0000004 = GSR
li t0, 2 // CCLKSEL
and t0, t0, t1
beq zero, t0, clk100
lui t0, 0xb000
clk66:
li t1, 0x120 // SDMDR
sw t1, 0x108(t0) // *(0xb0000108) = 0x120;
li t1, 0x000 // SDPTR
sw t1, 0x110(t0) // *(0xb0000110) = 0x000;
beq zero, zero, 1f
nop
clk100:
li t1, 0x230 // SDMDR
sw t1, 0x108(t0) // *(0xb0000108) = 0x230;
li t1, 0x021 // SDPTR
sw t1, 0x110(t0) // *(0xb0000110) = 0x021;
1:
#if defined(CONFIG_NEC_MARKHAM_32MB)
li t1, 0x3c2 // SDTSR 32M
// CAB=0x02, RAB=0x40 BTM=0x0080 SIZE=0x300(32M)
#else
li t1, 0x1a1 // SDTSR 8M
// CAB=0x01, RAB=0x20 BTM=0x0080 SIZE=0x100(8M)
#endif
sw t1, 0x10c(t0) // *(0xb000010c) = 0x1a1/0x3c2;
// allow writing to flash parts
li t1, 0x100 // RMMDR (00 4MB mode) WM=1 unmasked
sw t1, 0x100(t0) // *(0xb0000100) = 0x000;
li t1, 0x003 // RMATR FAT_8
sw t1, 0x104(t0) // *(0xb0000104) = 0x003;
li t1, 0x000 // IMR
sw t1, 0x00c(t0) // disable all INTs
nop
/* end of setup_hardware */
CHECKPOINT(0xB2)
/* invalidate_cache (was function, now PIC as may be linked at RAM) */
mtc0 zero, CP0_TAGLO // invalidate the instruction cache
li s0, 0x80000000
li s1, 0x80000000 + (1 << 14) // 16k
1:
cache (2 << 2) | 0, (s0)
add s0, 0x10
bne s0, s1, 1b
nop
mtc0 zero, CP0_TAGLO // invalidate the data cache
li s0, 0x80000000
li s1, 0x80000000 + (1 << 13) // 8k
1:
cache (2 << 2) | 1, (s0)
add s0, 0x10
bne s0, s1, 1b
nop
nop
/* end of invalidate_cache */
CHECKPOINT(0xB3)
mfc0 t0, CP0_CONFIG // enable kseg0 caching
ori t0, 0x1 // cached
mtc0 t0, CP0_CONFIG
CHECKPOINT(0xB4)
#ifdef CONFIG_NEC_KORVA_COMPRESSED
relocate:
la sp, .stack
move s0, a0
move s1, a1
move s2, a2
move s3, a3
la a0, __start
li a1, FLASHADDR
la a2, _edata
subu t1, a2, a0
srl t1, t1, 2
/* copy text section */
li t0, 0
1: lw v0, 0(a1)
nop
sw v0, 0(a0)
xor t0, t0, v0
addu a0, 4
bne a2, a0, 1b
addu a1, 4
/* clear BSS */
la a0, _edata
la a2, _end
2: sw zero, 0(a0)
bne a2, a0, 2b
addu a0, 4
/* now that code is in RAM we can jump okay */
// decompress kernel to ram
la ra, 1f
la t4, decompress_kernel // elsewhere in 'C'
jr t4
#else
/* actually we were linked at ROM so we're okay */
// copy kernel to ram
la ra, 1f
la t4, copy_kernel
jr t4
#endif
nop
1:
CHECKPOINT(0xB5)
// jump to kernel entry point
li t4, KERNEL_ENTRY
jr t4
nop
nop
END(__start)
LEAF(copy_kernel)
// copy kernel from ROM to RAM
// Load s0 = src, s1 = src_end, s2 = dest.
li s0, FLASH_BEGIN
li s1, FLASH_END
li s2, LOADADDR
sw zero, (s2)
sw zero, 4(s2)
sw zero, 8(s2)
sw zero, 12(s2)
1:
// Only update LED once in a while.
and t0, s0, 0xffff
bne t0, zero, 2f
// Show copy progress on LED.
srl t0, s0, 16
sh t0, DEBUG_LED
2:
// Copy src to dest.
lw t0, (s0)
bne t0, zero, 3f
nop
sw zero, (s2)
beq zero, zero, 4f
nop
3:
sw t0, (s2)
4:
// Increment src and dest.
add s0, 4
add s2, 4
// Loop if still more to go.
bne s0, s1, 1b
nop
jr ra
nop
END(copy_kernel)
#ifdef CONFIG_NEC_KORVA_COMPRESSED
.comm .stack,4096*2,4 // used by relocate to call 'C' program
#endif
=Boot.make======================================================================
# Boot.make - used by ../boot/Makefile
OBJCOPY = mipsel-linux-objcopy
OBJCOPY_FLAGS = -R .stab -R .stabstr -R .comment -R .note -R .reginfo -R .mdebug
OBJDUMP = mipsel-linux-objdump
#OBJDUMP_HFLAGS = --disassemble-all -b srec -m mips:4600 -EL
TOPDIR = ../../..
ifeq ($(LINUX_SRC),)
LINUX_SRC=$(TOPDIR)
endif
VMLINUX=$(LINUX_SRC)/vmlinux
SYSTEM_MAP=$(LINUX_SRC)/System.map
ifeq ($(USERLAND),)
USERLAND=$(LINUX_SRC)/../userland
endif
FLASHADDR = 0xbfc00000
# see arch/mips/Makefile LOADADDR
# 0x10000 bottom 64k reserved by/for boot.S (FLASH_BEGIN)
# 0x02000 additional 8k reserved RAM image vector table (see LOADADDR)
ifdef CONFIG_NEC_MARKHAM_BOOTROM
NN=10#in hex is 16M
LOADADDR += 0x81002000
ZLOADADDR += 0x81402000# +4M
VMA = 0x7f00e000 # 0x0-0x81000000+0x10000-0x2000
ZVMA = 0x7ebfe000 # 0x0-0x81402000
else
NN=00
LOADADDR += 0x80002000
ZLOADADDR += 0x80402000# +4M
VMA = 0x8000e000 # 0x0-0x80000000+0x10000-0x2000
ZVMA = 0x7fbfe000 # 0x0-0x80402000
endif
KERNEL_ENTRY=$(shell awk '/kernel_entry/{print "0x" $$1}' $(LINUX_SRC)/System.map)
override CFLAGS += -DKERNEL_ENTRY=$(KERNEL_ENTRY) -DNN=$(NN)
override CFLAGS += -DLOADADDR=$(LOADADDR) -DFLASHADDR=$(FLASHADDR) -DZLOADADDR=$(ZLOADADDR)
ifdef CONFIG_NEC_KORVA_COMPRESSED
zbootroms: bin zsrec
else
bootroms: bin srec
endif
$(TOPDIR)/arch/$(ARCH)/ld.script.$(ZLOADADDR)_z: $(TOPDIR)/arch/$(ARCH)/ld.script.in
sed -e 's/kernel_entry/__start/' -e 's/@@LOADADDR@@/$(ZLOADADDR)/' <$< >$@
ZLINKFLAGS += -T $(TOPDIR)/arch/$(ARCH)/ld.script.$(ZLOADADDR)_z
misc.c: ../korva/misc.c
@rm -f $@
cp $< $@
boot.S: ../korva/boot.S
@rm -f $@
cp $< $@
#vrboot$(NN): boot.o
vrboot$(NN): boot.o misc.o $(TOPDIR)/arch/$(ARCH)/ld.script.$(ZLOADADDR)_z
@rm -f $@
ifdef CONFIG_NEC_KORVA_COMPRESSED
$(LD) $(LDFLAGS) -static -EL -N -o $@ $(ZLINKFLAGS) boot.o misc.o
else
$(LD) $(LDFLAGS) -static -EL -N -o $@ -Ttext $(FLASHADDR) boot.o
endif
@rm -f $^ ../boot/misc.c ../boot/boot.S
vmlinux$(NN): $(VMLINUX)
@rm -f System$(NN).map
cp -p $(SYSTEM_MAP) System$(NN).map
cp -p $< $@
# move sections to 0, then add bfc00000 for ROMulator
vrvmlinux$(NN)-0: vmlinux$(NN) vrboot$(NN)
@rm -f $@
$(OBJCOPY) $(OBJCOPY_FLAGS) --change-addresses 0 -O binary \
vrboot$(NN) vrboot$(NN)-0.bin
$(OBJCOPY) $(OBJCOPY_FLAGS) --change-addresses $(VMA) \
vmlinux$(NN) vmlinux$(NN)-0
$(OBJCOPY) $(OBJCOPY_FLAGS) --add-section .vrboot=vrboot$(NN)-0.bin \
--set-section-flags .vrboot=,alloc,load,readonly,code \
vmlinux$(NN)-0 vrvmlinux$(NN)-0
vrvmlinux$(NN)-bfc: vrvmlinux$(NN)-0
$(OBJCOPY) $(OBJCOPY_FLAGS) --change-address $(FLASHADDR) \
vrvmlinux$(NN)-0 vrvmlinux$(NN)-bfc
# xxx-bfc.bin is for 'reload' & 'reburn' used on a running system
vrvmlinux$(NN)-bfc.bin: vrvmlinux$(NN)-0
$(OBJCOPY) $(OBJCOPY_FLAGS) --change-address $(FLASHADDR) -O binary \
vrvmlinux$(NN)-0 vrvmlinux$(NN)-bfc.bin
bin: vrvmlinux$(NN)-bfc vrvmlinux$(NN)-bfc.bin
vrvmlinux$(NN)-0.srec: vrvmlinux$(NN)-0
$(OBJCOPY) $(OBJCOPY_FLAGS) -O srec --srec-forceS3 --gap-fill 0 \
vrvmlinux$(NN)-0 vrvmlinux$(NN)-0.srec
$(OBJCOPY) $(OBJCOPY_FLAGS) --change-address $(FLASHADDR) -O srec \
vrvmlinux$(NN)-0 vrvmlinux$(NN)-bfc.srec
srec: vrvmlinux$(NN)-0.srec
# used by 'reburn' script for Korva (8M) which needs small 256K chunks
split:
@rm -rf split
@mkdir split
cd split && split -b 256k ../vrvmlinux00-bfc.bin vrvm
# compressed...
vmlinux$(NN).bin.gz: vmlinux$(NN)
$(OBJCOPY) -S -O binary $< $<.bin
gzip -vf $<.bin
zvrvmlinux$(NN)-0: vmlinux$(NN).bin.gz vrboot$(NN)
@rm -f $@
$(OBJCOPY) $(OBJCOPY_FLAGS) --change-addresses=$(ZVMA) \
vrboot$(NN) zvrboot$(NN)-0
$(OBJCOPY) $(OBJCOPY_FLAGS) --add-section .vmlinux=vmlinux$(NN).bin.gz \
--change-section-address .vmlinux=0x10000 \
--set-section-flags .vmlinux=,alloc,load,readonly,code \
zvrboot$(NN)-0 zvrvmlinux$(NN)-0
zvrvmlinux$(NN)-0.srec: zvrvmlinux$(NN)-0
$(OBJCOPY) $(OBJCOPY_FLAGS) -O srec --srec-forceS3 \
zvrvmlinux$(NN)-0 zvrvmlinux$(NN)-0.srec
$(OBJCOPY) $(OBJCOPY_FLAGS) -O srec --srec-forceS3 \
--change-address 0xbfc00000 \
zvrvmlinux$(NN)-0 zvrvmlinux$(NN)-bfc.srec
zsrec: zvrvmlinux$(NN)-0.srec
clean::
@rm -f System* vrvmlinux* vmlinux* vrboot* zvrvmlinux*
================================================================================
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: No bzImage target for MIPS
2001-12-14 3:28 ` Geoffrey Espin
@ 2001-12-14 3:51 ` Keith Owens
2001-12-14 4:12 ` Geoffrey Espin
2001-12-14 18:05 ` Pete Popov
1 sibling, 1 reply; 17+ messages in thread
From: Keith Owens @ 2001-12-14 3:51 UTC (permalink / raw)
To: Geoffrey Espin; +Cc: linux-mips
On Thu, 13 Dec 2001 19:28:46 -0800,
Geoffrey Espin <espin@idiom.com> wrote:
>=misc.c=========================================================================
>#include "../../../fs/jffs2/zlib.c" /**/
>#include "../../../lib/ctype.c"
I am phasing out the practice of ../ in kernel include paths. It is
much better to do
#include "zlib.c"
#include "ctype.c"
and the Makefile adds -I$(TOPDIR)/fs/jffs2 -I$(TOPDIR)/lib. Then when
sources are moved from one directory to another, the source does not
change, only the Makefile. Relative paths are a pain in the neck in
Makefiles, they are even more of a pain in source code.
>TOPDIR = ../../..
TOPDIR := $(shell cd ../../..; /bin/pwd)
is better, it returns an absolute path instead of a relative one.
Keith Owens, kernel build maintainer
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: No bzImage target for MIPS
2001-12-14 3:51 ` Keith Owens
@ 2001-12-14 4:12 ` Geoffrey Espin
0 siblings, 0 replies; 17+ messages in thread
From: Geoffrey Espin @ 2001-12-14 4:12 UTC (permalink / raw)
To: Keith Owens; +Cc: linux-mips
Keith,
On Fri, Dec 14, 2001 at 02:51:21PM +1100, Keith Owens wrote:
> >#include "../../../fs/jffs2/zlib.c" /**/
> >#include "../../../lib/ctype.c"
> I am phasing out the practice of ../ in kernel include paths. It is
> much better to do
> #include "zlib.c"
> #include "ctype.c"
> and the Makefile adds -I$(TOPDIR)/fs/jffs2 -I$(TOPDIR)/lib. Then when
I'll check around the tree. Doesn't matter to me. Both have crappy
implications. I hate it when -I's pile up... and you don't know which
directory takes precedence (esp. if there are duplicate names).
> >TOPDIR = ../../..
> TOPDIR := $(shell cd ../../..; /bin/pwd)
> is better, it returns an absolute path instead of a relative one.
Hmmm, okay. I probably shouldn't even have this macro.
I had hacked things earlier so I didn't have to run 'make' from linux/.
Thanks for the quick feedback, mate!
[I'll spare someone pointing out that I should have tried to use
linux/lib/vsprintf.c. Missed it! What a newbie.]
Geoff
--
Geoffrey Espin
espin@idiom.com
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: No bzImage target for MIPS
2001-12-14 3:28 ` Geoffrey Espin
2001-12-14 3:51 ` Keith Owens
@ 2001-12-14 18:05 ` Pete Popov
2001-12-14 18:52 ` Geoffrey Espin
1 sibling, 1 reply; 17+ messages in thread
From: Pete Popov @ 2001-12-14 18:05 UTC (permalink / raw)
To: Geoffrey Espin; +Cc: Krishna Kondaka, linux-mips
On Thu, 2001-12-13 at 19:28, Geoffrey Espin wrote:
>
> > > There is no "bzImage" target in the mips linux Makefiles. Could
> > > you tell me why this is missing? If I want to generate a
> > > compressed image for linux on MIPS, how do I do it?
>
> I guess Bill Gates was right, he practically created the Open
> Source movement by "providing" an excellent BIOS. </sarcasm>
>
> One of Embedded Linux's unspoken "problems" is lack of truly
> universal boot program. GRUB is as univeral as x86, not!
> Ppcboot is one of the best, but notice the 'ppc' in the name?
> I gather that PMON is used by many in MIPS... but that is another
> secret you won't find revealed, even in Jun Sun's execellent MIPS
> Porting Guide. :-)
The "original" pmon has outlived its purpose, although it's still found
on many boards. I've become a fan of MIPS Tech's yamon; it's small, it
works, it has just the features I need in an embedded system, and, did I
say it works?. Unfortunately the code is released under NDA only. If
MIPS opened the code, I think you would see it on many more boards.
> COming from a certain proprietary RTOS, I believe, using the OS
> itself, as the "boot monitor" is best approach. All reusable
> code, fastest bootstrap (i.e. no 2nd stage loading), etc... But,
> of course, not optimal for size, though my image is 1.3M which
> includes a 580K cramfs ramdisk.
That's fine once you've ported the kernel to your board. What do you do
before that point?
> > Download the linux-mips drop-in tree from sourceforge.net. Take a look
> > at arch/mips/zboot. The only zImage support in that directory is for
> > the Alchemy Pb1000 board. That's one way to do it and I basically
>
> I finally did rework this. I have a single 360 line "<board>/misc.c" file,
> a <board>/Boot.make included by arch/linux/boot/Makefile, and <board>/boot.S.
> There is no cut & pasting of code elsewhere in the linux tree, there are
> no new directories (zboot, compressed, blah-blah). Its just glue that
> sticks in front of vmlinux.bin.gz. Where <board> is Korva (AKA Markham),
> for now. Support for compressed, or not, plus linking a kernel to run
> at low memory or high. Running at 'high' allows the kernel to load
> another kernel into 'low' memory without burning flash. All selectable
> from "make menuconfig".
>
> Keeping up with sf.net is one of my failings... so no patch, sorry.
> Attached are the key files, if anyone thinks this is worth pursuing.
That's OK, I'm sure someone with interest in the Korva can create the
patch. But I fail to see how having this code in every <board>
directory is better than having a separate boot directory like the ppc
arch. The ppc-like zImage support I added is a bit different from the
patch below. It assumes that you do have a boot loader and the 'kernel
loader' is basically separate from the kernel image itself. Adding
initrd support that's not statically compiled in the kernel should be
pretty easy and I like that approach better than statically compiled
initrd images.
Pete
> Geoff
> --
> Geoffrey Espin espin@idiom.com
> --
>
> =misc.c=========================================================================
> /*
> * For Korva/Markham MIPS by Geoffrey Espin espin@idiom.com
> * Based on numerous predecessors including...
> *
> * Author: Johnnie Peters <jpeters@mvista.com>
> * Editor: Tom Rini <trini@mvista.com>
> * Ported by Pete Popov <ppopov@mvista.com> to
> * Copyright 2000-2001 MontaVista Software Inc.
> *
> * This program is free software; you can redistribute it and/or modify it
> * under the terms of the GNU General Public License as published by the
> * Free Software Foundation; either version 2 of the License, or (at your
> * option) any later version.
> *
> * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
> * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
> * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
> * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
> * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
> * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
> * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
> * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
> * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
> * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> *
> * You should have received a copy of the GNU General Public License along
> * with this program; if not, write to the Free Software Foundation, Inc.,
> * 675 Mass Ave, Cambridge, MA 02139, USA.
> */
>
> #include <linux/config.h>
>
> #include <stdarg.h>
> #include <asm/page.h>
>
> #include "../../../fs/jffs2/zlib.c" /**/
> #include "../../../lib/ctype.c"
> #undef __HAVE_ARCH_MEMCPY
> #undef __HAVE_ARCH_MEMSET
> #include "../../../lib/string.c"
> #define CONFIG_REMOTE_DEBUG
> #include "../korva/dbg_io.c"
>
> extern char _end[]; /* end of bss */
>
> int printk(const char *fmt, ...);
> void putc(const char c);
>
> void gunzip(void *, int, unsigned char *, int *);
>
> /* NEC KORVA/MARKHAM */
> #define DELAY(n) { volatile int x,y; for (x=0;x<100000*(n);x++) y=x; }
> #define LED(n) *(volatile unsigned char*)0xb000001c = (n)
>
> #define ZIMAGE_OFFSET 0x00010000 /* 64k per Makefile/VMA/vrboot */
> #define ZIMAGE_SIZE 0x00200000 /* 2M */
>
> #define AVAIL_RAM_START (PAGE_ALIGN((int)_end)) /* scratch area after image */
> #define AVAIL_RAM_SIZE 0x00100000 /* 1M */
>
> char *avail_ram; /* used by zalloc */
> char *end_avail;
>
> void
> decompress_kernel(void)
> {
> char *zimage_start;
> int zimage_size;
> int i;
>
> for (i = 0; i < 8; i++) {
> LED(1 << (7 - i));
> DELAY(5);
> }
>
> /* fix for dbg_io.c on Korva/Markham */
> *((volatile uint8 *) (0xb0000000 + 0)) |= 0x8; /* GMR = 0x8 UCSEL (uart) */
> avail_ram = (char *) AVAIL_RAM_START; /* used by zalloc */
> end_avail = (char *) (AVAIL_RAM_START + AVAIL_RAM_SIZE);
>
> zimage_start = (char *) (FLASHADDR + ZIMAGE_OFFSET);
> zimage_size = ZIMAGE_SIZE;
>
> printk("\nUncompressing from %#x to %#x\n", zimage_start, LOADADDR);
>
> #if 0
> printk("zImage [0-4]: %#x %#x %#x %#x\n",
> ((unsigned long *) zimage_start)[0],
> ((unsigned long *) zimage_start)[1],
> ((unsigned long *) zimage_start)[2],
> ((unsigned long *) zimage_start)[3]);
> #endif
>
> gunzip((void *) LOADADDR, 0x00400000, zimage_start, &zimage_size);
>
> #if 0
> printk("entry [0-4]: %#x %#x %#x %#x (at %#x size %d)\n",
> ((unsigned long *) KERNEL_ENTRY)[0],
> ((unsigned long *) KERNEL_ENTRY)[1],
> ((unsigned long *) KERNEL_ENTRY)[2],
> ((unsigned long *) KERNEL_ENTRY)[3], KERNEL_ENTRY, zimage_size);
> #endif
>
> printk("Booting Linux at %#x\n", KERNEL_ENTRY);
>
> for (i = 0; i < 8; i++) {
> LED(1 << (i));
> DELAY(5);
> }
>
> /* XXX returning and letting boot.S jump used to work? */
> if (1) {
> __asm__ __volatile__("jr\t%0"::"r"(KERNEL_ENTRY));
> }
> }
>
> void
> exit(void)
> {
> printk("\nexit\n");
> while (1) ;
> }
>
> void
> putc(const char c)
> {
> #define serial_putc(ch) putDebugChar(ch)
>
> serial_putc(c);
> if (c == '\n')
> serial_putc('\r');
> }
>
> void *
> zalloc(void *x, unsigned items, unsigned size)
> {
> void *p = avail_ram;
>
> size *= items;
> size = (size + 7) & -8;
> avail_ram += size;
> if (avail_ram > end_avail) {
> printk("oops... zalloc(%#x, %d, %#x) out of memory\n",
> (int) x, items, size);
> p = NULL;
> }
> return p;
> }
>
> void
> zfree(void *x, void *addr)
> {
> }
>
> void
> gunzip(void *dst, int dstlen, unsigned char *src, int *lenp)
> {
> #define HEAD_CRC 2
> #define EXTRA_FIELD 4
> #define ORIG_NAME 8
> #define COMMENT 0x10
> #define RESERVED 0xe0
>
> #define DEFLATED 8
>
> z_stream s;
> int r, i, flags;
>
> /* skip header */
> i = 10;
> flags = src[3];
> if (src[2] != DEFLATED || (flags & RESERVED) != 0) {
> printk("bad gzipped data\n");
> exit();
> }
> if ((flags & EXTRA_FIELD) != 0)
> i = 12 + src[10] + (src[11] << 8);
> if ((flags & ORIG_NAME) != 0)
> while (src[i++] != 0) ;
> if ((flags & COMMENT) != 0)
> while (src[i++] != 0) ;
> if ((flags & HEAD_CRC) != 0)
> i += 2;
> if (i >= *lenp) {
> printk("gunzip: ran out of data in header\n");
> exit();
> }
>
> s.zalloc = zalloc;
> s.zfree = zfree;
> r = inflateInit2(&s, -MAX_WBITS);
> if (r != Z_OK) {
> printk("inflateInit2 returned %#x\n", r);
> exit();
> }
> s.next_in = src + i;
> s.avail_in = *lenp - i;
> s.next_out = dst;
> s.avail_out = dstlen;
> r = inflate(&s, Z_FINISH);
> if (r != Z_OK && r != Z_STREAM_END) {
> printk("inflate returned %#x\n", r);
> exit();
> }
> *lenp = s.next_out - (unsigned char *) dst;
> inflateEnd(&s);
> }
>
> int
> _cvt(unsigned long val, char *buf, long radix, char *digits)
> {
> char temp[80];
> char *cp = temp;
> int length = 0;
> if (val == 0) { /* Special case */
> *cp++ = '0';
> } else
> while (val) {
> *cp++ = digits[val % radix];
> val /= radix;
> }
> while (cp != temp) {
> *buf++ = *--cp;
> length++;
> }
> *buf = '\0';
> return (length);
> }
>
> #define is_digit(c) ((c >= '0') && (c <= '9'))
>
> void
> _vprintk(void (*putc) (const char), const char *fmt0, va_list ap)
> {
> char c, sign, *cp = 0;
> int left_prec, right_prec, zero_fill, length = 0, pad, pad_on_right;
> char buf[32];
> long val;
>
> while ((c = *fmt0++)) {
> if (c == '%') {
> c = *fmt0++;
> left_prec = right_prec = pad_on_right = 0;
> if (c == '#')
> c = *fmt0++; /* ignore alternate fmt */
>
> if (c == '-') {
> c = *fmt0++;
> pad_on_right++;
> }
> if (c == '0') {
> zero_fill = 1;
> c = *fmt0++;
> } else {
> zero_fill = 0;
> }
> while (is_digit(c)) {
> left_prec = (left_prec * 10) + (c - '0');
> c = *fmt0++;
> }
> if (c == '.') {
> c = *fmt0++;
> zero_fill++;
> while (is_digit(c)) {
> right_prec =
> (right_prec * 10) + (c - '0');
> c = *fmt0++;
> }
> } else {
> right_prec = left_prec;
> }
>
> sign = '\0';
> switch (c) {
> case 'd':
> case 'x':
> case 'X':
> val = va_arg(ap, long);
> switch (c) {
> case 'd':
> if (val < 0) {
> sign = '-';
> val = -val;
> }
> length =
> _cvt(val, buf, 10, "0123456789");
> break;
> case 'x':
> length =
> _cvt(val, buf, 16,
> "0123456789abcdef");
> break;
> case 'X':
> length =
> _cvt(val, buf, 16,
> "0123456789ABCDEF");
> break;
> }
> cp = buf;
> break;
> case 's':
> cp = va_arg(ap, char *);
> length = strlen(cp);
> break;
> case 'c':
> c = va_arg(ap, long /*char */ );
> (*putc) (c);
> continue;
> default:
> (*putc) ('?');
> }
> pad = left_prec - length;
> if (sign != '\0') {
> pad--;
> }
> if (zero_fill) {
> c = '0';
> if (sign != '\0') {
> (*putc) (sign);
> sign = '\0';
> }
> } else {
> c = ' ';
> }
> if (!pad_on_right) {
> while (pad-- > 0) {
> (*putc) (c);
> }
> }
> if (sign != '\0') {
> (*putc) (sign);
> }
> while (length-- > 0) {
> (*putc) (c = *cp++);
> if (c == '\n') {
> (*putc) ('\r');
> }
> }
> if (pad_on_right) {
> while (pad-- > 0) {
> (*putc) (c);
> }
> }
> } else {
> (*putc) (c);
> if (c == '\n') {
> (*putc) ('\r');
> }
> }
> }
> }
>
> int
> printk(const char *fmt, ...)
> {
> va_list args;
> va_start(args, fmt);
> _vprintk(putc, fmt, args);
> va_end(args);
> return 0;
> }
>
> =boot.S=========================================================================
> /*
> * boot.S
> *
> * Modified by Geoffrey Espin <espin@idiom.com> for NEC Electronics
> *
> * Copyright (C) 1999 Bradley D. LaRonde
> * Copyright (C) 2001 Dai Itasaka <Daisaku_Itasaka@el.nec.com>
> *
> * This file is subject to the terms and conditions of the GNU General Public
> * License. See the file "COPYING" in the main directory of this archive
> * for more details.
> */
>
> #include <linux/config.h>
>
> #include <asm/asm.h>
> #include <asm/regdef.h>
> #include <asm/addrspace.h>
> #include <asm/mipsregs.h>
>
> #define FLASH_BEGIN (FLASHADDR+0x00010000) // skip first 64k (this program)
> #define FLASH_END (FLASHADDR+0x00400000) // 4M; see Boot.make
>
>
> /*
> EC:7(CPU clock / 1), EP:0(1word/1cycle), AD:0(VR4000 compatible)
> M16:0(Disable), BE:1(Big endian), CS:1(+10), IC:4(16K), DC:3(8K)
> K0:2(Disable)
>
> 31 30 28 27 24 23 22 21 19 18 17 16 15 14 13 12 11 9 8 6 5 3 2 0
> +---+-----+-----+---+-----+---+---+---+---+---+-----+---+-----+----+---+----+
> | 0 | EC | EP | AD| 0 |M16| 0 | 1 | 0 | BE| 1 0 | CS| IC | DC | 0 | K0 |
> +---+-----+-----+---+-----+---+---+---+---+---+-----+---+-----+----+---+----+
> EC : Tclock rate, EP : Transfer data pattern setting,
> AD : Accelerate data mode, M16 : MIPS16 ISA mode enable
> BE : BigEndian, CS : Cache Size mode Indication(fixed to 1)
> IC : Instruction Cache Size, DC : Data Cache Size,
> K0 : kseg0 coherency algorithm
>
> See uPD98501 Preliminary User's Manual, Chapter 2, page 156.
> */
>
> #define KORVA_CONFIG_INIT_VAL_BE 0x7002d8c2 /*BE*/
> #define KORVA_CONFIG_INIT_VAL 0x700258c2 /*LE*/
>
>
> #define DEBUG
> #ifdef DEBUG
> #define DEBUG_LED 0xb000001c
> #define CHECKPOINT(n) li t4, n; sw t4, DEBUG_LED;
> #else
> #define CHECKPOINT(n)
> #endif
>
> LEAF(__start)
> .set mips3
> .set noreorder
>
> nop // patched by script if using Kyoto-Micro ROM Emulator
> nop
> nop
>
> mtc0 zero, CP0_STATUS // disable interrupts
> mtc0 zero, CP0_CAUSE // clear interrupts
> li t0, KORVA_CONFIG_INIT_VAL
> mtc0 t0, CP0_CONFIG // make sure the cache is disabled
> mtc0 zero, CP0_WATCHLO
> mtc0 zero, CP0_WATCHHI // disable watch exception
>
> CHECKPOINT(0xB1)
>
> /* setup_hardware (was function, now PIC as may be linked at RAM) */
>
> // check if the CPU is running at 66MHz or 100MHz
> lui t0, 0xb000
> lw t1, 4(t0) // 0xb0000004 = GSR
> li t0, 2 // CCLKSEL
> and t0, t0, t1
> beq zero, t0, clk100
> lui t0, 0xb000
>
> clk66:
> li t1, 0x120 // SDMDR
> sw t1, 0x108(t0) // *(0xb0000108) = 0x120;
> li t1, 0x000 // SDPTR
> sw t1, 0x110(t0) // *(0xb0000110) = 0x000;
>
> beq zero, zero, 1f
> nop
>
> clk100:
> li t1, 0x230 // SDMDR
> sw t1, 0x108(t0) // *(0xb0000108) = 0x230;
> li t1, 0x021 // SDPTR
> sw t1, 0x110(t0) // *(0xb0000110) = 0x021;
>
> 1:
> #if defined(CONFIG_NEC_MARKHAM_32MB)
> li t1, 0x3c2 // SDTSR 32M
> // CAB=0x02, RAB=0x40 BTM=0x0080 SIZE=0x300(32M)
> #else
> li t1, 0x1a1 // SDTSR 8M
> // CAB=0x01, RAB=0x20 BTM=0x0080 SIZE=0x100(8M)
> #endif
> sw t1, 0x10c(t0) // *(0xb000010c) = 0x1a1/0x3c2;
>
> // allow writing to flash parts
> li t1, 0x100 // RMMDR (00 4MB mode) WM=1 unmasked
> sw t1, 0x100(t0) // *(0xb0000100) = 0x000;
>
> li t1, 0x003 // RMATR FAT_8
> sw t1, 0x104(t0) // *(0xb0000104) = 0x003;
>
> li t1, 0x000 // IMR
> sw t1, 0x00c(t0) // disable all INTs
>
> nop
> /* end of setup_hardware */
>
> CHECKPOINT(0xB2)
>
> /* invalidate_cache (was function, now PIC as may be linked at RAM) */
>
> mtc0 zero, CP0_TAGLO // invalidate the instruction cache
> li s0, 0x80000000
> li s1, 0x80000000 + (1 << 14) // 16k
> 1:
> cache (2 << 2) | 0, (s0)
> add s0, 0x10
> bne s0, s1, 1b
> nop
>
> mtc0 zero, CP0_TAGLO // invalidate the data cache
> li s0, 0x80000000
> li s1, 0x80000000 + (1 << 13) // 8k
> 1:
> cache (2 << 2) | 1, (s0)
> add s0, 0x10
> bne s0, s1, 1b
> nop
>
> nop
> /* end of invalidate_cache */
>
> CHECKPOINT(0xB3)
>
> mfc0 t0, CP0_CONFIG // enable kseg0 caching
> ori t0, 0x1 // cached
> mtc0 t0, CP0_CONFIG
>
> CHECKPOINT(0xB4)
>
> #ifdef CONFIG_NEC_KORVA_COMPRESSED
> relocate:
> la sp, .stack
> move s0, a0
> move s1, a1
> move s2, a2
> move s3, a3
>
> la a0, __start
>
> li a1, FLASHADDR
> la a2, _edata
> subu t1, a2, a0
> srl t1, t1, 2
>
> /* copy text section */
> li t0, 0
> 1: lw v0, 0(a1)
> nop
> sw v0, 0(a0)
> xor t0, t0, v0
> addu a0, 4
> bne a2, a0, 1b
> addu a1, 4
>
> /* clear BSS */
> la a0, _edata
> la a2, _end
> 2: sw zero, 0(a0)
> bne a2, a0, 2b
> addu a0, 4
>
> /* now that code is in RAM we can jump okay */
>
> // decompress kernel to ram
> la ra, 1f
> la t4, decompress_kernel // elsewhere in 'C'
> jr t4
> #else
> /* actually we were linked at ROM so we're okay */
>
> // copy kernel to ram
> la ra, 1f
> la t4, copy_kernel
> jr t4
> #endif
> nop
> 1:
>
> CHECKPOINT(0xB5)
>
> // jump to kernel entry point
> li t4, KERNEL_ENTRY
> jr t4
> nop
>
> nop
> END(__start)
>
>
> LEAF(copy_kernel)
> // copy kernel from ROM to RAM
>
> // Load s0 = src, s1 = src_end, s2 = dest.
> li s0, FLASH_BEGIN
> li s1, FLASH_END
>
> li s2, LOADADDR
>
> sw zero, (s2)
> sw zero, 4(s2)
> sw zero, 8(s2)
> sw zero, 12(s2)
>
> 1:
> // Only update LED once in a while.
> and t0, s0, 0xffff
> bne t0, zero, 2f
>
> // Show copy progress on LED.
> srl t0, s0, 16
> sh t0, DEBUG_LED
>
> 2:
> // Copy src to dest.
> lw t0, (s0)
> bne t0, zero, 3f
> nop
> sw zero, (s2)
> beq zero, zero, 4f
> nop
> 3:
> sw t0, (s2)
> 4:
> // Increment src and dest.
> add s0, 4
> add s2, 4
>
> // Loop if still more to go.
> bne s0, s1, 1b
> nop
>
> jr ra
> nop
> END(copy_kernel)
>
> #ifdef CONFIG_NEC_KORVA_COMPRESSED
> .comm .stack,4096*2,4 // used by relocate to call 'C' program
> #endif
>
> =Boot.make======================================================================
> # Boot.make - used by ../boot/Makefile
>
> OBJCOPY = mipsel-linux-objcopy
> OBJCOPY_FLAGS = -R .stab -R .stabstr -R .comment -R .note -R .reginfo -R .mdebug
> OBJDUMP = mipsel-linux-objdump
> #OBJDUMP_HFLAGS = --disassemble-all -b srec -m mips:4600 -EL
>
> TOPDIR = ../../..
>
> ifeq ($(LINUX_SRC),)
> LINUX_SRC=$(TOPDIR)
> endif
> VMLINUX=$(LINUX_SRC)/vmlinux
> SYSTEM_MAP=$(LINUX_SRC)/System.map
>
> ifeq ($(USERLAND),)
> USERLAND=$(LINUX_SRC)/../userland
> endif
>
> FLASHADDR = 0xbfc00000
>
> # see arch/mips/Makefile LOADADDR
> # 0x10000 bottom 64k reserved by/for boot.S (FLASH_BEGIN)
> # 0x02000 additional 8k reserved RAM image vector table (see LOADADDR)
>
> ifdef CONFIG_NEC_MARKHAM_BOOTROM
> NN=10#in hex is 16M
> LOADADDR += 0x81002000
> ZLOADADDR += 0x81402000# +4M
> VMA = 0x7f00e000 # 0x0-0x81000000+0x10000-0x2000
> ZVMA = 0x7ebfe000 # 0x0-0x81402000
> else
> NN=00
> LOADADDR += 0x80002000
> ZLOADADDR += 0x80402000# +4M
> VMA = 0x8000e000 # 0x0-0x80000000+0x10000-0x2000
> ZVMA = 0x7fbfe000 # 0x0-0x80402000
> endif
>
> KERNEL_ENTRY=$(shell awk '/kernel_entry/{print "0x" $$1}' $(LINUX_SRC)/System.map)
>
> override CFLAGS += -DKERNEL_ENTRY=$(KERNEL_ENTRY) -DNN=$(NN)
> override CFLAGS += -DLOADADDR=$(LOADADDR) -DFLASHADDR=$(FLASHADDR) -DZLOADADDR=$(ZLOADADDR)
>
> ifdef CONFIG_NEC_KORVA_COMPRESSED
> zbootroms: bin zsrec
> else
> bootroms: bin srec
> endif
>
> $(TOPDIR)/arch/$(ARCH)/ld.script.$(ZLOADADDR)_z: $(TOPDIR)/arch/$(ARCH)/ld.script.in
> sed -e 's/kernel_entry/__start/' -e 's/@@LOADADDR@@/$(ZLOADADDR)/' <$< >$@
>
> ZLINKFLAGS += -T $(TOPDIR)/arch/$(ARCH)/ld.script.$(ZLOADADDR)_z
>
> misc.c: ../korva/misc.c
> @rm -f $@
> cp $< $@
>
> boot.S: ../korva/boot.S
> @rm -f $@
> cp $< $@
>
> #vrboot$(NN): boot.o
> vrboot$(NN): boot.o misc.o $(TOPDIR)/arch/$(ARCH)/ld.script.$(ZLOADADDR)_z
> @rm -f $@
> ifdef CONFIG_NEC_KORVA_COMPRESSED
> $(LD) $(LDFLAGS) -static -EL -N -o $@ $(ZLINKFLAGS) boot.o misc.o
> else
> $(LD) $(LDFLAGS) -static -EL -N -o $@ -Ttext $(FLASHADDR) boot.o
> endif
> @rm -f $^ ../boot/misc.c ../boot/boot.S
>
> vmlinux$(NN): $(VMLINUX)
> @rm -f System$(NN).map
> cp -p $(SYSTEM_MAP) System$(NN).map
> cp -p $< $@
>
> # move sections to 0, then add bfc00000 for ROMulator
> vrvmlinux$(NN)-0: vmlinux$(NN) vrboot$(NN)
> @rm -f $@
> $(OBJCOPY) $(OBJCOPY_FLAGS) --change-addresses 0 -O binary \
> vrboot$(NN) vrboot$(NN)-0.bin
> $(OBJCOPY) $(OBJCOPY_FLAGS) --change-addresses $(VMA) \
> vmlinux$(NN) vmlinux$(NN)-0
> $(OBJCOPY) $(OBJCOPY_FLAGS) --add-section .vrboot=vrboot$(NN)-0.bin \
> --set-section-flags .vrboot=,alloc,load,readonly,code \
> vmlinux$(NN)-0 vrvmlinux$(NN)-0
>
> vrvmlinux$(NN)-bfc: vrvmlinux$(NN)-0
> $(OBJCOPY) $(OBJCOPY_FLAGS) --change-address $(FLASHADDR) \
> vrvmlinux$(NN)-0 vrvmlinux$(NN)-bfc
>
> # xxx-bfc.bin is for 'reload' & 'reburn' used on a running system
> vrvmlinux$(NN)-bfc.bin: vrvmlinux$(NN)-0
> $(OBJCOPY) $(OBJCOPY_FLAGS) --change-address $(FLASHADDR) -O binary \
> vrvmlinux$(NN)-0 vrvmlinux$(NN)-bfc.bin
>
> bin: vrvmlinux$(NN)-bfc vrvmlinux$(NN)-bfc.bin
>
> vrvmlinux$(NN)-0.srec: vrvmlinux$(NN)-0
> $(OBJCOPY) $(OBJCOPY_FLAGS) -O srec --srec-forceS3 --gap-fill 0 \
> vrvmlinux$(NN)-0 vrvmlinux$(NN)-0.srec
> $(OBJCOPY) $(OBJCOPY_FLAGS) --change-address $(FLASHADDR) -O srec \
> vrvmlinux$(NN)-0 vrvmlinux$(NN)-bfc.srec
>
> srec: vrvmlinux$(NN)-0.srec
>
> # used by 'reburn' script for Korva (8M) which needs small 256K chunks
> split:
> @rm -rf split
> @mkdir split
> cd split && split -b 256k ../vrvmlinux00-bfc.bin vrvm
>
> # compressed...
>
> vmlinux$(NN).bin.gz: vmlinux$(NN)
> $(OBJCOPY) -S -O binary $< $<.bin
> gzip -vf $<.bin
>
> zvrvmlinux$(NN)-0: vmlinux$(NN).bin.gz vrboot$(NN)
> @rm -f $@
> $(OBJCOPY) $(OBJCOPY_FLAGS) --change-addresses=$(ZVMA) \
> vrboot$(NN) zvrboot$(NN)-0
> $(OBJCOPY) $(OBJCOPY_FLAGS) --add-section .vmlinux=vmlinux$(NN).bin.gz \
> --change-section-address .vmlinux=0x10000 \
> --set-section-flags .vmlinux=,alloc,load,readonly,code \
> zvrboot$(NN)-0 zvrvmlinux$(NN)-0
>
> zvrvmlinux$(NN)-0.srec: zvrvmlinux$(NN)-0
> $(OBJCOPY) $(OBJCOPY_FLAGS) -O srec --srec-forceS3 \
> zvrvmlinux$(NN)-0 zvrvmlinux$(NN)-0.srec
> $(OBJCOPY) $(OBJCOPY_FLAGS) -O srec --srec-forceS3 \
> --change-address 0xbfc00000 \
> zvrvmlinux$(NN)-0 zvrvmlinux$(NN)-bfc.srec
>
> zsrec: zvrvmlinux$(NN)-0.srec
>
> clean::
> @rm -f System* vrvmlinux* vmlinux* vrboot* zvrvmlinux*
> ================================================================================
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: No bzImage target for MIPS
2001-12-14 18:05 ` Pete Popov
@ 2001-12-14 18:52 ` Geoffrey Espin
2001-12-14 19:11 ` Pete Popov
` (2 more replies)
0 siblings, 3 replies; 17+ messages in thread
From: Geoffrey Espin @ 2001-12-14 18:52 UTC (permalink / raw)
To: Pete Popov; +Cc: linux-mips
> The "original" pmon has outlived its purpose, although it's still found
> on many boards. I've become a fan of MIPS Tech's yamon; it's small, it
> works, it has just the features I need in an embedded system, and, did I
> say it works?. Unfortunately the code is released under NDA only. If
> MIPS opened the code, I think you would see it on many more boards.
I rest my case. Linux is GPL, last I checked. "LinuxMon", I'll
dub it, solves the problem... for all architectures. :-) Attached
is the trivial 'reload' script for loading linux on top of linux.
It's just a wrapper for 'dd'. Oh yeah, your reset.c:xxx_restart()
needs a quick check to see if a new kernel got loaded, and jump
to it, instead of PROM.
> > itself, as the "boot monitor" is best approach. All reusable
> > code, fastest bootstrap (i.e. no 2nd stage loading), etc... But,
> > of course, not optimal for size, though my image is 1.3M which
> > includes a 580K cramfs ramdisk.
> That's fine once you've ported the kernel to your board. What do you do
> before that point?
With a ROM Emulator, bringing up Linux is no harder than bringing
up a boot monitor or any embedded RTOS, no? A day or three, if
you are lucky and brilliant. A somewhat longer if you're not
lucky. :-) Getting serial I/O is always the first nut to crack...
with Monta Vista's dbg_io.c, this is greatly simplified. Of
course, I'm not counting all the extra drivers (Ethernet, ...)
and assuming a well supported architecture.
> patch. But I fail to see how having this code in every <board>
> directory is better than having a separate boot directory like the ppc
> arch. The ppc-like zImage support I added is a bit different from the
I quite agree that initrd stuff is not right, or rather builtin
ramdisk.o is not good for embedded. Having it attached to the
end of vmlinux, possibly padded/aligned to a nice flash sector
boundary should be the general rule. Having <board>/Boot.make
so one can customize the "make boot" target rule to do the right
thing on a board-by-board basis seems to be the way to go. E.g.
in arch/mips/boot/Makefile, simply:
#
# This file is subject to the terms and conditions of the GNU General Public
# License. See the file "COPYING" in the main directory of this archive
# for more details.
#
# Copyright (C) 1995, 1998, 2001 by Ralf Baechle
#
.S.s:
$(CPP) $(CFLAGS) $< -o $*.s
.S.o:
$(CC) $(CFLAGS) -c $< -o $*.o
...
ifdef CONFIG_NEC_KORVA
include ../korva/Boot.make
endif
all: vmlinux.ecoff addinitrd
...
BTW, does any actually build 'vmlinux.ecoff'?
And sure, cluttering up yet another Makefile with CONFIG_XXX_BOARD
is not desirable... rather some magic like:
include $?{CONFIG_BOARD:common}/Boot.make
would be nice.
Geoff
--
Geoffrey Espin espin@idiom.com
--
=reload.sh======================================================================
#!/bin/sh
IMAGE=vrvmlinux00-bfc.bin # 0M
SKIP=64 # 64K for vrboot
SEEK=8 # 8k (80002000) skip excep vecs to kernel offset
if [ `sed -n -e 's/8\([0-9]\).*bzero/\1/p' /proc/ksyms` -eq 0 ] ; then
echo "$0: kernel not running at high memory (e.g. 16M), use reboot"
exit 1
fi
if [ $# -eq 0 ] ; then
echo "usage (nfs): $0 <user>"
echo "usage (ftp): $0 <user> <password>"
exit 1
fi
USER=$1
shift
VM="/home/${USER}/linux/arch/mips/boot/${IMAGE}"
if [ $# -eq 1 ] ; then
PW=$1
shift
VMI="ftp://${USER}:${PW}@10.1.1.1${VM}"
VM=/tmp/${IMAGE}
echo wget -c ${VMI} -O ${VM}
wget -c ${VMI} -O ${VM}
if [ $? -ne 0 ] ; then
echo "wget failed"
exit 1
fi
else
# using NFS
fi
echo dd if=${VM} of=/dev/mem bs=1k skip=${SKIP} seek=${SEEK} conv=notrunc
dd if=${VM} of=/dev/mem bs=1k skip=${SKIP} seek=${SEEK} conv=notrunc
if [ $? -ne 0 ] ; then
echo "dd failed"
exit 1
fi
reboot
--
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: No bzImage target for MIPS
2001-12-14 18:52 ` Geoffrey Espin
@ 2001-12-14 19:11 ` Pete Popov
2001-12-15 8:31 ` Karsten Merker
2001-12-15 12:42 ` Florian Lohoff
2 siblings, 0 replies; 17+ messages in thread
From: Pete Popov @ 2001-12-14 19:11 UTC (permalink / raw)
To: Geoffrey Espin; +Cc: linux-mips
On Fri, 2001-12-14 at 10:52, Geoffrey Espin wrote:
>
> > The "original" pmon has outlived its purpose, although it's still found
> > on many boards. I've become a fan of MIPS Tech's yamon; it's small, it
> > works, it has just the features I need in an embedded system, and, did I
> > say it works?. Unfortunately the code is released under NDA only. If
> > MIPS opened the code, I think you would see it on many more boards.
>
> I rest my case. Linux is GPL, last I checked. "LinuxMon", I'll
> dub it, solves the problem... for all architectures. :-) Attached
> is the trivial 'reload' script for loading linux on top of linux.
> It's just a wrapper for 'dd'. Oh yeah, your reset.c:xxx_restart()
> needs a quick check to see if a new kernel got loaded, and jump
> to it, instead of PROM.
>
> > > itself, as the "boot monitor" is best approach. All reusable
> > > code, fastest bootstrap (i.e. no 2nd stage loading), etc... But,
> > > of course, not optimal for size, though my image is 1.3M which
> > > includes a 580K cramfs ramdisk.
> > That's fine once you've ported the kernel to your board. What do you do
> > before that point?
>
> With a ROM Emulator, bringing up Linux is no harder than bringing
> up a boot monitor or any embedded RTOS, no? A day or three, if
> you are lucky and brilliant. A somewhat longer if you're not
> lucky. :-) Getting serial I/O is always the first nut to crack...
> with Monta Vista's dbg_io.c, this is greatly simplified. Of
> course, I'm not counting all the extra drivers (Ethernet, ...)
> and assuming a well supported architecture.
True, if you can use a rom emulator on the given board, which you can't
do with all boards. But then you need to connect the emulator to the
board every time you want to do something ... I don't know, give me a
working boot loader with enet support and I'll take that instead.
> > patch. But I fail to see how having this code in every <board>
> > directory is better than having a separate boot directory like the ppc
> > arch. The ppc-like zImage support I added is a bit different from the
>
> I quite agree that initrd stuff is not right, or rather builtin
> ramdisk.o is not good for embedded. Having it attached to the
> end of vmlinux, possibly padded/aligned to a nice flash sector
> boundary should be the general rule. Having <board>/Boot.make
> so one can customize the "make boot" target rule to do the right
> thing on a board-by-board basis seems to be the way to go.
Exactly. That's why the <board> directory in arch/mips/zboot :-) BTW, I
added the new zboot directory in sourceforge because arch/mips/boot was
in the way and I didn't want to mess with that one.
Ultimately I don't care if the zImage support is in each <board>
directory or in a new directory like arch/mips/zboot, as long as the
support for zImages and, eventually, initrd, is there.
BTW, if you don't package up your work in a patch that Ralf would take,
the bits get lost over time. I don't know if you care, but that's how
linux evolves so I hope you submit your patches upstream rather than
allowing them to get lost in mailing lists.
Pete
> E.g.
> in arch/mips/boot/Makefile, simply:
>
> #
> # This file is subject to the terms and conditions of the GNU General Public
> # License. See the file "COPYING" in the main directory of this archive
> # for more details.
> #
> # Copyright (C) 1995, 1998, 2001 by Ralf Baechle
> #
>
> .S.s:
> $(CPP) $(CFLAGS) $< -o $*.s
> .S.o:
> $(CC) $(CFLAGS) -c $< -o $*.o
> ...
> ifdef CONFIG_NEC_KORVA
> include ../korva/Boot.make
> endif
>
> all: vmlinux.ecoff addinitrd
> ...
>
> BTW, does any actually build 'vmlinux.ecoff'?
>
> And sure, cluttering up yet another Makefile with CONFIG_XXX_BOARD
> is not desirable... rather some magic like:
>
> include $?{CONFIG_BOARD:common}/Boot.make
>
> would be nice.
>
> Geoff
> --
> Geoffrey Espin espin@idiom.com
> --
> =reload.sh======================================================================
> #!/bin/sh
>
> IMAGE=vrvmlinux00-bfc.bin # 0M
> SKIP=64 # 64K for vrboot
> SEEK=8 # 8k (80002000) skip excep vecs to kernel offset
>
> if [ `sed -n -e 's/8\([0-9]\).*bzero/\1/p' /proc/ksyms` -eq 0 ] ; then
> echo "$0: kernel not running at high memory (e.g. 16M), use reboot"
> exit 1
> fi
>
> if [ $# -eq 0 ] ; then
> echo "usage (nfs): $0 <user>"
> echo "usage (ftp): $0 <user> <password>"
> exit 1
> fi
>
> USER=$1
> shift
>
> VM="/home/${USER}/linux/arch/mips/boot/${IMAGE}"
>
> if [ $# -eq 1 ] ; then
> PW=$1
> shift
> VMI="ftp://${USER}:${PW}@10.1.1.1${VM}"
> VM=/tmp/${IMAGE}
> echo wget -c ${VMI} -O ${VM}
> wget -c ${VMI} -O ${VM}
> if [ $? -ne 0 ] ; then
> echo "wget failed"
> exit 1
> fi
> else
> # using NFS
> fi
>
> echo dd if=${VM} of=/dev/mem bs=1k skip=${SKIP} seek=${SEEK} conv=notrunc
> dd if=${VM} of=/dev/mem bs=1k skip=${SKIP} seek=${SEEK} conv=notrunc
>
> if [ $? -ne 0 ] ; then
> echo "dd failed"
> exit 1
> fi
>
> reboot
>
> --
^ permalink raw reply [flat|nested] 17+ messages in thread
* RE: No bzImage target for MIPS
@ 2001-12-14 22:59 Marc Karasek
2001-12-14 23:42 ` Pete Popov
0 siblings, 1 reply; 17+ messages in thread
From: Marc Karasek @ 2001-12-14 22:59 UTC (permalink / raw)
To: 'Pete Popov ', 'Geoffrey Espin '; +Cc: 'linux-mips '
What about redboot? It is Open Source and has support for a variety of
processors. The structure is such that adding support for a new
platform/processor is very easy. It has support for booting a linux kernel
and as an added bonus support for ecos is pretty much done once you get it
ported.
-----Original Message-----
From: Pete Popov
To: Geoffrey Espin
Cc: linux-mips
Sent: 12/14/01 2:11 PM
Subject: Re: No bzImage target for MIPS
On Fri, 2001-12-14 at 10:52, Geoffrey Espin wrote:
>
> > The "original" pmon has outlived its purpose, although it's still
found
> > on many boards. I've become a fan of MIPS Tech's yamon; it's small,
it
> > works, it has just the features I need in an embedded system, and,
did I
> > say it works?. Unfortunately the code is released under NDA only.
If
> > MIPS opened the code, I think you would see it on many more boards.
>
> I rest my case. Linux is GPL, last I checked. "LinuxMon", I'll
> dub it, solves the problem... for all architectures. :-) Attached
> is the trivial 'reload' script for loading linux on top of linux.
> It's just a wrapper for 'dd'. Oh yeah, your reset.c:xxx_restart()
> needs a quick check to see if a new kernel got loaded, and jump
> to it, instead of PROM.
>
> > > itself, as the "boot monitor" is best approach. All reusable
> > > code, fastest bootstrap (i.e. no 2nd stage loading), etc... But,
> > > of course, not optimal for size, though my image is 1.3M which
> > > includes a 580K cramfs ramdisk.
> > That's fine once you've ported the kernel to your board. What do you
do
> > before that point?
>
> With a ROM Emulator, bringing up Linux is no harder than bringing
> up a boot monitor or any embedded RTOS, no? A day or three, if
> you are lucky and brilliant. A somewhat longer if you're not
> lucky. :-) Getting serial I/O is always the first nut to crack...
> with Monta Vista's dbg_io.c, this is greatly simplified. Of
> course, I'm not counting all the extra drivers (Ethernet, ...)
> and assuming a well supported architecture.
True, if you can use a rom emulator on the given board, which you can't
do with all boards. But then you need to connect the emulator to the
board every time you want to do something ... I don't know, give me a
working boot loader with enet support and I'll take that instead.
> > patch. But I fail to see how having this code in every <board>
> > directory is better than having a separate boot directory like the
ppc
> > arch. The ppc-like zImage support I added is a bit different from
the
>
> I quite agree that initrd stuff is not right, or rather builtin
> ramdisk.o is not good for embedded. Having it attached to the
> end of vmlinux, possibly padded/aligned to a nice flash sector
> boundary should be the general rule. Having <board>/Boot.make
> so one can customize the "make boot" target rule to do the right
> thing on a board-by-board basis seems to be the way to go.
Exactly. That's why the <board> directory in arch/mips/zboot :-) BTW, I
added the new zboot directory in sourceforge because arch/mips/boot was
in the way and I didn't want to mess with that one.
Ultimately I don't care if the zImage support is in each <board>
directory or in a new directory like arch/mips/zboot, as long as the
support for zImages and, eventually, initrd, is there.
BTW, if you don't package up your work in a patch that Ralf would take,
the bits get lost over time. I don't know if you care, but that's how
linux evolves so I hope you submit your patches upstream rather than
allowing them to get lost in mailing lists.
Pete
> E.g.
> in arch/mips/boot/Makefile, simply:
>
> #
> # This file is subject to the terms and conditions of the GNU
General Public
> # License. See the file "COPYING" in the main directory of this
archive
> # for more details.
> #
> # Copyright (C) 1995, 1998, 2001 by Ralf Baechle
> #
>
> .S.s:
> $(CPP) $(CFLAGS) $< -o $*.s
> .S.o:
> $(CC) $(CFLAGS) -c $< -o $*.o
> ...
> ifdef CONFIG_NEC_KORVA
> include ../korva/Boot.make
> endif
>
> all: vmlinux.ecoff addinitrd
> ...
>
> BTW, does any actually build 'vmlinux.ecoff'?
>
> And sure, cluttering up yet another Makefile with CONFIG_XXX_BOARD
> is not desirable... rather some magic like:
>
> include $?{CONFIG_BOARD:common}/Boot.make
>
> would be nice.
>
> Geoff
> --
> Geoffrey Espin espin@idiom.com
> --
>
=reload.sh==============================================================
========
> #!/bin/sh
>
> IMAGE=vrvmlinux00-bfc.bin # 0M
> SKIP=64 # 64K for vrboot
> SEEK=8 # 8k (80002000) skip excep vecs to kernel
offset
>
> if [ `sed -n -e 's/8\([0-9]\).*bzero/\1/p' /proc/ksyms` -eq 0 ] ; then
> echo "$0: kernel not running at high memory (e.g. 16M), use
reboot"
> exit 1
> fi
>
> if [ $# -eq 0 ] ; then
> echo "usage (nfs): $0 <user>"
> echo "usage (ftp): $0 <user> <password>"
> exit 1
> fi
>
> USER=$1
> shift
>
> VM="/home/${USER}/linux/arch/mips/boot/${IMAGE}"
>
> if [ $# -eq 1 ] ; then
> PW=$1
> shift
> VMI="ftp://${USER}:${PW}@10.1.1.1${VM}"
> VM=/tmp/${IMAGE}
> echo wget -c ${VMI} -O ${VM}
> wget -c ${VMI} -O ${VM}
> if [ $? -ne 0 ] ; then
> echo "wget failed"
> exit 1
> fi
> else
> # using NFS
> fi
>
> echo dd if=${VM} of=/dev/mem bs=1k skip=${SKIP} seek=${SEEK}
conv=notrunc
> dd if=${VM} of=/dev/mem bs=1k skip=${SKIP} seek=${SEEK} conv=notrunc
>
> if [ $? -ne 0 ] ; then
> echo "dd failed"
> exit 1
> fi
>
> reboot
>
> --
^ permalink raw reply [flat|nested] 17+ messages in thread
* RE: No bzImage target for MIPS
2001-12-14 22:59 No bzImage target for MIPS Marc Karasek
@ 2001-12-14 23:42 ` Pete Popov
0 siblings, 0 replies; 17+ messages in thread
From: Pete Popov @ 2001-12-14 23:42 UTC (permalink / raw)
To: Marc Karasek; +Cc: 'Geoffrey Espin ', 'linux-mips '
On Fri, 2001-12-14 at 14:59, Marc Karasek wrote:
> What about redboot? It is Open Source and has support for a variety of
> processors. The structure is such that adding support for a new
> platform/processor is very easy. It has support for booting a linux kernel
> and as an added bonus support for ecos is pretty much done once you get it
> ported.
If you're doing your own board, redboot may be fine. But typically
vendors of referrence boards want you to use whatever boot code they
already have running because they are not willing to pay for new boot
code.
Pete
>
>
>
> -----Original Message-----
> From: Pete Popov
> To: Geoffrey Espin
> Cc: linux-mips
> Sent: 12/14/01 2:11 PM
> Subject: Re: No bzImage target for MIPS
>
> On Fri, 2001-12-14 at 10:52, Geoffrey Espin wrote:
> >
> > > The "original" pmon has outlived its purpose, although it's still
> found
> > > on many boards. I've become a fan of MIPS Tech's yamon; it's small,
> it
> > > works, it has just the features I need in an embedded system, and,
> did I
> > > say it works?. Unfortunately the code is released under NDA only.
> If
> > > MIPS opened the code, I think you would see it on many more boards.
> >
> > I rest my case. Linux is GPL, last I checked. "LinuxMon", I'll
> > dub it, solves the problem... for all architectures. :-) Attached
> > is the trivial 'reload' script for loading linux on top of linux.
> > It's just a wrapper for 'dd'. Oh yeah, your reset.c:xxx_restart()
> > needs a quick check to see if a new kernel got loaded, and jump
> > to it, instead of PROM.
> >
> > > > itself, as the "boot monitor" is best approach. All reusable
> > > > code, fastest bootstrap (i.e. no 2nd stage loading), etc... But,
> > > > of course, not optimal for size, though my image is 1.3M which
> > > > includes a 580K cramfs ramdisk.
> > > That's fine once you've ported the kernel to your board. What do you
> do
> > > before that point?
> >
> > With a ROM Emulator, bringing up Linux is no harder than bringing
> > up a boot monitor or any embedded RTOS, no? A day or three, if
> > you are lucky and brilliant. A somewhat longer if you're not
> > lucky. :-) Getting serial I/O is always the first nut to crack...
> > with Monta Vista's dbg_io.c, this is greatly simplified. Of
> > course, I'm not counting all the extra drivers (Ethernet, ...)
> > and assuming a well supported architecture.
>
> True, if you can use a rom emulator on the given board, which you can't
> do with all boards. But then you need to connect the emulator to the
> board every time you want to do something ... I don't know, give me a
> working boot loader with enet support and I'll take that instead.
>
> > > patch. But I fail to see how having this code in every <board>
> > > directory is better than having a separate boot directory like the
> ppc
> > > arch. The ppc-like zImage support I added is a bit different from
> the
> >
> > I quite agree that initrd stuff is not right, or rather builtin
> > ramdisk.o is not good for embedded. Having it attached to the
> > end of vmlinux, possibly padded/aligned to a nice flash sector
> > boundary should be the general rule. Having <board>/Boot.make
> > so one can customize the "make boot" target rule to do the right
> > thing on a board-by-board basis seems to be the way to go.
>
> Exactly. That's why the <board> directory in arch/mips/zboot :-) BTW, I
> added the new zboot directory in sourceforge because arch/mips/boot was
> in the way and I didn't want to mess with that one.
>
> Ultimately I don't care if the zImage support is in each <board>
> directory or in a new directory like arch/mips/zboot, as long as the
> support for zImages and, eventually, initrd, is there.
>
> BTW, if you don't package up your work in a patch that Ralf would take,
> the bits get lost over time. I don't know if you care, but that's how
> linux evolves so I hope you submit your patches upstream rather than
> allowing them to get lost in mailing lists.
>
> Pete
>
> > E.g.
> > in arch/mips/boot/Makefile, simply:
> >
> > #
> > # This file is subject to the terms and conditions of the GNU
> General Public
> > # License. See the file "COPYING" in the main directory of this
> archive
> > # for more details.
> > #
> > # Copyright (C) 1995, 1998, 2001 by Ralf Baechle
> > #
> >
> > .S.s:
> > $(CPP) $(CFLAGS) $< -o $*.s
> > .S.o:
> > $(CC) $(CFLAGS) -c $< -o $*.o
> > ...
> > ifdef CONFIG_NEC_KORVA
> > include ../korva/Boot.make
> > endif
> >
> > all: vmlinux.ecoff addinitrd
> > ...
> >
> > BTW, does any actually build 'vmlinux.ecoff'?
> >
> > And sure, cluttering up yet another Makefile with CONFIG_XXX_BOARD
> > is not desirable... rather some magic like:
> >
> > include $?{CONFIG_BOARD:common}/Boot.make
> >
> > would be nice.
> >
> > Geoff
> > --
> > Geoffrey Espin espin@idiom.com
> > --
> >
> =reload.sh==============================================================
> ========
> > #!/bin/sh
> >
> > IMAGE=vrvmlinux00-bfc.bin # 0M
> > SKIP=64 # 64K for vrboot
> > SEEK=8 # 8k (80002000) skip excep vecs to kernel
> offset
> >
> > if [ `sed -n -e 's/8\([0-9]\).*bzero/\1/p' /proc/ksyms` -eq 0 ] ; then
> > echo "$0: kernel not running at high memory (e.g. 16M), use
> reboot"
> > exit 1
> > fi
> >
> > if [ $# -eq 0 ] ; then
> > echo "usage (nfs): $0 <user>"
> > echo "usage (ftp): $0 <user> <password>"
> > exit 1
> > fi
> >
> > USER=$1
> > shift
> >
> > VM="/home/${USER}/linux/arch/mips/boot/${IMAGE}"
> >
> > if [ $# -eq 1 ] ; then
> > PW=$1
> > shift
> > VMI="ftp://${USER}:${PW}@10.1.1.1${VM}"
> > VM=/tmp/${IMAGE}
> > echo wget -c ${VMI} -O ${VM}
> > wget -c ${VMI} -O ${VM}
> > if [ $? -ne 0 ] ; then
> > echo "wget failed"
> > exit 1
> > fi
> > else
> > # using NFS
> > fi
> >
> > echo dd if=${VM} of=/dev/mem bs=1k skip=${SKIP} seek=${SEEK}
> conv=notrunc
> > dd if=${VM} of=/dev/mem bs=1k skip=${SKIP} seek=${SEEK} conv=notrunc
> >
> > if [ $? -ne 0 ] ; then
> > echo "dd failed"
> > exit 1
> > fi
> >
> > reboot
> >
> > --
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: No bzImage target for MIPS
2001-12-14 18:52 ` Geoffrey Espin
2001-12-14 19:11 ` Pete Popov
@ 2001-12-15 8:31 ` Karsten Merker
2001-12-15 9:14 ` Keith Owens
2001-12-15 12:42 ` Florian Lohoff
2 siblings, 1 reply; 17+ messages in thread
From: Karsten Merker @ 2001-12-15 8:31 UTC (permalink / raw)
To: linux-mips
On Fri, Dec 14, 2001 at 10:52:57AM -0800, Geoffrey Espin wrote:
> all: vmlinux.ecoff addinitrd
> ...
>
> BTW, does any actually build 'vmlinux.ecoff'?
Yes, it is (among other uses) the default target for DECstations,
the DECstation firmware cannot tftp-boot anything else.
Greetings,
Karsten
--
#include <standard_disclaimer>
Nach Paragraph 28 Abs. 3 Bundesdatenschutzgesetz widerspreche ich der Nutzung
oder Uebermittlung meiner Daten fuer Werbezwecke oder fuer die Markt- oder
Meinungsforschung.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: No bzImage target for MIPS
2001-12-15 8:31 ` Karsten Merker
@ 2001-12-15 9:14 ` Keith Owens
2001-12-15 12:46 ` Florian Lohoff
2001-12-17 13:12 ` Maciej W. Rozycki
0 siblings, 2 replies; 17+ messages in thread
From: Keith Owens @ 2001-12-15 9:14 UTC (permalink / raw)
To: Karsten Merker; +Cc: linux-mips
On Sat, 15 Dec 2001 09:31:01 +0100,
Karsten Merker <karsten@excalibur.cologne.de> wrote:
>On Fri, Dec 14, 2001 at 10:52:57AM -0800, Geoffrey Espin wrote:
>> BTW, does any actually build 'vmlinux.ecoff'?
>
>Yes, it is (among other uses) the default target for DECstations,
>the DECstation firmware cannot tftp-boot anything else.
I am standardizing the list of supported formats for linux boot, as
part of the kbuild 2.5 rewrite, I will add vmlinux.ecoff to the master
list.
AFAICT ecoff is only used on mips but, since ecoff is not an arch
specific object format, it makes sense to make it a generic kbuild
target, like elf, srec and bin. To that end, I looked at moving
elf2ecoff and addinitrd to an arch independent directory so everybody
could use those tools, alas both contain mips specific code. Any idea
how much work is required to make elf2ecoff and addinitrd into generic
utilities? Is it worth the effort or should they stay as mips only?
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: No bzImage target for MIPS
2001-12-14 18:52 ` Geoffrey Espin
2001-12-14 19:11 ` Pete Popov
2001-12-15 8:31 ` Karsten Merker
@ 2001-12-15 12:42 ` Florian Lohoff
2 siblings, 0 replies; 17+ messages in thread
From: Florian Lohoff @ 2001-12-15 12:42 UTC (permalink / raw)
To: Geoffrey Espin; +Cc: Pete Popov, linux-mips
[-- Attachment #1: Type: text/plain, Size: 352 bytes --]
On Fri, Dec 14, 2001 at 10:52:57AM -0800, Geoffrey Espin wrote:
>
> BTW, does any actually build 'vmlinux.ecoff'?
>
Yep - Some Indy/Indigo2 proms only boot ecoff images via tftp.
Flo
--
Florian Lohoff flo@rfc822.org +49-5201-669912
Nine nineth on september the 9th Welcome to the new billenium
[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: No bzImage target for MIPS
2001-12-15 9:14 ` Keith Owens
@ 2001-12-15 12:46 ` Florian Lohoff
2001-12-17 20:32 ` Ralf Baechle
2001-12-17 13:12 ` Maciej W. Rozycki
1 sibling, 1 reply; 17+ messages in thread
From: Florian Lohoff @ 2001-12-15 12:46 UTC (permalink / raw)
To: Keith Owens; +Cc: Karsten Merker, linux-mips
[-- Attachment #1: Type: text/plain, Size: 947 bytes --]
On Sat, Dec 15, 2001 at 08:14:59PM +1100, Keith Owens wrote:
> target, like elf, srec and bin. To that end, I looked at moving
> elf2ecoff and addinitrd to an arch independent directory so everybody
> could use those tools, alas both contain mips specific code. Any idea
> how much work is required to make elf2ecoff and addinitrd into generic
> utilities? Is it worth the effort or should they stay as mips only?
Last i had a look elf2ecoff and addinitrd were not really nice
recovering from toolchain problems like pages of null between sections
which was a common fault a couple months back. This lead to addinitrd
not beeing able to attach a ramdisk that the kernel would be able to
find it.
BTW: Shouldn't objcopy be able to convert an ELF into an ECOFF ?
Flo
--
Florian Lohoff flo@rfc822.org +49-5201-669912
Nine nineth on september the 9th Welcome to the new billenium
[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: No bzImage target for MIPS
2001-12-15 9:14 ` Keith Owens
2001-12-15 12:46 ` Florian Lohoff
@ 2001-12-17 13:12 ` Maciej W. Rozycki
1 sibling, 0 replies; 17+ messages in thread
From: Maciej W. Rozycki @ 2001-12-17 13:12 UTC (permalink / raw)
To: Keith Owens; +Cc: Karsten Merker, linux-mips
On Sat, 15 Dec 2001, Keith Owens wrote:
> AFAICT ecoff is only used on mips but, since ecoff is not an arch
> specific object format, it makes sense to make it a generic kbuild
> target, like elf, srec and bin. To that end, I looked at moving
> elf2ecoff and addinitrd to an arch independent directory so everybody
> could use those tools, alas both contain mips specific code. Any idea
> how much work is required to make elf2ecoff and addinitrd into generic
> utilities? Is it worth the effort or should they stay as mips only?
Elf2ecoff is probably going not to be used one day anymore, i.e. once
binutils are fixed. Right now there is a problem in marking ELF
executables impure (non-paged). Ultimately either objcopy or even ld
directly is going to be used for ECOFF binary creation.
--
+ Maciej W. Rozycki, Technical University of Gdansk, Poland +
+--------------------------------------------------------------+
+ e-mail: macro@ds2.pg.gda.pl, PGP key available +
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: No bzImage target for MIPS
2001-12-15 12:46 ` Florian Lohoff
@ 2001-12-17 20:32 ` Ralf Baechle
0 siblings, 0 replies; 17+ messages in thread
From: Ralf Baechle @ 2001-12-17 20:32 UTC (permalink / raw)
To: Florian Lohoff; +Cc: Keith Owens, Karsten Merker, linux-mips
On Sat, Dec 15, 2001 at 01:46:04PM +0100, Florian Lohoff wrote:
> > target, like elf, srec and bin. To that end, I looked at moving
> > elf2ecoff and addinitrd to an arch independent directory so everybody
> > could use those tools, alas both contain mips specific code. Any idea
> > how much work is required to make elf2ecoff and addinitrd into generic
> > utilities? Is it worth the effort or should they stay as mips only?
>
> Last i had a look elf2ecoff and addinitrd were not really nice
> recovering from toolchain problems like pages of null between sections
> which was a common fault a couple months back. This lead to addinitrd
> not beeing able to attach a ramdisk that the kernel would be able to
> find it.
>
> BTW: Shouldn't objcopy be able to convert an ELF into an ECOFF ?
In theory yes, in practice that was found to be so problematic that we
just gave up and use those NetBSD tools.
Ralf
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2001-12-17 21:33 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-12-14 22:59 No bzImage target for MIPS Marc Karasek
2001-12-14 23:42 ` Pete Popov
-- strict thread matches above, loose matches on Subject: below --
2001-12-14 0:55 Marc Karasek
2001-12-14 0:47 Krishna Kondaka
2001-12-14 1:10 ` Pete Popov
2001-12-14 3:28 ` Geoffrey Espin
2001-12-14 3:51 ` Keith Owens
2001-12-14 4:12 ` Geoffrey Espin
2001-12-14 18:05 ` Pete Popov
2001-12-14 18:52 ` Geoffrey Espin
2001-12-14 19:11 ` Pete Popov
2001-12-15 8:31 ` Karsten Merker
2001-12-15 9:14 ` Keith Owens
2001-12-15 12:46 ` Florian Lohoff
2001-12-17 20:32 ` Ralf Baechle
2001-12-17 13:12 ` Maciej W. Rozycki
2001-12-15 12:42 ` Florian Lohoff
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.