summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2022-03-03 23:40:17 +0000
committerAidan MacDonald <amachronic@protonmail.com>2022-03-12 18:25:10 +0000
commit38eafb60ff53079074443cddbda71dc4d7b31193 (patch)
treea72529338033f637b40640e562c9df27ae6a265c
parent376ffbcf9aabae6f47d62ba4734ae1bb230ebce3 (diff)
downloadrockbox-38eafb60ff53079074443cddbda71dc4d7b31193.tar.gz
rockbox-38eafb60ff53079074443cddbda71dc4d7b31193.zip
x1000: use core_alloc in bootloader for loading rockbox
Using the audio buffer directly is a bad idea because this will render core_alloc non-functional if load_firmware() writes into the buffer but then fails, for example on a checksum mismatch. Change-Id: Ib2d17bcea53bdea1c4c5496cec0c4eee5dd66069
-rw-r--r--bootloader/x1000.c16
-rw-r--r--firmware/target/mips/ingenic_x1000/app.lds2
2 files changed, 10 insertions, 8 deletions
diff --git a/bootloader/x1000.c b/bootloader/x1000.c
index bce7b69784..14634683e6 100644
--- a/bootloader/x1000.c
+++ b/bootloader/x1000.c
@@ -137,11 +137,6 @@ const struct menuitem recovery_items[] = {
137 {MENUITEM_ACTION, "Restore", &bootloader_restore}, 137 {MENUITEM_ACTION, "Restore", &bootloader_restore},
138}; 138};
139 139
140/* Temp buffer to contain the binary in memory */
141extern unsigned char loadbuffer[];
142extern unsigned char loadbufferend[];
143#define MAX_LOAD_SIZE (loadbufferend - loadbuffer)
144
145/* Flags to indicate if hardware was already initialized */ 140/* Flags to indicate if hardware was already initialized */
146bool lcd_inited = false; 141bool lcd_inited = false;
147bool usb_inited = false; 142bool usb_inited = false;
@@ -340,8 +335,17 @@ void boot_rockbox(void)
340 if(init_disk() != 0) 335 if(init_disk() != 0)
341 return; 336 return;
342 337
343 int rc = load_firmware(loadbuffer, BOOTFILE, MAX_LOAD_SIZE); 338 size_t max_size = 0;
339 int handle = core_alloc_maximum("rockbox", &max_size, &buflib_ops_locked);
340 if(handle < 0) {
341 splash(5*HZ, "Out of memory");
342 return;
343 }
344
345 unsigned char* loadbuffer = core_get_data(handle);
346 int rc = load_firmware(loadbuffer, BOOTFILE, max_size);
344 if(rc <= 0) { 347 if(rc <= 0) {
348 core_free(handle);
345 splash2(5*HZ, "Error loading Rockbox", loader_strerror(rc)); 349 splash2(5*HZ, "Error loading Rockbox", loader_strerror(rc));
346 return; 350 return;
347 } 351 }
diff --git a/firmware/target/mips/ingenic_x1000/app.lds b/firmware/target/mips/ingenic_x1000/app.lds
index 26b2854728..9b36071c3c 100644
--- a/firmware/target/mips/ingenic_x1000/app.lds
+++ b/firmware/target/mips/ingenic_x1000/app.lds
@@ -88,10 +88,8 @@ SECTIONS
88 { 88 {
89 . = ALIGN(4); 89 . = ALIGN(4);
90 audiobuffer = .; 90 audiobuffer = .;
91 loadbuffer = .;
92 } > DRAM 91 } > DRAM
93 92
94 loadbufferend = ENDAUDIOADDR;
95 audiobufend = ENDAUDIOADDR; 93 audiobufend = ENDAUDIOADDR;
96 codecbuf = ENDAUDIOADDR; 94 codecbuf = ENDAUDIOADDR;
97 pluginbuf = ENDCODECADDR; 95 pluginbuf = ENDCODECADDR;