Gmenu2x with built-in WiFi tools

ZipIt Comments Off on Gmenu2x with built-in WiFi tools
Mar 312012

The title of the post kinda sums it up.  See the screen shot on the right?  The icons on the bottom are all new and map to the new functionality.  There’s even a signal meter on the bottom bar that let’s you know if your connected.  You can download it here.

In addition to the gui changes, I made a couple of edits to minimize calls inside the main polling loop.  I also moved the power management from gmenu2x and used my versions of bldaemon  and ebindkeys to manage the backlights on the screen and keyboard.  There’s still a couple of settings in gmenu2x for setting the levels, but the timers are all hard coded for now.  Since the on-screen keyboard wasn’t really needed it was removed and replaced with an input dialog.  The UI part was easy, but I had a hard time finding an SDL example that didn’t completely reinvent the keyboard, thanks to deeice on the irc board for providing some support. The updated source code is on github.

Installation instructions are the same as for NodeZ2, I even borrowed the install script and forgot to rename it, so it’s a bit misleading.  Note:  If you still have a ‘stock’ zipit mozzwald has created a very nice install script  for flashing uboot and gmenu2x/openwrt:

FlashStock v0.1.2 Jun-28-2012 (md5 c6d01d4117b8492c5f57d41d81c34330)

As of version 5, mozzwald’s overlay scripts are included, be sure to read his blog posting for the details.  Instructions for configuring the ZipIt opkg repository can be found here.

What else is included?  Gmu from wejp, a feature full mp3 player is the ‘goto’ app but I also have mpg123 included for situations when a lighter load is needed.  Retawq, a text based web browser is very light and pretty easy to use.

The configuration for nano includes color, here are a few revised syntax files (Update: included in version 7).

A lot of the keyboard configs are from IZ2s that deeice has been perfecting.   He also provides some scripts for emacs, an irc client, and a ‘320×240’ patch for htop.

As you can see from the main pic I also put a little UI on anarsoul’s USB mode drivers, it was almost a freebie after the groundwork for the wifi tools was laid.  USB drivers, lots of em.  I’ve only found one USB flash drive that I couldn’t read (and I didn’t even troubleshoot).  All 5 or 6 of my USB hard drives connected, that includes the Western Digital MyBook that I couldn’t find the right setup for in the past.

There’s minicom and the drivers for using the ZipIt as a serial terminal as well as USB networking drivers for bridging or adding wifi to devices that don’t have it already.  Batman and the scripts that are included in NodeZ2 are also there, I just need to make an icon, next release…

Hit the escape key while in gmenu2x and a menu will pop up that displays the hot keys.  The one to remember is ‘alt+home (Update: as of ver7 it became just ‘home’)… it will return you to gmenu2x. Also, tryout the wakeup program, it can be quite useful.  It’ll wakeup your ZipIt from suspend, or it can be used to suspend your process until it wakes up.  It blocks until it goes off.

 

There are additional security features included as of version 7, but you will need to enable and configure them manually.

  • adduser, addgroup
  • deluser, delgroup
  • /etc/busybox.conf    <–provides sudo-like functionality

Follow these steps to set up a new user account and disable root logins over SSH.

root@engine12:~# mkdir /home
root@engine12:~# mkdir /home/mark
root@engine12:~# mkdir /home/mark/.ssh
root@engine12:~# adduser mark
root@engine12:~# chown mark -R /home/mark/

busybox needs to be SUID to switch to root with “su”

root@engine12:~# chmod 600 /etc/busybox.conf
root@engine12:~# chmod 4755 /bin/busybox

disable root login and restart dropbear

root@engine12:~# nano /etc/config/dropbear
root@engine12:~# /etc/init.d/dropbear stop
root@engine12:~# /etc/init.d/dropbear start


Troubleshooting

  • If your ZipIt doesn’t boot after running the flash script the most likely cause is incorrect u-boot parameters.

You can check your settings from a u-boot prompt.  Press a key after powering on the ZipIt,  and at the prompt type printenv:

$ printenv

The correct bootargs should look something like:

bootargs “console=ttyS2,115200 fbcon=rotate:3 root=/dev/mtdblock3 rw rootfstype=jffs2”

