quarta-feira, 21 de fevereiro de 2018

Creating custom ISO images for Fedora, CentOS or RHEL

TL;DR: This post is about creating custom ISO images with custom made RPM packages.

Motivation: My motivation was VERY specific. I had to debug a package that had an issue only on first execution after a fresh clean installation - https://bugzilla.redhat.com/show_bug.cgi?id=1518498. This means I had to create a new package and include it on a new custom ISO image every time I wanted to debug a new line or test a new solution.

Also, during the course of this, I faced error messages like:

09:58:3,721 DEBUG packaging: Member: hypervkvpd.x86_64 0:0-0.32.20161211git.e17 - u

09:58:3,727 ERR packaging: Error populating transaction after 10 anaconda retries: 
failure: Packages/hypervkvpd-0-0.32.20161211git.e17.x86_64.rpm from anaconda: 
[Errno 256] Mo more mirrors to try

09:58:3,727 DEBUG packaging: file:///run/install/repo/Packages/hypervkvpd-0-0.32.
20161211git.e17.x86_64.rpm: [Errno -1] Header is not complete.


The trick is very simple, first create your RPM package - here I assume you already know how to do that. Make sure your package has the same name and same dependencies than the one you want to replace. After that, you're ready to start building the new custom ISO image:

1. Download and mount the ISO image you want to customize:
# mount -t iso9660 -o loop RHEL-7.5-20180206.n.0-Server-x86_64-dvd1.iso temp/






2. Create the root directory for the new ISO image:
# mkdir iso_build

3. Copy everything from the original ISO to your newly created root directory:
# cp -pRf temp* iso_build/

4. Place your newly created RPM inside the iso_build/Packages/ directory;

5. Remove all hash data from repodata/ directory, but KEEP the comps file:
# rm -rfv repodata/*.gz repodata/*.bz2;

6. Create the new repository hash information, using as a reference the old comps file you didn't delete:
# createrepo /root/iso_build/Packages -g /iso_build/repodata/ -o /iso_build/ \
-u file:///run/install/repo/Packages/;

7. From inside iso_build/, generate the new ISO image:
# genisoimage -U -r -v -T -J -joliet-long -V 'RHEL-7.5 Server.x86_64'         \
-volset 'RHEL-7.5 Server.x86_64' -A 'RHEL-7.5 Server.x86_64'                  \
-b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot                   \
-boot-load-size 4 -boot-info-table -eltorito-alt-boot                         \
-e images/efiboot.img -no-emul-boot -o /RHEL-7.5-DEBUG-Server-x86_64-dvd1.iso .

Special thanks to Arx Cruz and Edjunior Machado who helped me on this issue.

Enjoy your debugging.

sexta-feira, 9 de fevereiro de 2018

QEMU Sandboxing for dummies

DevConf is an annual conference that takes place in Brno, Czech Republic. This year I applied for a talk to go over my work that I develop since mid 2012: Security on QEMU/KVM Virtual Machines using SECCOMP. Since then I became the maintainer of this feature on QEMU and released the second and better version not long ago. On this post you'll find the slides and the full video of the presentation.



So here we go, very first experience lecturing in English, what a catastrophe! In my defense the audience was very peculiar, not only the guy that very started libseccomp was there, but my manager and the director of the department as well. Anxiety apart, I think it was an outstanding experience, would do it again in the future. :-)



sexta-feira, 19 de janeiro de 2018

Xen synchronicity between frontend and backend devices

So I bumped into a problem last month and it took me too much time to figure out the big picture of the problem since I didn't find too much documentation about that. The help I could find when trying to figure out this was mostly from good people on the channel #xendevel @ Freenode, mostly maintainers. So if you want to understand a little bit of Xen without pinging people on IRC, that's the place.

The problem is the following: I'm running RHEL on Xen Hypervisor and whenever I try to unload and reload xen_netfront kernel module I see outputs like that on dmesg:
# modprobe -r xen_netfront

# dmesg|tail
[ 105.236836] xen:grant_table: WARNING: g.e. 0x903 still in use!
[ 105.236839] deferring g.e. 0x903 (pfn 0x35805)
[ 105.237156] xen:grant_table: WARNING: g.e. 0x904 still in use!
[ 105.237160] deferring g.e. 0x904 (pfn 0x35804)
[ 105.237163] xen:grant_table: WARNING: g.e. 0x905 still in use!
[ 105.237166] deferring g.e. 0x905 (pfn 0x35803)
[ 105.237545] xen:grant_table: WARNING: g.e. 0x906 still in use!
[ 105.237550] deferring g.e. 0x906 (pfn 0x35802)
[ 105.237553] xen:grant_table: WARNING: g.e. 0x907 still in use!
[ 105.237556] deferring g.e. 0x907 (pfn 0x35801)

Moreover, the interface is not usable as well:

# dmesg|tail
[ 105.237163] xen:grant_table: WARNING: g.e. 0x905 still in use!
[ 105.237166] deferring g.e. 0x905 (pfn 0x35803)
[ 105.237545] xen:grant_table: WARNING: g.e. 0x906 still in use!
[ 105.237550] deferring g.e. 0x906 (pfn 0x35802)
[ 105.237553] xen:grant_table: WARNING: g.e. 0x907 still in use!
[ 105.237556] deferring g.e. 0x907 (pfn 0x35801)
[ 160.050882] xen_netfront: Initialising Xen virtual ethernet driver
[ 160.066937] IPv6: ADDRCONF(NETDEV_UP): eth1: link is not ready
[ 160.067270] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[ 160.069355] IPv6: ADDRCONF(NETDEV_UP): eth2: link is not ready

# ifconfig eth0
eth0: flags=4098 mtu 1500
ether 00:00:00:00:00:00 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

# ifconfig eth0 up
SIOCSIFFLAGS: Cannot assign requested address

The first problem happens because the backend part of the module (xen_netback) is still using some pieces of memory (g.e. which states for grant entries) that are shared between guest and host. The ideal scenario would be to wait for the netback to free those entries and only then unload the netfront module. This was actually a bug on the synchronicity of the netfront and netback parts.

