Nyx: emuMMC Manage window, Tools UI, and misc updates

- Add gui_emu_tools: emuMMC Manage window with correct positioning (LV_PROTECT_PARENT + re-parent to win)
- Tools: single SD button (tap = SD partition manager, 3s hold = eMMC)
- Remove emuSD from Nyx UI (tabs, UMS, partition manager); keep bootloader emusd
- Shorten Create emuMMC description text by one character
- Storage/build/config and dependency updates

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-02-20 20:49:48 +01:00
parent 4eead2c14d
commit fed7f05831
81 changed files with 6932 additions and 3462 deletions

View File

@@ -1,7 +1,7 @@
/*-----------------------------------------------------------------------*/
/* Low level disk I/O module skeleton for FatFs */
/* (C) ChaN, 2016 */
/* (C) CTCaer, 2018-2025 */
/* (C) CTCaer, 2018-2020 */
/*-----------------------------------------------------------------------*/
/* If a working storage control module is available, it should be */
/* attached to the FatFs via a glue function rather than modifying it. */
@@ -9,18 +9,113 @@
/* storage control modules to the FatFs module with a defined API. */
/*-----------------------------------------------------------------------*/
#include <storage/emmc.h>
#include <string.h>
#include <bdk.h>
#include <libs/fatfs/diskio.h> /* FatFs lower layer API */
#include <fatfs_cfg.h>
#include "../../storage/sfd.h"
static u32 sd_rsvd_sectors = 0;
static u32 ramdisk_sectors = 0;
static u32 bis_sectors = 0;
static u32 emummc_sectors = 0;
static u32 emummc_sectors = 0;
static u32 sfd_sectors = 0;
static bool bis_write_allowed = false;
static u32 cur_partition;
static void save_cur_partition(BYTE pdrv){
bool save = false;
switch(pdrv){
case DRIVE_BOOT1:
case DRIVE_BOOT1_1MB:
case DRIVE_EMMC:
save = true;
break;
case DRIVE_SD:
case DRIVE_RAM:
break;
case DRIVE_BIS:
case DRIVE_EMU:
if(nx_emmc_bis_get_storage() == &emmc_storage){
save = true;
}
break;
case DRIVE_SFD:
if(sfd_get_storage() == &emmc_storage){
save = true;
}
break;
default:
break;
}
if(save){
cur_partition = emmc_storage.partition;
}
}
static void restore_cur_partition(BYTE pdrv){
bool restore = false;
switch(pdrv){
case DRIVE_BOOT1:
case DRIVE_BOOT1_1MB:
case DRIVE_EMMC:
restore = true;
break;
case DRIVE_SD:
case DRIVE_RAM:
break;
case DRIVE_BIS:
case DRIVE_EMU:
if(nx_emmc_bis_get_storage() == &emmc_storage){
restore = true;
}
break;
case DRIVE_SFD:
if(sfd_get_storage() == &emmc_storage){
restore = true;
}
break;
default:
break;
}
if(restore){
if(emmc_storage.partition != cur_partition){
emmc_set_partition(cur_partition);
}
}
}
static bool ensure_partition(BYTE pdrv){
u8 part;
switch(pdrv){
case DRIVE_BOOT1:
case DRIVE_BOOT1_1MB:
part = EMMC_BOOT1;
break;
case DRIVE_EMMC:
part = EMMC_GPP;
break;
case DRIVE_SD:
case DRIVE_RAM:
return true;
case DRIVE_BIS:
case DRIVE_EMU:
case DRIVE_SFD:
return true;
default:
return false;
}
if(emmc_storage.partition != part){
return emmc_set_partition(part);
}
return true;
}
/*-----------------------------------------------------------------------*/
/* Get Drive Status */
@@ -52,20 +147,45 @@ DRESULT disk_read (
UINT count /* Number of sectors to read */
)
{
switch (pdrv)
{
case DRIVE_SD:
return sdmmc_storage_read(&sd_storage, sector, count, (void *)buff) ? RES_OK : RES_ERROR;
case DRIVE_RAM:
return ram_disk_read(sector, count, (void *)buff);
case DRIVE_EMMC:
return sdmmc_storage_read(&emmc_storage, sector, count, (void *)buff) ? RES_OK : RES_ERROR;
case DRIVE_BIS:
case DRIVE_EMU:
return nx_emmc_bis_read(sector, count, (void *)buff) ? RES_OK : RES_ERROR;
DRESULT res = RES_OK;
save_cur_partition(pdrv);
if(!ensure_partition(pdrv)){
res = RES_ERROR;
}
return RES_ERROR;
if(res == RES_OK){
switch (pdrv)
{
case DRIVE_SD:
res = sdmmc_storage_read(&sd_storage, sector, count, (void *)buff) ? RES_OK : RES_ERROR;
break;
case DRIVE_RAM:
res = ram_disk_read(sector, count, (void *)buff);
break;
case DRIVE_EMMC:
res = sdmmc_storage_read(&emmc_storage, sector, count, (void *)buff) ? RES_OK : RES_ERROR;
break;
case DRIVE_BIS:
case DRIVE_EMU:
res = nx_emmc_bis_read(sector, count, (void *)buff) ? RES_OK : RES_ERROR;
break;
case DRIVE_BOOT1_1MB:
res = sdmmc_storage_read(&emmc_storage, sector + (0x100000 / 512), count, buff) ? RES_OK : RES_ERROR;
break;
case DRIVE_BOOT1:
res = sdmmc_storage_read(&emmc_storage, sector, count, buff) ? RES_OK : RES_ERROR;
break;
case DRIVE_SFD:
res = sfd_read(sector, count, buff) ? RES_OK : RES_ERROR;
break;
}
}
restore_cur_partition(pdrv);
return res;
}
/*-----------------------------------------------------------------------*/
@@ -78,22 +198,47 @@ DRESULT disk_write (
UINT count /* Number of sectors to write */
)
{
switch (pdrv)
{
case DRIVE_SD:
return sdmmc_storage_write(&sd_storage, sector, count, (void *)buff) ? RES_OK : RES_ERROR;
case DRIVE_RAM:
return ram_disk_write(sector, count, (void *)buff);
case DRIVE_EMMC:
return RES_WRPRT;
case DRIVE_BIS:
case DRIVE_EMU:
if (pdrv == DRIVE_BIS && !bis_write_allowed)
return RES_WRPRT;
return nx_emmc_bis_write(sector, count, (void *)buff) ? RES_OK : RES_ERROR;
DRESULT res = RES_OK;
save_cur_partition(pdrv);
if(!ensure_partition(pdrv)){
res = RES_ERROR;
}
return RES_ERROR;
if(res == RES_OK){
switch (pdrv)
{
case DRIVE_SD:
res = sdmmc_storage_write(&sd_storage, sector, count, (void *)buff) ? RES_OK : RES_ERROR;
break;
case DRIVE_RAM:
res = ram_disk_write(sector, count, (void *)buff);
break;
case DRIVE_EMMC:
res = sdmmc_storage_write(&emmc_storage, sector, count, (void*)buff) ? RES_OK : RES_ERROR;
break;
case DRIVE_BIS:
res = RES_WRPRT;
break;
case DRIVE_EMU:
res = nx_emmc_bis_write(sector, count, (void *)buff) ? RES_OK : RES_ERROR;
break;
case DRIVE_BOOT1_1MB:
res = sdmmc_storage_write(&emmc_storage, sector + (0x100000 / 512), count, (void*)buff) ? RES_OK : RES_ERROR;
break;
case DRIVE_BOOT1:
res = sdmmc_storage_write(&emmc_storage, sector, count, (void*)buff) ? RES_OK : RES_ERROR;
break;
case DRIVE_SFD:
res = sfd_write(sector, count, (void*)buff) ? RES_OK : RES_ERROR;
break;
}
}
restore_cur_partition(pdrv);
return res;
}
/*-----------------------------------------------------------------------*/
@@ -107,9 +252,8 @@ DRESULT disk_ioctl (
{
DWORD *buf = (DWORD *)buff;
switch (pdrv)
if (pdrv == DRIVE_SD)
{
case DRIVE_SD:
switch (cmd)
{
case GET_SECTOR_COUNT:
@@ -119,9 +263,9 @@ DRESULT disk_ioctl (
*buf = 32768; // Align to 16MB.
break;
}
break;
case DRIVE_RAM:
}
else if (pdrv == DRIVE_RAM)
{
switch (cmd)
{
case GET_SECTOR_COUNT:
@@ -131,33 +275,29 @@ DRESULT disk_ioctl (
*buf = 2048; // Align to 1MB.
break;
}
break;
case DRIVE_BIS:
switch (cmd)
{
case GET_SECTOR_COUNT:
*buf = bis_sectors;
break;
case GET_BLOCK_SIZE:
*buf = 32768; // Align to 16MB.
break;
}
break;
case DRIVE_EMU:
}
else if (pdrv == DRIVE_EMU)
{
switch (cmd)
{
case GET_SECTOR_COUNT:
*buf = emummc_sectors;
break;
case GET_BLOCK_SIZE:
*buf = 16384; // Align to 8MB (With BOOT0/1 data will be at 16MB BU).
*buf = 32768; // Align to 16MB.
break;
}
break;
default: // Catch all for unknown devices.
}else if(pdrv == DRIVE_SFD){
switch(cmd){
case GET_SECTOR_COUNT:
*buf = sfd_sectors;
break;
case GET_BLOCK_SIZE:
*buf = 32768;
break;
}
}else // Catch all for unknown devices.
{
switch (cmd)
{
case CTRL_SYNC:
@@ -167,7 +307,6 @@ DRESULT disk_ioctl (
*buf = 0; // Zero value to force default or abort.
break;
}
break;
}
return RES_OK;
@@ -188,22 +327,17 @@ DRESULT disk_set_info (
case DRIVE_SD:
sd_rsvd_sectors = *buf;
break;
case DRIVE_RAM:
ramdisk_sectors = *buf;
break;
case DRIVE_BIS:
bis_sectors = *buf;
break;
case DRIVE_EMU:
emummc_sectors = *buf;
break;
case DRIVE_SFD:
sfd_sectors = *buf;
break;
}
}
else if (cmd == SET_WRITE_PROTECT && pdrv == DRIVE_BIS)
bis_write_allowed = *(bool *)buff;
return RES_OK;
}