Commit 7dfdce9f7e51e27bdec22b5b0b5747b947f94b9e

Authored by James Adams
Committed by Gordon Hollingworth
1 parent eeba0a9b

Update to run under Cygwin

Showing 2 changed files with 24 additions and 6 deletions
Makefile 100644 → 100755
... ... @@ -84,26 +84,44 @@ int main(int argc, char *argv[])
84 84 int retcode;
85 85 int last_serial = -1;
86 86 FILE *fp1, *fp2, *fp;
87   - char def1[] = "/usr/share/rpiboot/usbbootcode.bin";
88   - char def2[] = "/usr/share/rpiboot/msd.elf";
89   - char def3[] = "/usr/share/rpiboot/buildroot.elf";
90 87  
91   - char *stage1 = def1, *stage2 = def2;
  88 + char def1_inst[] = "/usr/share/rpiboot/usbbootcode.bin";
  89 + char def2_inst[] = "/usr/share/rpiboot/msd.elf";
  90 + char def3_inst[] = "/usr/share/rpiboot/buildroot.elf";
  91 +
  92 + char def1_loc[] = "./usbbootcode.bin";
  93 + char def2_loc[] = "./msd.elf";
  94 + char def3_loc[] = "./buildroot.elf";
  95 +
  96 + char *def1, *def2, *def3;
  97 +
  98 + char *stage1 = NULL, *stage2 = NULL;
92 99 char *fatimage = NULL, *executable = NULL;
93 100 int loop = 0;
94 101  
  102 +// if local file version exists use it else use installed
  103 + if( access( def1_loc, F_OK ) != -1 ) { def1 = def1_loc; } else { def1 = def1_inst; }
  104 + if( access( def2_loc, F_OK ) != -1 ) { def2 = def2_loc; } else { def2 = def2_inst; }
  105 + if( access( def3_loc, F_OK ) != -1 ) { def3 = def3_loc; } else { def3 = def3_inst; }
  106 +
  107 + stage1 = def1;
  108 + stage2 = def2;
  109 +
95 110 struct MESSAGE_S {
96 111 int length;
97 112 unsigned char signature[20];
98 113 } message;
99 114  
  115 +#if defined (__CYGWIN__)
  116 + //printf("Running under Cygwin\n");
  117 +#else
100 118 //exit if not run as sudo
101   - int user = getuid();
102   - if(user != 0)
  119 + if(getuid() != 0)
103 120 {
104 121 printf("Must be run with sudo...\n");
105 122 exit(-1);
106 123 }
  124 +#endif
107 125  
108 126 // Skip the command name
109 127 argv++; argc--;
... ...