The state of the drivers are kept in separate structs, as defined in include/xen/xenbus.h:69:

/* A xenbus device. */
struct xenbus_device {
    const char *devicetype;
    const char *nodename;
    const char *otherend; 
    int otherend_id;
    struct xenbus_watch otherend_watch; 
    struct device dev;
    enum xenbus_state state;
    struct completion down;
    struct work_struct work; 
};

And the netfront state can be seen from the hypervisor with the command:

# xenstore-ls -fp
[...]
/local/domain/1/device/vif/0/state = "4" (n1,r0)
[...]

The number 4 indicates XenbusStateConnected (as defined in include/xen/interface/io/xenbus.h:17). So it means everything is a matter of wait for one end to finish using the memory region and the other to free, this first piece of the puzzle is solved by this patch:

diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index 8b8689c6d887..391432e2725d 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -87,6 +87,8 @@ struct netfront_cb {
 /* IRQ name is queue name with "-tx" or "-rx" appended */
 #define IRQ_NAME_SIZE (QUEUE_NAME_SIZE + 3)
 
+static DECLARE_WAIT_QUEUE_HEAD(module_unload_q);
+
 struct netfront_stats {
        u64                     packets;
        u64                     bytes;
@@ -2021,10 +2023,12 @@ static void netback_changed(struct xenbus_device *dev,
                break;
 
        case XenbusStateClosed:
+               wake_up_all(&module_unload_q);
                if (dev->state == XenbusStateClosed)
                        break;
                /* Missed the backend's CLOSING state -- fallthrough */
        case XenbusStateClosing:
+               wake_up_all(&module_unload_q);
                xenbus_frontend_closed(dev);
                break;
        }
@@ -2130,6 +2134,20 @@ static int xennet_remove(struct xenbus_device *dev)
 
        dev_dbg(&dev->dev, "%s\n", dev->nodename);
 
+       if (xenbus_read_driver_state(dev->otherend) != XenbusStateClosed) {
+               xenbus_switch_state(dev, XenbusStateClosing);
+               wait_event(module_unload_q,
+                          xenbus_read_driver_state(dev->otherend) ==
+                          XenbusStateClosing);
+
+               xenbus_switch_state(dev, XenbusStateClosed);
+               wait_event(module_unload_q,
+                          xenbus_read_driver_state(dev->otherend) ==
+                          XenbusStateClosed ||
+                          xenbus_read_driver_state(dev->otherend) ==
+                          XenbusStateUnknown);
+       }
+
        xennet_disconnect_backend(info);
 
        unregister_netdev(info->netdev);

The second piece of the problem is that the interface is not usable when reloaded back. And that's a lack of initializing the state of the device so the backend notices it, and hence, connects the two drivers together (frontend and backend). This was easily solved by the following patch:

diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index c5a34671abda..9bd7ddeeb6a5 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -1326,6 +1326,7 @@ static struct net_device *xennet_create_dev(struct xenbus_device *dev)
 
        netif_carrier_off(netdev);
 
+       xenbus_switch_state(dev, XenbusStateInitialising);
        return netdev;
 
  exit:

sexta-feira, 6 de novembro de 2015

Save radio shows in podcasts so you can listen later!

The story behind this project is that, since I moved to Germany I miss some old news shows on the radio that I use to listen in Brazil. Yeah, I know I can listen to them online. But due to the difference on the timezone, sometimes I just don't want to listen to it while I have my lunch, or work. Saving them into a podcast is much easier and gives me the freedom to listen whenever I want.


The idea is pretty simple: Use ffmpeg to save the stream online, copy it to your podcast server and enjoy. Let's work to put everything together:

First thing you're gonna need is some scripts. The first one captures the stream of audio and dumps into a ts file:

otubo@deathstar /opt/ $ cat capture_stream.sh 
#/bin/bash

TIMESTAMP=$(date +"%Y-%m-%d_%H-%M-%S");
/usr/bin/ffmpeg -i URL -c copy /opt/radio_show_${TIMESTAMP}.ts

Next, you're going to need a script to encode the transport stream into mp3:

otubo@deathstar /opt/ $ cat encode_stream.sh 
#/bin/bash

LAST_TS_FILE="$(ls -1t /opt/|grep ts|head -1)"
NEW_MP3_FILE="$(echo $LAST_TS_FILE|sed -e 's/ts/mp3/g')"
LAST_TS_FILE="/opt/${LAST_TS_FILE}"
NEW_MP3_FILE="/var/www/html/media/${NEW_MP3_FILE}"
/usr/bin/ffmpeg -i "${LAST_TS_FILE}" -acodec mp3 -write_xing 0 "${NEW_MP3_FILE}"
/usr/bin/id3 -t "$(date)" "${NEW_MP3_FILE}"
/usr/bin/id3 -a "News" "${NEW_MP3_FILE}"
wget -O- http://GENERATOR SERVER ADDR/html/pg-cron.php?key=YOUR KEY >/dev/null 2>&1
rm "${LAST_TS_FILE}"

Little gotcha: I had this issue with the iPhone podcast app, according to this ticket, adding the option -write_xing 0 solves the problem.

Note that in the last script, there's the "Podcast Generator" server. That's a really neat and simple to use podcast server made with php5. You can download it here: http://podcastgen.sourceforge.net/. The instructions to install and configure are very easy, and as they say: Newbie-proof.

Let's dig down a little bit on the last script: First you run ffmpeg to convert the transport stream into mp3, then you set the title id3 tag for the title of this podcast "episode", than set the artist id3 tag for the description. After that you call wget to reload your podcast library and update the RSS. And it's done!

Now let's put everything on the crontab:

30 10 * * * /opt/capture_stream.sh
2  12 * * * killall -9 ffmpeg
3  12 * * * /opt/encode_stream.sh

Easy and simple: The show starts at 10:30 (my germany time) and ends at 12h00 (I added 2 more minutes, just in case). Three minutes after the dump is finished I start the encoding script. And that's all! Podcast generator also gives you RSS url to put on your smartphone. Pretty easy :D

RetroPie: Play snes games on your Raspberry Pi!

So I wanted to play some old Super Nintendo games and also share this special retro gaming style with my daughter. So I decided to put it on my Raspberry Pi and have some fun. So let's do it!

The process is pretty easy, but the controllers configuration are a little tricky. Follow this guide to install RetroPie on an SD card and boot up your Raspberry Pi. This documentation explains everything you need to know about configuring wifi, setting up everything to have all up and running.

Now to the controller configuration:
I bought two ordinary snes controllers, they work pretty fine. The configuration is done via the file /opt/retropie/configs/all/retroarch.cfg, find this file and open it with your favorite text editor. Now find the input_player and erase everything related to it and make it look like this:

input_device_p1 = "0"
input_libretro_device_p1 = "0"
input_player2_analog_dpad_mode = "0"
input_player1_joypad_index = "0"

input_player1_b_btn = "2"
input_player1_y_btn = "3"
input_player1_select_btn = "8"
input_player1_start_btn = "9"
input_player1_up_axis = "-1"
input_player1_down_axis = "+1"
input_player1_left_axis = "-0"
input_player1_right_axis = "+0"
input_player1_a_btn = "1"
input_player1_x_btn = "0"
input_player1_l_btn = "4"
input_player1_r_btn = "5"


input_device_p2 = "1"
input_libretro_device_p2 = "0"
input_player2_analog_dpad_mode = "0"
input_player2_joypad_index = "1"

input_player2_b_btn = "2"
input_player2_y_btn = "3"
input_player2_select_btn = "8"
input_player2_start_btn = "9"
input_player2_up_axis = "-1"
input_player2_down_axis = "+1"
input_player2_left_axis = "-0"
input_player2_right_axis = "+0"
input_player2_a_btn = "1"
input_player2_x_btn = "0"
input_player2_l_btn = "4"
input_player2_r_btn = "5"

input_enable_hotkey_btn = "8"

input_exit_emulator_btn = "9"

This is all you're going to need to make those USB controllers work. If you bought a different controller, you can try to configure them using this command:

sudo ./retroarch-joyconfig -j 1 -p 2 >> /opt/retropie/configs/all/retroarch.cfg

This will interactively ask you to push every button in order to map it to the correct values. Always remember to double check your /opt/retropie/configs/all/retroarch.cfg to avoid duplicates, this got me in trouble for quite some time.

After that, you can copy all your ROM files into /home/pi/RetroPie/roms/snes, or if you have ROMs for different console, just copy into the correct folder.

That's it. Enjoy :D

segunda-feira, 8 de junho de 2015

GSM bridge between two raspbx hosts

Disclaimer: I know there's a lot of options on the market for free long distance calls like Skype, Viber, WhatsApp and so on. The goal of this personal project was all along to come up with a proof of concept that actually works, study something different other than my actual job and, why not, have some fun :) BUT, yes, there's one single use case that this setup will be useful: You're in the middle of nowhere, no internet connection and you need to call someone in the other side of the planet but you don't want to pay a long distance call: BINGO!

Disclaimer2: For this tutorial you'll have to be prepared for Asterisk terminologies like trunks and channels. If you're not familiar with this vocabulary, please take a quick look at this documentation.

Description of the environment: The server1 is placed on the Brazilian side. It's a Raspberry Pi model B that runs an asterisk-modded-for-raspberry-pi distro called raspbx. Attached to it there's an USB GSM dongle with a SIM card for the local Brazilian operator. In the same network of my server1 there's a Cisco PAP2t Internet Phone Adapter and, attached to it, a regular land line telephone. The same setup is duplicated on the German side, except that the Raspberry Pi is model B+.

5VpNk+MmEP01rkouqZFky7PHzGZ2ctmqVPmwyRFLjESNJFQIf82v30ZqJNBHxh47yFXxxaIFNLzmPRrsRfA1P74IUqbfeUyzhf8QHxfBHwvf95bBF/hSllNjeVyvGkMiWIyVOsOGvVM0PqB1x2JaWRUl55lkpW2MeFHQSFo2IgQ/2NVeeWZ7LUmiPXaGTUSyofUHi2WKs/DDzv4nZUmqPXshTnhLordE8F2B/hZ+8Fp/mtc50X3hRI8PTXGJ7U9YXi+1p8Ia0TvnuWUQtGrRwz5fGQ4Ly1suYioak7ZlrHgzMQqeIZyCc2ipnvLjV5qpkOpoNc2+Tbxt4RK0sHxPNgiaFpU8achpDBHAIhcy5QkvSPbcWZ9qWKnqAUB6SmWewaMHj/TI5N/G8z+qym8rKFWSCPm7WhCq1z2BFo3tG4PxYIsi7tUAi/E+2ol97VUVmmGrsU7OHE0V34kIa+FswXFCsVbNBwTnhfKcSnGqw5kRyfZ27wQjlbT1OmjhAdEdRxpdw8R22KkgVbmlonZXsoUfZjCkp5jt4TFRjyOmXyoKIAjvV/0O3I606Ft7IT6kTNJNSWpYDqAcdhhxpFRIqoVkAt0hbthAywzKTvCA5YNBYmRAavBX264BGglrAL2rtmB42XxXQsiLBGAYQTYH8cyngZ0bQt8bQrgegfDLDSDUri5SBYueM0nE51QBZ2uqQr2/OFAFdG2qAt9J2CTcr7c26pqzK3ecxe3cgIEVgEIB4XAPRLB6tIEIh0B4ev82kQhvQT29Pm+zIX/Al3M49zlOrYecqlF1wCkPdwCn6gVYiJN6pVrUhXtQtpEouMp30LVB6ZKU9VGBVREfrnLnG+rSYU6CgmKAIWlGy5QXdA4k9JQQidWZqYW2XYOEXhf/ITlrBt5JauGNMNCrj5guhHDIwSvOHP69nzlCvT5nOHR4Q4ZfcOqYhtY9iD1tcHns8PHuxak2tBt3IwJ3snE3GjHPmUT7vodDySqY71CiU/y7T8XNhaMM/YWj754uSJX0/a/OlR4R9qvwRI38n2z9Y5FwtvVr5xPpN76ddXt2mX+P3L62Cfg8WNiy5jIDD7APA4utIO8sY/ATh05Y4OblwMXbkLBZBj/9KGI60H57veh18NEtzC3WS4CDNTAaQtGpRpSRqmKRjYClPF2Nz16vDGEygNBQmTho29nagh7+4nD31kXB620F7baou2g0D1uZPzV90JHXvy5rhHLQUR2rdtrnhW+ofgkVuVrfIcnVSi22lfqqF/sgKW8X/1k5uUtKhD1OaBlxwomhht4fJybyF28kbfw3zpxPj76n9rx0KT0mh3w1PaDY/aDcVO/+LBA8/wQ=
What it does: This is the list of features that this project performs right now:
  1. Someone in Brazil calls my Brazilian number, the dongle1 answers the call, redirects to an IAX2 trunk directly to server2. The server2 takes this incoming call and uses the dongle2 to place a new call to my german cellphone. The other way is still pinned to a single phone -- like, call my dongle2 to reach a single number in Brazilian side -- but improvements are coming.
  2. Someone uses phone1 on Brazilian side to call extension phone2 on German side (and vice-versa) like a regular landline phone.
  3. Someone uses phone1 or phone2 to reach my german cellphone.

Ok, so LET'S DO IT!!

I'm gonna skip the PAP2t configuration because I think it's too much. This is only needed if you want to use land line telephones, it's not required for the GSM bridge. If anyone is interested in doing that, please leave a comment and I'll write a new post only for that configuration.

Important note: All the configuration explained from now on is identical on both servers.
  1. Install raspbx on your RPi's SD card. Also take a time to read through the raspbx documentation, which is very useful
  2. Use the script install-dongle (built-in inside raspbx) to install your dongle on your RPi. Important notes regarding problems I got:
    1. There's a list of GSM dongles that are tested with voice, SMS and USSD. I bought the Huawei E160;
    2. I had to unlock the voice feature with DC-Unlocker for Windows;
    3. Plug your dongle and only after that plug your RPi power. If you try to plug your dongle while the RPi turned on, you may experience your RPi to reboot due to power consumption failures;
    4. If your RPi starts rebooting it's because it can't handle the gsm dongle power consumption, in this case, use a proper powered USB hub. I bought the D-Link Dub-H7
    5. Find out the IMEI and the IMSI code of your dongle and set the correct values under /etc/asterisk/dongle.conf because /dev/ttyUSB1 or /dev/ttyUSB2 may change;
  3. Before you start configuring raspbx itself, it's important that you have both sides with network configured properly with static IPs and (in my case) DynDNS. I didn't want to open too many ports on the routers on both sides so I just setup an OpenVPN vpn; 
  4. Setup a new custom trunk for your dongle under Connectivity → Trunks → Add Custom Trunk and set these values:

    Trunk Name: to-my-cellphone
    Outbound CallerID: Your SIM card number with country code (with a plus sign at the beginning)
    Custom Dial String: dongle/dongle0/$OUTNUM$

    Note: This is the trunk that will actually place the inbound calls to your personal telephone.

  5. Setup a new IAX2 trunk under Connectivity → Trunks → Add IAX2 Trunk and set these values:

    General Settings:
    Trunk Name: Something that would remember the incoming connection from the other server
    Outbound CallerID: Your personal phone number

    Outgoing Settings:
    Trunk Name: (same as above, I also used the same name and it's ok)

    host=static IP under vpn of the remote server
    username=any username
    secret=any password
    type=friend
    trunk=yes
    qualify=yes
    qualifyfreqok=25000
    tos=0x18

    Note: The IAX2 trunk is responsible for redirecting calls from this server to the other.

  6. Setup a new inbound route under Connectivity → Inbound Routes → Add Incoming Route:

    DID Number: Your SIM card number with country code (with a plus sign at the beginning)
    CallerID Number: Your personal cell phone number
    Set Destinations: Trunk and your recently created IAX2 trunk.

    Note: This is the route responsible to redirect an inbound call on your local dongle over the IAX2 trunk and then to your remote server.
If you noticed any omitted fields in the above configurations, it's because I didn't fill with anything or it's not important. I also did some extra work on Claning the SIM card memory for SMS every once in a while, I set a static IP for the OpenVPN so each server can always see each other, an additional service to check my credit balance every month and so and so forth. If you also want details like that please let me know in the comments :-) 

That's it! You did it! If you need more help setting up anything else please let me know in the comments of this post. Good luck and have fun! :-)

quinta-feira, 9 de janeiro de 2014

Vendo: Placa Beagleboard rev C4 + Placa de expansão BeagleBuddy Zippy

tl;dr: R$200,00 por fora do Mercado Livre. Interessados deixem contato nos comentários.

Pessoal, estou vendendo esta placa de desenvolvimento apenas por que os repositórios de software que costumava usar foram descontinuados para este modelo (parou no Ubuntu Server 12.03, ainda da pra instalar e atualizar os pacotes, mas não tem versões mais novas). Apesar disso, é uma placa de baixíssimo consumo de energia, ideal para desenvolvimento de aplicações embarcadas e testes com processadores ARM.







Como mostram as fotos, a BeagleBoard já está soldada à placa de expansão BeagleBuddy Zippy e ambas estão muito bem cuidadas e funcionando normalmente. Já acompanha a bateria de 3V para o RealTime Clock.

Junto com as paquinhas vão:

  • Caixa original
  • Fonte de alimentação de 5V
  • Case de acrílico + um case fosco (na época que eu comprei veio um de brinde que eu nunca usei)
  • Cabo USB-serial
  • Bateria 3V para o RealTime Clock

Tudo isso por apenas R$200,00!

(tenho conta no ITAU, aceito PayPal e Bitcoin)

Interessados: Deixem o contato nos comentários.


BeagleBoard rev C4:
  • Package on Package POP CPU/Memory chip.
    • Processor TI OMAP3530 Processor - 720 MHz ARM Cortex-A8 core
    • 'HD capable' TMS320C64x+ core (520 MHz up to 720p @30 fps)
    • Imagination Technologies PowerVR SGX 2D/3D graphics processor supporting dual independent displays
    • 256 MB LPDDR RAM
    • 256 MB NAND Flash memory
  • Peripheral connections
    • DVI-D (HDMI connector chosen for size - maximum resolution is 1280×1024)
    • S-Video
    • USB OTG (mini AB)
    • 1 USB port
    • SD/MMC card slot
    • Stereo in and out jacks
    • RS-232 port
    • JTAG connector
    • Power socket (5 V barrel connector type)
    • Development
      • Boot code stored in ROM
      • Boot from NAND memory, SD/MMC, USB, or serial
      • Alternative boot source button.

BeagleBuddy Zippy:
  • 10BaseT Ethernet 
  • Additional SD/MMC interface 
  • Battery backed-up Real Time Clock (RTC)
  • Additional RS-232 serial port
  • 5V I2C expansion interface.

sábado, 13 de julho de 2013

Entendendo a digestão de um bebê.

Este post vai ser menos poético e mais técnico que o outro. Se não te interessa saber sobre refluxo e como evitá-lo, pode voltar a ler o seu jornal.

Pois bem, Carolina estava tendo bastante problema de refluxo, Marcelle vasculhou os confins da deep-web e encontrou o recomendado Dr David Costa, osteopata - Ele atende na academia Companhia Atletica, perto da Avenida dos Bandeirantes em São Paulo. Ele apelou pra tudo o que eu acredito nessa vida, a ciência. Explicou com detalhes de anatomia e química do por que a Carol ter refluxo e por que as vezes isso é normal. Neste post vou tentar entregar um pouco do seu ouro. Mas de qualquer forma, recomendo muito a consulta, médico atencioso, paciente e ouve os pais com seus problemas.

Antes de tudo um aviso importante: EU NÃO SOU UM PROFISSIONAL DA SAÚDE. Use este post como uma orientação e se tiver problemas procure um médico.

1) Meu filho mama muito bem no peito esquerdo, relaxa e até dorme; mas no peito direito ela fica inquieto e irritado. Por que isso acontece?
Pelo desenho do aparelho digestivo acima, nota-se que a saída do estômago é uma caída suave para a esquerda. Ora, se o bebê se inclina para a esquerda (fazendo o contato barriga-com-barriga que as mamães já estão por dentro) para mamar, o estômago é mais facilmente esvaziado, dando uma sensação de alívio ao bebê. O contrário também é válido, se ele se inclinar para o lado direito, o leite vai se acumulando do lado direito do estômago, ele logo fica empapuçado e fica com sentimentos misturados: Ainda tenho fome, mas algo me incomoda = choro. Então a dica aqui é: comece pelo peito direito, quando empapuçar, mande para o esquerdo e deixe ele relaxar.

2) Meu filho regurgita SEMPRE depois de mamar. O que faço?


Isso é normal. Existe um músculo circular em formal de anel que separa o estômago do esôfago chamado de Cárdia. Este músculo não é forte e nem possui reflexo para fechar ou abrir direito em bebês. Isso significa que, com o estômago cheio de leite - as vezes cheio demais - é natural que alguma coisa saia. Mas atenção, esse refluxo é de cor branca e fluida, assim como o leite. Caso seja em formato de queijo, veja o item 3.

3) Quando meu bebê regurgita, sai um queijo e ele fica muito irritado e chora muito. O que faço? 

