"Carr, Bill" <[EMAIL PROTECTED]> writes: > Hello all, > > I have done some further investigation and I thought I'd bring you all up to > date. > > First in answer to a comment that Jeremy made: > > >>> > Note that aboot/SRM console gives me problems with > >>> > fpu instructions - i suspect pal code problems. > > Yes, there is a pal code problem. According to the Alpha architecture > manual, an opDEC instruction fault should return the PC of the instruction > AFTER the fault (since MILO works just fine, I have to conclude that it is > doing the right thing). However, the latest available Digital SRM (version > 038) returns the PC AT the opDEC fault. So the following patch seems to > overcome the problem: > (NOTE: I would like to put in code to detect which pal code is running so > that the code could automatically update the PC in the case of the latest > (defective) Digital SRM pal. Suggestions welcome!) alpha_uses_srm is the variable to test. Though I really think linux should always load the appropriate palcode and then this wouldn't be an issue. > ============== > diff -Nau arch/alpha/kernel/traps.c > ../linux-2.2.17-multia-kgdb/arch/alpha/kernel > --- arch/alpha/kernel/traps.c Fri Jan 12 04:31:34 2001 > +++ ../linux-2.2.17-multia-kgdb/arch/alpha/kernel/traps.c Tue Dec 19 > 18:19:02 2000 > @@ -449,6 +449,9 @@ > > case 4: /* opDEC */ > if (implver() == IMPLVER_EV4) { > +#if 1 /* alpha SRM */ > + regs.pc += 4; > +#endif /* alpha SRM */ > /* EV4 does not implement anything except normal > rounding. Everything else will come here as > an illegal instruction. Emulate them. */ > > ============================= > > OK, on to the Multia flash burning topic. I have downloaded the MILO-2.2-17 > kit. I had to make some minor tweeks to get it to build, but I have > successfully gotten MILO to boot from the failsafe floppy as documented in > the MILO-HOWTO. Further, I have gotten the FMU to identify that there are > indeed 3 x Intel 27F020 flash devices, so the NoName code can correctly > address the flash chips for identification. However, it appears that the > NoName code wants to update flash roms 2 and 3, when on the Multia they are > roms 0,1, and 2. Hmm. If the device is an Intel 28F020 then I can find docs for it an intel's web site. > I was thinking of changing the code to burn flash 0, but I was way out of my > depth and in my past midnight delirium, I did not want to do irreparable > damage. I do know that I can restore the flash to the 038 SRM as long as I > have not fried (as opposed to burned) anything. Cool so you have a recover mechanism. Is this something implemented in your SROM? > I thought I would avail myself of your collective wisdom before proceeding. My goal and I'm about half way there is to update the mtd drivers so they can write to my flash chip, from linux. This should allow me to verify I've actually written the write thing. I have my chip socketed though so even if I do mess up I won't have a dead alpha :) > > Regarding Jeremy's comment about what to write INTO the chip, we have a copy > of the SRM image from which we could decode the "board specific header". It isn't board specific. The documentation is actually in flash/romhead.h from milo-2.2-17 The format matches the comments in the SROM source for the ds10 so we should be in good shape there. > However, if the rom should be laid out in a specific ROM-fs format as > Jeremy's suspects, decoding the entire 500k SRM image is a challenge I'm > not prepared to tackle. There is no ROM-fs format. Instead what there are 64k sectors of rom that can be burned independantly. By looking for different images in the flash you can attribute different rom sectors to different things. So in practice it isn't far from a fs but it isn't realy one. I hacked flash/eb.c from milo to read from a file to see what was going on. And pointed it at a copy of my rom dumped to a file. > > As to Eric's comment: > >>I actually have the source to a SROM. And the license on it looks like I > can redistribute it, but I'll have to double check. I can >>definentily get > you the the format that is used by the firmware. > > What is the status of the source to the SROM, and are SROM codes > sufficiently similar that they would apply to the Multia? Except for little architeture things unless you have a 264 based alpha it would probably be useless. As to the copyright yes it does say you can copy it. The supporting files for the SROM have some restrictions with respect to alpha hardware that I'm not certain about. It's all for the evaluation board software development kit.... Most of the usefull is stuff is already in milo so I'm not going to worry too much. Eric
/***************************************************************************** Copyright © 1995, 1996 Digital Equipment Corporation, Maynard, Massachusetts. All Rights Reserved Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the copyright notice and this permission notice appear in all copies of software and supporting documentation, and that the name of Digital not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. Digital grants this permission provided that you prominently mark, as not part of the original, any modifications made to this software or documentation. Digital Equipment Corporation disclaims all warranties and/or guarantees with regard to this software, including all implied warranties of fitness for a particular purpose and merchantability, and makes no representations regarding the use of, or the results of the use of, the software and documentation in terms of correctness, accuracy, reliability, currentness or otherwise; and you rely on the software, documentation and results solely at your own risk. ******************************************************************************/ /* * Evaluation board flash updating code. * * [EMAIL PROTECTED] */ #include <stdio.h> #include <stdarg.h> #include <stddef.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <sys/mman.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include "romhead.h" #define FLASH_SIZE (1024*1024*2) /* 2MB */ #define FLASH_BLOCK_SIZE (64*1024) #define FLASH_BLOCKS (FLASH_SIZE/FLASH_BLOCK_SIZE) #define TRUE 1 #define FALSE 0 static char *flash_file; #define ENVIRON_ID "MILO Environment" #if 1 int yes_no(char *string) { return 1; } void delete_flash_block(int blockno) { } #endif static char *flash_file_name = "ds10.bin"; static int file_flash_init(void) { int fd; void *addr; fd = open(flash_file_name, O_RDONLY); if (fd < 0) { fprintf(stderr, "Couldn't open %s %s\n", flash_file_name, strerror(errno)); return 0; } addr = mmap(0, FLASH_SIZE, PROT_READ, MAP_SHARED, fd, 0); if (addr == ((void *) -1)) { fprintf(stderr, "Couldn't mmap rom from %s %s\n", flash_file_name, strerror(errno)); return 0; } flash_file = addr; return 1; } static unsigned char read_flash_byte(unsigned offset) { return flash_file[offset]; } static int write_flash_byte(unsigned value, unsigned offset) { } static int eb_init(void); static void eb_list(void); static void eb_program(void); static void eb_delete_image(char *image); static void eb_delete_block(int blockno); static void eb_env(int blockno); #if 0 flash_t Flash = { "Evaluation Board", eb_init, eb_program, eb_list, eb_env, eb_delete_block, eb_delete_image, }; #endif static char *blocks = NULL; #define BLOCK_IN_USE(n) (blocks[n] != ((char) -1)) /* * The evaluation boards with flash (EB66+, AlphaPC64, EB164) * all follow the following layout of their 16 block flash... * * Block 0 - 2 Debug Monitor * Block 3 - 7 ARC NT Firmware * Block 8 - 13 SRM Console Firmware * Block 14 SRM Environment * Block 15 NT Environment */ /* * Image types are: * * 0 - dbm * 1 - NT * 2/3 - SRM console * 7 - Milo/Linux * */ static char *names[8] = { "Alpha Evaluation Board Debug Monitor", "Windows NT ARC", "VMS", "Digital Unix", "Unknown", "Unknown", "Unknown", "Milo/Linux", }; extern unsigned char flash_image[]; extern unsigned int flash_image_size; extern int yes_no(char *string); static void print_user(int id) { switch (id) { case 0: printf("DBM"); break; case 1: printf("WNT"); break; case 2: case 3: printf("SRM"); break; case 7: printf("MILO"); break; case -1: printf("U"); break; default: printf("%d",id); break; } printf(" "); } static int valid_flash_header(romheader_t * header); static void read_flash_header(romheader_t * header, int offset); /* look for an image more than one block long */ static int find_image(int imageno) { int i; romheader_t header; for (i = 0; i < FLASH_BLOCKS; i++) { if (blocks[i] == imageno) { if (i == FLASH_BLOCKS - 1) return -1; read_flash_header(&header, i * FLASH_BLOCK_SIZE); if (valid_flash_header(&header)) return i; } } return -1; } static int valid_flash_header(romheader_t * header) { if ((header->romh.V0.signature == ROM_H_SIGNATURE) && (header->romh.V0.csignature == (unsigned int) ~ROM_H_SIGNATURE)) return TRUE; else return FALSE; } static void read_flash_header(romheader_t * header, int offset) { unsigned char *buffer = (unsigned char *) header; int j; for (j = 0; j < sizeof(romheader_t); j++) { buffer[j] = read_flash_byte(offset + j); } } static void print_flash_header(romheader_t * header) { printf(" Firmware Id: %2d (%s)\n", header->romh.V1.fw_id, names[header->romh.V1.fw_id & 7]); printf(" Image size is %d bytes (%d blocks)\n", header->romh.V1.rimage_size, ((header->romh.V1.rimage_size + header->romh.V0.hsize) / FLASH_BLOCK_SIZE) + 1); printf(" Executing at 0x%x\n", header->romh.V0.destination.low); } /* find the stuff */ static int find_nvram() { int block, i, offset; unsigned char buffer[80]; char *id = ENVIRON_ID; offset = 0; for (block = 0; block < FLASH_BLOCKS; block++) { for (i = 0; i < strlen(id); i++) { buffer[i] = read_flash_byte(offset + i); } if (strncmp(buffer, id, strlen(id)) == 0) return block; offset += FLASH_BLOCK_SIZE; } return -1; } static void scan_blocks(void) { int blockno; romheader_t header; int size; int i; printf("Scanning Flash blocks for usage\n"); /* assume the worst */ for (blockno = 0; blockno < FLASH_BLOCKS; blockno++) blocks[blockno] = (char) -1; /* look at every block in turn, trying to find a header. */ for (blockno = 0; blockno < FLASH_BLOCKS; blockno++) { read_flash_header(&header, blockno * FLASH_BLOCK_SIZE); if (valid_flash_header(&header) == TRUE) { size = ((header. romh.V1.rimage_size + header.romh.V0.hsize) / FLASH_BLOCK_SIZE) + 1; for (i = blockno; i < (blockno + size); i++) blocks[i] = header.romh.V1.fw_id; } } /* depending on what's there, some blocks are not free */ blockno = find_image(1); /* windows NT */ if (blockno >= 0) blocks[15] = 1; blockno = find_image(2); /* VMS */ if (blockno >= 0) blocks[14] = 2; blockno = find_image(3); /* Digital Unix */ if (blockno >= 0) blocks[14] = 3; i = find_nvram(); if (i > 0) blocks[i] = 7; } /* ---------- F L A S H --- S U P P O R T --- R O U T I N E S ----------------*/ static void eb_delete_block(int blockno) { if ((blockno < 0) || (blockno >= FLASH_BLOCKS)) { printf("ERROR: invalid block number\n"); return; } if (blocks[blockno] == 0) { printf("ERROR: you cannot delete the Debug Monitor\n"); return; } if (!yes_no("Do you really want to do this (y/N)? ")) { return; } printf("%d[D]", blockno); delete_flash_block(blockno); printf("\n"); scan_blocks(); } static void eb_delete_image(char *image) { int imageno = -1; int blockno; if (strcmp(image, "dbm") == 0) imageno = 0; if (strcmp(image, "wnt") == 0) imageno = 1; if (strcmp(image, "milo") == 0) imageno = 7; if (imageno < 0) imageno = atoi(image); if (imageno == 0) { printf ("ERROR: you cannot delete the Debug Monitor image\n"); return; } blockno = find_image(imageno); if (blockno < 0) { printf("ERROR: no such image\n"); return; } if (!yes_no("Do you really want to do this (y/N)? ")) { return; } for (blockno = blockno; blockno < FLASH_BLOCKS; blockno++) { if (blocks[blockno] == imageno) { printf("%d[D] ", blockno); delete_flash_block(blockno); } else break; } printf("\n"); scan_blocks(); } #if 0 static void eb_program(void) { int blockno, image_blocks, i, j, flash_offset, image_offset; romheader_t *header = (romheader_t *) flash_image; int status; /* check for a valid image */ if (!valid_flash_header(header)) { printf("ERROR: invalid flash image\n"); return; } /* print out the header */ printf("Image is:\n"); print_flash_header(header); /* is there an existing image? */ blockno = find_image(header->romh.V1.fw_id); if (blockno >= 0) { printf("Found existing image at block %d\n", blockno); if (!yes_no("Overwrite existing image? (N/y)? ")) blockno = -1; else { for (i = 0; i < FLASH_BLOCKS; i++) { if (blocks[i] == header->romh.V1.fw_id) blocks[i] = (char) -1; } } } if (blockno < 0) { char ibuff[20]; printf("Please enter block number "); kbd_gets(ibuff, 20); blockno = atoi(ibuff); if ((blockno < 0) || (blockno > (FLASH_BLOCKS - 1))) { printf("ERROR: invalid block number\n"); return; } } /* check to see if there's room for this image */ image_blocks = ((header->romh.V1.rimage_size + header->romh.V0.hsize) / FLASH_BLOCK_SIZE) + 1; if ((blockno + image_blocks) > FLASH_BLOCKS) { printf("ERROR: not enough room for the image\n"); scan_blocks(); return; } /* check to see if the image would overwrite another image */ for (i = blockno; i < (blockno + image_blocks); i++) { if BLOCK_IN_USE (i) { printf ("ERROR: this would overwrite another image\n"); return; } } /* does the user _really_ want to do this? */ if (!yes_no("Do you really want to do this (y/N)? ")) { scan_blocks(); return; } /* program the image a flash block at a time */ printf("Programming image into flash\n"); image_offset = 0; for (i = blockno; i < (blockno + image_blocks); i++) { /* first delete the block */ printf("%d [D]", i); delete_flash_block(i); blocks[i] = (char) -1; /* now program it */ printf("[P]"); flash_offset = i * FLASH_BLOCK_SIZE; for (j = 0; j < FLASH_BLOCK_SIZE; j++) { status = write_flash_byte(flash_image[image_offset], flash_offset); if (!status) { printf ("\nERROR: writing flash at offset %d\n", flash_offset); scan_blocks(); return; } if (read_flash_byte(flash_offset) != flash_image[image_offset]) { printf ("ERROR: read byte (0x%x) does not match written byte (0x%x)\n", read_flash_byte(flash_offset), flash_image[image_offset]); printf(" at offset %d into the image\n", image_offset); return; } image_offset++; flash_offset++; } /* move on the variables */ printf(" "); } printf("\n"); /* scan again */ scan_blocks(); } #endif static void eb_list(void) { int block; int imageno; romheader_t header; printf("Flash blocks: "); for (block = 0; block < FLASH_BLOCKS; block++) { printf("%2d:", block); print_user(blocks[block]); } printf("\n"); printf("Listing flash Images\n"); for (imageno = 0; imageno < 31; imageno++) { block = find_image(imageno); if (block >= 0) { printf(" Flash image starting at block %d:\n", block); read_flash_header(&header, block * FLASH_BLOCK_SIZE); print_flash_header(&header); } } } static void create_environment(int i) { int offset; int status; char *marker = ENVIRON_ID; int j; /* try and find somewhere to put the environment variables */ printf("Using block %d for environment variables\n", i); delete_flash_block(i); offset = i * FLASH_BLOCK_SIZE; for (j = 0; j < strlen(marker); j++) { status = write_flash_byte(marker[j], offset); if (!status) { printf("ERROR: writing environment block\n"); scan_blocks(); return; } offset++; } blocks[i] = 7; } static void eb_env(int blockno) { int i; /* valid block number? */ if ((blockno < 0) || (blockno >= FLASH_BLOCKS)) { printf("ERROR: invalid block number\n"); return; } /* find the current nvram block, if there is one */ i = find_nvram(); if (i >= 0) { printf ("Block %d already contains the environment variables\n", i); return; } /* already in use? */ if BLOCK_IN_USE (blockno) { printf("ERROR: that block is already in use\n"); return; } /* make an environment block */ create_environment(blockno); } static int eb_init(void) { int status; int block; status = file_flash_init(); if (status) { /* scan the flash blocks for images */ blocks = (char *) malloc(FLASH_BLOCKS*sizeof(blocks[0])); scan_blocks(); /* look for some environment variables */ block = find_nvram(); if (block >= 0) { printf ("Block %d contains the environment variables\n", block); blocks[block] = 7; } } return status; } int main(int argc, char**argv) { if (argc > 1) { flash_file_name = argv[1]; } eb_init(); eb_list(); }