x1000: bootloader: add screenshot function

Screenshots of the recovery menu will be useful for documentation.

This can be disabled by turning off HAVE_BOOTLOADER_SCREENDUMP in
the target config file if the bootloader should ever run up against
max size limits.

Change-Id: I62ec1e465df2ca7a8a0e78625d88b31f6c4ef078
This commit is contained in:
Aidan MacDonald 2022-03-20 13:07:39 +00:00
parent 4cf36dfbf3
commit 5160c90690
7 changed files with 47 additions and 4 deletions

View file

@ -122,10 +122,17 @@ void splashf(long delay, const char* msg, ...)
int get_button(int timeout) int get_button(int timeout)
{ {
int btn = button_get_w_tmo(timeout); int btn = button_get_w_tmo(timeout);
if(btn == SYS_USB_CONNECTED) switch(btn) {
is_usb_connected = true; case SYS_USB_CONNECTED:
else if(btn == SYS_USB_DISCONNECTED) case SYS_USB_DISCONNECTED:
is_usb_connected = false; is_usb_connected = (btn == SYS_USB_CONNECTED);
break;
#ifdef HAVE_SCREENDUMP
case BL_SCREENSHOT:
screenshot();
break;
#endif
}
return btn; return btn;
} }

View file

@ -65,6 +65,9 @@ static const struct menuitem recovery_items[] = {
static const struct menuitem debug_menu_items[] = { static const struct menuitem debug_menu_items[] = {
{MENUITEM_HEADING, "Debug tools", NULL}, {MENUITEM_HEADING, "Debug tools", NULL},
#ifdef HAVE_SCREENDUMP
{MENUITEM_ACTION, "Enable screenshots", &screenshot_enable},
#endif
#ifdef OF_PLAYER_ADDR #ifdef OF_PLAYER_ADDR
{MENUITEM_ACTION, "Dump OF player", &dump_of_player}, {MENUITEM_ACTION, "Dump OF player", &dump_of_player},
#endif #endif

View file

@ -29,6 +29,7 @@
#include "rb-loader.h" #include "rb-loader.h"
#include "loader_strerror.h" #include "loader_strerror.h"
#include "linuxboot.h" #include "linuxboot.h"
#include "screendump.h"
#include "nand-x1000.h" #include "nand-x1000.h"
/* Set to true if a SYS_USB_CONNECTED event is seen /* Set to true if a SYS_USB_CONNECTED event is seen
@ -37,6 +38,8 @@
* TODO: this is an ugly kludge */ * TODO: this is an ugly kludge */
bool is_usb_connected = false; bool is_usb_connected = false;
static bool screenshot_enabled = false;
/* this is both incorrect and incredibly racy... */ /* this is both incorrect and incredibly racy... */
int check_disk(bool wait) int check_disk(bool wait)
{ {
@ -75,6 +78,25 @@ void usb_mode(void)
splashf(3*HZ, "USB disconnected"); splashf(3*HZ, "USB disconnected");
} }
void screenshot(void)
{
#ifdef HAVE_SCREENDUMP
if(!screenshot_enabled || check_disk(false) != DISK_PRESENT)
return;
screen_dump();
#endif
}
void screenshot_enable(void)
{
#ifdef HAVE_SCREENDUMP
splashf(3*HZ, "Screenshots enabled\nPress %s for screenshot",
BL_SCREENSHOT_NAME);
screenshot_enabled = true;
#endif
}
int load_rockbox(const char* filename, size_t* sizep) int load_rockbox(const char* filename, size_t* sizep)
{ {
if(check_disk(true) != DISK_PRESENT) if(check_disk(true) != DISK_PRESENT)

View file

@ -36,10 +36,12 @@ struct uimage_header;
# define BL_DOWN BUTTON_VOL_DOWN # define BL_DOWN BUTTON_VOL_DOWN
# define BL_SELECT BUTTON_PLAY # define BL_SELECT BUTTON_PLAY
# define BL_QUIT BUTTON_POWER # define BL_QUIT BUTTON_POWER
# define BL_SCREENSHOT_NAME BUTTON_MENU
# define BL_UP_NAME "VOL+" # define BL_UP_NAME "VOL+"
# define BL_DOWN_NAME "VOL-" # define BL_DOWN_NAME "VOL-"
# define BL_SELECT_NAME "PLAY" # define BL_SELECT_NAME "PLAY"
# define BL_QUIT_NAME "POWER" # define BL_QUIT_NAME "POWER"
# define BL_SCREENSHOT_NAME "MENU"
# define BOOTBACKUP_FILE "/fiiom3k-boot.bin" # define BOOTBACKUP_FILE "/fiiom3k-boot.bin"
# define OF_PLAYER_NAME "FiiO player" # define OF_PLAYER_NAME "FiiO player"
# define OF_PLAYER_ADDR 0x20000 # define OF_PLAYER_ADDR 0x20000
@ -63,10 +65,12 @@ struct uimage_header;
# define BL_DOWN BUTTON_NEXT # define BL_DOWN BUTTON_NEXT
# define BL_SELECT BUTTON_PLAY # define BL_SELECT BUTTON_PLAY
# define BL_QUIT BUTTON_POWER # define BL_QUIT BUTTON_POWER
# define BL_SCREENSHOT BUTTON_TOPLEFT
# define BL_UP_NAME "PREV" # define BL_UP_NAME "PREV"
# define BL_DOWN_NAME "NEXT" # define BL_DOWN_NAME "NEXT"
# define BL_SELECT_NAME "PLAY" # define BL_SELECT_NAME "PLAY"
# define BL_QUIT_NAME "POWER" # define BL_QUIT_NAME "POWER"
# define BL_SCREENSHOT_NAME "TOPLEFT"
# define BOOTBACKUP_FILE "/shanlingq1-boot.bin" # define BOOTBACKUP_FILE "/shanlingq1-boot.bin"
# define OF_PLAYER_NAME "Shanling player" # define OF_PLAYER_NAME "Shanling player"
# define OF_PLAYER_ADDR 0x140000 # define OF_PLAYER_ADDR 0x140000
@ -84,10 +88,12 @@ struct uimage_header;
# define BL_DOWN BUTTON_SCROLL_FWD # define BL_DOWN BUTTON_SCROLL_FWD
# define BL_SELECT BUTTON_PLAY # define BL_SELECT BUTTON_PLAY
# define BL_QUIT BUTTON_POWER # define BL_QUIT BUTTON_POWER
# define BL_SCREENSHOT BUTTON_MENU
# define BL_UP_NAME "Up" # define BL_UP_NAME "Up"
# define BL_DOWN_NAME "Scroll Down" # define BL_DOWN_NAME "Scroll Down"
# define BL_SELECT_NAME "PLAY" # define BL_SELECT_NAME "PLAY"
# define BL_QUIT_NAME "POWER" # define BL_QUIT_NAME "POWER"
# define BL_SCREENSHOT_NAME "MENU"
# define BOOTBACKUP_FILE "/erosqnative-boot.bin" # define BOOTBACKUP_FILE "/erosqnative-boot.bin"
#else #else
# error "Missing keymap!" # error "Missing keymap!"
@ -160,6 +166,8 @@ enum {
int check_disk(bool wait); int check_disk(bool wait);
void usb_mode(void); void usb_mode(void);
void screenshot(void);
void screenshot_enable(void);
int load_rockbox(const char* filename, size_t* sizep); int load_rockbox(const char* filename, size_t* sizep);
int load_uimage_file(const char* filename, int load_uimage_file(const char* filename,

View file

@ -136,3 +136,4 @@
#define HAVE_TAGCACHE #define HAVE_TAGCACHE
#define HAVE_QUICKSCREEN #define HAVE_QUICKSCREEN
#define HAVE_HOTKEY #define HAVE_HOTKEY
#define HAVE_BOOTLOADER_SCREENDUMP

View file

@ -144,3 +144,4 @@
#define HAVE_HOTKEY #define HAVE_HOTKEY
#define HAVE_LOCKED_ACTIONS #define HAVE_LOCKED_ACTIONS
#define AB_REPEAT_ENABLE #define AB_REPEAT_ENABLE
#define HAVE_BOOTLOADER_SCREENDUMP

View file

@ -128,3 +128,4 @@
#define HAVE_QUICKSCREEN #define HAVE_QUICKSCREEN
#define HAVE_HOTKEY #define HAVE_HOTKEY
#define AB_REPEAT_ENABLE #define AB_REPEAT_ENABLE
#define HAVE_BOOTLOADER_SCREENDUMP