Archive for category Projects

64-bit userspace on Nvidia TX1

I’ve been having trouble getting a 64-bit userspace up on the Nvidia TX1 (Linux4Tegra uses 32-bit), so I thought I’d share my progress and steps.

See the end of this post for a comment about how I actually got this working. These instructions don’t work as they are, but I’m leaving them here for posterity.

To begin with, I use Debian (or Ubuntu, or whatever) for most of my work, so that’s what this guide will be based on. Also, you’ll need to have another drive to use with your TX1. Linux4Tegra (L4T) will be installed on the on-board MMC device, and we’ll be installing Debian Sid on the other drive.

You’ll need to copy the extensive partition scheme that Nvidia builds on the MMC (there’s something like 8-9 partitions) onto your target drive. I do this by dd’ing the entire MMC onto the target

sudo dd if=/dev/mmcblk0 of=/dev/mmcblk1 bs=4096

Then we need to mount the root filesystem on the target device somewhere

sudo mkdir /mnt/rootfs
sudo mkfs.ext3 /dev/mmcblk1p1
sudo mount /dev/mmcblk1p1 /mnt/rootfs

Debootstrap will do the work of making the new (very minimal) root filesystem. It’s very important to include the –arch flag, otherwise the bootstrap process will generate a rootfs using armhf, and we’ll be stuck with a 32-bit userspace again.

sudo apt-get install debootstrap
sudo debootstrap --arch=arm64 sid /mnt/rootfs http://debian.osuosl.org/debian

As I said the rootfs will be VERY minimal, so we need to install tons of important stuff, including locales, keyboard maps, ssh server, etc… But, before we do that we have to chroot into the new rootfs:

sudo mount -o rbind /dev rootfs/dev
sudo mount -t proc none rootfs/proc
sudo mount -o bind /sys rootfs/sys
sudo chroot rootfs /bin/bash
source /etc/profile
apt-get update
apt-get install ssh openssh-server make gcc libncurses5-dev bc locales
dpkg-reconfigure locales

Then, we need to add information about the network interface to /etc/network/interfaces:

auto lo
iface lo inet loopback

allow-hotplug eth0
iface eth0 inet dhcp

The current linux-upstream kernel has support (though apparently, rudimentary) for the TX1. This should obviate the need for the binaries supplied with L4T. So, let’s clone the kernel repo and build one.

