Content originally posted in LPCWare by the-canary-islands on Sun May 22 13:17:47 MST 2011
Hi guys,
I wanted to report what I did to install lpcxpresso on a linux compiled from scratch.
I've been skimming previous posts this last week before attempting to install, mostly to get familiarized with the whole thing.
It seems to me many of those reporting problems had the very same one as me.
In my case, udev sets devices up under `dev/bus/usb' like `/dev/bus/usb/X/Y', where X is the bus, and Y the device no.
Through an strace, I found out redcode tools expect to access it as `/dev/bus/usb/00X/00Y'.
This is how they can be found under `/sys' and believe is the "current standard" way udev even creates them (it's just that mine is a bit old).
I haven't dig any deeper than this so as to know if the problem is caused by libusb or redcode tools (believe the latter, as I've used libusb before and have never had such problem)
So, all I had to was a couple udev rules and scripts, which I'm pasting bellow:
SUBSYSTEM=="usb_device", SYSFS{idVendor}=="0471", SYSFS{idProduct}=="df55", MODE="0666", PR\
OGRAM="/bin/udev-pad %k", NAME="%c", RUN="/bin/dfu-lpcxpresso"
The above should be in a single line, and must live before any `usb_device' rule proccessed by udev (normally found in separate ascending-numbered files under `/etc/udev.d/rules').
What this rule does is to call `/bin/udev-pad' when the device 0x0471:0xdf55 is plugged. This script returns udev the full path where this device's node should be created (`%c').
Also, after the device's node has been setup, udev will call
`/bin/dfu-lpcxpresso' which will actually flash the device with
`LPCXpressoWIN.enc'.
Another similar rule is needed bellow the previous one (remember, better in a single line). After being flashed, the hardware will reenumerate and will take whatever the vid/pid the firmware has been hardcoded with:
SUBSYSTEM=="usb_device", SYSFS{idVendor}=="1fc9", SYSFS{idProduct}=="0009", MODE="0666",
PROGRAM="/bin/udev-pad %k", NAME="%c"
Again, this rule will ask `/bin/udev-pad' for a suitable name, and from them on, the device should available and ready from both the ide, and the command-line.
The `MODE="0666"' is to allow your regular non-priviledged system's user actually use the hardware.
The scripts above mentioned follows:
----------------- /bin/udev-pad -------------------------------------------
#!/bin/sh
x=${1#usbdev}
bus=${x%%.*}
device=${x#*.}
# print bus and device number three-digits padded
printf "bus/usb/%03d/%03d\n" ${bus} ${device}
--------------- /bin/dfu-lpcxpresso ---------------------------------------
#!/bin/sh
# for logger
TAG=lpcxpresso
# hardware specific stuff
VID=0x0471
PID=0xdf55
# I've moved the firmware to /lib/firmware, and changed it's permissions to 644
FIRMWARE=/lib/firmware/LPCXpressoWIN.enc
# only perform the following if `ACTION' environment variable is "add", thus, if the device is being plugged in
if [ ${ACTION} = "add" ]; then
# upload the firmware
/usr/bin/dfu-util -d ${VID}:${PID} -c 0 -t 2048 -R -D ${FIRMWARE}
# check error code and write a message to the syslog, just to have some
# feedback
str="successfully flashed"
if [ "$?" != "0" ]; then
str="unable to flash the device!"
fi
/bin/logger -t ${TAG} ${str}
fi
------------------------------------------------------------
Also, and not willing to offend anybody, being an emacs user for quite a time, I couldn't resist completely avoiding the ide, which fortunately is possible.
I personally prefer using autoconf for my projects, overall when they have not only firmware, but also host-side software, docs, schematics, etc.
So as I already have a cross-toolchain:
Created `/opt/lpcxpresso', and moved there the whole `bin/' directory, thus all the `crt_emu_*' binaries, the xml files, and the xme ones. I also chmod'ed everything but the binaries to a suitable 644.
Then just moved `arm-none-eabi-gdb' there as well. It's not the same gdb you get with your regular cross-toolchain, it has specific support from redcode.
And that's all. I hope this can help others with the same problem I had, or otherwise be useful some way or another.
It would be really nice if we could see in a future firmware's source code, though, or if provisions were taken to allow users write their own.
The lpc-link is quite a nice piece of hardware.
Regards,