Support ROCKBOX_DIR in HibyOS hosted bootloader

Currently if you want to compile a bootloader like so:

$ ../tools/configure --rbdir=/.rockbox.aigoerosq --target=aigoerosq --type=b

This won't work because the bootloader is hard coded to look for the rockbox Linux binary in /.rockbox/rockbox.erosq regardless of what is specified by '--rbdir'.

This commit adds support for ROCKBOX_DIR in the hosted HibyOS bootloaders.

After compiling, they can be installed with adb via (for example):

adb push build/bootloader.erosq /usr/bin/bootloader.erosq

Change-Id: Ic4ceb75107f608beacfd497998a11a5874e87ac1
This commit is contained in:
neofright 2026-09-03 22:54:54 +01:00 • committed by Solomon Peachy
parent 4502948cd8
commit 4b8ea97fa9

View file

@ -36,6 +36,7 @@
#include "lcd.h"
#include "font.h"
#include "power.h"
#include "rbpaths.h"
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
@ -143,11 +144,6 @@
#endif
#define BASE_DIR PIVOT_ROOT
//#ifdef FIIO_M3K_LINUX
//#define BASE_DIR "/mnt"
//#else
//#define BASE_DIR "/mnt/sd_0"
//#endif
/* images */
#include "bitmaps/rockboxicon.h"
@ -258,7 +254,7 @@ static void mount_storage(int enable)
static enum boot_mode load_boot_mode(enum boot_mode mode)
{
mount_storage(true);
int fd = open(BASE_DIR "/.rockbox/rb_bl_mode.txt", O_RDONLY);
int fd = open(BASE_DIR ROCKBOX_DIR "/rb_bl_mode.txt", O_RDONLY);
if(fd >= 0)
{
read(fd, &mode, sizeof(mode));
@ -270,7 +266,7 @@ static enum boot_mode load_boot_mode(enum boot_mode mode)
static void save_boot_mode(enum boot_mode mode)
{
mount_storage(true);
int fd = open(BASE_DIR "/.rockbox/rb_bl_mode.txt", O_RDWR | O_CREAT | O_TRUNC);
int fd = open(BASE_DIR ROCKBOX_DIR "/rb_bl_mode.txt", O_RDWR | O_CREAT | O_TRUNC);
if(fd >= 0)
{
write(fd, &mode, sizeof(mode));
@ -720,14 +716,14 @@ int main(int argc, char **argv)
#endif
fflush(stdout);
mount_storage(true);
system("/bin/cp " BASE_DIR "/.rockbox/" BOOTFILE " /tmp");
system("/bin/cp " BASE_DIR ROCKBOX_DIR "/" BOOTFILE " /tmp");
system("/bin/chmod +x /tmp/" BOOTFILE);
#ifdef HIBY_R1
/* Load libasound from Rockbox directory */
char *argvr1[] = { "/tmp/" BOOTFILE, 0 };
char *envpr1[] =
{
"LD_LIBRARY_PATH=/data/mnt/sd_0/.rockbox",
"LD_LIBRARY_PATH=" BASE_DIR "/" ROCKBOX_DIR,
0
};
execve(argvr1[0], &argvr1[0], envpr1);