You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

658 lines
12 KiB

  1. # Can be viewed in: https://ide.kaitai.io/
  2. #
  3. # This file is a formal specification of the binary format used in Altium.
  4. # Files need to manually extracted using a program which can read the Microsoft Compound File Format.
  5. #
  6. # While I do not create a parser using this file, it is still very helpful to understand the binary
  7. # format.
  8. meta:
  9. id: altium_binary
  10. endian: le
  11. encoding: ISO8859-1
  12. seq:
  13. - id: record
  14. type: record
  15. repeat: eos
  16. # https://github.com/thesourcerer8/altium2kicad/blob/master/convertpcb.pl#L1291
  17. types:
  18. record:
  19. seq:
  20. - id: recordtype
  21. type: u1
  22. enum: record_id
  23. - id: record
  24. type:
  25. switch-on: recordtype
  26. cases:
  27. record_id::arc6: arc
  28. record_id::pad6: pad
  29. record_id::via6: via
  30. record_id::track6: track
  31. record_id::text6: text
  32. record_id::fill6: fill
  33. record_id::region6: region
  34. arc:
  35. seq:
  36. - id: sub1_len
  37. type: u4
  38. - id: data
  39. type: arc_sub1
  40. size: sub1_len
  41. arc_sub1:
  42. seq:
  43. - id: layer
  44. type: u1
  45. - #id: flags_u7
  46. type: b1
  47. - #id: flags_u6
  48. type: b1
  49. - #id: flags_u5
  50. type: b1
  51. - #id: flags_u4
  52. type: b1
  53. - #id: flags_u3
  54. type: b1
  55. - id: is_not_locked
  56. type: b1
  57. - id: is_not_polygonoutline
  58. type: b1
  59. - #id: flags_u0
  60. type: b1
  61. - id: is_keepout
  62. type: u1 # KEEPOUT = 2
  63. - id: net
  64. type: u2
  65. - id: subpolyindex
  66. type: u2
  67. - id: component
  68. type: u2
  69. - size: 4
  70. - id: center
  71. type: xy
  72. - id: radius
  73. type: u4
  74. - id: start_angle
  75. type: f8
  76. - id: end_angle
  77. type: f8
  78. - id: width
  79. type: u4
  80. pad:
  81. seq:
  82. - id: sub1_len
  83. type: u4
  84. - id: designator
  85. type: pad_sub1
  86. size: sub1_len
  87. - id: sub2_len
  88. type: u4
  89. - size: sub2_len
  90. - id: sub3_len
  91. type: u4
  92. - size: sub3_len
  93. - id: sub4_len
  94. type: u4
  95. - size: sub4_len
  96. - id: sub5_len
  97. type: u4
  98. - id: size_and_shape
  99. type: pad_sub5
  100. size: sub5_len
  101. - id: sub6_len
  102. type: u4
  103. - id: size_and_shape_by_layer
  104. type: pad_sub6
  105. size: sub6_len
  106. if: sub6_len > 0
  107. pad_sub1:
  108. seq:
  109. - id: name_len # = len-1?
  110. type: u1
  111. - id: name
  112. type: str
  113. size: name_len
  114. pad_sub5:
  115. seq:
  116. - id: layer # $pos+23
  117. type: u1
  118. enum: layer
  119. - id: test_fab_top
  120. type: b1
  121. - id: tent_bottom
  122. type: b1
  123. - id: tent_top
  124. type: b1
  125. - #id: flags_u4
  126. type: b1
  127. - #id: flags_u3
  128. type: b1
  129. - id: is_not_locked
  130. type: b1
  131. - #id: flags_u1
  132. type: b1
  133. - #id: flags_u0
  134. type: b1
  135. - #id: flags2_u7
  136. type: b1
  137. - #id: flags2_u6
  138. type: b1
  139. - #id: flags2_u5
  140. type: b1
  141. - #id: flags2_u4
  142. type: b1
  143. - #id: flags2_u3
  144. type: b1
  145. - #id: flags2_u2
  146. type: b1
  147. - #id: flags2_u1
  148. type: b1
  149. - id: test_fab_bottom
  150. type: b1
  151. #- id: u
  152. # size: 1
  153. - id: net # $pos+26
  154. type: u2
  155. - size: 2
  156. - id: component # $pos+30
  157. type: u2
  158. - size: 4
  159. - id: position # $pos+36, $pos+40
  160. type: xy
  161. - id: topsize # $pos+44, $pos+48
  162. type: xy
  163. - id: midsize # $pos+52, $pos+56
  164. type: xy
  165. - id: botsize # $pos+60, $pos+64
  166. type: xy
  167. - id: holesize # $pos+68
  168. type: u4
  169. - id: topshape # $pos+72
  170. type: u1
  171. enum: pad_shape
  172. - id: midshape # $pos+73
  173. type: u1
  174. enum: pad_shape
  175. - id: botshape # $pos+74
  176. type: u1
  177. enum: pad_shape
  178. - id: direction # $pos+75
  179. type: f8
  180. - id: plated # $pos+83
  181. type: u1
  182. enum: boolean
  183. - size: 1
  184. - id: pad_mode # $pos+85
  185. type: u1
  186. enum: pad_mode
  187. - size: 5
  188. - id: ccw # $pos+91
  189. type: u4
  190. - id: cen # $pos+95
  191. type: u1
  192. - size: 1
  193. - id: cag # $pos+97
  194. type: u4
  195. - id: cpr # $pos+101
  196. type: u4
  197. - id: cpc # $pos+105
  198. type: u4
  199. - id: pastemaskexpanionmanual
  200. type: s4
  201. - id: soldermaskexpansionmanual # $pos+113
  202. type: s4
  203. - id: cpl # $pos+117
  204. type: u1
  205. - size: 6
  206. - id: pastemaskexpansionmode # $pos+124
  207. type: u1
  208. enum: pad_mode_rule
  209. - id: soldermaskexpansionmode # $pos+125
  210. type: u1
  211. enum: pad_mode_rule
  212. - size: 3
  213. - id: holerotation # $pos+129
  214. type: f8
  215. - size: 4
  216. - id: testpoint_assembly_top
  217. type: u1
  218. enum: boolean
  219. - id: testpoint_assembly_bottom
  220. type: u1
  221. enum: boolean
  222. pad_sub6:
  223. seq:
  224. - id: x
  225. type: s4
  226. repeat: expr
  227. repeat-expr: 29
  228. - id: y
  229. type: s4
  230. repeat: expr
  231. repeat-expr: 29
  232. - id: shape
  233. type: u1
  234. enum: pad_shape
  235. repeat: expr
  236. repeat-expr: 29
  237. - size: 1
  238. - id: hole_type
  239. type: u1
  240. enum: pad_hole_type
  241. - id: slot_length
  242. type: s4
  243. - id: slot_rotation
  244. type: f8
  245. - id: holeoffset_x
  246. type: s4
  247. repeat: expr
  248. repeat-expr: 32
  249. - id: holeoffset_y
  250. type: s4
  251. repeat: expr
  252. repeat-expr: 32
  253. - size: 1
  254. - id: shape_alt
  255. type: u1
  256. enum: pad_shape_alt
  257. repeat: expr
  258. repeat-expr: 32
  259. - id: corner_radius
  260. type: u1
  261. repeat: expr
  262. repeat-expr: 32
  263. - size: 32
  264. via:
  265. seq:
  266. - id: sub1_len
  267. type: u4
  268. - id: data
  269. type: via_sub1
  270. size: sub1_len
  271. via_sub1:
  272. seq:
  273. - size: 1
  274. - id: test_fab_top
  275. type: b1
  276. - id: tent_bottom
  277. type: b1
  278. - id: tent_top
  279. type: b1
  280. - #id: flags_u4
  281. type: b1
  282. - #id: flags_u3
  283. type: b1
  284. - id: is_not_locked
  285. type: b1
  286. - #id: flags_u1
  287. type: b1
  288. - #id: flags_u0
  289. type: b1
  290. - #id: flags2_u7
  291. type: b1
  292. - #id: flags2_u6
  293. type: b1
  294. - #id: flags2_u5
  295. type: b1
  296. - #id: flags2_u4
  297. type: b1
  298. - #id: flags2_u3
  299. type: b1
  300. - #id: flags2_u2
  301. type: b1
  302. - #id: flags2_u1
  303. type: b1
  304. - id: test_fab_bottom
  305. type: b1
  306. - id: net
  307. type: u2
  308. - size: 2
  309. - id: component
  310. type: u2
  311. - size: 4
  312. - id: pos # 13
  313. type: xy
  314. - id: diameter # 21
  315. type: s4
  316. - id: holesize # 29
  317. type: s4
  318. - id: start_layer
  319. type: u1
  320. enum: layer
  321. - id: end_layer
  322. type: u1
  323. enum: layer
  324. - size: 43
  325. - id: via_mode
  326. type: u1
  327. enum: pad_mode
  328. - id: diameter_alt
  329. type: s4
  330. repeat: expr
  331. repeat-expr: 32
  332. track:
  333. seq:
  334. - id: sub1_len
  335. type: u4
  336. - id: data
  337. type: track_sub1
  338. size: sub1_len
  339. track_sub1:
  340. seq:
  341. - id: layer
  342. type: u1
  343. enum: layer
  344. - #id: flags_u7
  345. type: b1
  346. - #id: flags_u6
  347. type: b1
  348. - #id: flags_u5
  349. type: b1
  350. - #id: flags_u4
  351. type: b1
  352. - #id: flags_u3
  353. type: b1
  354. - id: is_not_locked
  355. type: b1
  356. - id: is_not_polygonoutline
  357. type: b1
  358. - #id: flags_u0
  359. type: b1
  360. - id: is_keepout
  361. type: u1 # KEEPOUT = 2
  362. - id: net
  363. type: u2
  364. - id: subpolyindex
  365. type: u2
  366. - id: component
  367. type: u2
  368. - size: 4
  369. - id: start # 13
  370. type: xy
  371. - id: end # 21
  372. type: xy
  373. - id: width # 29
  374. type: s4
  375. text:
  376. seq:
  377. - id: sub1_len
  378. type: u4
  379. - id: properties
  380. type: text_sub1
  381. size: sub1_len
  382. - id: sub2_len
  383. type: u4
  384. - id: text
  385. type: text_sub2
  386. size: sub2_len
  387. text_sub1:
  388. seq:
  389. - id: layer
  390. type: u1
  391. - #id: flags_u7
  392. type: b1
  393. - #id: flags_u6
  394. type: b1
  395. - #id: flags_u5
  396. type: b1
  397. - #id: flags_u4
  398. type: b1
  399. - #id: flags_u3
  400. type: b1
  401. - id: is_not_locked
  402. type: b1
  403. - #id: flags_u1
  404. type: b1
  405. - #id: flags_u0
  406. type: b1
  407. - size: 1
  408. - id: net
  409. type: u2
  410. - size: 2
  411. - id: component
  412. type: u2
  413. - size: 4
  414. - id: pos
  415. type: xy
  416. - id: height
  417. type: u4
  418. - id: font_name_id
  419. type: u1
  420. - size: 1
  421. - id: rotation
  422. type: f8
  423. - id: mirrored
  424. type: u1
  425. enum: boolean
  426. - id: strokewidth
  427. type: u4
  428. - id: is_comment
  429. type: u1
  430. enum: boolean
  431. - id: is_designator
  432. type: u1
  433. enum: boolean
  434. - size: 4
  435. - id: font_name
  436. size: 64
  437. type: str # TODO: terminates with [0, 0]
  438. encoding: UTF-16
  439. - size: 22
  440. - id: position
  441. type: u1
  442. enum: text_position
  443. - size: 27
  444. - id: truetype
  445. type: u1
  446. enum: boolean
  447. - id: barcode_name
  448. size: 64
  449. type: str # TODO: terminates with [0, 0]
  450. encoding: UTF-16
  451. text_sub2:
  452. seq:
  453. - id: len
  454. type: u1
  455. - id: name
  456. type: str
  457. size: len
  458. fill:
  459. seq:
  460. - id: sub1_len
  461. type: u4
  462. - id: data
  463. type: fill_sub1
  464. size: sub1_len
  465. fill_sub1:
  466. seq:
  467. - id: layer
  468. type: u1
  469. - #id: flags_u7
  470. type: b1
  471. - #id: flags_u6
  472. type: b1
  473. - #id: flags_u5
  474. type: b1
  475. - #id: flags_u4
  476. type: b1
  477. - #id: flags_u3
  478. type: b1
  479. - id: is_not_locked
  480. type: b1
  481. - #id: flags_u1
  482. type: b1
  483. - #id: flags_u0
  484. type: b1
  485. - id: is_keepout
  486. type: u1 # KEEPOUT = 2
  487. - id: net
  488. type: u2
  489. - size: 2
  490. - id: component
  491. type: u2
  492. - size: 4
  493. - id: pos1
  494. type: xy
  495. - id: pos2
  496. type: xy
  497. - id: rotation
  498. type: f8
  499. region:
  500. seq:
  501. - id: sub1_len
  502. type: u4
  503. - id: data
  504. type: region_sub1
  505. size: sub1_len
  506. region_sub1:
  507. seq:
  508. - id: layer
  509. type: u1
  510. - #id: flags_u7
  511. type: b1
  512. - #id: flags_u6
  513. type: b1
  514. - #id: flags_u5
  515. type: b1
  516. - #id: flags_u4
  517. type: b1
  518. - #id: flags_u3
  519. type: b1
  520. - id: is_not_locked
  521. type: b1
  522. - #id: flags_u1
  523. type: b1
  524. - #id: flags_u0
  525. type: b1
  526. - id: is_keepout
  527. type: u1 # KEEPOUT = 2
  528. - id: net
  529. type: u2
  530. - size: 2
  531. - id: component
  532. type: u2
  533. - size: 5
  534. - id: holecount # TODO: check
  535. type: u2
  536. - size: 2
  537. - id: propterties_len
  538. type: u4
  539. - id: properties
  540. size: propterties_len
  541. type: str
  542. - id: vertices_num
  543. type: u4
  544. - id: vertices # region1 type
  545. repeat: expr
  546. repeat-expr: vertices_num
  547. type: xyf
  548. #- id: vertices2 # region2 type
  549. # repeat: expr
  550. # repeat-expr: vertices_num+1
  551. # type: xyf2
  552. xy:
  553. seq:
  554. - id: x
  555. type: s4
  556. - id: y
  557. type: s4
  558. xyf: # no idea why two different formats?
  559. seq:
  560. - id: x
  561. type: f8
  562. - id: y
  563. type: f8
  564. xyf2: # no idea why two different formats?
  565. seq:
  566. - id: is_round
  567. type: u1
  568. enum: boolean
  569. - id: position
  570. type: xy
  571. - id: center
  572. type: xy
  573. - id: radius
  574. type: u4
  575. - id: angle1
  576. type: f8
  577. - id: angle2
  578. type: f8
  579. enums:
  580. record_id:
  581. 0x01: arc6
  582. 0x02: pad6
  583. 0x03: via6
  584. 0x04: track6
  585. 0x05: text6
  586. 0x06: fill6
  587. 0x0b: region6
  588. boolean:
  589. 0: false
  590. 1: true
  591. pad_shape:
  592. 0: unknown
  593. 1: circle
  594. 2: rect
  595. 3: octagonal
  596. pad_shape_alt:
  597. 0: unknown
  598. 1: round
  599. 2: rect
  600. 3: octagonal
  601. 9: roundrectangle
  602. pad_hole_type:
  603. 0: normal
  604. 1: square
  605. 2: slot
  606. pad_mode:
  607. 0: simple
  608. 1: top_middle_bottom
  609. 2: full_stack
  610. pad_mode_rule:
  611. 0: unknown
  612. 1: rule
  613. 2: manual
  614. text_position:
  615. 1: left_top
  616. 2: left_center
  617. 3: left_bottom
  618. 4: center_top
  619. 5: center_center
  620. 6: center_bottom
  621. 7: right_top
  622. 8: right_center
  623. 9: right_bottom
  624. layer:
  625. 1: f_cu
  626. 32: b_cu