├── CH569_SerDes_180Mbps ├── CH569_SerDes_180Mbps.bin ├── CH569_SerDes_180Mbps.bin.scopesession ├── CH569_SerDes_180Mbps.csv ├── CH569_SerDes_180Mbps.csv_res.txt └── README.md ├── CH569_SerDes_Descramble_glscopeclient_CSV_8b10bIBM_Hex ├── CH569_SerDes_Descramble_glscopeclient_CSV_8b10bIBM_Hex.c ├── Makefile ├── README.md ├── crc32_SATA.c ├── crc32_SATA.h ├── csv.c └── csv.h ├── LICENSE ├── README.md ├── WCH_CH569_SerDes_ReverseEngineering_BVERNOUX_31July2022.odt └── WCH_CH569_SerDes_ReverseEngineering_BVERNOUX_31July2022.pdf /CH569_SerDes_180Mbps/CH569_SerDes_180Mbps.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hydrausb3/wch-ch569-serdes/956ce6ec5df6e70fd9ab7474f1489198d079cd4a/CH569_SerDes_180Mbps/CH569_SerDes_180Mbps.bin -------------------------------------------------------------------------------- /CH569_SerDes_180Mbps/CH569_SerDes_180Mbps.bin.scopesession: -------------------------------------------------------------------------------- 1 | metadata: 2 | appver: "glscopeclient 0.1-a896eca" 3 | appdate: "Jul 30 2022 04:47:07" 4 | created: "2022-07-31 23:01:07" 5 | instruments: 6 | decodes: 7 | filter3: 8 | id: 3 9 | inputs: 10 | din: 1/2 11 | clk: 2/0 12 | parameters: 13 | Bit Rate: 180 Mbps 14 | Bit Rate Mode: "Fixed" 15 | Center Voltage: 1.7 V 16 | Clock Alignment: "Center" 17 | Clock Edge: "Both" 18 | Mask: "" 19 | Saturation Level: 1 20 | Vertical Range: 500 mV 21 | Vertical Scale Mode: "Auto" 22 | protocol: "Eye pattern" 23 | color: "#a6a6cecee3e3" 24 | nick: "Eyepattern_2" 25 | name: "Eyepattern_2" 26 | streams: 27 | stream0: 28 | index: 0 29 | vrange: 2.632764 30 | offset: -1.700000 31 | filter1: 32 | id: 1 33 | inputs: 34 | parameters: 35 | BIN File: "CH569_SerDes_180Mbps.bin" 36 | protocol: "BIN Import" 37 | color: "#a6a6cecee3e3" 38 | nick: "CH569_SerDes_180Mbps" 39 | name: "CH569_SerDes_180Mbps.bin" 40 | streams: 41 | stream0: 42 | index: 0 43 | vrange: 10.239014 44 | offset: -1.684029 45 | stream1: 46 | index: 1 47 | vrange: 10.411676 48 | offset: -0.234635 49 | stream2: 50 | index: 2 51 | vrange: 2.632764 52 | offset: -1.889442 53 | filter5: 54 | id: 5 55 | inputs: 56 | data: 4/0 57 | clk: 2/0 58 | parameters: 59 | Display Format: "Hex (K.bc b5)" 60 | protocol: "8b/10b (IBM)" 61 | color: "#3333a0a02c2c" 62 | nick: "8b10bIBM_Hex" 63 | name: "8b10bIBM_2" 64 | streams: 65 | stream0: 66 | index: 0 67 | vrange: 0.000000 68 | offset: 0.000000 69 | filter4: 70 | id: 4 71 | inputs: 72 | din: 1/2 73 | parameters: 74 | Hysteresis: 10 mV 75 | Threshold: 1.8 V 76 | protocol: "Threshold" 77 | color: "#1f1f7878b4b4" 78 | nick: "Threshold" 79 | name: "Threshold_2(CH569_SerDes_180Mbps.CH3)" 80 | streams: 81 | stream0: 82 | index: 0 83 | vrange: 0.000000 84 | offset: 0.000000 85 | filter2: 86 | id: 2 87 | inputs: 88 | IN: 4/0 89 | Gate: 0 90 | parameters: 91 | Symbol rate: 180 MHz 92 | Threshold: 1.2 V 93 | protocol: "Clock Recovery (PLL)" 94 | color: "#b2b2dfdf8a8a" 95 | nick: "ClockRecoveryPLL" 96 | name: "ClockRecoveryPLL_2" 97 | streams: 98 | stream0: 99 | index: 0 100 | vrange: 0.000000 101 | offset: 0.000000 102 | ui_config: 103 | window: 104 | width: 1920 105 | height: 1017 106 | areas: 107 | area6: 108 | id: 6 109 | persistence: 0 110 | channel: 1 111 | stream: 2 112 | overlays: 113 | overlay4: 114 | id: 4 115 | stream: 0 116 | overlay2: 117 | id: 2 118 | stream: 0 119 | overlay5: 120 | id: 5 121 | stream: 0 122 | area7: 123 | id: 7 124 | persistence: 0 125 | channel: 1 126 | stream: 1 127 | area8: 128 | id: 8 129 | persistence: 0 130 | channel: 3 131 | stream: 0 132 | area9: 133 | id: 9 134 | persistence: 0 135 | channel: 1 136 | stream: 0 137 | groups: 138 | group10: 139 | id: 10 140 | name: "Waveform Group 1" 141 | timebaseResolution: fs 142 | pixelsPerXUnit: 1.158272e-07 143 | xAxisOffset: -1234486272 144 | cursorConfig: none 145 | xcursor0: 0 146 | xcursor1: 0 147 | ycursor0: 0.000000 148 | ycursor1: 0.000000 149 | areas: 150 | area6: 151 | id: 6 152 | area9: 153 | id: 9 154 | area7: 155 | id: 7 156 | area8: 157 | id: 8 158 | markers: 159 | splitters: 160 | split11: 161 | id: 11 162 | dir: v 163 | split: 617 164 | child0: 10 165 | child1: 0 166 | top: 11 167 | -------------------------------------------------------------------------------- /CH569_SerDes_180Mbps/CH569_SerDes_180Mbps.csv: -------------------------------------------------------------------------------- 1 | Time (s),8b10bIBM_Hex 2 | 5.632952e-08,55 3 | 1.120242e-07,8a 4 | 1.676599e-07,1b 5 | 2.233066e-07,be 6 | 2.788796e-07,1a 7 | 3.344593e-07,bb 8 | 3.900158e-07,3d 9 | 4.456275e-07,b7 10 | 5.011321e-07,56 11 | 5.567593e-07,fa 12 | 6.122603e-07,1b 13 | 6.678199e-07,0b 14 | 7.233788e-07,f6 15 | 7.789148e-07,53 16 | 8.344784e-07,41 17 | 8.900525e-07,9c 18 | 9.455913e-07,80 19 | 1.001120e-06,f0 20 | 1.056669e-06,4a 21 | 1.112215e-06,c3 22 | 1.167788e-06,7f 23 | 1.223348e-06,74 24 | 1.278887e-06,91 25 | 1.334429e-06,52 26 | 1.389929e-06,86 27 | 1.445459e-06,be 28 | 1.501010e-06,b6 29 | 1.556590e-06,a7 30 | 1.612135e-06,6f 31 | 1.667724e-06,7a 32 | 1.723278e-06,d6 33 | 1.778804e-06,e6 34 | 1.834351e-06,63 35 | 1.889954e-06,31 36 | 1.945503e-06,0c 37 | 2.001083e-06,fe 38 | 2.056649e-06,36 39 | 2.112238e-06,f0 40 | 2.167807e-06,29 41 | 2.223348e-06,ea 42 | 2.278849e-06,f3 43 | 2.334434e-06,1e 44 | 2.389941e-06,94 45 | 2.445545e-06,26 46 | 2.501088e-06,34 47 | 2.556652e-06,eb 48 | 2.612158e-06,17 49 | 2.667754e-06,3b 50 | 2.723287e-06,85 51 | 2.778862e-06,53 52 | 2.834396e-06,4d 53 | 2.889958e-06,dc 54 | 2.945462e-06,4a 55 | 3.001057e-06,e9 56 | 3.056597e-06,88 57 | 3.112128e-06,0e 58 | 3.167723e-06,20 59 | 3.223308e-06,5d 60 | 3.278835e-06,d0 61 | 3.334359e-06,ed 62 | 3.389949e-06,01 63 | 3.445469e-06,69 64 | 3.501060e-06,de 65 | 3.556617e-06,38 66 | 3.612179e-06,9e 67 | 3.667757e-06,fa 68 | 3.723257e-06,07 69 | 3.778831e-06,4b 70 | 3.834380e-06,db 71 | 3.889921e-06,68 72 | 3.945467e-06,7b 73 | 4.001072e-06,43 74 | 4.056606e-06,0a 75 | 4.112132e-06,45 76 | 4.167706e-06,08 77 | 4.223310e-06,d7 78 | 4.278839e-06,0d 79 | 4.334357e-06,96 80 | 4.389961e-06,98 81 | 4.445517e-06,e6 82 | 4.501067e-06,35 83 | 4.556595e-06,3f 84 | 4.612150e-06,a5 85 | 4.667747e-06,98 86 | 4.723297e-06,76 87 | 4.778817e-06,fe 88 | 4.834349e-06,15 89 | 4.889903e-06,f7 90 | 4.945486e-06,0e 91 | 5.001040e-06,c8 92 | 5.056572e-06,af 93 | 5.112119e-06,90 94 | 5.167715e-06,60 95 | 5.223293e-06,66 96 | 5.278829e-06,cb 97 | 5.334341e-06,d5 98 | 5.389902e-06,f0 99 | 5.445448e-06,fa 100 | 5.500979e-06,9f 101 | 5.556580e-06,00 102 | 5.612105e-06,82 103 | 5.667706e-06,2b 104 | 5.723291e-06,91 105 | 5.778807e-06,74 106 | 5.834354e-06,31 107 | 5.889938e-06,0e 108 | 5.945431e-06,1e 109 | 6.000975e-06,6a 110 | 6.056600e-06,f4 111 | 6.112113e-06,76 112 | 6.167711e-06,48 113 | 6.223319e-06,69 114 | 6.278853e-06,6d 115 | 6.334391e-06,f4 116 | 6.389942e-06,93 117 | 6.445505e-06,8a 118 | 6.501034e-06,cd 119 | 6.556562e-06,7b 120 | 6.612137e-06,7e 121 | 6.667669e-06,ad 122 | 6.723263e-06,13 123 | 6.778825e-06,15 124 | 6.834367e-06,ee 125 | 6.889887e-06,fe 126 | 6.945447e-06,72 127 | 7.001044e-06,1e 128 | 7.056578e-06,3b 129 | 7.112118e-06,aa 130 | 7.167637e-06,14 131 | 7.223135e-06,a0 132 | 7.278767e-06,e7 133 | 7.334283e-06,d4 134 | 7.389833e-06,aa 135 | 7.445436e-06,23 136 | 7.501020e-06,67 137 | 7.556569e-06,9e 138 | 7.612103e-06,dc 139 | 7.667657e-06,b0 140 | 7.723285e-06,fb 141 | 7.778796e-06,73 142 | 7.834360e-06,a5 143 | 7.889919e-06,e0 144 | 7.945478e-06,4f 145 | 8.001034e-06,94 146 | 8.056570e-06,ca 147 | 8.112098e-06,06 148 | 8.167658e-06,12 149 | 8.223205e-06,92 150 | 8.278749e-06,e2 151 | 8.334271e-06,63 152 | 8.389843e-06,6d 153 | 8.445402e-06,62 154 | 8.500925e-06,78 155 | 8.556497e-06,45 156 | 8.612077e-06,93 157 | 8.667615e-06,0c 158 | 8.723176e-06,26 159 | 8.778795e-06,53 160 | 8.834333e-06,02 161 | 8.889888e-06,22 162 | 8.945466e-06,59 163 | 9.001032e-06,3e 164 | 9.056556e-06,63 165 | 9.112090e-06,ca 166 | 9.167594e-06,6e 167 | 9.223159e-06,2b 168 | 9.278745e-06,1f 169 | 9.334297e-06,1f 170 | 9.389850e-06,6a 171 | 9.445397e-06,63 172 | 9.500980e-06,ed 173 | 9.556544e-06,a9 174 | 9.612075e-06,b5 175 | 9.667602e-06,35 176 | 9.723176e-06,fd 177 | 9.778730e-06,a0 178 | 9.834297e-06,a2 179 | 9.889883e-06,4a 180 | 9.945406e-06,96 181 | 1.000095e-05,e1 182 | 1.005652e-05,af 183 | 1.011204e-05,71 184 | 1.016757e-05,62 185 | 1.022316e-05,7b 186 | 1.027870e-05,d5 187 | 1.033426e-05,e1 188 | 1.038984e-05,8a 189 | 1.044539e-05,56 190 | 1.050097e-05,a0 191 | 1.055650e-05,55 192 | 1.061208e-05,68 193 | 1.066764e-05,89 194 | 1.072317e-05,d1 195 | 1.077877e-05,82 196 | 1.083429e-05,ff 197 | 1.088983e-05,b4 198 | 1.094540e-05,4c 199 | 1.100097e-05,23 200 | 1.105649e-05,7f 201 | 1.111205e-05,1e 202 | 1.116757e-05,48 203 | 1.122315e-05,83 204 | 1.127870e-05,7f 205 | 1.133428e-05,e8 206 | 1.138982e-05,1a 207 | 1.144538e-05,b2 208 | 1.150090e-05,cd 209 | 1.155646e-05,ea 210 | 1.161206e-05,c5 211 | 1.166765e-05,a9 212 | 1.172319e-05,c3 213 | 1.177878e-05,ac 214 | 1.183431e-05,01 215 | 1.188986e-05,62 216 | 1.194545e-05,ce 217 | 1.200095e-05,39 218 | 1.205653e-05,09 219 | 1.211205e-05,f6 220 | 1.216754e-05,7d 221 | 1.222312e-05,76 222 | 1.227869e-05,5f 223 | 1.233426e-05,39 224 | 1.238985e-05,K.bc 225 | 1.244538e-05,4a 226 | 1.250094e-05,4a 227 | 1.255648e-05,7b 228 | 1.261204e-05,K.7c 229 | 1.266757e-05,95 230 | 1.272314e-05,b5 231 | 1.277868e-05,b5 232 | 1.283427e-05,K.7c 233 | 1.288982e-05,95 234 | 1.294536e-05,b5 235 | 1.300089e-05,b5 236 | 1.305647e-05,K.7c 237 | 1.311204e-05,aa 238 | 1.316756e-05,99 239 | 1.322313e-05,99 240 | 1.327869e-05,8d 241 | 1.333428e-05,76 242 | 1.338980e-05,d2 243 | 1.344536e-05,c2 244 | 1.350094e-05,68 245 | 1.355649e-05,b3 246 | 1.361201e-05,26 247 | 1.366757e-05,1f 248 | 1.372315e-05,6c 249 | 1.377872e-05,43 250 | 1.383431e-05,08 251 | 1.388986e-05,a5 252 | 1.394538e-05,54 253 | 1.400092e-05,d3 254 | 1.405646e-05,52 255 | 1.411207e-05,34 256 | 1.416758e-05,02 257 | 1.422314e-05,95 258 | 1.427867e-05,55 259 | 1.433425e-05,8a 260 | 1.438977e-05,1b 261 | 1.444535e-05,be 262 | 1.450089e-05,1a 263 | 1.455646e-05,bb 264 | 1.461199e-05,3d 265 | 1.466756e-05,b7 266 | 1.472307e-05,56 267 | 1.477866e-05,fa 268 | 1.483421e-05,1b 269 | 1.488977e-05,0b 270 | 1.494534e-05,f6 271 | 1.500086e-05,53 272 | 1.505646e-05,41 273 | 1.511206e-05,9c 274 | 1.516762e-05,80 275 | 1.522317e-05,f0 276 | 1.527871e-05,4a 277 | 1.533425e-05,c3 278 | 1.538983e-05,7f 279 | 1.544538e-05,74 280 | 1.550097e-05,91 281 | 1.555656e-05,52 282 | 1.561209e-05,86 283 | 1.566760e-05,be 284 | 1.572315e-05,b6 285 | 1.577874e-05,a7 286 | 1.583427e-05,6f 287 | 1.588979e-05,7a 288 | 1.594534e-05,d6 289 | 1.600087e-05,e6 290 | 1.605641e-05,63 291 | 1.611198e-05,31 292 | 1.616753e-05,0c 293 | 1.622310e-05,fe 294 | 1.627866e-05,36 295 | 1.633423e-05,f0 296 | 1.638977e-05,29 297 | 1.644534e-05,ea 298 | 1.650086e-05,f3 299 | 1.655644e-05,1e 300 | 1.661195e-05,94 301 | 1.666755e-05,26 302 | 1.672312e-05,34 303 | 1.677865e-05,eb 304 | 1.683423e-05,17 305 | 1.688978e-05,3b 306 | 1.694532e-05,85 307 | 1.700088e-05,53 308 | 1.705645e-05,4d 309 | 1.711202e-05,dc 310 | 1.716755e-05,4a 311 | 1.722309e-05,e9 312 | 1.727861e-05,88 313 | 1.733416e-05,0e 314 | 1.738974e-05,20 315 | 1.744528e-05,5d 316 | 1.750083e-05,d0 317 | 1.755635e-05,ed 318 | 1.761191e-05,01 319 | 1.766746e-05,69 320 | 1.772301e-05,de 321 | 1.777857e-05,38 322 | 1.783415e-05,9e 323 | 1.788973e-05,fa 324 | 1.794528e-05,07 325 | 1.800083e-05,4b 326 | 1.805635e-05,db 327 | 1.811192e-05,68 328 | 1.816749e-05,7b 329 | 1.822310e-05,43 330 | 1.827868e-05,0a 331 | 1.833420e-05,45 332 | 1.838978e-05,08 333 | 1.844535e-05,d7 334 | 1.850088e-05,0d 335 | 1.855645e-05,96 336 | 1.861203e-05,98 337 | 1.866756e-05,e6 338 | 1.872311e-05,35 339 | 1.877863e-05,3f 340 | 1.883416e-05,a5 341 | 1.888975e-05,98 342 | 1.894530e-05,76 343 | 1.900082e-05,fe 344 | 1.905635e-05,15 345 | 1.911190e-05,f7 346 | 1.916749e-05,0e 347 | 1.922307e-05,c8 348 | 1.927863e-05,af 349 | 1.933417e-05,90 350 | 1.938978e-05,60 351 | 1.944532e-05,66 352 | 1.950084e-05,cb 353 | 1.955640e-05,d5 354 | 1.961196e-05,f0 355 | 1.966753e-05,fa 356 | 1.972311e-05,9f 357 | 1.977864e-05,00 358 | 1.983424e-05,82 359 | 1.988976e-05,2b 360 | 1.994532e-05,91 361 | 2.000086e-05,74 362 | 2.005644e-05,31 363 | 2.011202e-05,0e 364 | 2.016758e-05,1e 365 | 2.022312e-05,6a 366 | 2.027863e-05,f4 367 | 2.033419e-05,76 368 | 2.038977e-05,48 369 | 2.044530e-05,69 370 | 2.050089e-05,6d 371 | 2.055642e-05,f4 372 | 2.061200e-05,93 373 | 2.066753e-05,8a 374 | 2.072309e-05,cd 375 | 2.077864e-05,7b 376 | 2.083422e-05,7e 377 | 2.088977e-05,ad 378 | 2.094529e-05,13 379 | 2.100085e-05,15 380 | 2.105639e-05,ee 381 | 2.111191e-05,fe 382 | 2.116747e-05,72 383 | 2.122303e-05,1e 384 | 2.127855e-05,3b 385 | 2.133413e-05,aa 386 | 2.138970e-05,14 387 | 2.144524e-05,a0 388 | 2.150081e-05,e7 389 | 2.155633e-05,d4 390 | 2.161193e-05,aa 391 | 2.166751e-05,23 392 | 2.172306e-05,67 393 | 2.177862e-05,9e 394 | 2.183414e-05,dc 395 | 2.188972e-05,b0 396 | 2.194528e-05,fb 397 | 2.200078e-05,73 398 | 2.205634e-05,a5 399 | 2.211190e-05,e0 400 | 2.216748e-05,4f 401 | 2.222303e-05,94 402 | 2.227859e-05,ca 403 | 2.233412e-05,06 404 | 2.238968e-05,12 405 | 2.244528e-05,92 406 | 2.250080e-05,e2 407 | 2.255636e-05,63 408 | 2.261191e-05,6d 409 | 2.266747e-05,62 410 | 2.272302e-05,78 411 | 2.277860e-05,45 412 | 2.283416e-05,93 413 | 2.288976e-05,0c 414 | 2.294531e-05,26 415 | 2.300083e-05,53 416 | 2.305637e-05,02 417 | 2.311190e-05,22 418 | 2.316744e-05,59 419 | 2.322300e-05,3e 420 | 2.327851e-05,63 421 | 2.333402e-05,ca 422 | 2.338965e-05,6e 423 | 2.344519e-05,2b 424 | 2.350077e-05,K.7c 425 | 2.355630e-05,b5 426 | 2.361185e-05,37 427 | 2.366742e-05,37 428 | 2.372301e-05,72 429 | 2.377858e-05,89 430 | 2.383419e-05,2d 431 | 2.388975e-05,cd 432 | 2.394530e-05,32 433 | 2.400084e-05,e9 434 | 2.405641e-05,7c 435 | 2.411191e-05,45 436 | 2.416747e-05,3e 437 | 2.422301e-05,04 438 | 2.427855e-05,3c 439 | 2.433409e-05,b0 440 | 2.438972e-05,K.7c 441 | 2.444526e-05,b5 442 | 2.450081e-05,d5 443 | 2.455632e-05,d5 444 | 2.461188e-05,K.7c 445 | 2.466740e-05,95 446 | 2.472297e-05,b5 447 | 2.477853e-05,b5 448 | 2.483406e-05,K.7c 449 | 2.488966e-05,95 450 | 2.494524e-05,b5 451 | 2.500082e-05,b5 452 | 2.505635e-05,K.7c 453 | 2.511187e-05,aa 454 | 2.516747e-05,99 455 | 2.522305e-05,99 456 | 2.527856e-05,8d 457 | 2.533413e-05,76 458 | 2.538969e-05,d2 459 | 2.544526e-05,c2 460 | 2.550085e-05,68 461 | 2.555640e-05,b3 462 | 2.561192e-05,26 463 | 2.566749e-05,1f 464 | 2.572302e-05,6c 465 | 2.577857e-05,43 466 | 2.583409e-05,08 467 | 2.588965e-05,a5 468 | 2.594518e-05,54 469 | 2.600074e-05,d3 470 | 2.605631e-05,52 471 | 2.611186e-05,34 472 | 2.616744e-05,02 473 | 2.622295e-05,95 474 | 2.627854e-05,55 475 | 2.633413e-05,8a 476 | 2.638964e-05,1b 477 | 2.644520e-05,be 478 | 2.650077e-05,1a 479 | 2.655635e-05,bb 480 | 2.661185e-05,K.bc 481 | 2.666741e-05,4a 482 | 2.672298e-05,4a 483 | 2.677848e-05,7b 484 | 2.683404e-05,K.7c 485 | 2.688960e-05,95 486 | 2.694513e-05,b5 487 | 2.700072e-05,b5 488 | 2.705626e-05,K.7c 489 | 2.711180e-05,95 490 | 2.716733e-05,b5 491 | 2.722291e-05,b5 492 | 2.727848e-05,K.7c 493 | 2.733404e-05,aa 494 | 2.738961e-05,99 495 | 2.744520e-05,99 496 | 2.750074e-05,8d 497 | 2.755628e-05,76 498 | 2.761187e-05,d2 499 | 2.766742e-05,c2 500 | 2.772296e-05,68 501 | 2.777851e-05,b3 502 | 2.783410e-05,26 503 | 2.788967e-05,1f 504 | 2.794519e-05,6c 505 | 2.800072e-05,43 506 | 2.805628e-05,08 507 | 2.811184e-05,a5 508 | 2.816741e-05,54 509 | 2.822298e-05,d3 510 | 2.827852e-05,52 511 | 2.833413e-05,34 512 | 2.838962e-05,02 513 | 2.844522e-05,95 514 | 2.850076e-05,55 515 | 2.855629e-05,8a 516 | 2.861183e-05,1b 517 | 2.866735e-05,be 518 | 2.872293e-05,1a 519 | 2.877851e-05,bb 520 | 2.883407e-05,3d 521 | 2.888964e-05,b7 522 | 2.894518e-05,56 523 | 2.900076e-05,fa 524 | 2.905628e-05,1b 525 | 2.911184e-05,0b 526 | 2.916739e-05,f6 527 | 2.922297e-05,53 528 | 2.927853e-05,41 529 | 2.933406e-05,9c 530 | 2.938961e-05,80 531 | 2.944524e-05,f0 532 | 2.950076e-05,4a 533 | 2.955628e-05,c3 534 | 2.961184e-05,7f 535 | 2.966740e-05,74 536 | 2.972297e-05,91 537 | 2.977852e-05,52 538 | 2.983409e-05,86 539 | 2.988964e-05,be 540 | 2.994518e-05,b6 541 | 3.000075e-05,a7 542 | 3.005629e-05,6f 543 | 3.011184e-05,7a 544 | 3.016740e-05,d6 545 | 3.022296e-05,e6 546 | 3.027853e-05,63 547 | 3.033404e-05,31 548 | 3.038960e-05,0c 549 | 3.044516e-05,fe 550 | 3.050068e-05,36 551 | 3.055624e-05,f0 552 | 3.061180e-05,29 553 | 3.066741e-05,ea 554 | 3.072296e-05,f3 555 | 3.077846e-05,1e 556 | 3.083400e-05,94 557 | 3.088958e-05,26 558 | 3.094514e-05,34 559 | 3.100070e-05,eb 560 | 3.105624e-05,17 561 | 3.111181e-05,3b 562 | 3.116739e-05,85 563 | 3.122297e-05,53 564 | 3.127850e-05,4d 565 | 3.133411e-05,dc 566 | 3.138966e-05,4a 567 | 3.144515e-05,e9 568 | 3.150071e-05,88 569 | 3.155627e-05,0e 570 | 3.161182e-05,20 571 | 3.166737e-05,5d 572 | 3.172289e-05,d0 573 | 3.177842e-05,ed 574 | 3.183400e-05,01 575 | 3.188958e-05,69 576 | 3.194510e-05,de 577 | 3.200071e-05,38 578 | 3.205624e-05,9e 579 | 3.211180e-05,fa 580 | 3.216735e-05,07 581 | 3.222287e-05,4b 582 | 3.227843e-05,db 583 | 3.233395e-05,68 584 | 3.238955e-05,7b 585 | 3.244512e-05,43 586 | 3.250076e-05,0a 587 | 3.255628e-05,45 588 | 3.261182e-05,08 589 | 3.266735e-05,d7 590 | 3.272288e-05,0d 591 | 3.277843e-05,96 592 | 3.283398e-05,98 593 | 3.288957e-05,e6 594 | 3.294512e-05,35 595 | 3.300063e-05,3f 596 | 3.305622e-05,a5 597 | 3.311179e-05,98 598 | 3.316731e-05,76 599 | 3.322289e-05,fe 600 | 3.327844e-05,15 601 | 3.333398e-05,f7 602 | 3.338956e-05,0e 603 | 3.344511e-05,c8 604 | 3.350074e-05,af 605 | 3.355626e-05,90 606 | 3.361183e-05,60 607 | 3.366734e-05,66 608 | 3.372292e-05,cb 609 | 3.377845e-05,d5 610 | 3.383401e-05,f0 611 | 3.388954e-05,fa 612 | 3.394511e-05,9f 613 | 3.400072e-05,00 614 | 3.405624e-05,82 615 | 3.411177e-05,2b 616 | 3.416733e-05,91 617 | 3.422289e-05,74 618 | 3.427846e-05,31 619 | 3.433401e-05,0e 620 | 3.438956e-05,1e 621 | 3.444515e-05,6a 622 | 3.450065e-05,f4 623 | 3.455619e-05,76 624 | 3.461174e-05,48 625 | 3.466729e-05,69 626 | 3.472285e-05,6d 627 | 3.477841e-05,f4 628 | 3.483400e-05,93 629 | 3.488955e-05,8a 630 | 3.494512e-05,cd 631 | 3.500069e-05,7b 632 | 3.505622e-05,7e 633 | 3.511176e-05,ad 634 | 3.516730e-05,13 635 | 3.522281e-05,15 636 | 3.527845e-05,ee 637 | 3.533396e-05,fe 638 | 3.538952e-05,72 639 | 3.544512e-05,1e 640 | 3.550069e-05,3b 641 | 3.555623e-05,aa 642 | 3.561176e-05,14 643 | 3.566731e-05,a0 644 | 3.572285e-05,e7 645 | 3.577839e-05,d4 646 | 3.583395e-05,aa 647 | 3.588950e-05,23 648 | 3.594508e-05,67 649 | 3.600062e-05,9e 650 | 3.605620e-05,dc 651 | 3.611172e-05,b0 652 | 3.616728e-05,fb 653 | 3.622282e-05,73 654 | 3.627840e-05,a5 655 | 3.633394e-05,e0 656 | 3.638949e-05,4f 657 | 3.644510e-05,94 658 | 3.650058e-05,ca 659 | 3.655618e-05,06 660 | 3.661177e-05,12 661 | 3.666729e-05,92 662 | 3.672284e-05,e2 663 | 3.677842e-05,63 664 | 3.683393e-05,6d 665 | 3.688951e-05,62 666 | 3.694512e-05,78 667 | 3.700063e-05,45 668 | 3.705623e-05,93 669 | 3.711177e-05,0c 670 | 3.716727e-05,26 671 | 3.722287e-05,53 672 | 3.727840e-05,02 673 | 3.733390e-05,22 674 | 3.738953e-05,59 675 | 3.744509e-05,3e 676 | 3.750068e-05,63 677 | 3.755622e-05,ca 678 | 3.761175e-05,6e 679 | 3.766730e-05,2b 680 | 3.772288e-05,1f 681 | 3.777841e-05,1f 682 | 3.783401e-05,6a 683 | 3.788953e-05,63 684 | 3.794509e-05,ed 685 | 3.800064e-05,a9 686 | 3.805624e-05,b5 687 | 3.811177e-05,35 688 | 3.816734e-05,fd 689 | 3.822287e-05,a0 690 | 3.827839e-05,a2 691 | 3.833395e-05,4a 692 | 3.838950e-05,96 693 | 3.844506e-05,e1 694 | 3.850062e-05,af 695 | 3.855616e-05,71 696 | 3.861174e-05,62 697 | 3.866729e-05,7b 698 | 3.872284e-05,d5 699 | 3.877838e-05,e1 700 | 3.883391e-05,8a 701 | 3.888949e-05,56 702 | 3.894508e-05,a0 703 | 3.900069e-05,55 704 | 3.905620e-05,68 705 | 3.911173e-05,89 706 | 3.916734e-05,d1 707 | 3.922286e-05,82 708 | 3.927843e-05,ff 709 | 3.933400e-05,b4 710 | 3.938953e-05,4c 711 | 3.944510e-05,23 712 | 3.950062e-05,7f 713 | 3.955613e-05,1e 714 | 3.961169e-05,48 715 | 3.966725e-05,83 716 | 3.972278e-05,7f 717 | 3.977838e-05,e8 718 | 3.983392e-05,1a 719 | 3.988950e-05,b2 720 | 3.994505e-05,cd 721 | 4.000064e-05,ea 722 | 4.005611e-05,c5 723 | 4.011170e-05,a9 724 | 4.016728e-05,c3 725 | 4.022283e-05,ac 726 | 4.027840e-05,01 727 | 4.033393e-05,62 728 | 4.038944e-05,ce 729 | 4.044498e-05,39 730 | 4.050055e-05,09 731 | 4.055613e-05,f6 732 | 4.061169e-05,7d 733 | 4.066725e-05,76 734 | 4.072280e-05,5f 735 | 4.077829e-05,39 736 | 4.083386e-05,K.bc 737 | 4.088944e-05,4a 738 | 4.094498e-05,4a 739 | 4.100052e-05,7b 740 | 4.105610e-05,K.7c 741 | 4.111163e-05,95 742 | 4.116720e-05,b5 743 | 4.122276e-05,b5 744 | 4.127830e-05,K.7c 745 | 4.133390e-05,95 746 | 4.138943e-05,b5 747 | 4.144496e-05,b5 748 | 4.150052e-05,K.7c 749 | 4.155608e-05,aa 750 | 4.161169e-05,99 751 | 4.166722e-05,99 752 | 4.172276e-05,8d 753 | 4.177827e-05,76 754 | 4.183388e-05,d2 755 | 4.188946e-05,c2 756 | 4.194502e-05,68 757 | 4.200054e-05,b3 758 | 4.205611e-05,26 759 | 4.211171e-05,1f 760 | 4.216728e-05,6c 761 | 4.222280e-05,43 762 | 4.227836e-05,08 763 | 4.233386e-05,a5 764 | 4.238942e-05,54 765 | 4.244499e-05,d3 766 | 4.250050e-05,52 767 | 4.255609e-05,34 768 | 4.261168e-05,02 769 | 4.266724e-05,95 770 | 4.272282e-05,55 771 | 4.277833e-05,8a 772 | 4.283389e-05,1b 773 | 4.288945e-05,be 774 | 4.294498e-05,1a 775 | 4.300052e-05,bb 776 | 4.305609e-05,3d 777 | 4.311165e-05,b7 778 | 4.316722e-05,56 779 | 4.322277e-05,fa 780 | 4.327832e-05,1b 781 | 4.333385e-05,0b 782 | 4.338943e-05,f6 783 | 4.344501e-05,53 784 | 4.350054e-05,41 785 | 4.355608e-05,9c 786 | 4.361165e-05,80 787 | 4.366721e-05,f0 788 | 4.372279e-05,4a 789 | 4.377831e-05,c3 790 | 4.383385e-05,7f 791 | 4.388946e-05,74 792 | 4.394501e-05,91 793 | 4.400055e-05,52 794 | 4.405608e-05,86 795 | 4.411167e-05,be 796 | 4.416724e-05,b6 797 | 4.422281e-05,a7 798 | 4.427830e-05,6f 799 | 4.433388e-05,7a 800 | 4.438943e-05,d6 801 | 4.444499e-05,e6 802 | 4.450056e-05,63 803 | 4.455607e-05,31 804 | 4.461164e-05,0c 805 | 4.466726e-05,fe 806 | 4.472280e-05,36 807 | 4.477838e-05,f0 808 | 4.483392e-05,29 809 | 4.488950e-05,ea 810 | 4.494503e-05,f3 811 | 4.500053e-05,1e 812 | 4.505613e-05,94 813 | 4.511168e-05,26 814 | 4.516723e-05,34 815 | 4.522274e-05,eb 816 | 4.527828e-05,17 817 | 4.533388e-05,3b 818 | 4.538943e-05,85 819 | 4.544495e-05,53 820 | 4.550050e-05,4d 821 | 4.555612e-05,dc 822 | 4.561162e-05,4a 823 | 4.566719e-05,e9 824 | 4.572274e-05,88 825 | 4.577828e-05,0e 826 | 4.583383e-05,20 827 | 4.588938e-05,5d 828 | 4.594490e-05,d0 829 | 4.600048e-05,ed 830 | 4.605607e-05,01 831 | 4.611165e-05,69 832 | 4.616720e-05,de 833 | 4.622278e-05,38 834 | 4.627829e-05,9e 835 | 4.633385e-05,fa 836 | 4.638940e-05,07 837 | 4.644489e-05,4b 838 | 4.650049e-05,db 839 | 4.655606e-05,68 840 | 4.661160e-05,7b 841 | 4.666714e-05,43 842 | 4.672275e-05,0a 843 | 4.677827e-05,45 844 | 4.683383e-05,08 845 | 4.688939e-05,d7 846 | 4.694488e-05,0d 847 | 4.700048e-05,96 848 | 4.705607e-05,98 849 | 4.711164e-05,e6 850 | 4.716720e-05,35 851 | 4.722275e-05,3f 852 | 4.727827e-05,a5 853 | 4.733383e-05,98 854 | 4.738942e-05,76 855 | 4.744495e-05,fe 856 | 4.750052e-05,15 857 | 4.755607e-05,f7 858 | 4.761162e-05,0e 859 | 4.766718e-05,c8 860 | 4.772274e-05,af 861 | 4.777825e-05,90 862 | 4.783380e-05,60 863 | 4.788935e-05,66 864 | 4.794490e-05,cb 865 | 4.800043e-05,d5 866 | 4.805598e-05,f0 867 | 4.811154e-05,fa 868 | 4.816707e-05,9f 869 | 4.822260e-05,00 870 | 4.827818e-05,82 871 | 4.833377e-05,2b 872 | 4.838933e-05,91 873 | 4.844489e-05,74 874 | 4.850046e-05,31 875 | 4.855598e-05,0e 876 | 4.861159e-05,1e 877 | 4.866718e-05,6a 878 | 4.872271e-05,f4 879 | 4.877829e-05,76 880 | 4.883382e-05,48 881 | 4.888937e-05,69 882 | 4.894490e-05,6d 883 | 4.900050e-05,f4 884 | 4.905604e-05,93 885 | 4.911158e-05,8a 886 | 4.916712e-05,cd 887 | 4.922269e-05,7b 888 | 4.927822e-05,7e 889 | 4.933375e-05,ad 890 | 4.938928e-05,13 891 | 4.944483e-05,15 892 | 4.950044e-05,ee 893 | 4.955598e-05,fe 894 | 4.961154e-05,72 895 | 4.966711e-05,1e 896 | 4.972268e-05,3b 897 | 4.977822e-05,aa 898 | 4.983375e-05,14 899 | 4.988932e-05,a0 900 | -------------------------------------------------------------------------------- /CH569_SerDes_180Mbps/CH569_SerDes_180Mbps.csv_res.txt: -------------------------------------------------------------------------------- 1 | CH569 SerDes data capture extractor(Descramble/check CRC32) v1.0 by B.VERNOUX 08 Jun 2022 2 | 3 | SerDes SOF data(HEX) packet1 at 0.00002350s/23.50us: 4 | 0FFFFFFF (SerDes HDR at 0.00002372s/23.72us) 5 | 5A5A5A5A 15344752 (SerDes CRC32 OK(Nb32bits=2) at 0.00002439s/24.39us) 6 | -------------------------------------------------------------------------------- /CH569_SerDes_180Mbps/README.md: -------------------------------------------------------------------------------- 1 | ### Example capture & descamble of CH569 SerDes at 180Mbps 2 | 3 | * Rigol MSO5000 Series bin capture file: `CH569_SerDes_180Mbps.bin` 4 | * Pre-configured glscopeclient session file: `CH569_SerDes_180Mbps.bin.scopesession` 5 | * glscopeclient exported "8b10bIBM_Hex" CSV data: `CH569_SerDes_180Mbps.csv` 6 | 7 | 8 | * CH569_SerDes_Descramble_glscopeclient_CSV_8b10bIBM_Hex descrambled results (using `CH569_SerDes_180Mbps.csv` as input): `SerDes_180Mbps.csv_res.txt` 9 | ``` 10 | CH569 SerDes data capture extractor(Descramble/check CRC32) v1.0 by B.VERNOUX 08 Jun 2022 11 | 12 | SerDes SOF data(HEX) packet1 at 0.00002350s/23.50us: 13 | 0FFFFFFF (SerDes HDR at 0.00002372s/23.72us) 14 | 5A5A5A5A 15344752 (SerDes CRC32 OK(Nb32bits=2) at 0.00002439s/24.39us) 15 | ``` 16 | -------------------------------------------------------------------------------- /CH569_SerDes_Descramble_glscopeclient_CSV_8b10bIBM_Hex/CH569_SerDes_Descramble_glscopeclient_CSV_8b10bIBM_Hex.c: -------------------------------------------------------------------------------- 1 | /* 2 | CH569_SerDes_Descramble_glscopeclient_CSV_8b10bIBM_Hex.c 3 | Code by B.VERNOUX 8 June 2022 4 | * SATA spec see https://www.seagate.com/support/disc/manuals/sata/SERDES_im.pdf 5 | 6 | Code used: 7 | * https://github.com/jandoczy/csv-fast-reader.git 8 | */ 9 | #include 10 | #include 11 | #include 12 | 13 | #include "csv.h" 14 | #include "crc32_SATA.h" 15 | 16 | /* For more details see SATA spec https://www.seagate.com/support/disc/manuals/sata/SERDES_im.pdf */ 17 | #define SERDES_PRIMITIVE_SOF (0x7CB53737) 18 | #define SERDES_PRIMITIVE_EOF (0x7CB5D5D5) 19 | 20 | #define SERDES_PRIMITIVE_SYNC (0x7C95B5B5) 21 | #define SERDES_PRIMITIVE_CONT (0x7CAA9999) 22 | 23 | #define SERDES_PRIMITIVE_ALIGN (0xBC4A4A7B) 24 | 25 | #define TIME_S_TO_MICROSEC (1000*1000) 26 | 27 | static int serdes_start_data = 0; /* 1=SOF received (reset to 0 after EOF) */ 28 | static int serdes_first_end_data = 0; /* 1=1st EOF received */ 29 | #define MAX_NB_32BITS (65536) 30 | static uint32_t scrambler_data[MAX_NB_32BITS]; 31 | static uint32_t data_u32_buf[MAX_NB_32BITS]; 32 | 33 | /* 34 | This code generates the entire sequence of 65535 Dwords produced 35 | by the scrambler defined in the Serial ATA specification 36 | */ 37 | void scramble(void) 38 | { 39 | int i, j; 40 | uint16_t context; /* The 16 bit register that holds the context or state */ 41 | uint32_t scrambler; /* The 32 bit output of the circuit */ 42 | uint8_t now[16]; /* The individual bits of context */ 43 | uint8_t next[32]; /* The computed bits of scrambler */ 44 | /* Parallelized versions of the scrambler are initialized to a value */ 45 | /* derived from the initialization value of 0xFFFF defined in the */ 46 | /* specification. This implementation is initialized to 0xF0F6. Other */ 47 | /* parallel implementations will have different initial values. The */ 48 | /* important point is that the first Dword output of any implementation */ 49 | /* must equal 0xC2D2768D. */ 50 | context = 0xF0F6; 51 | for (i = 0; i < 65535; ++i) 52 | { 53 | /* Split the register contents (the variable context) up into its */ 54 | /* individual bits for easy handling. */ 55 | for (j = 0; j < 16; ++j) 56 | { 57 | now[j] = (context >> j) & 0x01; 58 | } 59 | /* The following 16 assignments implement the matrix multiplication */ 60 | /* performed by the box labeled *M1. */ 61 | /* Notice that there are lots of shared terms in these assignments. */ 62 | next[31] = now[12] ^ now[10] ^ now[7] ^ now[3] ^ now[1] ^ now[0]; 63 | next[30] = now[15] ^ now[14] ^ now[12] ^ now[11] ^ now[9] ^ now[6] ^ now[3] ^ now[2] ^ now[0]; 64 | next[29] = now[15] ^ now[13] ^ now[12] ^ now[11] ^ now[10] ^ now[8] ^ now[5] ^ now[3] ^ now[2] ^ now[1]; 65 | next[28] = now[14] ^ now[12] ^ now[11] ^ now[10] ^ now[9] ^ now[7] ^ now[4] ^ now[2] ^ now[1] ^ now[0]; 66 | next[27] = now[15] ^ now[14] ^ now[13] ^ now[12] ^ now[11] ^ now[10] ^ now[9] ^ now[8] ^ now[6] ^ now[1] ^ now[0]; 67 | next[26] = now[15] ^ now[13] ^ now[11] ^ now[10] ^ now[9] ^ now[8] ^ now[7] ^ now[5] ^ now[3] ^ now[0]; 68 | next[25] = now[15] ^ now[10] ^ now[9] ^ now[8] ^ now[7] ^ now[6] ^ now[4] ^ now[3] ^ now[2]; 69 | next[24] = now[14] ^ now[9] ^ now[8] ^ now[7] ^ now[6] ^ now[5] ^ now[3] ^ now[2] ^ now[1]; 70 | next[23] = now[13] ^ now[8] ^ now[7] ^ now[6] ^ now[5] ^ now[4] ^ now[2] ^ now[1] ^ now[0]; 71 | next[22] = now[15] ^ now[14] ^ now[7] ^ now[6] ^ now[5] ^ now[4] ^ now[1] ^ now[0]; 72 | next[21] = now[15] ^ now[13] ^ now[12] ^ now[6] ^ now[5] ^ now[4] ^ now[0]; 73 | next[20] = now[15] ^ now[11] ^ now[5] ^ now[4]; 74 | next[19] = now[14] ^ now[10] ^ now[4] ^ now[3]; 75 | next[18] = now[13] ^ now[9] ^ now[3] ^ now[2]; 76 | next[17] = now[12] ^ now[8] ^ now[2] ^ now[1]; 77 | next[16] = now[11] ^ now[7] ^ now[1] ^ now[0]; 78 | /* The following 16 assignments implement the matrix multiplication */ 79 | /* performed by the box labeled *M2. */ 80 | next[15] = now[15] ^ now[14] ^ now[12] ^ now[10] ^ now[6] ^ now[3] ^ now[0]; 81 | next[14] = now[15] ^ now[13] ^ now[12] ^ now[11] ^ now[9] ^ now[5] ^ now[3] ^ now[2]; 82 | next[13] = now[14] ^ now[12] ^ now[11] ^ now[10] ^ now[8] ^ now[4] ^ now[2] ^ now[1]; 83 | next[12] = now[13] ^ now[11] ^ now[10] ^ now[9] ^ now[7] ^ now[3] ^ now[1] ^ now[0]; 84 | next[11] = now[15] ^ now[14] ^ now[10] ^ now[9] ^ now[8] ^ now[6] ^ now[3] ^ now[2] ^ now[0]; 85 | next[10] = now[15] ^ now[13] ^ now[12] ^ now[9] ^ now[8] ^ now[7] ^ now[5] ^ now[3] ^ now[2] ^ now[1]; 86 | next[9] = now[14] ^ now[12] ^ now[11] ^ now[8] ^ now[7] ^ now[6] ^ now[4] ^ now[2] ^ now[1] ^ now[0]; 87 | next[8] = now[15] ^ now[14] ^ now[13] ^ now[12] ^ now[11] ^ now[10] ^ now[7] ^ now[6] ^ now[5] ^ now[1] ^ now[0]; 88 | next[7] = now[15] ^ now[13] ^ now[11] ^ now[10] ^ now[9] ^ now[6] ^ now[5] ^ now[4] ^ now[3] ^ now[0]; 89 | next[6] = now[15] ^ now[10] ^ now[9] ^ now[8] ^ now[5] ^ now[4] ^ now[2]; 90 | next[5] = now[14] ^ now[9] ^ now[8] ^ now[7] ^ now[4] ^ now[3] ^ now[1]; 91 | next[4] = now[13] ^ now[8] ^ now[7] ^ now[6] ^ now[3] ^ now[2] ^ now[0]; 92 | next[3] = now[15] ^ now[14] ^ now[7] ^ now[6] ^ now[5] ^ now[3] ^ now[2] ^ now[1]; 93 | next[2] = now[14] ^ now[13] ^ now[6] ^ now[5] ^ now[4] ^ now[2] ^ now[1] ^ now[0]; 94 | next[1] = now[15] ^ now[14] ^ now[13] ^ now[5] ^ now[4] ^ now[1] ^ now[0]; 95 | next[0] = now[15] ^ now[13] ^ now[4] ^ now[0]; 96 | /* The 32 bits of the output have been generated in the "next" array. */ 97 | /* Reassemble the bits into a 32 bit Dword. */ 98 | scrambler = 0; 99 | for (j = 31; j >= 0; --j) 100 | { 101 | scrambler = scrambler << 1; 102 | scrambler |= next[j]; 103 | } 104 | /* The upper half of the scrambler output is stored backed into the */ 105 | /* register as the saved context for the next cycle. */ 106 | context = scrambler >> 16; 107 | scrambler_data[i] = scrambler; 108 | } 109 | return 0; 110 | } 111 | 112 | char* read_data_str(CsvHandle handle) 113 | { 114 | char* row = NULL; 115 | row = CsvReadNextRow(handle); 116 | if(row) 117 | { 118 | char* time_s; 119 | // 1st col "Time (s)" 120 | time_s = CsvReadNextCol(row, handle); 121 | if(time_s != NULL) 122 | { 123 | // 2nd Col "8b10bIBM_Hex" 124 | return CsvReadNextCol(row, handle); 125 | }else 126 | { 127 | return NULL; 128 | } 129 | }else 130 | { 131 | return NULL; 132 | } 133 | } 134 | 135 | /* 136 | Return 137 | 0=End of file 138 | 1=PRIMITIVE 139 | 2=DATA(SATA SOF detected) 140 | 3=NO DATA(SATA No SOF detected or EOF) 141 | 4=ERROR on DATA 142 | */ 143 | int read_data(CsvHandle handle, uint32_t* data_u32, double* data_time_s) 144 | { 145 | static int start_data = 0; /* 1=SOF received (reset to 0 after EOF) */ 146 | #define DATA32BITS_ASCII_HEX_LEN (8*2) 147 | char* data32bits_ASCII_HEX[DATA32BITS_ASCII_HEX_LEN+1] = { 0 }; 148 | char* row = NULL; 149 | 150 | row = CsvReadNextRow(handle); 151 | if(row) 152 | { 153 | const char* time; 154 | const char* data; 155 | time = CsvReadNextCol(row, handle); // 1st col "Time (s)" 156 | if(time == NULL) 157 | { 158 | return 0; /* Error end of file */ 159 | } 160 | *data_time_s = atof(time); 161 | data = CsvReadNextCol(row, handle); // 2nd Col "8b10bIBM_Hex" 162 | if(data != NULL) 163 | { 164 | if(data[0] == 'K' && data[1] == '.') // 165 | { 166 | int i; 167 | /* Read 4 Bytes */ 168 | strncat(data32bits_ASCII_HEX, &data[2], 2); 169 | for(i = 1; i < 4; i++) 170 | { 171 | data = read_data_str(handle); 172 | if(data != NULL) 173 | { 174 | if( strcmp(data, "ERROR") != 0 ) 175 | { 176 | strncat(data32bits_ASCII_HEX, data, 2); 177 | }else 178 | { 179 | return 4; /* ERROR on Data */ 180 | } 181 | }else 182 | { 183 | return 0; /* Error end of file */ 184 | } 185 | } 186 | *data_u32 = strtoul(data32bits_ASCII_HEX, NULL, 16); 187 | switch(*data_u32) 188 | { 189 | case SERDES_PRIMITIVE_SOF: 190 | start_data = 1; 191 | break; 192 | 193 | case SERDES_PRIMITIVE_EOF: 194 | start_data = 0; 195 | break; 196 | 197 | default: /* Nothing to do */ 198 | break; 199 | } 200 | return 1; // PRIMITIVE 201 | } 202 | 203 | if( strcmp(data, "ERROR") != 0 ) 204 | { 205 | const char* Bytes[4]; /* SATA Primitive encoding Byte0 to Byte3 Little Endian */ 206 | int i; 207 | if(start_data != 1) 208 | { 209 | return 3; /* NO DATA (SATA SOF not detected or EOF) */ 210 | } 211 | /* Read 4 Bytes */ 212 | Bytes[0] = &data[0]; 213 | for(i = 1; i < 4; i++) 214 | { 215 | data = read_data_str(handle); 216 | if(data != NULL) 217 | { 218 | if( strcmp(data, "ERROR") != 0 ) 219 | { 220 | Bytes[i] = data; 221 | }else 222 | { 223 | return 4; /* ERROR on Data */ 224 | } 225 | }else 226 | { 227 | return 0; /* Error end of file */ 228 | } 229 | } 230 | /* Reorder bytes MSB to LSB */ 231 | snprintf(data32bits_ASCII_HEX, DATA32BITS_ASCII_HEX_LEN, "%s%s%s%s", 232 | Bytes[3], Bytes[2], Bytes[1], Bytes[0]); 233 | *data_u32 = strtoul(data32bits_ASCII_HEX, NULL, 16); 234 | return 2; // DATA(SATA SOF detected) 235 | }else 236 | { 237 | return 4; /* ERROR on Data */ 238 | } 239 | }else 240 | { 241 | return 0; /* Error end of file */ 242 | } 243 | }else 244 | { 245 | return 0; /* Error end of file */ 246 | } 247 | } 248 | 249 | int error_exit_invalid_csv_file(CsvHandle handle) 250 | { 251 | printf("Error invalid csv file it shall contains \"Time (s),8b10bIBM_Hex\" data\n"); 252 | fflush(stdout); 253 | CsvClose(handle); 254 | exit(-1); 255 | } 256 | 257 | int main(int argc, char **argv) 258 | { 259 | int i, packet_no, ret; 260 | CsvHandle handle; 261 | uint32_t data_u32; 262 | uint32_t crc32_ret; 263 | uint32_t crc32_expected; 264 | 265 | double data_time_s; 266 | char* data = NULL; 267 | char* time_s = NULL; 268 | char* row = NULL; 269 | char* csvname = NULL; 270 | int verbose = 0; 271 | 272 | printf("CH569 SerDes data capture extractor(Descramble/check CRC32) v1.0 by B.VERNOUX 08 Jun 2022\n"); 273 | if(argc < 2) 274 | { 275 | printf("First parameter is mandatory and shall be set to fullpath *.csv file\nThe csv file shall contain only \"Time (s)\" & \"8b10bIBM_Hex\" data exported from glscopeclient\n"); 276 | exit(-1); 277 | } 278 | csvname = argv[1]; 279 | if(argc == 3) 280 | { 281 | if(strcmp(argv[2], "-v") == 0) 282 | { 283 | printf("Verbose mode\n"); 284 | /* Verbose mode enabled */ 285 | verbose = 1; 286 | } 287 | } 288 | scramble(); 289 | 290 | /* SATA CRC-32 Test */ 291 | #if 0 292 | data_u32_buf[0] = 0x00308027; 293 | data_u32_buf[1] = 0xE1234567; 294 | data_u32_buf[2] = 0x00000000; 295 | data_u32_buf[3] = 0x00000002; 296 | data_u32_buf[4] = 0x00000000; 297 | /* Expected results 298 | Running CRC value is 0x11E353FD 299 | Running CRC value is 0x0F656DA7 300 | Running CRC value is 0x3D14369C 301 | Running CRC value is 0x92D0D681 302 | Running CRC value is 0x319FFF6F 303 | The total number of data words processed was 5 304 | The CRC is 0x319FFF6F 305 | */ 306 | crc32_ret = CRC32_SERDES_START; 307 | for(i = 0; i < 5; i++) 308 | { 309 | crc32_ret = update_crc32_sata(crc32_ret, data_u32_buf[i]); 310 | printf("Running CRC value is 0x%08X\n", crc32_ret); 311 | } 312 | #endif 313 | 314 | handle = CsvOpen2(csvname, ',', '"', '\\'); 315 | if (!handle) 316 | { 317 | printf("Error can not open '%s' file\n", csvname); 318 | return -1; 319 | } 320 | 321 | /* Basic check of csv file format (headers) */ 322 | row = CsvReadNextRow(handle); 323 | if(row) 324 | { 325 | // 1st col "Time (s)" 326 | time_s = CsvReadNextCol(row, handle); 327 | if(time_s != NULL) 328 | { 329 | if(strcmp(time_s, "Time (s)") == 0) 330 | { 331 | // 2nd Col "8b10bIBM_Hex" 332 | data = CsvReadNextCol(row, handle); 333 | if(strcmp(data, "8b10bIBM_Hex") != 0) 334 | { 335 | error_exit_invalid_csv_file(handle); 336 | } 337 | }else 338 | { 339 | error_exit_invalid_csv_file(handle); 340 | } 341 | } else 342 | { 343 | error_exit_invalid_csv_file(handle); 344 | } 345 | }else 346 | { 347 | error_exit_invalid_csv_file(handle); 348 | } 349 | 350 | i = 0; 351 | packet_no = 0; 352 | do 353 | { 354 | ret = read_data(handle, &data_u32, &data_time_s); 355 | switch(ret) 356 | { 357 | case 0: // 0=End Of file 358 | { 359 | break; 360 | } 361 | case 1: // 1=PRIMITIVE 362 | { 363 | //printf("K %06d 0x%08X ", i, data_u32); 364 | switch(data_u32) 365 | { 366 | case SERDES_PRIMITIVE_SOF: 367 | { 368 | serdes_start_data = 1; 369 | i = 0; 370 | packet_no++; 371 | printf("\nSerDes SOF data(HEX) packet%d at %05.08fs/%.02fus:\n", packet_no, data_time_s, data_time_s*TIME_S_TO_MICROSEC); 372 | } 373 | break; 374 | 375 | case SERDES_PRIMITIVE_EOF: 376 | { 377 | if(serdes_start_data == 1) 378 | { 379 | serdes_start_data = 0; 380 | if(i > 0) 381 | { 382 | int j; 383 | crc32_expected = data_u32_buf[i-1]; 384 | /* Check CRC-32 */ 385 | crc32_ret = CRC32_SERDES_START; 386 | for(j = 0; j < (i-1); j++) 387 | { 388 | crc32_ret = update_crc32_sata(crc32_ret, data_u32_buf[j]); 389 | } 390 | if(crc32_ret == crc32_expected) 391 | { 392 | printf("(SerDes CRC32 OK(Nb32bits=%d) at %05.08fs/%.02fus)\n",i-1, data_time_s, data_time_s*TIME_S_TO_MICROSEC); 393 | }else 394 | { 395 | printf("(SerDes CRC32 ERROR !!)\n"); 396 | printf("crc32_expected=0x%08X crc32_ret=0x%08X (Nb32bits=%d)\n", crc32_expected, crc32_ret, i-1); 397 | } 398 | i = 0; 399 | } 400 | }else 401 | { 402 | if(serdes_first_end_data == 1) 403 | printf("\n"); 404 | } 405 | serdes_first_end_data = 1; 406 | } 407 | break; 408 | 409 | case SERDES_PRIMITIVE_SYNC: 410 | { 411 | if(verbose) 412 | { 413 | if(serdes_start_data) 414 | printf("\n"); 415 | printf("SYNC at %05.08fs/%.02fus\n", data_time_s, data_time_s*TIME_S_TO_MICROSEC); 416 | } 417 | } 418 | break; 419 | 420 | case SERDES_PRIMITIVE_CONT: 421 | { 422 | if(verbose) 423 | { 424 | if(serdes_start_data) 425 | printf("\n"); 426 | printf("CONT at %05.08fs/%.02fus\n", data_time_s, data_time_s*TIME_S_TO_MICROSEC); 427 | } 428 | } 429 | break; 430 | 431 | case SERDES_PRIMITIVE_ALIGN: 432 | { 433 | if(verbose) 434 | { 435 | if(serdes_start_data) 436 | printf("\n"); 437 | printf("ALIGN at %05.08fs/%.02fus\n", data_time_s, data_time_s*TIME_S_TO_MICROSEC); 438 | } 439 | } 440 | break; 441 | 442 | default: 443 | { 444 | if(verbose) 445 | printf("\nSerDes unknown primitive: K 0x%08X at %05.08fs/%.02fus\n",data_u32, data_time_s, data_time_s*TIME_S_TO_MICROSEC); 446 | } 447 | } 448 | } 449 | break; 450 | 451 | case 2: // 2=DATA 452 | { 453 | data_u32_buf[i] = (data_u32 ^ scrambler_data[i]); 454 | //printf("D %06d 0x%08X => Descramble 0x%08X\n", i, data_u32, data_u32_buf[i]); 455 | if(i == 0) /* First 32bits is Header => 8bits(including 4bits packet counter) + 24bits Identifier */ 456 | { 457 | printf("%08X (SerDes HDR at %05.08fs/%.02fus)\n", data_u32_buf[i], data_time_s, data_time_s*TIME_S_TO_MICROSEC); 458 | }else 459 | { 460 | printf("%08X ", data_u32_buf[i]); 461 | if( !(i%8) ) 462 | { 463 | printf("\n"); 464 | } 465 | } 466 | if(i < MAX_NB_32BITS) 467 | i++; 468 | } 469 | break; 470 | 471 | case 3: // 3=NO DATA(SATA No SOF detected or EOF) 472 | { 473 | if(verbose) 474 | printf("N 0x%08X at %05.08fs/%.02fus\n",data_u32, data_time_s, data_time_s*TIME_S_TO_MICROSEC); 475 | } 476 | break; 477 | 478 | case 4: // 4=ERROR 479 | { 480 | if(verbose) 481 | printf("\nSerDes DATA ERROR at %05.08fs/%.02fus\n", data_time_s, data_time_s*TIME_S_TO_MICROSEC); 482 | } 483 | break; 484 | 485 | default: // Unknown state 486 | { 487 | if(verbose) 488 | printf("Unknown state %d at %05.08fs/%.02fus\n", ret, data_time_s, data_time_s*TIME_S_TO_MICROSEC); 489 | } 490 | } 491 | }while(ret); 492 | 493 | CsvClose(handle); 494 | if(verbose) 495 | printf("\nEnd of csv file, exit\n"); 496 | return 0; 497 | } 498 | -------------------------------------------------------------------------------- /CH569_SerDes_Descramble_glscopeclient_CSV_8b10bIBM_Hex/Makefile: -------------------------------------------------------------------------------- 1 | 2 | RM=rm -rf 3 | 4 | CC=gcc 5 | CFLAGS=-w -Wall -ansi -std=c99 -O3 6 | LDFLAGS= 7 | EXEC=CH569_SerDes_Descramble_glscopeclient_CSV_8b10bIBM_Hex 8 | STRIP_EXE=strip 9 | 10 | OBJ=CH569_SerDes_Descramble_glscopeclient_CSV_8b10bIBM_Hex.o csv.o crc32_SATA.o 11 | 12 | all: $(EXEC) 13 | 14 | CH569_SerDes_Descramble_glscopeclient_CSV_8b10bIBM_Hex: $(OBJ) 15 | $(CC) -o $@ $^ $(LDFLAGS) 16 | 17 | # Dependencies 18 | 19 | %.o: %.c 20 | $(CC) -o $@ -c $< $(CFLAGS) 21 | 22 | clean: 23 | $(RM) *.o 24 | -------------------------------------------------------------------------------- /CH569_SerDes_Descramble_glscopeclient_CSV_8b10bIBM_Hex/README.md: -------------------------------------------------------------------------------- 1 | ### CH569_SerDes_Descramble_glscopeclient_CSV_8b10bIBM_Hex 2 | 3 | This tool do parsing of glscopeclient "CSV 8b10bIBM_Hex" and descramble & check the CRC of glscopeclient "CSV export of 8b10IBM data" 4 | 5 | The glscopeclient export "CSV 8b10bIBM_Hex" shall contains only following 2 columns (with strict name) 6 | "Time (s)" and "8b10bIBM_Hex" 7 | 8 | ### How to build with Windows Msys2/Mingw64 9 | * Launch "C:\msys64\mingw64.exe" 10 | * cd "current source code dir" 11 | * mingw32-make clean all 12 | 13 | ### How to build with GNU/Linux 14 | * cd "current source code dir" 15 | * make clean all 16 | -------------------------------------------------------------------------------- /CH569_SerDes_Descramble_glscopeclient_CSV_8b10bIBM_Hex/crc32_SATA.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Modified by B.VERNOUX -06 June 2022) for CRC-32 Serial ATA specification 3 | * SATA spec see https://www.seagate.com/support/disc/manuals/sata/sata_im.pdf 4 | */ 5 | #include "crc32_SATA.h" 6 | 7 | /* 8 | * uint32_t update_crc_32( uint32_t crc, uint32_t data_in); 9 | * 10 | * The function update_crc_32() calculates a new CRC-32 value based on the 11 | * previous value of the CRC and the next byte of the data to be checked. 12 | */ 13 | 14 | uint32_t update_crc32_sata(uint32_t crc, uint32_t data_in) 15 | { 16 | int i; 17 | unsigned char crc_bit[32], new_bit[32]; 18 | 19 | /* Add the data_in value to the current value of the CRC held in the */ 20 | /* "register". The addition is performed modulo two (XOR). */ 21 | crc ^= data_in; 22 | /* Expand the value of the CRC held in the register to 32 individual */ 23 | /* bits for easy manipulation. */ 24 | for (i = 0; i < 32; ++i) 25 | { 26 | crc_bit[i] = (crc >> i) & 0x01; 27 | } 28 | /* The following 32 assignments perform the function of the box */ 29 | /* labeled "*" in the block diagram above. The new_bit array is a */ 30 | /* temporary holding place for the new CRC value being calculated. */ 31 | /* Note that there are lots of shared terms in the assignments below. */ 32 | new_bit[31] = crc_bit[31] ^ crc_bit[30] ^ crc_bit[29] ^ crc_bit[28] ^ crc_bit[27] ^ crc_bit[25] ^ crc_bit[24] ^ 33 | crc_bit[23] ^ crc_bit[15] ^ crc_bit[11] ^ crc_bit[9] ^ crc_bit[8] ^ crc_bit[5]; 34 | new_bit[30] = crc_bit[30] ^ crc_bit[29] ^ crc_bit[28] ^ crc_bit[27] ^ crc_bit[26] ^ crc_bit[24] ^ crc_bit[23] ^ 35 | crc_bit[22] ^ crc_bit[14] ^ crc_bit[10] ^ crc_bit[8] ^ crc_bit[7] ^ crc_bit[4]; 36 | new_bit[29] = crc_bit[31] ^ crc_bit[29] ^ crc_bit[28] ^ crc_bit[27] ^ crc_bit[26] ^ crc_bit[25] ^ crc_bit[23] ^ 37 | crc_bit[22] ^ crc_bit[21] ^ crc_bit[13] ^ crc_bit[9] ^ crc_bit[7] ^ crc_bit[6] ^ crc_bit[3]; 38 | new_bit[28] = crc_bit[30] ^ crc_bit[28] ^ crc_bit[27] ^ crc_bit[26] ^ crc_bit[25] ^ crc_bit[24] ^ crc_bit[22] ^ 39 | crc_bit[21] ^ crc_bit[20] ^ crc_bit[12] ^ crc_bit[8] ^ crc_bit[6] ^ crc_bit[5] ^ crc_bit[2]; 40 | new_bit[27] = crc_bit[29] ^ crc_bit[27] ^ crc_bit[26] ^ crc_bit[25] ^ crc_bit[24] ^ crc_bit[23] ^ crc_bit[21] ^ 41 | crc_bit[20] ^ crc_bit[19] ^ crc_bit[11] ^ crc_bit[7] ^ crc_bit[5] ^ crc_bit[4] ^ crc_bit[1]; 42 | new_bit[26] = crc_bit[31] ^ crc_bit[28] ^ crc_bit[26] ^ crc_bit[25] ^ crc_bit[24] ^ crc_bit[23] ^ crc_bit[22] ^ 43 | crc_bit[20] ^ crc_bit[19] ^ crc_bit[18] ^ crc_bit[10] ^ crc_bit[6] ^ crc_bit[4] ^ crc_bit[3] ^ 44 | crc_bit[0]; 45 | new_bit[25] = crc_bit[31] ^ crc_bit[29] ^ crc_bit[28] ^ crc_bit[22] ^ crc_bit[21] ^ crc_bit[19] ^ crc_bit[18] ^ 46 | crc_bit[17] ^ crc_bit[15] ^ crc_bit[11] ^ crc_bit[8] ^ crc_bit[3] ^ crc_bit[2]; 47 | new_bit[24] = crc_bit[30] ^ crc_bit[28] ^ crc_bit[27] ^ crc_bit[21] ^ crc_bit[20] ^ crc_bit[18] ^ crc_bit[17] ^ 48 | crc_bit[16] ^ crc_bit[14] ^ crc_bit[10] ^ crc_bit[7] ^ crc_bit[2] ^ crc_bit[1]; 49 | new_bit[23] = crc_bit[31] ^ crc_bit[29] ^ crc_bit[27] ^ crc_bit[26] ^ crc_bit[20] ^ crc_bit[19] ^ crc_bit[17] ^ 50 | crc_bit[16] ^ crc_bit[15] ^ crc_bit[13] ^ crc_bit[9] ^ crc_bit[6] ^ crc_bit[1] ^ crc_bit[0]; 51 | new_bit[22] = crc_bit[31] ^ crc_bit[29] ^ crc_bit[27] ^ crc_bit[26] ^ crc_bit[24] ^ crc_bit[23] ^ crc_bit[19] ^ 52 | crc_bit[18] ^ crc_bit[16] ^ crc_bit[14] ^ crc_bit[12] ^ crc_bit[11] ^ crc_bit[9] ^ crc_bit[0]; 53 | new_bit[21] = crc_bit[31] ^ crc_bit[29] ^ crc_bit[27] ^ crc_bit[26] ^ crc_bit[24] ^ crc_bit[22] ^ crc_bit[18] ^ 54 | crc_bit[17] ^ crc_bit[13] ^ crc_bit[10] ^ crc_bit[9] ^ crc_bit[5]; 55 | new_bit[20] = crc_bit[30] ^ crc_bit[28] ^ crc_bit[26] ^ crc_bit[25] ^ crc_bit[23] ^ crc_bit[21] ^ crc_bit[17] ^ 56 | crc_bit[16] ^ crc_bit[12] ^ crc_bit[9] ^ crc_bit[8] ^ crc_bit[4]; 57 | new_bit[19] = crc_bit[29] ^ crc_bit[27] ^ crc_bit[25] ^ crc_bit[24] ^ crc_bit[22] ^ crc_bit[20] ^ crc_bit[16] ^ 58 | crc_bit[15] ^ crc_bit[11] ^ crc_bit[8] ^ crc_bit[7] ^ crc_bit[3]; 59 | new_bit[18] = crc_bit[31] ^ crc_bit[28] ^ crc_bit[26] ^ crc_bit[24] ^ crc_bit[23] ^ crc_bit[21] ^ crc_bit[19] ^ 60 | crc_bit[15] ^ crc_bit[14] ^ crc_bit[10] ^ crc_bit[7] ^ crc_bit[6] ^ crc_bit[2]; 61 | new_bit[17] = crc_bit[31] ^ crc_bit[30] ^ crc_bit[27] ^ crc_bit[25] ^ crc_bit[23] ^ crc_bit[22] ^ crc_bit[20] ^ 62 | crc_bit[18] ^ crc_bit[14] ^ crc_bit[13] ^ crc_bit[9] ^ crc_bit[6] ^ crc_bit[5] ^ crc_bit[1]; 63 | new_bit[16] = crc_bit[30] ^ crc_bit[29] ^ crc_bit[26] ^ crc_bit[24] ^ crc_bit[22] ^ crc_bit[21] ^ crc_bit[19] ^ 64 | crc_bit[17] ^ crc_bit[13] ^ crc_bit[12] ^ crc_bit[8] ^ crc_bit[5] ^ crc_bit[4] ^ crc_bit[0]; 65 | new_bit[15] = crc_bit[30] ^ crc_bit[27] ^ crc_bit[24] ^ crc_bit[21] ^ crc_bit[20] ^ crc_bit[18] ^ crc_bit[16] ^ 66 | crc_bit[15] ^ crc_bit[12] ^ crc_bit[9] ^ crc_bit[8] ^ crc_bit[7] ^ crc_bit[5] ^ crc_bit[4] ^ 67 | crc_bit[3]; 68 | new_bit[14] = crc_bit[29] ^ crc_bit[26] ^ crc_bit[23] ^ crc_bit[20] ^ crc_bit[19] ^ crc_bit[17] ^ crc_bit[15] ^ 69 | crc_bit[14] ^ crc_bit[11] ^ crc_bit[8] ^ crc_bit[7] ^ crc_bit[6] ^ crc_bit[4] ^ crc_bit[3] ^ 70 | crc_bit[2]; 71 | new_bit[13] = crc_bit[31] ^ crc_bit[28] ^ crc_bit[25] ^ crc_bit[22] ^ crc_bit[19] ^ crc_bit[18] ^ crc_bit[16] ^ 72 | crc_bit[14] ^ crc_bit[13] ^ crc_bit[10] ^ crc_bit[7] ^ crc_bit[6] ^ crc_bit[5] ^ crc_bit[3] ^ 73 | crc_bit[2] ^ crc_bit[1]; 74 | new_bit[12] = crc_bit[31] ^ crc_bit[30] ^ crc_bit[27] ^ crc_bit[24] ^ crc_bit[21] ^ crc_bit[18] ^ crc_bit[17] ^ 75 | crc_bit[15] ^ crc_bit[13] ^ crc_bit[12] ^ crc_bit[9] ^ crc_bit[6] ^ crc_bit[5] ^ crc_bit[4] ^ 76 | crc_bit[2] ^ crc_bit[1] ^ crc_bit[0]; 77 | new_bit[11] = crc_bit[31] ^ crc_bit[28] ^ crc_bit[27] ^ crc_bit[26] ^ crc_bit[25] ^ crc_bit[24] ^ crc_bit[20] ^ 78 | crc_bit[17] ^ crc_bit[16] ^ crc_bit[15] ^ crc_bit[14] ^ crc_bit[12] ^ crc_bit[9] ^ crc_bit[4] ^ 79 | crc_bit[3] ^ crc_bit[1] ^ crc_bit[0]; 80 | new_bit[10] = crc_bit[31] ^ crc_bit[29] ^ crc_bit[28] ^ crc_bit[26] ^ crc_bit[19] ^ crc_bit[16] ^ crc_bit[14] ^ 81 | crc_bit[13] ^ crc_bit[9] ^ crc_bit[5] ^ crc_bit[3] ^ crc_bit[2] ^ crc_bit[0]; 82 | new_bit[9] = crc_bit[29] ^ crc_bit[24] ^ crc_bit[23] ^ crc_bit[18] ^ crc_bit[13] ^ crc_bit[12] ^ crc_bit[11] ^ 83 | crc_bit[9] ^ crc_bit[5] ^ crc_bit[4] ^ crc_bit[2] ^ crc_bit[1]; 84 | new_bit[8] = crc_bit[31] ^ crc_bit[28] ^ crc_bit[23] ^ crc_bit[22] ^ crc_bit[17] ^ crc_bit[12] ^ crc_bit[11] ^ 85 | crc_bit[10] ^ crc_bit[8] ^ crc_bit[4] ^ crc_bit[3] ^ crc_bit[1] ^ crc_bit[0]; 86 | new_bit[7] = crc_bit[29] ^ crc_bit[28] ^ crc_bit[25] ^ crc_bit[24] ^ crc_bit[23] ^ crc_bit[22] ^ crc_bit[21] ^ 87 | crc_bit[16] ^ crc_bit[15] ^ crc_bit[10] ^ crc_bit[8] ^ crc_bit[7] ^ crc_bit[5] ^ crc_bit[3] ^ 88 | crc_bit[2] ^ crc_bit[0]; 89 | new_bit[6] = crc_bit[30] ^ crc_bit[29] ^ crc_bit[25] ^ crc_bit[22] ^ crc_bit[21] ^ crc_bit[20] ^ crc_bit[14] ^ 90 | crc_bit[11] ^ crc_bit[8] ^ crc_bit[7] ^ crc_bit[6] ^ crc_bit[5] ^ crc_bit[4] ^ crc_bit[2] ^ 91 | crc_bit[1]; 92 | new_bit[5] = crc_bit[29] ^ crc_bit[28] ^ crc_bit[24] ^ crc_bit[21] ^ crc_bit[20] ^ crc_bit[19] ^ crc_bit[13] ^ 93 | crc_bit[10] ^ crc_bit[7] ^ crc_bit[6] ^ crc_bit[5] ^ crc_bit[4] ^ crc_bit[3] ^ crc_bit[1] ^ 94 | crc_bit[0]; 95 | new_bit[4] = crc_bit[31] ^ crc_bit[30] ^ crc_bit[29] ^ crc_bit[25] ^ crc_bit[24] ^ crc_bit[20] ^ crc_bit[19] ^ 96 | crc_bit[18] ^ crc_bit[15] ^ crc_bit[12] ^ crc_bit[11] ^ crc_bit[8] ^ crc_bit[6] ^ crc_bit[4] ^ 97 | crc_bit[3] ^ crc_bit[2] ^ crc_bit[0]; 98 | new_bit[3] = crc_bit[31] ^ crc_bit[27] ^ crc_bit[25] ^ crc_bit[19] ^ crc_bit[18] ^ crc_bit[17] ^ crc_bit[15] ^ 99 | crc_bit[14] ^ crc_bit[10] ^ crc_bit[9] ^ crc_bit[8] ^ crc_bit[7] ^ crc_bit[3] ^ crc_bit[2] ^ 100 | crc_bit[1]; 101 | new_bit[2] = crc_bit[31] ^ crc_bit[30] ^ crc_bit[26] ^ crc_bit[24] ^ crc_bit[18] ^ crc_bit[17] ^ crc_bit[16] ^ 102 | crc_bit[14] ^ crc_bit[13] ^ crc_bit[9] ^ crc_bit[8] ^ crc_bit[7] ^ crc_bit[6] ^ crc_bit[2] ^ 103 | crc_bit[1] ^ crc_bit[0]; 104 | new_bit[1] = crc_bit[28] ^ crc_bit[27] ^ crc_bit[24] ^ crc_bit[17] ^ crc_bit[16] ^ crc_bit[13] ^ crc_bit[12] ^ 105 | crc_bit[11] ^ crc_bit[9] ^ crc_bit[7] ^ crc_bit[6] ^ crc_bit[1] ^ crc_bit[0]; 106 | new_bit[0] = crc_bit[31] ^ crc_bit[30] ^ crc_bit[29] ^ crc_bit[28] ^ crc_bit[26] ^ crc_bit[25] ^ crc_bit[24] ^ 107 | crc_bit[16] ^ crc_bit[12] ^ crc_bit[10] ^ crc_bit[9] ^ crc_bit[6] ^ crc_bit[0]; 108 | /* The new CRC value has been calculated as individual bits in the */ 109 | /* new_bit array. Re-assembled it into a 32 bit value and "clock" it */ 110 | /* into the "register". */ 111 | crc = 0; 112 | for (i = 31; i >= 0; --i) 113 | { 114 | crc = crc << 1; 115 | crc |= new_bit[i]; 116 | } 117 | return crc; 118 | } /* update_crc_32 */ 119 | -------------------------------------------------------------------------------- /CH569_SerDes_Descramble_glscopeclient_CSV_8b10bIBM_Hex/crc32_SATA.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Modified by B.VERNOUX -06 June 2022) for CRC-32 Serial ATA specification 3 | * SATA spec see https://www.seagate.com/support/disc/manuals/sata/sata_im.pdf 4 | */ 5 | 6 | #ifndef CRC32_SATA_H 7 | #define CRC32_SATA_H 8 | 9 | #include 10 | 11 | #define CRC32_SERDES_START 0x52325032L /* The same defined in CRC-32 SATA Spec */ 12 | 13 | /* 14 | * Prototype list of global functions 15 | */ 16 | //uint32_t crc_32(const unsigned char *input_str, size_t num_bytes); 17 | uint32_t update_crc32_sata(uint32_t crc, uint32_t data_in); 18 | 19 | #endif // CRC32_SATA_H 20 | -------------------------------------------------------------------------------- /CH569_SerDes_Descramble_glscopeclient_CSV_8b10bIBM_Hex/csv.c: -------------------------------------------------------------------------------- 1 | /* (c) 2019 Jan Doczy 2 | * This code is licensed under MIT license (see LICENSE.txt for details) */ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "csv.h" 9 | 10 | /* Windows specific */ 11 | #ifdef _WIN32 12 | #include 13 | typedef unsigned long long file_off_t; 14 | #else 15 | #include 16 | typedef off_t file_off_t; 17 | #endif 18 | 19 | /* max allowed buffer */ 20 | #define BUFFER_WIDTH_APROX (40 * 1024 * 1024) 21 | 22 | #if defined (__aarch64__) || defined (__amd64__) || defined (_M_AMD64) 23 | /* unpack csv newline search */ 24 | #define CSV_UNPACK_64_SEARCH 25 | #endif 26 | 27 | /* private csv handle: 28 | * @mem: pointer to memory 29 | * @pos: position in buffer 30 | * @size: size of memory chunk 31 | * @context: context used when processing cols 32 | * @blockSize: size of mapped block 33 | * @fileSize: size of opened file 34 | * @mapSize: ... 35 | * @auxbuf: auxiliary buffer 36 | * @auxbufSize: size of aux buffer 37 | * @auxbufPos: position of aux buffer reader 38 | * @quotes: number of pending quotes parsed 39 | * @fh: file handle - descriptor 40 | * @delim: delimeter - ',' 41 | * @quote: quote '"' 42 | * @escape: escape char 43 | */ 44 | struct CsvHandle_ 45 | { 46 | void* mem; 47 | size_t pos; 48 | size_t size; 49 | char* context; 50 | size_t blockSize; 51 | file_off_t fileSize; 52 | file_off_t mapSize; 53 | size_t auxbufSize; 54 | size_t auxbufPos; 55 | size_t quotes; 56 | void* auxbuf; 57 | 58 | #if defined ( __unix__ ) 59 | int fh; 60 | #elif defined ( _WIN32 ) 61 | HANDLE fh; 62 | HANDLE fm; 63 | #else 64 | #error Wrong platform definition 65 | #endif 66 | 67 | char delim; 68 | char quote; 69 | char escape; 70 | }; 71 | 72 | CsvHandle CsvOpen(const char* filename) 73 | { 74 | /* defaults */ 75 | return CsvOpen2(filename, ',', '"', '\\'); 76 | } 77 | 78 | /* trivial macro used to get page-aligned buffer size */ 79 | #define GET_PAGE_ALIGNED( orig, page ) \ 80 | (((orig) + ((page) - 1)) & ~((page) - 1)) 81 | 82 | /* thin platform dependent layer so we can use file mapping 83 | * with winapi and oses following posix specs. 84 | */ 85 | #ifdef __unix__ 86 | #include 87 | #include 88 | #include 89 | #include 90 | #include 91 | 92 | CsvHandle CsvOpen2(const char* filename, 93 | char delim, 94 | char quote, 95 | char escape) 96 | { 97 | /* alloc zero-initialized mem */ 98 | long pageSize; 99 | struct stat fs; 100 | 101 | CsvHandle handle = calloc(1, sizeof(struct CsvHandle_)); 102 | if (!handle) 103 | goto fail; 104 | 105 | /* set chars */ 106 | handle->delim = delim; 107 | handle->quote = quote; 108 | handle->escape = escape; 109 | 110 | /* page size */ 111 | pageSize = sysconf(_SC_PAGESIZE); 112 | if (pageSize < 0) 113 | goto fail; 114 | 115 | /* align to system page size */ 116 | handle->blockSize = GET_PAGE_ALIGNED(BUFFER_WIDTH_APROX, pageSize); 117 | 118 | /* open new fd */ 119 | handle->fh = open(filename, O_RDONLY); 120 | if (handle->fh < 0) 121 | goto fail; 122 | 123 | /* get real file size */ 124 | if (fstat(handle->fh, &fs)) 125 | { 126 | close(handle->fh); 127 | goto fail; 128 | } 129 | 130 | handle->fileSize = fs.st_size; 131 | return handle; 132 | 133 | fail: 134 | free(handle); 135 | return NULL; 136 | } 137 | 138 | static void* MapMem(CsvHandle handle) 139 | { 140 | handle->mem = mmap(0, handle->blockSize, 141 | PROT_READ | PROT_WRITE, 142 | MAP_PRIVATE, 143 | handle->fh, handle->mapSize); 144 | return handle->mem; 145 | } 146 | 147 | static void UnmapMem(CsvHandle handle) 148 | { 149 | if (handle->mem) 150 | munmap(handle->mem, handle->blockSize); 151 | } 152 | 153 | void CsvClose(CsvHandle handle) 154 | { 155 | if (!handle) 156 | return; 157 | 158 | UnmapMem(handle); 159 | 160 | close(handle->fh); 161 | free(handle->auxbuf); 162 | free(handle); 163 | } 164 | 165 | #else 166 | 167 | /* extra Windows specific implementations 168 | */ 169 | CsvHandle CsvOpen2(const char* filename, 170 | char delim, 171 | char quote, 172 | char escape) 173 | { 174 | LARGE_INTEGER fsize; 175 | SYSTEM_INFO info; 176 | CsvHandle handle = calloc(1, sizeof(struct CsvHandle_)); 177 | if (!handle) 178 | return NULL; 179 | 180 | handle->delim = delim; 181 | handle->quote = quote; 182 | handle->escape = escape; 183 | 184 | GetSystemInfo(&info); 185 | handle->blockSize = GET_PAGE_ALIGNED(BUFFER_WIDTH_APROX, info.dwPageSize); 186 | handle->fh = CreateFile(filename, 187 | GENERIC_READ, 188 | FILE_SHARE_READ, 189 | NULL, 190 | OPEN_EXISTING, 191 | FILE_ATTRIBUTE_NORMAL, 192 | NULL); 193 | 194 | if (handle->fh == INVALID_HANDLE_VALUE) 195 | goto fail; 196 | 197 | if (GetFileSizeEx(handle->fh, &fsize) == FALSE) 198 | goto fail; 199 | 200 | handle->fileSize = fsize.QuadPart; 201 | if (!handle->fileSize) 202 | goto fail; 203 | 204 | handle->fm = CreateFileMapping(handle->fh, NULL, PAGE_WRITECOPY, 0, 0, NULL); 205 | if (handle->fm == NULL) 206 | goto fail; 207 | 208 | return handle; 209 | 210 | fail: 211 | if (handle->fh != INVALID_HANDLE_VALUE) 212 | CloseHandle(handle->fh); 213 | 214 | free(handle); 215 | return NULL; 216 | } 217 | 218 | static void* MapMem(CsvHandle handle) 219 | { 220 | size_t size = handle->blockSize; 221 | if (handle->mapSize + size > handle->fileSize) 222 | size = 0; /* last chunk, extend to file mapping max */ 223 | 224 | handle->mem = MapViewOfFileEx(handle->fm, 225 | FILE_MAP_COPY, 226 | (DWORD)(handle->mapSize >> 32), 227 | (DWORD)(handle->mapSize & 0xFFFFFFFF), 228 | size, 229 | NULL); 230 | return handle->mem; 231 | } 232 | 233 | static void UnmapMem(CsvHandle handle) 234 | { 235 | if (handle->mem) 236 | UnmapViewOfFileEx(handle->mem, 0); 237 | } 238 | 239 | void CsvClose(CsvHandle handle) 240 | { 241 | if (!handle) 242 | return; 243 | 244 | UnmapMem(handle); 245 | 246 | CloseHandle(handle->fm); 247 | CloseHandle(handle->fh); 248 | free(handle->auxbuf); 249 | free(handle); 250 | } 251 | 252 | #endif 253 | 254 | static int CsvEnsureMapped(CsvHandle handle) 255 | { 256 | file_off_t newSize; 257 | 258 | /* do not need to map */ 259 | if (handle->pos < handle->size) 260 | return 0; 261 | 262 | UnmapMem(handle); 263 | 264 | handle->mem = NULL; 265 | if (handle->mapSize >= handle->fileSize) 266 | return -EINVAL; 267 | 268 | newSize = handle->mapSize + handle->blockSize; 269 | if (MapMem(handle)) 270 | { 271 | handle->pos = 0; 272 | handle->mapSize = newSize; 273 | 274 | /* read only up to filesize: 275 | * 1. mapped block size is < then filesize: (use blocksize) 276 | * 2. mapped block size is > then filesize: (use remaining filesize) */ 277 | handle->size = handle->blockSize; 278 | if (handle->mapSize > handle->fileSize) 279 | handle->size = (size_t)(handle->fileSize % handle->blockSize); 280 | 281 | return 0; 282 | } 283 | 284 | return -ENOMEM; 285 | } 286 | 287 | static char* CsvChunkToAuxBuf(CsvHandle handle, char* p, size_t size) 288 | { 289 | size_t newSize = handle->auxbufPos + size + 1; 290 | if (handle->auxbufSize < newSize) 291 | { 292 | void* mem = realloc(handle->auxbuf, newSize); 293 | if (!mem) 294 | return NULL; 295 | 296 | handle->auxbuf = mem; 297 | handle->auxbufSize = newSize; 298 | } 299 | 300 | memcpy((char*)handle->auxbuf + handle->auxbufPos, p, size); 301 | handle->auxbufPos += size; 302 | 303 | *(char*)((char*)handle->auxbuf + handle->auxbufPos) = '\0'; 304 | return handle->auxbuf; 305 | } 306 | 307 | static void CsvTerminateLine(char* p, size_t size) 308 | { 309 | /* we do support standard POSIX LF sequence 310 | * and Windows CR LF sequence. 311 | * old non POSIX Mac OS CR is not supported. 312 | */ 313 | char* res = p; 314 | if (size >= 2 && p[-1] == '\r') 315 | --res; 316 | 317 | *res = 0; 318 | } 319 | 320 | #define CSV_QUOTE_BR(c, n) \ 321 | do \ 322 | if (c##n == quote) \ 323 | handle->quotes++; \ 324 | else if (c##n == '\n' && !(handle->quotes & 1)) \ 325 | return p + n; \ 326 | while (0) 327 | 328 | 329 | static char* CsvSearchLf(char* p, size_t size, CsvHandle handle) 330 | { 331 | /* TODO: this can be greatly optimized by 332 | * using modern SIMD instructions, but for now 333 | * we only fetch 8Bytes "at once" 334 | */ 335 | char* end = p + size; 336 | char quote = handle->quote; 337 | 338 | #ifdef CSV_UNPACK_64_SEARCH 339 | uint64_t* pd = (uint64_t*)p; 340 | uint64_t* pde = pd + (size / sizeof(uint64_t)); 341 | 342 | for (; pd < pde; pd++) 343 | { 344 | /* unpack 64bits to 8x8bits */ 345 | char c0, c1, c2, c3, c4, c5, c6, c7; 346 | p = (char*)pd; 347 | c0 = p[0]; 348 | c1 = p[1]; 349 | c2 = p[2]; 350 | c3 = p[3]; 351 | c4 = p[4]; 352 | c5 = p[5]; 353 | c6 = p[6]; 354 | c7 = p[7]; 355 | 356 | CSV_QUOTE_BR(c, 0); 357 | CSV_QUOTE_BR(c, 1); 358 | CSV_QUOTE_BR(c, 2); 359 | CSV_QUOTE_BR(c, 3); 360 | CSV_QUOTE_BR(c, 4); 361 | CSV_QUOTE_BR(c, 5); 362 | CSV_QUOTE_BR(c, 6); 363 | CSV_QUOTE_BR(c, 7); 364 | } 365 | p = (char*)pde; 366 | #endif 367 | 368 | for (; p < end; p++) 369 | { 370 | char c0 = *p; 371 | CSV_QUOTE_BR(c, 0); 372 | } 373 | 374 | return NULL; 375 | } 376 | 377 | char* CsvReadNextRow(CsvHandle handle) 378 | { 379 | char* p = NULL; 380 | char* found = NULL; 381 | 382 | do 383 | { 384 | int err = CsvEnsureMapped(handle); 385 | handle->context = NULL; 386 | 387 | if (err == -EINVAL) 388 | { 389 | /* if this is n-th iteration 390 | * return auxbuf (remaining bytes of the file) */ 391 | if (p == NULL) 392 | break; 393 | 394 | return handle->auxbuf; 395 | } 396 | else if (err == -ENOMEM) 397 | { 398 | break; 399 | } 400 | size_t size; 401 | size = handle->size - handle->pos; 402 | if (!size) 403 | break; 404 | 405 | /* search this chunk for NL */ 406 | p = (char*)handle->mem + handle->pos; 407 | found = CsvSearchLf(p, size, handle); 408 | 409 | if (found) 410 | { 411 | /* prepare position for next iteration */ 412 | size = (size_t)(found - p) + 1; 413 | handle->pos += size; 414 | handle->quotes = 0; 415 | 416 | if (handle->auxbufPos) 417 | { 418 | if (!CsvChunkToAuxBuf(handle, p, size)) 419 | break; 420 | 421 | p = handle->auxbuf; 422 | size = handle->auxbufPos; 423 | } 424 | 425 | /* reset auxbuf position */ 426 | handle->auxbufPos = 0; 427 | 428 | /* terminate line */ 429 | CsvTerminateLine(p + size - 1, size); 430 | return p; 431 | } 432 | else 433 | { 434 | /* reset on next iteration */ 435 | handle->pos = handle->size; 436 | } 437 | 438 | /* correctly process boundries, storing 439 | * remaning bytes in aux buffer */ 440 | if (!CsvChunkToAuxBuf(handle, p, size)) 441 | break; 442 | 443 | } while (!found); 444 | 445 | return NULL; 446 | } 447 | 448 | const char* CsvReadNextCol(char* row, CsvHandle handle) 449 | { 450 | /* return properly escaped CSV col 451 | * RFC: [https://tools.ietf.org/html/rfc4180] 452 | */ 453 | char* p = handle->context ? handle->context : row; 454 | char* d = p; /* destination */ 455 | char* b = p; /* begin */ 456 | int quoted = 0; /* idicates quoted string */ 457 | 458 | quoted = *p == handle->quote; 459 | if (quoted) 460 | p++; 461 | 462 | for (; *p; p++, d++) 463 | { 464 | /* double quote is present if (1) */ 465 | int dq = 0; 466 | 467 | /* skip escape */ 468 | if (*p == handle->escape && p[1]) 469 | p++; 470 | 471 | /* skip double-quote */ 472 | if (*p == handle->quote && p[1] == handle->quote) 473 | { 474 | dq = 1; 475 | p++; 476 | } 477 | 478 | /* check if we should end */ 479 | if (quoted && !dq) 480 | { 481 | if (*p == handle->quote) 482 | break; 483 | } 484 | else if (*p == handle->delim) 485 | { 486 | break; 487 | } 488 | 489 | /* copy if required */ 490 | if (d != p) 491 | *d = *p; 492 | } 493 | 494 | if (!*p) 495 | { 496 | /* nothing to do */ 497 | if (p == b) 498 | return NULL; 499 | 500 | handle->context = p; 501 | } 502 | else 503 | { 504 | /* end reached, skip */ 505 | *d = '\0'; 506 | if (quoted) 507 | { 508 | for (p++; *p; p++) 509 | if (*p == handle->delim) 510 | break; 511 | 512 | if (*p) 513 | p++; 514 | 515 | handle->context = p; 516 | } 517 | else 518 | { 519 | handle->context = p + 1; 520 | } 521 | } 522 | return b; 523 | } 524 | -------------------------------------------------------------------------------- /CH569_SerDes_Descramble_glscopeclient_CSV_8b10bIBM_Hex/csv.h: -------------------------------------------------------------------------------- 1 | /* (c) 2019 Jan Doczy 2 | * This code is licensed under MIT license (see LICENSE.txt for details) */ 3 | 4 | /* simple and fast CSV reader: 5 | * 1. Open CSV file by calling CsvOpen("filename.csv") 6 | * 2. Read CSV row by calling CsvReadNextRow(csv_handle) 7 | * 3. Read single CSV line column by calling CsvReadNextCol(returned_row_str, csv_handle) 8 | */ 9 | 10 | #ifndef CSV_H_INCLUDED 11 | #define CSV_H_INCLUDED 12 | 13 | #ifdef __cplusplus 14 | extern "C" { /* C++ name mangling */ 15 | #endif 16 | 17 | /* pointer to private handle structure */ 18 | typedef struct CsvHandle_ *CsvHandle; 19 | 20 | /** 21 | * openes csv file 22 | * @filename: pathname of the file 23 | * @return: csv handle 24 | * @notes: you should call CsvClose() to release resources 25 | */ 26 | CsvHandle CsvOpen(const char* filename); 27 | CsvHandle CsvOpen2(const char* filename, 28 | char delim, 29 | char quote, 30 | char escape); 31 | 32 | /** 33 | * closes csv handle, releasing all resources 34 | * @handle: csv handle 35 | */ 36 | void CsvClose(CsvHandle handle); 37 | 38 | /** 39 | * reads (first / next) line of csv file 40 | * @handle: csv handle 41 | */ 42 | char* CsvReadNextRow(CsvHandle handle); 43 | 44 | /** 45 | * get column of file 46 | * @row: csv row (you can use CsvReadNextRow() to parse next line) 47 | * @context: handle returned by CsvOpen() or CsvOpen2() 48 | */ 49 | const char* CsvReadNextCol(char* row, CsvHandle handle); 50 | 51 | #ifdef __cplusplus 52 | }; 53 | #endif 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2022 Benjamin VERNOUX (bvernoux) 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # wch-ch569-serdes reverse-engineering 2 | Aim of this project: 3 | * To reverse the WCH CH569 SerDes to interface it with FPGA... 4 | * See documents: 5 | * [WCH_CH569_SerDes_ReverseEngineering_BVERNOUX_31July2022.pdf](WCH_CH569_SerDes_ReverseEngineering_BVERNOUX_31July2022.pdf) 6 | * [WCH_CH569_SerDes_ReverseEngineering_BVERNOUX_31July2022.odt](WCH_CH569_SerDes_ReverseEngineering_BVERNOUX_31July2022.odt) 7 | * See also repositories: 8 | * [CH569_SerDes_Descramble_glscopeclient_CSV_8b10bIBM_Hex](CH569_SerDes_Descramble_glscopeclient_CSV_8b10bIBM_Hex) 9 | * [CH569_SerDes_180Mbps](CH569_SerDes_180Mbps) 10 | * To reverse/rewrite all interesting blob/code to clean C code to have fully open source driver for WCH CH569 SerDes peripheral 11 | * Done in https://github.com/hydrausb3/hydrausb3_fw/tree/main/HydraUSB3_DualBoard_SerDes 12 | * See drv open source code API / code 13 | * https://github.com/hydrausb3/wch-ch56x-bsp/tree/main/drv/CH56x_serdes.c 14 | * https://github.com/hydrausb3/wch-ch56x-bsp/tree/main/drv/CH56x_serdes.h 15 | -------------------------------------------------------------------------------- /WCH_CH569_SerDes_ReverseEngineering_BVERNOUX_31July2022.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hydrausb3/wch-ch569-serdes/956ce6ec5df6e70fd9ab7474f1489198d079cd4a/WCH_CH569_SerDes_ReverseEngineering_BVERNOUX_31July2022.odt -------------------------------------------------------------------------------- /WCH_CH569_SerDes_ReverseEngineering_BVERNOUX_31July2022.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hydrausb3/wch-ch569-serdes/956ce6ec5df6e70fd9ab7474f1489198d079cd4a/WCH_CH569_SerDes_ReverseEngineering_BVERNOUX_31July2022.pdf --------------------------------------------------------------------------------