Isso tem a ver com o a fermentação do leite no estômago. Leite fermentado nada mais é do que queijo, se ele regurgitar queijo, quer dizer que o tempo entre as mamadas está errado. Ele fica irritado por que o PH dessa solução que fica no estômago é ácido, é só lembrar daquele seu porre que você vomitou até ficar com a garganta ardendo, bem era por causa disso.

Então, quando ele começar a mamar, ligue o cronômetro e não deixe passar de 30 minutos. Depois de 30 minutos, o estômago já começa a digerir o leite e este começa a virar queijo. Qualquer estímulo na cárdia pode fazer ele regurgitar e isso vai irritá-lo bastante. Depois disso tente respeitar o período mínimo de 2 horas para concluir a digestão antes de dar mais comida.

Embora bastante explicativas, essas dicas obviamente não são tudo. As vezes, ele vai acordar no meio da noite com dor de barriga, as vezes não vai querer dormir. Nessas ocasiões, boa sorte.

sexta-feira, 5 de julho de 2013

Junto com a filha, nasce um pai


Este post começou com o pedido de uma amigo velho para compartilhar as experiências vividas nessas poucas semanas de pai. Comecei a escrever o email e fui achando que poderia virar um post. Pois bem, ca estamos.

Já no sétimo mês fizemos um curso para gestantes. Aprendemos a dar banho, a trocar fralda e tudo mais. Mas obviamente que nem tudo estava previsto no manual. Então aqui deixo algumas das poucas experiências que já passei. Mais informações vocês podem encontrar no blog da Marcelle.

