Commit 1bb4c2da4775329bcf5811616fc8f0ce78ee2121
1 parent
c3ee230e
Compile bootcode.bin and start.elf into rpiboot
This helps avoid picking up the wrong files when msd files have already been installed as a debian package
Showing
2 changed files
with
15 additions
and
8 deletions
Makefile
| 1 | -rpiboot: main.c | 1 | +rpiboot: main.c msd/bootcode.h msd/start.h |
| 2 | $(CC) -Wall -Wextra -g -o $@ $< -lusb-1.0 | 2 | $(CC) -Wall -Wextra -g -o $@ $< -lusb-1.0 |
| 3 | 3 | ||
| 4 | +%.h: %.bin | ||
| 5 | + xxd -i $< > $@ | ||
| 6 | + | ||
| 7 | +%.h: %.elf | ||
| 8 | + xxd -i $< > $@ | ||
| 9 | + | ||
| 4 | uninstall: | 10 | uninstall: |
| 5 | rm -f /usr/bin/rpiboot | 11 | rm -f /usr/bin/rpiboot |
| 6 | rm -f /usr/share/rpiboot/usbbootcode.bin | 12 | rm -f /usr/share/rpiboot/usbbootcode.bin |
main.c
| @@ -5,6 +5,9 @@ | @@ -5,6 +5,9 @@ | ||
| 5 | 5 | ||
| 6 | #include <unistd.h> | 6 | #include <unistd.h> |
| 7 | 7 | ||
| 8 | +#include "msd/bootcode.h" | ||
| 9 | +#include "msd/start.h" | ||
| 10 | + | ||
| 8 | int signed_boot = 0; | 11 | int signed_boot = 0; |
| 9 | int verbose = 0; | 12 | int verbose = 0; |
| 10 | int loop = 0; | 13 | int loop = 0; |
| @@ -410,9 +413,11 @@ FILE * check_file(char * dir, char *fname) | @@ -410,9 +413,11 @@ FILE * check_file(char * dir, char *fname) | ||
| 410 | 413 | ||
| 411 | if(fp == NULL) | 414 | if(fp == NULL) |
| 412 | { | 415 | { |
| 413 | - strcpy(path, "/usr/share/rpiboot/msd/"); | ||
| 414 | - strcat(path, fname); | ||
| 415 | - fp = fopen(path, "rb"); | 416 | + if(strcmp(fname, "bootcode.bin") == 0) |
| 417 | + fp = fmemopen(msd_bootcode_bin, msd_bootcode_bin_len, "r"); | ||
| 418 | + else | ||
| 419 | + if(strcmp(fname, "start.elf") == 0) | ||
| 420 | + fp = fmemopen(msd_start_elf, msd_start_elf_len, "r"); | ||
| 416 | } | 421 | } |
| 417 | 422 | ||
| 418 | return fp; | 423 | return fp; |
| @@ -563,10 +568,6 @@ int main(int argc, char *argv[]) | @@ -563,10 +568,6 @@ int main(int argc, char *argv[]) | ||
| 563 | #endif | 568 | #endif |
| 564 | 569 | ||
| 565 | 570 | ||
| 566 | - // Default to standard msd directory | ||
| 567 | - if(directory == NULL) | ||
| 568 | - directory = "msd"; | ||
| 569 | - | ||
| 570 | second_stage = check_file(directory, "bootcode.bin"); | 571 | second_stage = check_file(directory, "bootcode.bin"); |
| 571 | if(second_stage == NULL) | 572 | if(second_stage == NULL) |
| 572 | { | 573 | { |