To change the bootargs enter the following commands after the u-boot prompt.

$ setenv bootargs “console=ttyS2,115200 fbcon=rotate:3 root=/dev/mtdblock3 rw rootfstype=jffs2”
$ saveenv; reset

  • After using certain apps you can no longer run a bash shell, all you get is a blank screen.  The current solution is to press alt+tab.  This will switch to the correct virtual terminal.

 

Building

Here are a few tips for setting up Codelite to browse and edit the gmenu2x source tree under OpenWrt.

  • create a new custom Makefile project
  • right click on the new project and select “import files from directory”
  • select the gmenu2x source tree under <openwrt_root>/build_dir/target-arm_v5te_uClibc-0.9.32_eabi/

To build the changes I used the OpenWrt command-line.  You always need to remove the .built flag in the build_dir first or the package will not be re-compiled.

<openwrt_root>/make package/gmenu2x/compile -j2 V=99

With additional effort you can configure Codelite to run the above command when instructed to build.  Be sure not to issue a make clean or similar command though, OpenWrt will eagerly vaporize your efforts and overwrite them with a clean install of the gmenu2x tarball located in the dl folder.

 

Scripting the DirectFB

Uncategorized Comments Off on Scripting the DirectFB
Mar 162012

There is a new version of NodeZ2.  The biggest addition is a module for scripting the DirectFB within Node.js.  No browser required.  How cool is that!

It’s not very tested and there are holes in the implementation, but it’s still very functional.  Included are several example scripts that should get you going.  No cross compiler needed.

If you decide to flash it to the onboard memory beware, there is very little memory left in the jffs2 file system.  There is enough to store quite a bit of javascript, but if you opkg anything it should be directed to the overlayfs.

There is a problem with the keypad not working shortly after bootup.  Symptoms include not being able to use the alt key.  Until the problem is resolved you’ll need to work around it… suspend the ZipIt by pressing the power button, then wake it up by pressing power again.  This should get the keyboard working again.

NodeZ2_v4

To start one of the example scripts… cd to /root/node/dfb_examples and enter the following:

root@OpenWrt:~/node/dfb_examples# node df_window.js

Use the escape key to end the program.

Other new features include color syntax highlighting for javascript in nano.  You can add other syntax maps for bash or cpp files, but they’re not included by default.  I compiled nano to use the mouse too, but no luck.  Additional packages must be needed, I didn’t troubleshoot much.

The source for the new bindings is on github.


NodeZ2 is a tiny rootfs for the ZipIt Z2 designed to fit into the onboard flash memory.  It was created with the OpenWrt build system brought to the ZipIt by Projectgus… way to go bloke!

After flashing… the partition layout will leave ~1Mb of space for your Javascript web app, or other desired packages.  Additional packages can be added using the overlayfs and an SD card or USB memory.

Note: NodeZ2 will only start on a ZipIt that has the ‘U-Boot’ bootloader installed.

To flash NodeZ2 onto your ZipIt follow these steps:

  1. Download NodeZ2 (md5sum fa9b838736ad74f36533bc8896c60772)
  2. make an ext2 partition at least 20 MB in size, mount it then cd to the new partition
  3. unpack with the following command –>  root@OpenWrt:/# sudo tar -xjpvf ~/Downloads/NodeZ2_rc2.tar.bz2
  4. insert the SD card and boot the ZipIt
  5. After booting run    –> root@OpenWrt:/# /root/flash_NodeZ2.sh
  6. poweroff, remove the SD card, and boot the ZipIt
  7. change password     –> root@OpenWrt:/# passwd
  8. change mac address –> root@OpenWrt:/# nano /etc/config/wireless (option ‘disabled’ should be ‘1’)

 

*******   WiFi settings can be configured by pressing the ‘Home’ key followed by ‘c’  *******

Included packages:

B.A.T.M.A.N mesh networking

configure your meshnode with the included batconnect script

root@NodeZ2:/# batconnect zipit 2412 192.168.11.235 <— yields a static IP on channel 1

Node.js server side Javascript

root@NodeZ2:/# node /root/webserver.js to start the example