Antes do nascimento, converse com sua filha: Pode parecer bobagem, mas conversar com a barriga da sua esposa é bastante importante. Depois do oitavo mês de gestação, o aparelho auditivo já está formado e ela já vai começar a reconhecer a sua voz. O dia do parto vai ser a pior experiência da vida dela, vai sair daquele quentinho e escurinho pra ir pra um ambiente claro e gelado na mão de um monte de gente estranha. Ter uma voz familiar como referência é o diferencial para ela manter a calma e não deixar a experiência tão traumatizante assim.

Depois do nascimento, converse com a sua filha também: Sempre que for trocar a fralda, dar banho ou botar pra dormir, converse com sua filha. "Filha, vou trocar sua fralda, ela não pode ficar suja. Vou tirar seu casaquinho agora..." E lembre-se: SEM BABY TALK. Voz normal, ela tem que reconhecer a sua voz. Claro que eles ainda não entendem, mas ouvir a voz do pai ou da mãe é algo mágico que acalma.

Depois de adulta, continue conversando. Mas isso a gente já sabe. :)

Rotina é MUITO importante: Bebês não sabem o que é dia e nem o que é noite, tenha uma rotina clara. De dia abra as janelas, faça barulho e acorde o bebê a cada duas horas para mamar. Se não acordar só com estímulos, tire a roupa, eles sempre acordam assim. A noite, diminua o ritmo, abaixe o volume das coisas e não deixe tantas luzes acesas. Ensine que é hora de dormir. Dê banho sempre no mesmo horário, arrote e bote no berço. É uma receita quase infalível.

