Posts Tagged Techniques

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

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:// 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)
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= 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:

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 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

sudo mount /dev/sdg1 /mnt/rootfs/
sudo LDK_ROOTFS_DIR=/mnt/rootfs ./
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.


, , , , , ,

No 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:

, , , , , , , , ,


3D Printing Talk

I recently gave a talk about 3D printing to the Academy of Lifelong Learning¬†. ¬†It went really well, other than that I had a head cold. ¬†I thought I’d share my slides, and provide some¬†links to supporting and bonus material.

The slides for the talk are shared using iCloud, and should work with any recent browser.  The link is RIGHT HERE.

Following are a set of relevant and interesting links about 3D printing.  Several of these topics came up in the Q&A.


Koenigsegg 3D printed production parts:

Koenigsegg 3D printed turbocharger (menioned in the first video):

Rockets, Jets and NASA:

University of California San Diego; Students for the Exploration and Development of Space (SEDS).


NASA Marshall Space Flight Center


Casts for broken bones:

Cortex Cast


Ultrasonic cast



Students use 3D printing to make a prosthetic arm.


Dad builds son artificial hand on 3D printer.


Leaders of the 3D printing revolution:

Kinematics clothing:

Kinematics from Nervous System on Vimeo.

More information about Kinematics


There are¬†many, many more examples of the usage of 3D printing. ¬†Leave examples that you’ve found, or think are interesting in the comments!

, , ,

1 Comment

Skyworks 65116 update

It has been a while since I played with the Sky65116 amplifier boards that I built and wrote about. ¬†Since getting my own spectrum analyzer, I’m now able to make much better absolute measurements. ¬†The DSA-815-TG analyzer is specified as having 1dB of uncertainly across the span, and the SA that I have at work is essentially uncalibrated.

Video modulator output

Video modulator output (click for enlargement)

Not only do I now know that the absolute power out of the video transmitter at the fundamental frequency is about 5.5dBm, I can also see the first and second harmonics. ¬†I don’t know why I didn’t see them with the other analyzer, but they are disturbingly large. ¬†I believe the FCC requirement is that these harmonics should be more than 40dB below the fundamental. ¬†By this criterion, the transmitter should not even be sold in the US.

The SKY65116 amplifier has close to 36dB of gain, and a 1dB compression point of 32.5dB. ¬†The 1dB compression point is specified as the output power level at which the gain is reduced by 1dB. ¬†The easiest way to show this is with the graph from the Sky65116 data sheet, shown below. ¬†You can see that as the output power begins to approach 32dB gain drops quickly. ¬†The goal is to not force the amplifier to operate in this region. ¬†If you do, you’re likely introduce harmonic distortion and other nasty nonlinear effects (i.e. intermodulation products).

Gain vs. Pout curve

Gain vs. Pout curve

So, knowing that the output is +5.5dBm, and we want about +30dBm out of an amplifier with a gain of 36dB, we need to introduce 11.5dB of attenuation (30dBm – 36dB – 5.5dBm = -11.5dB) between the transmitter and the amplifier, at a minimum. ¬†It’s easy to make 14dB attenuators with standard value resistors (4×150 ohm and 1×120). ¬†I’ve been playing around with QUCS a lot lately, so I’ve provided a model for the attenuator. ¬†It’s just about the most boring S-parameter model you’ll ever see… ¬†Perfectly flat response at -14dB, but that’s what we’re after.

Simple 14dB attenuator model

Simple 14dB attenuator model

A while back, I had a bunch of these simple 5-pole filter PCBs made up. ¬†I just left them blank until I needed them, and I made two of them into 14dB attenuators using the circuit above. ¬†I had two extra poles, so I filled one with a 0 ohm resistor and the other with a 1uF DC-blocking capacitor. ¬†The capacitor reduces the low frequency performance, but only less than about 1.5MHz. ¬†It’s worthy the trade-off in my mind.

Constructed attenuators

Constructed attenuators