**use nano to edit and create new scripts

tmux terminal multiplexer

root@NodeZ2:/# readme for a list of hotkeys to use

mjpg_streamer webcam streaming server

root@NodeZ2:/# startWebCam (uvc webcam and USB mod required)

mpg123 mp3 player (also plays shoutcast streams)

root@NodeZ2:/# mpg123 -b 1024 http://ice.somafm.com/groovesalad

 

 


Back in December ZipIts were selling for $9.99 on amazon.  It seemed like way too good a deal to be true, but I couldn’t resist the urge to get one, they have so many features that interest me.  I figured it was worth the risk.  I received the ZipIt, installed Linux, and tested out the hardware.  Impressed as I was, I ordered 10 more.  One of the primary reasons for acquiring  this many ZipIts was to set up and experiment with a mesh network.  I’m not disappointed, the value of my Zipits went way up this past weekend!  This post describes the steps for configuring the ZipIt as a node on a mesh network.

As of Linux kernel 2.6.38 the batman-adv kernel module is in mainline.  Using buildroot I configured and built the kernel to include the module.  I cross-compiled the user land utility batctrl and installed it to the /usr/sbin directory of Z2Lite.

To set up a mesh network node, boot Z2Lite and issue the following commands.  I put them in a script file and assigned the script to a key in tmux.conf.  Be sure to kill the wpa-supplicant process if it’s running.

z2lite:~# modprobe batman-adv

z2lite:~# ifconfig wlan0 down

z2lite:~# ifconfig wlan0 mtu 1476
z2lite:~# iwconfig wlan0 mode ad-hoc
z2lite:~# iwconfig wlan0 essid zipit ap 02:1A:34:56:78:9A channel 1

z2lite:~# batctl if add wlan0

z2lite:~# ifconfig bat0 192.168.11.219
z2lite:~# ifconfig wlan0 up
z2lite:~# ifconfig bat0 up

Assign a unique AP mac address for each node (i.e. ZipIt) and choose a channel that best suits your environment.  That’s it, everything else is just like other IP networks, ping, ssh etc.  The batctl utility has a few commands for troubleshooting the network if you have issues.  I haven’t had time to experiment yet, but the first is going to be location triangulation.  I think it’s built into the protocol.

 

http://www.open-mesh.org/

http://hostwork.com/users/matt/zipitz2/

I configured one of my ZipIts to be a serial terminal for the beagleboard.  Like the ZipIt, the beagleboard has Uboot installed.  The flexibility of Uboot allows many different ways to get an image into RAM.  The methods available for the beagleboard require a serial connection.  Both methods outlined will require minicom to be installed on the ZipIt in order to communicate with the beagleboard.  The lrzsz package is also needed, it can sometimes be included in the minicom package, but double check in case it’s not.

z2sid-rc3:~#: apt-get install minicom

z2sid-rc3:~#: apt-get install lrzsz

 

My ZipIt was running z2sid-rc3 with a kernel built using this config in buildroot.

 

Method 1

I first connected the beagleboard to the ZipIt the same way I was connecting it to my laptop.  This setup requires a USB to serial converter, the usb-serial driver and minicom.  Lots of cables, but that’s how the beagleboard is configured by default, out of the box.  First of all, before plugging anything into the ZipIt’s USB, load the usb-serial driver.

z2sid-rc3:~#: modprobe usbserial

The USB hub can now be connected to the ZipIt.  Give the USB devices a second to register, a /dev/ttyUSB0 node will be created.  Attach a minicom session with the following command.

z2sid-rc3:~$: minicom -D /dev/ttyUSB0

 

Method 2

A little investigating and I was able to eliminate most of the wires and the USB hub by using USB serial over the beagle’s OTG port (in the prior setup, the OTG cable was only providing power).  This setup requires a different driver to be running on the ZipIt and the beagleboard’s Uboot environment variables need to be modified.  Start with changing the Uboot enviroment variables.  Enter Uboot and issue the following commands.  Note: this will require the setup from Method 1 in order to get a Uboot prompt on the ZipIt.

OMAP3 beagleboard.org # setenv usbtty cdc_ac

