[SC64][SW] Added option for setting CIC parameters through sc64.py script

This commit is contained in:
Mateusz Faderewski 2023-02-06 20:48:44 +01:00
parent 1531278379
commit 5d4f3be619
4 changed files with 18 additions and 6 deletions

View File

@ -8,7 +8,7 @@
| --- | ---------------------- | ------------ | ------------ | ---- | ---------------- | --------------------------------------------------- | | --- | ---------------------- | ------------ | ------------ | ---- | ---------------- | --------------------------------------------------- |
| `v` | **VERSION_GET** | --- | --- | --- | api_version | Get command API version | | `v` | **VERSION_GET** | --- | --- | --- | api_version | Get command API version |
| `R` | **STATE_RESET** | --- | --- | --- | --- | Reset entire flashcart state | | `R` | **STATE_RESET** | --- | --- | --- | --- | Reset entire flashcart state |
| `B` | **CIC_PARAMS_SET** | cic_params_0 | cic_params_1 | --- | --- | Set CIC mode/seed/version/checksum | | `B` | **CIC_PARAMS_SET** | cic_params_0 | cic_params_1 | --- | --- | Set CIC disable/mode/seed/checksum |
| `c` | **CONFIG_GET** | config_id | --- | --- | current_value | Get config option | | `c` | **CONFIG_GET** | config_id | --- | --- | current_value | Get config option |
| `C` | **CONFIG_SET** | config_id | new_value | --- | --- | Set config option | | `C` | **CONFIG_SET** | config_id | new_value | --- | --- | Set config option |
| `t` | **TIME_GET** | --- | --- | --- | time | Get current RTC value | | `t` | **TIME_GET** | --- | --- | --- | time | Get current RTC value |

View File

@ -138,11 +138,10 @@ Any successful write to this config will disable automatic save writeback to SD
type: *word* | default: `0xFFFF` type: *word* | default: `0xFFFF`
- `0x0000` to `0x01FF` - Specified CIC seed/version value will be used - `0x0000` to `0x00FF` - Specified CIC seed value will be used
- `0xFFFF` - CIC seed/version value will be autodetected - `0xFFFF` - CIC seed value will be autodetected
Use this setting to force specific CIC seed/version. Use this setting to force specific CIC seed.
Lower 8 bits represents CIC seed and 9th bit represents CIC version.
By setting value `0xFFFF` bootloader will try to guess needed values from loaded ROM IPL3. By setting value `0xFFFF` bootloader will try to guess needed values from loaded ROM IPL3.
This setting is not used when **BOOT_MODE** is set to `3` (direct boot). This setting is not used when **BOOT_MODE** is set to `3` (direct boot).

View File

@ -320,7 +320,7 @@ bool cfg_update (uint32_t *args) {
return cfg_set_save_type((save_type_t) (args[1])); return cfg_set_save_type((save_type_t) (args[1]));
break; break;
case CFG_ID_CIC_SEED: case CFG_ID_CIC_SEED:
if ((args[1] != 0xFFFF) && (args[1] > 0x1FF)) { if ((args[1] != 0xFFFF) && (args[1] > 0xFF)) {
return true; return true;
} }
p.cic_seed = (cic_seed_t) (args[1] & 0xFFFF); p.cic_seed = (cic_seed_t) (args[1] & 0xFFFF);

View File

@ -750,6 +750,7 @@ if __name__ == '__main__':
parser.add_argument('--boot', type=SC64.BootMode, action=EnumAction, help='set boot mode') parser.add_argument('--boot', type=SC64.BootMode, action=EnumAction, help='set boot mode')
parser.add_argument('--tv', type=SC64.TVType, action=EnumAction, help='force TV type to set value') parser.add_argument('--tv', type=SC64.TVType, action=EnumAction, help='force TV type to set value')
parser.add_argument('--cic', type=SC64.CICSeed, action=EnumAction, help='force CIC seed to set value') parser.add_argument('--cic', type=SC64.CICSeed, action=EnumAction, help='force CIC seed to set value')
parser.add_argument('--cic-params', metavar='disabled,dd_mode,seed,checksum', help='set CIC emulation parameters')
parser.add_argument('--rtc', action='store_true', help='update clock in SC64 to system time') parser.add_argument('--rtc', action='store_true', help='update clock in SC64 to system time')
parser.add_argument('--no-shadow', action='store_false', help='do not put last 128 kB of ROM inside flash memory (can corrupt non EEPROM saves)') parser.add_argument('--no-shadow', action='store_false', help='do not put last 128 kB of ROM inside flash memory (can corrupt non EEPROM saves)')
parser.add_argument('--rom', metavar='file', help='upload ROM from specified file') parser.add_argument('--rom', metavar='file', help='upload ROM from specified file')
@ -841,6 +842,18 @@ if __name__ == '__main__':
sc64.upload_ddipl(f.read()) sc64.upload_ddipl(f.read())
print('done') print('done')
if (args.cic_params != None):
# TODO: calculate checksum in script
params = args.cic_params.split(',')
if (len(params) != 4):
raise ValueError('Incorrect number of CIC parameters')
disabled = (params[0] != '0')
dd_mode = (params[1] != '0')
seed = int(params[2])
checksum = int(params[3]).to_bytes(6, byteorder='big', signed=False)
sc64.set_cic_parameters(disabled, dd_mode, seed, checksum)
print(f'CIC parameters set to [{"DISABLED, " if disabled else ""}{"DDIPL" if dd_mode else "ROM"}, seed: 0x{seed:02X}, checksum: 0x{int(params[3]):12X}]')
if (args.debug): if (args.debug):
sc64.debug_loop(isv=args.isv, disks=args.disk) sc64.debug_loop(isv=args.isv, disks=args.disk)