File: make-binary-bitfiles

package info (click to toggle)
dahdi-firmware 2.11.1.0.20170917-3
  • links: PTS, VCS
  • area: non-free-firmware
  • in suites: sid, trixie
  • size: 9,224 kB
  • sloc: ansic: 120,145; perl: 2,395; sh: 973; makefile: 365; xml: 21
file content (73 lines) | stat: -rw-r--r-- 1,700 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
Author: Ben Hutchings <ben@decadent.org.uk>
Description: Add makefw -b option to enable binary output
Bug-Debian: http://bugs.debian.org/699104

We can't compile these bitfiles into the drivers in the free
dahdi-source package.  Add the -b option to write a binary
instead of a C array.

---
--- a/drivers/dahdi/makefw.c
+++ b/drivers/dahdi/makefw.c
@@ -1,6 +1,7 @@
 /* Xilinx firmware convertor program.
  *
  * Written by Jim Dixon <jim@lambdatel.com>.
+ * Binary output adde by Ben Hutchings <ben@decadent.org.uk>.
  *
  * Copyright (C) 2001 Jim Dixon / Zapata Telephony.
  * Copyright (C) 2001-2008 Digium, Inc.
@@ -34,10 +35,12 @@ FILE *fp;
 int i,j,nbytes;
 unsigned char c;
 char	buf[300];
+int bin;
 
 	if (argc < 3)
 	   {
 		puts("Usage... makefw  filename.rbt  array_name");
+		puts("         makefw  filename.rbt  -b");
 		exit(1);
 	   }	
 
@@ -47,8 +50,10 @@ char	buf[300];
 		perror("bit file open");
 		exit(1);
 	   }
+	bin = !strcmp(argv[2], "-b");
 	nbytes = 0;
-	printf("static unsigned char %s[] = {\n",argv[2]);
+	if (!bin)
+		printf("static unsigned char %s[] = {\n",argv[2]);
 	i = 0;
 	while(fgets(buf,sizeof(buf) - 1,fp))
 	   {
@@ -66,17 +71,22 @@ char	buf[300];
 			if ((j & 7) == 7)
 			   {
 				nbytes++;
-				if (i) printf(",");				
-				printf("0x%02x",c);
-				if (i++ == SWATH) {
-					printf(",\n");
-					i = 0;
+				if (bin) {
+					putchar(c);
+				} else {
+					if (i) printf(",");
+					printf("0x%02x",c);
+					if (i++ == SWATH) {
+						printf(",\n");
+						i = 0;
+					}
 				}
 				c = 0;
 			   }
 		   }
 	   }
-	printf("\n};\n\n");
+	if (!bin)
+		printf("\n};\n\n");
 	fprintf(stderr,"Loaded %d bytes from file\n",nbytes);
 	fclose(fp);
 	exit(0);