summaryrefslogtreecommitdiff
path: root/firmware/target/hosted/rolo.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/hosted/rolo.c')
-rw-r--r--firmware/target/hosted/rolo.c102
1 files changed, 102 insertions, 0 deletions
diff --git a/firmware/target/hosted/rolo.c b/firmware/target/hosted/rolo.c
new file mode 100644
index 0000000000..432d69c86e
--- /dev/null
+++ b/firmware/target/hosted/rolo.c
@@ -0,0 +1,102 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2020 Solomon Peachy
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
15 *
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
18 *
19 ****************************************************************************/
20
21#include "config.h"
22#include "lcd.h"
23#ifdef HAVE_REMOTE_LCD
24#include "lcd-remote.h"
25#endif
26#include "audio.h"
27#include "button.h"
28#include "scroll_engine.h"
29#include "storage.h"
30#include "rolo.h"
31#include "rbpaths.h"
32
33#include <unistd.h>
34#include <stdio.h>
35
36#if defined(HAVE_BOOTDATA) && !defined(SIMULATOR)
37#include "bootdata.h"
38#include "crc32.h"
39extern int write_bootdata(unsigned char* buf, int len, unsigned int boot_volume); /*rb-loader.c*/
40#endif
41
42static void rolo_error(const char *text, const char *text2)
43{
44 lcd_clear_display();
45 lcd_puts(0, 0, "ROLO error:");
46 lcd_puts_scroll(0, 1, text);
47 if (text2)
48 lcd_puts_scroll(0, 2, text2);
49 lcd_update();
50 button_get(true);
51 button_get(true);
52 button_get(true);
53 lcd_scroll_stop();
54}
55
56int rolo_load(const char* filename)
57{
58 lcd_clear_display();
59 lcd_puts(0, 0, "ROLO...");
60 lcd_puts(0, 1, "Loading");
61 lcd_update();
62#ifdef HAVE_REMOTE_LCD
63 lcd_remote_clear_display();
64 lcd_remote_puts(0, 0, "ROLO...");
65 lcd_remote_puts(0, 1, "Loading");
66 lcd_remote_update();
67#endif
68
69 audio_stop();
70
71#if defined(HAVE_BOOTDATA) && !defined(SIMULATOR)
72 /* write the bootdata as if rolo were the bootloader */
73 unsigned int crc = 0;
74 if (strcmp(filename, BOOTDIR "/" BOOTFILE) == 0)
75 crc = crc_32(boot_data.payload, boot_data.length, 0xffffffff);
76
77 if(crc > 0 && crc == boot_data.crc)
78 write_bootdata(filebuf, filebuf_size, boot_data.boot_volume); /* rb-loader.c */
79#endif
80
81#ifdef HAVE_STORAGE_FLUSH
82 lcd_puts(0, 1, "Flushing storage buffers");
83 lcd_update();
84 storage_flush();
85#endif
86
87 lcd_puts(0, 1, "Executing");
88 lcd_update();
89#ifdef HAVE_REMOTE_LCD
90 lcd_remote_puts(0, 1, "Executing");
91 lcd_remote_update();
92#endif
93
94 char buf[256];
95 snprintf(buf, sizeof(buf), "%s/%s", HOME_DIR, filename);
96 execl(buf, BOOTFILE, NULL);
97
98 rolo_error("Failed to launch!", strerror(errno));
99
100 /* never reached */
101 return 0;
102}