I went ahead and covered one of the attenuators with copper sheet just to make it more of a completed package. ¬†I’m sure I’ll need to use it many times in the future. ¬†I left the other open so I could unsolder it and make it something else if needed. ¬†An interesting thing happened when I installed the cover. ¬†The small ripple in the attenuation (around 500 MHz, see below) occurred only after I installed the cover. ¬†I assume this is due to parasitic capacitance between the components and the copper covering. ¬†It’s still only about 1dB of ripple, so I’m satisfied with it.

14dB attenuator performance

14dB attenuator performance

Anyway, back to the amplifier. ¬†I’ve now got about -8.5dBm going into the amp ( +5.5dBm – 14dB), so with its 36dB of gain, I should expect to see +27.5dBm out of the amp. ¬†That’s getting very close to the maximum input power on my SA (+30dBm). ¬†It’s always better to be safe with these things, so I used the other 14dB attenuator between the amp and the SA. ¬†Now, I should expect to see +13.5dBm on the input. ¬†I maxed-out the input attenuation on the analyzer (another 30dB) and gave it a shot. ¬†Note that the internal attenuation is calibrated out of what’s shown on the display, and I told the SA about the other 14dB of attenuation, so the power values shown on the display are referencing the amplifier’s output.

Transmitter after amplification

Transmitter after amplification

In the above image, you can see that we’re getting 27.5dBm out of the amplifier! ¬†I love it when a plan comes together! ¬†This is the value I calculated, right on the nose. ¬†I promise that I didn’t work the math backward! ūüôā ¬†Again, it’s so painfully obvious that the transmitter is AM, rather than the VSB signal that it should be.

Close-up of the signal

Close-up of the signal

Now, just for fun, let’s dive back into the video signal coming out of the transmitter. ¬†In the image above, I’ve put some markers on the various carriers present in the signal. ¬†The luma carrier is in the center at 433.85MHz, which is where we expect it to be. ¬†Marker 2 is at 437.45MHz, which is 3.6 (let’s call it 3.57) MHz away, matching exactly where the chroma carrier is supposed to be. ¬†There’s no audio carrier, which isn’t a surprise because there’s no audio, though I wouldn’t be surprised to see the carrier. ¬†Marker 3 is 19 MHz away; I have no idea what this is or why it’s there. ¬†It’s not supposed to be. ¬†Same with marker 4. ¬†Oh, well… ¬†that’s what you get with a shitty transmitter.

amplifier gain v. frequency

amplifier gain v. frequency

Now, what about those pesky harmonics? ¬†The Sky65116 is a 390-500 MHz amplifier, so my hope is that the reduced gain by the first harmonic will attenuate the harmonics enough to bring them into compliance. ¬†The graph above is the gain v. frequency graph from the data sheet. ¬†It’s neither encouraging nor discouraging. ¬†It’s difficult to infer what’s going to happen at 800 MHz when the graph stops at 500 MHz. ¬†In the image below, it appears that I lucked out. ¬†The first harmonic is 42dB down from the fundamental. ¬†If I were selling a product, there’s no way I would send this out for compliance testing. ¬†It would just be too risky, I’m not that confident in my measurements. ¬†By my math, it would cost less than $2 in parts (single unit quantities) to make a decent low pass filter. ¬†That’s the right thing to do. ¬†When I modeled it (in QUCS, again), I calculated that the harmonics would be within compliance even without the rolloff of the amplifier. ¬†With the rolloff, the harmonics would be well below the noise floor.

Harmonics after amplification

Harmonics after amplification

I’ve had a ton of fun redoing this experiment with my new spectrum analyzer. ¬†I’m going to write lots more about the analyzer in the future, and I’m really looking forward to it. ¬†Coming soon is an exploration of the skyworks low noise amplifiers. ¬†Between these two products, I expect to have a solid video link over 1000 feet or so.

, , , , , , , ,

1 Comment

3D Printering

Ok, confession time. ¬†I succumbed to the 3D printing fad thing. ¬†I know. ¬†I made fun of 3D printer fanbois in the past, but we got one at work. ¬†Using it for a bit forced me to realize that they’re actually pretty cool.

My kit of reprap parts!

My kit of reprap parts!

