This has been a very helpful thread for me. Thanks to many of the contributions here, I've gotten my XU4
- run from battery for over 3 hours, with the batteries claiming they're nowhere near spent, (as judged by the 4 blue LED indicators,)
- record H.264 video on *two* cameras simultaneously at 640x480 on a high quality setting the whole time, (although one camera seems to have dropped out after about 27 minutes for what appear to be software (ffmpeg) underflow reasons).
There were many obstacles to overcome, and several of the posts here have been instrumental in overcoming them. But first, the proof:https://www.youtube.com/watch?v=osY7ODJco5Q
My ultimate aim is to do some kind of AR/stereomorphic projection / flow-field mapping in real time while riding a bicycle, (DON'T try this at home - *I'm* not even there yet.) As a first step, I needed to get the odroid to run on battery for a prolonged period, and do some non-trivial work. And, acquiring video data will be useful for later stages. So, I set the first milestone to be acquiring video from 2 cameras on a long bike ride. Later, I want to do real-time processing and display on, e.g., something like this: https://store.vufine.com/collections/all
or thishttps://www.amazon.com/Gender-ACCUPiX-G ... B00AXVWNGA
(much riskier, not recommended, but cyber-punk as ****.)
As far as applications, I think a visual speedometer overlay would be pretty rad. Or something that overlays your planned route so you don't have to stop to check your google maps or strava route along the way. Or something that shows points of interest, places to eat, or bike routes. Or it could display low optical flow areas in high color saturation (low optical flow means the object is moving right at you,) so you can see oncoming collisions before they hit you. But mainly, I just want to get something to work in real time from battery, preferably using the GPU.
Some people suggested getting a 12V battery + voltage converter + soldering, but I am not a soldering enthusiast, and would rather throw $$ at the problem so I got 2 of these:https://www.amazon.com/gp/product/B012N ... UTF8&psc=1
and then for good measure I threw in one of these:https://www.amazon.com/gp/product/B01G1 ... UTF8&psc=1
They look like a lot of money, but if you check https://slickdeals.net/
2-3 times a week you'll see a deal on them. You could get the three for < $100 that way.
In theory, this combination should deliver ~12 amps, but I had my odroid spontaneously reboot on me several times, so probably the "smart" electronics were making them deliver less current than they're rated for, probably since lithium battery fires are more of a liability than underperforming batteries used for bobby projects. The upside is, they last longer. It's also possible that the massive USB daisy chain I used had something to do with it. *shrug*.
Thanks go to:
-jacky for this (I needed 5):https://www.amazon.com/Power-Enhancer-F ... le+femelle
and this (I needed 1):https://www.amazon.com/niceeshop-Barrel ... +%2F+2.1mm
-jl303 mentioned the Anker batteries, but they were even more $$, and I couldn't find that exact one.
-dronus for the -maxcpus=2 tip (I got mine to run with maxcpus=4 just as well. Maypbe the "cpus" are just threads, and the cores are what counts. Occasionally I've noticed things tend to break down when you cross from the 4th cpu to the 5th. YMMV, though.)
- The question then is, if you boot with 2 or 4 cpus online, how do you re-enable them? Elsewhere on the odroid forums I found this trick:
echo 1 > /sys/devices/system/cpu/cpu[0:7]/online
That's it, you can re-enable the cpus one at a time. BUT! what if you re-enable them all at the same time? You'll crash. So, what I did is, I created a script that does this:
echo 1 > /sys/devices/system/cpu/cpu4/online
echo 1 > /sys/devices/system/cpu/cpu5/online
echo 1 > /sys/devices/system/cpu/cpu6/online
echo 1 > /sys/devices/system/cpu/cpu7/online
and it works! The limitation is not how much total amperage the batteries can support - it's how *sudden* of an amperage demand they can support.
Likewise, I set the governor to "conservative" since that's designed to ramp up the cpus more slowly. I'm experimenting with mixing performance and conservative governors to get the best cpu utilization without maxing out the batteries. I believe the package you want is called "cpufrequtils". The command you want is "cpufreq-set", which allows you to set the governor and the max clock frequency for each cpu. The video you see above was set using 1600M as the max frequency for each core, (although the first 4 cores really wanted to run at 1400M for some reason.)
I also needed to figure out how to disable X11 on startup, but that information was elsewhere. Sorry, I don't have the link where I found that information, but it wasn't a major obstacle. You can google it.
This page on FFMPEG was useful:https://trac.ffmpeg.org/wiki/Encode/H.264
The command I use to start the capture is:
ffmpeg -s 640x480 -i /dev/video0 -c:v libx264 -preset ultrafast -crf 17 cam0.mpg -y
ffmpeg -s 640x480 -i /dev/video1 -c:v libx264 -preset ultrafast -crf 17 cam1.mpg -y
The -crf argument is important. It tells ffmpeg what quality you want. Lower is better, and I think 0 is lossless. People say that 18 is the threshold for subjectively seeing compression artifacts, and I agree after having tried several settings. So I set it to 17. With the 2 batteries, though, the best I could get was 19 without crashing. (That's why I got the third.)
I find it convenient to start each from a different tty. Then I unplug from the monitor, and go on a bikeride.
I looked up the answer to how to how to disable the GUI, and it turns out I didn't just google it, I got it from the odroid user in this thread:viewtopic.php?f=112&t=9722#p167971
The command is
sudo systemctl disable lightdm.service
Restarting the GUI can be done with the command
sudo service lightdm start