[libnxt/f12/master] Initial import (#631190).

dwrobel dwrobel at fedoraproject.org
Wed Sep 22 20:57:46 UTC 2010


commit 57ca076422f0fc26d43806a943faa03fbdff4405
Author: Damian Wrobel <dwrobel at ertelnet.rybnik.pl>
Date:   Wed Sep 22 22:57:42 2010 +0200

    Initial import (#631190).

 .gitignore                            |    1 +
 libnxt-NXT-REFLASH-HOWTO              |   41 +++++++++++++++++
 libnxt-flash-write-makefile.patch     |   19 ++++++++
 libnxt-hashlib.patch                  |   22 +++++++++
 libnxt-samba-endian-independent.patch |   23 +++++++++
 libnxt-sconstruct-optflags.patch      |   30 ++++++++++++
 libnxt.spec                           |   80 +++++++++++++++++++++++++++++++++
 sources                               |    1 +
 8 files changed, 217 insertions(+), 0 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index e69de29..19ee54e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/libnxt-0.3.tar.gz
diff --git a/libnxt-NXT-REFLASH-HOWTO b/libnxt-NXT-REFLASH-HOWTO
new file mode 100644
index 0000000..15254d3
--- /dev/null
+++ b/libnxt-NXT-REFLASH-HOWTO
@@ -0,0 +1,41 @@
+
+To reflash the Lego firmware please follow the following steps:
+
+1. Connect the device using the USB cable. You can verify the connection
+by checking the /var/log/messages file for the message similar to the
+following:
+
+kernel: usb 5-1: new full speed USB device using uhci_hcd and address 13
+kernel: usb 5-1: New USB device found, idVendor=0694, idProduct=0002
+kernel: usb 5-1: New USB device strings: Mfr=0, Product=0, SerialNumber=1
+kernel: usb 5-1: SerialNumber: 00xxxxxxxxxx
+
+where xxxxxxxxxx is a device serial number.
+
+2, Press and hold for at least 5 seconds the reset button hidden in the
+pin hole under the USB port. You can check whether the device entered
+reflash mode (a.k.a. SAMBA mode) by checking the /var/log/messages file for
+the message similar to the following:
+
+kernel: usb 5-1: new full speed USB device using uhci_hcd and address 10
+kernel: usb 5-1: New USB device found, idVendor=03eb, idProduct=6124
+kernel: usb 5-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
+
+The device should also produce clicks in the speaker (about once per second).
+
+3. Flash the firmware using the following command:
+
+    su -c 'nxt-fwflash firmware-image'
+
+where the firmware-image is the firmware file.
+
+While flashing the output should be as following:
+Checking firmware... OK.
+NXT device in reset mode located and opened.
+Starting firmware flash procedure now...
+Firmware flash complete.
+New firmware started!
+
+
+Official images can be found at the following URL:
+http://mindstorms.lego.com/en-us/support/files/default.aspx#Firmware
diff --git a/libnxt-flash-write-makefile.patch b/libnxt-flash-write-makefile.patch
new file mode 100644
index 0000000..c31da77
--- /dev/null
+++ b/libnxt-flash-write-makefile.patch
@@ -0,0 +1,19 @@
+Index: libnxt-0.3/flash_write/Makefile
+===================================================================
+--- libnxt-0.3.orig/flash_write/Makefile	2007-04-22 06:41:39.000000000 +0200
++++ libnxt-0.3/flash_write/Makefile	2010-07-17 18:18:26.675043511 +0200
+@@ -4,10 +4,10 @@
+ #	objdump --disassemble-all -bbinary -marm7tdmi flash.bin > flash.asm
+ #
+ 
+-CC=`which arm-elf-gcc`
+-AS=`which arm-elf-as`
+-LD=`which arm-elf-ld`
+-OBJCOPY=`which arm-elf-objcopy`
++CC=arm-gp2x-linux-gcc
++AS=arm-gp2x-linux-as
++LD=arm-gp2x-linux-ld
++OBJCOPY=arm-gp2x-linux-objcopy
+ 
+ all:
+ 	$(CC) -W -Wall -O3 -msoft-float -mcpu=arm7tdmi -mapcs -c -o flash.o flash.c
diff --git a/libnxt-hashlib.patch b/libnxt-hashlib.patch
new file mode 100644
index 0000000..36ff250
--- /dev/null
+++ b/libnxt-hashlib.patch
@@ -0,0 +1,22 @@
+Index: libnxt-0.3/make_flash_header.py
+===================================================================
+--- libnxt-0.3.orig/make_flash_header.py	2007-04-22 06:41:39.000000000 +0200
++++ libnxt-0.3/make_flash_header.py	2010-09-04 16:11:24.153078564 +0200
+@@ -12,7 +12,7 @@ import sys
+ import os
+ import os.path
+ import urllib2
+-import sha
++import hashlib
+ 
+ FLASH_DIR = 'flash_write'
+ FLASH_BIN = 'flash.bin'
+@@ -57,7 +57,7 @@ from the project website and use that.
+     f.close()
+ 
+     # Verify the SHA-1 checksum
+-    checksum = sha.new(data).hexdigest()
++    checksum = hashlib.sha1(data).hexdigest()
+     if checksum != DOWNLOAD_FLASH_CHECKSUM:
+         print "Oops, the flash binary I downloaded has the wrong checksum!"
+         print "Aborting :("
diff --git a/libnxt-samba-endian-independent.patch b/libnxt-samba-endian-independent.patch
new file mode 100644
index 0000000..6fb6da8
--- /dev/null
+++ b/libnxt-samba-endian-independent.patch
@@ -0,0 +1,23 @@
+Index: libnxt-0.3/samba.c
+===================================================================
+--- libnxt-0.3.orig/samba.c	2007-04-22 05:24:17.000000000 +0200
++++ libnxt-0.3/samba.c	2010-09-12 23:56:00.692274760 +0200
+@@ -87,16 +87,8 @@ nxt_read_common(nxt_t *nxt, char cmd, in
+   NXT_ERR(nxt_send_str(nxt, buf));
+   NXT_ERR(nxt_recv_buf(nxt, buf, len));
+ 
+-  w = *((nxt_word_t*)buf);
+-
+-#ifdef _NXT_BIG_ENDIAN
+-  /* The value returned is in little-endian byte ordering, so swap
+-     bytes on a big-endian architecture. */
+-  w = (((w & 0x000000FF) << 24) +
+-       ((w & 0x0000FF00) << 8)  +
+-       ((w & 0x00FF0000) >> 8)  +
+-       ((w & 0xFF000000) >> 24));
+-#endif /* _NXT_BIG_ENDIAN */
++  /* The value returned is in little-endian byte ordering */
++  w = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | (buf[0] << 0);
+ 
+   *word = w;
+   return NXT_OK;
diff --git a/libnxt-sconstruct-optflags.patch b/libnxt-sconstruct-optflags.patch
new file mode 100644
index 0000000..a14e1a8
--- /dev/null
+++ b/libnxt-sconstruct-optflags.patch
@@ -0,0 +1,30 @@
+Index: libnxt-0.3/SConstruct
+===================================================================
+--- libnxt-0.3.orig/SConstruct	2007-04-22 06:41:39.000000000 +0200
++++ libnxt-0.3/SConstruct	2010-09-13 14:49:37.422007163 +0200
+@@ -1,16 +1,17 @@
++import os
+ from glob import glob
+ 
+ auto_libs = ''
+ 
+-# Detect the system's endianness
+-from sys import byteorder
+-if byteorder == 'big':
+-	endian = '_NXT_BIG_ENDIAN'
+-else:
+-	endian = '_NXT_LITTLE_ENDIAN'
++BuildEnv = Environment()
++
++if os.environ.has_key('CC'):
++    BuildEnv['CC'] = os.environ['CC']
++if os.environ.has_key('CFLAGS'):
++    BuildEnv['CFLAGS'] = os.environ['CFLAGS']
++if os.environ.has_key('LDFLAGS'):
++    BuildEnv['LINKFLAGS'] = os.environ['LDFLAGS']
+ 
+-BuildEnv = Environment(CCFLAGS=['-Wall', '-std=gnu99',
+-				'-g', '-ggdb', '-D' + endian])
+ if auto_libs:
+ 	BuildEnv.ParseConfig('pkg-config --cflags --libs ' + auto_libs)
+ 
diff --git a/libnxt.spec b/libnxt.spec
new file mode 100644
index 0000000..9079b31
--- /dev/null
+++ b/libnxt.spec
@@ -0,0 +1,80 @@
+Summary: Utility for flashing LEGO Mindstorms NXT firmware
+Name: libnxt
+Version: 0.3
+Release: 2%{?dist}
+License: GPLv2+
+Group: Development/Tools
+URL: http://code.google.com/p/libnxt/
+Source0: http://libnxt.googlecode.com/files/%{name}-%{version}.tar.gz
+# Short document describing how to reflash the NXT firmware
+Source1: libnxt-NXT-REFLASH-HOWTO
+# Use appropriate tool's names (as per arm-gp2x-linux-gcc package)
+Patch0: libnxt-flash-write-makefile.patch
+# Use the hashlib module instead of the deprecated sha module
+Patch1: libnxt-hashlib.patch
+# Removes the following compilation warning and make the code
+# endian-independent:
+# samba.c: In function 'nxt_read_common':
+# samba.c:90: warning: dereferencing type-punned pointer will break
+# strict-aliasing rules
+Patch2: libnxt-samba-endian-independent.patch
+# Respect CFLAGS and LDFLAGS environment variables during the build
+Patch3: libnxt-sconstruct-optflags.patch
+Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+BuildRequires: libusb-devel
+BuildRequires: scons
+BuildRequires: arm-gp2x-linux-gcc
+
+
+%description
+LibNXT is an utility library for talking to the LEGO Mindstorms NXT.
+ It currently does:
+ * Handling USB communication and locating the NXT in the USB tree.
+ * Interaction with the Atmel AT91SAM boot assistant.
+ * Flashing of a firmware image to the NXT.
+ * Execution of code directly in RAM.
+
+
+%prep
+%setup -q
+%patch0 -p1
+%patch1 -p1
+%patch2 -p1
+%patch3 -p1
+cp -p %{SOURCE1} NXT-REFLASH-HOWTO
+make -C flash_write clean # to be sure that we will regenerate the flash.bin
+
+
+%build
+make -C flash_write
+export CFLAGS="%{optflags}"
+export LDFLAGS="%{optflags}"
+scons %{?_smp_mflags}
+
+
+%install
+rm -rf %{buildroot}
+install -D -m 755 fwexec %{buildroot}%{_bindir}/nxt-fwexec
+install -D -m 755 fwflash %{buildroot}%{_bindir}/nxt-fwflash
+
+
+%clean
+rm -rf %{buildroot}
+
+
+%files
+%defattr(-, root, root, -)
+%doc COPYING README NXT-REFLASH-HOWTO
+%{_bindir}/nxt-fwexec
+%{_bindir}/nxt-fwflash
+
+
+%changelog
+* Sun Sep 13 2010 Damian Wrobel <dwrobel at ertelnet.rybnik.pl> - 0.3-2
+- Fix for respecting CFLAGS and LDFLAGS during the build,
+- Fix for strict-aliasing rules problem,
+- Describe purpose of the patches,
+- Firmware reflash HOWTO added.
+
+* Mon Jul 19 2010 Damian Wrobel <dwrobel at ertelnet.rybnik.pl> - 0.3-1
+- Initial RPM release
diff --git a/sources b/sources
index e69de29..7a17ce3 100644
--- a/sources
+++ b/sources
@@ -0,0 +1 @@
+05be5f5b8822f10e4fc4e1dea7d5e770  libnxt-0.3.tar.gz


More information about the scm-commits mailing list