mirror of
https://github.com/Team-Resurgent/XboxMemCard.git
synced 2026-08-15 11:18:05 -07:00
enable sd card
This commit is contained in:
+2
-72
@@ -62,84 +62,14 @@ uint64_t flash_get_capcity()
|
||||
uint8_t txbuf[STORAGE_CMD_TOTAL_BYTES] = {0x9f};
|
||||
uint8_t rxbuf[STORAGE_CMD_TOTAL_BYTES] = {0};
|
||||
flash_do_cmd(txbuf, rxbuf, STORAGE_CMD_TOTAL_BYTES);
|
||||
capacity = (1 << rxbuf[3]) - (256 * 1024);
|
||||
printf("Flash Manufacturer %02x, Type %02x, CapacityCode %02x\n", rxbuf[0], rxbuf[1], rxbuf[2], rxbuf[3]);
|
||||
capacity = (1ULL << rxbuf[3]) - (256 * 1024);
|
||||
}
|
||||
return capacity;
|
||||
}
|
||||
|
||||
bool flash_init()
|
||||
{
|
||||
|
||||
// static uint8_t msc_disk0[DISK_BLOCK_NUM2][DISK_BLOCK_SIZE2] =
|
||||
// {
|
||||
// //------------- Block0: Boot Sector -------------//
|
||||
// // byte_per_sector = DISK_BLOCK_SIZE; fat12_sector_num_16 = DISK_BLOCK_NUM;
|
||||
// // sector_per_cluster = 1; reserved_sectors = 1;
|
||||
// // fat_num = 1; fat12_root_entry_num = 16;
|
||||
// // sector_per_fat = 1; sector_per_track = 1; head_num = 1; hidden_sectors = 0;
|
||||
// // drive_number = 0x80; media_type = 0xf8; extended_boot_signature = 0x29;
|
||||
// // filesystem_type = "FAT12 "; volume_serial_number = 0x1234; volume_label = "TinyUSB 0 ";
|
||||
// // FAT magic code at offset 510-511
|
||||
// {
|
||||
// 0xEB, 0x3C, 0x90, 0x4D, 0x53, 0x44, 0x4F, 0x53, 0x35, 0x2E, 0x30, 0x00, 0x02, 0x01, 0x01, 0x00,
|
||||
// 0x01, 0x10, 0x00, 0x10, 0x00, 0xF8, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x29, 0x34, 0x12, 0x00, 0x00, 'T' , 'i' , 'n' , 'y' , 'U' ,
|
||||
// 'S' , 'B' , ' ' , 'C' , ' ' , ' ' , 0x46, 0x41, 0x54, 0x31, 0x32, 0x20, 0x20, 0x20, 0x00, 0x00,
|
||||
|
||||
// // Zero up to 2 last bytes of FAT magic code
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xAA
|
||||
// },
|
||||
|
||||
// //------------- Block1: FAT12 Table -------------//
|
||||
// {
|
||||
// 0xF8, 0xFF, 0xFF, 0xFF, 0x0F // // first 2 entries must be F8FF, third entry is cluster end of readme file
|
||||
// },
|
||||
|
||||
// //------------- Block2: Root Directory -------------//
|
||||
// {
|
||||
// // first entry is volume label
|
||||
// 'X' , 'b' , 'o' , 'x' , 'C' , 'a' , 'r' , 'd' , ' ' , ' ' , ' ' , 0x08, 0x00, 0x00, 0x00, 0x00,
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0x6D, 0x65, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// // second entry is our file
|
||||
// 'I' , 'N' , 'D' , 'E' , 'X' , ' ' , ' ' , ' ' , 'H' , 'T' , 'M' , 0x20, 0x00, 0xC6, 0x52, 0x6D,
|
||||
// 0x65, 0x43, 0x65, 0x43, 0x00, 0x00, 0x88, 0x6D, 0x65, 0x43, 0x02, 0x00,
|
||||
// sizeof(INDEX_CONTENTS2)-1, 0x00, 0x00, 0x00 // readme's files size (4 Bytes)
|
||||
// },
|
||||
|
||||
// //------------- Block3: file Content -------------//
|
||||
// INDEX_CONTENTS2
|
||||
// };
|
||||
|
||||
#if CONFIG_TYPE == 1 // xboxog
|
||||
|
||||
if (flash_target_contents[0] != 0x46 || flash_target_contents[1] != 0x41 || flash_target_contents[2] != 0x54 || flash_target_contents[3] != 0x58)
|
||||
|
||||
@@ -45,21 +45,20 @@ void core1_entry()
|
||||
// }
|
||||
}
|
||||
|
||||
// flash_get_unique_id
|
||||
|
||||
int main(void)
|
||||
{
|
||||
stdio_init_all();
|
||||
|
||||
//sleep_ms(2000);
|
||||
|
||||
|
||||
//multicore_launch_core1(core1_entry);
|
||||
|
||||
gpio_init(PICO_DEFAULT_LED_PIN);
|
||||
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
||||
|
||||
#if CONFIG_TYPE == 1 || CONFIG_TYPE == 2
|
||||
flash_init();
|
||||
//sd_card_init();
|
||||
#elif CONFIG_TYPE == 3
|
||||
sd_card_init();
|
||||
#endif
|
||||
|
||||
tusb_init();
|
||||
|
||||
@@ -70,6 +69,4 @@ int main(void)
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// https://github.com/Ryzee119/ogx360_t4/blob/be37b41775778137f6e1918245771dc31b6afea9/src/xmu.cpp
|
||||
}
|
||||
+14
-3
@@ -141,8 +141,13 @@ void tud_msc_capacity_cb(uint8_t lun, uint32_t* block_count, uint16_t* block_siz
|
||||
{
|
||||
(void) lun;
|
||||
|
||||
#if CONFIG_TYPE == 1 || CONFIG_TYPE == 2
|
||||
const uint32_t STORAGE_BLOCKS = flash_get_capcity() >> XMU_SECTOR_SHIFT;
|
||||
//const uint32_t STORAGE_BLOCKS = sd_card_get_capcity() >> XMU_SECTOR_SHIFT;
|
||||
#elif CONFIG_TYPE == 3
|
||||
const uint32_t STORAGE_BLOCKS = sd_card_get_capcity() >> XMU_SECTOR_SHIFT;
|
||||
#endif
|
||||
|
||||
sleep_ms(2000);
|
||||
|
||||
*block_count = STORAGE_BLOCKS;
|
||||
*block_size = XMU_SECTOR_SIZE;
|
||||
@@ -174,8 +179,11 @@ bool tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, boo
|
||||
// Copy disk's data to buffer (up to bufsize) and return number of copied bytes.
|
||||
int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize)
|
||||
{
|
||||
#if CONFIG_TYPE == 1 || CONFIG_TYPE == 2
|
||||
const uint32_t STORAGE_BLOCKS = flash_get_capcity() >> XMU_SECTOR_SHIFT;
|
||||
//const uint32_t STORAGE_BLOCKS = sd_card_get_capcity() >> XMU_SECTOR_SHIFT;
|
||||
#elif CONFIG_TYPE == 3
|
||||
const uint32_t STORAGE_BLOCKS = sd_card_get_capcity() >> XMU_SECTOR_SHIFT;
|
||||
#endif
|
||||
|
||||
if ( lba >= STORAGE_BLOCKS ) return -1;
|
||||
|
||||
@@ -203,8 +211,11 @@ bool tud_msc_is_writable_cb (uint8_t lun)
|
||||
// Process data in buffer to disk's storage and return number of written bytes
|
||||
int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t* buffer, uint32_t bufsize)
|
||||
{
|
||||
#if CONFIG_TYPE == 1 || CONFIG_TYPE == 2
|
||||
const uint32_t STORAGE_BLOCKS = flash_get_capcity() >> XMU_SECTOR_SHIFT;
|
||||
//const uint32_t STORAGE_BLOCKS = sd_card_get_capcity() >> XMU_SECTOR_SHIFT;
|
||||
#elif CONFIG_TYPE == 3
|
||||
const uint32_t STORAGE_BLOCKS = sd_card_get_capcity() >> XMU_SECTOR_SHIFT;
|
||||
#endif
|
||||
|
||||
// out of ramdisk
|
||||
if ( lba >= STORAGE_BLOCKS ) return -1;
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ bool sd_card_init()
|
||||
return false;
|
||||
}
|
||||
|
||||
result = f_open(&sd_card_mounted_file, "0:\\XboxMu.iso", FA_OPEN_EXISTING | FA_READ | FA_WRITE);
|
||||
result = f_open(&sd_card_mounted_file, "0:\\Image.bin", FA_OPEN_EXISTING | FA_READ | FA_WRITE);
|
||||
if (result != FR_OK)
|
||||
{
|
||||
f_unmount(sd_card->pcName);
|
||||
|
||||
Reference in New Issue
Block a user