From: wdenk Date: Fri, 4 Aug 2000 12:47:54 +0000 (+0000) Subject: Release 0.4.2: X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=2b5d10b819b296dccd1d468c7a401473a54a404f;p=users%2Frw%2Fppcboot.git Release 0.4.2: Bug fixing, see TODO file for details. Added persistent environment handling (save to flash). --- diff --git a/CREDITS b/CREDITS index 5ddbc12..fa3c8c8 100644 --- a/CREDITS +++ b/CREDITS @@ -1,17 +1,26 @@ - - This is at least a partial credits-file of people that have - contributed to the PPCBOOT project. It is sorted by name and - formatted to allow easy grepping and beautification by scripts. - The fields are: name (N), email (E), web-address (W), PGP key ID - and fingerprint (P), description (D), and snail-mail address (S). - Thanks, - - Wolfgang Denk ----------- +# +# Parts of the development effort for this project have been +# sponsored by SIEMENS AG, Austria. Thanks to SIEMENS for +# supporting an Open Source project! +# +# +# This is at least a partial credits-file of individual people that +# have contributed to the PPCBOOT project. It is sorted by name and +# formatted to allow easy grepping and beautification by scripts. +# The fields are: name (N), email (E), web-address (W), PGP key ID +# and fingerprint (P), description (D), and snail-mail address (S). +# Thanks, +# +# Wolfgang Denk +#---------- + +N: Andre Beaudin +E: +D: PCMCIA, Ethernet, TFTP N: Roland Borde E: 100.130266@germanynet.de -D: TFTP / BOOTP +D: Ethernet, TFTP / BOOTP N: Raphael Bossek E: raphael.bossek@solutions4linux.de @@ -28,6 +37,7 @@ D: 8xxrom N: Wolfgang Denk E: wd@denx.de D: PPCBOOT initial version +W: www.denx.de N: Kirk Haderlie E: khaderlie@vividimage.com diff --git a/Makefile b/Makefile index c0221ca..cd9b438 100644 --- a/Makefile +++ b/Makefile @@ -24,8 +24,6 @@ ARCH := ppc CPU := mpc8xx BOARD := tqm8xx -#XXX#KERNEL := /home/wd/ppc/linux-2.2.13 -KERNEL := HOSTARCH := $(shell uname -m | \ sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/) @@ -36,7 +34,7 @@ else CROSS_COMPILE = powerpc-linux- endif -export ARCH CPU BOARD KERNEL CROSS_COMPILE HOSTARCH +export ARCH CPU BOARD CROSS_COMPILE HOSTARCH SUBDIRS = $(ARCH) $(CPU) $(BOARD) common examples tools @@ -61,17 +59,11 @@ all: ppcboot.srec install: all cp ppcboot.srec /net/gatekeeper/tftpboot/moni.srec -#ppcboot.elf: ppcboot -# $(OBJCOPY) $(OBJCFLAGS) -O elf32-powerpc $< $@ -# -#ppcboot.srec: ppcboot.elf -# $(OBJCOPY) -O srec $< $@ - ppcboot.srec: ppcboot $(OBJCOPY) -O srec $< $@ -ppcboot: $(SUBDIRS) $(OBJS) include/ppcboot.lds - $(LD) $(LDFLAGS) $(OBJS) -o ppcboot +ppcboot: $(SUBDIRS) $(OBJS) $(LDSCRIPT) + $(LD) $(LDFLAGS) $(OBJS) -Map ppcboot.map -o ppcboot $(SUBDIRS): dummy @for dir in $(SUBDIRS) ; do $(MAKE) -C $$dir || exit 1 ; done @@ -80,13 +72,29 @@ dummy: ######################################################################### +TQM823L_config \ +TQM850L_config \ +TQM860L_config : + rm -f board cpu include/config.h + ln -s tqm8xx board + ln -s mpc8xx cpu + cd include ; ln -s config_$(@:_config=).h config.h + +FADS_config: + rm -f board cpu include/config.h + ln -s FADS board + ln -s mpc8xx cpu + cd include ; ln -s config_FADS.h config.h + +######################################################################### + clean: @for dir in $(SUBDIRS); do $(MAKE) -C $$dir clean; done clobber distclean: clean @for dir in $(SUBDIRS) ; do $(MAKE) -C $$dir distclean; done rm -f $(OBJS) *.bak - rm -f ppcboot ppcboot.bin ppcboot.elf ppcboot.srec + rm -f ppcboot ppcboot.bin ppcboot.elf ppcboot.srec ppcboot.map backup: F=`basename $(TOPDIR)` ; cd .. ; \ @@ -95,7 +103,7 @@ backup: ######################################################################### depend dep: - @for dir in $(SUBDIRS) ; do $(MAKE) -C $$dir $@ ; done + @for dir in $(SUBDIRS) ; do $(MAKE) -C $$dir .depend ; done ######################################################################### diff --git a/README b/README index 4618585..afd20c8 100644 --- a/README +++ b/README @@ -181,6 +181,9 @@ The following options need to be configured: Configuration Settings: ----------------------- +- CFG_LONGHELP: Defined when you want long help messages included; + undefine this when you're short of memory. + - CFG_PROMPT: This is what PPCBOOT prints on the console to prompt for user input. @@ -207,12 +210,6 @@ Configuration Settings: - CFG_MONITOR_LEN: Size of memory reserved for monitor code -- CFG_HWINFO_LEN: - Size of Hardware Information stored with monitor - -- CFG_HWINFO_ADDR: - Physical start address of HW Information - - CFG_MALLOC_LEN: Size of DRAM reserved for malloc() use. @@ -234,6 +231,21 @@ Configuration Settings: - CFG_FLASH_WRITE_TOUT: Timeout for Flash write operations (in ms) +- CFG_FLASH_ENV_ALIGN: + Bitshift to align envrionment data (aka NVRAM area) + to the beginning of the right flash sector; for + instance, to with bottom boot type flash chips the + second sector will be used; in our example + configuration, the offset for this sector ix 0x8000 + or 1 << 15, thus the value to use for + CFG_FLASH_ENV_ALIGN is 15 + + I _know_ this is *UGLY*. Please tell me if you know a + better way to do this - wd + +- CFG_FLASH_ENV_SIZE: + Size of the flash sector(s) used for the environment + Many of the remaining options are named exactly as the corresponding Linux kernel configuration options. The intention is to make it diff --git a/TODO b/TODO index 495c703..4f73b7f 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,19 @@ -* mkimage: +* NEW: - BUG: mkimage -d does not truncate an existing image + Add check that monitor still fits in area defined by CFG_MONITOR_LEN + +* ppc/vsprintf.c: + + Eliminate asc_to_hex() - replace by simple_strtoul() + +* Timer: + + don't use 'lr RX, const; mtdec RX" -> use: + mfdec R3 + foo: add. R3,277000,R3 # 277,777 is base 10 + ble foo + mtdec R3 + instead * loads: @@ -17,14 +30,10 @@ * saveenv: - Implement writing environment variables to Flash. Needs special - layout of monitor image to reserve one of the small Flash "boot" - sectors. Make sure we fall back to useful defaults in case somebody - erases the Flash contents. - -* INIT: - - get ethernet address from environment + Can we create a ld script which automagically takes care about + flash boot sector location, so that it makes code "flow" around the + gap if there is one, instead of hard-coding the map - which will + break if sizes change? * INIT: @@ -32,29 +41,59 @@ structure containing `monitor functions'; add things like malloc() and free(). -* protect: - - Bug in sector limit check: - - => protect off 40000000 40008000 - Un-Protected 35 sectors - * ALL: Put `implementation' features in #ifdef's to make it possible to shrink monitor size to specific needs -* command: +* BUG: + + Fix Exception handling for "Software Emulation Exception" etc. +====================================================================== +Modifications for 0.4.2: +====================================================================== + +* saveenv: + Implement writing environment variables to Flash. Needs special + layout of monitor image to reserve one of the small Flash "boot" + sectors. Make sure we fall back to useful defaults in case somebody + erases the Flash contents. + + Done - Thu Aug 3 2000 - wd@denx.de + +* INIT: + get ethernet address from environment + + Done - Thu Aug 3 2000 - wd@denx.de + +* NEW: + Implement equivalent to TQ "sethwi" command + => Use "setenv serial#" and "setenv ethaddr" and "saveenv" + + Done - Fri Aug 4 2000 - wd@denx.de + +* command: Make "long help" texts configurable by a #ifdef to reduce monitor size + => See CFG_LONGHELP option -* bootm: + Done - Sun Jul 30 2000 - wd@denx.de +* bootm: Make checksum verification of images optional (depending on "verify" environment variable?) to allow for fast boot is speed is more important than safety. + Done - Fri Aug 4 2000 - wd@denx.de -* NEW: +* protect: + Bug in sector limit check: + => protect off 40000000 40008000 + Un-Protected 35 sectors - Implement equivalent to TQ "sethwi" command + Done - Fri Aug 4 2000 - wd@denx.de + +* mkimage: + BUG: mkimage -d does not truncate an existing image + + Done - Fri Aug 4 2000 - wd@denx.de diff --git a/common/Makefile b/common/Makefile index 91ecf6c..6d953f6 100644 --- a/common/Makefile +++ b/common/Makefile @@ -25,10 +25,12 @@ include $(TOPDIR)/config.mk LIB = libcommon.a -OBJS = board.o main.o command.o \ +AOBJS = environment.o +COBJS = board.o main.o command.o \ cmd_cache.o cmd_mem.o cmd_boot.o cmd_flash.o \ cmd_bootm.o cmd_nvedit.o \ s_record.o dlmalloc.o +OBJS = $(AOBJS) $(COBJS) CPPFLAGS += -I.. @@ -41,9 +43,11 @@ clean: distclean: clean rm -f $(LIB) core *.bak .depend -.depend: Makefile $(OBJS:.o=.c) - $(CC) -M $(CFLAGS) $(OBJS:.o=.c) > $@ +######################################################################### -depend dep: .depend +.depend: Makefile $(AOBJS:.o=.S) $(COBJS:.o=.c) + $(CC) -M $(CFLAGS) $(AOBJS:.o=.S) $(COBJS:.o=.c) > $@ sinclude .depend + +######################################################################### diff --git a/common/board.c b/common/board.c index 8db763c..2cb8450 100644 --- a/common/board.c +++ b/common/board.c @@ -78,6 +78,7 @@ board_init_f (volatile immap_t *immr, unsigned long bootflag) int board_type; ulong addr_moni, addr_sp; ulong dram_size, cpu_speed; + char *s, *e; /* SYPCR - contains watchdog control (11-9) */ @@ -104,7 +105,7 @@ board_init_f (volatile immap_t *immr, unsigned long bootflag) immr->im_clkrstk.cark_plprcrk = KAPWR_KEY; reg = immr->im_clkrst.car_plprcr; reg &= PLPRCR_MF_MSK; /* isolate MF field */ - reg |= CFG_PLPRCR; /* reset control bits */ + reg |= CFG_PLPRCR; /* reset control bits */ immr->im_clkrst.car_plprcr = reg; /* System integration timers. Don't change EBDF! (15-27) */ @@ -216,16 +217,27 @@ board_init_f (volatile immap_t *immr, unsigned long bootflag) bd->bi_immr_base = (ulong)immr; /* base of IMMR register */ bd->bi_bootflags = bootflag; /* boot / reboot flag (for LynxOS) */ - bd->bi_ip_addr = (10<<24)|99; /* Default IP Address: 10.0.0.99 */ - bd->bi_enetaddr[0] = 0x00; /* Default Ethernet adress */ - bd->bi_enetaddr[1] = 0xD0; - bd->bi_enetaddr[2] = 0x93; - bd->bi_enetaddr[3] = 0x00; - bd->bi_enetaddr[4] = 0x02; - bd->bi_enetaddr[5] = 0x6C; + /* IP Address */ + bd->bi_ip_addr = 0; + s = getenv ("ipaddr"); + for (reg=0; reg<4; ++reg) { + ulong val = s ? simple_strtoul(s, &e, 10) : 0; + bd->bi_ip_addr <<= 8; + bd->bi_ip_addr |= (val & 0xFF); + s = (*e) ? e+1 : e; + } + + s = getenv ("ethaddr"); + for (reg=0; reg<6; ++reg) { + bd->bi_enetaddr[reg] = s ? simple_strtoul(s, &e, 16) : 0; + s = (*e) ? e+1 : e; + } bd->bi_intfreq = cpu_speed; /* Internal Freq, in MHz */ bd->bi_busfreq = CONFIG_8xx_BUSCLOCK; /* Bus Freq, in MHz */ - bd->bi_baudrate = CONFIG_8xx_BAUDRATE; /* Console Baudrate */ + + /* Console Baudrate */ + s = getenv ("baudrate"); + bd->bi_baudrate = s ? (int)simple_strtoul(s, NULL, 10) : 9600; /* Function pointers must be added after code relocation */ #if 0 diff --git a/common/cmd_boot.c b/common/cmd_boot.c index 1bc68ff..da09465 100644 --- a/common/cmd_boot.c +++ b/common/cmd_boot.c @@ -36,6 +36,9 @@ static int read_record (char *buf, ulong len); void do_bdinfo (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) { + int i; + ulong ip = bd->bi_ip_addr; + printf (" memstart = 0x%08lx\n", bd->bi_memstart ); printf (" memsize = 0x%08lx\n", bd->bi_memsize ); printf (" flashstart = 0x%08lx\n", bd->bi_flashstart ); @@ -47,7 +50,16 @@ void do_bdinfo (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) printf (" bootflags = 0x%08lx\n", bd->bi_bootflags ); printf (" intfreq = %6ld MHz\n", bd->bi_intfreq ); printf (" busfreq = %6ld MHz\n", bd->bi_busfreq ); - printf (" baudrate = %6ld bps\n", bd->bi_baudrate ); + printf (" ethaddr ="); + for (i=0; i<6; ++i) { + printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]); + } + printf ("\n IP addr ="); + for (i=0; i<4; ++i) { + printf ("%c%d", i ? '.' : ' ', (ip >> 24) & 0xFF); + ip <<= 8; + } + printf ("\n baudrate = %6ld bps\n", bd->bi_baudrate ); printf (" getc = 0x%08lx\n",(ulong)bd->bi_serial_io.getc); printf (" tstc = 0x%08lx\n",(ulong)bd->bi_serial_io.tstc); printf (" putc = 0x%08lx\n",(ulong)bd->bi_serial_io.putc); diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 63ee6ae..4d70932 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -49,6 +49,7 @@ void do_bootm (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) ulong data, len, checksum; ulong initrd_start, initrd_end; ulong cmd_start, cmd_end; + int verify; char *cmdline; char *name, *s; bd_t *kbd; @@ -61,6 +62,9 @@ void do_bootm (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) return; } + s = getenv ("verify"); + verify = (s && (*s == 'n')) ? 0 : 1; + asc_to_hex(argv[1], &addr); printf ("## Booting Linux kernel at %08lx ...\n", addr); @@ -89,12 +93,14 @@ void do_bootm (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) data = addr + sizeof(image_header_t); len = hdr->ih_size; - printf (" Verifying Checksum ... "); - if (crc32 (0, (char *)data, len) != hdr->ih_dcrc) { - printf ("Bad Data CRC\n"); - return; + if (verify) { + printf (" Verifying Checksum ... "); + if (crc32 (0, (char *)data, len) != hdr->ih_dcrc) { + printf ("Bad Data CRC\n"); + return; + } + printf ("OK\n"); } - printf ("OK\n"); if ((hdr->ih_os != IH_OS_LINUX) || (hdr->ih_arch != IH_CPU_PPC)) { printf ("Unsupported OS or Architecture\n"); @@ -222,12 +228,14 @@ void do_bootm (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) data = addr + sizeof(image_header_t); len = hdr->ih_size; - printf (" Verifying Checksum ... "); - if (crc32 (0, (char *)data, len) != hdr->ih_dcrc) { - printf ("Bad Data CRC\n"); - do_reset (cmdtp, bd, flag, argc, argv); + if (verify) { + printf (" Verifying Checksum ... "); + if (crc32 (0, (char *)data, len) != hdr->ih_dcrc) { + printf ("Bad Data CRC\n"); + do_reset (cmdtp, bd, flag, argc, argv); + } + printf ("OK\n"); } - printf ("OK\n"); if ((hdr->ih_os != IH_OS_LINUX) || (hdr->ih_arch != IH_CPU_PPC) || diff --git a/common/cmd_flash.c b/common/cmd_flash.c index 4fce39f..f5105be 100644 --- a/common/cmd_flash.c +++ b/common/cmd_flash.c @@ -30,6 +30,9 @@ extern flash_info_t flash_info[]; /* info for FLASH chips */ +void flash_sect_erase (ulong addr_first, ulong addr_last); +void flash_sect_protect (int flag, ulong addr_first, ulong addr_last); + /* * The user interface starts numbering for Flash banks with 1. The * main reason is that asc_to_hex() returns 0 for invalid input, so @@ -65,8 +68,6 @@ void do_flerase(cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) { flash_info_t *info; ulong bank, addr_first, addr_last; - int s_first, s_last; - int erased; if (argc < 2) { printf ("Usage:\n%s\n", cmdtp->usage); @@ -108,6 +109,16 @@ void do_flerase(cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) return; } + flash_sect_erase(addr_first, addr_last); +} + +void flash_sect_erase (ulong addr_first, ulong addr_last) +{ + flash_info_t *info; + ulong bank; + int s_first, s_last; + int erased; + erased = 0; for (bank=0,info=&flash_info[0]; bank < CFG_MAX_FLASH_BANKS; ++bank, ++info) { @@ -132,13 +143,9 @@ void do_flerase(cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) if (addr_first == info->start[sect]) { s_first = sect; - if (s_last < 0) - s_last = s_end; } if (addr_last == end) { s_last = sect; - if (s_first < 0) - s_first = 0; } } if (s_first>=0 && s_first<=s_last) { @@ -159,8 +166,6 @@ void do_protect(cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) { flash_info_t *info; ulong bank, addr_first, addr_last; - int s_first, s_last; - int protected; int i; int p; @@ -219,6 +224,16 @@ void do_protect(cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) return; } + flash_sect_protect (p, addr_first, addr_last); +} + +void flash_sect_protect (int p, ulong addr_first, ulong addr_last) +{ + flash_info_t *info; + ulong bank; + int s_first, s_last; + int protected, i; + protected = 0; for (bank=0,info=&flash_info[0]; bank < CFG_MAX_FLASH_BANKS; ++bank, ++info) { @@ -243,13 +258,9 @@ void do_protect(cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) if (addr_first == info->start[sect]) { s_first = sect; - if (s_last < 0) - s_last = s_end; } if (addr_last == end) { s_last = sect; - if (s_first < 0) - s_first = 0; } } if (s_first>=0 && s_first<=s_last) { diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index 9b193dd..f876cca 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -28,12 +28,6 @@ #include #include -/* - * FIXME: - * - * XXX DUMMY IMPLEMENTATION ONLY! XXX - */ - /* * The environment storages is simply a list of '\0'-terminated * "name=value" strings, the end of the list marked by a double '\0'. @@ -42,22 +36,32 @@ * combination of deleting the old and adding the new value. */ -#define CFG_ENVSIZE 1024 -char environment[CFG_ENVSIZE] = { - "bootargs=" "root=/dev/nfs rw " - "nfsroot=10.0.0.2:/LinuxPPC " - "nfsaddrs=10.0.0.98:10.0.0.2" - "\0" - "ethaddr=" "00:D0:93:00:02:6C\0" - "ipaddr=" "10.0.0.98\0" - "verify=" "y\0" -}; +extern uchar environment[]; +extern ulong env_size; + +static uchar *flash_addr = environment; -static char *envmatch (char *, char *); +static uchar *envmatch (uchar *, uchar *); +static void env_init(void); -char *getenv (char *name) +#define XMK_STR(x) #x +#define MK_STR(x) XMK_STR(x) + +static uchar default_environment[] = { + "bootargs=" CONFIG_BOOTARGS "\0" + "bootcmd=" CONFIG_8xx_BOOTCOMMAND "\0" +#if (CONFIG_8xx_BOOTDELAY >= 0) + "bootdelay=" MK_STR(CONFIG_8xx_BOOTDELAY) "\0" +#endif + "baudrate=" MK_STR(CONFIG_8xx_BAUDRATE) "\0" + "\0" +}; + +char *getenv (uchar *name) { - char *env, *nxt; + uchar *env, *nxt; + + env_init(); for (env=environment; *env; env=nxt+1) { char *val; @@ -75,9 +79,11 @@ char *getenv (char *name) void do_printenv (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) { - char *env, *nxt; + uchar *env, *nxt; int i; + env_init(); + if (argc == 1) { /* Print all env variables */ for (env=environment; *env; env=nxt+1) { for (nxt=env; *nxt; ++nxt) @@ -113,9 +119,11 @@ void do_printenv (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) void do_setenv (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) { int i, len; - char *env, *nxt; - char *oldval = NULL; - char *name; + uchar *env, *nxt; + uchar *oldval = NULL; + uchar *name; + + env_init(); if (argc < 2) { printf ("Usage:\n%s\n", cmdtp->usage); @@ -138,6 +146,15 @@ void do_setenv (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) * Delete any existing definition */ if (oldval) { + /* + * Ethernet Address and serial# can be set only once + */ + if ((strcmp (name, "ethaddr") == 0) || + (strcmp (name, "serial#") == 0) ) { + printf ("Can't overwrite \"%s\"\n", name); + return; + } + if (*++nxt == '\0') { *env = '\0'; } else { @@ -160,18 +177,18 @@ void do_setenv (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) */ for (env=environment; *env || *(env+1); ++env) ; - ++env; + if (env > environment) + ++env; /* * Overflow when: - * "name" + "=" + "val" +"\0\0" > CFG_ENVSIZE - (env-environment) + * "name" + "=" + "val" +"\0\0" > env_size - (env-environment) */ len = strlen(name) + 2; /* add '=' for first arg, ' ' for all others */ for (i=2; i (&environment[CFG_ENVSIZE] - env)) { + if (len > (&environment[env_size]-env)) { printf ("## Error: environment overflow, \"%s\" deleted\n", name); return; } @@ -188,9 +205,34 @@ printf ("FREE: %d NEED: %d\n", &environment[CFG_ENVSIZE]-env, len); /* end is marked with double '\0' */ *++env = '\0'; } + void do_saveenv (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) { - printf ("XXX - not yet implemented\n"); + int rc; + extern void flash_sect_protect (int p, ulong addr_first, ulong addr_last); + extern void flash_sect_erase (ulong addr_first, ulong addr_last); + + env_init(); + + flash_sect_protect (0, (ulong)flash_addr, (ulong)flash_addr+env_size-1); + + printf ("Erasing Flash..."); + flash_sect_erase ((ulong)flash_addr, (ulong)flash_addr+env_size-1); + + printf ("Saving Environment to Flash...\n"); + switch (rc = flash_write (environment, (ulong)flash_addr, env_size)) { + case 0: break; + case 1: printf ("Timeout writing to Flash\n"); + break; + case 2: printf ("Flash not Erased\n"); + break; + case 4: printf ("Can't write to protected Flash sectors\n"); + break; + default: + printf ("%s[%d] FIXME: rc=%d\n",__FILE__,__LINE__,rc); + } + + flash_sect_protect (1, (ulong)flash_addr, (ulong)flash_addr+env_size-1); } /* @@ -199,8 +241,8 @@ void do_saveenv (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) * If the names match, return the value of s2, else NULL. */ -static char * -envmatch (char *s1, char *s2) +static uchar * +envmatch (uchar *s1, uchar *s2) { while (*s1 == *s2++) @@ -210,3 +252,16 @@ envmatch (char *s1, char *s2) return(s2); return(NULL); } + +/* + * Prevent confusion if running from erased flash memory + */ +static void env_init(void) +{ + if (environment[0] == 0xFF) { + printf ("*** Warning - no Environment, using defaults\n\n"); + memcpy (environment, + default_environment, + sizeof(default_environment)); + } +} diff --git a/common/command.c b/common/command.c index bd6907b..96181ad 100644 --- a/common/command.c +++ b/common/command.c @@ -37,7 +37,7 @@ /* * HELP command */ -#define CMD_TBL_HELP { \ +#define CMD_TBL_HELP MK_CMD_TBL_ENTRY( \ "help", 1, CFG_MAXARGS, do_help, \ "help - print online help\n", \ "[command ...]\n" \ @@ -45,20 +45,20 @@ "'help' prints online help for the monitor commands.\n\n" \ "Without arguments, it prints a short usage message for all commands.\n\n" \ "To get detailed help information for specific commands you can type\n" \ - "'help' with one or more command names as arguments.\n", \ - } + "'help' with one or more command names as arguments.\n" \ + ) -#define CMD_TBL_QUES { \ +#define CMD_TBL_QUES MK_CMD_TBL_ENTRY( \ "?", 1, CFG_MAXARGS, do_help, \ "? - alias for 'help'\n", \ - NULL, \ - } + NULL \ + ) -#define CMD_TBL_VERS { \ +#define CMD_TBL_VERS MK_CMD_TBL_ENTRY( \ "version", 4, 1, do_version, \ "version - print monitor version\n", \ - NULL, \ - } + NULL \ + ) void do_version (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) @@ -93,6 +93,7 @@ do_help (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) for (i=1; iname; cmdtp++) { if (strncmp(argv[i], cmdtp->name, cmdtp->lmin) == 0) { +#ifdef CFG_LONGHELP /* found - print (long) help info */ serial_putstr (cmdtp->name); serial_putc (' '); @@ -102,6 +103,10 @@ do_help (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) serial_putstr ("- No help available.\n"); } serial_putc ('\n'); +#else /* no long help available */ + if (cmdtp->usage) + serial_putstr (cmdtp->usage); +#endif /* CFG_LONGHELP */ goto done; } } @@ -141,5 +146,5 @@ cmd_tbl_t cmd_tbl[] = { CMD_TBL_HELP, CMD_TBL_QUES, /* the following entry terminates this table */ - { NULL, 0, 0, NULL, NULL, NULL, }, + MK_CMD_TBL_ENTRY( NULL, 0, 0, NULL, NULL, NULL ), }; diff --git a/common/environment.S b/common/environment.S new file mode 100644 index 0000000..3db1276 --- /dev/null +++ b/common/environment.S @@ -0,0 +1,29 @@ +#include + +#define XMK_STR(x) #x +#define MK_STR(x) XMK_STR(x) + + .text + .p2align CFG_FLASH_ENV_ALIGN + .globl environment +environment: + .ascii "bootargs=" + .ascii CONFIG_BOOTARGS + .ascii "\0" + .ascii "bootcmd=" + .ascii CONFIG_8xx_BOOTCOMMAND + .ascii "\0" +#if (CONFIG_8xx_BOOTDELAY >= 0) + .ascii "bootdelay=" + .ascii MK_STR(CONFIG_8xx_BOOTDELAY) + .ascii "\0" +#endif + .ascii "baudrate=" + .ascii MK_STR(CONFIG_8xx_BAUDRATE) + .ascii "\0" + .ascii "\0" + . = environment + CFG_FLASH_ENV_SIZE +.L_end: + .globl env_size +env_size: + .long .L_end - environment diff --git a/common/main.c b/common/main.c index 1bbf755..14514c0 100644 --- a/common/main.c +++ b/common/main.c @@ -43,7 +43,8 @@ void main_loop(bd_t *bd) { cmd_tbl_t *cmdtp; #if (CONFIG_8xx_BOOTDELAY >= 0) - int bootdelay = CONFIG_8xx_BOOTDELAY; + char *s = getenv ("bootdelay"); + int bootdelay = s ? (int)simple_strtoul(s, NULL, 10) : 0; int autoboot = 1; #endif /* CONFIG_8xx_BOOTDELAY */ @@ -90,8 +91,9 @@ void main_loop(bd_t *bd) serial_putc ('\n'); if (autoboot) { + s = getenv("bootcmd"); strncpy (console_buffer, - CONFIG_8xx_BOOTCOMMAND, + s ? s : "", CFG_CBSIZE-1); console_buffer[CFG_CBSIZE-1] = '\0'; /* just in case */ len = strlen (console_buffer); diff --git a/config.mk b/config.mk index de5758b..357405a 100644 --- a/config.mk +++ b/config.mk @@ -27,8 +27,6 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ else if [ -x /bin/bash ]; then echo /bin/bash; \ else echo sh; fi ; fi) -#XXX#HPATH = $(KERNEL)/include -#XXX#CDKHPATH = /LinuxPPC/CDK/lib/gcc-lib/powerpc-linux/2.95.2/include CDK_DIR = /LinuxPPC/CDK CDKHEADERS = -I$(CDK_DIR)/include \ -I$(CDK_DIR)/lib/gcc-lib/powerpc-linux/2.95.2/include @@ -53,8 +51,10 @@ RANLIB = $(CROSS_COMPILE)RANLIB MAKEDEPEND = makedepend -Y RELFLAGS= -mrelocatable -ffixed-r14 -DBGFLAGS= -g -DDEBUG -OPTFLAGS= #-O2 +DBGFLAGS= #-g -DDEBUG +OPTFLAGS= -O2 +#LDSCRIPT := $(BOARD)/ppcboot.lds.debug +LDSCRIPT := $(BOARD)/ppcboot.lds CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS) \ -D__KERNEL__ -D__powerpc__ -DCONFIG_8xx \ @@ -68,7 +68,7 @@ CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS) \ CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes -fomit-frame-pointer AFLAGS := -D__ASSEMBLY__ $(CPPFLAGS) -LDFLAGS += -Bstatic -T include/ppcboot.lds -Ttext $(TEXT_BASE) +LDFLAGS += -Bstatic -T $(LDSCRIPT) -Ttext $(TEXT_BASE) OBJCFLAGS = --remove-section=.stab \ --remove-section=.comment \ diff --git a/examples/Makefile b/examples/Makefile index 1d61cee..773b704 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -47,9 +47,9 @@ distclean: clean ######################################################################### -.depend: Makefile $(OBJS:.o=.c) - $(CC) -M $(CFLAGS) $(OBJS:.o=.c) > $@ - -depend dep: .depend +.depend: Makefile $(OBJS:.o=.c) + $(CC) -M $(CFLAGS) $(OBJS:.o=.c) > $@ sinclude .depend + +######################################################################### diff --git a/include/asm/8xx_immap.h b/include/asm/8xx_immap.h index 0223fe2..4721614 100644 --- a/include/asm/8xx_immap.h +++ b/include/asm/8xx_immap.h @@ -96,19 +96,21 @@ typedef struct mem_ctlr { */ typedef struct sys_int_timers { ushort sit_tbscr; + char res0[0x02]; uint sit_tbreff0; uint sit_tbreff1; char res1[0x14]; ushort sit_rtcsc; + char res2[0x02]; uint sit_rtc; uint sit_rtsec; uint sit_rtcal; - char res2[0x10]; + char res3[0x10]; ushort sit_piscr; - char res3[2]; + char res4[2]; uint sit_pitc; uint sit_pitr; - char res4[0x34]; + char res5[0x34]; } sit8xx_t; #define TBSCR_TBIRQ_MASK ((ushort)0xff00) @@ -174,20 +176,38 @@ typedef struct cark { */ #define KAPWR_KEY ((unsigned int)0x55ccaa33) -/* LCD interface. MPC821 Only. +/* Video interface. MPC823 Only. +*/ +typedef struct vid823 { + ushort vid_vccr; + ushort res1; + u_char vid_vsr; + u_char res2; + u_char vid_vcmr; + u_char res3; + uint vid_vbcb; + uint res4; + uint vid_vfcr0; + uint vid_vfaa0; + uint vid_vfba0; + uint vid_vfcr1; + uint vid_vfaa1; + uint vid_vfba1; + u_char res5[0x18]; +} vid823_t; + +/* LCD interface. 823 Only. */ typedef struct lcd { - ushort lcd_lcolr[16]; - char res[0x20]; uint lcd_lccr; uint lcd_lchcr; uint lcd_lcvcr; - char res2[4]; + char res1[4]; uint lcd_lcfaa; uint lcd_lcfba; char lcd_lcsr; - char res3[0x7]; -} lcd8xx_t; + char res2[0x7]; +} lcd823_t; /* I2C */ @@ -349,22 +369,30 @@ typedef struct fec { uint res9[0x1e]; } fec_t; +/* The FEC and LCD color map share the same address space.... + * I guess we will never see an 823T :-). + */ +union fec_lcd { + fec_t fl_un_fec; + u_char fl_un_cmap[0x200]; +}; + typedef struct comm_proc { /* General control and status registers. */ ushort cp_cpcr; - char res1[2]; + u_char res1[2]; ushort cp_rccr; - char res2[6]; + u_char res2[6]; ushort cp_cpmcr1; ushort cp_cpmcr2; ushort cp_cpmcr3; ushort cp_cpmcr4; - char res3[2]; + u_char res3[2]; ushort cp_rter; - char res4[2]; + u_char res4[2]; ushort cp_rtmr; - char res5[0x14]; + u_char res5[0x14]; /* Baud rate generators. */ @@ -384,52 +412,59 @@ typedef struct comm_proc { /* Serial Peripheral Interface. */ ushort cp_spmode; - char res6[4]; + u_char res6[4]; u_char cp_spie; - char res7[3]; + u_char res7[3]; u_char cp_spim; - char res8[2]; + u_char res8[2]; u_char cp_spcom; - char res9[2]; + u_char res9[2]; /* Parallel Interface Port. */ - char res10[2]; + u_char res10[2]; ushort cp_pipc; - char res11[2]; + u_char res11[2]; ushort cp_ptpr; uint cp_pbdir; uint cp_pbpar; - char res12[2]; + u_char res12[2]; ushort cp_pbodr; uint cp_pbdat; - char res13[0x18]; + u_char res13[0x18]; /* Serial Interface and Time Slot Assignment. */ uint cp_simode; u_char cp_sigmr; - char res14; + u_char res14; u_char cp_sistr; u_char cp_sicmr; - char res15[4]; + u_char res15[4]; uint cp_sicr; uint cp_sirp; - char res16[0x10c]; + u_char res16[0xc]; + + /* 256 bytes of MPC823 video controller RAM array. + */ + u_char cp_vcram[0x100]; u_char cp_siram[0x200]; /* The fast ethernet controller is not really part of the CPM, * but it resides in the address space. + * The LCD color map is also here. */ - fec_t cp_fec; + union fec_lcd fl_un; +#define cp_fec fl_un.fl_un_fec +#define lcd_cmap fl_un.fl_un_cmap char res18[0x1000]; /* Dual Ported RAM follows. * There are many different formats for this memory area * depending upon the devices used and options chosen. + * Some processors don't have all of it populated. */ - u_char cp_dpmem[0x1000]; /* BD / Data / ucode */ - u_char res19[0xc00]; + u_char cp_dpmem[0x1C00]; /* BD / Data / ucode */ u_char cp_dparam[0x400]; /* Parameter RAM */ } cpm8xx_t; @@ -443,7 +478,8 @@ typedef struct immap { car8xx_t im_clkrst; /* Clocks and reset */ sitk8xx_t im_sitk; /* Sys int timer keys */ cark8xx_t im_clkrstk; /* Clocks and reset keys */ - lcd8xx_t im_lcd; /* LCD (821 only) */ + vid823_t im_vid; /* Video (823 only) */ + lcd823_t im_lcd; /* LCD (823 only) */ i2c8xx_t im_i2c; /* I2C control/status */ sdma8xx_t im_sdma; /* SDMA control/status */ cpic8xx_t im_cpic; /* CPM Interrupt Controller */ diff --git a/include/cmd_boot.h b/include/cmd_boot.h index 5fd8e1a..359e5c4 100644 --- a/include/cmd_boot.h +++ b/include/cmd_boot.h @@ -27,37 +27,37 @@ #ifndef _CMD_BOOT_H #define _CMD_BOOT_H -#define CMD_TBL_BDINFO { \ +#define CMD_TBL_BDINFO MK_CMD_TBL_ENTRY( \ "bdinfo", 2, 1, do_bdinfo, \ "bdinfo - print Board Info structure\n", \ - NULL, \ -} + NULL \ +) void do_bdinfo (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]); -#define CMD_TBL_GO { \ +#define CMD_TBL_GO MK_CMD_TBL_ENTRY( \ "go", 2, CFG_MAXARGS, do_go, \ "go - start application at address 'addr'\n", \ "addr [arg ...]\n - start application at address 'addr'\n" \ - " passing 'arg' as arguments\n", \ -} + " passing 'arg' as arguments\n" \ +) void do_go (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]); -#define CMD_TBL_LOADS { \ +#define CMD_TBL_LOADS MK_CMD_TBL_ENTRY( \ "loads", 5, 2, do_load_serial, \ "loads - load S-Record file over serial line\n", \ "[ off ]\n" \ - " - load S-Record file over serial line with offset 'off'\n", \ -} + " - load S-Record file over serial line with offset 'off'\n" \ +) void do_load_serial (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]); -#define CMD_TBL_RESET { \ +#define CMD_TBL_RESET MK_CMD_TBL_ENTRY( \ "reset", 5, 1, do_reset, \ - "reset - Perform RESET of the CPU\n", \ - NULL, \ -} + "reset - Perform RESET of the CPU\n", \ + NULL \ +) void do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]); diff --git a/include/cmd_bootm.h b/include/cmd_bootm.h index a6127ad..e0532c7 100644 --- a/include/cmd_bootm.h +++ b/include/cmd_bootm.h @@ -29,23 +29,23 @@ void do_bootm (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]); -#define CMD_TBL_BOOTM { \ +#define CMD_TBL_BOOTM MK_CMD_TBL_ENTRY( \ "bootm", 3, CFG_MAXARGS, do_bootm, \ "bootm - boot application image from memory\n", \ "addr [arg ...]\n - boot application image stored in memory\n" \ " passing arguments 'arg ...'; when booting a Linux kernel,\n" \ - " 'arg' can be the address of an initrd image\n", \ -} + " 'arg' can be the address of an initrd image\n" \ +) void do_iminfo (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]); -#define CMD_TBL_IMINFO { \ +#define CMD_TBL_IMINFO MK_CMD_TBL_ENTRY( \ "iminfo", 3, CFG_MAXARGS, do_iminfo, \ "iminfo - print header information for application image\n", \ "addr [addr ...]\n" \ " - print header information for application image starting at\n" \ " address 'addr' in memory; this includes verification of the\n" \ - " image contents (magic number, header and payload checksums)\n", \ -} + " image contents (magic number, header and payload checksums)\n" \ +) #endif /* _CMD_BOOTM_H */ diff --git a/include/cmd_cache.h b/include/cmd_cache.h index e33e7ec..0b2879d 100644 --- a/include/cmd_cache.h +++ b/include/cmd_cache.h @@ -27,19 +27,19 @@ #ifndef _CMD_CACHE_H #define _CMD_CACHE_H -#define CMD_TBL_ICACHE { \ +#define CMD_TBL_ICACHE MK_CMD_TBL_ENTRY( \ "icache", 2, 2, do_icache, \ "icache - enable or disable instruction cache\n", \ "[on, off]\n" \ - " - enable or disable instruction cache\n", \ -} + " - enable or disable instruction cache\n" \ +) -#define CMD_TBL_DCACHE { \ +#define CMD_TBL_DCACHE MK_CMD_TBL_ENTRY( \ "dcache", 2, 2, do_dcache, \ "dcache - enable or disable data cache\n", \ "[on, off]\n" \ - " - enable or disable data (writethrough) cache\n", \ -} + " - enable or disable data (writethrough) cache\n" \ +) void do_icache (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]); void do_dcache (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]); diff --git a/include/cmd_flash.h b/include/cmd_flash.h index 8be6c38..b937243 100644 --- a/include/cmd_flash.h +++ b/include/cmd_flash.h @@ -27,23 +27,23 @@ #ifndef _CMD_FLASH_H #define _CMD_FLASH_H -#define CMD_TBL_FLINFO { \ +#define CMD_TBL_FLINFO MK_CMD_TBL_ENTRY( \ "flinfo", 3, 2, do_flinfo, \ "flinfo - print FLASH memory information\n", \ "\n - print information for all FLASH memory banks\n" \ - "flinfo N\n - print information for FLASH memory bank # N\n", \ -} + "flinfo N\n - print information for FLASH memory bank # N\n" \ +) -#define CMD_TBL_FLERASE { \ +#define CMD_TBL_FLERASE MK_CMD_TBL_ENTRY( \ "erase", 3, 3, do_flerase, \ "erase - erase FLASH memory\n", \ "start end\n" \ " - erase FLASH from addr 'start' to addr 'end'\n" \ "erase bank N\n - erase FLASH bank # N\n" \ - "erase all\n - erase all FLASH banks\n", \ -} + "erase all\n - erase all FLASH banks\n" \ +) -#define CMD_TBL_PROTECT { \ +#define CMD_TBL_PROTECT MK_CMD_TBL_ENTRY( \ "protect", 4, 4, do_protect, \ "protect - enable or disable FLASH write protection\n", \ "on start end\n" \ @@ -53,8 +53,8 @@ "protect off start end\n" \ " - make FLASH from addr 'start' to addr 'end' writable\n" \ "protect off bank N\n - make FLASH bank # N writable\n" \ - "protect off all\n - make all FLASH banks writable\n", \ -} + "protect off all\n - make all FLASH banks writable\n" \ +) void do_flinfo (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]); void do_flerase(cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]); diff --git a/include/cmd_mem.h b/include/cmd_mem.h index 8bf916d..4f8756e 100644 --- a/include/cmd_mem.h +++ b/include/cmd_mem.h @@ -27,57 +27,57 @@ #ifndef _CMD_MEM_H #define _CMD_MEM_H -#define CMD_TBL_MD { \ +#define CMD_TBL_MD MK_CMD_TBL_ENTRY( \ "md", 2, 3, do_mem_md, \ "md - memory display\n", \ - "[.b, .w, .l] address [# of objects]\n - memory display\n", \ -} -#define CMD_TBL_MM { \ + "[.b, .w, .l] address [# of objects]\n - memory display\n" \ +) +#define CMD_TBL_MM MK_CMD_TBL_ENTRY( \ "mm", 2, 2, do_mem_mm, \ "mm - memory modify (auto-incrementing)\n", \ "[.b, .w, .l] address\n" \ - " - memory modify, auto increment address\n", \ -} -#define CMD_TBL_NM { \ + " - memory modify, auto increment address\n" \ +) +#define CMD_TBL_NM MK_CMD_TBL_ENTRY( \ "nm", 2, 2, do_mem_nm, \ "nm - memory modify (constant address)\n", \ - "[.b, .w, .l] address\n - memory modify, read and keep address\n", \ -} -#define CMD_TBL_MW { \ + "[.b, .w, .l] address\n - memory modify, read and keep address\n" \ +) +#define CMD_TBL_MW MK_CMD_TBL_ENTRY( \ "mw", 2, 4, do_mem_mw, \ "mw - memory write (fill)\n", \ - "[.b, .w, .l] address value [count]\n - write memory\n", \ -} -#define CMD_TBL_CP { \ + "[.b, .w, .l] address value [count]\n - write memory\n" \ +) +#define CMD_TBL_CP MK_CMD_TBL_ENTRY( \ "cp", 2, 4, do_mem_cp, \ "cp - memory copy\n", \ - "[.b, .w, .l] source target count\n - copy memory\n", \ -} -#define CMD_TBL_CRC { \ + "[.b, .w, .l] source target count\n - copy memory\n" \ +) +#define CMD_TBL_CRC MK_CMD_TBL_ENTRY( \ "crc32", 3, 4, do_mem_crc, \ "crc32 - checksum calculation\n", \ - "address count\n - compute CRC32 checksum\n", \ -} -#define CMD_TBL_BASE { \ + "address count\n - compute CRC32 checksum\n" \ +) +#define CMD_TBL_BASE MK_CMD_TBL_ENTRY( \ "base", 2, 2, do_mem_base, \ "base - print or set address offset\n", \ "\n - print address offset fpr memory commands\n" \ - "base off\n - set address offset for memory commands to 'off'\n", \ -} + "base off\n - set address offset for memory commands to 'off'\n" \ +) /* * Require full name for "loop" and "mtest" because these are infinite loops! */ -#define CMD_TBL_LOOP { \ +#define CMD_TBL_LOOP MK_CMD_TBL_ENTRY( \ "loop", 4, 3, do_mem_loop, \ "loop - infinite loop on address range\n", \ "[.b, .w, .l] address number_of_objects\n" \ - " - loop on a set of addresses\n", \ -} -#define CMD_TBL_MTEST { \ + " - loop on a set of addresses\n" \ +) +#define CMD_TBL_MTEST MK_CMD_TBL_ENTRY( \ "mtest", 5, 1, do_mem_mtest, \ "mtest - simple RAM test\n", \ - "\n - simple SDRAM read/write test\n", \ -} + "\n - simple SDRAM read/write test\n" \ +) void do_mem_md (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]); void do_mem_mm (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]); diff --git a/include/cmd_nvedit.h b/include/cmd_nvedit.h index 2b37eaa..5a0099c 100644 --- a/include/cmd_nvedit.h +++ b/include/cmd_nvedit.h @@ -27,28 +27,28 @@ #ifndef _CMD_NVEDIT_H #define _CMD_NVEDIT_H -#define CMD_TBL_PRINTENV { \ +#define CMD_TBL_PRINTENV MK_CMD_TBL_ENTRY( \ "printenv", 8, CFG_MAXARGS, do_printenv, \ "printenv- print environment variables\n", \ "\n - print values of all environment variables\n" \ "printenv name ...\n" \ - " - print value of environment variable 'name'\n", \ -} + " - print value of environment variable 'name'\n" \ +) -#define CMD_TBL_SETENV { \ +#define CMD_TBL_SETENV MK_CMD_TBL_ENTRY( \ "setenv", 6, CFG_MAXARGS, do_setenv, \ "setenv - set environment variables\n", \ "name value ...\n" \ " - set environment variable 'name' to 'value ...'\n" \ "setenv name\n" \ - " - delete environment variable 'name'\n", \ -} + " - delete environment variable 'name'\n" \ +) -#define CMD_TBL_SAVEENV { \ +#define CMD_TBL_SAVEENV MK_CMD_TBL_ENTRY( \ "saveenv", 4, 1, do_saveenv, \ "saveenv - save environment variables to persistent storage\n", \ - NULL, \ -} + NULL \ +) void do_printenv (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]); void do_setenv (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]); diff --git a/include/command.h b/include/command.h index 311d9d5..9ef4229 100644 --- a/include/command.h +++ b/include/command.h @@ -42,13 +42,25 @@ struct cmd_tbl_s { /* Implementation function */ void (*cmd)(struct cmd_tbl_s *, bd_t *, int, int, char *[]); char *usage; /* Usage message (short) */ +#ifdef CFG_LONGHELP char *help; /* Help message (long) */ +#endif }; typedef struct cmd_tbl_s cmd_tbl_t; extern cmd_tbl_t cmd_tbl[]; +#ifdef CFG_LONGHELP +#define MK_CMD_TBL_ENTRY(name,lmin,maxargs,cmd,usage,help) \ + { name, lmin, maxargs, cmd, usage, help } +#else /* no help info */ +#define MK_CMD_TBL_ENTRY(name,lmin,maxargs,cmd,usage,help) \ + { name, lmin, maxargs, cmd, usage } +#endif + + + /* * Monitor Command * diff --git a/include/config_TQM850L.h b/include/config_TQM850L.h index 1fefb30..de630f3 100644 --- a/include/config_TQM850L.h +++ b/include/config_TQM850L.h @@ -47,13 +47,18 @@ #else #define CONFIG_8xx_BOOTDELAY 5 /* autoboot after 5 seconds */ #endif -#define CONFIG_8xx_BOOTCOMMAND "help" /* autoboot command */ +#define CONFIG_8xx_BOOTCOMMAND "bootm 40020000" /* autoboot command */ + +#define CONFIG_BOOTARGS "root=/dev/nfs rw " \ + "nfsroot=10.0.0.2:/LinuxPPC " \ + "nfsaddrs=10.0.0.99:10.0.0.2" #define CONFIG_DRAM_SPEED (CONFIG_8xx_BUSCLOCK) /* MHz */ /* * Miscellaneous configurable options */ +#define CFG_LONGHELP /* undef to save memory */ #define CFG_PROMPT "=> " /* Monitor Command Prompt */ #define CFG_CBSIZE 256 /* Console I/O Buffer Size */ #define CFG_PBSIZE (CFG_CBSIZE+sizeof(CFG_PROMPT)+16) /* Print Buffer Size */ @@ -80,8 +85,6 @@ #define CFG_SDRAM_BASE 0x00000000 #define CFG_FLASH_BASE 0x40000000 #define CFG_MONITOR_LEN (128 << 10) /* Reserve 128 kB for Monitor */ -#define CFG_HWINFO_LEN 0x0040 /* Length of HW Info Data */ -#define CFG_HWINFO_ADDR (CFG_FLASH_BASE + CFG_MONITOR_LEN - CFG_HWINFO_LEN) #define CFG_MALLOC_LEN (128 << 10) /* Reserve 128 kB for malloc() */ /* @@ -99,6 +102,8 @@ #define CFG_FLASH_ERASE_TOUT 120000 /* Timeout for Flash Erase (in ms) */ #define CFG_FLASH_WRITE_TOUT 500 /* Timeout for Flash Write (in ms) */ +#define CFG_FLASH_ENV_ALIGN 15 /* Bitshift for Environment Sector */ +#define CFG_FLASH_ENV_SIZE 0x4000 /* Total Size of Environment Sector */ /*----------------------------------------------------------------------- * Cache Configuration */ @@ -153,6 +158,22 @@ SCCR_DFNL000 | SCCR_DFNH000 | SCCR_DFLCD000 | \ SCCR_DFALCD00) +/*----------------------------------------------------------------------- + * PCMCIA stuff + *----------------------------------------------------------------------- + * + */ +#define CFG_PCMCIA_MEM_ADDR (0xE0000000) +#define CFG_PCMCIA_MEM_SIZE ( 64 << 20 ) +#define CFG_PCMCIA_DMA_ADDR (0xE4000000) +#define CFG_PCMCIA_DMA_SIZE ( 64 << 20 ) +#define CFG_PCMCIA_ATTRB_ADDR (0xE8000000) +#define CFG_PCMCIA_ATTRB_SIZE ( 64 << 20 ) +#define CFG_PCMCIA_IO_ADDR (0xEC000000) +#define CFG_PCMCIA_IO_SIZE ( 64 << 20 ) + +#define CFG_PCMCIA_INTERRUPT SIU_LEVEL6 + /*----------------------------------------------------------------------- * *----------------------------------------------------------------------- diff --git a/include/mpc8xx.h b/include/mpc8xx.h index 976deae..05918b3 100644 --- a/include/mpc8xx.h +++ b/include/mpc8xx.h @@ -425,6 +425,30 @@ #define TMR_GE 0x0001 /* Gate Enable */ +/*----------------------------------------------------------------------- + * PCMCIA Interface General Control Register 17-12 + */ +#define PCMCIA_GCRX_CXRESET 0x00000040 +#define PCMCIA_GCRX_CXOE 0x00000080 + +#define PCMCIA_VS1(slot) (0x80000000 >> (slot << 4)) +#define PCMCIA_VS2(slot) (0x40000000 >> (slot << 4)) +#define PCMCIA_VS_MASK(slot) (0xc0000000 >> (slot << 4)) +#define PCMCIA_VS_SHIFT(slot) (30 - (slot << 4)) + +#define PCMCIA_WP(slot) (0x20000000 >> (slot << 4)) +#define PCMCIA_CD2(slot) (0x10000000 >> (slot << 4)) +#define PCMCIA_CD1(slot) (0x08000000 >> (slot << 4)) +#define PCMCIA_BVD2(slot) (0x04000000 >> (slot << 4)) +#define PCMCIA_BVD1(slot) (0x02000000 >> (slot << 4)) +#define PCMCIA_RDY(slot) (0x01000000 >> (slot << 4)) +#define PCMCIA_RDY_L(slot) (0x00800000 >> (slot << 4)) +#define PCMCIA_RDY_H(slot) (0x00400000 >> (slot << 4)) +#define PCMCIA_RDY_R(slot) (0x00200000 >> (slot << 4)) +#define PCMCIA_RDY_F(slot) (0x00100000 >> (slot << 4)) +#define PCMCIA_MASK(slot) (0xFFFF0000 >> (slot << 4)) + + #define UPMA 0x00000000 #define UPMB 0x00800000 diff --git a/include/ppcboot.h b/include/ppcboot.h index 46692e7..aee520e 100644 --- a/include/ppcboot.h +++ b/include/ppcboot.h @@ -111,7 +111,7 @@ int checkdram (void); int testdram (void); /* common/cmd_nvedit.c */ -char *getenv (char *); +char *getenv (uchar *); /* board/flash.c */ ulong flash_get_size (vu_long *addr, flash_info_t *info); @@ -168,6 +168,8 @@ int disable_interrupts (void); /* mpc8xx/traps.c */ /* ppc/vsprintf.c */ +unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base); +long simple_strtol(const char *cp,char **endp,unsigned int base); unsigned int asc_to_hex(char *cp, ulong *val); void printf(const char *fmt, ...); void panic(const char *fmt, ...); diff --git a/include/version.h b/include/version.h index 63b70e6..46e730b 100644 --- a/include/version.h +++ b/include/version.h @@ -24,6 +24,6 @@ #ifndef __VERSION_H__ #define __VERSION_H__ -#define PPCBOOT_VERSION "ppcboot 0.4.1" +#define PPCBOOT_VERSION "ppcboot 0.4.2" #endif /* __VERSION_H__ */ diff --git a/mpc8xx/Makefile b/mpc8xx/Makefile index 71b0525..6f7abba 100644 --- a/mpc8xx/Makefile +++ b/mpc8xx/Makefile @@ -23,9 +23,7 @@ include $(TOPDIR)/config.mk -DIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi) -NAME = $(shell basename $(DIR)) -LIB = lib$(NAME).a +LIB = lib$(CPU).a START = start.o OBJS = traps.o serial.o cpu.o speed.o interrupts.o @@ -41,9 +39,11 @@ clean: distclean: clean rm -f $(LIB) core *.bak .depend -.depend: Makefile $(START:.o=.S) $(OBJS:.o=.c) - $(CC) -M $(CFLAGS) $(START:.o=.S) $(OBJS:.o=.c) > $@ +######################################################################### -depend dep: .depend +.depend: Makefile $(START:.o=.S) $(OBJS:.o=.c) + $(CC) -M $(CFLAGS) $(START:.o=.S) $(OBJS:.o=.c) > $@ sinclude .depend + +######################################################################### diff --git a/mpc8xx/cpu.c b/mpc8xx/cpu.c index bdbad05..732901b 100644 --- a/mpc8xx/cpu.c +++ b/mpc8xx/cpu.c @@ -119,6 +119,7 @@ static int check_CPU(long clock, uint pvr, uint immr) case 0x20020001 : printf("PPC823ZTnnZ3"); break; case 0x21000000 : printf("PPC823ZTnnA"); break; case 0x21010000 : printf("PPC823ZTnnB"); m=1; break; + case 0x21010001 : printf("PPC823ZTnnB2"); m=1; break; /* MPC823E */ case 0x24010000 : printf("PPC823EZTnnB2"); m=1; break; diff --git a/mpc8xx/interrupts.c b/mpc8xx/interrupts.c index c1b9ae9..8d68c27 100644 --- a/mpc8xx/interrupts.c +++ b/mpc8xx/interrupts.c @@ -104,8 +104,7 @@ interrupt_init (bd_t *bd) cpm_interrupt_init(); - ((immap_t *)CFG_IMMR)->im_siu_conf.sc_simask |= - (1 << (31-CPM_INTERRUPT)); + ((immap_t *)CFG_IMMR)->im_siu_conf.sc_simask |= (1 << (31-CPM_INTERRUPT)); set_dec (decrementer_count); diff --git a/mpc8xx/serial.c b/mpc8xx/serial.c index ad8ff29..fe84396 100644 --- a/mpc8xx/serial.c +++ b/mpc8xx/serial.c @@ -57,6 +57,8 @@ serial_init() volatile cpm8xx_t *cp = &(im->im_cpm); volatile iop8xx_t *ip = (iop8xx_t *)&(im->im_ioport); uint dpaddr; + char *s = getenv ("baudrate"); + int baudrate = s ? (int)simple_strtoul(s, NULL, 10) : 9600; /* initialize pointers to SMC */ @@ -147,7 +149,7 @@ serial_init() #else cp->cp_brgc2 = /* Console on SMC2 */ #endif - (((((CONFIG_8xx_CPUCLOCK * 1000000)/16) / CONFIG_8xx_BAUDRATE)-1) << 1) + (((((CONFIG_8xx_CPUCLOCK * 1000000)/16) / baudrate)-1) << 1) | CPM_BRG_EN; /* Make the first buffer the only buffer. diff --git a/ppc/Makefile b/ppc/Makefile index 489cd0b..f9d79e2 100644 --- a/ppc/Makefile +++ b/ppc/Makefile @@ -23,9 +23,7 @@ include $(TOPDIR)/config.mk -DIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi) -NAME = $(shell basename $(DIR)) -LIB = lib$(NAME).a +LIB = lib$(ARCH).a AOBJS = ppcstring.o COBJS = ctype.o vsprintf.o extable.o string.o \ @@ -41,9 +39,11 @@ clean: distclean: clean rm -f $(LIB) core *.bak .depend -.depend: Makefile $(AOBJS:.o=.S) $(COBJS:.o=.c) - $(CC) -M $(CFLAGS) $(AOBJS:.o=.S) $(COBJS:.o=.c) > $@ +######################################################################### -depend dep: .depend +.depend: Makefile $(AOBJS:.o=.S) $(COBJS:.o=.c) + $(CC) -M $(CFLAGS) $(AOBJS:.o=.S) $(COBJS:.o=.c) > $@ sinclude .depend + +######################################################################### diff --git a/tools/Makefile b/tools/Makefile index 666a651..b93e798 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -55,9 +55,11 @@ clean: distclean: clean rm -f $(BINS) core *.bak .depend -.depend: Makefile $(OBJS:.o=.c) - $(CC) -M $(CPPFLAGS) -I../include $(OBJS:.o=.c) > $@ +######################################################################### -depend dep: .depend +.depend: Makefile $(OBJS:.o=.c) + $(CC) -M $(CPPFLAGS) -I../include $(OBJS:.o=.c) > $@ sinclude .depend + +######################################################################### diff --git a/tools/mkimage.c b/tools/mkimage.c index 39d0bf4..7a11fd0 100644 --- a/tools/mkimage.c +++ b/tools/mkimage.c @@ -4,8 +4,8 @@ * Wolfgang Denk, wd@denx.de * All rights reserved. * - * $Date: 2000/07/18 08:54:27 $ - * $Revision: 1.1 $ + * $Date: 2000/08/04 12:04:10 $ + * $Revision: 1.2 $ */ #include @@ -205,7 +205,7 @@ NXTARG: ; imagefile = *argv; - if ((ifd = open(imagefile, lflag ? O_RDONLY : O_WRONLY | O_CREAT)) < 0) { + if ((ifd=open(imagefile,lflag ? O_RDONLY : O_WRONLY|O_CREAT|O_TRUNC)) < 0) { fprintf (stderr, "%s: Can't open %s: %s\n", cmdname, imagefile, strerror(errno)); exit (EXIT_FAILURE); diff --git a/tqm8xx/Makefile b/tqm8xx/Makefile index b5fe35e..bb59b52 100644 --- a/tqm8xx/Makefile +++ b/tqm8xx/Makefile @@ -38,9 +38,9 @@ distclean: clean ######################################################################### -.depend: Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c) - $(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@ - -depend dep: .depend - +.depend: Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c) + $(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@ + sinclude .depend + +######################################################################### diff --git a/tqm8xx/flash.c b/tqm8xx/flash.c index 757900b..e1017ac 100644 --- a/tqm8xx/flash.c +++ b/tqm8xx/flash.c @@ -460,7 +460,7 @@ void flash_erase (flash_info_t *info, int s_first, int s_last) addr[0x02AA] = 0x00550055; /* Start erase on unprotected sectors */ - for (sect = s_first; sectprotect[sect] == 0) { /* not protected */ addr = (vu_long*)(info->start[sect]); addr[0] = 0x00300030; @@ -536,7 +536,7 @@ flash_info_t *addr2info (ulong addr) int flash_write (uchar *src, ulong addr, ulong cnt) { int i; - ulong end = addr + cnt; + ulong end = addr + cnt - 1; flash_info_t *info_first = addr2info (addr); flash_info_t *info_last = addr2info (end ); flash_info_t *info; diff --git a/include/ppcboot.lds b/tqm8xx/ppcboot.lds similarity index 90% rename from include/ppcboot.lds rename to tqm8xx/ppcboot.lds index 989d8b5..5c6c841 100644 --- a/include/ppcboot.lds +++ b/tqm8xx/ppcboot.lds @@ -53,6 +53,18 @@ SECTIONS .plt : { *(.plt) } .text : { + /* WARNING - the following is hand-optimized to fit within */ + /* the sector layout of our flash chips! XXX FIXME XXX */ + + mpc8xx/start.o (.text) + common/dlmalloc.o (.text) + ppc/ppcstring.o (.text) + ppc/vsprintf.o (.text) + ppc/crc32.o (.text) + ppc/zlib.o (.text) + + common/environment.o(.text) + *(.text) *(.fixup) *(.got1) diff --git a/tqm8xx/ppcboot.lds.debug b/tqm8xx/ppcboot.lds.debug new file mode 100644 index 0000000..83c7f19 --- /dev/null +++ b/tqm8xx/ppcboot.lds.debug @@ -0,0 +1,131 @@ +/* + * (C) Copyright 2000 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + * + * See file CREDITS for list of people who contributed to this + * project. + * + * 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 program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +OUTPUT_ARCH(powerpc) +SEARCH_DIR(/lib); SEARCH_DIR(/usr/lib); SEARCH_DIR(/usr/local/lib); SEARCH_DIR(/usr/local/powerpc-any-elf/lib); +/* Do we need any of these for elf? + __DYNAMIC = 0; */ +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + . = + SIZEOF_HEADERS; + .interp : { *(.interp) } + .hash : { *(.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .rel.text : { *(.rel.text) } + .rela.text : { *(.rela.text) } + .rel.data : { *(.rel.data) } + .rela.data : { *(.rela.data) } + .rel.rodata : { *(.rel.rodata) } + .rela.rodata : { *(.rela.rodata) } + .rel.got : { *(.rel.got) } + .rela.got : { *(.rela.got) } + .rel.ctors : { *(.rel.ctors) } + .rela.ctors : { *(.rela.ctors) } + .rel.dtors : { *(.rel.dtors) } + .rela.dtors : { *(.rela.dtors) } + .rel.bss : { *(.rel.bss) } + .rela.bss : { *(.rela.bss) } + .rel.plt : { *(.rel.plt) } + .rela.plt : { *(.rela.plt) } + .init : { *(.init) } + .plt : { *(.plt) } + .text : + { + /* WARNING - the following is hand-optimized to fit within */ + /* the sector layout of our flash chips! XXX FIXME XXX */ + + mpc8xx/start.o (.text) + common/dlmalloc.o (.text) + ppc/vsprintf.o (.text) + ppc/crc32.o (.text) + ppc/extable.o (.text) + + common/environment.o(.text) + + *(.text) + *(.fixup) + *(.got1) + } + _etext = .; + PROVIDE (etext = .); + .rodata : + { + *(.rodata) + *(.rodata1) + } + .fini : { *(.fini) } =0 + .ctors : { *(.ctors) } + .dtors : { *(.dtors) } + + /* Read-write section, merged into data segment: */ + . = (. + 0x0FFF) & 0xFFFFF000; + _erotext = .; + PROVIDE (erotext = .); + .reloc : + { + *(.got) + _GOT2_TABLE_ = .; + *(.got2) + _FIXUP_TABLE_ = .; + *(.fixup) + } + __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2; + __fixup_entries = (. - _FIXUP_TABLE_)>>2; + + .data : + { + *(.data) + *(.data1) + *(.sdata) + *(.sdata2) + *(.dynamic) + CONSTRUCTORS + } + _edata = .; + PROVIDE (edata = .); + + __start___ex_table = .; + __ex_table : { *(__ex_table) } + __stop___ex_table = .; + + . = ALIGN(4096); + __init_begin = .; + .text.init : { *(.text.init) } + .data.init : { *(.data.init) } + . = ALIGN(4096); + __init_end = .; + + __bss_start = .; + .bss : + { + *(.sbss) *(.scommon) + *(.dynbss) + *(.bss) + *(COMMON) + } + _end = . ; + PROVIDE (end = .); +} + diff --git a/tqm8xx/tqm8xx.c b/tqm8xx/tqm8xx.c index c526a06..fc334e0 100644 --- a/tqm8xx/tqm8xx.c +++ b/tqm8xx/tqm8xx.c @@ -98,19 +98,19 @@ const uint sdram_table[] = int checkboard (void) { - unsigned char *s = (unsigned char *)CFG_HWINFO_ADDR; + unsigned char *s = getenv("serial#"); unsigned char *e; int l_type; - if (strncmp(s, "TQM8", 4)) { + if (!s || strncmp(s, "TQM8", 4)) { printf ("### No HW ID - assuming TQM8xxL\n"); return (1); } l_type = (*(s+6) == 'L'); - for (e=s; (e-s)