Thursday, November 1, 2012

Arch Linux VPS and glibc upgrade issue


So I just got a VPS with Archx86_64 and had some trouble with the glibc upgrade (again), I've been following various guides and ran into a little hiccup with glibc that I haven't seen elsewhere, there were files owned by util-linux-ng in /lib, I just had to sync that package explicitly and it was removed and replaced util-linux and glibc installed fine :)
[root@lovejes ~]# find /lib -exec pacman -Qo -- {} +
error: cannot determine ownership of directory '/lib'
/lib/libcrypt.so.1 is owned by glibc 2.16.0-99
/lib/libnss_hesiod-2.16.so is owned by glibc 2.16.0-99
/lib/libresolv-2.16.so is owned by glibc 2.16.0-99
/lib/libpcprofile.so is owned by glibc 2.16.0-99
/lib/libuuid.so.1.3.0 is owned by util-linux-ng 2.17.2-2
/lib/libcidn.so.1 is owned by glibc 2.16.0-99
/lib/libresolv.so.2 is owned by glibc 2.16.0-99
/lib/libuuid.so.1 is owned by util-linux-ng 2.17.2-2
/lib/libnss_files-2.16.so is owned by glibc 2.16.0-99
/lib/librt.so.1 is owned by glibc 2.16.0-99
/lib/libBrokenLocale-2.16.so is owned by glibc 2.16.0-99
/lib/libnss_nisplus-2.16.so is owned by glibc 2.16.0-99
/lib/libblkid.so.1 is owned by util-linux-ng 2.17.2-2
/lib/libnss_dns-2.16.so is owned by glibc 2.16.0-99
/lib/libSegFault.so is owned by glibc 2.16.0-99
/lib/libc-2.16.so is owned by glibc 2.16.0-99
/lib/libdl-2.16.so is owned by glibc 2.16.0-99
/lib/libBrokenLocale.so.1 is owned by glibc 2.16.0-99
/lib/libpthread-2.16.so is owned by glibc 2.16.0-99
/lib/libthread_db-1.0.so is owned by glibc 2.16.0-99
/lib/ld-linux-x86-64.so.2 is owned by glibc 2.16.0-99
/lib/libm-2.16.so is owned by glibc 2.16.0-99
/lib/libnss_nis-2.16.so is owned by glibc 2.16.0-99
/lib/libnss_compat.so.2 is owned by glibc 2.16.0-99
/lib/libdl.so.2 is owned by glibc 2.16.0-99
/lib/libnss_hesiod.so.2 is owned by glibc 2.16.0-99
/lib/librt-2.16.so is owned by glibc 2.16.0-99
/lib/libmemusage.so is owned by glibc 2.16.0-99
/lib/libutil.so.1 is owned by glibc 2.16.0-99
/lib/libblkid.so.1.1.0 is owned by util-linux-ng 2.17.2-2
/lib/ld-2.16.so is owned by glibc 2.16.0-99
/lib/libpthread.so.0 is owned by glibc 2.16.0-99
/lib/libnss_files.so.2 is owned by glibc 2.16.0-99
/lib/libutil-2.16.so is owned by glibc 2.16.0-99
/lib/libanl.so.1 is owned by glibc 2.16.0-99
/lib/libcrypt-2.16.so is owned by glibc 2.16.0-99
/lib/libnss_db.so.2 is owned by glibc 2.16.0-99
/lib/libnsl.so.1 is owned by glibc 2.16.0-99
/lib/libcidn-2.16.so is owned by glibc 2.16.0-99
/lib/libanl-2.16.so is owned by glibc 2.16.0-99
/lib/libnss_db-2.16.so is owned by glibc 2.16.0-99
/lib/libm.so.6 is owned by glibc 2.16.0-99
/lib/libnss_dns.so.2 is owned by glibc 2.16.0-99
/lib/libnss_compat-2.16.so is owned by glibc 2.16.0-99
/lib/libnss_nis.so.2 is owned by glibc 2.16.0-99
/lib/libnss_nisplus.so.2 is owned by glibc 2.16.0-99
/lib/libthread_db.so.1 is owned by glibc 2.16.0-99
/lib/libnsl-2.16.so is owned by glibc 2.16.0-99
/lib/libc.so.6 is owned by glibc 2.16.0-99
[root@lovejes ~]# pacman -S util-linux-ng
resolving dependencies...
looking for inter-conflicts...
:: util-linux and util-linux-ng are in conflict. Remove util-linux-ng? [y/N] y

Tuesday, October 30, 2012

Github.com won't reliably resolve when pulling/pushing

It started a couple months ago, it was confusing at first, I thought maybe my remote address was screwed up, or I had the wrong public key on github... but it just seems really unreliable.  The message looks like this a lot of the time:
[nak@arch Guru]$ git pull origin development
ssh: Could not resolve hostname github.com: Name or service not known
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

 Then I press up-arrow, enter... over and over again until I'm able to get a connection, and then it works fine...

