tkaiser Posted August 2, 2016 Posted August 2, 2016 EDIT: The tutorial below is based on outdated instructions. With the most recent Raspbian images the same is possible with less efforts using the g_ether module. All details here: https://gist.github.com/gbaman/975e2db164b3ca2b51ae11e45e8fd40a Today arrived both a RPI 3 and a RPi Zero. I want to use the latter to confirm some consumption measurements we're currently doing to prepare Armbian low-power (or IoT) settings for a couple of boards (see here and here for details) To my surprise I wasn't able to login to RPi Zero without soldering wires or GPIO header since I've no Micro-HDMI cable/adapter, my only Micro-USB adapter is a 90° one preventing to power the board when I want to connect an USB-Ethernet adapter so I thought: Let's use the RPi's USB OTG port like we do with some H3 boards: For both powering and USB gadget stuff in this case using as serial console via the g_serial module. I found this nice tutorial here: https://learn.adafruit.com/turning-your-raspberry-pi-zero-into-a-usb-gadget/overview But they assume you are able to boot into Raspbian on your RPi which I can't so I thought about burning the SD card with Raspbian Jessie Lite the usual way but then inserting it into a card reader attached to one of my Armbian installations and do the modifications there. Works flawlessly, only minor caveat is that the kernel version then used is a bit outdated (4.4.0-rc5 while latest Raspbian already uses 4.4.11-v7). So the steps are as follows: I burned the Raspbian image on OS X, ejected the card, then used an USB-SD-card reader and attached it to an Orange Pi PC running Armbian. In the next steps we will mount both SD card partitions, copy the stuff to the correct locations, add g_serial module to be loaded automatically and activate the necessary getty from within /etc/rc.local. Looks then like this: cd /tmp wget http://adafruit-download.s3.amazonaws.com/gadgetmodulekernel_151226a.tgz mkdir /mnt/sda1 mkdir /mnt/sda2 mount /dev/sda1 /mnt/sda1 mount /dev/sda2 /mnt/sda2 tar xf /tmp/gadgetmodulekernel_151226a.tgz cd tmp/boot/ # backup old kernel image mv /mnt/sda1/kernel.img /mnt/sda1/kernel_backup.img # move stuff to correct locations mv kernel.img /mnt/sda1/ mv overlays/* /mnt/sda1/overlays/ mv *.dtb /mnt/sda1/ cp -R modules/lib/* /mnt/sda2/lib/ echo 'g_serial' >> /mnt/sda2/etc/modules sed -i '/exit 0/isystemctl enable getty@ttyGS0.service' /mnt/sda2/etc/rc.local sync cd / umount /mnt/sda1 /mnt/sda2 (this will also work with any recent Linux distro and in case you burned the Raspbian image already on Linux you can do all the stuff above directly afterwards too). Now back in OS X the RPi's OTG port simply connected with a good (20AWG rated) USB cable it looks like this: Gadget Serial v2.4: Product ID: 0xa4a7 Vendor ID: 0x0525 (PLX Technology, Inc.) Version: 4.04 Speed: Up to 480 Mb/sec Manufacturer: Linux 4.4.0-rc5+ with 20980000.usb Location ID: 0x14200000 / 30 Current Available (mA): 500 Current Required (mA): 500 This 'UART adapter' appears as /dev/cu.usbmodem1421 and so it's time to login: macbookpro-tk:~ tk$ minicom -D /dev/cu.usbmodem1421 -b 115200 Raspbian GNU/Linux 8 raspberrypi ttyGS0 raspberrypi login: pi Password: Linux raspberrypi 4.4.0-rc5+ #10 PREEMPT Thu Dec 24 22:52:14 EST 2015 armv6l The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. pi@raspberrypi:~$ w 14:38:03 up 0 min, 1 user, load average: 0.48, 0.18, 0.07 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT pi ttyGS0 14:37 1.00s 0.82s 0.03s w Now the fun begins, let's check out whether an Orange Pi Lite consumes less than RPi Zero or not! 1
rodolfo Posted August 3, 2016 Posted August 3, 2016 By using g_ether instead of g_serial ( same method as described ) one gets a fast ethernet connection ( usb0 ). With static IPs and routing defined for the PIZERO and the host ( Armbian board, Linux/OSX notebook ) one gains easy network access for any updates/upgrades on the PIZERO. If you really need the early boot messages on the PIZERO, a serial console cable on the GPIO pins can still be used to power/connect the PIZERO.
arox Posted August 3, 2016 Posted August 3, 2016 About "serial console cable" Caution ! I am not giving here any advice : you could have difficulties in using (my) solution and damage your cards. I just want to know if someone can share experience with me. Historically, serial links were handle on V24 lines. That means electrical level up to -15/+15 V. TTL logic use 0/5V levels. The UART of RPI is 0/3.3V level and not compatible with PC serial port in any case. But you can cross TX/RX UART between 2 RPI to gain access to the console. With recent cards, it seems that the "serial console" port may be TTL (5V) levels, but as we know specs is not easy to get with all cards and subject to caution. You can also cross 5V UART between cards, but it is important to be sure that both use the same levels and the attribution of interface number (and naming) is not consistant between cards and OS.
rodolfo Posted August 3, 2016 Posted August 3, 2016 About "serial console cable" This one works for OPI and RASPI : http://www.ebay.com/itm/USB-To-RS232-TTL-UART-PL2303HX-Auto-Converter-USB-to-COM-Cable-Adapter-Module-/181847253057?hash=item2a56f0e041
tkaiser Posted August 3, 2016 Author Posted August 3, 2016 using g_ether instead of g_serial Didn't try that since my aim was to measure lowest idle consumption possible. RPi Zero in idle mode doing exactly nothing (not the best use case ) is at 365mW. Yesterday I bought another Micro-USB-to-USB adapter and by adding RTL8153 based Gbit Ethernet consumption increases by 1.1W: Just did the upgrades (apt-get upgrade like with Armbian) and had to realize that Raspbian now contains all the gadget stuff after upgrading to kernel 4.4.13: root@raspberrypi:/lib/modules/4.4.13+/kernel/drivers/usb/gadget/legacy# ls -la total 204 drwxr-xr-x 2 root root 4096 Aug 3 10:17 . drwxr-xr-x 5 root root 4096 Aug 3 10:17 .. -rw-r--r-- 1 root root 13388 Jun 22 07:04 g_acm_ms.ko -rw-r--r-- 1 root root 29232 Jun 22 07:04 gadgetfs.ko -rw-r--r-- 1 root root 11144 Jun 22 07:04 g_audio.ko -rw-r--r-- 1 root root 11328 Jun 22 07:04 g_cdc.ko -rw-r--r-- 1 root root 13116 Jun 22 07:04 g_ether.ko -rw-r--r-- 1 root root 10928 Jun 22 07:04 g_hid.ko -rw-r--r-- 1 root root 13156 Jun 22 07:04 g_mass_storage.ko -rw-r--r-- 1 root root 10932 Jun 22 07:04 g_midi.ko -rw-r--r-- 1 root root 16052 Jun 22 07:04 g_multi.ko -rw-r--r-- 1 root root 11644 Jun 22 07:04 g_printer.ko -rw-r--r-- 1 root root 11112 Jun 22 07:04 g_serial.ko -rw-r--r-- 1 root root 12264 Jun 22 07:04 g_webcam.ko -rw-r--r-- 1 root root 15036 Jun 22 07:04 g_zero.ko So I would believe if the next Raspbian release is out based on this or a higher kernel version the whole procedure outlined above isn't necessary any more (just loading the approriate module and getty/network config)
rodolfo Posted August 3, 2016 Posted August 3, 2016 Didn't try that since my aim was to measure lowest idle consumption possible. RPi Zero in idle mode doing exactly nothing (not the best use case ) is at 365mW. Yesterday I bought another Micro-USB-to-USB adapter and by adding RTL8153 based Gbit Ethernet consumption increases by 1.1W. Simply connecting and doing nothing via g_ether adds virtually nothing to total consumption ( ~ .4 W ). Using the connection running iperf ( at 102 mbps and 92/28mbps since PIZERO uses no hub ) on both boards adds .4 W with actual usage of the board ( the luxury non-null use case ). Using a PIZERO as a "slave" hooked up to an OPI ONE/LITE/PC might be interesting in cases where there exist viable solutions (GPIO/SPI..) for RASPI not yet ported to Armbian. OPI ONE/LITE/PC with superior processing power and connectivity would serve as gateway, logger, number cruncher ... While lowest possible consumption is of rather limited value, lowest practical consumption for H3-boards ( clever fex and userspace settings for the main power hogs and boosting performance under user control ) is of great value specially in battery-operated/buffered environments.
tkaiser Posted August 3, 2016 Author Posted August 3, 2016 Using a PIZERO as a "slave" hooked up to an OPI ONE/LITE/PC might be interesting in cases where there exist viable solutions (GPIO/SPI..) for RASPI not yet ported to Armbian. Well, GPIO and SPI use cases can be done with H3 boards and Armbian already. There's only one use case where I see the necessity to use a RPi and that's exactly the reason why I bought the Zero: Using it as video camera since I know of no other SBC where we get HW accelerated video encoding. The most recent RPi Zero has also the camera interface exposed, unfortunately with an incompatible connector and so they charge the same amount of money for the necessary cable as for the Pi. And since you can only order one Zero at a time you can also add the same amount of shipping costs to the bill. So the '$5 SBC' when used for the only use case where we can not use cheap H3 boards costs three times more: Pimoroni charged £12.00 (£4.00 each for Zero, cable and shipping to germany -- the cheapest available Zero here in Germany was part of an 40€ kit). That means using a RPi Zero for camera usage costs me ~14,30€ per device. And an Orange Pi PC could power and use up to 4 of these 'slaves' requiring one non-standard Micro-USB-to-Micro-USB cable of course (they exist but are pretty expensive). BTW: Using RPi Zero with g_ether even for initial setup is way more easy than the outdated method I wrote above. It's all explained here: https://gist.github.com/gbaman/975e2db164b3ca2b51ae11e45e8fd40a I'm currently doing some more consumption measurements with a couple of RPis just to get an idea of the 'baseline' consumption we should try to reach with our new low-power or IoT settings. Updates will follow.
arox Posted August 3, 2016 Posted August 3, 2016 "There's only one use case where I see the necessity to use a RPi and that's exactly the reason why I bought the Zero: Using it as video camera since I know of no other SBC where we get HW accelerated video encoding." I assembled a RPI-A when they released the first camera. I stripped down the system to boot in a few seconds, taylored it to minimize power consumption and power it with battery and got video streaming with hard work (I hope it is easier now). It is a pity however they dont provide a better lens (focus and zoom). It seems possible with mechanical skill to remove the lens and assemble better optical device. But it is a time consuming tasks ... I am fed up with RPI zero (un)availability. I rediscovered (following one of your posts) the C.H.I.P. And it seems to be the optimal solution for IOT devices. I always hope to make a streaming cam with arm, but I will wait. I have more projects than I can handle. BTW, "slave devices" with any cards can be a good alternative to virtualization. In my case, it would be to dedicate a virtual (iSCSI) disk with freezed OS and app for some hard to (re)configure software, with simplified wiring, cheap hardware and low power consumption. (if I cannot boot without SD card, I could use it as an archive). Individual and dynamic power control of USB port is possible but complex (it is part of sleeping state functionality).
Recommended Posts