summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjaseg <git@jaseg.net>2018-11-12 12:48:47 +0900
committerjaseg <git@jaseg.net>2018-11-12 12:48:47 +0900
commit70d8dcb6f6eaffd0c5717ffdca24ebc25a3b8de2 (patch)
tree8c6e1e1a0e338288aaa00acf68676591d8f784c9
parent2f4f3e13aa6a6dbbb5a45e02b792eb935e91c766 (diff)
downloadsecure-hid-70d8dcb6f6eaffd0c5717ffdca24ebc25a3b8de2.tar.gz
secure-hid-70d8dcb6f6eaffd0c5717ffdca24ebc25a3b8de2.tar.bz2
secure-hid-70d8dcb6f6eaffd0c5717ffdca24ebc25a3b8de2.zip
Confirmed pairing works
-rw-r--r--adjectives.py260
-rwxr-xr-xhexnoise.py20
-rw-r--r--nouns.py260
-rw-r--r--src/demo.c27
-rw-r--r--src/hid_keycodes.c56
-rw-r--r--src/hid_keycodes.h2
-rw-r--r--src/noise.c1
-rw-r--r--src/usbh_driver_hid.c6
-rw-r--r--src/usbh_lld_stm32f4.c52
9 files changed, 616 insertions, 68 deletions
diff --git a/adjectives.py b/adjectives.py
new file mode 100644
index 0000000..78641ce
--- /dev/null
+++ b/adjectives.py
@@ -0,0 +1,260 @@
+
+ADJECTIVES = [
+ "wrathful", # 0
+ "worthy", # 1
+ "weird", # 2
+ "warm", # 3
+ "volatile", # 4
+ "veiled", # 5
+ "vacuous", # 6
+ "useless", # 7
+ "upset", # 8
+ "unsoiled", # 9
+ "unsightly", # 10
+ "unpronounceable", # 11
+ "unfriendly", # 12
+ "unfree", # 13
+ "unfit", # 14
+ "unfaithful", # 15
+ "unchaste", # 16
+ "unbroken", # 17
+ "unbound", # 18
+ "unblessed", # 19
+ "unbefitting", # 20
+ "unaltered", # 21
+ "unabused", # 22
+ "unable", # 23
+ "ugly", # 24
+ "tongued", # 25
+ "thorny", # 26
+ "thirsty", # 27
+ "thick", # 28
+ "terminal", # 29
+ "ten-sided", # 30
+ "teeming", # 31
+ "tangerine", # 32
+ "taken", # 33
+ "substantial", # 34
+ "stupefying", # 35
+ "stringy", # 36
+ "strange", # 37
+ "stillborn", # 38
+ "sticky", # 39
+ "stagnant", # 40
+ "spongy", # 41
+ "sour", # 42
+ "soul-destroying", # 43
+ "smoldering", # 44
+ "smitten", # 45
+ "slain", # 46
+ "six-sided", # 47
+ "shifting", # 48
+ "shadowy", # 49
+ "severed", # 50
+ "seven-sided", # 51
+ "serene", # 52
+ "salty", # 53
+ "rust-red", # 54
+ "royal", # 55
+ "rotten", # 56
+ "riddled", # 57
+ "resentful", # 58
+ "regrettable", # 59
+ "reeking", # 60
+ "rare", # 61
+ "rank", # 62
+ "rancid", # 63
+ "quiescent", # 64
+ "putrid", # 65
+ "putrid", # 66
+ "putrescent", # 67
+ "prehistoric", # 68
+ "predatory", # 69
+ "predaceous", # 70
+ "porous", # 71
+ "poisonous", # 72
+ "pierced", # 73
+ "phlegmatic", # 74
+ "petrifying", # 75
+ "pessimal", # 76
+ "pathetic", # 77
+ "odorless", # 78
+ "oddish", # 79
+ "obsessed", # 80
+ "obscene", # 81
+ "numb", # 82
+ "nine-sided", # 83
+ "nasty", # 84
+ "mysterious", # 85
+ "mute", # 86
+ "musky", # 87
+ "morose", # 88
+ "moribund", # 89
+ "moldy", # 90
+ "miasmic", # 91
+ "material", # 92
+ "many-lobed", # 93
+ "malodorous", # 94
+ "malign", # 95
+ "maimed", # 96
+ "luminescent", # 97
+ "low-cut", # 98
+ "lousy", # 99
+ "live", # 100
+ "limp", # 101
+ "lifeless", # 102
+ "leering", # 103
+ "leaky", # 104
+ "layered", # 105
+ "latent", # 106
+ "lackluster", # 107
+ "jagged", # 108
+ "irregular", # 109
+ "iridescent", # 110
+ "intangible", # 111
+ "infinite", # 112
+ "inept", # 113
+ "incomprehensible", # 114
+ "in-between", # 115
+ "improper", # 116
+ "idle", # 117
+ "hunted", # 118
+ "hideous", # 119
+ "heavy", # 120
+ "hairy", # 121
+ "guilty", # 122
+ "grotesque", # 123
+ "grey", # 124
+ "greedy", # 125
+ "gory", # 126
+ "gorgeous", # 127
+ "gooey", # 128
+ "golden-brown", # 129
+ "golden", # 130
+ "ghastly", # 131
+ "frostbitten", # 132
+ "fresh-cut", # 133
+ "freakish", # 134
+ "frantic", # 135
+ "fossilized", # 136
+ "formless", # 137
+ "formidable", # 138
+ "floccose", # 139
+ "five-lobed", # 140
+ "firstborn", # 141
+ "filthy", # 142
+ "fickle", # 143
+ "fetid", # 144
+ "fertile", # 145
+ "fearful", # 146
+ "fatal", # 147
+ "familiar", # 148
+ "fallen", # 149
+ "fallacious", # 150
+ "faint", # 151
+ "faceless", # 152
+ "extinct", # 153
+ "esoteric", # 154
+ "errant", # 155
+ "emergent", # 156
+ "elastic", # 157
+ "eight-sided", # 158
+ "eerie", # 159
+ "ebon", # 160
+ "dysphoric", # 161
+ "dying", # 162
+ "dumb", # 163
+ "dull-purple", # 164
+ "dull", # 165
+ "dull", # 166
+ "dull", # 167
+ "dormant", # 168
+ "doomed", # 169
+ "disfigured", # 170
+ "dirty", # 171
+ "defenseless", # 172
+ "deep-pink", # 173
+ "deep", # 174
+ "deconsecrated", # 175
+ "deathlike", # 176
+ "deadly", # 177
+ "dead", # 178
+ "dark-blue", # 179
+ "dark", # 180
+ "curly", # 181
+ "curious", # 182
+ "cured", # 183
+ "cunning", # 184
+ "crystalline", # 185
+ "cryptic", # 186
+ "crying", # 187
+ "crumbly", # 188
+ "crimson", # 189
+ "crested", # 190
+ "creepy", # 191
+ "crazy", # 192
+ "corrupt", # 193
+ "corporeal", # 194
+ "contemptible", # 195
+ "contained", # 196
+ "concrete", # 197
+ "cloudy", # 198
+ "chopped", # 199
+ "chained", # 200
+ "caustic", # 201
+ "catholic", # 202
+ "cathartic", # 203
+ "captive", # 204
+ "cancerous", # 205
+ "cabalistic", # 206
+ "burnt", # 207
+ "buoyant", # 208
+ "bronze-red", # 209
+ "bronze", # 210
+ "broken", # 211
+ "bright-red", # 212
+ "breathless", # 213
+ "bound", # 214
+ "bound", # 215
+ "bottomless", # 216
+ "bony", # 217
+ "bodiless", # 218
+ "blue-lilac", # 219
+ "blue", # 220
+ "bloody", # 221
+ "bloodthirsty", # 222
+ "bloodsucking", # 223
+ "bloodstained", # 224
+ "bloodcurdling", # 225
+ "blonde", # 226
+ "blistered", # 227
+ "blank", # 228
+ "bitter", # 229
+ "bilgy", # 230
+ "bewitched", # 231
+ "befouled", # 232
+ "beardless", # 233
+ "bastardly", # 234
+ "barbed", # 235
+ "baleful", # 236
+ "balding", # 237
+ "awkward", # 238
+ "awful", # 239
+ "atrocious", # 240
+ "arcane", # 241
+ "appalling", # 242
+ "antic", # 243
+ "anonymous", # 244
+ "angry", # 245
+ "ample", # 246
+ "ambiguous", # 247
+ "amber-green", # 248
+ "amber", # 249
+ "aghast", # 250
+ "activated", # 251
+ "acidic", # 252
+ "abused", # 253
+ "abstruse", # 254
+ "abject", # 255
+]
+
diff --git a/hexnoise.py b/hexnoise.py
index 1f53fcd..d5bce09 100755
--- a/hexnoise.py
+++ b/hexnoise.py
@@ -52,8 +52,8 @@ def send_packet(ser, pkt_type, data, width=16):
def receive_packet(ser, width=16):
packet = ser.read_until(b'\0')
data = cobs.decode(packet[:-1])
- print(f'\033[93mReceived {len(data)} bytes\033[0m')
- hexdump(print, data, width)
+ #print(f'\033[93mReceived {len(data)} bytes\033[0m')
+ #hexdump(print, data, width)
return data[0], data[1:]
if __name__ == '__main__':
@@ -67,6 +67,7 @@ if __name__ == '__main__':
args = parser.parse_args()
ser = serial.Serial(args.serial, args.baudrate)
+ ser.write(b'\0') # COBS synchronization
import uinput
ALL_KEYS = [ v for k, v in uinput.ev.__dict__.items() if k.startswith('KEY_') ]
@@ -117,13 +118,24 @@ if __name__ == '__main__':
print('Handshake finished, handshake hash:')
hexdump(print, proto.get_handshake_hash(), args.width)
+ from nouns import NOUNS
+ from adjectives import ADJECTIVES
+ def map_bytes_to_incantation(data):
+ return " ".join(f'{ADJECTIVES[a]:>16} {NOUNS[b]:<16}' for a, b in zip(data[0::2], data[1::2]))
+ print('Handshake channel binding incantation:')
+ hhash = proto.get_handshake_hash()
+ print(' ' + map_bytes_to_incantation(hhash[:8 ]))
+ print(' ' + map_bytes_to_incantation(hhash[ 8:16 ]))
+ print(' ' + map_bytes_to_incantation(hhash[ 16:24 ]))
+ print(' ' + map_bytes_to_incantation(hhash[ 24:]))
+
old_kcs = set()
def noise_rx(received, ui):
global old_kcs
data = proto.decrypt(received)
- print('Decrypted data:')
- hexdump(print, data, args.width)
+ #print('Decrypted data:')
+ #hexdump(print, data, args.width)
rtype, rlen, *report = data
if rtype != 1 or rlen != 8:
diff --git a/nouns.py b/nouns.py
new file mode 100644
index 0000000..27d1b91
--- /dev/null
+++ b/nouns.py
@@ -0,0 +1,260 @@
+
+NOUNS = [
+ "yolk", # 0
+ "writing", # 1
+ "wrath", # 2
+ "wound", # 3
+ "worm", # 4
+ "wings", # 5
+ "whistle", # 6
+ "watchdog", # 7
+ "waste", # 8
+ "vomit", # 9
+ "vermin", # 10
+ "variation", # 11
+ "underachievement", # 12
+ "tusk", # 13
+ "troll", # 14
+ "trick", # 15
+ "transplant", # 16
+ "transgression", # 17
+ "tooth", # 18
+ "tongue", # 19
+ "tickle", # 20
+ "tick", # 21
+ "thorn", # 22
+ "thistle", # 23
+ "thing", # 24
+ "terror", # 25
+ "tentacle", # 26
+ "tease", # 27
+ "surrender", # 28
+ "surge", # 29
+ "sucker", # 30
+ "substance", # 31
+ "storm", # 32
+ "stone", # 33
+ "stew", # 34
+ "stalk", # 35
+ "squid", # 36
+ "sprout", # 37
+ "sponge", # 38
+ "spill", # 39
+ "spider", # 40
+ "sphere", # 41
+ "spectacle", # 42
+ "speck", # 43
+ "spawn", # 44
+ "soul", # 45
+ "solution", # 46
+ "snout", # 47
+ "snake", # 48
+ "smell", # 49
+ "sloth", # 50
+ "slime", # 51
+ "slice", # 52
+ "sleeper", # 53
+ "slave", # 54
+ "sinew", # 55
+ "shell", # 56
+ "shape", # 57
+ "seizure", # 58
+ "seed", # 59
+ "schism", # 60
+ "scam", # 61
+ "scale", # 62
+ "sainthood", # 63
+ "root", # 64
+ "robe", # 65
+ "roach", # 66
+ "rinse", # 67
+ "remains", # 68
+ "relay", # 69
+ "rejuvenation", # 70
+ "realization", # 71
+ "reaction", # 72
+ "ransom", # 73
+ "pupa", # 74
+ "pride", # 75
+ "prey", # 76
+ "predator", # 77
+ "potion", # 78
+ "pornography", # 79
+ "polyp", # 80
+ "plum", # 81
+ "pleasure", # 82
+ "pitch", # 83
+ "pigeon", # 84
+ "phenomenon", # 85
+ "pest", # 86
+ "periwinkle", # 87
+ "percolation", # 88
+ "parasite", # 89
+ "pair", # 90
+ "oyster", # 91
+ "orphan", # 92
+ "orgasm", # 93
+ "organism", # 94
+ "orchid", # 95
+ "object", # 96
+ "nail", # 97
+ "mushroom", # 98
+ "murder", # 99
+ "mucus", # 100
+ "movement", # 101
+ "mother", # 102
+ "mold", # 103
+ "mist", # 104
+ "mildew", # 105
+ "metal", # 106
+ "mesh", # 107
+ "meddling", # 108
+ "mayhem", # 109
+ "masterpiece", # 110
+ "masonry", # 111
+ "mask", # 112
+ "manhood", # 113
+ "maggot", # 114
+ "lust", # 115
+ "loop", # 116
+ "living_thing", # 117
+ "liquor", # 118
+ "liquid", # 119
+ "lining", # 120
+ "laceration", # 121
+ "knife", # 122
+ "kitten", # 123
+ "kiss", # 124
+ "jumper", # 125
+ "jest", # 126
+ "instrument", # 127
+ "injustice", # 128
+ "injury", # 129
+ "influence", # 130
+ "indulgence", # 131
+ "incursion", # 132
+ "impulse", # 133
+ "imago", # 134
+ "hound", # 135
+ "horn", # 136
+ "hook", # 137
+ "hoof", # 138
+ "heirloom", # 139
+ "heart", # 140
+ "hawk", # 141
+ "hare", # 142
+ "hair", # 143
+ "gulp", # 144
+ "guardian", # 145
+ "grass", # 146
+ "goat", # 147
+ "gnat", # 148
+ "gluttony", # 149
+ "glowworm", # 150
+ "gasp", # 151
+ "game", # 152
+ "fusion", # 153
+ "fungus", # 154
+ "frustration", # 155
+ "frog", # 156
+ "foul", # 157
+ "foot", # 158
+ "food", # 159
+ "fog", # 160
+ "foal", # 161
+ "fluke", # 162
+ "fluff", # 163
+ "flower", # 164
+ "flicker", # 165
+ "flea", # 166
+ "flattery", # 167
+ "flask", # 168
+ "flare", # 169
+ "firefly", # 170
+ "finger", # 171
+ "filtration", # 172
+ "female", # 173
+ "feeder", # 174
+ "feather", # 175
+ "fart", # 176
+ "fang", # 177
+ "failure", # 178
+ "face", # 179
+ "fabrication", # 180
+ "extract", # 181
+ "exodus", # 182
+ "evil", # 183
+ "envy", # 184
+ "enema", # 185
+ "embryo", # 186
+ "egress", # 187
+ "echo", # 188
+ "eater", # 189
+ "ear", # 190
+ "dwarf", # 191
+ "dust", # 192
+ "drop", # 193
+ "draft", # 194
+ "domestication", # 195
+ "distortion", # 196
+ "dew", # 197
+ "depravity", # 198
+ "deity", # 199
+ "death", # 200
+ "daughter", # 201
+ "dash", # 202
+ "dagger", # 203
+ "culture", # 204
+ "crutch", # 205
+ "crow", # 206
+ "critter", # 207
+ "creeper", # 208
+ "creation", # 209
+ "crab", # 210
+ "corruption", # 211
+ "cocoon", # 212
+ "claw", # 213
+ "chip", # 214
+ "child", # 215
+ "cell", # 216
+ "catch", # 217
+ "carving", # 218
+ "carrot", # 219
+ "carnival", # 220
+ "cancer", # 221
+ "butterfly", # 222
+ "burn", # 223
+ "buildup", # 224
+ "brush", # 225
+ "brew", # 226
+ "bottle", # 227
+ "boot", # 228
+ "book", # 229
+ "bone", # 230
+ "blunder", # 231
+ "blot", # 232
+ "blood", # 233
+ "blink", # 234
+ "bite", # 235
+ "bird", # 236
+ "benthos", # 237
+ "beak", # 238
+ "basket", # 239
+ "bark", # 240
+ "ball", # 241
+ "baby", # 242
+ "axolotl", # 243
+ "ashes", # 244
+ "artifact", # 245
+ "arson", # 246
+ "armor", # 247
+ "apparition", # 248
+ "antenna", # 249
+ "alms", # 250
+ "alienation", # 251
+ "advent", # 252
+ "adornment", # 253
+ "abomination", # 254
+ "abandonment", # 255
+]
+
diff --git a/src/demo.c b/src/demo.c
index 3a76a5d..ba76d2b 100644
--- a/src/demo.c
+++ b/src/demo.c
@@ -136,21 +136,27 @@ int pairing_check(struct NoiseState *st, const char *buf);
void pairing_input(uint8_t keycode);
void pairing_parse_report(struct hid_report *buf, uint8_t len);
+/* Minimum number of bytes of handshake hash to confirm during pairing */
+#define MIN_PAIRING_SEQUENCE_LENGTH 8
+
int pairing_check(struct NoiseState *st, const char *buf) {
+ LOG_PRINTF("Checking pairing\n");
const char *p = buf;
int idx = 0;
do {
const char *found = strchr(p, ' ');
size_t plen = found ? (size_t)(found - p) : strlen(p); /* p >= found */
int num = -1;
+ /* FIXME ignore "and", ignore commata and dots, handle letter case correctly (currently it's ignored). */
for (int i=0; i<256; i++) {
- if (!strncmp(p, adjectives[i], plen) || !strncmp(p, nouns[i], plen)) {
+ if ((!strncmp(p, adjectives[i], plen)) || (!strncmp(p, nouns[i], plen))) {
+ LOG_PRINTF(" idx=%02d h=%02x i=%02x adj=%s n=%s plen=%d s=%s\n", idx, st->handshake_hash[idx], i, adjectives[i], nouns[i], plen, p);
num = i;
break;
}
}
if (num == -1) {
- LOG_PRINTF("Pairing word not found in dictionary\n");
+ LOG_PRINTF("Pairing word \"%s\" not found in dictionary\n", p);
return -1;
}
if (st->handshake_hash[idx] != num) {
@@ -159,9 +165,12 @@ int pairing_check(struct NoiseState *st, const char *buf) {
}
idx++;
p = strchr(p, ' ');
- } while (p != NULL && idx < BLAKE2S_HASH_SIZE);
+ if (!p)
+ break; /* end of string */
+ p++; /* skip space */
+ } while (idx < BLAKE2S_HASH_SIZE);
- if (idx < 8) {
+ if (idx < MIN_PAIRING_SEQUENCE_LENGTH) {
LOG_PRINTF("Pairing sequence too short, only %d bytes of hash checked\n", idx);
return -1;
}
@@ -180,20 +189,24 @@ void pairing_input(uint8_t keycode) {
break;
case KEY_BACKSPACE:
+ pairing_buf[pairing_buf_pos] = '\0'; /* FIXME debug */
if (pairing_buf_pos > 0)
pairing_buf_pos--;
break;
default:
- for (size_t i=0; i<sizeof(keycode_mapping)/sizeof(keycode_mapping[0]); i++) {
+ for (size_t i=0; keycode_mapping[i].kc != KEY_NONE; i++) {
if (keycode_mapping[i].kc == keycode) {
- if (pairing_buf_pos < sizeof(pairing_buf)-1) /* allow for terminating null byte */
+ if (pairing_buf_pos < sizeof(pairing_buf)-1) /* allow for terminating null byte */ {
pairing_buf[pairing_buf_pos++] = keycode_mapping[i].ch;
+ pairing_buf[pairing_buf_pos] = '\0'; /* FIXME debug */
+ }
break;
}
}
break;
}
+ LOG_PRINTF("Input: %s\n", pairing_buf);
}
void pairing_parse_report(struct hid_report *buf, uint8_t len) {
@@ -228,7 +241,7 @@ static void hid_in_message_handler(uint8_t device_id, const uint8_t *data, uint3
return;
}
- LOG_PRINTF("Sending event %02X %02X %02X %02X\n", data[0], data[1], data[2], data[3]);
+ //LOG_PRINTF("Sending event %02X %02X %02X %02X\n", data[0], data[1], data[2], data[3]);
struct hid_report_packet pkt = {
.len = length,
.report = {0}
diff --git a/src/hid_keycodes.c b/src/hid_keycodes.c
index 19b6f69..79acb72 100644
--- a/src/hid_keycodes.c
+++ b/src/hid_keycodes.c
@@ -1,33 +1,33 @@
#include "hid_keycodes.h"
-struct keymap_entry keycode_mapping[37] = {
- { KEY_A, 'A' },
- { KEY_B, 'B' },
- { KEY_C, 'C' },
- { KEY_D, 'D' },
- { KEY_E, 'E' },
- { KEY_F, 'F' },
- { KEY_G, 'G' },
- { KEY_H, 'H' },
- { KEY_I, 'I' },
- { KEY_J, 'J' },
- { KEY_K, 'K' },
- { KEY_L, 'L' },
- { KEY_M, 'M' },
- { KEY_N, 'N' },
- { KEY_O, 'O' },
- { KEY_P, 'P' },
- { KEY_Q, 'Q' },
- { KEY_R, 'R' },
- { KEY_S, 'S' },
- { KEY_T, 'T' },
- { KEY_U, 'U' },
- { KEY_V, 'V' },
- { KEY_W, 'W' },
- { KEY_X, 'X' },
- { KEY_Y, 'Y' },
- { KEY_Z, 'Z' },
+struct keymap_entry keycode_mapping[] = {
+ { KEY_A, 'a' },
+ { KEY_B, 'b' },
+ { KEY_C, 'c' },
+ { KEY_D, 'd' },
+ { KEY_E, 'e' },
+ { KEY_F, 'f' },
+ { KEY_G, 'g' },
+ { KEY_H, 'h' },
+ { KEY_I, 'i' },
+ { KEY_J, 'j' },
+ { KEY_K, 'k' },
+ { KEY_L, 'l' },
+ { KEY_M, 'm' },
+ { KEY_N, 'n' },
+ { KEY_O, 'o' },
+ { KEY_P, 'p' },
+ { KEY_Q, 'q' },
+ { KEY_R, 'r' },
+ { KEY_S, 's' },
+ { KEY_T, 't' },
+ { KEY_U, 'u' },
+ { KEY_V, 'v' },
+ { KEY_W, 'w' },
+ { KEY_X, 'x' },
+ { KEY_Y, 'y' },
+ { KEY_Z, 'z' },
{ KEY_1, '1' },
{ KEY_2, '2' },
{ KEY_3, '3' },
@@ -38,6 +38,8 @@ struct keymap_entry keycode_mapping[37] = {
{ KEY_8, '8' },
{ KEY_9, '9' },
{ KEY_0, '0' },
+ { KEY_MINUS, '-' },
{ KEY_SPACE, ' ' },
+ { KEY_NONE, 0 }, /* end marker */
};
diff --git a/src/hid_keycodes.h b/src/hid_keycodes.h
index a7f590a..4cfe115 100644
--- a/src/hid_keycodes.h
+++ b/src/hid_keycodes.h
@@ -6,7 +6,7 @@ struct keymap_entry {
char ch;
};
-extern struct keymap_entry keycode_mapping[37];
+extern struct keymap_entry keycode_mapping[];
enum hid_keycode {
KEY_NONE = 0x00, // No key pressed
diff --git a/src/noise.c b/src/noise.c
index 09a4c47..e855a4a 100644
--- a/src/noise.c
+++ b/src/noise.c
@@ -142,7 +142,6 @@ enum handshake_state try_continue_noise_handshake(struct NoiseState *st, uint8_t
goto errout;
}
-
HANDLE_NOISE_ERROR(noise_dhstate_get_public_key(remote_dh, st->remote_key, sizeof(st->remote_key)), "getting remote pubkey");
if (!memcmp(st->remote_key, st->remote_key_reference, sizeof(st->remote_key))) { /* keys match */
diff --git a/src/usbh_driver_hid.c b/src/usbh_driver_hid.c
index bb842db..4893354 100644
--- a/src/usbh_driver_hid.c
+++ b/src/usbh_driver_hid.c
@@ -96,7 +96,7 @@ void hid_driver_init(const hid_config_t *config)
static void *init(usbh_device_t *usbh_dev)
{
if (!initialized) {
- LOG_PRINTF("\n%s/%d : driver not initialized\r\n", __FILE__, __LINE__);
+ LOG_PRINTF("\n%s/%d : driver not initialized\n", __FILE__, __LINE__);
return 0;
}
@@ -341,7 +341,7 @@ static void remove(void *drvdata)
bool hid_set_report(uint8_t device_id, uint8_t val)
{
if (device_id >= USBH_HID_MAX_DEVICES) {
- LOG_PRINTF("invalid device id");
+ LOG_PRINTF("invalid device id\n");
return false;
}
@@ -374,7 +374,7 @@ bool hid_set_report(uint8_t device_id, uint8_t val)
bool hid_is_connected(uint8_t device_id)
{
if (device_id >= USBH_HID_MAX_DEVICES) {
- LOG_PRINTF("is connected: invalid device id");
+ LOG_PRINTF("is connected: invalid device id\n");
return false;
}
return hid_device[device_id].state_next == STATE_INACTIVE;
diff --git a/src/usbh_lld_stm32f4.c b/src/usbh_lld_stm32f4.c
index 0654d28..3fcd51a 100644
--- a/src/usbh_lld_stm32f4.c
+++ b/src/usbh_lld_stm32f4.c
@@ -342,12 +342,13 @@ static void rxflvl_handle(void *drvdata)
if ( channels[channel].data_index < channels[channel].packet.datalen) {
if (len == channels[channel].packet.endpoint_size_max) {
REBASE_CH(OTG_HCCHAR, channel) |= OTG_HCCHAR_CHENA;
- LOG_PRINTF("CHENA[%d/%d] ", channels[channel].data_index, channels[channel].packet.datalen);
+ //LOG_PRINTF("CHENA[%d/%d] ", channels[channel].data_index, channels[channel].packet.datalen);
}
}
} else if ((rxstsp&OTG_GRXSTSP_PKTSTS_MASK) == OTG_GRXSTSP_PKTSTS_IN_COMP) {
+/*
#ifdef USART_DEBUG
uint32_t i;
LOG_PRINTF("\nDATA: ");
@@ -356,6 +357,7 @@ static void rxflvl_handle(void *drvdata)
LOG_PRINTF("%02X ", data[i]);
}
#endif
+*/
} else if ((rxstsp&OTG_GRXSTSP_PKTSTS_MASK) == OTG_GRXSTSP_PKTSTS_CHH) {
} else {
@@ -441,7 +443,7 @@ static enum USBH_POLL_STATUS poll_run(usbh_lld_stm32f4_driver_data_t *dev)
// To clear interrupt write 0 to PENA
// To disable port write 1 to PENCHNG
REBASE(OTG_HPRT) &= ~OTG_HPRT_PENA;
- LOG_PRINTF("PENCHNG");
+ //LOG_PRINTF("PENCHNG");
if ((hprt & OTG_HPRT_PENA)) {
return USBH_POLL_STATUS_DEVICE_CONNECTED;
}
@@ -451,13 +453,13 @@ static enum USBH_POLL_STATUS poll_run(usbh_lld_stm32f4_driver_data_t *dev)
if (REBASE(OTG_HPRT) & OTG_HPRT_POCCHNG) {
// TODO: Check for functionality
REBASE(OTG_HPRT) |= OTG_HPRT_POCCHNG;
- LOG_PRINTF("POCCHNG");
+ //LOG_PRINTF("POCCHNG");
}
}
if (REBASE(OTG_GINTSTS) & OTG_GINTSTS_DISCINT) {
REBASE(OTG_GINTSTS) = OTG_GINTSTS_DISCINT;
- LOG_PRINTF("DISCINT");
+ //LOG_PRINTF("DISCINT");
/*
* When the voltage drops, DISCINT interrupt is generated although
@@ -465,7 +467,7 @@ static enum USBH_POLL_STATUS poll_run(usbh_lld_stm32f4_driver_data_t *dev)
* Often, DISCINT is bad interpreted upon insertion of device
*/
if (!(REBASE(OTG_HPRT) & OTG_HPRT_PCSTS)) {
- LOG_PRINTF("discint processsing...");
+ //LOG_PRINTF("discint processsing...");
channels_init(dev);
}
REBASE(OTG_GINTSTS) = REBASE(OTG_GINTSTS);
@@ -490,7 +492,7 @@ static enum USBH_POLL_STATUS poll_run(usbh_lld_stm32f4_driver_data_t *dev)
if (hcint & OTG_HCINT_NAK) {
REBASE_CH(OTG_HCINT, channel) = OTG_HCINT_NAK;
- LOG_PRINTF("NAK\n");
+ //LOG_PRINTF("NAK\n");
free_channel(dev, channel);
@@ -506,7 +508,7 @@ static enum USBH_POLL_STATUS poll_run(usbh_lld_stm32f4_driver_data_t *dev)
if (hcint & OTG_HCINT_ACK) {
REBASE_CH(OTG_HCINT, channel) = OTG_HCINT_ACK;
- LOG_PRINTF("ACK");
+ //LOG_PRINTF("ACK");
if (eptyp == USBH_ENDPOINT_TYPE_CONTROL) {
channels[channel].packet.toggle[0] = 1;
} else {
@@ -516,7 +518,7 @@ static enum USBH_POLL_STATUS poll_run(usbh_lld_stm32f4_driver_data_t *dev)
if (hcint & OTG_HCINT_XFRC) {
REBASE_CH(OTG_HCINT, channel) = OTG_HCINT_XFRC;
- LOG_PRINTF("XFRC\n");
+ //LOG_PRINTF("XFRC\n");
free_channel(dev, channel);
@@ -532,7 +534,7 @@ static enum USBH_POLL_STATUS poll_run(usbh_lld_stm32f4_driver_data_t *dev)
if (hcint & OTG_HCINT_FRMOR) {
REBASE_CH(OTG_HCINT, channel) = OTG_HCINT_FRMOR;
- LOG_PRINTF("FRMOR");
+ //LOG_PRINTF("FRMOR");
free_channel(dev, channel);
@@ -547,7 +549,7 @@ static enum USBH_POLL_STATUS poll_run(usbh_lld_stm32f4_driver_data_t *dev)
if (hcint & OTG_HCINT_TXERR) {
REBASE_CH(OTG_HCINT, channel) = OTG_HCINT_TXERR;
- LOG_PRINTF("TXERR");
+ //LOG_PRINTF("TXERR");
free_channel(dev, channel);
@@ -564,7 +566,7 @@ static enum USBH_POLL_STATUS poll_run(usbh_lld_stm32f4_driver_data_t *dev)
if (hcint & OTG_HCINT_STALL) {
REBASE_CH(OTG_HCINT, channel) = OTG_HCINT_STALL;
- LOG_PRINTF("STALL");
+ //LOG_PRINTF("STALL");
free_channel(dev, channel);
@@ -580,7 +582,7 @@ static enum USBH_POLL_STATUS poll_run(usbh_lld_stm32f4_driver_data_t *dev)
if (hcint & OTG_HCINT_CHH) {
REBASE_CH(OTG_HCINT, channel) = OTG_HCINT_CHH;
- LOG_PRINTF("CHH");
+ //LOG_PRINTF("CHH");
free_channel(dev, channel);
}
@@ -589,7 +591,7 @@ static enum USBH_POLL_STATUS poll_run(usbh_lld_stm32f4_driver_data_t *dev)
if (hcint & OTG_HCINT_NAK) {
REBASE_CH(OTG_HCINT, channel) = OTG_HCINT_NAK;
if (eptyp == USBH_ENDPOINT_TYPE_CONTROL) {
- LOG_PRINTF("NAK");
+ //LOG_PRINTF("NAK");
}
REBASE_CH(OTG_HCCHAR, channel) |= OTG_HCCHAR_CHENA;
@@ -598,12 +600,12 @@ static enum USBH_POLL_STATUS poll_run(usbh_lld_stm32f4_driver_data_t *dev)
if (hcint & OTG_HCINT_DTERR) {
REBASE_CH(OTG_HCINT, channel) = OTG_HCINT_DTERR;
- LOG_PRINTF("DTERR");
+ //LOG_PRINTF("DTERR");
}
if (hcint & OTG_HCINT_ACK) {
REBASE_CH(OTG_HCINT, channel) = OTG_HCINT_ACK;
- LOG_PRINTF("ACK");
+ //LOG_PRINTF("ACK");
channels[channel].packet.toggle[0] ^= 1;
@@ -613,7 +615,7 @@ static enum USBH_POLL_STATUS poll_run(usbh_lld_stm32f4_driver_data_t *dev)
if (hcint & OTG_HCINT_XFRC) {
REBASE_CH(OTG_HCINT, channel) = OTG_HCINT_XFRC;
- LOG_PRINTF("XFRC\n");
+ //LOG_PRINTF("XFRC\n");
free_channel(dev, channel);
usbh_packet_callback_data_t cb_data;
@@ -633,7 +635,7 @@ static enum USBH_POLL_STATUS poll_run(usbh_lld_stm32f4_driver_data_t *dev)
if (hcint & OTG_HCINT_BBERR) {
REBASE_CH(OTG_HCINT, channel) = OTG_HCINT_BBERR;
- LOG_PRINTF("BBERR");
+ //LOG_PRINTF("BBERR");
free_channel(dev, channel);
usbh_packet_callback_data_t cb_data;
@@ -647,13 +649,13 @@ static enum USBH_POLL_STATUS poll_run(usbh_lld_stm32f4_driver_data_t *dev)
if (hcint & OTG_HCINT_FRMOR) {
REBASE_CH(OTG_HCINT, channel) = OTG_HCINT_FRMOR;
- LOG_PRINTF("FRMOR");
+ //LOG_PRINTF("FRMOR");
}
if (hcint & OTG_HCINT_TXERR) {
REBASE_CH(OTG_HCINT, channel) = OTG_HCINT_TXERR;
- LOG_PRINTF("TXERR");
+ //LOG_PRINTF("TXERR");
free_channel(dev, channel);
@@ -669,7 +671,7 @@ static enum USBH_POLL_STATUS poll_run(usbh_lld_stm32f4_driver_data_t *dev)
if (hcint & OTG_HCINT_STALL) {
REBASE_CH(OTG_HCINT, channel) = OTG_HCINT_STALL;
- LOG_PRINTF("STALL");
+ //LOG_PRINTF("STALL");
free_channel(dev, channel);
@@ -684,7 +686,7 @@ static enum USBH_POLL_STATUS poll_run(usbh_lld_stm32f4_driver_data_t *dev)
}
if (hcint & OTG_HCINT_CHH) {
REBASE_CH(OTG_HCINT, channel) = OTG_HCINT_CHH;
- LOG_PRINTF("CHH");
+ //LOG_PRINTF("CHH");
free_channel(dev, channel);
}
@@ -694,12 +696,12 @@ static enum USBH_POLL_STATUS poll_run(usbh_lld_stm32f4_driver_data_t *dev)
if (REBASE(OTG_GINTSTS) & OTG_GINTSTS_MMIS) {
REBASE(OTG_GINTSTS) = OTG_GINTSTS_MMIS;
- LOG_PRINTF("Mode mismatch");
+ //LOG_PRINTF("Mode mismatch");
}
if (REBASE(OTG_GINTSTS) & OTG_GINTSTS_IPXFR) {
REBASE(OTG_GINTSTS) = OTG_GINTSTS_IPXFR;
- LOG_PRINTF("IPXFR");
+ //LOG_PRINTF("IPXFR");
}
return USBH_POLL_STATUS_NONE;
@@ -847,7 +849,7 @@ static void poll_init(usbh_lld_stm32f4_driver_data_t *dev)
if (done) {
dev->poll_sequence++;
dev->timestamp_us = dev->time_curr_us;
- LOG_PRINTF("\t\t POLL SEQUENCE %d\n", dev->poll_sequence);
+ //LOG_PRINTF("\t\t POLL SEQUENCE %d\n", dev->poll_sequence);
}
}
@@ -859,7 +861,7 @@ static void poll_reset(usbh_lld_stm32f4_driver_data_t *dev)
dev->state = dev->state_prev;
dev->state_prev = DEVICE_STATE_RESET;
- LOG_PRINTF("RESET");
+ //LOG_PRINTF("RESET");
} else {
LOG_PRINTF("waiting %d < %d\n",dev->time_curr_us, dev->timestamp_us);
}