Saturday, January 25, 2014

Raspbian for APC 8750 (Apricot install)

This seems to be getting hard to find.

http://thunderace94.wordpress.com/2013/06/12/apc-8750-install-raspbian-on-nand-flash/


Apricot R4 on NAND, for APC.io WM8750

Overview

For memory. Adapted from this repost, original source: RoyalPanda from APC.IO forum.
The plot is simple: How to install a real GNU/Linux on the APC.io wm8750 PicoITX board. Royal Panda made a great job adapting Raspbian for the APC, he called this remix Apricot
The last release is Apricot R5, but it still lacks Video support (among others things) and Royal Panda didn't release any NAND installer. So this “tutorial” is made with the previous release: Apricot R4. The process should stay the same if there's an update one day…
Long story short: I needed to reinstall my APC board, but the kernel I had (and though was the one from the installer) lacks the UBI support, so I couldn't follow the original Howto…

Steps

What you'll need

  • The board itself, the original APC.io board: WM8750
  • A 1 Gio MicroSD card
  • An Ethernet connection
  • A Serial adapter
  • Screen and Keyboard might help too…

Files

  • The Installer Files with a scriptcmd file (it's easier this way, but don't worry, you'll play with uBoot via Serial)
  • mtd-utils deb package (so you don't have to type the URL to download it)
  • mod-kernel-RaspBian.tar.gz (the Kernel to be flashed on the NAND)
I've made a bundle with the useful files: Here
  • Apricot R4 MMC (for its rootfs): Here

MicroSD preparation

The easy way is to copy the Apricot R4 img on the uSD card, then add the the other files on the first partition.
  dd if=./ApricotR4-NoGUI-1G-SDCARD.img of=/dev/sdh bs=4096
There should be one partition named XCP-1.6.10 Base Pack. Copy the files initrd.gz, uzImage.bin, scriptcmd, mtd-utils (DEB package) there, replace the existing files (uzImage.bin and scriptcmd)
Create a folder where you extract the mod-kernel-RaspBian.tar.gz archive. Mine's named modKern.

First boot

Insert the MicroSD card, boot the board. The debian-installer should start (on the screen, not in serial). Choose your language, you don't need the Network. Stop the installer as soon as you can, and drop to a Shell. From the menu, it's the Execute a shell option.
Make sure your NAND layout is correct:
  cat /proc/mtd
You should see this:
  dev:    size   erasesize  name
  mtd0: 00d00000 00010000 "filesystem-SF"
  mtd1: 00280000 00010000 "kernel-SF"
  mtd2: 00050000 00010000 "u-boot-SF"
  mtd3: 00010000 00010000 "u-boot env. cfg. 1-SF"
  mtd4: 00010000 00010000 "u-boot env. cfg. 2-SF"
  mtd5: 00010000 00010000 "w-load-SF"
  mtd6: 00a00000 00100000 "kernel"
  mtd7: 7f600000 00100000 "rootfs"
If your layout is different, stop here unless you know what you're doing…
Mount the first partition of the uSD card somewhere, Flash the kernel on the NAND (mtd6)
  mkdir /mnt
  mount /dev/mmcblk0p1 /mnt
  cd /mnt/modKern
  dd if=uzImage.bin of=/dev/mtdblock6
You can try to erase the mtd partition before flashing the kernel, but I'm not sure it'd work, and if that's really necessary since dd does a raw copy…
Shutdown the board. Unplug the uSD card.

Second Boot

Connect your serial adapter, open with these parameters: 115200 8n1 without any flow control.
Restart the board.Interrupt the boot process in uBoot by pressing Enter. It should drop you to a uBoot shell. Enter theses lines
  setenv nandargs "setenv bootargs mem=460M ubi.mtd=7 root=/dev/mmcblk0p2 console=ttyS0,115200n8 console=tty0 mtdparts=WMT.nand:10m(kernel),-(rootfs)"
  setenv nandboot "nandrw r 0x0 0x1000000 0x400000;  if iminfo 0x1000000; then run nandargs; bootm 0x1000000; fi"
then
  boot
When the Kernel starts booting, insert the uSD card so it can find the rootfs. When the system is ready, you should be able to connect using SSH. Login: root, password: apricot. Use the physical screen and keyboard to find out the IP address
From now it's pretty much the same as the original HowTo. Format the mtd7 partition (the rootfs)
  mount /dev/mmcblk0p1 /mnt
  dpkg -i /mnt/mtd-utils_1.5.0-1_armhf.deb
  umount /mnt
  ubidetach -d 0
  ubiformat /dev/mtd7
  ubiattach -p /dev/mtd7
  ubimkvol /dev/ubi0 -m -N rootfs
  mount -t ubifs ubi0:rootfs /mnt
Debootstrap Time ! It ccan be quite long, so… once you've seen it's start correctly, go do something else, have a coffe, take a (short) nap, …
  apt-get install -y debootstrap
  debootstrap --no-check-gpg wheezy /chroot http://mirrordirector.raspbian.org/raspbian/
Once it's done, you can chroot in your new system !
  mount -t proc none /mnt/proc
  mount -t sysfs none /mnt/sys
  mount -o bind /dev /mnt/dev
  chroot /mnt
You should now be using the rootfs on NAND, time to setup the Raspbian distro
  mount /dev/mmcblk0p1 /mnt
  cp -R /mnt/modKern/modules /lib/
  depmod
Install uBoot tools to be able to change the uBoot parameters if/when you need
  apt-get install u-boot-tools
  echo "/dev/mtd3 0x0000 0x10000 0x10000" > /etc/fw_env.config
  echo "/dev/mtd4 0x0000 0x10000 0x10000" >> /etc/fw_env.config
  fw_printenv ## Should print the uBoot env
Make the previous setenv changes permanent:
  fw_setenv nandargs "setenv bootargs mem=460M ubi.mtd=7 root=ubi0:rootfs rootfstype=ubifs console=ttyS0,115200n8 console=tty0 mtdparts=WMT.nand:10m(kernel),-(rootfs)"
  fw_setenv nandboot "nandrw r 0x0 0x1000000 0x400000;  if iminfo 0x1000000; then run nandargs; bootm 0x1000000; fi"
Setup you debian installation
  passwd 
  echo "proc /proc proc defaults 0 0" >> /etc/fstab
  echo "ubi0:rootfs / ubifs defaults 0 0" >> /etc/fstab
  echo "" >> /etc/network/interfaces
  echo "allow-hotplug eth0" >> /etc/network/interfaces
  echo "iface eth0 inet dhcp" >> /etc/network/interfaces
Install the SSH server
  apt-get update
  apt-get install openssh-server tmux
Edit the inittab to enable a serial session, just in case…
  nano /etc/inittab
That should be it, you can safely poweroff the board, unplug the uSD card, then reboot.

That's all folks !

Well, you now have a working Debian Wheezy system. I haven't tested all the graphic part, since it's running as server under my desk, but it should work fine…

Troubleshooting

The board doesn't start ? Even with Firmware 1.2, it seems the board sometimes needs a screen attached to complete the boot process and connect to the network…

Monday, January 20, 2014

MTP file system setup for linux (Android device, mounted automatically)

Linux

Linux MTP setup
On a Linux install, things aren't quite as easy.  On the plus side you have a bit of control how things are mounted, but there's no one click solution.  Don't be discouraged, you can have MTP set up and running in no time with a bit of terminal command fun.  Here's a walkthrough for using the Galaxy Nexus with Ubuntu:
Set up a UDEV rule via the terminal by opening the rules file
sudo nano -w /etc/udev/rules.d/51-android.rules
And entering the following line at the end of the file (be sure to use your user name at the end!):
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0600", OWNER="<your-username>"
Now install the tools and set a mount point by entering the following commands one line at a time
  • sudo apt-get install mtpfs
  • sudo mkdir /media/GNexus
  • sudo chmod 775 /media/GNexus
Plug your Galaxy Nexus in, and enter the next line in the same terminal window:
sudo mtpfs -o allow_other /media/GNexus
Drag and drop through Nautilus, and when you're done and need to unmount, enter the following:
sudo umount mtpfs
This will have to suffice until someone writes a couple scripts or a front end.  You don't have to install mtpfs, make the mount point, or chmod it after the first time.  You may have to mount the device manually each time, I'll know more when I get one to play with.

http://www.androidcentral.com/ics-feature-mtp-what-it-why-use-it-and-how-set-it 

ADB mode tricks

Screen recording with adb

adb shell screenrecord /sdcard/filename.mp4 
Save the file to the device SDcard and press ctrl+c to stop recording.
Here is a video on a easy way to screen record. VIDEO

 Logcat

WHAT IS A LOGCATLogcat is the command to view the internal logs of the Android system. Viewing logs is often the best way to diagnose a problem, and is required for many issues. This way you'll find out what apps are doing in the background without you noticing.

TAKING AN LOGCAT
Now type this in the terminal 
adb devices (note) to make sure devices is connected
adb logcat -v long > logcat.txt
OR
adb logcat > logcat.txt:


ADB Commands

ADB Commands
Quote:
adb devices - list all connected devices
adb push <local> <remote> - copy file/dir to device
adb pull <remote> [<local>] - copy file/dir from device
adb sync [ <directory> ] - copy host->device only if changed
(-l means list but don't copy)
(see 'adb help all')
adb shell - run remote shell interactively
adb shell <command> - run remote shell command
adb emu <command> - run emulator console command
adb logcat [ <filter-spec> ] - View device log
adb forward <local> <remote> - forward socket connections forward specs are one of: tcp:<port>
localabstract:<unix domain socket name>
localreserved:<unix domain socket name>
localfilesystem:<unix domain socket name>
dev:<character device name>
jdwp:<process pid> (remote only)
adb jdwp - list PIDs of processes hosting a JDWP transport
adb install [-l] [-r] [-s] <file> - push this package file to the device and install it
('-l' means forward-lock the app)
('-r' means reinstall the app, keeping its data)
('-s' means install on SD card instead of internal storage)
adb uninstall [-k] <package> - remove this app package from the device
('-k' means keep the data and cache directories)
adb bugreport - return all information from the device
that should be included in a bug report.
adb help - show this help message
adb version - show version num
DATAOPTS:
(no option) - don't touch the data partition
-w - wipe the data partition
-d - flash the data partition
scripting:
adb wait-for-device - block until device is online
adb start-server - ensure that there is a server running
adb kill-server - kill the server if it is running
adb get-state - prints: offline | bootloader | device
adb get-serialno - prints: <serial-number>
adb status-window - continuously print device status for a specified device
adb remount - remounts the /system partition on the device read-write
adb reboot [bootloader|recovery] - reboots the device, optionally into the bootloader or recovery program
adb reboot-bootloader - reboots the device into the bootloader
adb root - restarts the adbd daemon with root permissions
adb usb - restarts the adbd daemon listening on USB
adb tcpip <port> - restarts the adbd daemon listening on TCP on the specified port
networking:
adb ppp <tty> [parameters] - Run PPP over USB.
Note: you should not automatically start a PPP connection.
< tty> refers to the tty for PPP stream. Eg. dev:/dev/omap_csmi_tty1
[parameters] - Eg. defaultroute debug dump local notty usepeerdns
adb sync notes: adb sync [ <directory> ]
< localdir> can be interpreted in several ways:
- If <directory> is not specified, both /system and /data partitions will be updated.
- If it is "system" or "data", only the corresponding partition is updated.

environmental variables:
ADB_TRACE - Print debug information. A comma separated list of the following values
1 or all, adb, sockets, packets, rwx, usb, sync, sysdeps, transport, jdwp
ANDROID_SERIAL - The serial number to connect to. -s takes priority over this if given.
ANDROID_LOG_TAGS - When used with the logcat option, only these debug tags are printed 


FAstboot commands:

Fastboot Commands
Quote: Example (fastboot flash recovery TWRP-recovery.img) then hit enter this will flash a recovery image to the device.
usage: fastboot [ <option> ] <command>
commands:
update <filename> reflash device from update.zip
flashall flash boot + recovery + system
flash <partition> [ <filename> ] write a file to a flash partition
erase <partition> erase a flash partition
getvar <variable> display a bootloader variable
boot <kernel> [ <ramdisk> ] download and boot kernel
flash:raw boot <kernel> [ <ramdisk> ] create bootimage and flash it
devices list all connected devices
reboot reboot device normally
reboot-bootloader reboot device into bootloader
options:
-w erase userdata and cache
-s <serial number> specify device serial number
-p <product> specify product name
-c <cmdline> override kernel commandline
-i <vendor id> specify a custom USB vendor id
-b <base_addr> specify a custom kernel base address
-n <page size> specify the nand page size. default: 2048
from:    https://sites.google.com/site/tomsgt123/adb-fastboot

Galaxy Note 2 info

https://sites.google.com/site/tomsgt123/all-videos/samsung-galaxy-note-2




Monday, January 6, 2014

Removing crapware from android

This bit was lifted from a nice blog entry (dissed in comments, but had a tidbit below that is useful).

Android phones are shipped with apps that are there to annoy help you with using your phone, and can't be disabled w/o rooting your phone and proceeding carefully.

this suggests a way to shut them off from launching at lest.  They'll litter your apps button screen, but won't launch when the phone is booted at least.

Here is the link,

http://www.itworld.com/security/381716/want-protect-your-android-phone-heres-how-kill-its-crapware

here is the info:

If you've got Android 4.0 or above and want to disable the crapware without rooting the phone, here's how to do it. Note that many manufacturers have customized Android, so the instructions here might differ a bit from what you'll see on your phone. But the general instructions and principles are the same.
First, go to Settings. You'll find the Settings menu in the App Menu , or else you can get there by pulling down the notification drawer and tapping Settings. Once you're there, go to "Apps." Depending on your phone, it might be called "Manage Apps," or even "Application Manager."
Now swipe to the All apps list. Scroll to find an app you want to disable. Tap it. The App Info page appears. If the app isn't true crapware, there will be an Uninstall button. Simply tap the button to uninstall the app. But if it is crapware, an Uninstall button won't be there. There will, however, be a button that reads either "Uninstall updates" or Disable. If there's an "Uninstall updates" button, tap it. The button will change to read Disable.
Tap the Disable button. That will disable the app, and from now on, the app won't launch in the background. If you want to enable the app, head back to the All apps list. You'll find disabled apps at the bottom. Tap any you want to enable, then tap the Enable button.
Disabling the app, won't actually remove it from your system, which means it will take up hard disk space. That shouldn't be a problem. But if you absolutely, positively want to get the app off your system, you're going to have to root your phone, then use a free piece of software called NoBloat Free. There are plenty of ways to root your phone, and my suggestion is to do an Internet search. Keep in mind that it can prove to be problematic, and you'll void your phone's warranty if you do it, so make sure it's really something you want to do. A few good starting points are this page from Android Central and this page from LifeHacker. Once you've rooted the phone, run NoBloat Free.

Friday, December 27, 2013

file table is full on macos

ah, the mac which "just works".

this happens now when I try to preview a directory full of images from one of my surveillance cameras, of about 2900 in this case.

looks like something is using too many files.  I'm going to try rebooting and not starting everything and see what happens.

this message comes out of the console log in my case.

here is a google group discussion with a message with some sysctl command suggestions.

https://groups.google.com/forum/#!topic/uk.comp.sys.mac/Qw7QxZGXGak

> Third time now. Machine hasn't been touched in almost a week, I come
> back and find it has hung - hard power off, then after reboot i find
> the kernel log full of 'file table is full'.
>
> Any ideas how to go about tracing this?
This limit is controllable using sysctl. To see the current values:
sysctl kern.maxfiles kern.maxfilesperproc
Mine says 12288 and 10240. OS X *used* to read in definitions when it
booted from /etc/sysctl.conf, but you can change those values on the
fly.
Why you're running out is more of a mystery. I suppose you could run
lsof regularly over a period and see what changes.

Thursday, December 26, 2013

yum notes Redhat Enterprise Linux 6.2 or such.

to find out what package contains a command using yum.  must have repository set up.

yum whatprovides vnc-server

To set up repository after installation to use dvd as source:

put this in /etc/yum.repos.d/rhel-media  (any file name will do)

[rhel-media]
name=Red Hat Enterprise Linux 6.2
baseurl=file:///mnt/cdrom/Server/

file:///mnt/cdrom/
gpgcheck=0
enabled=1
gpgkey=file://etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release


The gpgkey can be left out if the gpg checking is off (as shown)  noted only if you want to mess with such.  for media it isn't much use if you know where your media came from.

yum will find and install any package on the dvd.  Create another file in the repos directory for any additional media.  This example uses the 6.2 install media dvd 1 as an example.

Gui application install front end for system, also invoked by system->administration->add/remove software with gnome desktop

 gpk-application

run from a gnome command window at user level command line (not root).

Jay's 3174 setup instructions

Re: 3174 ( and Jay's parms)

Last year, Jay sent me these customization parms which worked well
for me. (Thanks again, Jay) I found that the 3278, 3178, 3191 (from
heaviest to lightest) work the best. The 3279 seems to work okay but
as I indicated previously, graphics support is disabled.
Dave S.
(Following from Jay)-------------------------------------
Here you go:

This configuration is defined to use 2 physical terminals with 5
logical
terminal sessions each. There is no SNA host on my network, so SNA
parameters are only specified enough to keep the customization
procedure
happy. My controller does not have AEA hardware, so it's disabled and
no
customization is done for it. Questions not specified here are
allowed to
default.

Main menu option 1, customization:

Model/Attach:

098 FOO (online test password)
099 whatever (product assistance data)
100 63R (controller model)
101 7 (host attach via Token Ring)
102 1 (LAN adapter type)

Token-Ring Description:

080 4000 C0A8 4902 (address; 40000 + hex value of IP address)
082 1 (16 MBPS ring speed, with no early release)

LAN:

106 4000 C0A8 4902 04 (address and SAP)
107 4000 C0A8 4901 04 (gateway address and SAP; dummy value)
108 23V4504 (my machine S/N)
110 2 0000 (MLT configuration: allow controller to assign addresses)
116 1_ __ (MLT addressing)

Common SNA:

all defaults

117 - Port Assignment:

Enter 5 for IS for first two ports (26-00 and 26-01), and any others
you
intend to use.

Frame Relay Description:

300 0 (disable frame relay)

End-User Productivity Functions:

001 0000 (Local Copy print queue buffer size)
002 1 (calculator function - RPN)
003 0 (5250 emulation off)
004 5 (LAN T1 timer)
005 07 (LAN retry count)
006 N (copy from session to session)
007 N (HAP sharing for local copy)
008 Y (CSCF IML passwor drequired)
009 all 0s (nonstandard options)

Save your responses.

Main menu option 5, AEA/TCP/IP configuration:

AEA and TCP/IP Configure:

700 0 1 (disable AEA, enable TCP/IP)

Port set:

1 Name 3270DISP, session limit 5, port type 1

Port to Port Set Map:

Enter 1 in ports 26-00 and 26-01. (And any others you intend to use.)

There will be 4 AEA and TCP/IP station sets.

Set 1:
721 UNUSED SNA (station set name)
722 3H (station type: 3270 host)

Set 2:
721 TELNET (station set name)
722 TH (telnet host)
751 4 (emulate VT220 with 7-bit controls)
763 0 (new line option: don't assume LF with CR)

Set 3:
721 TN3270 (station set name)
722 TH (telnet host)
751 6 (TN3270)

Set 4:
721 3270 DISPLAYS (station set name)
722 3D (station type: 3270 display)
723 3270DISP (port set name)

AEA and TCP/IP Default Destination:

Leave all entries blank. This will force all logical terminals to the
connection menu.

TCP/IP Options Menu:

052 192.168.073.002 (3174 IP address; change as needed for your LAN)
054 255.255.255.000 (IP subnet mask; change as needed)
057 N (3174 will not do IP routing)
058 010 (maximum telnet sessions; set to 5*number of devices)
059 00 (maximum printer connections)
060 0020 (TCP/IP buffer space, in KB; adjust as needed once you see
how much
memory is actually used)
062 Y (routing field support)
064 Y (all routes broadcast)

TCP/IP Routing Information:

Enter one route, no destination IP address, type D (default), router
IP
address 192.168.073.001 (or whatever your default gateway is).

TCP/IP Domain Name Services: (Change these as needed.)

Controller Hostname: MRSQUEAK
Controller Domain Name: CONMICRO CX (note the space instead of dot)
Domain Nameserver IP Addresses: 192.083.120.001

TCP/IP Controller Defined Nicknames:

Leave blank. (Unless you want to define the equivalent of /etc/hosts.)

Save responses. You're done.

Wednesday, December 25, 2013

Grabbing X11 display into an mpg file (example from ffmpeg man pages Ubuntu)

I didn't know this had been integrated or that there was a method for ffmpeg input to be the x display.

EXAMPLES

   Video and Audio grabbing
       If you specify the input format and device then ffmpeg can grab video and audio directly.

               ffmpeg -f oss -i /dev/dsp -f video4linux2 -i /dev/video0 /tmp/out.mpg

       Note that you must activate the right video source and channel before launching ffmpeg with any TV viewer such as
        xawtv ("http://linux.bytesex.org/xawtv/") by Gerd Knorr. You also have to set the audio recording levels correctly with a standard mixer.

   X11 grabbing
       Grab the X11 display with ffmpeg via

               ffmpeg -f x11grab -s cif -r 25 -i :0.0 /tmp/out.mpg

       0.0 is display.screen number of your X11 server, same as the DISPLAY environment variable.

               ffmpeg -f x11grab -s cif -r 25 -i :0.0+10,20 /tmp/out.mpg

       10 is the x-offset and 20 the y-offset for the grabbing.

               ffmpeg -f x11grab -follow_mouse centered -s cif -r 25 -i :0.0 /tmp/out.mpg

       The grabbing region follows the mouse pointer, which stays at the center of region.

               ffmpeg -f x11grab -follow_mouse 100 -s cif -r 25 -i :0.0 /tmp/out.mpg

       Only follows when mouse pointer reaches within 100 pixels to the edge of region.

               ffmpeg -f x11grab -show_region 1 -s cif -r 25 -i :0.0+10,20 /tmp/out.mpg

       The grabbing region will be indicated on screen.

               ffmpeg -f x11grab -follow_mouse centered -show_region 1 -s cif -r 25 -i :0.0 /tmp/out.mpg

       The grabbing region indication will follow the mouse pointer.

Grabbing input from other devices:

http://ffmpeg.org/ffmpeg.html

Video and Audio grabbing

If you specify the input format and device then ffmpeg can grab video and audio directly.
ffmpeg -f oss -i /dev/dsp -f video4linux2 -i /dev/video0 /tmp/out.mpg
Or with an ALSA audio source (mono input, card id 1) instead of OSS:
ffmpeg -f alsa -ac 1 -i hw:1 -f video4linux2 -i /dev/video0 /tmp/out.mpg
Note that you must activate the right video source and channel before launching ffmpeg with any TV viewer such as xawtv by Gerd Knorr. You also have to set the audio recording levels correctly with a standard mixer.