ports/153963: New port: comms/uarduno USB/serial kernel module for Arduino Uno

bob frazier bobf at mrp3.com
Thu Jan 13 21:30:10 UTC 2011


>Number:         153963
>Category:       ports
>Synopsis:       New port: comms/uarduno USB/serial kernel module for Arduino Uno
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jan 13 21:30:09 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator:     bob frazier
>Release:        8-STABLE
>Organization:
S.F.T. Inc.
>Environment:
FreeBSD hack.SFT.local 8.2-PRERELEASE FreeBSD 8.2-PRERELEASE #2: Sun Jan  2 04:23:19 PST 2011     bobf at hack.SFT.local:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
New port, USB/serial kernel module that supports the Arduino Uno . Current drivers do not recognize nor support the USB interface for this device, as it uses a scaled-down version of the ACM USB serial and has its own unique vendor ID and product ID combination.  I tried modifying existing drivers to accept this combination, but none of them would work, so I modified existing kernel source and created a driver that is similar to uplcom.  The product and vendor ID combinations are stored in a text file, files/ids.txt


>How-To-Repeat:

>Fix:
shar file attached

Patch attached with submission follows:

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	uarduno
#	uarduno/files
#	uarduno/files/ids.txt
#	uarduno/pkg-descr
#	uarduno/distinfo
#	uarduno/Makefile
#	uarduno/pkg-message
#
echo c - uarduno
mkdir -p uarduno > /dev/null 2>&1
echo c - uarduno/files
mkdir -p uarduno/files > /dev/null 2>&1
echo x - uarduno/files/ids.txt
sed 's/^X//' >uarduno/files/ids.txt << '8835e31487adbe240df1b0e84c647af0'
X// Arduino UNO USB Serial Port Kernel Driver for FreeBSD
X//
X// This is a user-modifiable file that can be used to add extra
X// USB Vendor ID / Product ID combinations to the list of existing
X// combinations that the driver recognizes as an Arduino Uno.
X//
X// If you modify your Arduino Uno (or obtain a similar unit with a different
X// Vendor/Product combination) you can simply modify this file to include
X// the new Vendor/Product information.
X//
X// Place your NEW Vendor ID / Product ID combinations below in the form of
X// a C-language structure initializer entry, as follows
X//
X//     { 0xaaaa, 0xbbbb },
X//
X// Where '0xaaaa' is the vendor ID, and '0xbbbb' is the product ID that you
X// want the driver to recognize as an Arduino UNO.  It must end with a ','
X//
X// The default value of { 0x2341, 0x0001 } is already included as a reference.
X// NOTE:  do not remove or modify this entry unless you really really mean it.
X//
X// If you change this file, you will need to update it each
X// time you obtain a fresh copy of the ports tree.
X//
X//
X
X    { 0x2341, 0x0001 },  // Arduino UNO, vendor 2341H, product 0001H
X
X// place your entries below this line
X
X
X
X// end of file
X
8835e31487adbe240df1b0e84c647af0
echo x - uarduno/pkg-descr
sed 's/^X//' >uarduno/pkg-descr << 'e08707e16caa1eadff844eb52373e1aa'
XThe Arduino Uno (http://arduino.cc/) is an open source hardware micro-
Xcontroller designed primarily for prototyping and experimentation.
XAlthough the devel/arduino port already exists for programming the device,
Xit will not work properly with the newest Arduino hardware.  Previous
Xversions of the Arduino used an FTDI USB to Serial interface.  The newest
XArduino (beginning with the Uno) uses an on-board ATMel 8U2 controller
Xto emulate a USB to Serial interface with its own custom Vendor ID and
XHardware ID.  As a result, NONE of the existing FreeBSD USB to serial
Xdrivers can work with it.  This kernel driver supplies the necessary
Xkernel support for the Arduino Uno on FreeBSD.
X
XAdditionally, some 'ACM' USB Serial devices may work with this driver by
Xmanually adding their Vendor ID and Product ID combination to files/ids.txt
X
XOfficial web site
XWWW:  http://www.mrp3.com/uarduno.html
e08707e16caa1eadff844eb52373e1aa
echo x - uarduno/distinfo
sed 's/^X//' >uarduno/distinfo << '5467ae5f817096597b116ceac50c0b5f'
XSHA256 (uarduno-1.0.tar.gz) = 0deb0b39b4af3c159ce8f9311fc33fe802c1220d964d26bcbd709786aa687f58
XSIZE (uarduno-1.0.tar.gz) = 62976
5467ae5f817096597b116ceac50c0b5f
echo x - uarduno/Makefile
sed 's/^X//' >uarduno/Makefile << 'bab716c1a23b71bc35078db5dc519fea'
X# Ports collection makefile for:	uarduno
X# Date created:				11-19-2010
X# Whom:					'Big Bad Bob' Frazier <bobf at mrp3.com>
X#
X# $FreeBSD$
X#
X
XPORTNAME=	uarduno
XPORTVERSION=	1.0
XCATEGORIES=	comms kld
XMASTER_SITES=	http://mrp3.com/
X#DISTNAME=	 ${PORTNAME}-${PORTVERSION}
X
XMAINTAINER=	bobf at mrp3.com
XCOMMENT=	FreeBSD Kernel Driver for the Arduino Uno USB interface
X
XNO_PACKAGE=	You must (re)build this port with your kernel source
X
X# need to enforce installation into kernel module directory
XMAKE_ENV+=	KMODDIR=${KMODDIR}
XLOCALBASE=	${KMODDIR}
X
XSRCPREFIX?=	${SRC_BASE}
X
X# some test targets need a predictable source directory
XWRKSRC=		${WRKDIR}/uarduno
X
XPLIST_FILES=	uarduno.ko
XMAKE_JOBS_SAFE=	yes
X
X# no license required
XLICENSE=		BSD
XNO_LICENSES_INSTALL=	yes
XNO_LICENSES_DIALOGS=	yes
X
X#
X# version 7xxxx and 8xxxx are very different
X# so make sure I correctly identify them
X#
XCFLAGS+=	-DKERNELVER=${OSVERSION}
X
X.include <bsd.port.pre.mk>
X
X.if ${OSVERSION} < 700000
XBROKEN=		not tested for earlier than 7.x, probably won't build
X.endif
X
X.if ${OSVERSION} < 800000
X# Simple check for 7.x kernel source (find usb.c)
X.if ! exists(${SRCPREFIX}/sys/dev/usb/usb.c)
XIGNORE=	this port will not build without the latest 7.x kernel source
X.endif
X.else
X# 8.x and later kernels (not tested in 9.x yet, mabye add to kernel?)
X# simple check for 8.x and later kernel source (find usb_core.c)
X.if ! exists(${SRCPREFIX}/sys/dev/usb/usb_core.c)
XIGNORE=	this port will not build without the latest kernel source
X.endif
X.endif
X
X# post-patch target, copy 'ids.txt' as 'ids.h' (user-modifiable file)
Xpost-patch:
X	@${CP} ${FILESDIR}/ids.txt ${WRKSRC}/ids.h
X
X# post-install target, make sure kernel module is unloaded
Xpost-install:
X	@if kldstat -q -m uhub/uarduno ; then \
X	 echo "" ; echo " +++ Unloading uarduno.ko (related devices will need to be re-attached)" ; kldunload uarduno ; fi
X	@${ECHO_MSG}
X	@${CAT} ${PKGMESSAGE}
X	@${ECHO_MSG}
X
X#
X# these next 2 targets are for developer use
X#
X# building a source tarball and related files
Xuarduno-src-tarball:
X	${MAKE} patch
X	${MAKE} -C ${WRKSRC} my-clean
X	tar -c -f ${PORTSDIR}/distfiles/${DISTNAME}${EXTRACT_SUFX} -C ${WRKDIR} uarduno
X	${MAKE} makesum
X
X# partial clean for incremental build and test
Xuarduno-part-clean:
X	-${RM} ${WRKDIR}/.patch_done.uarduno._boot_kernel
X	-${RM} ${WRKDIR}/.configure_done.uarduno._boot_kernel
X	-${RM} ${WRKDIR}/.build_done.uarduno._boot_kernel
X	-${RM} ${WRKDIR}/.install_done.uarduno._boot_kernel
X	${MAKE} -C ${WRKSRC} my-clean
X	${MAKE} patch
X
X.include <bsd.port.post.mk>
bab716c1a23b71bc35078db5dc519fea
echo x - uarduno/pkg-message
sed 's/^X//' >uarduno/pkg-message << 'b73ea7a4d5146f0d2f8f540b78bee5b7'
XThe Arduino Uno uses a specific vendor ID of 0x2341 and product ID of 0x0001
X
XIf you modify your Arduino Uno to use a DIFFERENT vendor ID or product ID, you
Xcan add your vendor/product combination to the files/ids.txt text file
Xaccording to the example shown.  Additionally, this driver MAY work with
Xgeneric ACM USB Serial Devices.  You would need to manually add the
Xvendor ID and product ID for these devices as well.  For ACM devices that
Xare modems, consider using or modifyig the 'umodem' driver.
X
XYou will need to load the uarduno kernel module before connecting the Arduino UNO
Xvia USB to your computer.  The command to manually load the driver is:
X
X  kldload uarduno.ko
X
XTo automatically load the driver on startup, add the following line to
Xyour /boot/loader.conf file:
X
X  uarduno_load="YES"
b73ea7a4d5146f0d2f8f540b78bee5b7
exit



>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list