2020-10-11 13:30:41 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
*
|
|
|
|
* Copyright (C) 2020 Solomon Peachy
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2020-10-17 21:50:36 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2020-10-11 13:30:41 +00:00
|
|
|
#include "config.h"
|
|
|
|
#include "lcd.h"
|
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
#include "lcd-remote.h"
|
|
|
|
#endif
|
|
|
|
#include "audio.h"
|
|
|
|
#include "button.h"
|
|
|
|
#include "scroll_engine.h"
|
|
|
|
#include "storage.h"
|
|
|
|
#include "rolo.h"
|
|
|
|
#include "rbpaths.h"
|
|
|
|
|
2020-10-17 21:50:36 +00:00
|
|
|
//#define LOGF_ENABLE
|
|
|
|
#include "logf.h"
|
2020-10-11 13:30:41 +00:00
|
|
|
|
|
|
|
static void rolo_error(const char *text, const char *text2)
|
|
|
|
{
|
|
|
|
lcd_clear_display();
|
|
|
|
lcd_puts(0, 0, "ROLO error:");
|
|
|
|
lcd_puts_scroll(0, 1, text);
|
|
|
|
if (text2)
|
|
|
|
lcd_puts_scroll(0, 2, text2);
|
|
|
|
lcd_update();
|
|
|
|
button_get(true);
|
|
|
|
button_get(true);
|
|
|
|
button_get(true);
|
|
|
|
lcd_scroll_stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
int rolo_load(const char* filename)
|
|
|
|
{
|
|
|
|
lcd_clear_display();
|
|
|
|
lcd_puts(0, 0, "ROLO...");
|
|
|
|
lcd_puts(0, 1, "Loading");
|
|
|
|
lcd_update();
|
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
lcd_remote_clear_display();
|
|
|
|
lcd_remote_puts(0, 0, "ROLO...");
|
|
|
|
lcd_remote_puts(0, 1, "Loading");
|
|
|
|
lcd_remote_update();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
audio_stop();
|
|
|
|
|
|
|
|
#ifdef HAVE_STORAGE_FLUSH
|
2020-10-12 14:04:45 +00:00
|
|
|
lcd_puts(0, 2, "Flushing storage buffers");
|
2020-10-11 13:30:41 +00:00
|
|
|
lcd_update();
|
|
|
|
storage_flush();
|
|
|
|
#endif
|
|
|
|
|
2020-10-12 14:04:45 +00:00
|
|
|
lcd_puts(0, 3, "Executing");
|
2020-10-11 13:30:41 +00:00
|
|
|
lcd_update();
|
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
lcd_remote_puts(0, 1, "Executing");
|
|
|
|
lcd_remote_update();
|
|
|
|
#endif
|
|
|
|
|
2020-10-11 12:26:53 +00:00
|
|
|
#ifdef PIVOT_ROOT
|
2020-10-17 21:50:36 +00:00
|
|
|
#define EXECDIR "/tmp"
|
2020-10-11 12:26:53 +00:00
|
|
|
#else
|
2020-10-11 12:26:53 +00:00
|
|
|
#define EXECDIR HOME_DIR
|
2020-10-11 12:26:53 +00:00
|
|
|
#endif
|
|
|
|
|
2020-10-11 13:30:41 +00:00
|
|
|
char buf[256];
|
2020-10-17 21:50:36 +00:00
|
|
|
#ifdef PIVOT_ROOT
|
|
|
|
snprintf(buf, sizeof(buf), "/bin/cp " PIVOT_ROOT "/%s " EXECDIR "/" BOOTFILE, filename);
|
|
|
|
logf("system: %s", buf);
|
|
|
|
system(buf);
|
|
|
|
snprintf(buf, sizeof(buf), "/bin/chmod +x " EXECDIR "/" BOOTFILE);
|
|
|
|
logf("system: %s", buf);
|
|
|
|
system(buf);
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%s/%s", EXECDIR, BOOTFILE);
|
|
|
|
#else
|
2020-10-11 12:26:53 +00:00
|
|
|
snprintf(buf, sizeof(buf), "%s/%s", EXECDIR, filename);
|
2020-10-17 21:50:36 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
logf("execl: %s", buf);
|
2020-10-11 13:30:41 +00:00
|
|
|
execl(buf, BOOTFILE, NULL);
|
|
|
|
|
|
|
|
rolo_error("Failed to launch!", strerror(errno));
|
|
|
|
|
|
|
|
/* never reached */
|
|
|
|
return 0;
|
|
|
|
}
|