From d2eaa38df0fa89c95793ebd026371a69bd7c87fa Mon Sep 17 00:00:00 2001 From: Mateusz Faderewski Date: Fri, 31 Mar 2023 22:04:58 +0200 Subject: [PATCH] Added support for SRAM 1M save type --- sw/bootloader/src/sc64.h | 3 ++- sw/controller/src/cfg.c | 3 +++ sw/controller/src/cfg.h | 3 ++- sw/controller/src/writeback.c | 5 +++++ sw/deployer/src/debug.rs | 5 ++++- sw/deployer/src/main.rs | 4 +++- sw/deployer/src/n64.rs | 4 ++-- sw/deployer/src/sc64/mod.rs | 13 ++++++++----- sw/deployer/src/sc64/{utils.rs => time.rs} | 0 sw/deployer/src/sc64/types.rs | 10 +++++++--- 10 files changed, 36 insertions(+), 14 deletions(-) rename sw/deployer/src/sc64/{utils.rs => time.rs} (100%) diff --git a/sw/bootloader/src/sc64.h b/sw/bootloader/src/sc64.h index ae47463..3502295 100644 --- a/sw/bootloader/src/sc64.h +++ b/sw/bootloader/src/sc64.h @@ -59,7 +59,8 @@ typedef enum { SAVE_TYPE_EEPROM_16K = 2, SAVE_TYPE_SRAM = 3, SAVE_TYPE_FLASHRAM = 4, - SAVE_TYPE_SRAM_BANKED = 5 + SAVE_TYPE_SRAM_BANKED = 5, + SAVE_TYPE_SRAM_1M = 6 } sc64_save_type_t; typedef enum { diff --git a/sw/controller/src/cfg.c b/sw/controller/src/cfg.c index 9806694..d8e04a1 100644 --- a/sw/controller/src/cfg.c +++ b/sw/controller/src/cfg.c @@ -210,6 +210,9 @@ static bool cfg_set_save_type (save_type_t save_type) { case SAVE_TYPE_SRAM_BANKED: cfg_change_scr_bits(CFG_SCR_SRAM_BANKED | CFG_SCR_SRAM_ENABLED, true); break; + case SAVE_TYPE_SRAM_1M: + cfg_change_scr_bits(CFG_SCR_SRAM_ENABLED, true); + break; default: save_type = SAVE_TYPE_NONE; break; diff --git a/sw/controller/src/cfg.h b/sw/controller/src/cfg.h index bd67d20..bc3611c 100644 --- a/sw/controller/src/cfg.h +++ b/sw/controller/src/cfg.h @@ -12,7 +12,8 @@ typedef enum { SAVE_TYPE_EEPROM_16K = 2, SAVE_TYPE_SRAM = 3, SAVE_TYPE_FLASHRAM = 4, - SAVE_TYPE_SRAM_BANKED = 5 + SAVE_TYPE_SRAM_BANKED = 5, + SAVE_TYPE_SRAM_1M = 6, } save_type_t; diff --git a/sw/controller/src/writeback.c b/sw/controller/src/writeback.c index 86c91c4..39ded8e 100644 --- a/sw/controller/src/writeback.c +++ b/sw/controller/src/writeback.c @@ -14,6 +14,7 @@ #define SRAM_LENGTH (32 * 1024) #define FLASHRAM_LENGTH (128 * 1024) #define SRAM_BANKED_LENGTH (3 * 32 * 1024) +#define SRAM_1M_LENGTH (128 * 1024) #define WRITEBACK_DELAY_TICKS (100) @@ -53,6 +54,10 @@ static save_type_t writeback_get_address_length (uint32_t *address, uint32_t *le *address = SRAM_FLASHRAM_ADDRESS; *length = SRAM_BANKED_LENGTH; break; + case SAVE_TYPE_SRAM_1M: + *address = SRAM_FLASHRAM_ADDRESS; + *length = SRAM_1M_LENGTH; + break; default: *address = 0; *length = 0; diff --git a/sw/deployer/src/debug.rs b/sw/deployer/src/debug.rs index 540a9bf..64280fc 100644 --- a/sw/deployer/src/debug.rs +++ b/sw/deployer/src/debug.rs @@ -7,6 +7,7 @@ use std::{ io::{stdin, ErrorKind, Read, Write}, net::{TcpListener, TcpStream}, panic, + path::PathBuf, sync::mpsc::{channel, Receiver, Sender}, thread::{sleep, spawn}, time::Duration, @@ -285,7 +286,9 @@ impl Handler { "save", match save_writeback.save { sc64::SaveType::Eeprom4k | sc64::SaveType::Eeprom16k => "eep", - sc64::SaveType::Sram | sc64::SaveType::SramBanked => "srm", + sc64::SaveType::Sram | sc64::SaveType::SramBanked | sc64::SaveType::Sram1m => { + "srm" + } sc64::SaveType::Flashram => "fla", _ => "sav", }, diff --git a/sw/deployer/src/main.rs b/sw/deployer/src/main.rs index a624455..998f888 100644 --- a/sw/deployer/src/main.rs +++ b/sw/deployer/src/main.rs @@ -217,6 +217,7 @@ enum SaveType { Eeprom16k, Sram, SramBanked, + Sram1m, Flashram, } @@ -228,8 +229,8 @@ impl From for SaveType { n64::SaveType::Eeprom16k => Self::Eeprom16k, n64::SaveType::Sram => Self::Sram, n64::SaveType::SramBanked => Self::SramBanked, + n64::SaveType::Sram1m => Self::Sram1m, n64::SaveType::Flashram => Self::Flashram, - n64::SaveType::Sram128kB => Self::Sram, } } } @@ -242,6 +243,7 @@ impl From for sc64::SaveType { SaveType::Eeprom16k => Self::Eeprom16k, SaveType::Sram => Self::Sram, SaveType::SramBanked => Self::SramBanked, + SaveType::Sram1m => Self::Sram1m, SaveType::Flashram => Self::Flashram, } } diff --git a/sw/deployer/src/n64.rs b/sw/deployer/src/n64.rs index 63537a6..aa8ff7d 100644 --- a/sw/deployer/src/n64.rs +++ b/sw/deployer/src/n64.rs @@ -10,7 +10,7 @@ pub enum SaveType { Sram, SramBanked, Flashram, - Sram128kB, + Sram1m, } const HASH_CHUNK_LENGTH: usize = 1 * 1024 * 1024; @@ -31,7 +31,7 @@ pub fn guess_save_type( 3 => SaveType::Sram, 4 => SaveType::SramBanked, 5 => SaveType::Flashram, - 6 => SaveType::Sram128kB, + 6 => SaveType::Sram1m, _ => SaveType::None, }, None, diff --git a/sw/deployer/src/sc64/mod.rs b/sw/deployer/src/sc64/mod.rs index 4353240..d4c7b13 100644 --- a/sw/deployer/src/sc64/mod.rs +++ b/sw/deployer/src/sc64/mod.rs @@ -3,8 +3,8 @@ mod error; pub mod firmware; mod link; mod server; +mod time; mod types; -mod utils; pub use self::{ error::Error, @@ -20,10 +20,10 @@ pub use self::{ use self::{ cic::{calculate_ipl3_checksum, guess_ipl3_seed, IPL3_LENGTH, IPL3_OFFSET}, link::{Command, Link}, + time::{convert_from_datetime, convert_to_datetime}, types::{ get_config, get_setting, Config, ConfigId, FirmwareStatus, Setting, SettingId, UpdateStatus, }, - utils::{convert_from_datetime, convert_to_datetime}, }; use chrono::{DateTime, Local}; use std::{ @@ -83,8 +83,9 @@ const EEPROM_ADDRESS: u32 = 0x0500_2000; const EEPROM_4K_LENGTH: usize = 512; const EEPROM_16K_LENGTH: usize = 2 * 1024; const SRAM_LENGTH: usize = 32 * 1024; -const SRAM_BANKED_LENGTH: usize = 3 * 32 * 1024; const FLASHRAM_LENGTH: usize = 128 * 1024; +const SRAM_BANKED_LENGTH: usize = 3 * 32 * 1024; +const SRAM_1M_LENGTH: usize = 128 * 1024; const BOOTLOADER_ADDRESS: u32 = 0x04E0_0000; @@ -450,8 +451,9 @@ impl SC64 { SaveType::Eeprom4k => (EEPROM_ADDRESS, EEPROM_4K_LENGTH), SaveType::Eeprom16k => (EEPROM_ADDRESS, EEPROM_16K_LENGTH), SaveType::Sram => (SAVE_ADDRESS, SRAM_LENGTH), - SaveType::SramBanked => (SAVE_ADDRESS, SRAM_BANKED_LENGTH), SaveType::Flashram => (SAVE_ADDRESS, FLASHRAM_LENGTH), + SaveType::SramBanked => (SAVE_ADDRESS, SRAM_BANKED_LENGTH), + SaveType::Sram1m => (SAVE_ADDRESS, SRAM_1M_LENGTH), }; if length != save_length { @@ -473,8 +475,9 @@ impl SC64 { SaveType::Eeprom4k => (EEPROM_ADDRESS, EEPROM_4K_LENGTH), SaveType::Eeprom16k => (EEPROM_ADDRESS, EEPROM_16K_LENGTH), SaveType::Sram => (SAVE_ADDRESS, SRAM_LENGTH), - SaveType::SramBanked => (SAVE_ADDRESS, SRAM_BANKED_LENGTH), SaveType::Flashram => (SAVE_ADDRESS, FLASHRAM_LENGTH), + SaveType::SramBanked => (SAVE_ADDRESS, SRAM_BANKED_LENGTH), + SaveType::Sram1m => (SAVE_ADDRESS, SRAM_1M_LENGTH), }; self.memory_read_chunked(writer, address, save_length) diff --git a/sw/deployer/src/sc64/utils.rs b/sw/deployer/src/sc64/time.rs similarity index 100% rename from sw/deployer/src/sc64/utils.rs rename to sw/deployer/src/sc64/time.rs diff --git a/sw/deployer/src/sc64/types.rs b/sw/deployer/src/sc64/types.rs index 22fd852..03f6b9a 100644 --- a/sw/deployer/src/sc64/types.rs +++ b/sw/deployer/src/sc64/types.rs @@ -253,6 +253,7 @@ pub enum SaveType { Sram, Flashram, SramBanked, + Sram1m, } impl Display for SaveType { @@ -261,9 +262,10 @@ impl Display for SaveType { Self::None => "None", Self::Eeprom4k => "EEPROM 4k", Self::Eeprom16k => "EEPROM 16k", - Self::Sram => "SRAM", - Self::SramBanked => "SRAM banked", - Self::Flashram => "FlashRAM", + Self::Sram => "SRAM 256k", + Self::SramBanked => "SRAM 768k", + Self::Flashram => "FlashRAM 1M", + Self::Sram1m => "SRAM 1M", }) } } @@ -278,6 +280,7 @@ impl TryFrom for SaveType { 3 => Self::Sram, 4 => Self::Flashram, 5 => Self::SramBanked, + 6 => Self::Sram1m, _ => return Err(Error::new("Unknown save type code")), }) } @@ -292,6 +295,7 @@ impl From for u32 { SaveType::Sram => 3, SaveType::Flashram => 4, SaveType::SramBanked => 5, + SaveType::Sram1m => 6, } } }