cd /usr/src
git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git linux-next
cd linux-next
cp /proc/config.gz ./
gunzip config.gz
cp config .config
make oldconfig (press enter until it's done)
make menuconfig
(in General Setup, select "open by fhandle syscalls")
(in Drivers->General, delete all the extra firmware names listed)
make
cp build

Next, we have to copy the entry that selects the boot mode in /boot/extlinux/extlinux.conf and edit it to select our new rootfs. We’ll leave the old one there so we can swift back and forth. This is especially helpful if something breaks.


LABEL debian
MENU LABEL debian kernel
LINUX /boot/Image-next
FDT /boot/tegra210-p2371-2180.dtb
APPEND fbcon=map:0 console=tty0 console=ttyS0,115200n8 tegraid=21.1.2.0.0 ddr_die=2048M@2048M ddr_die=2048M@4096M section=256M memtype=0 vpr_resize usb_port_owner_info=0 lane_owner_info=0 emc_max_dvfs=0 touch_id=0@63 video=tegrafb no_console_suspend=1 debug_uartport=lsport,0 earlyprintk=uart8250-32bit,0x70006000 maxcpus=4 usbcore.old_scheme_first=1 lp0_vec=${lp0_vec} nvdumper_reserved=${nvdumper_reserved} core_edp_mv=1125 core_edp_ma=4000 gpt root=/dev/mmcblk1p1 rw rootwait

The last thing to do in the chroot is to set the root password to something, and allow (for now, change it later!!) root login over ssh:

passwd
vi /etc/ssh/sshd_config
...
PermitRootLogin yes
...

Now, we need to really dive into to some somewhat painful work. We have to setup a serial console onto the board, and have another computer (specifically a x86-64 machine running Ubuntu 14.04) to run the L4T apply_binaries.sh tool. First, the serial port connection is explained at elinux. Then, you need open a serial terminal to the board with 115200 baud. Once that’s done, reboot the board, and prevent u-boot from autobooting. In the uboot console, enable the USB Mass Storage mode:

Tegra210 (P2371-2180) # ums 0 mmc 1
UMS: disk start sector: 0x0, count: 0x39f0000

Then, with the usb cable connected from the TX1 to your x86-64 box run apply_binaries.sh:

sudo mount /dev/sdg1 /mnt/rootfs/
sudo LDK_ROOTFS_DIR=/mnt/rootfs ./apply_binaries.sh
sudo umount /mnt/rootfs

The problem I’ve been having is that the USB keyboard that I have doesn’t work on the console. It’s obviously a HUGE bummer to not be able to login to a machine using the console. 🙁

I ended up following these instructions to net-install debian arm64 on my SD card. The limitation here is that most of the things that makes this an Nvidia device (GPU, CUDA, etc) don’t work. For my needs, I only want a Arm64 to work on a Swift port, so I don’t care.

References:

http://forum.lemaker.org/thread-3312-1-1.html
https://wiki.debian.org/Arm64Port
https://devtalk.nvidia.com/default/topic/916095/a-debian-experience/#4804151

, , , , , ,

No Comments

Swift available for Beaglebone/RasPi

I was able to succeed in building Swift and Foundation for Ubuntu on ARMv7. This includes the Beagle Bone/Board, the Raspberry Pi, Tegra TK1, Cubox, and so much more…

This is more-or-less alpha-level at this point, but you should be able to compile and run basic swift programs that use the standard library, Glibc, or Foundation. Keep in mind that, even for x86_64, Foundation is far from complete.

To install, you can either un-tar in your root directory (which will install into /usr) or, create a new directory in /opt (for example /opt/apple, or /opt/swift) and update your paths. If you choose to install into /usr you’re running a much greater risk to your system, and you had better be willing to re-install if from scratch!! 🙂

Once it’s installed, give swiftc a try:

wdillon@arm:~$ cat hello.swift
print("Hello world!")
wdillon@arm:~$ swiftc hello.swift
wdillon@arm:~$ ./hello
Hello world!
wdillon@arm:~$ uname -a
Linux arm 4.1.12-ti-r29 #1 SMP PREEMPT Tue Nov 10 00:38:08 UTC 2015 armv7l armv7l armv7l GNU/Linux
wdillon@arm:~$

You can download the file here.

If you want to contribute to the effort, there are still a few tests that fail in stdlib that could be addressed, the swift package manager still doesn’t work, lldb doesn’t work, Foundation isn’t finished, and it would probably be pretty great to have swift wrappers for GPIO pins and peripherals (such as SPI, I2C, etc.)

, , , , , ,

7 Comments

VORs and SDRs part 3 supplemental materials

I recently posted part 3 of the VORs and SDRs series. In this video, I look into the instrument landing system (ILS), and how it works. I just uploaded the raw baseband data and GNU Radio companion document for anyone that wants to play around with it:

GNURadio Companion GRC file
Baseband data

, , , , , , , , ,

16 Comments

VORs and SDRs Part 1 & 2 Supplemental materials

Part 1

Part 2

I want to share some supplemental materials to go along with this video. In the attached zip file, I’ve included the raw samples (32k/sec sample rate, roughly centered carrier) and the GNU Radio Companion file for basic processing. I’d be very interested to see if others can squeeze out a little better performance.

Also, this is the path that I took. It may help understand the angles. I need to make clear that I’m not at all certain that the absolute angles are representative to compass points. I’m only looking at relative angles at this point. Eventually I’ll calibrate the system using a known VOR calibration location (there is one at the Corvallis airport).

This is the path I took while collecting the VOR data. Ignore the drive time

This is the path I took while collecting the VOR data.

17 Comments

My new Chinese laser cutter!

For my birthday, my entire family chipped-in and gave me most of the money to buy a (relatively) cheap laser cutter directly from China. I had seen several Hack-a-day articles about these machines, and I’ve got experience with 3D printers, so I thought it was something that I could handle. Boy, did I have a lot to learn.

The path the slow boat from china took

The path the slow boat from china took

To begin with, I looked around on eBay and Alibaba. I noticed that 90% of the ~$1000 units are almost identical. There are occasional small differences such as pointing laser, whether it has a spring loaded “work clamp,” whether it has a raising-lowering bed, etc. I found one that claimed to have a larger bed than any other that I’d seen (mistake #1). I don’t know why I accepted that a machine that looked like every other machine out there would have magically increased the work size, but I did, and it doesn’t.

Because I was mentally set on this machine, I was willing to accept the shenanigans of the seller (mistake #2). The trouble began when their “free shipping to the USA” became $200. I thought “That’s kinda annoying, but not the end of the world.” The shipping charge was on par with other vendors. The next problem became that the $200 shipping was by boat, and F.O.B. (Mistake #3). Alibaba doesn’t support shipping by boat, and at this point the vendor and I agreed to leave the relative safety of Alibaba (Mistake #4). I requested a refund of my Escrow and it was granted.

A quick note about how Alibaba works, for the uninitiated. Alibaba is a marketplace, like eBay. Unlike eBay, however, Alibaba provides some additional protections to the buyer, and less so, the seller. When you purchase something from a vendor and make a payment you pay Alibaba directly, and that money is put into an Escrow account for the transaction. At this point, the Seller is assured that the money is there and they are guaranteed payment if they hold up their end of the deal. The seller, then, ships the product with an Alibaba approved carrier (like DHL, EMS, etc.). When the buyer receives the product and decides that it was accurately represented and meets expectation the seller is paid and the escrow is closed.

If you decide to leave Alibaba, it’s the wild, wild … east? The vendor really wanted to be paid by a wire transfer, which is the system that you see in spy movies. Bank account number, routing number, etc. The thing about a wire transfer is that there are NO protections. That money is gone, forever. If the vendor is feeling generous they may give it back if there’s a problem, but there are no systems in place for you to dispute it. There was no way I was going to go for that. I got them to agree to accept PayPal, which for all their faults does provide some buyer protections. Paypal makes their money by levying a surcharge on business transactions; the only way I got the vendor to agree to this was by paying the surcharge myself. In my mind, it was a worthwhile investment in insurance.

Ok, at this point I’ve paid the vendor and they’ve sent me vague information about when the ship will be leaving the Qingdao port. Then, one day I get an email from them about filing an ISF (10+2) form. I had no idea what this was, and I literally called the Port of Portland to ask them. They basically laughed at me. Apparently, the ISF is a form for a system that was introduced after the Sept. 11 collective mindless panic. Someone had the thought along the lines of “zomg, someone could put a bomb in a shipping container and blow up an entire city!” So, of course the government intervened and invented yet another complicated, expensive, process that can only really be done by a customs broker.

Now I need to find a customs broker. Off to Google… Whelp, no one has a ratings site for customs brokers. All my usual methods for deciding on a service provider fail. I find myself at the port of portland website and staring at a list of what seems like a hundred brokers. I literally choose one at random (mistake #5). I call their number and someone assures me that I’ve got plenty of time to file (Did I mention that you have to file the form three days before the ship leaves the last foreign port, and that failure to comply can be a $5000 fine?). I never hear from him again. Two days later I get a call at 3:00am from China. They’re calling to yell at me about the fact that my form hasn’t been filed and that I needed to do it right now. I calmly (lucky for them, my 1-year old wasn’t woken) explain to them that no one is awake or willing to take my calls at 3:00am. I’m not happy. The next morning I googled for “Customs broker portland oregon.” I choose the first link. My thinking is that google’s magic algorithms must know something more than random guessing. The new company is fast, responsive, and mostly a pleasure to work with.

Importing something substantial (I’m not sure what makes something substantial, but stay with me) is an expensive affair. The ISF form costs $35 to file. Great. Wait, I also have to become a customer of the brokerage company, $50. I need to have an ISF bond, $100. Don’t forget the customs bond premium, $45. Someone needs to enter the customs yard, $125. I haven’t even mentioned duty yet (this is what most people think of when importing), $26.50. By the way, any device that “emits radiation” has to be FDA accepted (they mean all radiation. Yes, I know that LEDs emit radiation, so do radios, you get my point), that’s another $35. So far were looking at about $400 in addition to my $200 shipping. Awesome.

You can see in the image above that the boat is going to Long Beach, California. Cool. I don’t live in California. The whole time I’ve been talking to them I’ve said Port of Portland perhaps a dozen times. I’m panicking a little. About two days before the boat is set to arrive in Long Beach, I get a call from a company at the Port of Long Beach. They were wondering when I would pay their fees. What? I wasn’t aware I had contracted with anyone at the Port of Long Beach. They had asked me about who my customs broker was. It seemed like this was the kind of thing that they could bill my customs broker for, and I had them do that. These guys charged another $160 of fees, including my favorite, the “Clean truck fee.”

Now, at this time (October 2014, and persisting now, into January 2015) there is a major bottleneck at the Port of Long Beach. My delivery was delayed a bit over a week because of this.

I was curious how I could get a shipment delivered to Long Beach, and have it go through customs in Portland. Apparently, it’s possible to move merchandise across the country that has not gone through customs. It just has to go to customs before it goes to the customer. That seems strange to me.

Anyway, the truck eventually got my package to Portland, and I drove up one day to get it (I had 2 days before I’d start getting charged warehouse fees). They put it on a forklift and surprisingly gracefully placed it in the back of my 4-runner.

All told, the cost for the machine was $700 + $200 shipping + $667 in customs fees. I feel a bit nauseous typing that out. Even more so when I add them and have to say that it was $1567 in total. Though, when I remember how much a decent laptop costs, I feel a little better. 🙂

The rest of my laser-cutter adventures were documented in video. Please enjoy the YouTube playlist below:

, , , , , , , , ,

2 Comments