Commit ae2822cc75b6378ad257ff9cad5eb004ab391a88
Committed by
Gordon Hollingworth
1 parent
906051bf
Add installation target to makefile
Showing
2 changed files
with
16 additions
and
18 deletions
Makefile
main.c
| 1 | #include "libusb-1.0/libusb.h" | 1 | #include "libusb-1.0/libusb.h" |
| 2 | #include <stdio.h> | 2 | #include <stdio.h> |
| 3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
| 4 | +#include <string.h> | ||
| 4 | 5 | ||
| 5 | #include <unistd.h> | 6 | #include <unistd.h> |
| 6 | 7 | ||
| @@ -56,35 +57,26 @@ int main(int argc, char *argv[]) | @@ -56,35 +57,26 @@ int main(int argc, char *argv[]) | ||
| 56 | int size; | 57 | int size; |
| 57 | int retcode; | 58 | int retcode; |
| 58 | FILE *fp1, *fp2; | 59 | FILE *fp1, *fp2; |
| 59 | - char def1[] = "usbbootcode.bin"; | ||
| 60 | - char def2[] = "msd.bin"; | ||
| 61 | - char *str1, *str2; | 60 | + char def1[] = "/usr/share/rpiboot/usbbootcode.bin"; |
| 61 | + char def2[] = "/usr/share/rpiboot/msd.bin"; | ||
| 62 | + char *dir; | ||
| 63 | + | ||
| 62 | struct MESSAGE_S { | 64 | struct MESSAGE_S { |
| 63 | int length; | 65 | int length; |
| 64 | unsigned char signature[20]; | 66 | unsigned char signature[20]; |
| 65 | } message; | 67 | } message; |
| 66 | 68 | ||
| 67 | - if (argc < 3) | ||
| 68 | - { | ||
| 69 | - str1 = def1; | ||
| 70 | - str2 = def2; | ||
| 71 | - } else | ||
| 72 | - { | ||
| 73 | - str1 = argv[1]; | ||
| 74 | - str2 = argv[2]; | ||
| 75 | - } | ||
| 76 | - | ||
| 77 | - fp1 = fopen(str1, "rb"); | 69 | + fp1 = fopen(def1, "rb"); |
| 78 | if (fp1 == NULL) | 70 | if (fp1 == NULL) |
| 79 | { | 71 | { |
| 80 | - printf("Cannot open file %s\n", str1); | 72 | + printf("Cannot open file %s\n", def1); |
| 81 | exit(-1); | 73 | exit(-1); |
| 82 | } | 74 | } |
| 83 | 75 | ||
| 84 | - fp2 = fopen(str2, "rb"); | 76 | + fp2 = fopen(def2, "rb"); |
| 85 | if (fp2 == NULL) | 77 | if (fp2 == NULL) |
| 86 | { | 78 | { |
| 87 | - printf("Cannot open file %s\n", str2); | 79 | + printf("Cannot open file %s\n", def2); |
| 88 | exit(-1); | 80 | exit(-1); |
| 89 | } | 81 | } |
| 90 | 82 | ||
| @@ -122,7 +114,7 @@ int main(int argc, char *argv[]) | @@ -122,7 +114,7 @@ int main(int argc, char *argv[]) | ||
| 122 | (usb_device), &desc); | 114 | (usb_device), &desc); |
| 123 | printf("Found serial = %d: writing file %s\n", | 115 | printf("Found serial = %d: writing file %s\n", |
| 124 | desc.iSerialNumber, | 116 | desc.iSerialNumber, |
| 125 | - desc.iSerialNumber == 0 ? str1 : str2); | 117 | + desc.iSerialNumber == 0 ? def1 : def2); |
| 126 | fp = desc.iSerialNumber == 0 ? fp1 : fp2; | 118 | fp = desc.iSerialNumber == 0 ? fp1 : fp2; |
| 127 | } | 119 | } |
| 128 | 120 |