Skip to content

Commit

Permalink
Initial release.
Browse files Browse the repository at this point in the history
  • Loading branch information
uecasm committed Apr 6, 2017
1 parent 2e014ed commit 803493e
Show file tree
Hide file tree
Showing 20 changed files with 378 additions and 0 deletions.
61 changes: 61 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# mxser

This repository contains a Debianized version of the official [MOXA Smartio/Industio Linux serial driver](http://www.moxa.com/support/download.aspx?type=support&id=1122).

While some in-kernel drivers exist, this version is preferred because it is currently the only one that fully supports card configuration (such as selectible termination and cards that can switch between 232/422/485).

It is mostly intended for private use and is not expected to get picked up by the official Debian repository, partly because I'm a newbie maintainer and have probably violated policies but also because the upstream package contains some prebuilt binaries without source and is thus only buildable on limited architectures. However it has been published for general use in the hope that others will find it useful. (And perhaps to learn some tricks from any experienced maintainers who spot something I did incorrectly.)

Some of the packaging metadata assumes you're compiling it for kernel 4.9 (and for Debian Stretch), but this should be trivially editable for any other version -- if there's some magic way to make this pick up the correct version automatically, then please let me know.

## Packages

* **mxser-dkms**
This is a DKMS-compatible package containing driver source code, such that the corresponding kernel modules `mxser` and `mxupcie` can be built for (hopefully) any arbitrary Linux kernel, provided that the corresponding **linux-headers** package is installed (or full source is) along with a suitable compiler.

Simply installing this package is usually sufficient to compile and install the drivers for your current kernel.

* **mxser-tools**
This contains the userland tools from the official driver package:

* `muestty`
Device configuration tool for MUE series PCI Express multiport boards.

* `msdiag`
Diagnostic program for displaying installed Moxa Smartio/Industio boards.

* `msmon`
Monitor program to observe data count and line status signals.

* `msterm`
A simple terminal program which is useful in testing serial ports.

More information can be found in the readme.txt file from the original vendor package, which will also be installed to `/usr/share/doc/mxser-tools/`.

## Installing from a Release

I've uploaded some pre-built packages in the Releases tab, to make life easier. Just download them and `dpkg -i` them as discussed further below. Of course, this assumes that you're using a compatible system (currently Debian Stretch).

## Installing from Source

The below assumes you have `git-buildpackage` installed. Without that you can still build this but you'll need different commands.

gbp clone [--pristine-tar] https://github.com/uecasm/mxser.git
cd mxser
gbp buildpackage -us -uc

This should create the appropriate `.deb` packages in `../build-area/`. Currently it will also print some `lintian` errors (some of which I have no intention of fixing due to upstream limitations), but it should at least produce the packages.

(If you don't want to use `git-buildpackage`, then you should just be able to `git clone` the repository and then `debuild` or `dpkg-buildpackage` it instead, but you'll need to extract the pristine tarball first.)

You can use `dpkg -i` to install the packages, as usual.

## Installing modules on an embedded system

If you want to install the kernel modules onto a system that does not have compilers installed, then you'll first need to install the dkms module onto a compatible machine or chroot (ideally a clone, but mainly just the same architecture and kernel) that *does* have the compilers installed.

Once the modules have been built (and for the same kernel as on the target machine) you can use the following command to export a package containing only the compiled modules that can be installed on a machine without compilers:

dkms mkbmdeb mxser/1.16+14030317 --all

(Or specify a specific kernel version to export; see the DKMS docs for more information.)
5 changes: 5 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mxser (1.16+14030317-1) UNRELEASED; urgency=medium

* Initial release.

-- Gavin Lambert <[email protected]> Wed, 05 Apr 2017 17:52:40 +1200
1 change: 1 addition & 0 deletions debian/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9
33 changes: 33 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# In non-free because upstream (and hence mxser-tools) contains prebuilt
# libraries without source (which also causes the limited Architecture).
# Though theoretically everything is GPL...

Source: mxser
Section: non-free/kernel
Priority: extra
Maintainer: Gavin Lambert <[email protected]>
Build-Depends: debhelper (>=9), dkms, linux-libc-dev, linux-kbuild-4.9
Standards-Version: 3.9.8
Homepage: http://www.moxa.com/support/download.aspx?type=support&id=1122

Package: mxser-dkms
Architecture: linux-any
Multi-Arch: foreign
Depends: ${misc:Depends}, linux-kbuild-4.9
Recommends: mxser-tools
Description: DKMS files to build and install mxser and mxupcie
Drivers for MOXA serial port adapters.
.
This package contains the DKMS files to build and install mxser and mxupcie.
.
To install this package, you have to install the header files for your current
kernel manually (usually included in the "linux-headers-<your architecture>").

Package: mxser-tools
Architecture: i386 amd64
Depends: ${misc:Depends}
Recommends: mxser-dkms
Description: Tools to configure or test mxser/mxupcie serial adapters.
Drivers for MOXA serial port adapters.
.
This package contains utilities needed to configure and test the adapters.
28 changes: 28 additions & 0 deletions debian/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: mxser
Source: http://www.moxa.com/support/download.aspx?type=support&id=1122

Files: *
Copyright: 2009-2014 Moxa Inc. <[email protected]>
License: GPL-2.0+

Files: debian/*
Copyright: 2017 Gavin Lambert <[email protected]>
License: GPL-2.0+

License: GPL-2.0+
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, see <http://www.gnu.org/licenses/>.
.
On Debian systems, the complete text of the GNU General Public License
Version 2 can be found in `/usr/share/common-licenses/GPL-2'.
5 changes: 5 additions & 0 deletions debian/gbp.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[DEFAULT]
pristine-tar = True

[buildpackage]
export-dir = ../build-area/
13 changes: 13 additions & 0 deletions debian/mxser-dkms.README.Debian
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
mxser/mxupcie for Debian

The kernel modules for the MOXA Smartio/Industio family of serial adapters
are provided as a dkms source package. Installing it should automatically
build and install the drivers into your current kernel, and optionally all
others installed on your system. (See the DKMS manpages for more info.)

The readme.txt.gz and VERSION.txt.gz files are compressed copies of the
vendor-supplied documentation, which have some more details about the
driver and changelog. The build instructions in those files don't apply
to this packaged version, of course.

-- Gavin Lambert <[email protected]> Tue, 04 Apr 2017 17:30:12 +1200
12 changes: 12 additions & 0 deletions debian/mxser-dkms.dkms
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
PACKAGE_NAME="mxser"
PACKAGE_VERSION="1.16+14030317"

CLEAN="make KERNELRELEASE=${kernelver} clean"
MAKE[0]="make all"
BUILT_MODULE_NAME[0]="mxser"
BUILT_MODULE_NAME[1]="mxupcie"
BUILT_MODULE_LOCATION[0]="driver/"
BUILT_MODULE_LOCATION[1]="driver/"
DEST_MODULE_LOCATION[0]="/kernel/drivers/char/"
DEST_MODULE_LOCATION[1]="/kernel/drivers/char/"
AUTOINSTALL="yes"
2 changes: 2 additions & 0 deletions debian/mxser-dkms.docs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
readme.txt
VERSION.txt
11 changes: 11 additions & 0 deletions debian/mxser-tools.README.Debian
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
mxser/mxupcie for Debian

The configuration and test utilities are provided as compiled binaries, as
usual. Of these, probably the most useful is the muestty utility. Man
pages haven't been provided for them, but they do include some help.

The vendor-supplied documentation is included in the mxser-dkms package,
and not reproduced here. With that package installed, look in
/usr/share/doc/mxser-dkms/ for more information.

-- Gavin Lambert <[email protected]> Tue, 04 Apr 2017 17:30:12 +1200
4 changes: 4 additions & 0 deletions debian/mxser-tools.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
usr/bin/msdiag
usr/bin/msmon
usr/bin/msterm
usr/bin/muestty
69 changes: 69 additions & 0 deletions debian/patches/01-install-destdir.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
Support install into $DESTDIR.
--- a/utility/conf/Makefile
+++ b/utility/conf/Makefile
@@ -5,7 +5,7 @@
all: muestty

install: muestty
- @cp -f muestty /usr/bin
+ @install muestty $(DESTDIR)/usr/bin/

muestty: $(FILES)
@cc $(FILES) -o muestty
@@ -18,4 +18,4 @@
@rm -f muestty

uninstall:
- @rm -f /usr/bin/muestty
+ @rm -f $(DESTDIR)/usr/bin/muestty
--- a/utility/diag/Makefile
+++ b/utility/diag/Makefile
@@ -4,7 +4,7 @@
all: msdiag

install: msdiag
- @cp -p msdiag /usr/bin
+ @install msdiag $(DESTDIR)/usr/bin/

msdiag: $(FILES)
@cc $(FILES) -o msdiag
@@ -20,4 +20,4 @@
@rm -f msdiag

uninstall:
- @rm -f /usr/bin/msdiag
+ @rm -f $(DESTDIR)/usr/bin/msdiag
--- a/utility/mon/Makefile
+++ b/utility/mon/Makefile
@@ -12,7 +12,7 @@
all: msmon

install: msmon
- @cp -p msmon /usr/bin
+ @install msmon $(DESTDIR)/usr/bin/

msmon: $(FILES)
@cc $(FILES) -o msmon
@@ -33,4 +33,4 @@
@rm -f msmon

uninstall:
- @rm -f /usr/bin/msmon
+ @rm -f $(DESTDIR)/usr/bin/msmon
--- a/utility/term/Makefile
+++ b/utility/term/Makefile
@@ -12,7 +12,7 @@
all: msterm

install: msterm
- @cp -p msterm /usr/bin
+ @install msterm $(DESTDIR)/usr/bin/

msterm: $(FILES)
@cc $(FILES) -o msterm
@@ -44,4 +44,4 @@
@rm -f msterm

uninstall:
- @rm -f /usr/bin/msterm
+ @rm -f $(DESTDIR)/usr/bin/msterm
45 changes: 45 additions & 0 deletions debian/patches/02-static-patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Ensure tools are linked statically.
--- a/utility/conf/Makefile
+++ b/utility/conf/Makefile
@@ -8,7 +8,7 @@
@install muestty $(DESTDIR)/usr/bin/

muestty: $(FILES)
- @cc $(FILES) -o muestty
+ @cc -static $(FILES) -o muestty

conftool.o: conftool.c
@$(CC) conftool.c $(HDR_DIR)
--- a/utility/diag/Makefile
+++ b/utility/diag/Makefile
@@ -7,7 +7,7 @@
@install msdiag $(DESTDIR)/usr/bin/

msdiag: $(FILES)
- @cc $(FILES) -o msdiag
+ @cc -static $(FILES) -o msdiag

diag.o: diag.c ../global.h
@$(CC) diag.c
--- a/utility/mon/Makefile
+++ b/utility/mon/Makefile
@@ -15,7 +15,7 @@
@install msmon $(DESTDIR)/usr/bin/

msmon: $(FILES)
- @cc $(FILES) -o msmon
+ @cc -static $(FILES) -o msmon


mon_p.o: mon_p.c ../global.h
--- a/utility/term/Makefile
+++ b/utility/term/Makefile
@@ -15,7 +15,7 @@
@install msterm $(DESTDIR)/usr/bin/

msterm: $(FILES)
- @cc $(FILES) -o msterm
+ @cc -static $(FILES) -o msterm

term.o: term.c term.h
@$(CC) term.c
15 changes: 15 additions & 0 deletions debian/patches/03-dkms.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Add Makefile for dkms package.
--- /dev/null
+++ b/dkms/Makefile
@@ -0,0 +1,11 @@
+KERNELRELEASE:=$(shell uname -r)
+KDIR:=/lib/modules/${KERNELRELEASE}/build
+
+MakeMod = -C ${KDIR} M=${CURDIR}/driver
+
+all:
+ ${MAKE} LVER=${KERNELRELEASE} ${MakeMod} modules
+
+clean:
+ ${MAKE} LVER=${KERNELRELEASE} ${MakeMod} clean
+ ${MAKE} LVER=${KERNELRELEASE} -C driver clean_local
33 changes: 33 additions & 0 deletions debian/patches/04-irq-disabled.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
IRQF_DISABLED has been removed as of kernel 4.1
Index: b/driver/mxpcie.h
===================================================================
--- a/driver/mxpcie.h
+++ b/driver/mxpcie.h
@@ -79,8 +79,10 @@

#if (LINUX_VERSION_CODE < VERSION_CODE(2,6,23))
#define IRQ_T(info) ((info->flags & ASYNC_SHARE_IRQ) ? SA_SHIRQ : SA_INTERRUPT)
-#else
+#elif (LINUX_VERSION_CODE < VERSION_CODE(4,1,0))
#define IRQ_T(info) ((info->flags & ASYNC_SHARE_IRQ) ? IRQF_SHARED : IRQF_DISABLED)
+#else
+#define IRQ_T(info) (IRQF_SHARED)
#endif

#ifndef MIN
Index: b/driver/mxser.c
===================================================================
--- a/driver/mxser.c
+++ b/driver/mxser.c
@@ -156,8 +156,10 @@

#if (LINUX_VERSION_CODE < VERSION_CODE(2,6,23))
#define IRQ_T(info) ((info->flags & ASYNC_SHARE_IRQ) ? SA_SHIRQ : SA_INTERRUPT)
-#else
+#elif (LINUX_VERSION_CODE < VERSION_CODE(4,1,0))
#define IRQ_T(info) ((info->flags & ASYNC_SHARE_IRQ) ? IRQF_SHARED : IRQF_DISABLED)
+#else
+#define IRQ_T(info) (IRQF_SHARED)
#endif

#ifndef MIN
4 changes: 4 additions & 0 deletions debian/patches/series
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
01-install-destdir.patch
02-static-patch
03-dkms.patch
04-irq-disabled.patch
28 changes: 28 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/make -f
export DH_VERBOSE = 1
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

VERSION ?= $(shell dpkg-parsechangelog | sed -rne 's/^Version: ([0-9.]+\+[0-9.]+)[-+].*$$/\1/p')

%:
dh $@ --with dkms

override_dh_auto_build:
dh_auto_build --buildsystem=makefile -Dutility

override_dh_strip:
dh_strip --no-automatic-dbgsym

override_dh_installdirs:
dh_installdirs
mkdir -p debian/tmp/usr/bin

override_dh_auto_install:
dh_auto_install --buildsystem=makefile -Dutility
dh_install -pmxser-dkms -X.o -X.ko driver/ usr/src/mxser-$(VERSION)
dh_install -pmxser-dkms dkms/Makefile usr/src/mxser-$(VERSION)

override_dh_dkms:
dh_dkms -V
1 change: 1 addition & 0 deletions debian/source/format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0 (quilt)
2 changes: 2 additions & 0 deletions debian/source/local-options
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
unapply-patches
extend-diff-ignore="README\.md$"
6 changes: 6 additions & 0 deletions debian/watch
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version=4
opts="pagemangle=s%<input .*hid_url.* value=(.[^"]*.) />%<a href=$1>link</a>%, \
uversionmangle=s%_build_%\+%" \
http://www.moxa.com/support/download.aspx?type=support&id=1122 \
.*driv_linux_smart_v([\d\.]+_build_\d+)\.tgz \
debian uupdate

0 comments on commit 803493e

Please sign in to comment.