chiark / gitweb /
id location stuff done by Makefiles
authorian <ian>
Fri, 28 Jan 2005 01:39:40 +0000 (01:39 +0000)
committerian <ian>
Fri, 28 Jan 2005 01:39:40 +0000 (01:39 +0000)
cebpic/.cvsignore
cebpic/Makefile
cebpic/README.protocol
cebpic/make-idlocs [new file with mode: 0755]
pic.make

index 6bb7294cdaf18c6d21306e6b36c6500bec521a17..243b0c33664c7f1ec821f7e45463982bb397b8a5 100644 (file)
@@ -1,4 +1,5 @@
 *.hex
 *.cod
 *.lst
+idlocs*.asm
 gpsim.log
index 02ca0496ec16fbf11c6a33acbc3a27e721948fe0..f0b6c86dd6bf069e9e080158442ebf2289b1867b 100644 (file)
@@ -2,12 +2,25 @@ PROGRAMS=     led-flash send-serial reply-serial      \
                nmra-stream nmra-stream,slow
 # booster-output-low  -disabled because you forgot to cvs add it
 
+PICNOS=                0 1 3
+
+TARGETS=       $(foreach i, $(PICNOS), perpic$i.hex)
+
 include ../pic.make
 
 clean:         pic-clean
+               rm -f idlocs*.asm
 
 %,slow.o:      %.asm
                $(ASSEMBLE) -D SLOW_VERSION -c -o $@ $<
 
-%-full.hex:    %.o config.o
+idlocs%.asm:   make-idlocs
+               ./$< $* >$@.new && mv -f $@.new $@
+
+perpic%.hex:   config.o idlocs%.o
                $(LINK)
+
+%-entire0.hex: %.o config.o idlocs0.o
+               $(LINK)
+
+.PRECIOUS:     idlocs%.asm
index 5b5582ccc90b4f14ea6034a8a5e2488d9b9498ca..52b880ef5baaa0ff5edbb1474a7549999a9fc556 100644 (file)
@@ -18,11 +18,16 @@ most significant bit first
 8n1
 
 
-Flash memory
-============
+Flash memory ID locations
+=========================
 
-Byte 20 0000h bit 0 is 1 for the main PIC and 0 otherwise
+Byte 20 0000h
+               bit 0           1 for the main PIC (#0)
+                               0 otherwise
+               1-7             currently unused, set to 0
 
+Byte 20 0001h
+               PIC number (guaranteed to be in range 0..63 inclusive)
 
 I2C
 ===
diff --git a/cebpic/make-idlocs b/cebpic/make-idlocs
new file mode 100755 (executable)
index 0000000..a1447c5
--- /dev/null
@@ -0,0 +1,18 @@
+#!/usr/bin/perl
+
+@ARGV==1 or die;
+$_=shift @ARGV;
+m/^\d+$/ or die;
+$_<32 or die;
+
+push @a, $_ ? '0x00' : '0x80';
+push @a, sprintf "0x%02x", $_;
+
+printf "; automatically generated - do not edit\n" or die $!;
+for ($i= 0x200000;
+     @a;
+     $i++) {
+    $_= shift @a;
+    printf "\t __idlocs \t 0x%06x, %s\n", $i, $_ or die $!;
+}
+print "\t end\n" or die $!;
index 8c1f5fdcba8a4994bcc2bb672d5f6fecf2a2ebff..e4e2db81c221ceacb71533a07440ac3487a9f456 100644 (file)
--- a/pic.make
+++ b/pic.make
@@ -1,6 +1,20 @@
+# recommended programming order
+#   one test on PIC#0
+#      first time:                             erase, write FOO-entire0.hex
+#      subsequently if only FOO.asm changed:   update FOO.hex
+#   for all pics
+#      first time:     for each individually   erase, write perpicNUM.hex
+#      subsequently:   for all                 update FOO.hex
+#   other possibilities are not ruled out
+#
+# filename conventions - contents of hex files
+#   FOO.hex            FOO.o (only)
+#   FOO-withcfg.hex    FOO.o                           config.o
+#   FOO-entire0.hex    FOO.o           idlocs0.o       config.o
+#   perpicNUMBER.hex                   idlocsNUMBER.o  config.o
 
 PROGRAM_HEXES= $(addsuffix .hex, $(PROGRAMS)) \
-               $(addsuffix -full.hex, $(PROGRAMS))
+               $(addsuffix -withcfg.hex, $(PROGRAMS))
 
 all:           $(TARGETS) $(PROGRAM_HEXES)
 
@@ -9,7 +23,7 @@ o=>$@.new && mv -f $@.new $@
 LINK=          gplink -o $@ $^
 ASSEMBLE=      gpasm -p 18f458
 
-%-full.hex:    %.o config.o
+%-withcfg.hex: %.o config.o
                $(LINK)
 
 %.hex:         %.o