Parece que no começo você vai morrer, que não vai dormir nunca mais, que ela acorda a noite inteira e acabou tudo. SIM. Mas passa. E não demora. A Carol já está acordando apenas UMA vez por noite.

Bebês choram por motivos simples de desconforto: Ou é fome, ou está com fralda suja ou está com calor ou com frio. Se você verificar todos esses fatores e estiver tudo OK, então é hora de levar ao hospital. Bebês recém nascidos não são manhosos, nem mal acostumados nem malandros - eles ainda não aprenderam o que é isso. Se chorar é por que tem algo de errado mesmo.

Na hora de dormir: Não deixe dormir no colo pra depois colocar no berço, é importante que ela aprenda a dormir sozinha e no berço. Do contrário sim, você vai estar mal acostumando sua filha.

E o que eu descobri sendo pai? Bem, aprenda a se respeitar também. Você não vai nascer pai, vai aprender. Errar não vai o tornar a pior pessoa do universo, com calma a gente chega lá :)

Bibliografia recomendada:
Os Bebês e suas mães - D. W. Winnicott.
A encantadora de bebês - Tracy Hogg.

quinta-feira, 20 de dezembro de 2012

Amigo Blogueiro 2012

Confesso que não sei o que escrever pro meu amigo secreto, nem o conhecia antes do evento e tive que pesquisar MUITO (cof cof), olhar no google pra poder escrever algo legal sobre ele. 

