Archive for the 'PC' Category

13
Jul
12

Galaxy S3 access files in Linux

I’ve gotten myself a Samsung Galaxy S3 recently, and wanted to change the ringtones and upload some music.

The problem is, I use mainly linux (read: ‘I don’t have Windows’).

So what with the MTP/PTP?

Apparently libmtp and jmtpfs don’t work with the S3 very well. The error is something like:

$ mtp-detect
libmtp version: 1.1.3

Listing raw device(s)
Device 0 (VID=04e8 and PID=6860) is a Samsung GT-P7310/P7510/N7000/I9100/Galaxy Tab 7.7/10.1/S2/Nexus/Note.
Found 1 device(s):
Samsung: GT-P7310/P7510/N7000/I9100/Galaxy Tab 7.7/10.1/S2/Nexus/Note (04e8:6860) @ bus 2, dev 21
Attempting to connect device(s)
PTP_ERROR_IO: failed to open session, trying again after resetting USB interface
LIBMTP libusb: Attempt to reset device
LIBMTP PANIC: failed to open session on second attempt
Unable to open raw device 0
OK.

And since Kies is not available for linux (afaik) and running it on Wine is not really something I’m fond of, I had been searching for a way to access the phones files in a fast way.

There is a way, through rooting your phone, and installing an app, but my phone is new so I didn’t want that…yet 😀

Since the access would have to be fast to be of my liking, it would have to be through USB cable, not Wifi. So I would probably have to do sth with ADB (Android Debug Bridge, google it)..

There is an adbfs solution already there:
http://collectskin.com/adbfs/

But it seems to be extremely slow. Adb was NOT designed for this kind of usage (continuous I/O access).

So I went on using an app I already knew, SSHDroid:
https://play.google.com/store/apps/details?id=berserker.android.apps.sshdroid&hl=en

But doesn’t this create a SSH server for remote shell login? Yeah, kinda does… but it’s SSH! This means you can run SSHFS through it! And better, forward the listening port through ADB to your own machine, via USB cable, so no Wifi is needed.

Here are the steps:
1. Install SSHDroid and run it
2. With the phone connected via USB, test adb with

$adb devices

and see if it shows up
3. Forward the remote SSHDroid port to your machine with

$adb forward tcp:2222 tcp:2222

(2222 is the default SSHDroid port for none rooted phones)
4. Mount sshfs on your machine with:

$sshfs -p 2222 root@localhost:/mnt/ >mount point, like ~/Desktop/sshfs<

The default password should be admin, if you haven’t changed it. YOU SHOULD HAVE!
5. Done! On my Arch, nautilus did not want to unmount it, so I ran

$fusermount -u <mount point, like ~/Desktop/sshfs>

As always, don’t trust what I tell you to do, just some guidelines to be able to find a similar, if not the same, solution. Have in mind that the steps here are not idiot-proof, I expect that people at least be able to use google and the basics of linux, like installing sshfs.

UPDATE (2013-04-12):
I decided to try again using the S3 with MTP and installed go-mtpfs on Arch. https://wiki.archlinux.org/index.php/MTP

After adding me as owner to udev rule, it seems to work but has some bugs:

$ touch test
touch: failed to close ‘test’: Invalid argument

but the file shows up:

$ ls
BKP clockworkmod data DCIM Downloads LOST.DIR MOV07784.MPG Roms test Tools

$ cat test
cat: test: Invalid argument

removing it works fine…

mtpfs still doesn’t work… either with

$ mtfps ~/s3/

or

# mtfps -o allow_other /home/oliver/s3/

Just does nothing.

