New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NixOS, RISC-V, openocd and muforth #7
Comments
When setting the ELF interpreter, you can avoid typing quite so much by doing something like this: $ ldso=$(patchelf --print-interpreter /run/current-system/sw/bin/bash)
$ patchelf --set-interpreter $ldso <path-to-openocd-binary> And instead of mucking about with LD_LIBRARY_PATH it's possible to set openocd's RPATH instead. First you have to figure out where 'libusb1' is installed. If you installed it via I haven't found an ideal way to capture the store location of the installed libusb, but this will show it: $ nix-env -q --out-path libusb On my system - an i686 running the latest 16.09 - I see a -dev version of libusb-1.0.20 and a non-dev-version. Eyeballing the store path of the non-dev version - which starts with $ patchelf --set-rpath /nix/store/sjk3sh<TAB>/lib <path-to-openocd> |
I've opened an issue over at the sifive/cinco repo to try to help resolve this. We'd still have to patch ldso, but that's pretty easy, and can be done with a trivial script. |
Hmm, what a shock, we appear to have different "states" in our machines . ;) I didn't get any joy initially with
as "Nearly Normal User" and running as sudo pointed to a different derivation -- which apparently refuses to get garbage collected (for reasons outside the scope of this discussion.) Hence, once I found a libusb1.x that worked with openocd (by a convoluted path best avoided in the future,) I went with my method. I was looking for the fastest possible solution that consistently worked and avoided a lot of the wailing regarding rpath, LD_LIBRARY_PATH , patchelf and other workarounds for unpatched binaries in general . Buried in all of that and scattered elsewhere in the Stygian bowels of der Interwebs are several alarming threads regarding kooky breakage resulting from rpath manipulation. In the interests of my sanity, I'm going to use my method for now and respectfully not use
but let's see what happens on our respective systems. Change is rampant. And, per our discussion earlier, yeah, creating a Nix expression that downloads and patches openocd should definitely be on the table. For everyone else, welcome to NixOS. Here are two solutions. Brian McKenna thinks he has found a nifty one as well. If you're going to be one of the extremely few working with muforth in NixOS, hopefully these different solutions will at least illuminate something resembling a path. |
Closing this. Workarounds above work for the few and the brave. |
Closing this, we workarounds above. |
This is the fastest way to start chatting with the HiFive1 using
muforth/openocd on NixOS. Currently, this has only been tested with
NixOS version 17.03 running 4.9.20-grsec kernel.
Step 1. Git muforth.
Pay particular attention to the message produced after running muforth/src/configure.sh. Make sure
you append udev.nix to /etc/nixos/configuration.nix.
Step 2. Download the appropriate openocd binary per instructions here:
Step 3. Make certain that you have both patchelf and libusb-1.0x. If
you're running NixOS I'm assuming you know how to get them if you don't
have them. ;)
Step 4. Since you built muforth from source, you can use patchelf to find out
where your interpreter is located:
Point your openocd binary at that terrifying output with patchelf.
NB: The above assumes you did the logical thing and untarred that
openocd binary archive into your home directory without naming it
anything cute or clever.
Step 5. You'll need to set your LD_LIBRARY_PATH to point at the location in
/nix/store of the user-environment/lib that contains your libusb* files.
You can use the path of inconvenience and type it manually every login
session or once you figure out where it is, include it in a script. This
is the path of least resistance. I recommend that path. (Binaries and
LD_LIBRARY_PATH cause intermittent grief in NixOS land, so it would be
wise to remember this workaround. It would also be wise to not set
this permanently, as more permanent workarounds to LD_LIBRARY_PATH
issues have been known to cause wailing and gnashing of teeth.)
Remember the Path of Least Resistance: you'll put that in a shell script
and run it once per login session.
Step 6. Ready, set, chat with target. In one terminal window:
In another terminal window:
"You should see a dump of four registers, all zero except for SP."
-- @0x0dada
The text was updated successfully, but these errors were encountered: