Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix wrong dongle_id check. Add define (DEBUG) to save dongle_id, jig_…

…response and jig_challenge.
  • Loading branch information...
commit bafad614569647276c166c491c292932c6721971 1 parent c6fffc8
@Noltari authored
Showing with 44 additions and 18 deletions.
  1. +26 −0 Makefile
  2. +17 −16 main.c
  3. +1 −2  usb_desc.h
View
26 Makefile
@@ -4,6 +4,7 @@ CCS_FLAGS_NBL = +FH +Y9 -T -L -E -M -P -J -D -A
CCS_FLAGS_WBLHID = $(CCS_FLAGS_NBL) +GWBOOTLOADERHID="true"
CCS_FLAGS_WBLMCHP = $(CCS_FLAGS_NBL) +GWBOOTLOADERMCHP="true"
CCS_FLAGS_LEDS = +GLEDR1="PIN_B4" +GLEDR2="PIN_B1" +GLEDR3="PIN_C0" +GLEDG1="PIN_B5" +GLEDG2="PIN_C1"
+CCS_FLAGS_DEBUG = +GDEBUG="true"
ZIP = zip -r
BUILD_DIR = build
CLEAN_FILES = *.err *.esym *.cod *.sym *.hex *.lst *.zip $(BUILD_DIR)
@@ -35,6 +36,31 @@ all:
mv build/PSGradePIC_$(VERSION).zip ./
rm -f -r $(BUILD_DIR)
+debug:
+ #HEX with HID Bootloader.
+ $(CCS_COMPILER) $(CCS_FLAGS_WBLHID) $(CCS_FLAGS_LEDS) $(CCS_SOURCE) $(CCS_FLAGS_DEBUG)
+
+ #HEX with MCHP Bootloader.
+ $(CCS_COMPILER) $(CCS_FLAGS_WBLMCHP) $(CCS_FLAGS_LEDS) $(CCS_SOURCE) $(CCS_FLAGS_DEBUG)
+
+ #HEX without Bootloader.
+ $(CCS_COMPILER) $(CCS_FLAGS_NBL) $(CCS_FLAGS_LEDS) $(CCS_SOURCE) $(CCS_FLAGS_DEBUG)
+
+ #Create build structure.
+ rm -f -r $(BUILD_DIR)
+ mkdir $(BUILD_DIR);
+
+ #Fix MCHP Bootloader
+ sed -i '1i :020000040000FA..' PSGradePIC*_wBTL_MCHP.hex
+
+ #Move each payload to its directory.
+ mv PSGradePIC*.hex $(BUILD_DIR);
+
+ #Zip all HEX.
+ cd $(BUILD_DIR) && $(ZIP) "PSGradePIC_$(VERSION)_DEBUG" *
+ mv build/PSGradePIC_$(VERSION)_DEBUG.zip ./
+ rm -f -r $(BUILD_DIR)
+
clean:
#Clean files.
rm -f -r $(CLEAN_FILES)
View
33 main.c
@@ -262,7 +262,7 @@ void main() {
//Check dongle_id. If it should be revoked a new one is generated.
int i;
for(i = 0; i < sizeof(usb_dongle_revoke_list); i++) {
- if(usb_dongle_revoke_list[i] == (((dongle_id[0] << 8) & 0xFF) & (dongle_id[1] & 0xFF)) ) {
+ if(usb_dongle_revoke_list[i] == (((dongle_id[0] << 8) & 0xFF00) ^ (dongle_id[1] & 0xFF)) ) {
i = 0;
dongle_id[0] = rand();
dongle_id[1] = rand();
@@ -286,27 +286,28 @@ void main() {
HMACDone();
SHA1MemCpy(usb_dongle_key, SHA1_DIGESTSIZE);
- //Uncomment this to save the usb_dongle_key for the random dongle_id generated (EEPROM). Only for dev purposes :). Use USB HID Bootloader 2.6b Read funcntion to dump EEPROM.
- /*
+ //Generate jig_response.
+ HMACInit(usb_dongle_key, SHA1_DIGESTSIZE);
+ HMACBlock(jig_challenge + JIG_DATA_HEADER_LEN, SHA1_DIGESTSIZE);
+ HMACDone();
+ SHA1MemCpy(jig_response + JIG_DATA_HEADER_LEN + sizeof(dongle_id), SHA1_DIGESTSIZE);
+
+ #if defined (DEBUG)
+ //Save the usb_dongle_key for the random dongle_id generated (EEPROM). Only for dev purposes :). Use USB HID Bootloader 2.6b Read funcntion to dump EEPROM.
write_eeprom(0x00, dongle_id[0]);
write_eeprom(0x01, dongle_id[1]);
for(i = 0; i < sizeof(usb_dongle_key); i++) {
- write_eeprom(0x10 + i, usb_dongle_key[i]);
+ write_eeprom(0x20 + i, usb_dongle_key[i]);
}
- */
-
- //Uncomment this to save the jig_challenge generated by the PS3. Only for dev purposes :). Use USB HID Bootloader 2.6b Read funcntion to dump EEPROM.
- /*
+ //Save the jig_challenge generated by the PS3. Only for dev purposes :). Use USB HID Bootloader 2.6b Read funcntion to dump EEPROM.
for(i = 0; i < sizeof(jig_challenge); i++) {
- write_eeprom(0x30 + i, jig_challenge[i]);
+ write_eeprom(0x50 + i, jig_challenge[i]);
}
- */
-
- //Generate jig_response.
- HMACInit(usb_dongle_key, SHA1_DIGESTSIZE);
- HMACBlock(jig_challenge + JIG_DATA_HEADER_LEN, SHA1_DIGESTSIZE);
- HMACDone();
- SHA1MemCpy(jig_response + JIG_DATA_HEADER_LEN + sizeof(dongle_id), SHA1_DIGESTSIZE);
+ //Save the jig_response generated by the dongle. Only for dev purposes :). Use USB HID Bootloader 2.6b Read funcntion to dump EEPROM.
+ for(i = 0; i < sizeof(jig_response); i++) {
+ write_eeprom(0xA0 + i, jig_response[i]);
+ }
+ #endif
nJigs = 0;
WaitJig = 2;
View
3  usb_desc.h
@@ -14,7 +14,6 @@
const unsigned int8 USB_DEVICE_DESC[] = {
//HUB_DEVICE
0x12, 0x01, 0x00, 0x02, 0x09, 0x00, 0x01, 0x08,
- //0xe3, 0x05, 0x08, 0x06, 0x64, 0x77, 0x00, 0x01,
0xAA, 0xAA, 0xCC, 0xCC, 0x00, 0x01, 0x00, 0x00,
0x00, 0x01,
//HUB_HUB_DEVICE
@@ -63,7 +62,7 @@ static unsigned int8 jig_response[64];
#define PORT5_DEVICE_SIZE 0x0012
#define HUB_DEVICE_OFFSET 0x0000
-#define HUB_HUB_DEVICE_OFFSET HUB_DEVICE_SIZE
+#define HUB_HUB_DEVICE_OFFSET HUB_DEVICE_SIZE
#define PORT5_DEVICE_OFFSET HUB_HUB_DEVICE_OFFSET + HUB_HUB_DEVICE_SIZE
#define HUB_CONFIG_SIZE 0x0019
Please sign in to comment.
Something went wrong with that request. Please try again.