Poise bem! Ele comanda o blog  Franquias Baratas de Sucesso e da dicas bastante espertas para quem quer abrir uma franquia, começar um trampo novo e quem sabe até uma vida nova. Posts ágeis direto ao ponto sem rodeios. Já aproveitei pra me antenar e entender melhor o conceito correto do termo franquia, anotei também as 10 Franquias Baratas de se investir. Ótimas dicas.

Mas chega de business, direto do Instagram dele tem várias fotos belas de por do sol direto de Belo Horizonte, que é a cidade onde mora. E na mesma página onde tem as lindas paisagens mineiras, tem também os gadgets todos desmontados (opa, cheguei na minha praia). Ah eu queria ter a coragem desse rapaz pra abrir e ver a anatomia dos meus devices de perto :-)

#Samsung #Galaxy #SII

Keep focused! Galaxy SII disassembly.

Amigo secreto, Luiz Gadetto, prazer conhecê-lo. Vou seguir pra saber mais das experiências com os devices :-) Feliz natal e ótimo ano 2013 (se existir) Grande abraço!

sexta-feira, 13 de julho de 2012

Vendo Canon XS e Lente SIGMA 19-200mm

Vendinha do Otubo aberta novamente!

Algum de vocês deve ter visto meu problema com algumas fraudes no Mercado Livre e ainda um caloteiro que comprou e não pagou. Decidi então tentar vender meu equipamento de fotografia por aqui também. Os preços não são fixos mas sempre podemos negociar, aceitamos qualquer negócio. Então vamos lá:
  • 1 lente 18-200mm SIGMA + parasol
  • Preço: R$600,00







quinta-feira, 23 de fevereiro de 2012

Flexget & Transmission Daemon downloading your torrents for you

  • Do you watch dozens of TV shows and it sucks to download every single one of them?
  • Do you have trouble on finding torrent files?
  • Is it hard to keep track which one has new episodes or not?



Well, your problems are finally over! By the end of this (pretty cool) straight-forward tutorial you'll have an email at your inbox every time there's a new episode to watch. And there's more! Call now and.. Ok, I got it.

Note: I configured this service on my home-based Ubuntu Server running on a Beagle Board - no arch dependent. In other words, if you want a fully automatic service, you might want to install it on a always-on-computer, not your notebook. :)

Ok, cut the crap. Let's do this!

1) Download and install Flexget. Keep cool, it's easy.
2) Before configuring flexget, install transmission-daemon:

    root@minivader ~ # sudo apt-get install transmission-daemon

and edit the configuration file to look like this: (customize the configuration as you wish and erase the comments in red)

