opened
bentiss
username_0
Fixes both #280 and #122 (hopefully).

This is the first step required before we are finally able to write macros on the device.
The "new" memory API only allows full sectors to be read/written. This ensures we always write the crc and check for it.

Also, now we better detect if the device is using factory profiles or not (see #280).

I still haven't yet implemented caching for the memory. This will be required for macros and to speed up a little bit the parsing of the device.

Please test!

Note: I also quickly wrote a tool to reset the memory to 0x00. This is hopefully the factory default (can't remember if this is true or not).
hidpp20 memory rework
issue
created
SonicFrog
username_1
I've done some quick testing. 
This new memory model works fine with the G900 as far as I can tell.
There are still a few problems though:

- It doesn't handle sector sizes that are not multiple of 16 (as the G603 has)
- It fails to commit changes for the G502 as mentionned in #280 

I have a fix in the works for the first of these, and I can see what's the problem exactly with the G502 next week.
comment
created
bentiss
username_0
If you happen to have access to a G502 in the stock factory settings, could you run `./build/hidpp20-dump-page /dev/hidrawX` with `hidrawX` being the hidraw node given from the dmesg?

This way, I can reflash the device into the factory default and test this.

Locally, if I reset the memory to 0x00 with the new nuclear tool, it doesn't export the error on my G502.
comment
created
SonicFrog
username_1
Looks like the flash is already all zeroes. I attached the ROM dump, should be the factory defaults.
[g502romdump.txt](https://github.com/libratbag/libratbag/files/1284993/g502romdump.txt)
comment
created
bentiss
username_0
Then in that case I do not understand what is going on. It works for me if I reset the flash with 0.

The bug in #280 is that the firmware sees that the dictionary is invalid (error 02), which is true because we used to write all profiles as disabled. Now, at least locally, the dictionary should be a rewrite of the ROM one, in which all 3 profiles are enabled.
comment
created
SonicFrog
username_1
Well after writing the ROM content on the flash with a correct dictionary it seems to work fine... Dunno what happened there. I still get some ERR_INVALID_ARGUMENT from hidpp20-dump-page though.
comment
created
SonicFrog
username_1
Looks good to me! I've done some testing with a few more models and all seem to work fine!
comment
created
bentiss
username_0
Thanks both of you. I am fixing the two nitpicks and will merge in a few
comment