I figured I'd write about this in case others are googling around, you're not alone, but I don't know the solution yet.  Maybe I'll do a wireshark session to see if I can dissect anything.

Until next time,
Eternally Confused,
Naked Proof~

Blog of confusion

This really seems to be a blog documenting my confusion, and then what proceeds from that confusion:
A lot of the time more confusion, or confusion disguised as revelation, and then maybe if I am lucky, true revelation.

Like my last post on coffeescript -cw, I'm not sure if there's still an issue with that anymore, did vim patch something? Was I really confused and blaming something that wasn't having problems? Eesh!

Wednesday, October 17, 2012

Coffee script `file removed` while using compile/watch switches with vim

I thought it was just my main Arch system, but I've recently been forced to use my clunky old laptop to develop and have found that there is a race condition in coffee-script when saving with vim on there too.

I fixed the problem with this simple patch (a hacky 100ms setTimeout to add a short pause), I was hoping the CPU on my laptop was slow enough that the logic would line up without the patch.  This was not the case.

Here's what I did since that patch link is now broken:

in command.coffee I have this:

# Watch a source CoffeeScript file using `fs.watch`, recompiling it every
# time the file is updated. May be used in combination with other options,
# such as `--lint` or `--print`.
watch = (source, base) ->

  prevStats = null
  compileTimeout = null

  watchErr = (e) ->
    if e.code is 'ENOENT'
      return if sources.indexOf(source) is -1
      try
        vimTimeout = wait 100, ->
          rewatch()
          compile()
      catch e
        removeSource source, base, yes
        compileJoin()

    else throw e



ALSO: This blog entry seems to have a good suggestion, I may try it myself!

When I brought the issue up in the coffee-script IRC channel a few months ago, there were some very defensive people (person?) saying the problem wasn't with coffee-script and the -cw switch works fine with vim.

This has not been the case for me.

I hope this helps some people, because I don't think I'm the only one who's experiencing this, or will experience this.

Please let me know if this issue gets patched, I submitted a pull request, but I deleted it due to lack of response and the embarrassingly nasty little hack (although similar hacks are used throughout the compiler to deal with race conditions!).

Anyway, much love to coffee-script for now, good luck fellow hackers.

Friday, October 5, 2012

Rant to Self: Arduino Development of Haptic Compass on Arch Linux

Poni Halp Me
Yesterday I was able to get the arduino development environment setup on Arch Linux AND get the compass module talking to the arduino over I2C (yay pre-existing code).

A lot of the haptic compass projects I see are driving the vibrator motors directly from the digital pin on the arduino, naughty!

I'll post how I used a transistor to switch each motor, even though I haven't done it yet :-P

So now the hard part where I'm sort of flabbergasted at the moment.  I have 6 registers of data spilling out magnetic field strength data for 3 axis, oh yeah the module I have exposed the DRY (data ready) pin from the compass chip, so I altered the sparkfun code to update continuously when that pin is high... high ... heh.

Anyway. When the data is inspected as a signed integer, I seem to see values from -700 to 700 for each axis.  I'll probably have to do something called 'vector addition' heh made that up, maybe, but like... I know I can't directly add or subtract the vectors, x and y are on the same plane and z is sticking out, and it seems like the higher the number the more aligned to north the axis is, negative is when the axis is "pointing" south.

Also when an axis is pointing down towards the ground its a positive, when it's pointing towards the sky it's negative. Not too sure about this behavior yet.

I should really read the data sheet more in depth now. Until next time!

Tuesday, September 18, 2012

How to strip file extension in a bash shell script function

FILENAME=`echo $1 | sed -e 's/\..*//g'`
From a BASH function take the first command line argument and strip off the extension and then assign it to the variable FILENAME.

