Compare commits

...

135 commits

Author SHA1 Message Date
Jeff Epler
8dfaba0b6a Remove files needed only for Windows
I asked Peter whether building mesaflash on Windows was important to him, and
he said he has not used it for a long time.

I don't like carrying these files, especially the binary files without clear
links to their source.  So let's remove them.

(These files also wouldn't be suitable for modern 64-bit versions of Windows,
which would be virtually any current system.)
2021-05-04 09:05:13 -05:00
a0f3c26ae4
Merge pull request #46 from jepler/cm4-pci
Enable PCI device enumeration on Compute Module 4
2021-05-04 09:02:26 -05:00
Jeff Epler
0359666ea4 Respond to review comments 2021-05-04 08:39:50 -05:00
b594a7d4ab Enable PCI device enumeration on Compute Module 4
* The PCI offset may be a 64-bit number like 0x600000000, which needs
   to fit in off_t (for mmap) and board_struct.mem_base
 * off_t is only 64-bits with -D_FILE_OFFSET_BITS=64
   (which is not the default in 2021!!!)
 * This requires the offset to be printed as a uint64_t
 * mmap was not checked for failure

After this change, I can detect a 5i24 plugged into the 1x slot of
a Raspberry Pi Compute Module 4 IO board with 2GB RAM compute module.
That's the only operation I tried.
2021-04-28 21:19:00 -05:00
7b2cb3abcd
Merge pull request #45 from jepler/conditional-pci-epp
Make PCI & EPP support conditional
2021-04-10 17:24:53 -05:00
d3778586fb pick up straggling sys/io.h outside of preprocessor guards 2021-04-10 22:36:09 +01:00
1de31add09 remove travis integration 2021-04-10 19:16:07 +01:00
e5395db448 bump CI version to 20.04 2021-04-10 18:10:13 +01:00
e8190b61a8 Make portions that need direct port access conditional
This should fix compilation on aarch64.
2021-04-10 18:03:58 +01:00
dc0dfa936f
Merge pull request #39 from DuttonIndustrial/master
Adds Sigma 5 Encoder GTAGs
2021-04-02 12:40:14 -05:00
a58d670647
Merge pull request #41 from JTrantow/master
Add build-essential to install list
2021-04-02 12:35:39 -05:00
jjt
acfe208625 Add build-essential to install list 2021-04-02 12:07:21 -05:00
Peter Wallace
c863030e66 Eliminate spaces in integrated BOB pin names 2021-03-06 19:59:10 -08:00
Peter Wallace
6672a29903 Better pin number list for integrated BOB cards + add SSerialB, DataPainter 2021-03-01 07:54:57 -08:00
Peter Wallace
d2df119ac1 Add shared muxed encoder/stepgen index pin display 2021-02-22 11:26:00 -08:00
Peter Wallace
09e9224ea3 fix minor formatting error with global pins 2021-01-31 19:31:30 -08:00
Peter Wallace
370e76bca6 Fix Stepgen index and probe pin names 2021-01-31 09:59:44 -08:00
Peter Wallace
b3d11257f5 Fix 7I96 GPIO 10 name (TB3 pin 11) 2021-01-30 19:23:54 -08:00
curtdutt
aae5929f6d Adds Sigma 5 Encoder GTAGs 2020-11-27 16:55:56 -05:00
Sebastian Kuzminsky
891a19cdfe
Merge pull request #38 from dwrobel/dw-6
Add mesaflash availability info on Fedora
2020-07-01 10:04:17 -06:00
Damian Wrobel
9168723538 Add mesaflash availability info on Fedora 2020-06-30 22:31:27 +02:00
Peter Wallace
946725c83c Oops, deleted the 7I97s FPGA part number 2020-06-07 18:46:00 -07:00
Peter Wallace
a61da59aa9 Fix internal pin names for FPGA cards with built in breakouts 2020-06-07 17:30:46 -07:00
Sebastian Kuzminsky
84b8b3f35d Mesaflash 3.4.0~pre1 2020-05-22 10:33:16 -06:00
Sebastian Kuzminsky
d0d21a71db
Merge pull request #36 from jepler/actions-ci
Add CI via github actions
2020-05-15 14:59:45 -06:00
Sebastian Kuzminsky
b2a9a89a49
Merge pull request #37 from jepler/device-auto-spi
anyio: Add --device AUTO and --device SPI
2020-05-15 10:23:26 -06:00
Sebastian Kuzminsky
4ed087f518
Merge pull request #35 from jepler/format-warnings
Fix -Wformat= warnings
2020-05-15 10:22:23 -06:00
Jeff Epler
f23d728834 anyio: Add --device AUTO and --device SPI
Testing performed:  Both found an attached SPI device on a Pi4 e.g.,

    $ ./mesaflash --device auto --addr /dev/spidev0.0 --spi --readhmid | head -1
    unable to set bpw32, fallback to bpw8
    Configuration Name: HOSTMOT2