root@minivader ~ # cat /etc/transmission-daemon/settings.json 
{
    "alt-speed-down": 50, 
    "alt-speed-enabled": false, 
    "alt-speed-time-begin": 540, 
    "alt-speed-time-day": 127, 
    "alt-speed-time-enabled": false, 
    "alt-speed-time-end": 1020, 
    "alt-speed-up": 50, 
    "bind-address-ipv4": "0.0.0.0", 
    "bind-address-ipv6": "::", 
    "blocklist-enabled": false, 
    "blocklist-url": "http://www.example.com/blocklist", 
    "cache-size-mb": 4, 
    "dht-enabled": true, 
    "download-dir": "/media/deathstar/torrent", 
      change this to your destination folder
    "download-limit": 100, 
    "download-limit-enabled": 0, 
    "encryption": 1, 
    "idle-seeding-limit": 30, 
    "idle-seeding-limit-enabled": false, 
    "incomplete-dir": "/home/otubo/Downloads", 
    "incomplete-dir-enabled": false, 
    "lpd-enabled": false, 
    "max-peers-global": 200, 
    "message-level": 2, 
    "peer-congestion-algorithm": "", 
    "peer-limit-global": 10000, 
    "peer-limit-per-torrent": 1000, 
    "peer-port": 51413, 
    "peer-port-random-high": 65535, 
    "peer-port-random-low": 49152, 
    "peer-port-random-on-start": false, 
    "peer-socket-tos": "default", 
    "pex-enabled": true, 
    "port-forwarding-enabled": false, 
    "preallocation": 1, 
    "prefetch-enabled": 1, 
    "ratio-limit": 2, 
    "ratio-limit-enabled": false, 
    "rename-partial-files": true, 
    "rpc-authentication-required": true, 
    "rpc-bind-address": "0.0.0.0", 
    "rpc-enabled": true, 
    "rpc-password": "whatever", 
    "rpc-port": 9091, 
    "rpc-url": "/transmission/", 
    "rpc-username": "otubo", 
    "rpc-whitelist": "*", 
    "rpc-whitelist-enabled": true,
     enable all the rpc options above (user & password optional) this is important to make flexget talk to transmission AND access transmission daemon web @ http://localhost:9091
    "script-torrent-done-enabled": false, 
    "script-torrent-done-filename": "", 
    "speed-limit-down": 100, 
    "speed-limit-down-enabled": false, 
    "speed-limit-up": 100, 
    "speed-limit-up-enabled": false, 
    "start-added-torrents": true, 
    "trash-original-torrent-files": false, 
    "umask": 18, 
    "upload-limit": 100, 
    "upload-limit-enabled": 0, 
    "upload-slots-per-torrent": 14, 
    "utp-enabled": true
}

Note: Remember NOT to kill transmission-daemon, you need to SIGHUP it in order to reload the configuration. You can either:

    kill -HUP pid

or

    invoke-rc.d transmission-daemon reload

3) Now configure Flexget to look like this: (customize the configuration as you wish and erase the comments in red)

root@minivader ~ # cat ~/.flexget/config.yml 
presets:
  global:
    transmission:
      host: localhost
      port: 9091
      username: otubo
      password: whatever
    email:
      change your gmail credentials
      from: youremail@gmail.com
      to:
        - youremail@gmail.com
        - your_room_mate@gmail.com
      smtp_host: smtp.gmail.com
      smtp_port: 587
      smtp_username: youremail
      smtp_password: yourpasswd
      smtp_tls: yes
    series:
      configure as you wish, plain text, human readable :)
      - The Big Bang Theory
      - House
      - Family Guy
      - How I Met Your Mother
      - The New Girl
      - Grey's Anatomy
      - Private Practice
      - The Secret Circle
      - The Vampire Diaries
      - Hart of Dixie
      - The Walking Dead
      - The Good Wife
      - Switched at birth
      - Once Upon a Time
      - True Blood
      - Teen Wolf

feeds:
  this is where I look for new torrents, you can add yours
  btchat-vtv:
    rss: http://rss.bt-chat.com/?group=2
  btchat-eztv:
    rss: http://rss.bt-chat.com/?group=3
  btchat:
    rss: http://rss.bt-chat.com/?group=1
  btchat-verified:
    rss: http://rss.bt-chat.com/?group=230
  ezrss-latest:
    rss: http://www.ezrss.it/feed/

4) Now put your flexget into a cronjob:

    root@minivader ~ # crontab -l|grep flexget
    @hourly /usr/local/bin/flexget --cron

Now you might want to run:

    root@minivader ~ # flexget -v

and check if everything goes fine. Once everything goes smoothly, DONE! Now you can LITERALLY sit and watch your server download all the content for you :-)

How it works, for those who like to read the post until the end: cron will run flexget hourly. It will read the RSS from the feed you pointed trying to match the TV Show name. If it matches, flexget will send you an email AND perform an RPC to talk to transmission in order to add the torrent file in the queue for download. You can check the progress in the transmission daemon web @ http://localhost:9091

5) Missing points that I leave for you to have some fun:
  • We should tell transmission-daemon to stop seeding at some point (after it finishes, or after it gets to a certain ratio number would be perfect)
  • It would be really cool to download each TV show into a separate directory.
  • AND EVEN COOLER if we could separate the files into Season folders, creating new ones when season changes.
All right, that's it. have fun :)

terça-feira, 16 de agosto de 2011

Contribute code to an Ubuntu defect with Launchpad and bzr in the RIGHT way

I am writing this post because I had to read some manuals and (wrongly) send a patch email to a mailing list to learn how to actually be able to contribute with code to an Ubuntu package. If you need detailed information, please google some official documentation. But if you just want to start coding, this is your place, here you'll find the cake recipe to do it.
  1. Sign up to a Launchpad account.
    1. The only really needed information is your username and your ssh key
  2. Choose a project. Ensemble, for example.
  3. Download the source code:
    1. mkdir ensemble
    2. cd ensemble
    3. bzr init
    4. bzr branch lp:ensemble master
    5. bzr branch master bug-whatever
    6. cd bug-whatever
    7. CODE! Those bugs won't get fixed itself!
    8. bzr commit #goto step 6, if needed
    9. bzr push
  4. Make your branch public
  5. Make a merge proposal
  6. Done!
Now go for it!

[update] another interesting documentation shared by rsalveti today: Ubuntu Packaging Guide

terça-feira, 9 de agosto de 2011

Enjoy old SNES games on your Xoom using PS3 controller

(image from eu, android)

Yes, that exactly what you read. Now you can play SNES games on your Motorola Xoom using your PS3 controller over bluetooth. Also, this tutorial is an adaptation from an article at Eu, Android and it's intended to be used on Ubuntu only, if you need to use the other OS, please check the original. The Linux specific information is from a cached ubuntu wiki, so I'll copy & paste the relevant part here in case it expire in the future. Right, so cut the crap and let's play! :-)


