Signature verification prior to startup - page 5 - General Discussion and Assistance - CHDK Forum

Signature verification prior to startup

  • 83 Replies
  • 42423 Views
*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: Signature verification prior to startup
« Reply #40 on: 30 / September / 2013, 19:56:22 »
Advertisements
Does the added code that generates bin_compat.h run correctly on Windows?

It seems to, although the check string generated for the IXUS 700 firmware version is "ion GM1.01A".
The address to check is correct so it all still works - just looks odd in the bin_compat.h file.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

*

Offline srsa_4c

  • ******
  • 4451
Re: Signature verification prior to startup
« Reply #41 on: 01 / October / 2013, 10:53:49 »
It seems to, although the check string generated for the IXUS 700 firmware version is "ion GM1.01A".
I used a fixed offset into the string, and the ixus700 is one of the 3 exceptions that use a different version string. The next version will use the last 7 letters of the string instead (which will still not look good on the ixus30/40, but at least it fits in 2 words).

A question about the sigfinder: Your version now locates several functions with "new" methods. Have you compared the results to the old stubs_entry.S files (the stubs_entry_2.S changes indicate so), or should I do it?

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: Signature verification prior to startup
« Reply #42 on: 01 / October / 2013, 15:44:56 »
A question about the sigfinder: Your version now locates several functions with "new" methods. Have you compared the results to the old stubs_entry.S files (the stubs_entry_2.S changes indicate so), or should I do it?

I use a Perl script to compare the values that aren't overridden in stubs_entry_2.S with the values in the current trunk build.

As far as I can tell everything is correct; but it's probably worth double checking a few to make sure.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

*

Offline srsa_4c

  • ******
  • 4451
Re: Signature verification prior to startup
« Reply #43 on: 05 / October / 2013, 19:04:45 »
Now I also have a perl script to compare the content of stubs files, and I see no problems either. I have tried 3 cameras to be sure (a410, a420, ixus40), the resulting diskboot files are usable.

I have added firmware build date and time information to the sigfinders, but I decided not to use them for the boot-time check (for now).
A question: should I make the auto generated bin_compat.h files version controlled, or not?

If this finsig_vxworks gets added to trunk (and 1.2), I'll start adding the "new" functions that I made available on DryOS earlier.

The attachment doesn't include the bin_compat.h files and reyalp's additions - those can be added when the first port gets its boot verification implementation.
I have not made a full batch build yet as a test, only batch-rebuild-stubs.

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: Signature verification prior to startup
« Reply #44 on: 05 / October / 2013, 20:24:17 »
Now I also have a perl script to compare the content of stubs files, and I see no problems either. I have tried 3 cameras to be sure (a410, a420, ixus40), the resulting diskboot files are usable.

I have added firmware build date and time information to the sigfinders, but I decided not to use them for the boot-time check (for now).
A question: should I make the auto generated bin_compat.h files version controlled, or not?

I would add them to SVN; but possibly in a separate commit.

Quote
If this finsig_vxworks gets added to trunk (and 1.2), I'll start adding the "new" functions that I made available on DryOS earlier.

The attachment doesn't include the bin_compat.h files and reyalp's additions - those can be added when the first port gets its boot verification implementation.
I have not made a full batch build yet as a test, only batch-rebuild-stubs.

So it should be safe enough to add to 1.3 for initial testing.

Note there are a lot of white space / formatting changes in finsig_vxworks.c and firmware_load.c making it harder to evaluate (and changing the code formatting). The standard in CHDK is generally to set tabs to 4 spaces and insert tabs as spaces (although there are still many places where this is not the case).

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

*

Offline srsa_4c

  • ******
  • 4451
Re: Signature verification prior to startup
« Reply #45 on: 06 / October / 2013, 01:17:18 »
Note there are a lot of white space / formatting changes in finsig_vxworks.c and firmware_load.c making it harder to evaluate (and changing the code formatting). The standard in CHDK is generally to set tabs to 4 spaces and insert tabs as spaces (although there are still many places where this is not the case).
Sorry about that, my svn client was set to ignore whitespace changes which caused lots of noise with whitespaces in the diff...

Looks like I managed to break down autobuild too, the server's awk is apparently set to "compatibility" mode, the following should fix autobuild until I can rewrite the awk parts of the makefile.
Code: [Select]
Index: Makefile
===================================================================
--- Makefile (revision 3134)
+++ Makefile (working copy)
@@ -211,7 +211,7 @@
 rebuild-stubs:
  if [ -s $(PRIMARY_ROOT)/$(PLATFORM)/sub/$(PLATFORMSUB)/PRIMARY.BIN ] ; then \
  echo "rebuild stubs for $(PLATFORM)-$(PLATFORMSUB)" ;\
- $(MAKE) -C $(topdir)platform/$(PLATFORM)/sub/$(PLATFORMSUB) stubs_entry.S bin_compat.h ;\
+ $(MAKE) -C $(topdir)platform/$(PLATFORM)/sub/$(PLATFORMSUB) stubs_entry.S ;\
  else \
  echo "!!! missing primary for $(PLATFORM)-$(PLATFORMSUB)"; \
  fi
Index: platform/makefile_sub.inc
===================================================================
--- platform/makefile_sub.inc (revision 3134)
+++ platform/makefile_sub.inc (working copy)
@@ -18,13 +18,13 @@
      gui.thm.o kbd_process.thm.o conf.thm.o gui_osd.thm.o raw.thm.o \
      shot_histogram.thm.o shooting.thm.o camera_info.thm.o remotecap.thm.o
 
