This also fixes#958
Original commits:
* initial work on cart save crypto/wearleveling
* add support for n3ds only save crypto
* use existing crc16 impl for save blockmap
* fix missing aeskey select for card2 save decrypt
* fix old/new cart media being swapped
* fix 1 MiB save chips / blockmap type 2
* move cart save wearleveling/crypto to separate file
* try 2nd wearlevel header on fail + minor fixes
* save_ctr: zero out savectx before reading fallback header
* Add i2c read support to lua
* Add i2c write support to lua
With memory permissions before write
* Adjust i2c write
* Fix inverted id check, better permissions
* Change write to not return anything on success
* Add some documentation for lua i2c
* Change write length from 1024 to 64
* Add whitelist for i2c writing
* Move i2c module into preload
* Add registers and bitmasks for mcu
Add documentation to lua-doc
* Fix missing column divider in lua-doc
* Add ~= 0 then to lua example
* Add some more registers
* Add cart_id2 to gamecart.h
This prepares changes to fix private header dumps.
The name ID2 matches Lotus3 (see Switchbrew) since it's evident Lotus3 is just a continuation of the 3DS cart controller
* Add Cart_GetID2() to protocol.h
This prepares changes to fix private header dumps.
The name ID2 matches Lotus3 (see Switchbrew) since it's evident Lotus3 is just a continuation of the 3DS cart controller.
* gc protocol: Add support to get ID2
This renames the unknowna0_cmd to its proper name and the A0_Response to CartID2, matching Lotus3 terminology.
* Store ID2 in private header at +0x44
The ID2 contains important information that in particular determines the cryptographic keys used. It is impossible to decrypt a dump of cart<->controller communications without knowing the ID2 or trying all possible keys.
This behavior matches Gateway. I suppose that it was presumed that Gateway would always store zeroes there because regular cartridges on retail would always report zero and then everybody just copied this false assumption.
* fix build (gamecart.c): memset->memcpy
* fix build (protocol.c): Fix dupe definition of Cart_GetID()
* Add gyro model detection
* Add gyro detection to sysinfo
* Add gyro model as lua global
* Normalize line endings to LF
* Add documentation, add var to gm9 script, change model to start at 1
* Scripting: Normalize output of FormatBytes
* lua: Add flag to use locale when formatting bytes
Co-Authored-By: ihaveahax <ian@ianburgwin.net>
---------
Co-authored-by: ihaveahax <ian@ianburgwin.net>
* lua-doc: Fix fs.find_all documentation
It returns an array, not a string. Also document return information.
* lua-doc: Remove TODO for fs.verify_with_sha_file
No reason to add fs.read_file errors here as that function gets
pcall-ed. If it fails, nil gets returned.
* lua-doc: Consistently refer to tables/arrays as tables
That's what they're called within Lua all the time.
* lua-doc: fix incorrect references to util module
string.find has pattern matching by default, so it was incorrectly
reading "r+" when the mode was supposed to be "r". So this disables the
pattern matching and does a plain substring search.