diff options
Diffstat (limited to 'utils/MTP/beastpatcher/beastpatcher.c')
-rw-r--r-- | utils/MTP/beastpatcher/beastpatcher.c | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/utils/MTP/beastpatcher/beastpatcher.c b/utils/MTP/beastpatcher/beastpatcher.c index 05993531ff..72de1b57b8 100644 --- a/utils/MTP/beastpatcher/beastpatcher.c +++ b/utils/MTP/beastpatcher/beastpatcher.c | |||
@@ -56,7 +56,7 @@ | |||
56 | #include "bootimg.h" | 56 | #include "bootimg.h" |
57 | 57 | ||
58 | /* Code to create a single-boot bootloader. | 58 | /* Code to create a single-boot bootloader. |
59 | Based on tools/gigabeats.c by Will Robertson. | 59 | Based on tools/gigabeats.c by Will Robertson. |
60 | */ | 60 | */ |
61 | 61 | ||
62 | /* Entry point (and load address) for the main Rockbox bootloader */ | 62 | /* Entry point (and load address) for the main Rockbox bootloader */ |
@@ -83,7 +83,7 @@ static void create_single_boot(unsigned char* boot, int bootlen, | |||
83 | { | 83 | { |
84 | unsigned char* buf; | 84 | unsigned char* buf; |
85 | 85 | ||
86 | /* 15 bytes for header, 16 for signature bypass, | 86 | /* 15 bytes for header, 16 for signature bypass, |
87 | * 12 for record header, size of bootloader, 12 for footer */ | 87 | * 12 for record header, size of bootloader, 12 for footer */ |
88 | *fwsize = 15 + 16 + 12 + bootlen + 12; | 88 | *fwsize = 15 + 16 + 12 + bootlen + 12; |
89 | *fwbuf = malloc(*fwsize); | 89 | *fwbuf = malloc(*fwsize); |
@@ -106,7 +106,7 @@ static void create_single_boot(unsigned char* boot, int bootlen, | |||
106 | 106 | ||
107 | /* If the value below is too small, the update will attempt to flash. | 107 | /* If the value below is too small, the update will attempt to flash. |
108 | * Be careful when changing this (leaving it as is won't cause issues) */ | 108 | * Be careful when changing this (leaving it as is won't cause issues) */ |
109 | put_uint32le(0xCC0CD8, buf+11); | 109 | put_uint32le(0xCC0CD8, buf+11); |
110 | 110 | ||
111 | /* Step 3: Add the signature bypass record */ | 111 | /* Step 3: Add the signature bypass record */ |
112 | put_uint32le(0x88065A10, buf+15); | 112 | put_uint32le(0x88065A10, buf+15); |
@@ -186,3 +186,30 @@ int beastpatcher(void) | |||
186 | return 0; | 186 | return 0; |
187 | } | 187 | } |
188 | 188 | ||
189 | |||
190 | int sendfirm(const char* filename) | ||
191 | { | ||
192 | struct mtp_info_t mtp_info; | ||
193 | |||
194 | if (mtp_init(&mtp_info) < 0) { | ||
195 | fprintf(stderr,"[ERR] Can not init MTP\n"); | ||
196 | return 1; | ||
197 | } | ||
198 | |||
199 | /* Scan for attached MTP devices. */ | ||
200 | if (mtp_scan(&mtp_info) < 0) | ||
201 | { | ||
202 | fprintf(stderr,"[ERR] No devices found\n"); | ||
203 | return 1; | ||
204 | } | ||
205 | |||
206 | printf("[INFO] Found device \"%s - %s\"\n", mtp_info.manufacturer, | ||
207 | mtp_info.modelname); | ||
208 | printf("[INFO] Device version: \"%s\"\n",mtp_info.version); | ||
209 | |||
210 | mtp_send_file(&mtp_info, filename); | ||
211 | |||
212 | mtp_finished(&mtp_info); | ||
213 | return 0; | ||
214 | } | ||
215 | |||