-libplatformsub.a: $(OBJS) bin_compat.h
+libplatformsub.a: $(OBJS)
 
 clean:
  rm -f *.o libplatformsub.a stubs_entry.S.err stubs_not_found_names.err
 
 distclean: clean
- rm -f stubs_entry.S stubs_auto.S bin_compat.h
+ rm -f stubs_entry.S stubs_auto.S
  rm -rf .dep
 
 run-code-gen:

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: Signature verification prior to startup
« Reply #46 on: 06 / October / 2013, 02:00:13 »
Note there are a lot of white space / formatting changes in finsig_vxworks.c and firmware_load.c making it harder to evaluate (and changing the code formatting). The standard in CHDK is generally to set tabs to 4 spaces and insert tabs as spaces (although there are still many places where this is not the case).
Sorry about that, my svn client was set to ignore whitespace changes which caused lots of noise with whitespaces in the diff...

Looks like I managed to break down autobuild too, the server's awk is apparently set to "compatibility" mode, the following should fix autobuild until I can rewrite the awk parts of the makefile.
Code: [Select]
Index: Makefile
===================================================================
--- Makefile (revision 3134)
+++ Makefile (working copy)
@@ -211,7 +211,7 @@
 rebuild-stubs:
  if [ -s $(PRIMARY_ROOT)/$(PLATFORM)/sub/$(PLATFORMSUB)/PRIMARY.BIN ] ; then \
  echo "rebuild stubs for $(PLATFORM)-$(PLATFORMSUB)" ;\
- $(MAKE) -C $(topdir)platform/$(PLATFORM)/sub/$(PLATFORMSUB) stubs_entry.S bin_compat.h ;\
+ $(MAKE) -C $(topdir)platform/$(PLATFORM)/sub/$(PLATFORMSUB) stubs_entry.S ;\
  else \
  echo "!!! missing primary for $(PLATFORM)-$(PLATFORMSUB)"; \
  fi
Index: platform/makefile_sub.inc
===================================================================
--- platform/makefile_sub.inc (revision 3134)
+++ platform/makefile_sub.inc (working copy)
@@ -18,13 +18,13 @@
      gui.thm.o kbd_process.thm.o conf.thm.o gui_osd.thm.o raw.thm.o \
      shot_histogram.thm.o shooting.thm.o camera_info.thm.o remotecap.thm.o
 
-libplatformsub.a: $(OBJS) bin_compat.h
+libplatformsub.a: $(OBJS)
 
 clean:
  rm -f *.o libplatformsub.a stubs_entry.S.err stubs_not_found_names.err
 
 distclean: clean
- rm -f stubs_entry.S stubs_auto.S bin_compat.h
+ rm -f stubs_entry.S stubs_auto.S
  rm -rf .dep
 
 run-code-gen:

Odd, it built ok on my VM using the autobuild toolchain.

I've applied your patch so hopefully it will fix the autobuild.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

*

Offline srsa_4c

  • ******
  • 4451
Re: Signature verification prior to startup
« Reply #47 on: 06 / October / 2013, 09:55:01 »
Odd, it built ok on my VM using the autobuild toolchain.
Debian (and its derivatives) have mawk as the default awk.

The following could be done to fix this:
- call gawk instead of awk in the offending script - I wonder if GNU awk is installed on the server...?
- auto-detect the system awk in the beginning of the make procedure, and only pass --non-decimal-data to GNU awk
- change the sigfinder to also output decimal addresses where needed

Which one of these options seems right?

edit:
Went for option 2 (auto detection), testing now.
« Last Edit: 06 / October / 2013, 14:46:34 by srsa_4c »

*

Offline srsa_4c

  • ******
  • 4451
Re: Signature verification prior to startup
« Reply #48 on: 06 / October / 2013, 17:23:05 »
The attached patch fixes the generation of bin_compat.h by using the --non-decimal-data switch only for GNU Awk. I'm not completely sure whether the detection method is the most appropriate (is AWK_SWITCH evaluated only once for a build, or once for each camera when batch building?).
I have tested it (batch-rebuild-stubs) with GNU Awk and mawk on Linux, and also made a single test build using the 4.5.1 Windows toolchain.
The difference in the Elph320 port is due to changeset 3137.

edit:
I decided to risk the commit. Since mawk spams the log all over, something must be wrong with the makefiles. I'll try to determine the cause.

edit2:
In changeset 3139 I moved the awk detection elsewhere, optimizing the build process further is beyond me, unfortunately...
« Last Edit: 07 / October / 2013, 16:29:28 by srsa_4c »

*

Offline srsa_4c

  • ******
  • 4451
Re: Signature verification prior to startup
« Reply #49 on: 12 / October / 2013, 17:14:15 »
Looks like I'll have to modify the signature generation code. Thanks to nafraf's recent commit (and then his research), it turned out that Debian (and its derivatives) have
- mawk 1.3.3, which is unable to handle integers over 0x7fffffff
- a shell named "dash" as the default shell, whose built-in echo command doesn't know about the -e switch.
The latter can be dealt with easily. To be able to output correct addresses, I'll either have to use GNU awk (is it available on the autobuild server?), or do the math inside the sigfinder. Unless somebody has a better idea, I'll probably modify the sigfinders.

The shell issue has visible consequences btw: the autobuild's zip files' zip comment always begins with "-e " ...

 

Related Topics


SimplePortal © 2008-2014, SimplePortal