w00t
simple-mtfps seems to work fine, will test it further! (available in AUR from Arch or https://github.com/phatina/simple-mtpfs/)

Showing the devices:

$ simple-mtpfs -l
Device 0 (VID=04e8 and PID=6860) is a Samsung Galaxy models (MTP).
Unable to open ~/.mtpz-data for reading, MTPZ disabled.1: SamsungGalaxy models (MTP)

Mounting:

$ simple-mtpfs –device 1 s3/
Device 0 (VID=04e8 and PID=6860) is a Samsung Galaxy models (MTP).

Unmounting (obvious):

$ fusermount -u /home/oliver/s3

It is recomended not running simple-mtfps as root, as always… but nice that it doesn’t need to run as root 😀

Touching, displaying and removing files from both Phone and Card directories worked flawlessly.
Though I did not do a stress test on this method. Will try to pass some gigs later 😀

UPDATE2:
Seems jmtpfs is working too! Some time that I haven’t tried it. Another solution, I prefer simple-mtpfs though for more options, listing and specifying the device to be mounted.

03
Aug
11

Bluetooth TTL module and Murphy

I bought a new Bluetooth Serial TTL module at eBay for a project of mine, which I will probably documenting here.

It is from MDFLY, as can be seen in the pictures below. The model is RF-BT0417CB.

Since at the time I had not yet received my Arduino 2009, a friend of mine suggested I test it with his Bus Pirate v3.5(BP for short).

He had bought one but never really used it, so there were the two of us, trying to get the BP to work. It is accessed through serial through USB, so to talk to it we discovered that screen does emulate serial connections!

screen /dev/ttyUSB0 115200

(BAUD rate does not need to be 115200, could be any other probably, and device may not be /dev/ttyUSB0… check your dmesg)

Obs.: screen is a Linux program, not Windows. Deal with it or install Cygwin. ‘Ctrl+a, k, y’ kills the screen so you can close it if you need to(probably will).

After connecting, screen is black. Hit ENTER to have ‘HiZ>’ appear. Now we need to set the mode that the BP will operate, since it has many available features.

HiZ>m
1. HiZ
2. 1-WIRE
3. UART
4. I2C
5. SPI
6. 2WIRE
7. 3WIRE
8. LCD
9. DIO
x. exit(without change)

(1)>3
Set serial port speed: (bps)
1. 300
2. 1200
3. 2400
4. 4800
5. 9600
6. 19200
7. 38400
8. 57600
9. 115200
10. BRG raw value

(1)>5
Data bits and parity:
1. 8, NONE *default
2. 8, EVEN
3. 8, ODD
4. 9, NONE
(1)>
Stop bits:
1. 1 *default
2. 2
(1)>
Receive polarity:
1. Idle 1 *default
2. Idle 0
(1)>
Select output type:
1. Open drain (H=Hi-Z, L=GND)
2. Normal (H=3.3V, L=GND)
(1)>2
Ready
UART>

Explained:
UART is so the BP can comunicate through serial, 9600 is normally the default speed, most of the rest are default options, and I prefer to use the ‘Normal’ output type because my Bluetooth module is TTL.

You will also need to connect the pins of the BP to the module:

BP -> MODULE
GND->GND
+5V->+5V
MOSI->RX
MISO->TX

Now we need to set the BP to power the module:

UART>W
Power supplies ON

The modules LED should begin to blink. If it stays on steadily it means that the module is connected through Bluetooth to another device. If it is off.. recheck the previous steps.

UART>{
UART LIVE DISPLAY, } TO STOP

This sets the BP to listen to incoming serial data. If there is a stream of data that should not be, it usually means that the TX is not connected properly to the MISO pin or that the module is turned off.

To test the communication with the device, send “AT” to it with:

WRITE: “AT”
UART>
READ: 0x4F
UART>
READ: 0x4B

The AT command should return “OK”(O=0x4F, K=0x4B).
If this doesn’t happen, recheck the TX->MISO connection or the BAUD rate for the module may be wrong. Try setting the BAUD rate to other values by redoing the mode setup.
Note: the ‘b’ command for the BP sets the BAUD rate for the pc side communication, not the module side.

Now comes the ‘problem’. Somewhere I read that the command to set/see the BAUD rate of the device was “AT+BAUD1”. This actually sets the BAUD rate to 1200. Great!. The recommended setting is “AT+BAUD4”, which will set it to 9600.

Second problem. The Bluetooth module is kind of picky when sending a ‘complex’ command. “AT” should work at almost any place, “AT+…” will probably not.
As I showed above, sending “AT” will return “OK” but in hex, not as chars. When using “AT+BAUD4” or “AT+VERSION”(check the version), the hex numbers representing the string will be shown, and not characters, which is a pain.
Also, when sending and receiving data through other devices, the data will be shown as hex, which normally isn’t very practical.

You can run the BP in Macro mode.

UART>(0)
0.Macro menu
1.Transparent bridge
2. Live monitor
3.Bridge with flow control

2 and 3 can be used on to read. When pressing a key the exit the mode. So pretty useless for normal applications.
The ‘Transparent bridge’ mode connects you ‘directly’ to the module. In this mode you receive the characters normally, not in hex, but everything you write does not appear for you AND every char you send, is sent as you type, not after you press enter. So while “A” and then “T” will work and you will receive “OK” as an answer; “A”, “T”, “+”, and then the command will not work since apparently it takes to long for each char to reach the module, so the command is discarded and you don’t even receive the “OK” for the “AT” part.

09
Jul
11

New addition: Arduino

W00t! My new and only arduino just arrived!

Ordered it from eBay(HK, cough cough) instead of buying it here in Brazil. Obvious choice because it would cost me 62.6 USD instead of the 15 I payed.

I bought the Duemilanove, discovered later I should have bought the UNO, which has the ATmega8U2 instead of the FTDI to communicate via USB. This is better because the ATmega8U2 is programmable, so you could make it act as any USB device instead of just a virtual com.

Getting started is ridiculous, in ubuntu at least. Just download the arduino software available at arduino.cc, extract and run.

Select your board in Tools, and other minor configurations, paste the LED Tutorial(also available at the official site) onto the sketch and upload. There! Your first arduino code running!(Note that the 2009 already comes with a LED connected to the pin 13, no need to connect another)

The interesting thing is, the USB-TTL used to program the arduino can be used to communicate with your code that’s running inside the arduino! When using this feature, the pins 0 and 1 (digital), which are named RX and TX respectively, are/can be used to connect a serial ttl device directly to the computer.

Why is this so nice? I bought a bluetooth TTL module which I plan to connect to the arduino and make it talk to android!

 

Further ramblings:
With the launch of the ADK(Open Accessory Development Kit for android, which is basically an arduino with various sensors) you can now connect it via usb on the android an do all sort of stuff.

With a non-official ADK arduino, you must make use of the USB-Host shield and use the new lib.

First, ADK should be able to be host OR client, depending on the power source. Don’t know if the USB-Host shield supports this and/or the android device must be able to provide power via the usb interface. I should look into it… someday.

Second, the arduino UNO allows for USB device ’emulation’. Is the USB-Host shield really needed or could the ATmega8U2 be programmed to act as an ADK device/proxy?

 

 

So, a new hope a new turn. I should be posting stuff about the arduino and what I’m trying to do with it in the not that near future.

Some other posts are coming along slowly, when I have the opportunity to write. Must stop procrastinating!

26
Apr
11

Compiling GnuRadio on RHEL5 (5.6 Tikanga)

Since my android phone is taking a trip to the central technical assistance, I have time to write about some other things.

I’m currently trying to get gnuradio running on a Redhat 5 x64 machine.

Since the machines where I work have a custom repo, which updates all of them concurrently, the objective of this tutorial is to install gnuradio with minimal interference of customized packages which could induce presently or futurely a dependecy hell or any other problems…

If you don’t care for customized packages mayhem, I suggest taking a look at http://blackopsoft.com/Main_Page repository, which includes gnuradio and all it’s dependencies.

I’m compiling it onto my own account for now, will try to redistribute to the users in need of the software sometime.

Install via yum:
cppunit-devel
guile-devel
fftw3-devel

You need to get the following sources:

package (current version)
boost (1.46)
swig(1.3.40)
gnuradio(3.3.0)

Extract all of them.

swig:

./configure –prefix=~/swig_install/
make
make install

boost:

./bootstrap.sh –with-libraries=thread,date_time,program_options –prefix=~/boost_install/
./bjam install

gnuradio:

env PATH=~/swig_install/bin/:$PATH ./configure –with-boost=~/boost_install/ –prefix=~/gnuradio_install/ LDFLAGS=”-L~/gnuradio_install/lib64/” –prefix=~/gnuradio_install/
make
make install

Note: this throws error when trying to install python24 swig libs… Did not overcome those yet…
Obs.: the LDFLAGS=”-L~/gnuradio_install/lib64/” is a bug in gnuradio make install. make install tries to link to the lib without checking that it was installed to a custom prefix…

Testing the install:

env LD_LIBRARY_PATH=~/boost_install/lib/ ~/gnuradio_install/bin/gnuradio-config-info

Would have to test a compile using the libs…

UPDATE
Sorry, it was decided that the best would be to use a more upstream linux and we installed Fedora, so the installation was as complicated as running sudo yum install gnuradio-*.

19
Feb
11

Sharing Photosmart 7200 from ubuntu to win7 via smb

So, I had to format my mothers computer because the 30GB partition reserved for Windows 7 64-bits had less than 3GB free space, and nothing really removable.

Instead of being lazy and using gparted to fix the problem(which included removing a 30GB Windows XP partition and moving the current partition out of a logical section of the harddrive, I just backed up the games(Steam rocks!) and formatted the damn thing.

Of course, backing up 100GB of Steam games and then getting them back would be no easy task(12hours by the steam backup manager, spliting the games into DVD sized chunks).

After having reinstalled everything, I went to configure the printer which is connected at another computer and shared through samba on an ubuntu maverick. (It was working fine before I formatted the harddrive.)

I added the printer through the interface in windows, but a prompt asked me to select the correct driver. OF COURSE, the exact driver of the printer was NOT present. Only photosmart 8xxx or photosmart 3xxx.

Searching the internet, I found out that the driver only is installed through windows update. Great. I had to select a driver, which only was installed if the printer was selected as the correct model. Just great….

I saw some references about modifying the smb.conf and cupsd.conf but none of the tries worked. I discovered the printer could be shared by selecting the cups http interface in windows but cups did not allow remote connections, and I was not able to configure it otherwise.

I ended up grabing the printer and connecting it to the Windows 7 and installing the driver, removing the printer device and taking it back to the ubuntu computer.

Then the driver was available in the prompt. YAY.

Note: I did not need to do this before, because the first time I configured the printer, the computer sharing it was Windows XP and probably reports the driver correctly to windows 7.

UPDATE
And I formatted my windows machine again. Had the same problem AGAIN. Obvious…

But this time I think I solved it… I’m trying to as I’m writing this.
This time I shared the printer via CUPS. The samba loading before cups problem in ubuntu is at fault.

It is quite easy configuring the CUPS interface via http://localhost:631 and sharing it on the network. Fuck samba.

I added the printer via http://ubuntumaching:631/printers/printer_name and set a similar driver(Photosmart C7200).
Now, in Windows, go to the Devices and Printers window, right-click the printer in question and click the Printer properties.
In the Advanced tab, click the New Driver button. Then follow the wizard, using the Windows Update to update your drivers list. It will take a while.

Select your driver and voilá! The correct driver is installed!




The Author

Older Ramblings

Tweets

Linux User Sig