From 842ffabbf35cc608961429a0f3c96d8dde6b22ad Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Tue, 6 Jan 2009 14:42:52 -0800 Subject: make firmware/dsp56k/bootstrap.asm buildable on a56 Make firmware/dsp56k/bootstrap.asm buildable on a56, the free Motorola DSP56001 assembler (http://www.zdomain.com/a56.html). Summary of changes: - Remove '<' and '>' candy (they specify explicit addressing modes, which a56 don't grok, but uses implicitly anyway). - Replace 'move' with 'movem' when accessing program memory. - Rename a few labels to avoid duplicates (which a56 can't handle). Signed-off-by: Robert Millan Cc: Jaswinder Singh Cc: David Woodhouse Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- firmware/dsp56k/bootstrap.asm | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'firmware') diff --git a/firmware/dsp56k/bootstrap.asm b/firmware/dsp56k/bootstrap.asm index 10d8919..a411047 100644 --- a/firmware/dsp56k/bootstrap.asm +++ b/firmware/dsp56k/bootstrap.asm @@ -51,19 +51,19 @@ start jmp <$40 ; Copy DSP program control move #real,r0 move #upload,r1 - do #upload_end-upload,<_copy - move P:(r0)+,x0 - move x0,P:(r1)+ -_copy movep #>4,X:<$c00,X:<1,X:<0,X:< Date: Wed, 7 Jan 2009 20:52:43 +0100 Subject: fix modules_install via NFS Rafael reported: I get the following error from 'make modules_install' on my test boxes: HOSTCC firmware/ihex2fw /home/rafael/src/linux-2.6/firmware/ihex2fw.c:268: fatal error: opening dependency file firmware/.ihex2fw.d: Read-only file system compilation terminated. make[3]: *** [firmware/ihex2fw] Error 1 make[2]: *** [_modinst_post] Error 2 make[1]: *** [sub-make] Error 2 make: *** [all] Error 2 where the configuration is that the kernel is compiled on a build box with 'make O= -j5' and then is mounted over NFS read-only by each test box (full path to this directory is the same on the build box and on the test boxes). Then, I cd into , run 'make modules_install' and get the error above. The issue turns out to be that we when we install firmware pick up the list of firmware blobs from firmware/Makefile. And this triggers the Makefile rules to update ihex2fw. There were two solutions for this issue: 1) Move the list of firmware blobs to a separate file 2) Avoid ihex2fw rebuild by moving it to scripts As I seriously beleive that the list of firmware blobs should be done in a fundamental different way solution 2) was selected. Reported-and-tested-by: "Rafael J. Wysocki" Signed-off-by: Sam Ravnborg Cc: David Woodhouse --- firmware/.gitignore | 1 - firmware/Makefile | 10 +- firmware/ihex2fw.c | 268 ---------------------------------------------------- 3 files changed, 4 insertions(+), 275 deletions(-) delete mode 100644 firmware/ihex2fw.c (limited to 'firmware') diff --git a/firmware/.gitignore b/firmware/.gitignore index d9c6901..f89a21f 100644 --- a/firmware/.gitignore +++ b/firmware/.gitignore @@ -3,4 +3,3 @@ *.bin *.csp *.dsp -ihex2fw diff --git a/firmware/Makefile b/firmware/Makefile index d872b79..55d3082 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -99,10 +99,10 @@ quiet_cmd_ihex = IHEX $@ cmd_ihex = $(OBJCOPY) -Iihex -Obinary $< $@ quiet_cmd_ihex2fw = IHEX2FW $@ - cmd_ihex2fw = $(objtree)/$(obj)/ihex2fw $< $@ + cmd_ihex2fw = $(objtree)/scripts/ihex2fw $< $@ quiet_cmd_h16tofw = H16TOFW $@ - cmd_h16tofw = $(objtree)/$(obj)/ihex2fw -w $< $@ + cmd_h16tofw = $(objtree)/scripts/ihex2fw -w $< $@ quiet_cmd_fwbin = MK_FW $@ cmd_fwbin = FWNAME="$(patsubst firmware/%.gen.S,%,$@)"; \ @@ -165,11 +165,11 @@ $(obj)/%: $(obj)/%.ihex | $(objtree)/$(obj)/$$(dir %) # is actually meaningful, because the firmware has to be loaded in a certain # order rather than as a single binary blob. Thus, we convert them into our # more compact binary representation of ihex records () -$(obj)/%.fw: $(obj)/%.HEX $(obj)/ihex2fw | $(objtree)/$(obj)/$$(dir %) +$(obj)/%.fw: $(obj)/%.HEX | $(objtree)/$(obj)/$$(dir %) $(call cmd,ihex2fw) # .H16 is our own modified form of Intel HEX, with 16-bit length for records. -$(obj)/%.fw: $(obj)/%.H16 $(obj)/ihex2fw | $(objtree)/$(obj)/$$(dir %) +$(obj)/%.fw: $(obj)/%.H16 | $(objtree)/$(obj)/$$(dir %) $(call cmd,h16tofw) $(firmware-dirs): @@ -186,5 +186,3 @@ targets := $(fw-shipped-) $(patsubst $(obj)/%,%, \ # Without this, built-in.o won't be created when it's empty, and the # final vmlinux link will fail. obj-n := dummy - -hostprogs-y := ihex2fw diff --git a/firmware/ihex2fw.c b/firmware/ihex2fw.c deleted file mode 100644 index 8f7fdaa9..0000000 --- a/firmware/ihex2fw.c +++ /dev/null @@ -1,268 +0,0 @@ -/* - * Parser/loader for IHEX formatted data. - * - * Copyright © 2008 David Woodhouse - * Copyright © 2005 Jan Harkes - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#define _GNU_SOURCE -#include - - -struct ihex_binrec { - struct ihex_binrec *next; /* not part of the real data structure */ - uint32_t addr; - uint16_t len; - uint8_t data[]; -}; - -/** - * nybble/hex are little helpers to parse hexadecimal numbers to a byte value - **/ -static uint8_t nybble(const uint8_t n) -{ - if (n >= '0' && n <= '9') return n - '0'; - else if (n >= 'A' && n <= 'F') return n - ('A' - 10); - else if (n >= 'a' && n <= 'f') return n - ('a' - 10); - return 0; -} - -static uint8_t hex(const uint8_t *data, uint8_t *crc) -{ - uint8_t val = (nybble(data[0]) << 4) | nybble(data[1]); - *crc += val; - return val; -} - -static int process_ihex(uint8_t *data, ssize_t size); -static void file_record(struct ihex_binrec *record); -static int output_records(int outfd); - -static int sort_records = 0; -static int wide_records = 0; - -int usage(void) -{ - fprintf(stderr, "ihex2fw: Convert ihex files into binary " - "representation for use by Linux kernel\n"); - fprintf(stderr, "usage: ihex2fw [] \n"); - fprintf(stderr, " -w: wide records (16-bit length)\n"); - fprintf(stderr, " -s: sort records by address\n"); - return 1; -} - -int main(int argc, char **argv) -{ - int infd, outfd; - struct stat st; - uint8_t *data; - int opt; - - while ((opt = getopt(argc, argv, "ws")) != -1) { - switch (opt) { - case 'w': - wide_records = 1; - break; - case 's': - sort_records = 1; - break; - default: - return usage(); - } - } - - if (optind + 2 != argc) - return usage(); - - if (!strcmp(argv[optind], "-")) - infd = 0; - else - infd = open(argv[optind], O_RDONLY); - if (infd == -1) { - fprintf(stderr, "Failed to open source file: %s", - strerror(errno)); - return usage(); - } - if (fstat(infd, &st)) { - perror("stat"); - return 1; - } - data = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, infd, 0); - if (data == MAP_FAILED) { - perror("mmap"); - return 1; - } - - if (!strcmp(argv[optind+1], "-")) - outfd = 1; - else - outfd = open(argv[optind+1], O_TRUNC|O_CREAT|O_WRONLY, 0644); - if (outfd == -1) { - fprintf(stderr, "Failed to open destination file: %s", - strerror(errno)); - return usage(); - } - if (process_ihex(data, st.st_size)) - return 1; - - output_records(outfd); - return 0; -} - -static int process_ihex(uint8_t *data, ssize_t size) -{ - struct ihex_binrec *record; - uint32_t offset = 0; - uint8_t type, crc = 0, crcbyte = 0; - int i, j; - int line = 1; - int len; - - i = 0; -next_record: - /* search for the start of record character */ - while (i < size) { - if (data[i] == '\n') line++; - if (data[i++] == ':') break; - } - - /* Minimum record length would be about 10 characters */ - if (i + 10 > size) { - fprintf(stderr, "Can't find valid record at line %d\n", line); - return -EINVAL; - } - - len = hex(data + i, &crc); i += 2; - if (wide_records) { - len <<= 8; - len += hex(data + i, &crc); i += 2; - } - record = malloc((sizeof (*record) + len + 3) & ~3); - if (!record) { - fprintf(stderr, "out of memory for records\n"); - return -ENOMEM; - } - memset(record, 0, (sizeof(*record) + len + 3) & ~3); - record->len = len; - - /* now check if we have enough data to read everything */ - if (i + 8 + (record->len * 2) > size) { - fprintf(stderr, "Not enough data to read complete record at line %d\n", - line); - return -EINVAL; - } - - record->addr = hex(data + i, &crc) << 8; i += 2; - record->addr |= hex(data + i, &crc); i += 2; - type = hex(data + i, &crc); i += 2; - - for (j = 0; j < record->len; j++, i += 2) - record->data[j] = hex(data + i, &crc); - - /* check CRC */ - crcbyte = hex(data + i, &crc); i += 2; - if (crc != 0) { - fprintf(stderr, "CRC failure at line %d: got 0x%X, expected 0x%X\n", - line, crcbyte, (unsigned char)(crcbyte-crc)); - return -EINVAL; - } - - /* Done reading the record */ - switch (type) { - case 0: - /* old style EOF record? */ - if (!record->len) - break; - - record->addr += offset; - file_record(record); - goto next_record; - - case 1: /* End-Of-File Record */ - if (record->addr || record->len) { - fprintf(stderr, "Bad EOF record (type 01) format at line %d", - line); - return -EINVAL; - } - break; - - case 2: /* Extended Segment Address Record (HEX86) */ - case 4: /* Extended Linear Address Record (HEX386) */ - if (record->addr || record->len != 2) { - fprintf(stderr, "Bad HEX86/HEX386 record (type %02X) at line %d\n", - type, line); - return -EINVAL; - } - - /* We shouldn't really be using the offset for HEX86 because - * the wraparound case is specified quite differently. */ - offset = record->data[0] << 8 | record->data[1]; - offset <<= (type == 2 ? 4 : 16); - goto next_record; - - case 3: /* Start Segment Address Record */ - case 5: /* Start Linear Address Record */ - if (record->addr || record->len != 4) { - fprintf(stderr, "Bad Start Address record (type %02X) at line %d\n", - type, line); - return -EINVAL; - } - - /* These records contain the CS/IP or EIP where execution - * starts. Don't really know what to do with them. */ - goto next_record; - - default: - fprintf(stderr, "Unknown record (type %02X)\n", type); - return -EINVAL; - } - - return 0; -} - -static struct ihex_binrec *records; - -static void file_record(struct ihex_binrec *record) -{ - struct ihex_binrec **p = &records; - - while ((*p) && (!sort_records || (*p)->addr < record->addr)) - p = &((*p)->next); - - record->next = *p; - *p = record; -} - -static int output_records(int outfd) -{ - unsigned char zeroes[6] = {0, 0, 0, 0, 0, 0}; - struct ihex_binrec *p = records; - - while (p) { - uint16_t writelen = (p->len + 9) & ~3; - - p->addr = htonl(p->addr); - p->len = htons(p->len); - write(outfd, &p->addr, writelen); - p = p->next; - } - /* EOF record is zero length, since we don't bother to represent - the type field in the binary version */ - write(outfd, zeroes, 6); - return 0; -} -- cgit v1.1