Skip to content
Permalink
Browse files

Agptek Rocker: Enable USB storage driver

This change requires bootloader update. This is because
rockbox.rock needs to be run from other location then
/mnt/sd_0 since we need to umount SD card before handing
access to the block device to the android_usb.
The solution is to copy the binary to /tmp which is tmpfs
and run from there.
  • Loading branch information...
wodz committed Mar 15, 2018
1 parent 49e2d90 commit 8acd397c7e0364a760b323473fe6855521d42624
Showing with 27 additions and 13 deletions.
  1. +4 −0 apps/main.c
  2. +2 −6 bootloader/rocker_linux.c
  3. +21 −7 firmware/target/hosted/agptek/usb-agptek.c
@@ -335,6 +335,10 @@ static void init(void)
font_init();
#endif
show_logo();
#ifndef USB_NONE
usb_init();
usb_start_monitoring();
#endif
button_init();
powermgmt_init();
backlight_init();
@@ -522,13 +522,9 @@ int main(int argc, char **argv)
}
else if(mode == BOOT_ROCKBOX)
{
/* Rockbox expects /.rockbox to contain themes, rocks, etc, but we
* cannot easily create this symlink because the root filesystem is
* mounted read-only. Although we could remount it read-write temporarily,
* this is neededlessly complicated and we defer this job to the dualboot
* install script */
fflush(stdout);
execl("/mnt/sd_0/.rockbox/rockbox.rocker", "rockbox.rocker", NULL);
system("/bin/cp /mnt/sd_0/.rockbox/rockbox.rocker /tmp");
execl("/tmp/rockbox.rocker", "rockbox.rocker", NULL);
printf("execvp failed: %s\n", strerror(errno));
/* fallback to OF in case of failure */
error_screen("Cannot boot Rockbox");
@@ -23,11 +23,13 @@
#include "disk.h"
#include "usb.h"
#include "sysfs.h"
#include "power.h"
#include "power-agptek.h"

/* TODO: implement usb detection properly */
int usb_detect(void)
{
return USB_EXTRACTED;
return power_input_status() == POWER_INPUT_USB_CHARGER ? USB_INSERTED : USB_EXTRACTED;
}

void usb_enable(bool on)
@@ -42,10 +44,13 @@ void usb_enable(bool on)
*/
int disk_mount_all(void)
{
sysfs_set_string("/sys/class/android_usb/android0/f_mass_storage/lun/file", "empty");
sysfs_set_string("/sys/class/android_usb/android0/f_mass_storage/lun/file", "");

system("mount /dev/mmcblk0 /mnt/sd_0");
system("mount /dev/mmcblk0p1 /mnt/sd_0");
if (system("/bin/mount /dev/mmcblk0p1 /mnt/sd_0") &&
system("/bin/mount /dev/mmcblk0 /mnt/sd_0"))
{
return 0;
}

return 1;
}
@@ -57,10 +62,19 @@ int disk_mount_all(void)
int disk_unmount_all(void)
{
/* TODO: figure out actual block device */
system("umount /dev/mmcblk0p1 /mnt/sd_0");
system("umount /dev/mmcblk0 /mnt/sd_0");
if (!system("/bin/umount /dev/mmcblk0p1"))
{
sysfs_set_string("/sys/class/android_usb/android0/f_mass_storage/lun/file", "/dev/mmcblk0p1");
}
else if (!system("/bin/umount /dev/mmcblk0"))
{
sysfs_set_string("/sys/class/android_usb/android0/f_mass_storage/lun/file", "/dev/mmcblk0");
}
else
{
return 0;
}

sysfs_set_string("/sys/class/android_usb/android0/f_mass_storage/lun/file", "/dev/mmcblk0p1");
return 1;
}

0 comments on commit 8acd397

Please sign in to comment.
You can’t perform that action at this time.