Friday, July 07, 2017

Gentoo on RaspberryPi

There are several guides on how to setup Gentoo on a Raspberry PI.  For whatever reason they all seem to have mistakes or things in them that frustrate me.

[Edit:  This is a story of failure.  I've struck out the useless & frustrating bits.  The only interesting or possibly useful bit is at the bottom.]

So here is my guide, for me, which you will probably find mistakes in and find frustrating. Sorry.

So if you really want the best speed from you Pi SD card the partitions need to be done in just the right way - or so I'm told:
However it's worth noting that the SDCard reader on the Pi does have a theoretical limit on how fast it can move data.  I think its somewhere close to 25Mbps (MBps?).  So maybe don't expect that your extreme/pro/super card will run at top speed no matter what we do to it:

fdisk -c=dos /dev/mmcblk0
x (expert mode)
h (set to 255)
s (set to 63)
p (check out the total bytes on the card)
c (set cylinders = integer part of { [total bytes] / 255 / 63 / 512 })
   (Probably the same as the default because we started with "-c=dos")

r (go back to regular mode)

(I make my partitions like this:
Disk /dev/mmcblk0: 14.4 GiB, 15489564672 bytes, 30253056 sectors
Geometry: 255 heads, 63 sectors/track, 1883 cylinders
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x9649c08a

Device         Boot    Start      End  Sectors  Size Id Type
/dev/mmcblk0p1 *          63   262207   262145  128M  c W95 FAT32 (LBA)
/dev/mmcblk0p2        262208 28155902 27893695 13.3G 83 Linux
/dev/mmcblk0p3      28155903 30253055  2097153    1G 82 Linux swap / Solaris

I put the swap at the end, cause I figure it will get trashed and die from heavy use.  Maybe I wil be able to shrink partition 2 and just move the swap in as write fatigue destroys it. YMMV)

mkfs.vfat -F 32 -n BOOT /dev/mmcblk0p1
mkfs.f2fs -L ROOT/dev/mmcblk0p2
mkswap -L SWAP /dev/mmcblk0p

(Might need to choose something other than f2fs to start with, I think the modern raspberry pi kernels support ext4)

Then mount them up at /mnt/gentoo and /mnt/gentoo/boot

And start copying files, I followed these instructions:
And that didn't work: kernel panic couldn't mount the partitions...  I think the problem was with the /boot/cmdline.txt file.  But seeing as I already took issue with that guy's sdcard formating and choice of filesystem, I decided to look elsewhere.

I tried to follow these instructions:

mount /dev/mmcblk0p1 /boot
emerge --oneshot sys-boot/raspberrypi-firmware

* Please configure your ram setup by editing /boot/config.txt

vim /boot/cmdline.txt
"root=/dev/mmcblk0p2 rootdelay=2"

mount /dev/mmcblk0p2 /mnt/gentoo
mkdir /mnt/gentoo/boot
mount /dev/mmcblk0p1 /mnt/gentoo/boot
tar xpjf /home/anon/Downloads/Gentoo\ RPi\ Images/stage3-armv6j_hardfp-20161205.tar.bz2 -C /mnt/gentoo


This isn't working....  All the guides I've been able to find are terrible. Many broken links, small incomplete sections, nothing covered thoroughly, while trying to cover a huge variety of software and scenarios:
*Using portage to get firmware.
*At least four different sections concerning installing the kernel
*Modifying ebuild files
*Stage 3 downloads
*Stage 4 downloads
*Cross compiling with cossdev
**Creating an overlay
*Compiling using chroot
**Using QEMU virtualization
* Binhost servers (

Really! >:-(

That's too much stuff to just touch on and assume that the reader will figure it out.  I wasted days trying to work though all that, and I've at least experienced many of those concepts/software before.  If you were trying to scare someone off of using Gentoo on a raspberry pi; congratulations: you did a great job!  (Jerk.)
Then near the bottom I find this:

Is a working link to a Raspberry Pi 3 image that can be installed by Noobs, and has clear instructions.
I ordered a couple of raspberry pi 3's and I'll wait for them to arrive.

(What a waste...)

In the mean time I started working on my own Gentoo on Raspberry Pi wiki how-to.  I don't know if I'm going to be successful; but if I can figure out how to get Gentoo onto a Pi - then I can definitely write a better wiki page about it.

Sunday, July 02, 2017

Trying not to "fix" my phone.

So I went into settings on my Nexus 6 and tapped repeatedly on the Build Number; and apparently now I'm an Android developer!!! I ordered this phone within hours of it being available and I've been absolutely overjoyed with how well it's worked for me. I think however it's time for me to start playing with it. Maybe I'll try out the Lineage OS. First thing's first; I need to do some backing up and updating; then more backing up and testing.... Fun times, fun times!

Update 7/2/2017
Ok so I found some pages that gave information on how to backup parts of the phone, pictures, contacts etc... To my pleasure I'd already activated all the "built-in" Google backup options. So even if I screw this up tremendously it's likely that I can eventually get my phone back to a functional state. However what I'm really after is a complete image of the phone so that after messing around with it if I'm unhappy with the state of things I can just roll back to the way everything was before I started. I haven't been able to find a way to do this yet.
Things I have figured out, there are several software packages which are very interesting:
appears to offer the adb program which allows sending commands to the android OS, among other things.

The Open Handset Alliance's SDK

The Open Handset Alliance's NDK, for writing native code instead of transportable Java code.

The Open Handset Alliance's IDE for Android developers.

(Ha! The only one to have util in the name, and it's in the
 dev-java group instead of dev-util - It probably makes more sense than it seems, still funny :-) - I don't know what this is for yet. Says it's a library providing API's

What isn't clear at all is whether Android Studio comes with the Android-Tools, and the SDK, or whether all three need to be installed.  More questions...

Then this fell into my lap: According to an XDA Developers forum post: "All user data, content and media on the internal partition are erased when you unlock the bootloader."

So I need to get a backup I'm happy with before doing that, good tip! 

I installed Android Studio and then I really started to get upset:

I hate mystery meat navigation.  I'm desperate for some specific relevant information.  Even with very excellent adblocker software I'm spent hours pouring through useless web pages full of pictures, beggin for money, with the same abysmally low quality of information.  Hints, Allegations, and Things Left Unsaid.  I need some concrete documentation that doesn't have hundreds of pages of beginner crap at the beginning which I simply can't force myself to wade through.

All this effort to make stuff easy to use for the average person makes things REALLY HARD to use for someone who want's to really use the hardware.

This sucks.

After lunch I came back to this problem with fresh eyes and I found this.  Someone else, as frustrated as I, who diligently, and clearly, asked for help and got it!  Hooray for you Izzy! (and thank you!).

So I went into the developer settings on the phone and enabled USB debugging.
Then I swpied on the phone from the top down and selected Use USB for Charging, and changed it to Use USB for file transfers.
I was hoping that the phone would automagicially show up in the File Manager but it didn't...

I ran adb usb  and immediately got the Allow USB debugging? pop-up on the phone. - Progress!!

I'd like to access the files on the device and copy those over before tying out the adb backup command....   Hmm.

I did a little digging and found that Android uses MTP for file transfers, the sys-fs/mtpfs fits the bill. However is appears that my Kernel isn't built with FUSE support.   Doe!  Off to go build a new kernel.

Update 7/2/2017
   Working on the new kernel, I think I'd like to try turning on the "Randomize the address of the kernel image" option in the "Processor type and features" menu.  I seem to recall that I had that turned on before, but for what ever reason I have it turned off now.

Other changes:
General Setup - Timers subsystem - full dynticks -  I found this explanation and chose to go from idle dynticks to full dynticks.
General setup - Initial RAM filesystem and RAM disk - Turned off; not using it right now although I'm sure I will at some point.
General setup - Use a virtually mapped stack - A new option that I enabled for better kernel security.
Processor Type and Features - Common API for compressed memory storage & both ZBUD and Z3FOLD - This system doesn't have very much ram, this might help(?) Would be interesting to test a few things with and without this option.
Power Management and ACPI options - CPU Frequency scaling - Intel P state controll VS ACPI Processor P-states driver - Apparently performance differences between these drivers are tiny, but it might be interesting to try Intel's driver, for now I left it at the ACPI driver.  I did turn on the CPU idle PM support - Menu governor - and the CPU idle for Intel processors - seemed appropriate.
Device Drivers - Multiple devices driver suport (RAID & LVM) - Autodetect RAID arrays during kernel boot - Turned off, according to the tool tip it might save several seconds at boot up.
Device Drivers - Network Device Support - Ethernet driver support & PHY Device support and infrastructure & Wireless LAN - I changed everything to modules instead of built in - despite disabling quite a few drivers I'm sure I still have more than I need being built. - Will have to check to see what modules get loaded and thin the herd.
Device Drivers - Network Device Support - USB Network Adapters - Set everything to 'M' and turned off Multi-purpose USB Networking framework.
Device Drivers - Input Device Support - Mice - Synaptics I2C Touchpad Support & Synaptics USB device support - Turned both on as modules, maybe my touch pad will work now!!!  I either forgot to turn these on originally, or I was so annoyed at the touch pad that I disabled them - I don't remember which.
Device Drivers -Character devices - Serial drivers - 8250/16550 and compatible serial support - Changed from off to 'M' - Maybe this is the reason the touchpad wasn't working?
Device Drivers -Character devices - Hardware Random Number Generator Core Support - Changed the Intel and VIA driver to modules - Surely we have zero or one and not both of these, I'm guessing zero.
Device Drivers - Character devices -/dev/nvram - Turned this off.
Device Drivers - Graphics Support - Bootup Logo - Instead of just the 244 color logo I chose all three. - Maybe should disable all of these, and see if there is a difference; I'm not sure I've ever noticed the bootup logo.  Then again I like my computers to boot very quickly, maybe it just scrolls by too fast.  I should probably turn this off; the only bootup logo I want to see is SLiM.
Device Drivers - HID Support - Special HID Drivers - I enabled a few as modules here that referred to mice, maybe one of them is needed for the touchpad.
Device Drivers -HID Support - I2C HID Support - Enabled as a module, again touchpad..
Device Drivers - USB Support - USB ULPI PHY interface support - Set to 'M' - it's a new option and it says it provides functions such as ADP sensing/probing (OTG protocol) and USB charger detection.  Seeing as I have USB OTG adapters for the Raspberry Pi zero, maybe I'll need it someday.
Device Drivers - DMA Engine Support - Synopsys Designware AHB DMA PCI Driver - is marked as M and I can't change it - it used to be off.
Device Drivers - X86 Platform Specific Device Drivers - Asus Laptop Extras - Changed from disabled to Module
I kind of rushed through the crypto options because it's bedtime...  :-)   I'll have a go at compiling the kernel tomorrow,  I did remember to enable FUSE. ;-)

The Kernel compiled smoothly, and my little laptop now boots in under 15 seconds.  Still needs some work, but we're getting there. :-)  I had to use Samba/CIFS to help fix another laptop, So I rebuilt the Kernel with

Still trying to smooth out some of the wrinkles in my kernel:
Device Drivers - Misc devices - ME Enabled Intel Chipsets - Turned on
Device Drivers - Multifunction device drivers - Intel ICH LPC - Turned on

Found a new problem; one which I feel like I've encountered before: The UI fonts in libreoffice have gone to greek? maybe italian?  I managed to switch them to Japanese; but can't see to get them back to english.

Doing an emerge --oneshot libreoffice to see if that helps, then I'll try out these latest kernel modifications; including FUSE.

It did not help...

Nor can I connect via serial console cable to my Raspbery Pi.  I'm at least three problems deep now; I really wish I could solve one!