2020-05-15 09:09:03 -05:00
Jeff Epler
f15d246724 Add CI via github actions 2020-05-15 08:51:40 -05:00
Jeff Epler
d1eb20b81d Makefile: Treat format problems as errors 2020-05-15 08:42:34 -05:00
Jeff Epler
66d5effcc8 various: fix -Wformat diagnostics
Mostly, this involves using the "z" length modifier where a sizeof() is involved
2020-05-15 08:40:59 -05:00
Jeff Epler
6aa9b69671 hostmot2.c: remove unused function
hostmot2.c:50:20: warning: ‘hm2_get_pin_secondary_name’ defined but not used [-Wunused-function]
 static const char* hm2_get_pin_secondary_name(hm2_pin_desc_t *pin) {
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~
2020-05-15 08:39:31 -05:00
Sebastian Kuzminsky
76384e6e17
Merge pull request #34 from dwrobel/Allow-to-pass-VERSION-string-from-the-build-system
Allow to pass VERSION string from the build system
2020-04-30 21:02:50 -06:00
Damian Wrobel
6bb35e443b Allow to pass VERSION string from the build system
Usage:
  $ CFLAGS='-DVERSION=\"version-string\"' make

Signed-off-by: Damian Wrobel <dwrobel@ertelnet.rybnik.pl>
2020-04-29 20:13:20 +02:00
Sebastian Kuzminsky
2bd4202eca install makefile 2020-04-28 17:55:31 -06:00
Sebastian Kuzminsky
cd53e573a7 docs: minor manpage updates 2020-04-28 17:55:28 -06:00
Sebastian Kuzminsky
ca6979fadf add manpage from jethornton/mesaflash man-page branch 2020-04-28 17:39:58 -06:00
Sebastian Kuzminsky
3c57d9dd77 update copyright notice 2020-04-28 15:14:20 -06:00
Sebastian Kuzminsky
bfb0c3065c Release 3.4.0~pre0 2020-04-28 10:33:09 -06:00
Sebastian Kuzminsky
6199c01029 debian: update watch file with new linuxcnc url 2020-04-28 10:33:09 -06:00
Sebastian Kuzminsky
c8f4606ab0 debian: use git archive to produce dfsg orig tarball 2020-04-28 10:33:09 -06:00
Sebastian Kuzminsky
3633b9457f debian: remove trailing whitespace in changelog
This fixes a lintian warning.
2020-04-28 10:33:09 -06:00
Sebastian Kuzminsky
e4b6c9ecad debian: add Vcs fields to control file 2020-04-28 10:33:09 -06:00
Sebastian Kuzminsky
a1fe8a333c debian: change Maintainer to LinuxCNC Developers 2020-04-28 10:33:09 -06:00
Sebastian Kuzminsky
eae3738b95 debian: update package description to include SPI boards 2020-04-28 10:33:09 -06:00
Sebastian Kuzminsky
28cd6a3766 debian: build-depend on pkg-config 2020-04-28 10:33:09 -06:00
Sebastian Kuzminsky
ada9aa2f25 debian: require debhelper 9 or higher 2020-04-28 10:33:09 -06:00
Sebastian Kuzminsky
abb3d7b8c7 downgrade C standard support from C11 to C99 to we can build on Precise 2020-04-28 10:33:09 -06:00
Sebastian Kuzminsky
e743729c1a build using the C11 standard
This is needed for older compilers (like Wheezy's gcc 4.7.2 and Jessie's
gcc 4.9.2) to accept "modern" things like for-loops with the index
variable declared in them:

hostmot2.c:759:5: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
     for (int i = 0; i < num_pins; i ++) {
      ^
hostmot2.c:759:5: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code

This also means we no longer need to override CFLAGS in the travis config.
2020-04-27 21:31:26 -06:00
Sebastian Kuzminsky
dfdce44198 fix a typo in an sserial_init() error message 2020-04-26 16:02:43 -06:00
Sebastian Kuzminsky
0d9357f60f serial_recv_packet(): add read error handling 2020-04-25 16:27:26 -06:00
Sebastian Kuzminsky
c7ff674377 serial_recv_packet(): make explicit what the read is doing, no behavioral change 2020-04-25 16:27:26 -06:00
Sebastian Kuzminsky
33d375821a safer string handling in command-line parsing
Make sure the requested filename fits in the `bitfile_name` buffer before
copying it.
2020-04-25 16:27:26 -06:00
Sebastian Kuzminsky
706a8eaf65 check return value from seteuid(), though it should be safe
This squelches a warning from -D_FORTIFY_SOURCE.
2020-04-25 16:27:21 -06:00
Sebastian Kuzminsky
a852e5c7f1 sserial_module_init(): fix a potential unterminated string
Make sure there's room in the destination buffer for the whole source
string, plus the terminating NULL.
2020-04-25 16:02:12 -06:00
Sebastian Kuzminsky
6a4fd889a7 sserial_module_init(): minor refactor for legibility, no behavioral change 2020-04-25 16:02:08 -06:00
Sebastian Kuzminsky
5d460b46a9 Makefile: combine USE_STUBS handling for simplicity 2020-04-24 14:28:39 -06:00
Sebastian Kuzminsky
202482a82f Makefile: get rid of DEBUG, just use CFLAGS directly 2020-04-24 14:28:39 -06:00
Sebastian Kuzminsky
f09ea90ca1 Makefile: get rid of INCLUDE, just use CFLAGS directly 2020-04-24 14:28:38 -06:00
Sebastian Kuzminsky
18cd2ebd86 Makefile: simplify how libpci CFLAGS and LDFLAGS are handled 2020-04-24 14:28:38 -06:00
Sebastian Kuzminsky
54c8a96e12 Makefile: make sure we can find pkg-config and libpci
Error out early and print a helpful error message if they're not found.
2020-04-24 14:28:38 -06:00
Sebastian Kuzminsky
87298f4690 Makefile: rename LIBS to the more traditional LDFLAGS, & simplify 2020-04-24 14:28:19 -06:00
Sebastian Kuzminsky
f02d331dca Makefile: reorg so the TARGET checks are together 2020-04-24 14:27:01 -06:00
Sebastian Kuzminsky
5be492fce8 Makefile: reindent only, no code changes
This makes the `if` statement bodies indent by 4 spaces instead of
sometimes one tab and sometimes nothing.
2020-04-24 14:27:01 -06:00
Sebastian Kuzminsky
279ef4a5b5 README: note build dependency on pkg-config 2020-04-24 14:27:01 -06:00
Sebastian Kuzminsky
9341ab2a89
Merge pull request #33 from LinuxCNC/merge-jt
changes from jethornton/mesaflash master branch
2020-04-24 10:21:51 -06:00
john
81e3d971a8 add travis 2020-04-23 15:14:50 -06:00
Peter Wallace
3684302a9f Add RCPWM pinout support 2020-04-23 15:08:12 -06:00
Peter Wallace
0294f2fac3 add RCPWM pinout support 2020-04-23 15:08:01 -06:00
Peter Wallace
7e008541ed Add Inm and BISS pinout list support
fix a couple of compile warnings
2020-04-23 15:07:46 -06:00
Peter Wallace
ef98977a25 Add inmux pin names and xy100 module information and pin names 2020-04-23 15:02:20 -06:00
Peter Wallace
8b2f060daa add new SPI boards and SPI reload ability to --help 2020-04-23 15:02:13 -06:00
Peter Wallace
7ae92326f8 Add --reload capability to SPI boards 2020-04-23 15:02:07 -06:00
Sebastian Kuzminsky
68b23a771b merge changes from JT's mesaflash version 2020-04-23 15:01:06 -06:00
Sebastian Kuzminsky
5f53bda39b mesaflash: note SPI boards are supported now 2020-04-23 12:41:23 -06:00
Sebastian Kuzminsky
da53731277 mesaflash: remove leading newline in --help message 2020-04-23 12:41:18 -06:00
Sebastian Kuzminsky
86ce0aa359 serial_boards: don't redefine _GNU_SOURCE, it's in CFLAGS now 2020-04-23 12:41:05 -06:00
Sebastian Kuzminsky
6c6d5a65d4 Merge remote-tracking branch 'origin/v3.3'
* origin/v3.3:
  read-hmid: report unknown pins better
  hm2_print_pin_file(): use find_module_name() instead of searching the list
  rename pin_find_module_name() to find_module_name()
  include gtag number of unknown gtags in pin list
  remove dead code
  7i96: fixup pins per connector
  don't segfault on unknown ethernet boards
  fix a typo in a comment
  fix SSR pin names
  fix sserial channel number in readhmid pin list
  rename the "Transformer" GTAG to "SSR", to match the linuxcnc hm2 driver
  7i96: make the connector list match the ioport list
  capitalize Ethernet consistently in --help message
  fix addr argument for ethernet boards in --help message
  consistent capitalization and punctuation in --help output
  fix formatting of --help output
  release 3.3.0~pre0+dfsg-0
  release mesaflash 3.2.1
  debian/changelog: new version
  pci_analog_write: include unistd.h, which declares usleep()
  sserial_module: declare sserial_write(), used by pci_analog_write
  pci_encoder_read: include unistd.h, for usleep()
  serial_boards: add some missing declarations
  spi_boards: include unistd.h
  spi_boards: include ctype.h
  add missing return value in spi_boards_init()
  spi_boards: include eeprom.h
  eeprom_local: include pci/pci.h
  hostmot2: add some missing function declarations
  pci_boards: move pci_read() and pci_write() to before the first use in the file
  pci_boards: include sys/time.h
  anyio: include missing serial_boards.h
  include bitfile.h in eeprom.c, for print_bitfile_header()
  function declarations shouldn't be marked inline
2020-04-23 12:40:29 -06:00
Sebastian Kuzminsky
1bded53776
Merge pull request #31 from dwrobel/7-stringop-truncation
Fix -Wstringop-truncation warnings
2020-04-23 12:32:10 -06:00
Sebastian Kuzminsky
625763effa
Merge pull request #32 from dwrobel/8-use-stubs
Add sys/io.h stubs implementation
2020-04-23 10:05:11 -06:00
Sebastian Kuzminsky
650097f4ad
Merge pull request #30 from dwrobel/6-linking-errors
Fix linking errors
2020-04-23 08:41:25 -06:00
Sebastian Kuzminsky
5aac0ec1da
Merge pull request #29 from dwrobel/5-compilation-errors
Fix compilation errors
2020-04-23 08:37:48 -06:00
Sebastian Kuzminsky
3bb6cbe9dd
Merge pull request #28 from dwrobel/4-wformat-warnings
Fix -Wformat warning
2020-04-23 08:34:39 -06:00
Sebastian Kuzminsky
c5ba440faa
Merge pull request #26 from dwrobel/2-easy-packaging
Make packaging easier
2020-04-23 08:31:25 -06:00
Michael
e84e9f0781
Merge pull request #27 from dwrobel/3-indentation-warnings
Fix misleading indentation warnings
2020-04-21 19:51:15 +02:00
Michael
c724677369
Merge pull request #25 from dwrobel/1-gpl-license
Add GPL license text file
2020-04-21 19:50:30 +02:00
Damian Wrobel
59cda6148f Add sys/io.h stubs implementation
Allows mesaflash to be compiled on platforms (such as arm)
which do not provides <sys/io.h> header file.

Signed-off-by: Damian Wrobel <dwrobel@ertelnet.rybnik.pl>
2020-04-20 18:18:40 +02:00
Damian Wrobel
63e8e8f64b Fix -Wstringop-truncation warnings
Fixes the following warnings:
In function 'strncpy',
    inlined from 'spi_boards_scan' at spi_boards.c:203:9:
/usr/include/bits/string_fortified.h:106:10: warning: '__builtin_strncpy'
output truncated before terminating nul copying 4 bytes
from a string of the same length [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));

In file included from /usr/include/string.h:495,
                 from pci_boards.c:34:
In function ‘strncpy’,
    inlined from ‘pci_boards_scan’ at pci_boards.c:1281:21:
/usr/include/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’
output truncated before terminating nul copying 4 bytes from a string of
the same length [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘strncpy’,
    inlined from ‘pci_boards_scan’ at pci_boards.c:1240:21:
/usr/include/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’
output truncated before terminating nul copying 4 bytes from a string of
the same length [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘strncpy’,
    inlined from ‘pci_boards_scan’ at pci_boards.c:1205:21:
/usr/include/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’
output truncated before terminating nul copying 4 bytes from a string of
the same length [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘strncpy’,
    inlined from ‘pci_boards_scan’ at pci_boards.c:1177:21:
/usr/include/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’
output truncated before terminating nul copying 4 bytes from a string of
the same length [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘strncpy’,
    inlined from ‘pci_boards_scan’ at pci_boards.c:1144:21:
/usr/include/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’
output truncated before terminating nul copying 4 bytes from a string of
the same length [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘strncpy’,
    inlined from ‘pci_boards_scan’ at pci_boards.c:1117:21:
/usr/include/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’
output truncated before terminating nul copying 4 bytes from a string of
the same length [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘strncpy’,
    inlined from ‘pci_boards_scan’ at pci_boards.c:1089:21:
/usr/include/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’
output truncated before terminating nul copying 4 bytes from a string of
the same length [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘strncpy’,
    inlined from ‘pci_boards_scan’ at pci_boards.c:1056:21:
/usr/include/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’
output truncated before terminating nul copying 4 bytes from a string of
the same length [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘strncpy’,
    inlined from ‘pci_boards_scan’ at pci_boards.c:1026:21:
/usr/include/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’
output truncated before terminating nul copying 4 bytes from a string of
the same length [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘strncpy’,
    inlined from ‘pci_boards_scan’ at pci_boards.c:995:17:
/usr/include/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’
output truncated before terminating nul copying 4 bytes from a string of
the same length [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘strncpy’,
    inlined from ‘pci_boards_scan’ at pci_boards.c:967:17:
/usr/include/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’
output truncated before terminating nul copying 4 bytes from a string of
the same length [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘strncpy’,
    inlined from ‘pci_boards_scan’ at pci_boards.c:940:17:
/usr/include/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’
output truncated before terminating nul copying 4 bytes from a string of
the same length [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘strncpy’,
    inlined from ‘pci_boards_scan’ at pci_boards.c:912:17:
/usr/include/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’
output truncated before terminating nul copying 4 bytes from a string of
the same length [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘strncpy’,
    inlined from ‘pci_boards_scan’ at pci_boards.c:885:17:
/usr/include/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’
output truncated before terminating nul copying 4 bytes from a string of
the same length [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘strncpy’,
    inlined from ‘pci_boards_scan’ at pci_boards.c:851:17:
/usr/include/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’
output truncated before terminating nul copying 14 bytes from a string of
the same length [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In file included from /usr/include/string.h:495,
                 from usb_boards.c:21:
In function ‘strncpy’,
    inlined from ‘usb_boards_scan’ at usb_boards.c:188:9:
/usr/include/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’
output truncated before terminating nul copying 4 bytes from a string of
the same length [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘strncpy’,
    inlined from ‘usb_boards_scan’ at usb_boards.c:147:13:
/usr/include/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’
output truncated before terminating nul copying 4 bytes from a string of
the same length [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In function ‘strncpy’,
    inlined from ‘eth_scan_one_addr’ at eth_boards.c:329:13,
    inlined from ‘eth_scan_one_addr.isra.0’ at eth_boards.c:136:12:
/usr/include/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’ output
may be truncated copying 16 bytes from a string of length 19 [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘strncpy’,
    inlined from ‘eth_scan_one_addr’ at eth_boards.c:306:13,
    inlined from ‘eth_scan_one_addr.isra.0’ at eth_boards.c:136:12:
/usr/include/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’ output
may be truncated copying 16 bytes from a string of length 19 [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘strncpy’,
    inlined from ‘eth_scan_one_addr’ at eth_boards.c:283:13,
    inlined from ‘eth_scan_one_addr.isra.0’ at eth_boards.c:136:12:
/usr/include/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’ output
may be truncated copying 16 bytes from a string of length 19 [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘strncpy’,
    inlined from ‘eth_scan_one_addr’ at eth_boards.c:259:13,
    inlined from ‘eth_scan_one_addr.isra.0’ at eth_boards.c:136:12:
/usr/include/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’ output
may be truncated copying 16 bytes from a string of length 19 [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘strncpy’,
    inlined from ‘eth_scan_one_addr’ at eth_boards.c:235:13,
    inlined from ‘eth_scan_one_addr.isra.0’ at eth_boards.c:136:12:
/usr/include/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’ output
may be truncated copying 16 bytes from a string of length 19 [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘strncpy’,
    inlined from ‘eth_scan_one_addr’ at eth_boards.c:211:13,
    inlined from ‘eth_scan_one_addr.isra.0’ at eth_boards.c:136:12:
/usr/include/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’ output
may be truncated copying 16 bytes from a string of length 19 [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘strncpy’,
    inlined from ‘eth_scan_one_addr’ at eth_boards.c:186:13,
    inlined from ‘eth_scan_one_addr.isra.0’ at eth_boards.c:136:12:
/usr/include/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’ output
may be truncated copying 16 bytes from a string of length 19 [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘strncpy’,
    inlined from ‘eth_scan_one_addr’ at eth_boards.c:161:13,
    inlined from ‘eth_scan_one_addr.isra.0’ at eth_boards.c:136:12:
/usr/include/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’ output
may be truncated copying 16 bytes from a string of length 19 [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Damian Wrobel <dwrobel@ertelnet.rybnik.pl>
2020-04-20 16:35:34 +02:00
Damian Wrobel
889ab134af Fix linking errors
Fixes the following linking errors on gcc 10:
/usr/bin/ld: libanyio.a(spi_boards.o):spi_boards.c:41:
 multiple definition of `sd';
 libanyio.a(eth_boards.o):eth_boards.c:49: first defined here
/usr/bin/ld: libanyio.a(serial_boards.o):serial_boards.c:38:
 multiple definition of `sd';
 libanyio.a(eth_boards.o):eth_boards.c:49: first defined here
/usr/bin/ld: libanyio.a(lbp.o):mesaflash/lbp.c:31:
 multiple definition of `sd';
 libanyio.a(eth_boards.o):eth_boards.c:49: first defined here

Signed-off-by: Damian Wrobel <dwrobel@ertelnet.rybnik.pl>
2020-04-20 16:33:41 +02:00
Damian Wrobel
803a569576 Fix compilation errors
Fixes the following compilation errors:
examples/pci_encoder_read.c:33:19: error: unknown type name ‘useconds_t’; did you mean ‘suseconds_t’?
   33 | extern int usleep(useconds_t usec); // static global access variable conflicts with POSIX function in unistd.h
      |                   ^~~~~~~~~~
      |                   suseconds_t
examples/pci_encoder_read.c: In function ‘main’:
examples/pci_encoder_read.c:171:9: warning: implicit declaration of function ‘usleep’ [-Wimplicit-function-declaration]
  171 |         usleep(delay*1000);             // wait delay ms
      |         ^~~~~~

examples/pci_encoder_read.c:40:23: error: ‘access’ redeclared as different kind of symbol
   40 | static board_access_t access;
      |                       ^~~~~~
In file included from examples/pci_encoder_read.c:29:
/usr/include/unistd.h:287:12: note: previous declaration of ‘access’ was here
  287 | extern int access (const char *__name, int __type) __THROW __nonnull ((1));
      |            ^~~~~~

examples/pci_analog_write.c:33:19: error: unknown type name ‘useconds_t’; did you mean ‘suseconds_t’?
   33 | extern int usleep(useconds_t usec); // static global access variable conflicts with POSIX function in unistd.h
      |                   ^~~~~~~~~~
      |                   suseconds_t

examples/pci_analog_write.c:40:23: error: ‘access’ redeclared as different kind of symbol
   40 | static board_access_t access;
      |                       ^~~~~~
In file included from examples/pci_analog_write.c:29:
/usr/include/unistd.h:287:12: note: previous declaration of ‘access’ was here
  287 | extern int access (const char *__name, int __type) __THROW __nonnull ((1));
      |            ^~~~~~

Signed-off-by: Damian Wrobel <dwrobel@ertelnet.rybnik.pl>
2020-04-20 16:32:22 +02:00
Damian Wrobel
260be11cc0 Fix -Wformat warning
Fixes:
 pi_boards.c:190:56: warning: format '%x' expects argument of type
 'unsigned int', but argument 4 has type 'long unsigned int' [-Wformat=]
   190 |         fprintf(stderr, "Unexpected cookie at %04x..%04x:\n%08x %08x %08x\n",
       |                                                     ~~~^
       |                                                        |
       |                                                        unsigned int
       |                                                     %04lx

Signed-off-by: Damian Wrobel <dwrobel@ertelnet.rybnik.pl>
2020-04-20 16:31:18 +02:00
Damian Wrobel
9d6374af3d Fix misleading indentation warnings
Fixes the following warnings:

 lbp.c: In function 'lbp_send':
 lbp.c:43:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    43 |     if (LBP_SENDRECV_DEBUG)
       |     ^~
 lbp.c:45:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    45 |  return send;
       |  ^~~~~~
 lbp.c: In function 'lbp_recv':
 lbp.c:55:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    55 |     if (LBP_SENDRECV_DEBUG)
       |     ^~
 lbp.c:57:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    57 |  return recv;
       |  ^~~~~~

Signed-off-by: Damian Wrobel <dwrobel@ertelnet.rybnik.pl>
2020-04-20 16:29:16 +02:00
Damian Wrobel
454e45a0bc Make packaging easier
Improves a few things to make it easier to package mesaflash
e.g. as an rpm package:

 - Allows to honor CFLAGS passed from command line,
 - Do not need to run make install from 'root' user,
 - Do not hardcode include directory,
 - Use pkg-config to determine compiler options for using libcpi.

As this change is fully backward compatible in order to use new
features it is needed to set the followings variables:
  - CFLAGS - usually done by linux distribution,
  - DEBUG - set to empty as CFLAGS should contain everything needed,
  - OWNERSHIP - set to empty - (e.g. rpm will set it correctly for you).

Example:
 $ CFLAGS="distribution specific list of options" DEBUG="" OWNERSHIP="" make

Signed-off-by: Damian Wrobel <dwrobel@ertelnet.rybnik.pl>
2020-04-20 16:27:53 +02:00
Damian Wrobel
fee7da3cf1 Add GPL license text file
Add missing license text file which is needed to package mesaflash
for Fedora linux distribution.

The following command was used to obtain the license text file:
 $ wget -O COPYING https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt

Signed-off-by: Damian Wrobel <dwrobel@ertelnet.rybnik.pl>
2020-04-20 16:27:04 +02:00
Michael
84fa463567
Merge pull request #24 from dremeier/patch-1
Update README
2020-04-15 04:11:24 +02:00
dremeier
b0770c6dcd
Update README
add: make install
2019-09-15 15:33:23 +02:00
Sebastian Kuzminsky
5dc2dd1c3a read-hmid: report unknown pins better 2018-06-09 17:14:38 -06:00
Sebastian Kuzminsky
2e2d2138ee hm2_print_pin_file(): use find_module_name() instead of searching the list 2018-06-09 16:55:18 -06:00
Sebastian Kuzminsky
6013aa9022 rename pin_find_module_name() to find_module_name()
Since it has nothing to do with pins.
2018-06-09 16:55:18 -06:00
Sebastian Kuzminsky
36fa45f70a include gtag number of unknown gtags in pin list
This makes it easier to bootstrap support for new gtags.
2018-06-02 14:34:30 -06:00
Sebastian Kuzminsky
a866381c55 remove dead code
These functions were never called, and some of the declarations were duplicated.
2018-06-02 14:34:22 -06:00
Sebastian Kuzminsky
5e50dfcb15 7i96: fixup pins per connector 2018-06-02 10:38:12 -06:00
Sebastian Kuzminsky
ed5349aebf don't segfault on unknown ethernet boards
eth_scan_one_addr() now returns an int indicating pass (it found a
known board at the specified address) or fail (no known board found at
that address).

eth_boards_scan() propagates this pass/fail signal up to anyio_find_dev(),
so it can report eth-board failures just like it does for pci, epp, etc.

This commit also fixes a harmless(?) bug where unknown ethernet boards
would cause mesaflash to miscount the number of discovered boards.
2018-04-22 21:51:12 -06:00
Sebastian Kuzminsky
9e111a39df Merge branch '7i96-fixes' into v3.3 2018-03-03 12:34:46 -07:00
Sebastian Kuzminsky
3f09836163 fix a typo in a comment 2018-03-03 10:19:07 -07:00
Sebastian Kuzminsky
fa69937a89 fix SSR pin names
This fixes a segfault when listing the pins on the 7i96.
2018-03-03 10:19:07 -07:00
Sebastian Kuzminsky
e2d8f65a06 fix sserial channel number in readhmid pin list 2018-03-03 10:19:01 -07:00
Sebastian Kuzminsky
0a84fe9cdd rename the "Transformer" GTAG to "SSR", to match the linuxcnc hm2 driver 2018-03-03 10:18:55 -07:00
Sebastian Kuzminsky
e3160995da 7i96: make the connector list match the ioport list
The 7i96 is unique in that there isn't a 1:1 mapping between connectors
and ioports.  TB1 and TB2 are both part of ioport 1.  This fudges the
connector list to match.
2018-03-03 10:18:50 -07:00
Michael
487e7b78b5
Merge pull request #19 from SebKuzminsky/minor-fixes
Minor fixes
2018-02-27 21:01:12 +01:00
Sebastian Kuzminsky
38f01ad2bb capitalize Ethernet consistently in --help message 2018-02-18 16:24:04 -07:00
Sebastian Kuzminsky
d004da0476 fix addr argument for ethernet boards in --help message 2018-02-18 16:23:41 -07:00
Sebastian Kuzminsky
a533f15ea3 consistent capitalization and punctuation in --help output 2018-02-18 16:22:20 -07:00
Sebastian Kuzminsky
dae69da99b fix formatting of --help output
Whitespace changes only, no content changes.
2018-02-18 16:19:09 -07:00
Sebastian Kuzminsky
084297ebf1 release 3.3.0~pre0+dfsg-0 2017-06-27 21:52:50 -06:00
Sebastian Kuzminsky
9f2bb5e0fa Merge branch 'v3.2' into v3.3
Conflicts:
	debian/changelog
	eeprom_local.c
	pci_boards.c
2017-06-27 10:33:37 -06:00
Sebastian Kuzminsky
35d69bef1c release mesaflash 3.2.1 2017-06-27 10:26:32 -06:00
Sebastian Kuzminsky
0cefd5a03a debian/changelog: new version
Bump the version of the package from 3.2.0 to 3.2.0-1.
2017-06-25 21:32:48 -06:00
Sebastian Kuzminsky
b40248b68e pci_analog_write: include unistd.h, which declares usleep()
Also rename the variable "access" to "board_access" to avoid collission
with the access() function declared by unistd.h .
2017-06-25 20:48:36 -06:00
Sebastian Kuzminsky
fe190b8be9 sserial_module: declare sserial_write(), used by pci_analog_write 2017-06-25 20:48:09 -06:00
Sebastian Kuzminsky
9fa91d7e97 pci_encoder_read: include unistd.h, for usleep()
Also rename the variable "access" to "board_access", to avoid collission
with the access() function that unistd.h declares.
2017-06-25 20:45:13 -06:00
Sebastian Kuzminsky
137bae5f33 serial_boards: add some missing declarations
ppoll() is a _GNU_SOURCE feature, and since mesaflash is GPL 2+ we can
enable _GNU_SOURCE here.
2017-06-25 20:43:06 -06:00
Sebastian Kuzminsky
9cd36eb934 spi_boards: include unistd.h
This declares close(), which avoids an 'implicit declaration' warning
from GCC 6.3 in Debian Stretch.
2017-06-25 20:39:13 -06:00
Sebastian Kuzminsky
ca3fd5dae3 spi_boards: include ctype.h
This provides the declaration of isprint(), which is needed to avoid an
'implicit declaration' warning from GCC 6.3 in Debian Stretch.
2017-06-25 20:24:45 -06:00
Sebastian Kuzminsky
28e189e8a4 add missing return value in spi_boards_init()
mesaflash uses the standard return value -1 for indicating errors,
so use it here too.
2017-06-25 20:23:33 -06:00
Sebastian Kuzminsky
85f9328f58 spi_boards: include eeprom.h
This provides the declaration of eeprom_init(), avoiding an "implicit
declaration" warning on GCC 6.3 on Debian Stretch.
2017-06-25 20:21:24 -06:00
Sebastian Kuzminsky
392e85ef09 eeprom_local: include pci/pci.h
This C file calls functions in libpci, so make sure we declare them.
This fixes the situation on Linux, no idea about Windows.
2017-06-25 20:19:57 -06:00
Sebastian Kuzminsky
29759f2667 hostmot2: add some missing function declarations
These functions are used by encoder_module, so we need to declare them
to avoid an "implicit declaration" warning from GCC 6.3 in Debian Stretch.
2017-06-25 20:18:23 -06:00
Sebastian Kuzminsky
ff1684cfe6 pci_boards: move pci_read() and pci_write() to before the first use in the file
This avoids an "implicit declaration" warning from GCC 6.3 in Debian
Stretch.
2017-06-25 20:15:12 -06:00
Sebastian Kuzminsky
55aa941e84 pci_boards: include sys/time.h
This provides the declaration of gettimeofday(), squelching a compile
warning on GCC 6.3 in Debian Stretch.
2017-06-25 20:13:13 -06:00
Sebastian Kuzminsky
b01982d3d7 anyio: include missing serial_boards.h
This defines some serial_boards_*() functions that anyio.c uses.
2017-06-25 20:09:39 -06:00
Sebastian Kuzminsky
407286323a include bitfile.h in eeprom.c, for print_bitfile_header() 2017-06-25 11:18:39 -06:00
Sebastian Kuzminsky
9ea86013ff function declarations shouldn't be marked inline
GCC 6.3 in Debian Strech uses C99 inline semantics, so it complains:

    In file included from eeprom_local.c:31:0:
    eeprom_local.c: At top level:
    epp_boards.h:37:13: warning: inline function ‘epp_write8’ declared but never defined
     inline void epp_write8(board_t *board, u8 data);
		 ^~~~~~~~~~

The function declaration needs to be non-inline, and the function
definition can be inline.
2017-06-25 11:14:13 -06:00
Sebastian Kuzminsky
3c326c9aca fix a typo: intefaces/interfaces 2017-04-27 21:13:15 -06:00
Sebastian Kuzminsky
d598b180b6 debian/changelog: fix syntax error
Some debian changelog parsing tools don't like it if there isn't a
single changelog entry.  This commit adds a placeholder changelog entry
to placate those tools.
2017-04-27 21:12:47 -06:00
41 changed files with 1335 additions and 2157 deletions

8
.gitattributes vendored Normal file
View file

@ -0,0 +1,8 @@
WinIo32.* export-ignore
libpci.dll export-ignore
libpci/** export-ignore
libpci export-ignore
winio32/** export-ignore
winio32 export-ignore

28
.github/workflows/ci.yml vendored Normal file
View file

@ -0,0 +1,28 @@
on:
push:
pull_request:
release:
types: [published]
check_suite:
types: [rerequested]
jobs:
test:
runs-on: ubuntu-20.04
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v2
- name: Install deps
run: |
sudo apt-get update
sudo apt-get install -y eatmydata
sudo eatmydata apt-get install -y --no-install-suggests --no-install-recommends build-essential devscripts equivs
mk-build-deps -irs sudo -t "apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y"
- name: Build
run: |
make -j$(nproc)

339
COPYING Normal file
View file

@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

View file

@ -25,29 +25,59 @@ CC = gcc
RM = rm -f
AR = ar
RANLIB = ranlib
MATHLIB = -lm
OPT = -O0
#DEBUG = -g -pedantic -Wall -Wextra
#DEBUG = -g -Wall -Wextra
DEBUG = -g
OWNERSHIP ?= --owner root --group root
# default CFLAGS
CFLAGS ?= -O0 -g -Wall -Werror=format -Werror=format-security
# mesaflash needs at least C99 to compile.
#
# The oldest distros we support are Debian Wheezy (EOL 2018-05-31)
# and Ubuntu Precise (EOL 2017-04-28):
#
# Debian Wheezy has gcc 4.7.2, which defaults to C90 but supports C11.
#
# Ubuntu Precise has gcc 4.6.3, which defaults to C90 but supports
# C99 (but does not support C11).
#
# So we explicitly select the newest ancient C standard that we have to
# support here.
CFLAGS += -std=c99
ifeq ($(TARGET),linux)
INCLUDE = -I/usr/include
$(shell which pkg-config > /dev/null)
ifeq ($(.SHELLSTATUS), 1)
$(error "can't find pkg-config")
endif
$(shell pkg-config --exists libpci > /dev/null)
ifeq ($(.SHELLSTATUS), 1)
$(error "pkg-config can't find libpci")
endif
LIBPCI_CFLAGS := $(shell pkg-config --cflags libpci)
LIBPCI_LDFLAGS := $(shell pkg-config --libs libpci)
BIN = mesaflash
LIBS = -lpci $(MATHLIB)
CFLAGS += -D_GNU_SOURCE
LDFLAGS = -lm $(LIBPCI_LDFLAGS)
CFLAGS += -D_GNU_SOURCE $(LIBPCI_CFLAGS) -D_FILE_OFFSET_BITS=64
UNAME_M := $(shell uname -m)
ifeq ($(UNAME_M),aarch64)
MESAFLASH_IO ?= 0
endif
endif
ifeq ($(TARGET),windows)
MINGW = c:/MinGW
INCLUDE = -I$(MINGW)/include
CFLAGS += -I$(MINGW)/include
BIN = mesaflash.exe
LIBS = -lwsock32 -lws2_32 libpci.dll winio32.dll
DEBUG += -mno-ms-bitfields
LDFLAGS = -lwsock32 -lws2_32 libpci.dll winio32.dll
CFLAGS += -mno-ms-bitfields
endif
CFLAGS += $(OPT) $(DEBUG) $(INCLUDE)
MESAFLASH_IO ?= 1
CFLAGS += -DMESAFLASH_IO=$(MESAFLASH_IO)
objects = common.o lbp.o lbp16.o bitfile.o hostmot2.o eeprom.o anyio.o eth_boards.o epp_boards.o usb_boards.o pci_boards.o
objects += sserial_module.o encoder_module.o eeprom_local.o eeprom_remote.o spi_boards.o serial_boards.o
@ -67,7 +97,7 @@ mesaflash.o : mesaflash.c $(headers)
$(CC) $(CFLAGS) -c mesaflash.c
$(BIN): mesaflash.o anyio.h $(LIBANYIO)
$(CC) -o $(BIN) mesaflash.o $(LIBANYIO) $(LIBS)
$(CC) $(CFLAGS) -o $(BIN) mesaflash.o $(LIBANYIO) $(LDFLAGS)
anyio.o : anyio.c $(headers)
$(CC) $(CFLAGS) -c anyio.c
@ -124,18 +154,18 @@ pci_encoder_read.o : examples/pci_encoder_read.c $(LIBANYIO) $(headers)
$(CC) $(CFLAGS) -c examples/pci_encoder_read.c
pci_encoder_read: pci_encoder_read.o anyio.h encoder_module.h
$(CC) -o pci_encoder_read pci_encoder_read.o $(LIBANYIO) $(LIBS)
$(CC) $(CFLAGS) -o pci_encoder_read pci_encoder_read.o $(LIBANYIO) $(LDFLAGS)
pci_analog_write.o : examples/pci_analog_write.c $(LIBANYIO) $(headers)
$(CC) $(CFLAGS) -c examples/pci_analog_write.c
pci_analog_write: pci_analog_write.o anyio.h sserial_module.h
$(CC) -o pci_analog_write pci_analog_write.o $(LIBANYIO) $(LIBS)
$(CC) $(CFLAGS) -o pci_analog_write pci_analog_write.o $(LIBANYIO) $(LDFLAGS)
clean :
$(RM) *.o $(LIBANYIO) $(BIN) pci_encoder_read pci_analog_write
.PHONY: install
install: $(BIN)
install --mode=0755 --owner root --group root --dir $(DESTDIR)/bin
install --mode=0755 --owner root --group root $(BIN) $(DESTDIR)/bin
install -p -D --mode=0755 $(OWNERSHIP) $(BIN) $(DESTDIR)/bin/$(BIN)
install -p -D --mode=0644 $(OWNERSHIP) mesaflash.1 $(DESTDIR)/share/man/man1/mesaflash.1

20
README
View file

@ -1,20 +0,0 @@
mesaflash
=========
Configuration and diagnostic tool for Mesa Electronics PCI(E)/ETH/EPP/USB/SPI boards
Quickstart:
===========
From the top level directory, switch to the source directory:
cd mesaflash
In the source directory, install dependency and build:
sudo apt-get install libpci-dev
make
to get command line syntax:
./mesaflash --help

47
README.md Normal file
View file

@ -0,0 +1,47 @@
# mesaflash
Configuration and diagnostic tool for Mesa Electronics PCI(E)/ETH/EPP/USB/SPI boards
Quickstart:
===========
MesaFlash depends on a couple of packages to build, so install those
first:
sudo apt install libpci-dev pkg-config build-essential
You may need to install git first:
sudo apt install git
Clone MesaFlash:
git clone https://github.com/LinuxCNC/mesaflash.git
From the top level directory, switch to the source directory:
cd mesaflash
In the source directory to build MesaFlash:
make
To get command line syntax from a local make:
./mesaflash --help
To build and install MesaFlash:
sudo make install
To run an installed MesaFlash:
mesaflash --help
Distributions
===============
**mesaflash** package is available on [Fedora](https://src.fedoraproject.org/rpms/mesaflash) _(version 31 or newer)_ and can be simply installed by using:
```
# dnf install mesaflash
```
Availability of **mesaflash** for other Linux distributions can be checked on [release-monitoring](https://release-monitoring.org/project/105522/) project page.

Binary file not shown.

Binary file not shown.

27
anyio.c
View file

@ -31,9 +31,14 @@
supported_board_entry_t supported_boards[] = {
{"ETHER", BOARD_ETH | BOARD_WILDCARD},
{"SPI", BOARD_SPI | BOARD_WILDCARD},
{"7I92", BOARD_ETH},
{"7I93", BOARD_ETH},
{"7I94", BOARD_ETH},
{"7I95", BOARD_ETH},
{"7I96", BOARD_ETH},
{"7I97", BOARD_ETH},
{"7I98", BOARD_ETH},
{"7I80", BOARD_ETH},
{"7I76E", BOARD_ETH},
@ -51,10 +56,13 @@ supported_board_entry_t supported_boards[] = {
{"4I69", BOARD_PCI},
{"3X20", BOARD_PCI},
{"7C80", BOARD_MULTI_INTERFACE | BOARD_EPP | BOARD_SPI},
{"7C81", BOARD_MULTI_INTERFACE | BOARD_EPP | BOARD_SPI},
{"7I43", BOARD_MULTI_INTERFACE | BOARD_EPP | BOARD_USB},
{"7I90", BOARD_MULTI_INTERFACE | BOARD_EPP | BOARD_SPI | BOARD_SER},
{"7I64", BOARD_MULTI_INTERFACE | BOARD_USB | BOARD_SPI},
{"AUTO", BOARD_MULTI_INTERFACE | BOARD_WILDCARD | BOARD_USB | BOARD_EPP | BOARD_SPI | BOARD_SER | BOARD_PCI},
{NULL, 0},
};
@ -74,10 +82,12 @@ void anyio_cleanup(board_access_t *access) {
}
if (access->open_iface & BOARD_ETH)
eth_boards_cleanup(access);
#if MESAFLASH_IO
if (access->open_iface & BOARD_PCI)
pci_boards_cleanup(access);
if (access->open_iface & BOARD_EPP)
epp_boards_cleanup(access);
#endif
if (access->open_iface & BOARD_USB)
usb_boards_cleanup(access);
if (access->open_iface & BOARD_SPI)
@ -118,8 +128,12 @@ int anyio_find_dev(board_access_t *access) {
if (supported_board->type & BOARD_ETH) {
ret = eth_boards_init(access);
access->open_iface |= BOARD_ETH;
eth_boards_scan(access);
ret = eth_boards_scan(access);
if (ret < 0) {
return ret;
}
}
#if MESAFLASH_IO
if (supported_board->type & BOARD_PCI) {
ret = pci_boards_init(access);
if (ret < 0) {
@ -136,6 +150,7 @@ int anyio_find_dev(board_access_t *access) {
access->open_iface |= BOARD_EPP;
epp_boards_scan(access);
}
#endif
if (supported_board->type & BOARD_USB) {
ret = usb_boards_init(access);
access->open_iface |= BOARD_USB;
@ -157,6 +172,7 @@ int anyio_find_dev(board_access_t *access) {
access->open_iface |= BOARD_ETH;
eth_boards_scan(access);
}
#if MESAFLASH_IO
if (access->type & BOARD_PCI) {
ret = pci_boards_init(access);
if (ret < 0) {
@ -173,6 +189,7 @@ int anyio_find_dev(board_access_t *access) {
access->open_iface |= BOARD_EPP;
epp_boards_scan(access);
}
#endif
if (access->type & BOARD_USB) {
ret = usb_boards_init(access);
access->open_iface |= BOARD_USB;
@ -323,6 +340,14 @@ void anyio_dev_print_hm2_info(board_t *board, int xml_flag) {
hm2_print_pin_file(&(board->llio), xml_flag);
}
void anyio_dev_print_pin_descriptors(board_t *board) {
if (board == NULL) {
return;
}
hm2_read_idrom(&(board->llio.hm2));
hm2_print_pin_descriptors(&board->llio);
}
void anyio_dev_print_sserial_info(board_t *board) {
if (board == NULL) {
return;

View file

@ -36,6 +36,7 @@ int anyio_dev_set_remote_ip(board_t *board, char *lbp16_set_ip_addr);
int anyio_dev_reload(board_t *board, int fallback_flag);
int anyio_dev_reset(board_t *board);
void anyio_dev_print_hm2_info(board_t *board, int xml_flag);
void anyio_dev_print_pin_descriptors(board_t *board);
void anyio_dev_print_sserial_info(board_t *board);
void anyio_bitfile_print_info(char *bitfile_name, int verbose_flag);

View file

@ -60,7 +60,7 @@ struct board_struct {
struct pci_dev *dev;
void *base;
int len;
u32 mem_base;
u64 mem_base;
#ifdef _WIN32
tagPhysStruct_t mem_handle;
#endif

35
debian/changelog vendored
View file

@ -1,8 +1,33 @@
mesaflash (3.3.0~pre) UNRELEASED; urgency=low
mesaflash (3.4.0~pre1-1) stable; urgency=medium
-- Michael Geszkiewicz <micges@wp.pl> 27 Sep 2015 19:24:42 -0500
* Add a manpage.
* Fix several compile warnings.
* Add `--device AUTO` and `--device SPI`.
mesaflash (3.2.0) UNRELEASED; urgency=low
-- LinuxCNC Developers <emc-developers@lists.sourceforge.net> Fri, 22 May 2020 10:30:23 -0600
mesaflash (3.4.0~pre0-1) stable; urgency=medium
* mesaflash is now maintained by the LinuxCNC organization.
-- LinuxCNC Developers <emc-developers@lists.sourceforge.net> Thu, 23 Apr 2020 10:34:49 -0600
mesaflash (3.3.0~pre0+dfsg-0) stable; urgency=low
* support Mesa 7i93 ethernet board
* support Mesa 7i96 ethernet board
* Verify firmware after writing
* Many bug fixes
-- Sebastian Kuzminsky <seb@highlab.com> Tue, 27 Jun 2017 21:52:31 -0600
mesaflash (3.2.1) stable; urgency=low
* Fix some compile warnings and link issues on Debian Stretch.
-- Sebastian Kuzminsky <seb@highlab.com> Tue, 27 Jun 2017 10:25:59 -0600
mesaflash (3.2.0) stable; urgency=low
* Don't check bitfile destinations while gpio recovering 6i24/6i25 boards
* Use modules base address from module descriptor, not from regmap
@ -16,7 +41,7 @@ mesaflash (3.2.0) UNRELEASED; urgency=low
-- Michael Geszkiewicz <micges@wp.pl> 27 Sep 2015 19:24:42 -0500
mesaflash (3.1.0) UNRELEASED; urgency=low
mesaflash (3.1.0) stable; urgency=low
* First stable release.
* Support 7i90HD under linux in SPI and rs422 mode
@ -41,7 +66,7 @@ mesaflash (3.1.0) UNRELEASED; urgency=low
-- Michael Geszkiewicz <micges@wp.pl> Sat, 24 Nov 2014 01:07:22 -0500
mesaflash (3.0.0) UNRELEASED; urgency=low
mesaflash (3.0.0) stable; urgency=low
* Initial release.

2
debian/compat vendored
View file

@ -1 +1 @@
7
9

8
debian/control vendored
View file

@ -1,13 +1,15 @@
Source: mesaflash
Maintainer: Michael Geszkiewicz <micges@wp.pl>
Maintainer: LinuxCNC Developers <emc-developers@lists.sourceforge.net>
Section: misc
Priority: optional
Standards-Version: 3.9.4
Build-Depends: libpci-dev, debhelper
Build-Depends: libpci-dev, debhelper (>= 9), pkg-config
Vcs-Browser: https://github.com/linuxcnc/mesaflash
Vcs-git: https://github.com/LinuxCNC/mesaflash.git -b master
Package: mesaflash
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: Mesa Electronics utility tool
Configuration and diagnostic tool for
Mesa Electronics PCI(E)/ETH/EPP/USB boards
Mesa Electronics PCI(E)/ETH/EPP/USB/SPI boards

35
debian/rules vendored
View file

@ -1,4 +1,5 @@
#!/usr/bin/make -f
include /usr/share/dpkg/pkg-info.mk
%:
dh $@
@ -6,34 +7,12 @@
override_dh_auto_install:
$(MAKE) DESTDIR=$$(pwd)/debian/mesaflash/usr install
PKD = $(abspath $(dir $(MAKEFILE_LIST)))
PKG = $(word 2,$(shell dpkg-parsechangelog -l$(PKD)/changelog | grep ^Source))
UVER = $(shell dpkg-parsechangelog -l$(PKD)/changelog | perl -ne 'print $$1 if m{^Version:\s+(?:\d+:)?(\d.*)(?:\-\d+.*)};')
DTYPE = +dfsg
VER ?= $(subst $(DTYPE),,$(UVER))
.PHONY: get-orig-source
get-orig-source: $(PKG)_$(VER)$(DTYPE).orig.tar.xz $(info I: $(PKG)_$(VER)$(DTYPE))
get-orig-source: $(DEB_SOURCE)_$(DEB_VERSION_UPSTREAM).orig.tar.xz
$(DEB_SOURCE)_$(DEB_VERSION_UPSTREAM).orig.tar.xz:
git archive HEAD | xz --compress > $@
$(PKG)_$(VER)$(DTYPE).orig.tar.xz:
@echo "# Downloading..."
uscan --noconf --verbose --rename --destdir=$(CURDIR) --check-dirname-level=0 --force-download --download-version $(VER) $(PKD)
$(if $(wildcard $(PKG)-$(VER)),$(error $(PKG)-$(VER) exist, aborting..))
@echo "# Extracting..."
mkdir $(PKG)-$(VER) \
&& tar -xf $(PKG)_$(VER).orig.tar.* --directory $(PKG)-$(VER) --strip-components 1 \
|| $(RM) -r $(PKG)-$(VER)
@echo "# Cleaning-up..."
cd $(PKG)-$(VER) \
&& $(RM) -r -v \
debian \
winio32 \
WinIo32.* \
libpci.dll \
libpci
#$(RM) -v $(PKG)_$(VER).orig.tar.*
@echo "# Packing..."
find -L "$(PKG)-$(VER)" -xdev -type f -print | LC_ALL=C sort \
| XZ_OPT="-6v" tar -caf "$(PKG)_$(VER)$(DTYPE).orig.tar.xz" -T- --owner=root --group=root --mode=a+rX \
&& $(RM) -r "$(PKG)-$(VER)"
override_dh_clean:
rm -rf winio32 WinIo32.* libpci.dll libpci
dh_clean

5
debian/watch vendored
View file

@ -1,3 +1,4 @@
version=3
opts=filenamemangle=s/.+\/v?(\d\S*)\.tar\.gz/mesaflash-$1\.tar\.gz/ \
https://github.com/micges/mesaflash/tags .*/v?(\d\S*)\.tar\.gz
opts=\
uversionmangle=s/-pre/~pre/,\
filenamemangle=s/.+\/v?(\d\S*)\.tar\.gz/mesaflash-$1\.tar\.gz/ https://github.com/LinuxCNC/mesaflash/tags .*/v?(\d\S*)\.tar\.gz

View file

@ -26,6 +26,7 @@
#include "eeprom_local.h"
#include "eeprom_remote.h"
#include "boards.h"
#include "bitfile.h"
u8 boot_block[BOOT_BLOCK_SIZE] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,

View file

@ -17,7 +17,9 @@
//
#ifdef __linux__
#if MESAFLASH_IO
#include <sys/io.h>
#endif
#include <pci/pci.h>
#elif _WIN32
#include <windows.h>
@ -209,6 +211,7 @@ static u8 recv_byte_gpio(llio_t *self) {
// spi access via io ports like on 3x20
#if MESAFLASH_IO
static void wait_for_data_io(llio_t *self) {
board_t *board = self->board;
u32 i = 0;
@ -310,6 +313,7 @@ static u8 recv_byte_epp(llio_t *self) {
epp_addr8(board, EPP_SPI_SREG_REG);
return epp_read8(board);
}
#endif
// pci flash
@ -435,12 +439,14 @@ void open_spi_access_local(llio_t *self) {
eeprom_access.recv_byte = &recv_byte_hm2;
break;
case BOARD_FLASH_IO:
#if MESAFLASH_IO
eeprom_access.set_cs_low = &set_cs_low_io;
eeprom_access.set_cs_high = &set_cs_high_io;
eeprom_access.prefix = &prefix_io;
eeprom_access.suffix = &suffix_io;
eeprom_access.send_byte = &send_byte_io;
eeprom_access.recv_byte = &recv_byte_io;
#endif
break;
case BOARD_FLASH_GPIO:
eeprom_access.set_cs_low = &set_cs_low_gpio;
@ -452,12 +458,14 @@ void open_spi_access_local(llio_t *self) {
init_gpio(self);
break;
case BOARD_FLASH_EPP:
#if MESAFLASH_IO
eeprom_access.set_cs_low = &set_cs_low_epp;
eeprom_access.set_cs_high = &set_cs_high_epp;
eeprom_access.prefix = &prefix_epp;
eeprom_access.suffix = &suffix_epp;
eeprom_access.send_byte = &send_byte_epp;
eeprom_access.recv_byte = &recv_byte_epp;
#endif
break;
case BOARD_FLASH_REMOTE:
break;

View file

@ -16,6 +16,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
#if MESAFLASH_IO
#ifdef __linux__
#include <linux/parport.h>
#include <sys/ioctl.h>
@ -519,3 +520,4 @@ void epp_print_info(board_t *board) {
show_board_info(board);
}
#endif

View file

@ -133,6 +133,8 @@ static int eth_board_close(board_t *board) {
return 0;
}
// Look for an Ethernet board.
// Returns 0 if it finds one, -1 if it doesn't find one.
static int eth_scan_one_addr(board_access_t *access) {
lbp16_cmd_addr packet, packet2;
int send = 0, recv = 0, ret = 0;
@ -144,7 +146,7 @@ static int eth_scan_one_addr(board_access_t *access) {
recv = lbp16_recv_packet(&cookie, sizeof(cookie));
if ((recv > 0) && (cookie == HM2_COOKIE)) {
char buff[20];
char buff[16];
board_t *board = &boards[boards_count];
board_init_struct(board);
@ -180,6 +182,7 @@ static int eth_scan_one_addr(board_access_t *access) {
board->flash = BOARD_FLASH_REMOTE;
board->fallback_support = 1;
board->llio.verbose = access->verbose;
boards_count ++;
} else if (strncmp(buff, "7I80DB-25", 9) == 0) {
board->type = BOARD_ETH;
strncpy(board->dev_addr, eth_socket_get_src_ip(), 16);
@ -198,13 +201,13 @@ static int eth_scan_one_addr(board_access_t *access) {
board->llio.verify_flash = &remote_verify_flash;
board->llio.reset = &lbp16_board_reset;
board->llio.reload = &lbp16_board_reload;
board->open = &eth_board_open;
board->close = &eth_board_close;
board->print_info = &eth_print_info;
board->flash = BOARD_FLASH_REMOTE;
board->fallback_support = 1;
board->llio.verbose = access->verbose;
boards_count ++;
} else if (strncmp(buff, "7I80HD-16", 9) == 0) {
board->type = BOARD_ETH;
strncpy(board->dev_addr, eth_socket_get_src_ip(), 16);
@ -222,13 +225,13 @@ static int eth_scan_one_addr(board_access_t *access) {
board->llio.verify_flash = &remote_verify_flash;
board->llio.reset = &lbp16_board_reset;
board->llio.reload = &lbp16_board_reload;
board->open = &eth_board_open;
board->close = &eth_board_close;
board->print_info = &eth_print_info;
board->flash = BOARD_FLASH_REMOTE;
board->fallback_support = 1;
board->llio.verbose = access->verbose;
boards_count ++;
} else if (strncmp(buff, "7I80HD-25", 9) == 0) {
board->type = BOARD_ETH;
strncpy(board->dev_addr, eth_socket_get_src_ip(), 16);
@ -246,13 +249,13 @@ static int eth_scan_one_addr(board_access_t *access) {
board->llio.verify_flash = &remote_verify_flash;
board->llio.reset = &lbp16_board_reset;
board->llio.reload = &lbp16_board_reload;
board->open = &eth_board_open;
board->close = &eth_board_close;
board->print_info = &eth_print_info;
board->flash = BOARD_FLASH_REMOTE;
board->fallback_support = 1;
board->llio.verbose = access->verbose;
boards_count ++;
} else if (strncmp(buff, "7I76E-16", 9) == 0) {
board->type = BOARD_ETH;
strncpy(board->dev_addr, eth_socket_get_src_ip(), 16);
@ -262,6 +265,7 @@ static int eth_scan_one_addr(board_access_t *access) {
board->llio.ioport_connector_name[0] = "on-card";
board->llio.ioport_connector_name[1] = "P1";
board->llio.ioport_connector_name[2] = "P2";
board->llio.bob_hint[0] = BOB_7I76;
board->llio.fpga_part_number = "6slx16ftg256";
board->llio.num_leds = 4;
board->llio.read = &eth_read;
@ -270,13 +274,13 @@ static int eth_scan_one_addr(board_access_t *access) {
board->llio.verify_flash = &remote_verify_flash;
board->llio.reset = &lbp16_board_reset;
board->llio.reload = &lbp16_board_reload;
board->open = &eth_board_open;
board->close = &eth_board_close;
board->print_info = &eth_print_info;
board->flash = BOARD_FLASH_REMOTE;
board->fallback_support = 1;
board->llio.verbose = access->verbose;
boards_count ++;
} else if (strncmp(buff, "7I92", 4) == 0) {
board->type = BOARD_ETH;
strncpy(board->dev_addr, eth_socket_get_src_ip(), 16);
@ -293,13 +297,13 @@ static int eth_scan_one_addr(board_access_t *access) {
board->llio.verify_flash = &remote_verify_flash;
board->llio.reset = &lbp16_board_reset;
board->llio.reload = &lbp16_board_reload;
board->open = &eth_board_open;
board->close = &eth_board_close;
board->print_info = &eth_print_info;
board->flash = BOARD_FLASH_REMOTE;
board->fallback_support = 1;
board->llio.verbose = access->verbose;
boards_count ++;
} else if (strncmp(buff, "7I93", 4) == 0) {
board->type = BOARD_ETH;
strncpy(board->dev_addr, eth_socket_get_src_ip(), 16);
@ -316,23 +320,23 @@ static int eth_scan_one_addr(board_access_t *access) {
board->llio.verify_flash = &remote_verify_flash;
board->llio.reset = &lbp16_board_reset;
board->llio.reload = &lbp16_board_reload;
board->open = &eth_board_open;
board->close = &eth_board_close;
board->print_info = &eth_print_info;
board->flash = BOARD_FLASH_REMOTE;
board->fallback_support = 1;
board->llio.verbose = access->verbose;
} else if (strncmp(buff, "7I96", 4) == 0) {
boards_count ++;
} else if (strncmp(buff, "7I94", 4) == 0) {
board->type = BOARD_ETH;
strncpy(board->dev_addr, eth_socket_get_src_ip(), 16);
strncpy(board->llio.board_name, buff, 16);
board->llio.num_ioport_connectors = 3;
board->llio.pins_per_connector = 13;
board->llio.ioport_connector_name[0] = "P1";
board->llio.ioport_connector_name[1] = "TB1";
board->llio.ioport_connector_name[2] = "TB2";
board->llio.ioport_connector_name[3] = "TB3";
board->llio.num_ioport_connectors = 2;
board->llio.pins_per_connector = 21;
board->llio.ioport_connector_name[0] = "Expansion+Serial 0..1";
board->llio.ioport_connector_name[1] = "Serial 1..7";
board->llio.bob_hint[0] = BOB_7I94_0;
board->llio.bob_hint[1] = BOB_7I94_1;
board->llio.fpga_part_number = "6slx9tqg144";
board->llio.num_leds = 4;
board->llio.read = &eth_read;
@ -341,20 +345,124 @@ static int eth_scan_one_addr(board_access_t *access) {
board->llio.verify_flash = &remote_verify_flash;
board->llio.reset = &lbp16_board_reset;
board->llio.reload = &lbp16_board_reload;
board->open = &eth_board_open;
board->close = &eth_board_close;
board->print_info = &eth_print_info;
board->flash = BOARD_FLASH_REMOTE;
board->fallback_support = 1;
board->llio.verbose = access->verbose;
boards_count ++;
} else if (strncmp(buff, "7I95", 4) == 0) {
board->type = BOARD_ETH;
strncpy(board->dev_addr, eth_socket_get_src_ip(), 16);
strncpy(board->llio.board_name, buff, 16);
board->llio.num_ioport_connectors = 2;
board->llio.pins_per_connector = 29;
board->llio.ioport_connector_name[0] = "Step/DIR+Serial+Encoders";
board->llio.ioport_connector_name[1] = "I/O+Expansion";
board->llio.bob_hint[0] = BOB_7I95_0;
board->llio.bob_hint[1] = BOB_7I95_1;
board->llio.fpga_part_number = "6slx9tqg144";
board->llio.num_leds = 4;
board->llio.read = &eth_read;
board->llio.write = &eth_write;
board->llio.write_flash = &remote_write_flash;
board->llio.verify_flash = &remote_verify_flash;
board->llio.reset = &lbp16_board_reset;
board->llio.reload = &lbp16_board_reload;
board->open = &eth_board_open;
board->close = &eth_board_close;
board->print_info = &eth_print_info;
board->flash = BOARD_FLASH_REMOTE;
board->fallback_support = 1;
board->llio.verbose = access->verbose;
boards_count ++;
} else if (strncmp(buff, "7I96", 4) == 0) {
board->type = BOARD_ETH;
strncpy(board->dev_addr, eth_socket_get_src_ip(), 16);
strncpy(board->llio.board_name, buff, 16);
board->llio.num_ioport_connectors = 3;
board->llio.pins_per_connector = 17;
board->llio.ioport_connector_name[0] = "TB3";
board->llio.ioport_connector_name[1] = "TB1/TB2";
board->llio.ioport_connector_name[2] = "P1";
board->llio.bob_hint[0] = BOB_7I96_0;
board->llio.bob_hint[1] = BOB_7I96_1;
board->llio.bob_hint[2] = BOB_7I96_2;
board->llio.fpga_part_number = "6slx9tqg144";
board->llio.num_leds = 4;
board->llio.read = &eth_read;
board->llio.write = &eth_write;
board->llio.write_flash = &remote_write_flash;
board->llio.verify_flash = &remote_verify_flash;
board->llio.reset = &lbp16_board_reset;
board->llio.reload = &lbp16_board_reload;
board->open = &eth_board_open;
board->close = &eth_board_close;
board->print_info = &eth_print_info;
board->flash = BOARD_FLASH_REMOTE;
board->fallback_support = 1;
board->llio.verbose = access->verbose;
boards_count ++;
} else if (strncmp(buff, "7I97", 4) == 0) {
board->type = BOARD_ETH;
strncpy(board->dev_addr, eth_socket_get_src_ip(), 16);
strncpy(board->llio.board_name, buff, 16);
board->llio.num_ioport_connectors = 3;
board->llio.pins_per_connector = 17;
board->llio.ioport_connector_name[0] = "TB1/TB2/TB3";
board->llio.ioport_connector_name[1] = "TB4/TB5";
board->llio.ioport_connector_name[2] = "P1";
board->llio.bob_hint[0] = BOB_7I97_0;
board->llio.bob_hint[1] = BOB_7I97_1;
board->llio.bob_hint[2] = BOB_7I97_2;
board->llio.fpga_part_number = "6slx9tqg144";
board->llio.num_leds = 4;
board->llio.read = &eth_read;
board->llio.write = &eth_write;
board->llio.write_flash = &remote_write_flash;
board->llio.verify_flash = &remote_verify_flash;
board->llio.reset = &lbp16_board_reset;
board->llio.reload = &lbp16_board_reload;
board->open = &eth_board_open;
board->close = &eth_board_close;
board->print_info = &eth_print_info;
board->flash = BOARD_FLASH_REMOTE;
board->fallback_support = 1;
board->llio.verbose = access->verbose;
boards_count ++;
} else if (strncmp(buff, "7I98", 4) == 0) {
board->type = BOARD_ETH;
strncpy(board->dev_addr, eth_socket_get_src_ip(), 16);
strncpy(board->llio.board_name, buff, 16);
board->llio.num_ioport_connectors = 3;
board->llio.pins_per_connector = 17;
board->llio.ioport_connector_name[0] = "P1";
board->llio.ioport_connector_name[1] = "P2";
board->llio.ioport_connector_name[2] = "P3";
board->llio.fpga_part_number = "6slx9tqg144";
board->llio.num_leds = 4;
board->llio.read = &eth_read;
board->llio.write = &eth_write;
board->llio.write_flash = &remote_write_flash;
board->llio.verify_flash = &remote_verify_flash;
board->llio.reset = &lbp16_board_reset;
board->llio.reload = &lbp16_board_reload;
board->open = &eth_board_open;
board->close = &eth_board_close;
board->print_info = &eth_print_info;
board->flash = BOARD_FLASH_REMOTE;
board->fallback_support = 1;
board->llio.verbose = access->verbose;
boards_count ++;
} else {
printf("Unsupported ethernet device %s at %s\n", buff, eth_socket_get_src_ip());
ret = -1;
}
boards_count++;
eth_socket_nonblocking();
} else {
ret = -1;
}
return ret;
}
@ -403,10 +511,13 @@ void eth_boards_cleanup(board_access_t *access) {
close(sd);
}
void eth_boards_scan(board_access_t *access) {
// Scan for Ethernet board(s).
// Returns 0 if it found one, -1 on failure.
int eth_boards_scan(board_access_t *access) {
char addr[16];
int i;
char *ptr;
int r = 0;
if (access->address == 0) {
access->dev_addr = LBP16_HW_IP;
@ -419,28 +530,37 @@ void eth_boards_scan(board_access_t *access) {
int size;
if (WSAStringToAddress(access->dev_addr, AF_INET, NULL, (struct sockaddr *)&ss, &size) != 0) {
#endif
return;
return -1;
};
eth_socket_nonblocking();
if (access->address == 1) {
eth_socket_set_dest_ip(access->dev_addr);
eth_scan_one_addr(access);
r = eth_scan_one_addr(access);
} else {
strncpy(addr, access->dev_addr, 16);
ptr = strrchr(addr, '.');
*ptr = '\0';
// We're scanning for boards, return Success (0) if we find at
// least one, return Fail (-1) if we don't find any.
r = -1;
for (i = 1; i < 255; i++) {
char addr_name[32];
int this_r;
sprintf(addr_name, "%s.%d", addr, i);
eth_socket_set_dest_ip(addr_name);
eth_scan_one_addr(access);
this_r = eth_scan_one_addr(access);
if (this_r == 0) {
r = 0;
}
}
}
eth_socket_blocking();
return r;
}
void eth_print_info(board_t *board) {
@ -549,7 +669,7 @@ void eth_print_info(board_t *board) {
printf(" [space 6] LBP16 control/status:\n");
printf(" packets received: all %d, UDP %d, bad %d\n", stat_area.RXPacketCount, stat_area.RXGoodCount, stat_area.RXBadCount);
printf(" packets sended: all %d, UDP %d, bad %d\n", stat_area.TXPacketCount, stat_area.TXGoodCount, stat_area.TXBadCount);
printf(" packets sent: all %d, UDP %d, bad %d\n", stat_area.TXPacketCount, stat_area.TXGoodCount, stat_area.TXBadCount);
printf(" parse errors: %d, mem errors %d, write errors %d\n", stat_area.LBPParseErrors, stat_area.LBPMemErrors, stat_area.LBPWriteErrors);
printf(" error flags: 0x%04X\n", stat_area.ErrorReg);
printf(" debug LED ptr: 0x%04X\n", stat_area.DebugLEDPtr);

View file

@ -23,7 +23,7 @@
int eth_boards_init(board_access_t *access);
void eth_boards_cleanup(board_access_t *access);
void eth_boards_scan(board_access_t *access);
int eth_boards_scan(board_access_t *access);
void eth_print_info(board_t *board);
int eth_send_packet(void *packet, int size);
int eth_recv_packet(void *buffer, int size);

View file

@ -22,23 +22,23 @@
#include <ctype.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include "../anyio.h"
#include "../sserial_module.h"
#ifdef __linux__
#include <pci/pci.h>
#include <unistd.h>
#elif _WIN32
#include "libpci/pci.h"
#endif
extern int usleep(useconds_t usec); // static global access variable conflicts with POSIX function in unistd.h
static int device_flag;
static int instance_flag;
static int instance = 0;
static int delay_flag;
static int delay = 50;
static int verbose_flag;
static board_access_t access;
static board_access_t board_access;
static struct option long_options[] = {
{"device", required_argument, 0, 'd'},
@ -87,9 +87,9 @@ int process_cmd_line(int argc, char *argv[]) {
printf("Error: multiply --device option\n");
exit(-1);
}
access.device_name = optarg;
board_access.device_name = optarg;
for (i = 0; optarg[i] != '\0'; i++)
access.device_name[i] = toupper(access.device_name[i]);
board_access.device_name[i] = toupper(board_access.device_name[i]);
device_flag++;
}
@ -143,18 +143,18 @@ int main(int argc, char *argv[]) {
return -1;
}
access.verbose = verbose_flag;
board_access.verbose = verbose_flag;
if (anyio_init(&access) != 0) { // init library
if (anyio_init(&board_access) != 0) { // init library
return -1;
}
ret = anyio_find_dev(&access); // find board
ret = anyio_find_dev(&board_access); // find board
if (ret < 0) {
return -1;
}
board = anyio_get_dev(&access, 1); // if found the get board handle
board = anyio_get_dev(&board_access, 1); // if found the get board handle
if (board == NULL) {
printf("No %s board found\n", access.device_name);
printf("No %s board found\n", board_access.device_name);
return -1;
}
@ -184,7 +184,7 @@ int main(int argc, char *argv[]) {
board->close(board); // close board communication
anyio_cleanup(&access); // close library
anyio_cleanup(&board_access); // close library
return 0;
}

View file

@ -22,23 +22,23 @@
#include <ctype.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include "../anyio.h"
#include "../encoder_module.h"
#ifdef __linux__
#include <pci/pci.h>
#include <unistd.h>
#elif _WIN32
#include "libpci/pci.h"
#endif
extern int usleep(useconds_t usec); // static global access variable conflicts with POSIX function in unistd.h
static int device_flag;
static int instance_flag;
static int instance = 0;
static int delay_flag;
static int delay = 50;
static int verbose_flag;
static board_access_t access;
static board_access_t board_access;
static struct option long_options[] = {
{"device", required_argument, 0, 'd'},
@ -87,9 +87,9 @@ int process_cmd_line(int argc, char *argv[]) {
printf("Error: multiply --device option\n");
exit(-1);
}
access.device_name = optarg;
board_access.device_name = optarg;
for (i = 0; optarg[i] != '\0'; i++)
access.device_name[i] = toupper(access.device_name[i]);
board_access.device_name[i] = toupper(board_access.device_name[i]);
device_flag++;
}
@ -141,18 +141,18 @@ int main(int argc, char *argv[]) {
return -1;
}
access.verbose = verbose_flag;
board_access.verbose = verbose_flag;
if (anyio_init(&access) != 0) { // init library
if (anyio_init(&board_access) != 0) { // init library
return -1;
}
ret = anyio_find_dev(&access); // find board
ret = anyio_find_dev(&board_access); // find board
if (ret < 0) {
return -1;
}
board = anyio_get_dev(&access, 1); // if found the get board handle
board = anyio_get_dev(&board_access, 1); // if found the get board handle
if (board == NULL) {
printf("No %s board found\n", access.device_name);
printf("No %s board found\n", board_access.device_name);
return -1;
}
@ -176,7 +176,7 @@ int main(int argc, char *argv[]) {
fail0:
board->close(board); // close board communication
anyio_cleanup(&access); // close library
anyio_cleanup(&board_access); // close library
return 0;
}

View file

@ -1,5 +1,6 @@
//
// Copyright (C) 2013-2014 Michael Geszkiewicz
// Copyright (C) 2018 Sebastian Kuzminsky
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@ -16,10 +17,12 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
#include <stdio.h>
#include <string.h>
#include "hostmot2.h"
void hm2_read_idrom(hostmot2_t *hm2) {
u32 idrom_addr, cookie;
int i;
@ -29,7 +32,7 @@ void hm2_read_idrom(hostmot2_t *hm2) {
printf("ERROR: no HOSTMOT2 firmware found. %X\n", cookie);
return;
}
// check if it was already readed
// check if it was already read
if (strncmp(hm2->config_name, "HOSTMOT2", 8) == 0)
return;
@ -46,214 +49,6 @@ void hm2_read_idrom(hostmot2_t *hm2) {
}
}
const char *hm2_hz_to_mhz(u32 freq_hz) {
static char mhz_str[20];
int r;
int freq_mhz, freq_mhz_fractional;
freq_mhz = freq_hz / (1000*1000);
freq_mhz_fractional = (freq_hz / 1000) % 1000;
r = snprintf(mhz_str, sizeof(mhz_str), "%d.%03d", freq_mhz, freq_mhz_fractional);
if (r >= sizeof(mhz_str)) {
printf("too many MHz!\n");
return "(unpresentable)";
}
return mhz_str;
}
const char *hm2_get_general_function_name(int gtag) {
switch (gtag) {
case HM2_GTAG_IRQ_LOGIC: return "IRQ logic";
case HM2_GTAG_WATCHDOG: return "Watchdog";
case HM2_GTAG_IOPORT: return "IOPort";
case HM2_GTAG_ENCODER: return "Encoder";
case HM2_GTAG_STEPGEN: return "StepGen";
case HM2_GTAG_PWMGEN: return "PWMGen";
case HM2_GTAG_SPI: return "SPI";
case HM2_GTAG_SSI: return "SSI";
case HM2_GTAG_UART_TX: return "UART Transmit Channel";
case HM2_GTAG_UART_RX: return "UART Receive Channel";
case HM2_GTAG_TRAM: return "TrnslationRAM";
case HM2_GTAG_MUXED_ENCODER: return "Muxed Encoder";
case HM2_GTAG_MUXED_ENCODER_SEL: return "Muxed Encoder Select";
case HM2_GTAG_BSPI: return "Buffered SPI Interface";
case HM2_GTAG_DBSPI: return "DBSPI";
case HM2_GTAG_DPLL: return "DPLL";
case HM2_GTAG_MUXED_ENCODER_MIM: return "Muxed Encoder MIM";
case HM2_GTAG_MUXED_ENCODER_SEL_MIM: return "Muxed Encoder Select MIM";
case HM2_GTAG_TPPWM: return "ThreePhasePWM";
case HM2_GTAG_WAVEGEN: return "WaveGen";
case HM2_GTAG_DAQ_FIFO: return "DAQ FIFO";
case HM2_GTAG_BIN_OSC: return "BIN OSC";
case HM2_GTAG_BIN_DMDMA: return "BIN DMDMA";
case HM2_GTAG_BISS: return "BISS";
case HM2_GTAG_FABS: return "FABS";
case HM2_GTAG_HM2DPLL: return "HM2DPLL";
case HM2_GTAG_LIOPORT: return "LIOPORT";
case HM2_GTAG_LED: return "LED";
case HM2_GTAG_RESOLVER: return "Resolver";
case HM2_GTAG_SSERIAL: return "Smart Serial Interface";
case HM2_GTAG_TWIDDLER: return "TWIDDLER";
case HM2_GTAG_XFORMER: return "Transformer";
default: {
static char unknown[100];
snprintf(unknown, 100, "(unknown-gtag-%d)", gtag);
printf("Firmware contains unknown function (gtag-%d)/n", gtag);
return unknown;
}
}
}
static const char* hm2_get_pin_secondary_name(hm2_pin_desc_t *pin) {
static char unknown[100];
int sec_pin = pin->sec_pin & 0x7F; // turn off the "pin is an output" bit
switch (pin->sec_tag) {
case HM2_GTAG_MUXED_ENCODER:
switch (sec_pin) {
case 1: return "Muxed A";
case 2: return "Muxed B";
case 3: return "Muxed Index";
case 4: return "Muxed IndexMask";
}
break;
case HM2_GTAG_MUXED_ENCODER_SEL:
switch (sec_pin) {
case 1: return "Mux Select 0";
case 2: return "Mux Select 1";
}
break;
case HM2_GTAG_ENCODER:
switch (sec_pin) {
case 1: return "A";
case 2: return "B";
case 3: return "Index";
case 4: return "IndexMask";
case 5: return "Probe";
}
break;
case HM2_GTAG_RESOLVER:
switch (sec_pin) {
case 1: return "NC";
case 2: return "REFPDM+";
case 3: return "REFPDM-";
case 4: return "AMUX0";
case 5: return "AMUX1";
case 6: return "AMUX2";
case 7: return "SPICS";
case 8: return "SPICLK";
case 9: return "SPIDO0";
case 10: return "SPIDO1";
}
break;
case HM2_GTAG_PWMGEN:
// FIXME: these depend on the pwmgen mode
switch (sec_pin) {
case 1: return "Out0 (PWM or Up)";
case 2: return "Out1 (Dir or Down)";
case 3: return "Not-Enable";
}
break;
case HM2_GTAG_TPPWM:
switch (sec_pin) {
case 1: return "PWM A";
case 2: return "PWM B";
case 3: return "PWM C";
case 4: return "PWM /A";
case 5: return "PWM /B";
case 6: return "PWM /C";
case 7: return "Enable";
case 8: return "Fault";
}
break;
case HM2_GTAG_STEPGEN:
// FIXME: these depend on the stepgen mode
switch (sec_pin) {
case 1: return "Step";
case 2: return "Direction";
case 3: return "(unused)";
case 4: return "(unused)";
case 5: return "(unused)";
case 6: return "(unused)";
}
break;
case HM2_GTAG_SSERIAL:
if (pin->sec_pin & 0x80){ // Output pin codes
switch (sec_pin) {
case 0x1: return "TxData0";
case 0x2: return "TxData1";
case 0x3: return "TxData2";
case 0x4: return "TxData3";
case 0x5: return "TxData4";
case 0x6: return "TxData5";
case 0x7: return "TxData6";
case 0x8: return "TxData7";
case 0x11: return "TxEn0 ";
case 0x12: return "TxEn1 ";
case 0x13: return "TxEn2 ";
case 0x14: return "TxEn3 ";
case 0x15: return "TxEn4 ";
case 0x16: return "TxEn5 ";
case 0x17: return "TxEn6 ";
case 0x18: return "TxEn7 ";
}
break;
}else{ // INput Pin Codes
switch (sec_pin) {
case 0x1: return "RxData0";
case 0x2: return "RxData1";
case 0x3: return "RxData2";
case 0x4: return "RxData3";
case 0x5: return "RxData4";
case 0x6: return "RxData5";
case 0x7: return "RxData6";
case 0x8: return "RxData7";
}
break;
}
case HM2_GTAG_BSPI:
switch (sec_pin) {
case 0x1: return "/Frame";
case 0x2: return "Serial Out";
case 0x3: return "Clock";
case 0x4: return "Serial In";
case 0x5: return "CS0";
case 0x6: return "CS1";
case 0x7: return "CS2";
case 0x8: return "CS3";
case 0x9: return "CS4";
case 0xA: return "CS5";
case 0xB: return "CS6";
case 0xC: return "CS7";
}
break;
case HM2_GTAG_UART_RX:
switch (sec_pin) {
case 0x1: return "RX Data";
}
break;
case HM2_GTAG_UART_TX:
switch (sec_pin) {
case 0x1: return "TX Data";
case 0x2: return "Drv Enable";
}
break;
}
snprintf(unknown, sizeof(unknown), "unknown-pin-%d", sec_pin & 0x7F);
return unknown;
}
hm2_module_desc_t *hm2_find_module(hostmot2_t *hm2, u8 gtag) {
int i;
@ -318,100 +113,79 @@ void hm2_set_pin_direction(hostmot2_t *hm2, int pin_number, u8 direction) {
hm2->llio->write(hm2->llio, addr + HM2_MOD_OFFS_GPIO_DDR + (pin_number / 24)*4, &data, sizeof(data));
}
void hm2_print_idrom(hostmot2_t *hm2) {
printf("IDRom:\n");
printf(" IDRom Type: 0x%02X\n", hm2->idrom.idrom_type);
printf(" Offset to Modules: 0x%08X\n", hm2->idrom.offset_to_modules);
printf(" Offset to Pin Description: 0x%08X\n", hm2->idrom.offset_to_pins);
printf(" Board Name: %.*s\n", (int)sizeof(hm2->config_name), hm2->idrom.board_name);
printf(" FPGA Size: %u\n", hm2->idrom.fpga_size);
printf(" FPGA Pins: %u\n", hm2->idrom.fpga_pins);
printf(" Port Width: %u\n", hm2->idrom.port_width);
printf(" IO Ports: %u\n", hm2->idrom.io_ports);
printf(" IO Width: %u\n", hm2->idrom.io_width);
printf(" Clock Low: %d Hz (%d KHz, %d MHz)\n", hm2->idrom.clock_low, (hm2->idrom.clock_low / 1000), (hm2->idrom.clock_low / (1000 * 1000)));
printf(" Clock High: %d Hz (%d KHz, %d MHz)\n", hm2->idrom.clock_high, (hm2->idrom.clock_high / 1000), (hm2->idrom.clock_high / (1000 * 1000)));
printf(" Instance Stride 0: 0x%08X\n", hm2->idrom.instance_stride0);
printf(" Instance Stride 1: 0x%08X\n", hm2->idrom.instance_stride1);
printf(" Register Stride 0: 0x%08X\n", hm2->idrom.register_stride0);
printf(" Register Stride 1: 0x%08X\n", hm2->idrom.register_stride1);
}
void hm2_print_modules(hostmot2_t *hm2) {
int i;
for (i = 0; i < HM2_MAX_MODULES; i++) {
hm2_module_desc_t *mod = &hm2->modules[i];
u32 addr = HM2_IDROM_ADDR + hm2->idrom.offset_to_modules + i*sizeof(hm2_module_desc_t);
u32 clock_freq;
if (mod->gtag == HM2_GTAG_NONE) break;
printf("Module Descriptor %d at 0x%04X:\n", i, addr);
printf(" General Function Tag: %d (%s)\n", mod->gtag, hm2_get_general_function_name(mod->gtag));
printf(" Version: %d\n", mod->version);
if (mod->clock_tag == HM2_CLOCK_LOW_TAG) {
clock_freq = hm2->idrom.clock_low;
} else if (mod->clock_tag == HM2_CLOCK_HIGH_TAG) {
clock_freq = hm2->idrom.clock_high;
} else {
printf("Module Descriptor %d (at 0x%04x) has invalid ClockTag %d\n", i, addr, mod->clock_tag);
return;
}
printf(" Clock Tag: %d (%s MHz)\n", mod->clock_tag, hm2_hz_to_mhz(clock_freq));
printf(" Instances: %d\n", mod->instances);
printf(" Base Address: 0x%04X\n", mod->base_address);
printf(" -- Num Registers: %d\n", mod->registers);
if ((mod->strides & 0x0000000F) == 0) {
printf(" Register Stride: 0x%08X\n", hm2->idrom.register_stride0);
} else if ((mod->strides & 0x0000000F) == 1) {
printf(" Register Stride: 0x%08X\n", hm2->idrom.register_stride1);
} else {
printf("Module Descriptor %d (at 0x%04x) has invalid RegisterStride %d\n", i, addr, mod->strides);
return;
}
if (((mod->strides >> 4) & 0x0000000F) == 0) {
printf(" -- Instance Stride: 0x%08X\n", hm2->idrom.instance_stride0);
} else if (((mod->strides >> 4) & 0x0000000F) == 1) {
printf(" -- Instance Stride: 0x%08X\n", hm2->idrom.instance_stride1);
} else {
printf("Module Descriptor %d (at 0x%04x) has invalid InstanceStride %d\n", i, addr, mod->strides);
return;
}
printf(" -- Multiple Registers: 0x%08X\n", mod->mp_bitmap);
}
}
void hm2_print_pins(hostmot2_t *hm2) {
int i;
for (i = 0; i < HM2_MAX_PINS; i++) {
hm2_pin_desc_t *pin = &hm2->pins[i];
if (pin->gtag == 0) break;
printf("pin %d:\n", i);
printf(" Primary Tag: 0x%02X (%s)\n", pin->gtag, hm2_get_general_function_name(pin->gtag));
if (pin->sec_tag != 0) {
printf(" Secondary Tag: 0x%02X (%s)\n", pin->sec_tag, hm2_get_general_function_name(pin->sec_tag));
printf(" Secondary Unit: 0x%02X\n", pin->sec_chan);
printf(" Secondary Pin: 0x%02X (%s, %s)\n", pin->sec_pin, hm2_get_pin_secondary_name(pin), ((pin->sec_pin & 0x80) ? "Output" : "Input"));
}
}
}
// PIN FILE GENERATING SUPPORT
static bob_pin_name_t bob_pin_names[MAX_BOB_NAMES] = {
{BOB_7I76, {"TB2-4,5","TB2-2,3","TB2-10,11","TB2-8,9","TB2-16,17","TB2-14,15","TB2-22,23","TB2-20,21",
"TB3-4,5","TB3-2,3","Internal","Internal","TB3-18,19","TB3-16,17","TB3-13,14","TB3-10,11","TB3-7,8"}},
{BOB_7I77, {"Internal","TB6-5,6","TB6-3,4","Internal","Internal","Internal","Internal","Internal","TB3-1,2,9,10","TB3-4,5,12,13",
"TB3-7,8,15,16","TB3-17,18 TB4-1,2","TB3-20,21,TB4-4,5","TB3-23,24,TB4-7,8","TB4-9,10,17,18","TB4-12,13,20,21","TB4-15,16,23,24"}},
{BOB_7I94_0, {"P1-01/DB25-01","P1-02/DB25-14","P1-03/DB25-02","P1-04/DB25-15",
"P1-05/DB25-03","P1-06/DB25-16","P1-07/DB25-04","P1-08/DB25-17","P1-09/DB25-05","P1-11/DB25-06","P1-13/DB25-07",
"P1-15/DB25-08","P1-17/DB25-09","P1-19/DB25-10","P1-21/DB25-11","P1-23/DB25-12","P1-25/DB25-13","J6 1,2","J6 3,6","J6 TXEN","J7 1,2"}},
{BOB_7I94_1, {"J7-3,6","J7-TXEN","J8-1,2","J8-3,6","J8-TXEN","J9-1,2","J9-3,6","J9-TXEN","J4-1,2","J4-3,6",
"J4-TXEN","J3-1,2","J3-3,6","J3-TXEN","J2-1,2","J2-3,6","J2-TXEN","J1-1,2","J1-3,6","J1-TXEN","P2-/ENA"}},
{BOB_7I95_0, {"TB3-2,3","TB3-4,5","TB3-8,9","TB3-10,11","TB3-14,15","TB3-16,17","TB3-20,21","TB3-22,23",
"TB4-2,3","TB4-4,5","TB4-8,9","TB4-10,11","TB2-14,15","TB4-16,17","Internal","TB4-20,21","TB4-22,23","Internal",
"TB1-1,2,9,10","TB1-4,5,12,13","TB1-7,8,15,16","TB1-17,18 TB2-1,2","TB1-20,21 TB2-4,5","TB1-23,24,TB2-7,8",
"TB2-9,10,17,18","TB2-11,12,20,21","TB2-15,16,23,24","Internal","Internal"}},
{BOB_7I95_1, {"Internal","Internal","Internal","Internal","Internal","TB3 13,14","TB3 15,16","TB3 17,18",
"TB3-19,20","TB3-21,22","TB3-23,24","Internal","P1-01/DB25-01","P1-02/DB25-14","P1-03/DB25-02","P1-04/DB25-15",
"P1-05/DB25-03","P1-06/DB25-16","P1-07/DB25-04","P1-08/DB25-17","P1-09/DB25-05","P1-11/DB25-06","P1-13/DB25-07",
"P1-15/DB25-08","P1-17/DB25-09","P1-19/DB25-10","P1-21/DB25-11","P1-23/DB25-12","P1-25/DB25-13"}},
{BOB_7I96_0, {"TB3-1","TB3-2","TB3-3","TB3-4","TB3-5","TB3-6","TB3-7","TB3-8","TB3-9","TB3-10","TB3-11",
"TB3-13,14","TB3-15,16","TB3-17,18","TB3-19,20","TB3-21,22","TB3-23,24"}},
{BOB_7I96_1, {"TB1-2,3","TB1-4,5","TB1-8,9","TB1-10,11","TB1-14,15","TB1-16,17","TB1-20,21","TB1-22,23",
"TB2-2,3","TB2-4,5","TB2-7,8","TB2-10,11","TB2-13,14","TB2-16,17","TB2-18,19","Internal","Internal"}},
{BOB_7I96_2, {"P1-01/DB25-01","P1-02/DB25-14","P1-03/DB25-02","P1-04/DB25-15",
"P1-05/DB25-03","P1-06/DB25-16","P1-07/DB25-04","P1-08/DB25-17","P1-09/DB25-05","P1-11/DB25-06","P1-13/DB25-07",
"P1-15/DB25-08","P1-17/DB25-09","P1-19/DB25-10","P1-21/DB25-11","P1-23/DB25-12","P1-25/DB25-13"}},
{BOB_7I97_0, {"TB3-4","TB3-8","TB3-12","TB3-16","TB3-20","TB3-20","TB3-24","TB3-24","TB3-4,8,12,16",
"TB1-1,2,9,10","TB1-4,5,12,13","TB1-7,8,15,16","TB1-17,18,TB2 1,2","TB1-20,21,TB2-4,5","TB1-23,24,TB2-7,8",
"TB2-9,10,17,18","TB2-12,13,20,21"}},
{BOB_7I97_1, {"TB2-15,16,23,24","Internal","TB5-13,14","TB5-15,16","TB5-17,18","TB5-19,20","TB5-21,22",
"TB5-23,24","Internal","Internal","Internal","Internal","Internal","Internal","TB4-15,16","TB4-17,18","Internal"}},
{BOB_7I97_2, {"P1-01/DB25-01","P1-02/DB25-14","P1-03/DB25-02","P1-04/DB25-15",
"P1-05/DB25-03","P1-06/DB25-16","P1-07/DB25-04","P1-08/DB25-17","P1-09/DB25-05","P1-11/DB25-06","P1-13/DB25-07",
"P1-15/DB25-08","P1-17/DB25-09","P1-19/DB25-10","P1-21/DB25-11","P1-23/DB25-12","P1-25/DB25-13"}},
{BOB_7C80_0, {"TB7-2,3","TB7-4,5","TB8-2,3","TB8-4,5","TB9-2,3","TB9-4,5","TB10-2,3","TB10-4,5","TB11-2,3","TB11-4,5",
"TB12-2,3","TB13-4,5","TB3-3,4","TB3-5,6","Internal","TB4-1,2","TB4-4,5","TB4-7,8","TB5-2","TB5-2","TB5-5,6","TB5-7,8"
"Internal","Internal","Internal","Internal","Internal"}},
{BOB_7C80_1, {"Internal","TB13-1,2","TB13-3,4","TB13-5,6","TB13-7,8","TB14-1,2","TB14-3,4","TB14-5,6","TB14-7,8",
"Internal", "P1-01/DB25-01","P1-02/DB25-14","P1-03/DB25-02","P1-04/DB25-15",
"P1-05/DB25-03","P1-06/DB25-16","P1-07/DB25-04","P1-08/DB25-17","P1-09/DB25-05","P1-11/DB25-06","P1-13/DB25-07",
"P1-15/DB25-08","P1-17/DB25-09","P1-19/DB25-10","P1-21/DB25-11","P1-23/DB25-12","P1-25/DB25-13"}},
{BOB_7C81_0, {"P1-01/DB25-01","P1-02/DB25-14","P1-03/DB25-02","P1-04/DB25-15",
"P1-05/DB25-03","P1-06/DB25-16","P1-07/DB25-04","P1-08/DB25-17","P1-09/DB25-05","P1-11/DB25-06","P1-13/DB25-07",
"P1-15/DB25-08","P1-17/DB25-09","P1-19/DB25-10","P1-21/DB25-11","P1-23/DB25-12","P1-25/DB25-13","P5 3,6","P6 3,6"}},
{BOB_7C81_1, {"P2-01/DB25-01","P2-02/DB25-14","P2-03/DB25-02","P2-04/DB25-15",
"P2-05/DB25-03","P2-06/DB25-16","P2-07/DB25-04","P2-08/DB25-17","P2-09/DB25-05","P2-11/DB25-06","P2-13/DB25-07",
"P2-15/DB25-08","P2-17/DB25-09","P2-19/DB25-10","P2-21/DB25-11","P2-23/DB25-12","P2-25/DB25-13","P5 TXEN","P6 TXEN"}},
{BOB_7C81_2, {"P7-01/DB25-01","P7-02/DB25-14","P7-03/DB25-02","P7-04/DB25-15",
"P7-05/DB25-03","P7-06/DB25-16","P7-07/DB25-04","P7-08/DB25-17","P7-09/DB25-05","P7-11/DB25-06","P7-13/DB25-07",
"P7-15/DB25-08","P7-17/DB25-09","P7-19/DB25-10","P7-21/DB25-11","P7-23/DB25-12","P7-25/DB25-13","P5 1,2","P6 1,2"}}
};
static pin_name_t pin_names[HM2_MAX_TAGS] = {
{HM2_GTAG_NONE, {"Null1", "Null2", "Null3", "Null4", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_IRQ_LOGIC, {"Null1", "Null2", "Null3", "Null4", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_WATCHDOG, {"Null1", "Null2", "Null3", "Null4", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_IOPORT, {"Null1", "Null2", "Null3", "Null4", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_ENCODER, {"Quad-A", "Quad-B", "Quad-IDX", "Quad-IDXM", "Quad-Probe", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_MUXED_ENCODER, {"MuxQ-A", "MuxQ-B", "MuxQ-IDX", "MuxQ-IDXM", "Quad-ProbeM", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_ENCODER, {"Quad-A", "Quad-B", "Quad-IDX", "Quad-IDXM", "Quad-Probe", "Shared-IDX", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_MUXED_ENCODER, {"MuxQ-A", "MuxQ-B", "MuxQ-IDX", "MuxQ-IDXM", "Quad-ProbeM", "Shared-IDX", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_MUXED_ENCODER_SEL, {"MuxSel0", "MuxSel1", "Null3", "Null4", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_MUXED_ENCODER_MIM, {"MuxQ-A", "MuxQ-B", "MuxQ-IDX", "MuxQ-IDXM", "Quad-ProbeM", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_MUXED_ENCODER_MIM, {"MuxQ-A", "MuxQ-B", "MuxQ-IDX", "MuxQ-IDXM", "Quad-ProbeM", "Shared-IDX", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_MUXED_ENCODER_SEL_MIM, {"MuxSel0", "MuxSel1", "Null3", "Null4", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_STEPGEN, {"Step/Table1", "Dir/Table2", "Table3", "Table4", "Table5", "Table6", "SGindex", "SGProbe", "Null9", "Null10"}},
{HM2_GTAG_STEPGEN, {"Step/Table1", "Dir/Table2", "Table3", "Table4", "Table5", "Table6", "Table7", "Table8", "Index", "Probe"}},
{HM2_GTAG_PWMGEN, {"PWM", "Dir", "/Enable", "Null4", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_RCPWMGEN, {"PWM", "Null2","Null3", "Null4", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_TPPWM, {"PWMA", "PWMB", "PWMC", "NPWMA", "NPWMB", "NPWMC", "/ENA", "FAULT", "Null9", "Null10"}},
{HM2_GTAG_WAVEGEN, {"PDMA", "PDMB", "Trig0", "Trig1", "Trig2", "Trig3", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_DAQ_FIFO, {"Data", "Strobe", "Full", "Null4", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
@ -419,17 +193,24 @@ static pin_name_t pin_names[HM2_MAX_TAGS] = {
{HM2_GTAG_BIN_DMDMA, {"Null1", "Null2", "Null3", "Null4", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_RESOLVER, {"PwrEn", "PDMP", "PDMM", "ADChan0", "ADChan1", "ADChan2", "SPICS", "SPIClk", "SPIDI0", "SPIDI1"}},
{HM2_GTAG_SSERIAL, {"RXData", "TXData", "TXEn", "TestPin", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_SSERIALB, {"RXData", "TXData", "TXEn", "TestPin", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_TWIDDLER, {"InBit", "IOBit", "OutBit", "Null4", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_XFORMER, {"Drive", "Ref", "Null3", "Null4", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_SSR, {"Out", "AC Ref", "Null3", "Null4", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_SPI, {"/Frame", "DOut", "SClk", "DIn", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_BSPI, {"/Frame", "DOut", "SClk", "DIn", "CS0", "CS1", "CS2", "CS3", "Null9", "Null10"}},
{HM2_GTAG_DBSPI, {"Null1", "DOut", "SClk", "DIn", "/CS-FRM0", "/CS-FRM1", "/CS-FRM2", "/CS-FRM3", "Null9", "Null10"}},
{HM2_GTAG_DPLL, {"Sync", "DDSMSB", "FOut", "PostOut", "SyncToggle", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_SSI, {"SClk", "SClkEn", "Data", "DAv", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_BISS, {"Clk", "ClkEn", "Din", "DAv", "TData", "STime", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_UART_TX, {"TXData", "TXEna", "Null3", "Null4", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_UART_RX, {"RXData", "Null2", "Null3", "Null4", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_TRAM, {"Null1", "Null2", "Null3", "Null4", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_LED, {"Null1", "Null2", "Null3", "Null4", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_INMUX, {"Addr0", "Addr1", "Addr2", "Addr3", "Addr4", "MuxData", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_SIGMA5, {"TXData", "RXData", "TxEn", "Null4", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_INM, {"Input0", "Input1", "Input2", "Input3", "Input4", "Input5", "Input6", "Input7", "Input8"}},
{HM2_GTAG_XYMOD, {"XData", "YData", "Clk", "Sync", "Status", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_DPAINTER, {"VidData", "VidClk", "Null3", "Null4", "Null5","Null6", "Null7", "Null8", "Null9", "Null10"}},
};
static pin_name_t pin_names_xml[HM2_MAX_TAGS] = {
@ -438,12 +219,13 @@ static pin_name_t pin_names_xml[HM2_MAX_TAGS] = {
{HM2_GTAG_WATCHDOG, {"Null1", "Null2", "Null3", "Null4", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_IOPORT, {"Null1", "Null2", "Null3", "Null4", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_ENCODER, {"Phase A", "Phase B", "Index", "Quad-IDXM", "Quad-Probe", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_MUXED_ENCODER, {"Muxed Phase A", "Muxed Phase B", "Muxed Index", "MuxQ-IDXM", "Quad-ProbeM", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_MUXED_ENCODER, {"Muxed Phase A", "Muxed Phase B", "Muxed Index", "MuxQ-IDXM", "Quad-ProbeM", "Shared-IDX", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_MUXED_ENCODER_SEL, {"Muxed Encoder Select 0", "Muxed Encoder select 1", "Null3", "Null4", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_MUXED_ENCODER_MIM, {"MuxQ-A", "MuxQ-B", "MuxQ-IDX", "MuxQ-IDXM", "Quad-ProbeM", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_MUXED_ENCODER_MIM, {"MuxQ-A", "MuxQ-B", "MuxQ-IDX", "MuxQ-IDXM", "Quad-ProbeM", "Shared-IDX", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_MUXED_ENCODER_SEL_MIM, {"MuxSel0", "MuxSel1", "Null3", "Null4", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_STEPGEN, {"Step/Table1", "Dir/Table2", "Table3", "Table4", "Table5", "Table6", "SGindex", "SGProbe", "Null9", "Null10"}},
{HM2_GTAG_STEPGEN, {"Step/Table1", "Dir/Table2", "Table3", "Table4", "Table5", "Table6", "Table7", "Table8", "Index", "Probe"}},
{HM2_GTAG_PWMGEN, {"PWM/Up", "Dir/Down", "/Enable", "Null4", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_RCPWMGEN, {"PWM", "Null2","Null3", "Null4", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_TPPWM, {"PWMA", "PWMB", "PWMC", "NPWMA", "NPWMB", "NPWMC", "/ENA", "FAULT", "Null9", "Null10"}},
{HM2_GTAG_WAVEGEN, {"PDMA", "PDMB", "Trig0", "Trig1", "Trig2", "Trig3", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_DAQ_FIFO, {"Data", "Strobe", "Full", "Null4", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
@ -451,17 +233,24 @@ static pin_name_t pin_names_xml[HM2_MAX_TAGS] = {
{HM2_GTAG_BIN_DMDMA, {"Null1", "Null2", "Null3", "Null4", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_RESOLVER, {"PwrEn", "PDMP", "PDMM", "ADChan0", "ADChan1", "ADChan2", "SPICS", "SPIClk", "SPIDI0", "SPIDI1"}},
{HM2_GTAG_SSERIAL, {"RXData", "TXData", "TXEn", "TestPin", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_SSERIALB, {"RXData", "TXData", "TXEn", "TestPin", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_TWIDDLER, {"InBit", "IOBit", "OutBit", "Null4", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_XFORMER, {"Drive", "Ref", "Null3", "Null4", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_SSR, {"Out", "AC Ref", "Null3", "Null4", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_SPI, {"/Frame", "DOut", "SClk", "DIn", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_BSPI, {"/Frame", "DOut", "SClk", "DIn", "CS0", "CS1", "CS2", "CS3", "Null9", "Null10"}},
{HM2_GTAG_DBSPI, {"Null1", "DOut", "SClk", "DIn", "/CS-FRM0", "/CS-FRM1", "/CS-FRM2", "/CS-FRM3", "Null9", "Null10"}},
{HM2_GTAG_DPLL, {"Sync", "DDSMSB", "FOut", "PostOut", "SyncToggle", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_SSI, {"SClk", "SClkEn", "Din", "DAv", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_BISS, {"Clk", "ClkEn", "Din", "DAv", "TData", "STime", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_UART_TX, {"TXData", "TXEna", "Null3", "Null4", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_UART_RX, {"RXData", "Null2", "Null3", "Null4", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_TRAM, {"Null1", "Null2", "Null3", "Null4", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_LED, {"Null1", "Null2", "Null3", "Null4", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_INMUX, {"Addr0", "Addr1", "Addr2", "Addr3", "Addr4", "MuxData", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_SIGMA5, {"TXData", "RXData", "TxEn", "Null4", "Null5", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_INM, {"Input0", "Input1", "Input2", "Input3", "Input4", "Input5", "Input6", "Input7", "Input8"}},
{HM2_GTAG_XYMOD, {"XData", "YData", "Clk", "Sync", "Status", "Null6", "Null7", "Null8", "Null9", "Null10"}},
{HM2_GTAG_DPAINTER, {"VidData", "VidClk", "Null3", "Null4", "Null5","Null6", "Null7", "Null8", "Null9", "Null10"}},
};
static mod_name_t mod_names[HM2_MAX_TAGS] = {
@ -472,6 +261,7 @@ static mod_name_t mod_names[HM2_MAX_TAGS] = {
{"QCount", HM2_GTAG_ENCODER},
{"StepGen", HM2_GTAG_STEPGEN},
{"PWM", HM2_GTAG_PWMGEN},
{"RCPWM", HM2_GTAG_RCPWMGEN},
{"SPI", HM2_GTAG_SPI},
{"SSI", HM2_GTAG_SSI},
{"UARTTX", HM2_GTAG_UART_TX},
@ -493,8 +283,15 @@ static mod_name_t mod_names[HM2_MAX_TAGS] = {
{"LED", HM2_GTAG_LED},
{"ResolverMod", HM2_GTAG_RESOLVER},
{"SSerial", HM2_GTAG_SSERIAL},
{"SSerialB", HM2_GTAG_SSERIALB},
{"Twiddler", HM2_GTAG_TWIDDLER},
{"Transformer", HM2_GTAG_XFORMER},
{"SSR", HM2_GTAG_SSR},
{"InMux", HM2_GTAG_INMUX},
{"Sigma5Enc", HM2_GTAG_SIGMA5},
{"InM", HM2_GTAG_INM},
{"BISS", HM2_GTAG_BISS},
{"XYMod", HM2_GTAG_XYMOD},
{"DataPainter",HM2_GTAG_DPAINTER},
};
static mod_name_t mod_names_xml[HM2_MAX_TAGS] = {
@ -505,6 +302,7 @@ static mod_name_t mod_names_xml[HM2_MAX_TAGS] = {
{"Encoder", HM2_GTAG_ENCODER},
{"StepGen", HM2_GTAG_STEPGEN},
{"PWM", HM2_GTAG_PWMGEN},
{"RCPWM", HM2_GTAG_RCPWMGEN},
{"SPI", HM2_GTAG_SPI},
{"SSI", HM2_GTAG_SSI},
{"UARTTX", HM2_GTAG_UART_TX},
@ -526,12 +324,20 @@ static mod_name_t mod_names_xml[HM2_MAX_TAGS] = {
{"LED", HM2_GTAG_LED},
{"ResolverMod", HM2_GTAG_RESOLVER},
{"SSerial", HM2_GTAG_SSERIAL},
{"SSerialB", HM2_GTAG_SSERIALB},
{"Twiddler", HM2_GTAG_TWIDDLER},
{"Transformer", HM2_GTAG_XFORMER},
{"SSR", HM2_GTAG_SSR},
{"InMux", HM2_GTAG_INMUX},
{"Sigma5Enc", HM2_GTAG_SIGMA5},
{"InM", HM2_GTAG_INM},
{"BISS", HM2_GTAG_BISS},
{"XYMod", HM2_GTAG_XYMOD},
{"DataPainter",HM2_GTAG_DPAINTER},
};
static char *pin_find_module_name(int gtag, int xml_flag) {
static char *find_module_name(int gtag, int xml_flag) {
int i;
static char unknown[100];
mod_name_t *mod_names_ptr;
if (gtag == HM2_GTAG_NONE) {
@ -548,7 +354,9 @@ static char *pin_find_module_name(int gtag, int xml_flag) {
if (mod_names_ptr[i].tag == gtag)
return mod_names_ptr[i].name;
}
return "(unknown-gtag)";
snprintf(unknown, 100, "(unknown-gtag-%d)", gtag);
return unknown;
}
@ -566,8 +374,8 @@ static char *pin_get_pin_name(hm2_pin_desc_t *pin, int xml_flag) {
for (i = 0; i < HM2_MAX_TAGS; i++) {
if (pin_names_ptr[i].tag == pin->sec_tag) {
if (pin->sec_tag == HM2_GTAG_SSERIAL) {
chan = pin->sec_pin & 0x0F;
if ((pin->sec_tag == HM2_GTAG_SSERIAL) || (pin->sec_tag == HM2_GTAG_SSERIALB)) {
chan = (pin->sec_pin & 0x0F) - 1;
if ((pin->sec_pin & 0xF0) == 0x00) {
sprintf(buff, "%s%u", pin_names_ptr[i].name[0], chan);
return buff;
@ -581,6 +389,15 @@ static char *pin_get_pin_name(hm2_pin_desc_t *pin, int xml_flag) {
sprintf(buff, "%s%u", pin_names_ptr[i].name[3], chan);
return buff;
}
} else if (pin->sec_tag == HM2_GTAG_SSR) {
if ((pin->sec_pin & 0xF0) == 0x80) {
chan = pin->sec_pin - 0x81;
sprintf(buff, "%s-%02u", pin_names_ptr[i].name[0], chan);
return buff;
} else if (pin->sec_pin == 0xA0) {
sprintf(buff, "%s", pin_names_ptr[i].name[1]);
return buff;
}
} else if (pin->gtag == HM2_GTAG_DAQ_FIFO) {
chan = pin->sec_chan & 0x1F;
if ((pin->sec_pin & 0xE0) == 0x00) {
@ -612,13 +429,25 @@ static char *pin_get_pin_name(hm2_pin_desc_t *pin, int xml_flag) {
sprintf(buff, "%s%u", pin_names_ptr[i].name[0], chan);
return buff;
}
} else if (pin->sec_tag == HM2_GTAG_INMUX) {
if ((pin->sec_pin & 0x80) == 0x80) {
// output pins
snprintf(buff, sizeof(buff), "Addr%d", pin->sec_pin - 0x81);
} else {
// input pins
snprintf(buff, sizeof(buff), "Data%d", pin->sec_pin - 0x01);
}
return buff;
} else if (pin->sec_tag == HM2_GTAG_INM) {
snprintf(buff, sizeof(buff), "Input%d", pin->sec_pin - 0x01);
return buff;
} else {
sprintf(buff, "%s", pin_names_ptr[i].name[(pin->sec_pin & 0x0F) - 1]);
return buff;
}
};
};
sprintf(buff, "Unknown");
snprintf(buff, sizeof(buff), "Unknown-Gtag%d-Chan%d-Pin%d", pin->sec_tag, pin->sec_chan, pin->sec_pin);
return buff;
}
@ -647,16 +476,8 @@ void hm2_print_pin_file(llio_t *llio, int xml_flag) {
if ((llio->hm2.modules[i].gtag == 0) && (llio->hm2.modules[i].version == 0) &&
(llio->hm2.modules[i].clock_tag == 0) && (llio->hm2.modules[i].instances == 0)) break;
{
int k;
for (k = 0; k < HM2_MAX_TAGS; k++) {
if (mod_names[k].tag == llio->hm2.modules[i].gtag) {
printf(" Module: %s\n", mod_names[k].name);
printf(" There are %u of %s in configuration\n", llio->hm2.modules[i].instances, mod_names[k].name);
break;
}
}
}
printf(" Module: %s\n", find_module_name(llio->hm2.modules[i].gtag, xml_flag));
printf(" There are %u of %s in configuration\n", llio->hm2.modules[i].instances, find_module_name(llio->hm2.modules[i].gtag, xml_flag));
printf(" Version: %u\n", llio->hm2.modules[i].version);
printf(" Registers: %u\n", llio->hm2.modules[i].registers);
@ -687,14 +508,21 @@ void hm2_print_pin_file(llio_t *llio, int xml_flag) {
case 32:
pin_nr = i*(llio->hm2.idrom.port_width) + j;
break;
default:
pin_nr = 0;
break;
}
if (llio->bob_hint[i] != 0) {
printf("%-18s",bob_pin_names[llio->bob_hint[i]-1].name[j]);
} else {
printf("%2u ", pin_nr);
}
printf("%2u", pin_nr);
printf(" %3u", i*(llio->hm2.idrom.port_width) + j);
printf(" %-8s", pin_find_module_name(pin->gtag, xml_flag));
printf(" %-8s", find_module_name(pin->gtag, xml_flag));
if (pin->sec_tag == HM2_GTAG_NONE) {
printf(" %-15s", "None");
} else {
printf(" %-15s", pin_find_module_name(pin->sec_tag, xml_flag));
printf(" %-15s", find_module_name(pin->sec_tag, xml_flag));
if (pin->sec_chan & HM2_CHAN_GLOBAL) {
printf(" Global ");
@ -730,17 +558,8 @@ void hm2_print_pin_file(llio_t *llio, int xml_flag) {
(llio->hm2.modules[i].clock_tag == 0) && (llio->hm2.modules[i].instances == 0)) break;
printf(" <module>\n");
{
int k;
for (k = 0; k < HM2_MAX_TAGS; k++) {
if (mod_names[k].tag == llio->hm2.modules[i].gtag) {
printf(" <tagname>%s</tagname>\n", mod_names[k].name);
printf(" <tagname>%s</tagname>\n", find_module_name(llio->hm2.modules[i].gtag, xml_flag));
printf(" <numinstances>%2d</numinstances>\n", llio->hm2.modules[i].instances);
break;
}
}
}
printf(" </module>\n");
}
printf(" </modules>\n");
@ -761,10 +580,13 @@ void hm2_print_pin_file(llio_t *llio, int xml_flag) {
case 32:
pin_nr = i*(llio->hm2.idrom.port_width) + j;
break;
default:
pin_nr = 0;
break;
}
printf(" <pin>\n");
printf(" <connector>%s</connector>\n", llio->ioport_connector_name[i]);
printf(" <secondarymodulename>%s</secondarymodulename>\n", pin_find_module_name(pin->sec_tag, xml_flag));
printf(" <secondarymodulename>%s</secondarymodulename>\n", find_module_name(pin->sec_tag, xml_flag));
printf(" <secondaryfunctionname>");
if (pin->sec_tag != HM2_GTAG_NONE) {
printf("%s", pin_get_pin_name(pin, xml_flag));
@ -775,7 +597,11 @@ void hm2_print_pin_file(llio_t *llio, int xml_flag) {
}
}
printf("</secondaryfunctionname>\n");
if (llio->bob_hint[i] != 0) {
printf(" <secondaryinstance>%-18s</secondaryinstance>\n",bob_pin_names[llio->bob_hint[i]-1].name[j]);
} else {
printf(" <secondaryinstance>%2d</secondaryinstance>\n", pin_nr);
}
printf(" </pin>\n");
}
}
@ -783,3 +609,35 @@ void hm2_print_pin_file(llio_t *llio, int xml_flag) {
printf("</hostmot2>\n");
}
}
void hm2_print_pin_descriptors(llio_t *llio) {
int num_pins;
num_pins = llio->hm2.idrom.io_ports * llio->hm2.idrom.port_width;
printf("%d HM2 Pin Descriptors:\n", num_pins);
for (int i = 0; i < num_pins; i ++) {
hm2_pin_desc_t *pd = &llio->hm2.pins[i];
printf(" pin %d:\n", i);
printf(
" Primary Tag: 0x%02X (%s)\n",
pd->gtag,
find_module_name(pd->gtag, 0)
);
if (llio->hm2.pins[i].sec_tag != 0) {
printf(
" Secondary Tag: 0x%02X (%s)\n",
llio->hm2.pins[i].sec_tag,
find_module_name(pd->sec_tag, 0)
);
printf(" Secondary Unit: 0x%02X\n", pd->sec_chan);
printf(
" Secondary Pin: 0x%02X (%s, %s)\n",
pd->sec_pin,
pin_get_pin_name(pd, 0),
(pd->sec_pin & 0x80) ? "Output" : "Input"
);
}
}
}

View file

@ -36,7 +36,8 @@ typedef struct {
int sw_modes_cnt;
} sserial_device_t;
#define HM2_MAX_TAGS 30
#define HM2_MAX_TAGS 255
#define MAX_BOB_NAMES 17
#define ANYIO_MAX_IOPORT_CONNECTORS 8
typedef struct llio_struct llio_t;
@ -60,12 +61,13 @@ struct llio_struct {
int num_ioport_connectors;
int pins_per_connector;
const char *ioport_connector_name[ANYIO_MAX_IOPORT_CONNECTORS];
u16 bob_hint[ANYIO_MAX_IOPORT_CONNECTORS];
int num_leds;
const char *fpga_part_number;
char board_name[16];
void *board;
hostmot2_t hm2;
sserial_interface_t ss_interface[HM2_SSERIAL_MAX_INTEFACES];
sserial_interface_t ss_interface[HM2_SSERIAL_MAX_INTERFACES];
sserial_device_t ss_device[HM2_SSERIAL_MAX_CHANNELS];
int verbose;
};
@ -75,18 +77,20 @@ typedef struct {
char *name[10];
} pin_name_t;
typedef struct {
u16 bobname;
char *name[32];
} bob_pin_name_t;
typedef struct {
char *name;
u8 tag;
} mod_name_t;
int hm2_check_cookie(llio_t *llio);
void hm2_read_idrom(hostmot2_t *hm2);
hm2_module_desc_t *hm2_find_module(hostmot2_t *hm2, u8 gtag);
void hm2_print_idrom(hostmot2_t *hm2);
void hm2_print_modules(hostmot2_t *hm2);
void hm2_print_pins(hostmot2_t *hm2);
void hm2_print_pin_file(llio_t *llio, int xml_flag);
void hm2_print_pin_descriptors(llio_t *llio);
void hm2_set_pin_source(hostmot2_t *hm2, int pin_number, u8 source);
void hm2_set_pin_direction(hostmot2_t *hm2, int pin_number, u8 direction);
void sserial_module_init(llio_t *llio);

View file

@ -59,12 +59,22 @@
#define HM2_GTAG_BISS 0x18
#define HM2_GTAG_FABS 0x19
#define HM2_GTAG_HM2DPLL 0x1A
#define HM2_GTAG_INMUX 0x1E
#define HM2_GTAG_SIGMA5 0x1F
#define HM2_GTAG_INM 0x23
#define HM2_GTAG_DPAINTER 0x2A
#define HM2_GTAG_XYMOD 0x2B
#define HM2_GTAG_RCPWMGEN 0x2C
#define HM2_GTAG_LIOPORT 0x40
#define HM2_GTAG_LED 0x80
#define HM2_GTAG_RESOLVER 0xC0
#define HM2_GTAG_SSERIAL 0xC1
#define HM2_GTAG_TWIDDLER 0xC2
#define HM2_GTAG_XFORMER 0xC3
#define HM2_GTAG_SSR 0xC3
#define HM2_GTAG_CPDRIVE 0xC4
#define HM2_GTAG_DSAD 0xC5
#define HM2_GTAG_SSERIALB 0xC6
// HM2 EEPROM SPI INTERFACE
@ -207,7 +217,7 @@ typedef struct {
// SSERIAL MODULE
#define HM2_SSERIAL_MAX_INTEFACES 4
#define HM2_SSERIAL_MAX_INTERFACES 4
#define HM2_SSERIAL_MAX_CHANNELS 8
#define HM2_MOD_OFFS_SSERIAL_CMD 0x0000
@ -268,6 +278,25 @@ typedef struct {
#define SSLBP_REMOTE_7I77_ANALOG 0x11000000
#define SSLBP_REMOTE_7I77_IO 0x12000000
// must match BOB name order
# define BOB_7I76 1
# define BOB_7I77 2
# define BOB_7I94_0 3
# define BOB_7I94_1 4
# define BOB_7I95_0 5
# define BOB_7I95_1 6
# define BOB_7I96_0 7
# define BOB_7I96_1 8
# define BOB_7I96_2 9
# define BOB_7I97_0 10
# define BOB_7I97_1 11
# define BOB_7I97_2 12
# define BOB_7C80_0 13
# define BOB_7C80_1 14
# define BOB_7C81_0 15
# define BOB_7C81_1 16
# define BOB_7C81_2 17
struct sserial_pdd_struct {
u8 record_type;
u8 data_size;

7
lbp.c
View file

@ -28,7 +28,7 @@
#include "lbp.h"
#ifdef __linux__
int sd;
static int sd = -1;
#elif _WIN32
HANDLE sd;
#endif
@ -42,6 +42,7 @@ int lbp_send(void *packet, int size) {
#endif
if (LBP_SENDRECV_DEBUG)
printf("%d=lbp_send(%d)\n", send, size);
return send;
}
@ -54,6 +55,7 @@ int lbp_recv(void *packet, int size) {
#endif
if (LBP_SENDRECV_DEBUG)
printf("%d=lbp_recv(%d)\n", recv, size);
return recv;
}
@ -65,6 +67,7 @@ u8 lbp_read_ctrl(u8 cmd) {
recv = lbp_recv(&data, 1);
if (LBP_SENDRECV_DEBUG)
printf("%d=send(%X), %d=recv(%X)\n", send, cmd, recv, data);
return data;
}
@ -81,6 +84,7 @@ int lbp_read(u16 addr, void *buffer) {
recv = lbp_recv(buffer, 4);
if (LBP_SENDRECV_DEBUG)
printf("lbp_read(%02X:%04X): %08X\n", packet.cmd, addr, *ptr);
return 0;
}
@ -96,6 +100,7 @@ int lbp_write(u16 addr, void *buffer) {
send = lbp_send(&packet, sizeof(lbp_cmd_addr_data));
if (LBP_SENDRECV_DEBUG)
printf("lbp_write(%02X:%04X)\n", packet.cmd, addr);
return 0;
}

Binary file not shown.

View file

@ -1,6 +0,0 @@
#define PCI_ARCH_I386
#define PCI_OS_WINDOWS
#define PCI_HAVE_PM_INTEL_CONF
#define PCI_IDS "pci.ids"
#define PCI_PATH_IDS_DIR "."
#define PCILIB_VERSION "3.1.10"

File diff suppressed because it is too large Load diff

View file

@ -1,240 +0,0 @@
/*
* The PCI Library
*
* Copyright (c) 1997--2009 Martin Mares <mj@ucw.cz>
*
* Can be freely distributed and used under the terms of the GNU GPL.
*/
#ifndef _PCI_LIB_H
#define _PCI_LIB_H
#ifndef PCI_CONFIG_H
#include "config.h"
#endif
#include "header.h"
#include "types.h"
#define PCI_LIB_VERSION 0x030100
#ifndef PCI_ABI
#define PCI_ABI
#endif
/*
* PCI Access Structure
*/
struct pci_methods;
enum pci_access_type {
/* Known access methods, remember to update access.c as well */
PCI_ACCESS_AUTO, /* Autodetection */
PCI_ACCESS_SYS_BUS_PCI, /* Linux /sys/bus/pci */
PCI_ACCESS_PROC_BUS_PCI, /* Linux /proc/bus/pci */
PCI_ACCESS_I386_TYPE1, /* i386 ports, type 1 */
PCI_ACCESS_I386_TYPE2, /* i386 ports, type 2 */
PCI_ACCESS_FBSD_DEVICE, /* FreeBSD /dev/pci */
PCI_ACCESS_AIX_DEVICE, /* /dev/pci0, /dev/bus0, etc. */
PCI_ACCESS_NBSD_LIBPCI, /* NetBSD libpci */
PCI_ACCESS_OBSD_DEVICE, /* OpenBSD /dev/pci */
PCI_ACCESS_DUMP, /* Dump file */
PCI_ACCESS_MAX
};
struct pci_access {
/* Options you can change: */
unsigned int method; /* Access method */
int writeable; /* Open in read/write mode */
int buscentric; /* Bus-centric view of the world */
char *id_file_name; /* Name of ID list file (use pci_set_name_list_path()) */
int free_id_name; /* Set if id_file_name is malloced */
int numeric_ids; /* Enforce PCI_LOOKUP_NUMERIC (>1 => PCI_LOOKUP_MIXED) */
unsigned int id_lookup_mode; /* pci_lookup_mode flags which are set automatically */
/* Default: PCI_LOOKUP_CACHE */
int debugging; /* Turn on debugging messages */
/* Functions you can override: */
void (*error)(char *msg, ...) PCI_PRINTF(1,2); /* Write error message and quit */
void (*warning)(char *msg, ...) PCI_PRINTF(1,2); /* Write a warning message */
void (*debug)(char *msg, ...) PCI_PRINTF(1,2); /* Write a debugging message */
struct pci_dev *devices; /* Devices found on this bus */
/* Fields used internally: */
struct pci_methods *methods;
struct pci_param *params;
struct id_entry **id_hash; /* names.c */
struct id_bucket *current_id_bucket;
int id_load_failed;
int id_cache_status; /* 0=not read, 1=read, 2=dirty */
int fd; /* proc/sys: fd for config space */
int fd_rw; /* proc/sys: fd opened read-write */
int fd_pos; /* proc/sys: current position */
int fd_vpd; /* sys: fd for VPD */
struct pci_dev *cached_dev; /* proc/sys: device the fds are for */
};
/* Initialize PCI access */
struct pci_access *pci_alloc(void) PCI_ABI;
void pci_init(struct pci_access *) PCI_ABI;
void pci_cleanup(struct pci_access *) PCI_ABI;
/* Scanning of devices */
void pci_scan_bus(struct pci_access *acc) PCI_ABI;
struct pci_dev *pci_get_dev(struct pci_access *acc, int domain, int bus, int dev, int func) PCI_ABI; /* Raw access to specified device */
void pci_free_dev(struct pci_dev *) PCI_ABI;
/* Names of access methods */
int pci_lookup_method(char *name) PCI_ABI; /* Returns -1 if not found */
char *pci_get_method_name(int index) PCI_ABI; /* Returns "" if unavailable, NULL if index out of range */
/*
* Named parameters
*/
struct pci_param {
struct pci_param *next; /* Please use pci_walk_params() for traversing the list */
char *param; /* Name of the parameter */
char *value; /* Value of the parameter */
int value_malloced; /* used internally */
char *help; /* Explanation of the parameter */
};
char *pci_get_param(struct pci_access *acc, char *param) PCI_ABI;
int pci_set_param(struct pci_access *acc, char *param, char *value) PCI_ABI; /* 0 on success, -1 if no such parameter */
/* To traverse the list, call pci_walk_params repeatedly, first with prev=NULL, and do not modify the parameters during traversal. */
struct pci_param *pci_walk_params(struct pci_access *acc, struct pci_param *prev) PCI_ABI;
/*
* Devices
*/
struct pci_dev {
struct pci_dev *next; /* Next device in the chain */
u16 domain; /* PCI domain (host bridge) */
u8 bus, dev, func; /* Bus inside domain, device and function */
/* These fields are set by pci_fill_info() */
int known_fields; /* Set of info fields already known */
u16 vendor_id, device_id; /* Identity of the device */
u16 device_class; /* PCI device class */
int irq; /* IRQ number */
pciaddr_t base_addr[6]; /* Base addresses including flags in lower bits */
pciaddr_t size[6]; /* Region sizes */
pciaddr_t rom_base_addr; /* Expansion ROM base address */
pciaddr_t rom_size; /* Expansion ROM size */
struct pci_cap *first_cap; /* List of capabilities */
char *phy_slot; /* Physical slot */
/* Fields used internally: */
struct pci_access *access;
struct pci_methods *methods;
u8 *cache; /* Cached config registers */
int cache_len;
int hdrtype; /* Cached low 7 bits of header type, -1 if unknown */
void *aux; /* Auxillary data */
};
#define PCI_ADDR_IO_MASK (~(pciaddr_t) 0x3)
#define PCI_ADDR_MEM_MASK (~(pciaddr_t) 0xf)
#define PCI_ADDR_FLAG_MASK 0xf
u8 pci_read_byte(struct pci_dev *, int pos) PCI_ABI; /* Access to configuration space */
u16 pci_read_word(struct pci_dev *, int pos) PCI_ABI;
u32 pci_read_long(struct pci_dev *, int pos) PCI_ABI;
int pci_read_block(struct pci_dev *, int pos, u8 *buf, int len) PCI_ABI;
int pci_read_vpd(struct pci_dev *d, int pos, u8 *buf, int len) PCI_ABI;
int pci_write_byte(struct pci_dev *, int pos, u8 data) PCI_ABI;
int pci_write_word(struct pci_dev *, int pos, u16 data) PCI_ABI;
int pci_write_long(struct pci_dev *, int pos, u32 data) PCI_ABI;
int pci_write_block(struct pci_dev *, int pos, u8 *buf, int len) PCI_ABI;
int pci_fill_info(struct pci_dev *, int flags) PCI_ABI; /* Fill in device information */
#define PCI_FILL_IDENT 1
#define PCI_FILL_IRQ 2
#define PCI_FILL_BASES 4
#define PCI_FILL_ROM_BASE 8
#define PCI_FILL_SIZES 16
#define PCI_FILL_CLASS 32
#define PCI_FILL_CAPS 64
#define PCI_FILL_EXT_CAPS 128
#define PCI_FILL_PHYS_SLOT 256
#define PCI_FILL_RESCAN 0x10000
void pci_setup_cache(struct pci_dev *, u8 *cache, int len) PCI_ABI;
/*
* Capabilities
*/
struct pci_cap {
struct pci_cap *next;
u16 id; /* PCI_CAP_ID_xxx */
u16 type; /* PCI_CAP_xxx */
unsigned int addr; /* Position in the config space */
};
#define PCI_CAP_NORMAL 1 /* Traditional PCI capabilities */
#define PCI_CAP_EXTENDED 2 /* PCIe extended capabilities */
struct pci_cap *pci_find_cap(struct pci_dev *, unsigned int id, unsigned int type) PCI_ABI;
/*
* Filters
*/
struct pci_filter {
int domain, bus, slot, func; /* -1 = ANY */
int vendor, device;
};
void pci_filter_init(struct pci_access *, struct pci_filter *) PCI_ABI;
char *pci_filter_parse_slot(struct pci_filter *, char *) PCI_ABI;
char *pci_filter_parse_id(struct pci_filter *, char *) PCI_ABI;
int pci_filter_match(struct pci_filter *, struct pci_dev *) PCI_ABI;
/*
* Conversion of PCI ID's to names (according to the pci.ids file)
*
* Call pci_lookup_name() to identify different types of ID's:
*
* VENDOR (vendorID) -> vendor
* DEVICE (vendorID, deviceID) -> device
* VENDOR | DEVICE (vendorID, deviceID) -> combined vendor and device
* SUBSYSTEM | VENDOR (subvendorID) -> subsystem vendor
* SUBSYSTEM | DEVICE (vendorID, deviceID, subvendorID, subdevID) -> subsystem device
* SUBSYSTEM | VENDOR | DEVICE (vendorID, deviceID, subvendorID, subdevID) -> combined subsystem v+d
* SUBSYSTEM | ... (-1, -1, subvendorID, subdevID) -> generic subsystem
* CLASS (classID) -> class
* PROGIF (classID, progif) -> programming interface
*/
char *pci_lookup_name(struct pci_access *a, char *buf, int size, int flags, ...) PCI_ABI;
int pci_load_name_list(struct pci_access *a) PCI_ABI; /* Called automatically by pci_lookup_*() when needed; returns success */
void pci_free_name_list(struct pci_access *a) PCI_ABI; /* Called automatically by pci_cleanup() */
void pci_set_name_list_path(struct pci_access *a, char *name, int to_be_freed) PCI_ABI;
void pci_id_cache_flush(struct pci_access *a) PCI_ABI;
enum pci_lookup_mode {
PCI_LOOKUP_VENDOR = 1, /* Vendor name (args: vendorID) */
PCI_LOOKUP_DEVICE = 2, /* Device name (args: vendorID, deviceID) */
PCI_LOOKUP_CLASS = 4, /* Device class (args: classID) */
PCI_LOOKUP_SUBSYSTEM = 8,
PCI_LOOKUP_PROGIF = 16, /* Programming interface (args: classID, prog_if) */
PCI_LOOKUP_NUMERIC = 0x10000, /* Want only formatted numbers; default if access->numeric_ids is set */
PCI_LOOKUP_NO_NUMBERS = 0x20000, /* Return NULL if not found in the database; default is to print numerically */
PCI_LOOKUP_MIXED = 0x40000, /* Include both numbers and names */
PCI_LOOKUP_NETWORK = 0x80000, /* Try to resolve unknown ID's by DNS */
PCI_LOOKUP_SKIP_LOCAL = 0x100000, /* Do not consult local database */
PCI_LOOKUP_CACHE = 0x200000, /* Consult the local cache before using DNS */
PCI_LOOKUP_REFRESH_CACHE = 0x400000, /* Forget all previously cached entries, but still allow updating the cache */
};
#endif

View file

@ -1,65 +0,0 @@
/*
* The PCI Library -- Types and Format Strings
*
* Copyright (c) 1997--2008 Martin Mares <mj@ucw.cz>
*
* Can be freely distributed and used under the terms of the GNU GPL.
*/
#include <sys/types.h>
#ifndef PCI_HAVE_Uxx_TYPES
#ifdef PCI_OS_WINDOWS
#include <windef.h>
typedef BYTE u8;
typedef WORD u16;
typedef DWORD u32;
#elif defined(PCI_HAVE_STDINT_H) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
#include <stdint.h>
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
#else
typedef u_int8_t u8;
typedef u_int16_t u16;
typedef u_int32_t u32;
#endif
#ifdef PCI_HAVE_64BIT_ADDRESS
#include <limits.h>
#if ULONG_MAX > 0xffffffff
typedef unsigned long u64;
#define PCI_U64_FMT "l"
#else
typedef unsigned long long u64;
#define PCI_U64_FMT "ll"
#endif
#endif
#endif /* PCI_HAVE_Uxx_TYPES */
#ifdef PCI_HAVE_64BIT_ADDRESS
typedef u64 pciaddr_t;
#define PCIADDR_T_FMT "%08" PCI_U64_FMT "x"
#define PCIADDR_PORT_FMT "%04" PCI_U64_FMT "x"
#else
typedef u32 pciaddr_t;
#define PCIADDR_T_FMT "%08x"
#define PCIADDR_PORT_FMT "%04x"
#endif
#ifdef PCI_ARCH_SPARC64
/* On sparc64 Linux the kernel reports remapped port addresses and IRQ numbers */
#undef PCIADDR_PORT_FMT
#define PCIADDR_PORT_FMT PCIADDR_T_FMT
#define PCIIRQ_FMT "%08x"
#else
#define PCIIRQ_FMT "%d"
#endif
#if defined(__GNUC__) && __GNUC__ > 2
#define PCI_PRINTF(x,y) __attribute__((format(printf, x, y)))
#else
#define PCI_PRINTF(x,y)
#endif

117
mesaflash.1 Normal file
View file

@ -0,0 +1,117 @@
.TH MESAFLASH 1 "August 13 2019" "version 3.4.0~pre"
.SH NAME
MesaFlash \- utility to flash Mesa Electronics FPGA Cards
.SH SYNOPSIS
.B mesaflash [options] [commands]
.SH DESCRIPTION
.B mesaflash
Read, write, configure Mesa Electronics FPGA cards.
.SH OPTIONS
.TP
.BI --device " name"
Select active device name. If no command is given it will detect board
with given name and print info about it.
The special values "ETHER", "SPI" and "AUTO" will attempt to detect a device
on ethernet, SPI, or any interface; --addr still needs to be specified for
non-PCI devices.
.TP
.BI --addr " [ip]|[device]"
Use ip or device name to look for <name> (IP address for Ethernet boards,
serial device name for USB boards and serial boards, SPI device name for
SPI boards)
.TP
.B --addr_hi
Set the high register address for the EPP interface.
.TP
.B --epp
Use EPP interface to connect to board, only for boards with multiple
interfaces (7i43, 7i90, 7i64).
.TP
.B --usb
Use USB interface to connect to board, only for boards with multiple
interfaces (7i43, 7i90, 7i64).
.TP
.B --spi
Use SPI interface to connect to board, only for boards with multiple
interfaces (7i43, 7i90, 7i64).
.TP
.B --serial
Use serial interface to connect to board, only for boards with multiple
interfaces (7i43, 7i90, 7i64).
.TP
.B --fallback
Use the fallback area of the EEPROM while executing commands.
.TP
.B --recover
Access board using PCI bridge GPIO (currently only 6I24/6I25).
.TP
.B --xml
Format output from 'readhmid' command into XML.
.TP
.B --verbose
Print detailed information while running commands.
.SH COMMANDS
.TP
.BI --write " filename"
Writes a standard bitfile 'filename' configuration to the userarea of
the EEPROM (IMPORTANT! 'filename' must be VALID FPGA configuration file).
.TP
.B --fix-boot-block
If a write operation does not detect a valid boot block, write one.
.TP
.B --no-auto-verify
Don't automatically verify after writing.
.TP
.BI --verify " filename"
Verifies the EEPROM configuration against the bitfile 'filename'.
.TP
.BI --program " filename"
Writes a standard bitfile 'filename' configuration to the FPGA
(IMPORTANT! 'filename' must be VALID FPGA configuration file).
.TP
.B --readhmid
Print hostmot2 configuration in PIN file format.
.TP
.B --print-pd
Print hostmot2 Pin Descriptors.
.TP
.B --reload
Do full FPGA reload from flash (only Ethernet and pci boards).
.TP
.B --reset
Do full firmware reset (only Ethernet and serial boards).
.TP
.B --sserial
Print full information about all sserial remote boards.
.TP
.BI --rpo " address"
Read hostmot2 variable directly at 'address'.
.TP
.BI --wpo " address value"
Write hostmot2 variable directly at 'address' with 'value'.
.TP
.BI --set " ip address"
Set board IP address in eeprom to n.n.n.n (only Ethernet boards).
.TP
.BI --info " filename"
Print info about configuration in 'file_name'.
.TP
.B --help
Print the help message
.SH BUGS
No known bugs.
.SH AUTHOR
LinuxCNC Developer Community <emc-developers@lists.sourceforge.net>
.PP
Michael Geszkiewicz <micges@wp.pl>
.PP
Peter Wallace <tech@mesanet.com>
.SH COPYRIGHT
GNU GPL v2+ License
.PP
Copyright (c) 2020 Sebastian Kuzminsky
.PP
Copyright (c) 2019 Peter Wallace
.PP
Copyright (c) 2013-2015 Michael Geszkiewicz

View file

@ -1,5 +1,7 @@
//
// Copyright (C) 2013-2014 Michael Geszkiewicz
// Copyright (C) 2020 Sebastian Kuzminsky <seb@highlab.com>
// Copyright (C) 2013-2015 Michael Geszkiewicz
// Copyright (C) Mesa Electronics
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@ -29,6 +31,10 @@
#include "libpci/pci.h"
#endif
#ifndef VERSION
#define VERSION "3.4.0~pre1"
#endif
static int device_flag;
static int addr_flag;
static int addr_hi_flag;
@ -40,6 +46,7 @@ static int fallback_flag;
static int recover_flag;
static int program_flag;
static int readhmid_flag;
static int print_pd_flag;
static int reload_flag;
static int reset_flag;
static int sserial_flag;
@ -72,6 +79,7 @@ static struct option long_options[] = {
{"recover", no_argument, &recover_flag, 1},
{"program", required_argument, 0, 'p'},
{"readhmid", no_argument, &readhmid_flag, 1},
{"print-pd", no_argument, &print_pd_flag, 1},
{"reload", no_argument, &reload_flag, 1},
{"reset", no_argument, &reset_flag, 1},
{"sserial", no_argument, &sserial_flag, 1},
@ -90,10 +98,8 @@ static struct option long_options[] = {
};
void print_short_usage() {
printf("\nMesaflash version 3.3.0~pre (built on %s %s with libpci %s)\n", __DATE__, __TIME__, PCILIB_VERSION);
printf("Configuration and diagnostic tool for Mesa Electronics PCI(E)/ETH/EPP/USB boards\n");
printf("(C) 2013-2015 Michael Geszkiewicz (contact: micges@wp.pl)\n");
printf("(C) Mesa Electronics\n");
printf("Mesaflash version %s\n", VERSION);
printf("Configuration and diagnostic tool for Mesa Electronics PCI(E)/ETH/EPP/USB/SPI boards\n");
printf("Try 'mesaflash --help' for more information\n");
}
@ -111,34 +117,55 @@ void print_usage() {
printf(" mesaflash --device device_name [options] --set ip=n.n.n.n\n");
printf(" mesaflash --info file_name\n");
printf(" mesaflash --help\n");
printf("\nOptions:\n");
printf(" --device select active device name. If no command is given it will detect board with given name and print info about it.\n");
printf(" --addr <device_address>\n");
printf(" select <device address> for looking for <device_name> (network C mask for ethernet boards, serial port for USB boards)\n");
printf(" --addr_hi set the high register address for the EPP interface\n");
printf(" --epp use EPP interface to connect to board, only for boards with multiple interfaces (7i43, 7i90, 7i64)\n");
printf(" --usb use USB interface to connect to board, only for boards with multiple interfaces (7i43, 7i90, 7i64)\n");
printf(" --spi use SPI interface to connect to board, only for boards with multiple interfaces (7i43, 7i90, 7i64)\n");
printf(" --serial use serial interface to connect to board, only for boards with multiple interfaces (7i43, 7i90, 7i64)\n");
printf(" --fallback use the fallback area of the EEPROM while executing commands\n");
printf(" --recover access board using PCI bridge GPIO (currently only 6I25)\n");
printf(" --xml format output from 'readhmid' command into XML\n");
printf(" --verbose print detailed information while running commands\n");
printf("\nCommands:\n");
printf(" --write writes a standard bitfile 'filename' configuration to the userarea of the EEPROM (IMPORTANT! 'filename' must be VALID FPGA configuration file)\n");
printf(" --fix-boot-block If a write operation does not detect a valid boot block, write one\n");
printf(" --no-auto-verify Don't automatically verify after writing\n");
printf(" --verify verifies the EEPROM configuration against the bitfile 'filename'\n");
printf(" --program writes a standard bitfile 'filename' configuration to the FPGA (IMPORTANT! 'filename' must be VALID FPGA configuration file)\n");
printf(" --readhmid print hostmot2 configuration in PIN file format\n");
printf(" --reload do full FPGA reload from flash (only ethernet and pci boards)\n");
printf(" --reset do full firmware reset (only ethernet boards)\n");
printf(" --sserial print full information about all sserial remote boards\n");
printf(" --rpo read hostmot2 variable directly at 'address'\n");
printf(" --wpo write hostmot2 variable directly at 'address' with 'value'\n");
printf(" --set set board IP address in eeprom to n.n.n.n (only ethernet boards)\n");
printf(" --info print info about configuration in 'file_name'\n");
printf(" --help print this help message\n");
printf("\n");
printf("Options:\n");
printf(" --device <name> Select active device name. If no command is given it\n");
printf(" will detect board with given name and print info\n");
printf(" about it.\n");
printf(" --addr <dev> Select <dev> for looking for <name> (IP address for\n");
printf(" Ethernet boards, serial device name for USB boards\n");
printf(" and serial boards, SPI device name for SPI boards)\n");
printf(" --addr_hi Set the high register address for the EPP interface.\n");
printf(" --epp Use EPP interface to connect to board, only for boards\n");
printf(" with multiple interfaces (7c80, 7c81, 7i43, 7i90, 7i64).\n");
printf(" --usb Use USB interface to connect to board, only for boards\n");
printf(" with multiple interfaces (7c80, 7c81, 7i43, 7i90, 7i64).\n");
printf(" --spi Use SPI interface to connect to board, only for boards\n");
printf(" with multiple interfaces (7c80, 7c81, 7i43, 7i90, 7i64).\n");
printf(" --serial Use serial interface to connect to board, only for\n");
printf(" boards with multiple interfaces (7i43, 7i90, 7i64).\n");
printf(" --fallback Use the fallback area of the EEPROM while executing\n");
printf(" commands.\n");
printf(" --recover Access board using PCI bridge GPIO (currently\n");
printf(" only 6I24/6I25).\n");
printf(" --xml Format output from 'readhmid' command into XML.\n");
printf(" --verbose Print detailed information while running commands.\n");
printf("\n");
printf("Commands:\n");
printf(" --write Writes a standard bitfile 'filename' configuration to\n");
printf(" the userarea of the EEPROM (IMPORTANT! 'filename' must\n");
printf(" be VALID FPGA configuration file).\n");
printf(" --fix-boot-block If a write operation does not detect a valid boot\n");
printf(" block, write one.\n");
printf(" --no-auto-verify Don't automatically verify after writing.\n");
printf(" --verify Verifies the EEPROM configuration against the\n");
printf(" bitfile 'filename'.\n");
printf(" --program Writes a standard bitfile 'filename' configuration to\n");
printf(" the FPGA (IMPORTANT! 'filename' must be VALID FPGA\n");
printf(" configuration file).\n");
printf(" --readhmid Print hostmot2 configuration in PIN file format.\n");
printf(" --print-pd Print hostmot2 Pin Descriptors.\n");
printf(" --reload Do full FPGA reload from flash (only Ethernet, SPI and\n");
printf(" PCI boards).\n");
printf(" --reset Do full firmware reset (only Ethernet and serial boards).\n");
printf(" --sserial Print full information about all sserial remote boards.\n");
printf(" --rpo Read hostmot2 variable directly at 'address'.\n");
printf(" --wpo Write hostmot2 variable directly at 'address'\n");
printf(" with 'value'.\n");
printf(" --set Set board IP address in eeprom to n.n.n.n (only\n");
printf(" Ethernet boards).\n");
printf(" --info Print info about configuration in 'file_name'.\n");
printf(" --help Print this help message.\n");
}
int process_cmd_line(int argc, char *argv[]) {
@ -203,7 +230,12 @@ int process_cmd_line(int argc, char *argv[]) {
printf("Error: multiple --write options\n");
exit(-1);
}
strncpy(bitfile_name, optarg, 255);
size_t len = strlen(optarg);
if (len+1 > sizeof(bitfile_name)) {
printf("--write argument too long (max %zu)\n", sizeof(bitfile_name)-1);
return 1;
}
strcpy(bitfile_name, optarg);
write_flag++;
}
break;
@ -213,7 +245,12 @@ int process_cmd_line(int argc, char *argv[]) {
printf("Error: multiple --program options\n");
exit(-1);
}
strncpy(bitfile_name, optarg, 255);
size_t len = strlen(optarg);
if (len+1 > sizeof(bitfile_name)) {
printf("--program argument too long (max %zu)\n", sizeof(bitfile_name)-1);
return 1;
}
strcpy(bitfile_name, optarg);
program_flag++;
}
break;
@ -285,7 +322,12 @@ int process_cmd_line(int argc, char *argv[]) {
printf("Error: multiple --verify options\n");
exit(-1);
}
strncpy(bitfile_name, optarg, 255);
size_t len = strlen(optarg);
if (len+1 > sizeof(bitfile_name)) {
printf("--verify argument too long (max %zu)\n", sizeof(bitfile_name)-1);
return 1;
}
strcpy(bitfile_name, optarg);
verify_flag++;
}
break;
@ -295,7 +337,12 @@ int process_cmd_line(int argc, char *argv[]) {
printf("Error: multiple --info options\n");
exit(-1);
}
strncpy(bitfile_name, optarg, 255);
size_t len = strlen(optarg);
if (len+1 > sizeof(bitfile_name)) {
printf("--info argument too long (max %zu)\n", sizeof(bitfile_name)-1);
return 1;
}
strcpy(bitfile_name, optarg);
info_flag++;
}
break;
@ -353,6 +400,7 @@ int main(int argc, char *argv[]) {
exit(1);
ret = anyio_find_dev(&access);
if (ret < 0) {
printf("No %s board found\n", access.device_name);
return -1;
}
board = anyio_get_dev(&access, 1);
@ -365,6 +413,8 @@ int main(int argc, char *argv[]) {
if (readhmid_flag == 1) {
anyio_dev_print_hm2_info(board, xml_flag);
} else if (print_pd_flag == 1) {
anyio_dev_print_pin_descriptors(board);
} else if (sserial_flag == 1) {
anyio_dev_print_sserial_info(board);
} else if (rpo_flag == 1) {

View file

@ -16,9 +16,11 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
#if MESAFLASH_IO
#ifdef __linux__
#include <sys/mman.h>
#include <sys/io.h>
#include <sys/time.h>
#include <pci/pci.h>
#elif _WIN32
#include <windows.h>
@ -29,8 +31,8 @@
#include <sys/time.h>
#include <unistd.h>
#include <fcntl.h>
#include <inttypes.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include "types.h"
@ -767,6 +769,10 @@ static int pci_board_open(board_t *board) {
if (board->mem_base != 0) {
#ifdef __linux__
board->base = mmap(0, board->len, PROT_READ | PROT_WRITE, MAP_SHARED, memfd, board->mem_base);
if (board->base == NULL || board->base == MAP_FAILED) {
perror("mmap pci");
abort();
}
#elif _WIN32
board->base = map_memory(board->mem_base, board->len, &(board->mem_handle));
#endif
@ -811,7 +817,10 @@ int pci_boards_init(board_access_t *access) {
memfd = open("/dev/mem", O_RDWR);
eno = errno;
seteuid(getuid());
if (seteuid(getuid()) != 0) {
printf("Failed to restore euid: %s\n", strerror(errno));
return -1;
}
if (memfd < 0) {
printf("%s can't open /dev/mem: %s", __func__, strerror(eno));
return -1;
@ -848,7 +857,7 @@ void pci_boards_scan(board_access_t *access) {
board_init_struct(board);
if ((dev->vendor_id == VENDORID_XIO2001) && (dev->device_id == DEVICEID_XIO2001)) {
board->type = BOARD_PCI;
strncpy(board->llio.board_name, "6I25 (RECOVER)", 14);
strcpy(board->llio.board_name, "6I25 (RECOVER)");
board->llio.num_ioport_connectors = 2;
board->llio.pins_per_connector = 17;
board->llio.ioport_connector_name[0] = "P3";
@ -882,7 +891,7 @@ void pci_boards_scan(board_access_t *access) {
if (dev->vendor_id == VENDORID_MESAPCI) {
if (dev->device_id == DEVICEID_MESA4I74) {
board->type = BOARD_PCI;
strncpy((char *) board->llio.board_name, "4I74", 4);
strcpy((char *) board->llio.board_name, "4I74");
board->llio.num_ioport_connectors = 3;
board->llio.pins_per_connector = 24;
board->llio.ioport_connector_name[0] = "P1";
@ -909,7 +918,7 @@ void pci_boards_scan(board_access_t *access) {
boards_count++;
} else if (dev->device_id == DEVICEID_MESA5I24) {
board->type = BOARD_PCI;
strncpy((char *) board->llio.board_name, "5I24", 4);
strcpy(board->llio.board_name, "5I24");
board->llio.num_ioport_connectors = 3;
board->llio.pins_per_connector = 24;
board->llio.ioport_connector_name[0] = "P4";
@ -937,7 +946,7 @@ void pci_boards_scan(board_access_t *access) {
boards_count++;
} else if (dev->device_id == DEVICEID_MESA5I25) {
board->type = BOARD_PCI;
strncpy((char *) board->llio.board_name, "5I25", 4);
strcpy(board->llio.board_name, "5I25");
board->llio.num_ioport_connectors = 2;
board->llio.pins_per_connector = 17;
board->llio.ioport_connector_name[0] = "P3";
@ -964,7 +973,7 @@ void pci_boards_scan(board_access_t *access) {
boards_count++;
} else if (dev->device_id == DEVICEID_MESA6I24) {
board->type = BOARD_PCI;
strncpy((char *) board->llio.board_name, "6I24", 4);
strcpy(board->llio.board_name, "6I24");
board->llio.num_ioport_connectors = 3;
board->llio.pins_per_connector = 24;
board->llio.ioport_connector_name[0] = "P4";
@ -992,7 +1001,7 @@ void pci_boards_scan(board_access_t *access) {
boards_count++;
} else if (dev->device_id == DEVICEID_MESA6I25) {
board->type = BOARD_PCI;
strncpy(board->llio.board_name, "6I25", 4);
strcpy(board->llio.board_name, "6I25");
board->llio.num_ioport_connectors = 2;
board->llio.pins_per_connector = 17;
board->llio.ioport_connector_name[0] = "P3";
@ -1023,7 +1032,7 @@ void pci_boards_scan(board_access_t *access) {
u16 ssid = pci_read_word(dev, PCI_SUBSYSTEM_ID);
if (ssid == SUBDEVICEID_MESA5I20) {
board->type = BOARD_PCI;
strncpy(board->llio.board_name, "5I20", 4);
strcpy(board->llio.board_name, "5I20");
board->llio.num_ioport_connectors = 3;
board->llio.pins_per_connector = 24;
board->llio.ioport_connector_name[0] = "P2";
@ -1053,7 +1062,7 @@ void pci_boards_scan(board_access_t *access) {
plx9030_fixup_LASxBRD_READY(&(board->llio));
} else if (ssid == SUBDEVICEID_MESA4I65) {
board->type = BOARD_PCI;
strncpy(board->llio.board_name, "4I65", 4);
strcpy(board->llio.board_name, "4I65");
board->llio.num_ioport_connectors = 3;
board->llio.pins_per_connector = 24;
board->llio.ioport_connector_name[0] = "P1";
@ -1086,7 +1095,7 @@ void pci_boards_scan(board_access_t *access) {
u16 ssid = pci_read_word(dev, PCI_SUBSYSTEM_ID);
if ((ssid == SUBDEVICEID_MESA4I68_OLD) || (ssid == SUBDEVICEID_MESA4I68)) {
board->type = BOARD_PCI;
strncpy(board->llio.board_name, "4I68", 4);
strcpy(board->llio.board_name, "4I68");
board->llio.num_ioport_connectors = 3;
board->llio.pins_per_connector = 24;
board->llio.ioport_connector_name[0] = "P1";
@ -1114,7 +1123,7 @@ void pci_boards_scan(board_access_t *access) {
boards_count++;
} else if (ssid == SUBDEVICEID_MESA5I21) {
board->type = BOARD_PCI;
strncpy(board->llio.board_name, "5I21", 4);
strcpy(board->llio.board_name, "5I21");
board->llio.num_ioport_connectors = 2;
board->llio.pins_per_connector = 32;
board->llio.ioport_connector_name[0] = "P1";
@ -1141,7 +1150,7 @@ void pci_boards_scan(board_access_t *access) {
boards_count++;
} else if ((ssid == SUBDEVICEID_MESA5I22_10) || (ssid == SUBDEVICEID_MESA5I22_15)) {
board->type = BOARD_PCI;
strncpy(board->llio.board_name, "5I22", 4);
strcpy(board->llio.board_name, "5I22");
board->llio.num_ioport_connectors = 4;
board->llio.pins_per_connector = 24;
board->llio.ioport_connector_name[0] = "P2";
@ -1174,7 +1183,7 @@ void pci_boards_scan(board_access_t *access) {
boards_count++;
} else if (ssid == SUBDEVICEID_MESA5I23) {
board->type = BOARD_PCI;
strncpy(board->llio.board_name, "5I23", 4);
strcpy(board->llio.board_name, "5I23");
board->llio.num_ioport_connectors = 3;
board->llio.pins_per_connector = 24;
board->llio.ioport_connector_name[0] = "P2";
@ -1202,7 +1211,7 @@ void pci_boards_scan(board_access_t *access) {
boards_count++;
} else if ((ssid == SUBDEVICEID_MESA4I69_16) || (ssid == SUBDEVICEID_MESA4I69_25)) {
board->type = BOARD_PCI;
strncpy(board->llio.board_name, "4I69", 4);
strcpy(board->llio.board_name, "4I69");
board->llio.num_ioport_connectors = 3;
board->llio.pins_per_connector = 24;
board->llio.ioport_connector_name[0] = "P1";
@ -1237,7 +1246,7 @@ void pci_boards_scan(board_access_t *access) {
u16 ssid = pci_read_word(dev, PCI_SUBSYSTEM_ID);
if ((ssid == SUBDEVICEID_MESA3X20_10) || (ssid == SUBDEVICEID_MESA3X20_15) || (ssid == SUBDEVICEID_MESA3X20_20)) {
board->type = BOARD_PCI;
strncpy(board->llio.board_name, "3X20", 4);
strcpy(board->llio.board_name, "3X20");
board->llio.num_ioport_connectors = 6;
board->llio.pins_per_connector = 24;
board->llio.ioport_connector_name[0] = "P4";
@ -1278,7 +1287,7 @@ void pci_boards_scan(board_access_t *access) {
}
} else if (dev->device_id == DEVICEID_PLX8112) {
board->type = BOARD_PCI;
strncpy(board->llio.board_name, "5I71", 4);
strcpy(board->llio.board_name, "5I71");
board->open = &pci_board_open;
board->close = &pci_board_close;
board->print_info = &pci_print_info;
@ -1311,7 +1320,7 @@ void pci_print_info(board_t *board) {
show_formatted_size(board->dev->size[i]);
printf("\n");
} else {
printf(" Region %d: Memory at %08X", i, (unsigned int) board->dev->base_addr[i]);
printf(" Region %d: Memory at %016" PRIx64, i, board->dev->base_addr[i]);
show_formatted_size(board->dev->size[i]);
printf("\n");
}
@ -1323,7 +1332,8 @@ void pci_print_info(board_t *board) {
if (board->data_base_addr > 0)
printf(" Data I/O addr: %04X\n", board->data_base_addr);
if (board->mem_base > 0)
printf(" Memory: %08X\n", board->mem_base);
printf(" Memory: %016" PRIx64 "\n", board->mem_base);
show_board_info(board);
}
#endif

View file

@ -24,6 +24,7 @@
#include <string.h>
#include <errno.h>
#include <math.h>
#include <unistd.h>
#include <sys/poll.h>
#include "types.h"
#include "anyio.h"
@ -35,7 +36,7 @@
extern board_t boards[MAX_BOARDS];
extern int boards_count;
int sd;
static int sd = -1;
// serial access functions
@ -77,8 +78,15 @@ int serial_recv_packet(void *packet, int size) {
while (r < size) {
rc = ppoll(fds, 1, &timeout, NULL);
if (rc > 0) {
ret = read(sd, buffer + r, rc);
r += rc;
ret = read(sd, buffer + r, 1);
if (ret < 0) {
printf("serial read error: %s\n", strerror(errno));
return -1;
} else if (ret == 0) {
printf("serial read EOF\n");
return -1;
}
r += ret;
} else if (rc == 0) {
timeouts ++;
if (timeouts == 5) {
@ -290,7 +298,7 @@ void serial_print_info(board_t *board) {
printf(" [space 6] LBP16 control/status:\n");
printf(" packets received: all %d, good %d, bad %d\n", stat_area.RXPacketCount, stat_area.RXGoodCount, stat_area.RXBadCount);
printf(" packets sended: all %d, good %d, bad %d\n", stat_area.TXPacketCount, stat_area.TXGoodCount, stat_area.TXBadCount);
printf(" packets sent: all %d, good %d, bad %d\n", stat_area.TXPacketCount, stat_area.TXGoodCount, stat_area.TXBadCount);
printf(" parse errors: %d, mem errors %d, write errors %d\n", stat_area.LBPParseErrors, stat_area.LBPMemErrors, stat_area.LBPWriteErrors);
printf(" error flags: 0x%04X\n", stat_area.ErrorReg);
printf(" debug LED ptr: 0x%04X\n", stat_area.DebugLEDPtr);

View file

@ -16,6 +16,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
#include <ctype.h>
#include <fcntl.h>
#include <linux/spi/spidev.h>
#include <stdbool.h>
@ -28,7 +29,9 @@
#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "types.h"
#include "eeprom.h"
#include "eeprom_local.h"
#include "spi_boards.h"
#include "common.h"
@ -36,9 +39,9 @@
extern board_t boards[MAX_BOARDS];
extern int boards_count;
bool canDo32 = true;
static bool canDo32 = true;
int sd = -1;
static int sd = -1;
struct spi_ioc_transfer settings;
static int spidev_set_lsb_first(int fd, u8 lsb_first) {
@ -84,7 +87,7 @@ static int spi_board_close(board_t *board) {
}
int spi_boards_init(board_access_t *access) {
settings.speed_hz = 8 * 1000 * 1000;
settings.speed_hz = 20 * 1000 * 1000;
settings.bits_per_word = 32;
sd = open(access->dev_addr, O_RDWR);
@ -176,6 +179,52 @@ int spi_write(llio_t *self, u32 addr, void *buffer, int size) {
return 0;
}
static int spi_board_reload(llio_t *self, int fallback_flag) {
board_t *board = self->board;
int i;
u32 boot_addr, cookie;
spi_read(&(board->llio), HM2_ICAP_REG, &cookie, sizeof(u32));
if (cookie != HM2_ICAP_COOKIE) {
printf("ERROR: Active firmware too old to support --reload\n");
return -1;
}
if (fallback_flag == 1) {
boot_addr = 0x10000;
} else {
boot_addr = 0x0;
}
boot_addr |= 0x0B000000; // plus read command in high byte
u32 data[14] = {
0xFFFF, // dummy
0xFFFF, // dummy
0xAA99, // sync
0x5566, // sync
0x3261, // load low flash start address
boot_addr & 0xFFFF, // start addr
0x3281, // load high start address + read command
boot_addr >> 16, // start addr (plus read command in high byte)
0x30A1, // load command register
0x000E, // IPROG command
0x2000, // NOP
0x2000, // NOP
0x2000, // NOP
0x2000 // NOP
};
for (i = 0; i < 14; i++) {
spi_write(&(board->llio), HM2_ICAP_REG, &data[i], sizeof(u32));
usleep(1000);
}
printf("Waiting for FPGA configuration...");
sleep(2);
printf("OK\n");
return 0;
}
void spi_boards_scan(board_access_t *access) {
u32 buf[4];
u32 cookie[] = {0x55aacafe, 0x54534f48, 0x32544f4d};
@ -187,7 +236,7 @@ void spi_boards_scan(board_access_t *access) {
}
if(memcmp(buf, cookie, sizeof(cookie))) {
fprintf(stderr, "Unexpected cookie at %04x..%04x:\n%08x %08x %08x\n",
fprintf(stderr, "Unexpected cookie at %04x..%04zx:\n%08x %08x %08x\n",
HM2_COOKIE_REG, HM2_COOKIE_REG + sizeof(buf),
buf[0], buf[1], buf[2]);
return;
@ -200,8 +249,9 @@ void spi_boards_scan(board_access_t *access) {
board_t *board = &boards[boards_count];
board->type = BOARD_SPI;
strcpy(board->dev_addr, access->dev_addr);
strncpy(board->llio.board_name, "7I90", 4);
board->llio.num_ioport_connectors = 24;
strcpy(board->llio.board_name, "7I90");
board->llio.num_ioport_connectors = 3;
board->llio.pins_per_connector = 24;
board->llio.ioport_connector_name[0] = "P1";
board->llio.ioport_connector_name[1] = "P2";
board->llio.ioport_connector_name[2] = "P3";
@ -211,6 +261,59 @@ void spi_boards_scan(board_access_t *access) {
board->llio.read = spi_read;
board->llio.write_flash = local_write_flash;
board->llio.verify_flash = local_verify_flash;
board->llio.reload = &spi_board_reload;
board->llio.fpga_part_number = "6slx9tqg144";
board->open = spi_board_open;
board->close = spi_board_close;
board->print_info = spi_print_info;
board->flash = BOARD_FLASH_HM2;
board->fallback_support = 1;
boards_count ++;
} else if(!memcmp(ident, "MESA7C80", 8)) {
board_t *board = &boards[boards_count];
board->type = BOARD_SPI;
strcpy(board->dev_addr, access->dev_addr);
strcpy(board->llio.board_name, "7C80");
board->llio.num_ioport_connectors = 2;
board->llio.pins_per_connector = 27;
board->llio.ioport_connector_name[0] = "StepGens+Misc";
board->llio.ioport_connector_name[1] = "Outputs+P1";
board->llio.bob_hint[0] = BOB_7C80_0;
board->llio.bob_hint[1] = BOB_7C80_1;
board->llio.num_leds = 4;
board->llio.verbose = access->verbose;
board->llio.write = spi_write;
board->llio.read = spi_read;
board->llio.write_flash = local_write_flash;
board->llio.verify_flash = local_verify_flash;
board->llio.reload = &spi_board_reload;
board->llio.fpga_part_number = "6slx9tqg144";
board->open = spi_board_open;
board->close = spi_board_close;
board->print_info = spi_print_info;
board->flash = BOARD_FLASH_HM2;
board->fallback_support = 1;
boards_count ++;
} else if(!memcmp(ident, "MESA7C81", 8)) {
board_t *board = &boards[boards_count];
board->type = BOARD_SPI;
strcpy(board->dev_addr, access->dev_addr);
strcpy(board->llio.board_name, "7C81");
board->llio.num_ioport_connectors = 3;
board->llio.pins_per_connector = 19;
board->llio.ioport_connector_name[0] = "P1+Serial";
board->llio.ioport_connector_name[1] = "P2+Serial";
board->llio.ioport_connector_name[2] = "P7+Serial";
board->llio.bob_hint[0] = BOB_7C81_0;
board->llio.bob_hint[1] = BOB_7C81_1;
board->llio.bob_hint[2] = BOB_7C81_2;
board->llio.num_leds = 4;
board->llio.verbose = access->verbose;
board->llio.write = spi_write;
board->llio.read = spi_read;
board->llio.write_flash = local_write_flash;
board->llio.verify_flash = local_verify_flash;
board->llio.reload = &spi_board_reload;
board->llio.fpga_part_number = "6slx9tqg144";
board->open = spi_board_open;
board->close = spi_board_close;

View file

@ -228,8 +228,8 @@ int sserial_init(sserial_module_t *ssmod, board_t *board, int interface_num, int
printf("No sserial module found.\n");
return -1;
}
if (interface_num >= HM2_SSERIAL_MAX_INTEFACES) {
printf("sserial inteface number too high.\n");
if (interface_num >= HM2_SSERIAL_MAX_INTERFACES) {
printf("sserial interface number too high.\n");
return -1;
}
if (channel_num >= HM2_SSERIAL_MAX_CHANNELS) {
@ -286,7 +286,7 @@ int sserial_init(sserial_module_t *ssmod, board_t *board, int interface_num, int
board->llio.read(&(ssmod->board->llio), ssmod->base_address + HM2_MOD_OFFS_SSERIAL_CS + interface_num*ssmod->instance_stride + channel_num*4, &(status), sizeof(u32));
board->llio.read(&(ssmod->board->llio), ssmod->base_address + HM2_MOD_OFFS_SSERIAL_INTERFACE0 + interface_num*ssmod->instance_stride + channel_num*4, &(status), sizeof(u32));
if ((status & 0xFF000000) != remote_type) {
printf("Found wrong remote at %d:%d, reqeust %x but found %x\n", interface_num, channel_num, remote_type, status);
printf("Found wrong remote at %d:%d, request %x but found %x\n", interface_num, channel_num, remote_type, status);
return -1;
}
ssmod->device.unit = status;
@ -475,8 +475,13 @@ void sserial_module_init(llio_t *llio) {
sslbp_read_remote_bytes(ssmod, port, channel, d, &(sserial_md), sizeof(sserial_md_t));
sslbp_read_remote_bytes(ssmod, port, channel, d + sizeof(sserial_md_t), &(name), -1);
if (sserial_md.mode_type == 0x01) {
llio->ss_device[channel].sw_modes[llio->ss_device[channel].sw_modes_cnt].index = sserial_md.mode_index;
strncpy(llio->ss_device[channel].sw_modes[llio->ss_device[channel].sw_modes_cnt].name, name, strlen(name));
sw_mode_t *sw_mode = &llio->ss_device[channel].sw_modes[llio->ss_device[channel].sw_modes_cnt];
if (strlen(name)+1 > sizeof(sw_mode->name)) {
printf("name too long while reading LBP_MODE (max %zu)\n", sizeof(sw_mode->name)-1);
abort();
}
sw_mode->index = sserial_md.mode_index;
strcpy(sw_mode->name, name);
llio->ss_device[channel].sw_modes_cnt++;
}
}

View file

@ -144,7 +144,7 @@ void usb_boards_scan(board_access_t *access) {
board->type = BOARD_USB;
board->mode = BOARD_MODE_FPGA;
strcpy(board->dev_addr, access->dev_addr);
strncpy(board->llio.board_name, "7I43", 4);
strcpy(board->llio.board_name, "7I43");
board->llio.num_ioport_connectors = 2;
board->llio.pins_per_connector = 24;
board->llio.ioport_connector_name[0] = "P3";
@ -185,7 +185,7 @@ void usb_boards_scan(board_access_t *access) {
board->type = BOARD_USB;
board->mode = BOARD_MODE_CPLD;
strcpy(board->dev_addr, access->dev_addr);
strncpy(board->llio.board_name, "7I43", 4);
strcpy(board->llio.board_name, "7I43");
board->llio.num_ioport_connectors = 2;
board->llio.pins_per_connector = 24;
board->llio.ioport_connector_name[0] = "P3";

View file

@ -1,23 +0,0 @@
#ifndef WINIO_H
#define WINIO_H
#include "winio_nt.h"
typedef struct tagPhysStruct tagPhysStruct_t;
BOOL InitializeWinIo();
void ShutdownWinIo();
PBYTE MapPhysToLin(tagPhysStruct_t *PhysStruct);
BOOL UnmapPhysicalMemory(tagPhysStruct_t *PhysStruct);
BOOL GetPhysLong(PBYTE pbPhysAddr, PDWORD pdwPhysVal);
BOOL SetPhysLong(PBYTE pbPhysAddr, DWORD dwPhysVal);
BOOL GetPortVal(WORD wPortAddr, PDWORD pdwPortVal, BYTE bSize);
BOOL SetPortVal(WORD wPortAddr, DWORD dwPortVal, BYTE bSize);
BOOL InstallWinIoDriver(PWSTR pszWinIoDriverPath, BOOL IsDemandLoaded);
BOOL RemoveWinIoDriver();
extern HANDLE hDriver;
extern BOOL IsWinIoInitialized;
extern BOOL g_Is64BitOS;
#endif

View file

@ -1,69 +0,0 @@
#ifndef WINIONT_H
#define WINIONT_H
// Define the various device type values. Note that values used by Microsoft
// Corporation are in the range 0-32767, and 32768-65535 are reserved for use
// by customers.
#define FILE_DEVICE_WINIO 0x00008010
// Macro definition for defining IOCTL and FSCTL function control codes.
// Note that function codes 0-2047 are reserved for Microsoft Corporation,
// and 2048-4095 are reserved for customers.
#define WINIO_IOCTL_INDEX 0x810
// Define our own private IOCTL
#define IOCTL_WINIO_MAPPHYSTOLIN CTL_CODE(FILE_DEVICE_WINIO, \
WINIO_IOCTL_INDEX, \
METHOD_BUFFERED, \
FILE_ANY_ACCESS)
#define IOCTL_WINIO_UNMAPPHYSADDR CTL_CODE(FILE_DEVICE_WINIO, \
WINIO_IOCTL_INDEX + 1, \
METHOD_BUFFERED, \
FILE_ANY_ACCESS)
#define IOCTL_WINIO_ENABLEDIRECTIO CTL_CODE(FILE_DEVICE_WINIO, \
WINIO_IOCTL_INDEX + 2, \
METHOD_BUFFERED, \
FILE_ANY_ACCESS)
#define IOCTL_WINIO_DISABLEDIRECTIO CTL_CODE(FILE_DEVICE_WINIO, \
WINIO_IOCTL_INDEX + 3, \
METHOD_BUFFERED, \
FILE_ANY_ACCESS)
#define IOCTL_WINIO_READPORT CTL_CODE(FILE_DEVICE_WINIO, \
WINIO_IOCTL_INDEX + 4, \
METHOD_BUFFERED, \
FILE_ANY_ACCESS)
#define IOCTL_WINIO_WRITEPORT CTL_CODE(FILE_DEVICE_WINIO, \
WINIO_IOCTL_INDEX + 5, \
METHOD_BUFFERED, \
FILE_ANY_ACCESS)
#pragma pack(push)
#pragma pack(1)
struct tagPhysStruct
{
DWORD64 dwPhysMemSizeInBytes;
DWORD64 pvPhysAddress;
DWORD64 PhysicalMemoryHandle;
DWORD64 pvPhysMemLin;
DWORD64 pvPhysSection;
};
struct tagPortStruct
{
USHORT wPortAddr;
ULONG dwPortVal;
UCHAR bSize;
};
#pragma pack(pop)
#endif