OMAP3 beagleboard.org # saveenv

OMAP3 beagleboard.org # reset

OMAP3 beagleboard.org # setenv stdout usbtty; setenv stdin usbtty; setenv stderr usbtty; saveenv

At this point Method 1 will no longer work on the beagleboard, as we have changed the stdin and stdout.

1.  Plug the ZipIt into AC power and boot z2sid-rc3.

2.  Load the cdc_acm driver with the following command.

z2sid-rc3:~#: modprobe cdc-acm

3.  Connect the beagleboard’s OTG cable to the ZipIt as shown in the picture for Method 2.

4.  There should be a new /dev/tttyACM0 node present now, attach minicom to it.

z2sid-rc3:~$: minicom -D /dev/ttyACM0

 

 

clonetty

The clonetty utility is needed for keeping minicom alive when plugging and unplugging the beagleboard.  It places a pseudo tty in between the ttyACM0 node and minicom.  The pseudo tty never goes down, and when the ttyACM0 node appears, clonetty takes care of setting up the link automatically.  The utility consists of a single C file and can be compiled with this make file.  I built mine right on z2sidx-rc3.  It’s assumed you have everything setup for Method 2.  These are the steps to set up clonetty and minicom.

1.  Plug the ZipIt into AC power, boot Linux.

2.  Connect the beagleboard’s OTG cable to the ZipIt as shown in the picture for Method 2.

3. Start minicom and configure the options to connect with the beagleboard (i.e. 115200 8N1), save as dfl and quit.

z2sid-rc3:~$: minicom -D /dev/ttyACM0 -o

4.  Start clonetty in the background.

z2sid-rc3:~$: clonetty /dev/ttyACM0 &

3.  Observe the output:

pty: /dev/pts/3
Using /dev/ttyACM0

4.  Attach minicom to the pty that clonetty just created.

z2sid-rc3:~$: minicom -p /dev/pts/3 -o

5.  You should now be able to unplug/plug or reset the beagleboard and the minicom connection will stay up.

 

 

omap-u-boot-utils

The omap-u-boot-utils package has source files needed for communicating with uboot and automating a serial transfer of an image into RAM.  There isn’t much OMAP specific code, the routines should work with any uboot’ed target.  This beagle_kermit.sh script uses the kermit method of serial transfer.  Start clonetty as described above, minicom is not needed.  Change to the directory with the omap-u-boot-utils and execute beagle_kermit.sh.  Note: the ‘port’ variable at the head of the script may need adjustment, it should match the output from clonetty.

z2sid-rc3:~/Uboot_utils$: ./beagle_kermit.sh

 

Links:

http://gitorious.org/clonetty

http://engine12.com/files/clonetty/Makefile

http://engine12.com/files/.config.04052011(usb_serial)

http://elinux.org/U-boot_musb_gadget_support

http://zipit.markamber.co/z2sid_v6_uboot_rc3.tar.bz2

http://code.google.com/p/omap-u-boot-utils/

 

By using the USB networking features of Linux you can create a TCP/IP network and achieve the same functionality that is given with an ethernet or 802.11 network.  That is to say, you instantly get all of the network stack protocols such as  ssh, ftp, http, etc.  With USB networking you can easily add several new networking interfaces to a host machine.  These new interfaces can be configured to the same network or can be configured as seperate networks.  A USB network can also be bridged and shared with ethernet and 802.11 networks.

I have a beagleboard rev. C4 with Ubuntu running on an 8 GB SD card.  The beagleboard does not have an ethernet port or wifi chip, however, it does have both USB host and USB OTG ports.  The goal was to connect the ZipIt to the beagleboard with USB and then bridge to the ZipIt’s wireless connection.  By bridging the two networks, both the beagleboard and the ZipIt can utilize the wifi connection and access the web over the LAN.

  1. network a ZipIt Z2 to a beagleboard using USB
  2. create a bridge to the ZipIt’s wifi connection and share it with the beagleboard