It's probably not the best way of doing it, but it's how it happened.  I couldn't find any one liners from the googles :'(

Post your better solution in the comments below!11111!!!!

This is the total function (in my bash.bashrc):

mk430 () {
  FILENAME=`echo $1 | sed -e 's/\..*//g'`
  msp430-gcc -mmcu=msp430f2274 -o $FILENAME.elf $1
}
for compiling MSP430 C files to elfs, there's probably a better alias too!

Sunday, September 9, 2012

MSP430 eZ430-RF2500 on Arch Linux

Hi, I didn't see much info on this particular model and Arch. So I'll log what I do here:

I plugged in the USB dongle with the breakout board attached, ran lsusb which showed this entry:

Bus 008 Device 004: ID 0451:f432 Texas Instruments, Inc. eZ430 Development Tool
So far so good. Now I need to install some stuff:
$ yaourt mspdebug-git
yaourt is a AUR package manager, you can do this manually by searching aur.archlinux.com and then installing the package with makepkg.

The build fails: make: /bin/install: Command not found
I run these commands to make a soft-link to `which install`:
$ cd /bin
$ sudo ln -s /usr/bin/install install

then select Restart building mspdebug-git? [y/N] y

The build succeeds and the package installs.
I type...
$ sudo mspdebug rf2500
because shamwowzow, I'm a frolicking alien and it connects to the device and gives me a prompt, I see the availiable commands and enter:
(mspdebug) run
The light on the breakout board begins flashing, I plugin the other board and the green light turns on... signalling a wireless connection I suppose.
I used sudo because I guess my normal user doesn't have permission to do this kind of magic yet, probably have to add it to some group.
[EDIT]: $ sudo gpasswd -a uucp

NOW TO TRY AND WRITE SOME CODE FOR THIS JOLLY WAG.

I search AUR for mspgcc for a gcc toolchain or whatever, and it shows me a lot of stuff. I dunno what to do so I read this ubuntu guide for some ideas. Then I read this arch linux guide for another MSP430.  Seems promising. I search AUR for MSP430, seems like there's a package called `gcc-msp430`  I'll try that...
$ yaourt gcc-msp430
 I type `1-3` to install the 3 packages... I lazily don't edit the PKGBUILDs like a lazy arch user that's prone to blowing off his feet because of silly mistakes. Things compile, things install, things download and repeat, I type `y` and `n` seemingly arbitrarily to get through this maze of discrete choice towards getting code into some carefully crafted silicon hanging in it's bare PCB off the dongle at the front of my PC....

Wow. This takes a long time, I was running BOINC (like SETI for AIDS and malaria and protein folding) and turned it off so my CPU could focus on compiling all this MSP430 junk...

The next patch would create the file ld/emulparams/msp430uni.sh,
which already exists!  Assume -R? [n]
Uh oh, I'm just going to press enter and hope the god of good defaults saves me.

Apply anyway? [n]
Skipping patch.
1 out of 1 hunk ignored
Uh oh, now its doing the same thing with `msp430.em`... I'm going to ctrl-c and try putting `y` instead...
I just ran `yaourt gcc-msp430` again, it's retrieving sources.... I dont think yaourt has a cache >.>

Ugh. That was a mistake.
Ok so I pressed `y` to make it assume -R (which means reversed or something, idk) and now it finally came back with:

make[4]: *** No rule to make target `emulparams/msp430uni.sh', needed by `emsp430.c'.  Stop.
make[4]: Leaving directory `/tmp/yaourt-tmp-nak/aur-mspgcc-binutils/src/binutils-2.21.1/ld'
make[3]: *** [all-recursive] Error 1
going to "restart building" again and try just pressing enter like I did the first time... I really don't know what I'm doing at this point, as if I ever did... wow didn't even come to that point.

Targets (1): mspgcc-binutils-20120406-1
Total Installed Size:   9.95 MiB
Proceed with installation? [Y/n]
(1/1) checking package integrity                                       [#######################################] 100%
(1/1) loading package files                                            [#######################################] 100%
(1/1) checking for file conflicts                                      [#######################################] 100%
error: failed to commit transaction (conflicting files)
mspgcc-binutils: /usr/bin/msp430-addr2line exists in filesystem
mspgcc-binutils: /usr/bin/msp430-ar exists in filesystem
...
with a ton more "exists in filesystem" messages, then quits saying no packages were upgraded. I don't know what's happening, I don't think it does either.
Well I guess I'll try and compile some LED blinking code from here and put it on there.

$ msp430-gcc -g -o led.elf led.c
led.c:1:26: fatal error: msp430x20x3.h: No such file or directory
compilation terminated.
Guess I need some headers... or something...
$ yaourt msp430-libc
Uhh ok its doing mspgcc-binutils again... pray for it.
Wow... I'm just not very good at yaourt, I've been installing crap I don't need by doing stuff like 1-3 ... I need to do a little cleaning after I'm done I think.
$yaourt msp430mcu
this says it installs the headers... getting closer

[nak@arch msp430]$ msp430-gcc -g -o led.elf led.c
/usr/bin/msp430-ld: cannot open linker script file memory.x: No such file or directory
collect2: ld returned 1 exit status
OKAY THIS IS THE -mmcu FOR THE eZ430-RF2500:
msp430-gcc -mmcu=msp430f2274 -o led.elf led.c
it output an elf without any errors, now to put it on the board...

WOOO ROCKSTAR FROM MARS
$ sudo mspdebug rf2500
(mspdebug) erase
Erasing...
(mspdebug) prog led.elf
Erasing...
Programming...
Writing  154 bytes at 8000 [section: .text]...
Writing   32 bytes at ffe0 [section: .vectors]...
Done, 186 bytes total
(mspdebug) run
Running. Press Ctrl+C to interrupt...

And the LED is blinking~
I'll created a compressed version of this sometime.