Needless to say, you must have proper root access on your device - details for brazilians here.

  1. Install Sixaxis Compatibility Checker, open the application, give root permissions and then a popup message will be shown telling you if your device is supported or not (hopefully yes).

  2. Install required libs:
    $ sudo apt-get install libusb-dev libusb-0.1-4

  3. Download sixpair.c (original also hosted at the ubuntu wiki, I did a copy on my github)

  4. Compile it:
    $ gcc -o sixpair sixpair.c -lusb

    Before running sixpair, you'll need the bluetooth mac addr of your Xoom. The easy way to get it is installing Sixaxis Controller - don't worry, you'll need the app anyway to use the controller. The app will display a message "Local Bluetooth Adderss" with the bluetooth mac addr you'll need.

  5. Run sixpair with the Motorola Xoom bluetooth mac addrs you just got as a parameter:
    $ ./sixpair 41:f4:89:6d:41:73

  6. Open the Sixaxis Controller and follow the onscreen instructions - important note: You'll might need to reboot your Xoom to make it work (I had to)
 NOW I WANNA PLAY!
easy... almost there

Install a neat SNES emulator, I choosed Snes9x EX. Now you have to configure your controller to map the keys the emulator uses: Go to Sixaxis Controller -> Menu -> Preferences -> Input Mapping -> 1st Controller mappings. Since I am using Snes9x EX, I set my mapping like this:
  • square: A
  • triangle: S
  • circle: X
  • cross: Z
  • left: Q
  • right: W
  • select: SPACE
  • start: ENTER
  • power: HOME
This way, for example, Snes9x EX will understand that when you press square you're actually pressing A which means the Y button on a normal SNES controller. Yes, I know, confusing as hell, but works.

Now go and have fun :-D

domingo, 15 de maio de 2011

Xoom Brasileiro Vivo 3G atualizado (sem querer) pro Android 3.1


en_US friends: Gonna write this post in pt_BR since this weird update only regards to brazilian devices. But if even you even though have questions, post it and I'll be glad to help :)

Já adianto que o procedimento que vou descrever aqui VIOLA SUA GARANTIA E DESABILITA A FUNÇÃO 3G, esse disclaimer é sempre o mesmo, mas não custa falar pra tirar o meu da reta :)

[obs: Desabilitar o 3G, pra mim, não é la grande problema já que eu não tenho plano de dados só pro tablet e uso majoritariamente em casa. Se essa dinâmica se aplica a você, e se você gosta de se meter a besta de atualizar seus devices, então siga em frente]


Poise, consegui a façanha bizarra de atualizar meu Motorola Xoom brasileiro sem querer. Certo, certo, a idéia era sim rootear e atualizar pro 3.1, mas eu só consegui isso depois de flashar todos os boot[root].img que encontrei. Só depois de quase brickar (e me cagar nas calças) eu decidi reflashar as imagens originais e FÃ: Descubro que a Motorola ainda não liberou as imagens pro modelo MZ605, o 3G brasileiro. Só me restou flashar a imagem do MZ604 (que é wifi only e por isso o disclaimer) e qual a surpresa? No dia seguinte tinha atualização OTA disponível pra mim! Yay! [obs: No site da Motorola tem sim outras imagens, com suporte a 3G inclusive, mas só as imagens do modelo MZ604 bootaram]

[UPDATE 16/maio] Só pra constar, para flashar uma imagem no Motorola Xoom você vai precisar de M$ Windows e seus Motorola drivers, além do Android SDK (para usar o fastboot). O procedimento para de fato flashar estão no próprio site da Motorola.

Mas no fundo no fundo atualizar o tablet era só foguinho de nerd. As atrações legais que a atualização trás (filmes no Market e o Google Music) ainda não estão disponíveis aqui no Brasil ainda.

segunda-feira, 25 de abril de 2011

Using mtpfs as storage device with Motorola Xoom and Ubuntu

Meta info: No, I am certainly not going to make review for this device. For this sort of content you can find tons of information on the web, one better than another. My post would be yet another in this sea of information :-) INSTEAD, let's learn how to mount it as "mass storage device" on Ubuntu Maverick.

(default image for this post :P)


This tutorial is needed because the new Android version (3.0 aka Honeycomb) DOES NOT support mass storage device YET. It uses MTP (Media Transfer Protocol). This is not bad at all! In fact, the transfer rates are pretty faster than in usual mount as mass storage.

The procedure is pretty straightforward, I found a complete guide on XDA developers forum, which I'll describe here in short words:

1) Install mtpfs package on Ubuntu:
otubo@vader ~ $ sudo apt-get install mtpfs

2) Create new rules in udev for the Xoom:
otubo@vader ~ $ cat > /etc/udev/rules.d/51-android.rules
SUBSYSTEM=="usb", SYSFS{idVendor}=="22b8", SYMLINK+="libmtp-%k", MODE="0666"

3) Create the mount point and make it yours:
otubo@vader ~ $ sudo mkdir /media/xoom
otubo@vader ~ $ sudo chown otubo:otubo /media/xoom

4) Configure your /etc/fstab to mount it automatically by adding this line:
mtpfs /media/xoom fuse user,noauto,allow_other 0 0

5) Uncomment the option user_allow_other on the fuse configuration file at /etc/fuse.conf

6) Add yourself to the fuse group.

7) Reboot, plug your Xoom in and click "xoom" on the "Places" menu on your Ubuntu. Simple as that :)

BUT, if you face any problems, like "Transport endpoint is not connected", you may need to reinstall mtpfs from a different version. This sort of error is a bug on mtpfs, it segfaults when trying to mount/access it. So I installed from Natty's repository and everything worked fine :) BUT, if you're reading this post after the Natty's release, you probably won't need to worry about this.

[IMPORTANT UPDATE - May/3/2011]

Later on I figured out that even with Natty's version of the mtpfs I was getting a segfault when trying to mount/access the device. So, I downloaded the source code from the maintainer's page, compiled and now EVERYTHING is working pretty fine. Thank God :) It's important to notice that the segfault is on the mtpfs package and not in libmtpfs (which I also tried to uninstall and install from source). If you need to mess with your system (install from source and not from repository) always try to mess as little as possible :)

[IMPORTANT UPDATE 2 - same day]

I got a segfault AGAIN. Trying to reproduce all the steps I figured out that I had to REBOOT my Motorola Xoom to make it work with the same setup. Looking forward to have a CyanogenMod ROM for my device. Sigh. :-(