I asked my whole family to chip in for a¬†RepRap Prusa i3 kit¬†for my birthday (in September, to give you an idea of how behind I am). ¬†It came relatively quickly, but there were certainly some issues. ¬†For one, everything smelled –very strongly– of cigarette smoke. ¬†Luckily, it was mostly isolated to the outside of the packaging. ¬†Once I unpacked everything, it went away.

Aaaarg! Two sets of threaded rods!

Aaaarg! Two sets of threaded rods!

Then, I discovered that I got two sets of threaded rods!! ¬†That wouldn’t be so bad, except that I didn’t get any smooth rods! ¬†I emailed the company, and they got a replacement set of smooth rods in the mail right away, but I still had to wait a while. ¬†In the mean time, I figured that 5/16″ is awfully close to 8mm. ¬†I bought some 5/16″ stainless steel rods from the hardware store to keep working on the printer. ¬†The 5/16″ rods are undersized for the LM8UU linear bearings (they’re designed for 8mm rods), so there was extra slop in all the axes. ¬†Eventually, the 8mm rods came in the mail, and I installed them.

There were a few other minor issues. ¬†For one, the melamine material that was used for the main frame was thicker than the laser-cut slots. ¬†I had to carefully trim the tabs so that they would fit. ¬†It may be difficult to understand what I’m talking about without photos, but all that’s important to understand is that there were some attention to detail issues.

After printing for a while, I noticed another problem with the melamine. ¬†It’s also used in the frame that holds the build platform to the Y axis bearings. ¬†The frame material wasn’t strong enough to level the platform. ¬†When I lengthened the screws on the low sides, the frame would just bend downward rather than moving the platform. ¬†I found a place in town that sold me a sheet of 3/16″x1’x2′ aluminum for $5, from which I cut out a replacement frame with my scroll saw.

Other than those problems, everything went together smoothly. ¬†One interesting thing about RepRaps (the models that I know about, anyway) is that they don’t really include something to hold your spool on. ¬†I almost think it’s to give people something to design and print out of the chute. ¬†My solution was to build a frame using aluminum channel stock. ¬†I started with just the upright part of the spool holder. ¬†Then, the spool spun a bit too easily, and it would unspool and catch on things. ¬†The angled portion holds a dry sponge with a hole in it. ¬†This has the dual purpose of wiping the dust off of the filament and providing a small amount of friction.

The reprap is all finished.

The reprap is all finished.

The green adapters on the spool ends are just bearing holders that help the spool turn more easily. ¬†It was the first thing that I printed. ¬†Here’s a very short video of it working:

¬†The final issue I had was with the GFCI circuit in my office. ¬†I can’t figure out why I have GFCI there, but I do. ¬†To add insult to injury, my firewall/router/server is on the same circuit. ¬†So, every time the printer trips my GFCI, it takes down the internet and generally causes havoc. ¬†I pulled my hair out over this one. ¬†I replaced my (very expensive) GFCI circuit breaker and the printers power supply.

Trying to measure GFCI current

Trying to measure GFCI current

In the photo above, I’m trying to measure the peak ground current from the printer. ¬†The fluke is on the mA setting with peak hold. ¬†This is the highest reading I ever got, and the circuit didn’t trip. ¬†It’s my understanding that GFCI trips when there’s about 30mA on the ground circuit. ¬†My assumption at this point was that the shunt resistance in the DMM was limiting the peak current, therefore no 30mA spike and no trip.

The problem persisted for sometime, and I began to suspect the GFCI breaker. ¬†I went to an electrician store, and the guy said that they can wear out.¬† After I replaced the circuit breaker, and $50 later, the problem got worse! ¬†It would trip even when the printer wasn’t plugged in! ¬†At least then, it was no longer an¬†intermittent¬†fault. ¬†Now that I could reliably cause the fault, I at least had hope for isolating it. ¬†I unplugged everything on the circuit and plugged in things one-by-one. ¬†I turned out that a cheap power strip (the same kind as in the above photo) was the culprit. ¬†Boooo.

Any way, I’m now a 3D printing convert. ¬†But I promise I won’t be annoying about it. ūüôā

, , , , ,

No Comments