The beagleboard has the ability to act as both a USB host and a USB client.  The connection being described in this post has the beagleboard assigned as the host and the ZipIt in USB client mode.  The ZipIt can also act as the USB host, but unlike the beagleboard, it cannot be both at the same time.  A kernel that has been configured to put the ZipIt in USB client mode is a requirement.  I compiled my own kernel using buildroot and the kernel sources from anarsoul’s tree with this .config and this additional patch, also provided by anarsoul.  At the time of this post, he has not released a compiled version of the USB client, I’m sure that if you poke him, he will be happy to help, otherwise I can also provide a binary.

You will also need to create a USB adapter for the ZipIt.  The USB wiring–>pin connections are the same as those for the USB host cable, the only difference you may consider is a male end.  The configuration details below can easily be adapted to work with a ZipIt to ZipIt, or a ZipIt to laptop connection.

It is recommended to use the z2lite-rc8 userland by wicknix.  This userland has the iptables already included.  The usage of other userlands will need  this package installed (i.e. z2sid-rc3).

The additions needed to /etc/network/interfaces for the beagleboard and ZipIt are as follows.

beagleboard –> /etc/network/interfaces

iface usb1 inet static

address 192.168.2.22

netmask 255.255.255.0

network 192.168.2.0

gateway 192.168.2.12 (this is the IP assigned to the ZipIt)

 

ZipIt  –> /etc/network/interfaces

auto usb0
iface usb0 inet static

address 192.168.2.12
netmask 255.255.255.0
network 192.168.2.0
broadcast 192.168.2.255

up echo 1 > /proc/sys/net/ipv4/ip_forward
up iptables -t nat -A POSTROUTING -o wlan0 -s 192.168.2.0/24 -j MASQUERADE
up iptables -t nat -A PREROUTING -i wlan0 -p tcp –dport 3074 -j DNAT –to-destination 192.168.2.12
up iptables -A FORWARD -i wlan0 -d 192.168.2.12 -p tcp –dport 3074 -j ACCEPT

down echo 0 > /proc/sys/net/ipv4/ip_forward
down iptables -t nat -D POSTROUTING -o wlan0 -s 192.168.2.0/24 -j MASQUERADE

 

Boot the beagleboard and the ZipIt.  Log in to the ZipIt and issue the following commands.

z2sid-rc3:~#:modprobe g_ether

z2sid-rc3:~#:ifdown usb0

z2sid-rc3:~#:ifup usb0

It’s assumed the ZipIt is already connected to a wireless AP and can access the web.  Please note that you configure and connect the ZipIt to the wireless AP as normal.  The ZipIt’s USB cable can now be plugged into the beagleboard’s USB hub.  That should be it.  Open your beagleboard’s web browser and try to access the web.

Troubleshooting:

Networking problems can arise from many sources.  The problem may be with the hardware, software, environment, configuration, etc., and can often be a combination of the possibilities.  Here’s a few tips for troubleshooting problems.

Start with establishing a ping signal.  It is best to clear any rules in the iptables that could prevent a response from the ping request.

z2sid-rc3:~#:iptables -L –> lists all the rules for the ‘firewall’

z2sid-rc3:~#:iptables -F –> clears all the rules for the ‘firewall’.  Should be the same as if a firewall was not up.

With USB networking the first thing to check of course would be the USB connection.  This can be done with a userland tool called ethtool.  The ethtool package can be found in most repositories, including those of Ubuntu.  If you are using a buildroot based userland such as z2lite you may need to build the ethtool package yourself.  The z2lite-rc8 package has the needed userland tools for creating the network bridge.

z2sid-rc3:~#:ethool usb0 –> should return Link Detected: yes

z2sid-rc3:~#:ethtool -i usb0 –> returns info about the driver and firmware.  Look for driver: g_ether.

z2sid-rc3:~#:ping 192.168.2.22 –> looking for a ping response of  ~ 2 ms

Once you have a ping response you can then start adding rules to the iptables that will bridge the USB network and the ZipIts wifi connection.

 

Links:

http://downloads.tuxfamily.org/linuxrx1950/precompiled/zipit/

https://github.com/anarsoul/linux-2.6/tree/pxa27x-dev

http://mozzwald.com/node/60

http://hostwork.com/users/matt/zipitz2/

 

 

© 2016 engine12