Recognition SDcard on Vagrant Environment - linux

Does anyone know how to recognize SD card on Linux in Vagarnt?
Vagrant 1.7.2
Host: Windows7 (and Cygwin)
Guest: Ubuntu15.04
At first I built Ubuntu CUI using
vagrant init ubuntu-15.04
vagrant up
in Ubuntu env:
sudo apt-get update
sudo apt-get install -y ubuntu-desktop
and I modified Vagrantfile by adding:
vb.gui = true
and modified to recognize SD card as USB device:
vb.customize ['modifyvm', :id, '--usb', 'on']
vb.customize ['usbfilter', 'add', '0',
'--target', :id,
'--name', 'Any mass storage',
'--manufacturer', 'Generic',
'--product', 'Mass Storage Device']
but I can't recognize SD-card and device such as /dev/sdb or /dev/sdc is not generated.
$ lsusb
Bus 001 Device 005: ID 1307:0310 Transcend Information, Inc. SD/MicroSD CardReader [hama]
Bus 001 Device 002: ID 04e6:5115 SCM Microsystems, Inc. SCR335 SmartCard Reader
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 40G 0 disk
└─sda1 8:1 0 40G 0 part /
sda1 is my HDD.
By default, installing Ubuntu15.04 from VirtualBox GUI, SD card can be detected by just inserting SD-card. So I can't understand the difference of
Installing Ubuntu from Vagrant with CUI --> add GUI environment
Installing Ubuntu from VirtualBox with GUI
How should I add modification to use SD card via installing from Vagrant CUI?

Related

block device access on windows docker tool box

docker installed my machine
ubuntu 12.04 (Virtual Machine on MAC)
windows 7 (native)
and Docker images as below ..
ubuntu 12.04 base docker image
when i run Docker image on Ubuntu 12.04 and insert Micro SD Card then Docker Image can access this block device.
Docker Image Execution Command as ...
docker run --privileged -i -t --cidfile ${ID_FILE} $1
and input lsblk command (on docker image)result as ..
root#4373a704da4a:/# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 64G 0 disk
|-sda1 8:1 0 63G 0 part
|-sda2 8:2 0 1K 0 part
`-sda5 8:5 0 1022M 0 part [SWAP]
sdb 8:16 1 3.8G 0 disk
`-sdb1 8:17 1 3.8G 0 part
sr0 11:0 1 1024M 0 rom
sr1 11:1 1 1024M 0 rom
sdb is Micro SD Card.
but when i tired this on Windows docker toolbox (same image above) sd card not appears.
docker image which executed by windows 7 and docker toolbox can's access block device ?
thank you.
Solved
windows Docker environment is based on "virtual box"
so, for using USB, install virtual box extension and setting USB 3.0 driver enable.
and run docker container, able access to Micro SD Card /dev/sdx

Cannot open /dev/video0 (No such device)

I am trying to install a webcam on a Synology NAS (arm, linux kernel 3.2.40).
I have compiled and installed the kernel modules, they seem to work. This is the kernel output when inserting the modules and plugging the camera (Logitech C270):
[ 130.963903] Linux video capture interface: v2.00
[ 136.098356] usbcore: registered new interface driver uvcvideo
[ 136.104135] USB Video Class driver (1.1.1)
[ 145.384393] usb 3-2: new high-speed USB device number 4 using etxhci_hcd_150119
[ 145.628583] uvcvideo: Found UVC 1.00 device USBDevice (046d:0825)
[ 145.726156] input: USBDevice as /devices/pci0000:00/0000:00:00.0/usb3/3-2/3-2:1.0/input/input0
This is the lsusb output:
# lsusb
libudev: udev_has_devtmpfs: name_to_handle_at on /dev: Function not implemented
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 004: ID 046d:0825 Logitech, Inc. Webcam C270
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
However, I cannot access the camera:
# v4l2-ctl --all
Failed to open /dev/video0: No such device
in strace:
open("/dev/video0", O_RDWR) = -1 ENODEV (No such device)
I have tried different camera model, the C270 on another computer (works fine), deleting /dev/video0 and re-creating it (mknod /dev/video0 c 81 0), changing permissions, etc. but I get the same error...
crw-rw-rw- 1 root video 81, 0 Jun 14 12:07 /dev/video0
lsmod shows that uvcvideo is not used for the camera:
# lsmod
Module Size Used by
uvcvideo 57657 0
videodev 72561 1 uvcvideo
usbcore 147080 7 ehci_hcd,etxhci_hcd,usb_storage,usblp,usbhid,uvcvideo
usb_common 592 1 usbcore
Any ideas?

Init process not found when booting with ramdisk as rootfs

I'm trying to setup a ramdisk for a setup I have with AT91SAM9261 and 2.6.30 kernel.
I know you would say why don't I use initramfs? I will use also that one, as of now I would like to check if I can boot with a ramdisk as rootfs.
I have already a root fs running fine on this system in jffs2 format.
I used below tutorial:
http://www.ibm.com/developerworks/library/l-initrd/
So I created the ramdisk directly on the embedded target, with 4MB size.
I used "dd" and "mkefs" and the ramdisk image works fine if I mount it as loop when rootfs is my jffs2.
I can browse mount_point and do stuff inside.
The content was created according to the section "Manually building initial RAM disk" in the above link.
In /dev I placed null and console, in /bin I copied busybox and created the links.
I set the execute attribute to init script as well, which works fine when I run it here (as loop device with jffs2 as rootfs)
In my kernel config I enabled ramdisk support as follows:
CONFIG_BLK_DEV_INITRD=y
CONFIG_RD_GZIP=y
CONFIG_BLK_DEV_RAM=y
CONFIG_BLK_DEV_RAM_COUNT=16
CONFIG_BLK_DEV_RAM_SIZE=4096
Using tftp I download the ramdisk image to 0x21100000.
At 0x20008000 I have the kernel uncompressed and at 0x22000000 the zImage copied.
However, I'm not able to boot successfully the system as it hangs when checking init process.
As I mentioned, I checked several times that my init can be executed,
I also used in the bootargs init=/bin/busybox or other scripts/binaries to check if any can be used as init.
Command line I use now:
bootargs=64M console=ttyS0,115200 root=/dev/ram0 rw
initrd=0x21100000,4194304 init=/init
For some I set ownership to "nobody" just to check if it makes any difference.
As it can be seen in the log output the ramdisk is mounted, but init fails.
It gives a warning to check the ext2 image, which I did before copying it and I have no error reported.
The tftp server is on Windows7. I though I might have some incompatibility if I copy the ramdisk image from linux to Windows then do tftp from Windows server.
So I copied the image again from Windows to linux, mounted it and checked if the FS reports any error and scripts can be executed - everything looks normal.
So I do have all files in place, attributes set, ramdisk is reported as being mounted ok as rootfs, but init cannot be found.
Uncompressing Linux......................................................................................................... done, booting the kernel.
Linux version 2.6.30-olimex (mishu#KubuntuVM) (gcc version 4.3.3 (Sourcery G++ Lite 2009q1-203) ) #1 Mon Dec 29 13:53:54 CET 2014
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00053177
CPU: VIVT data cache, VIVT instruction cache
Machine: Olimex SAM9-L9261
Ignoring unrecognised tag 0x54410008
Memory policy: ECC disabled, Data cache writeback
Clocks: CPU 198 MHz, master 99 MHz, main 18.432 MHz
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256
Kernel command line: 64M console=ttyS0,115200 root=/dev/ram0 rw initrd=0x21100000,4194304 init=/init
NR_IRQS:192
AT91: 96 gpio irqs in 3 banks
PID hash table entries: 256 (order: 8, 1024 bytes)
Console: colour dummy device 80x30
console [ttyS0] enabled
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 57384KB available (2924K code, 246K data, 132K init, 0K highmem)
Calibrating delay loop... 99.12 BogoMIPS (lpj=495616)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
net_namespace: 716 bytes
NET: Registered protocol family 16
AT91: Power Management
AT91: Starting after user reset
bio: create slab <bio-0> at 0
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
NET: Registered protocol family 1
Trying to unpack rootfs image as initramfs...
rootfs image is not initramfs (junk in compressed archive); looks like an initrd
Freeing initrd memory: 4096K
NetWinder Floating Point Emulator V0.97 (double precision)
JFFS2 version 2.2. (NAND) (SUMMARY) © 2001-2006 Red Hat, Inc.
msgmni has been set to 120
io scheduler noop registered
io scheduler anticipatory registered (default)
atmel_lcdfb atmel_lcdfb.0: backlight control is not available
atmel_lcdfb atmel_lcdfb.0: 225KiB frame buffer at 23140000 (mapped at ffc00000)
Console: switching to colour frame buffer device 40x30
atmel_lcdfb atmel_lcdfb.0: fb0: Atmel LCDC at 0x00600000 (mapped at c4866000), irq 21
atmel_usart.0: ttyS0 at MMIO 0xfefff200 (irq = 1) is a ATMEL_SERIAL
atmel_usart.1: ttyS1 at MMIO 0xfffb0000 (irq = 6) is a ATMEL_SERIAL
brd: module loaded
loop: module loaded
ssc ssc.1: Atmel SSC device at 0xc4878000 (irq 15)
Driver 'sd' needs updating - please use bus_type methods
dm9000 Ethernet Driver, V1.31
eth0 (dm9000): not using net_device_ops yet
eth0: dm9000e at c486a000,c486e044 IRQ 107 MAC: 3a:1f:34:08:54:64 (chip)
NAND device: Manufacturer ID: 0xec, Chip ID: 0xdc (Samsung NAND 512MiB 3,3V 8-bit)
Scanning device for bad blocks
Bad eraseblock 1478 at 0x00000b8c0000
Creating 2 MTD partitions on "atmel_nand":
0x000000000000-0x000000040000 : "Partition 1"
0x000000040000-0x000020000000 : "Partition 2"
atmel_spi atmel_spi.0: Atmel SPI Controller at 0xfffc8000 (irq 12)
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
at91_ohci at91_ohci: AT91 OHCI
at91_ohci at91_ohci: new USB bus registered, assigned bus number 1
at91_ohci at91_ohci: irq 20, io mem 0x00500000
usb usb1: New USB device found, idVendor=1d6b, idProduct=0001
usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb1: Product: AT91 OHCI
usb usb1: Manufacturer: Linux 2.6.30-olimex ohci_hcd
usb usb1: SerialNumber: at91
usb usb1: configuration #1 chosen from 1 choice
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
udc: at91_udc version 3 May 2006
g_serial gadget: Gadget Serial v2.4
g_serial gadget: g_serial ready
mice: PS/2 mouse device common for all mice
input: gpio-keys as /class/input/input0
ads7846 spi0.2: touchscreen, irq 29
input: ADS784x Touchscreen as /class/input/input1
rtc-at91sam9 at91_rtt.0: rtc core: registered at91_rtt as rtc0
IRQ 1/rtc0: IRQF_DISABLED is not guaranteed on shared IRQs
rtc-at91sam9 at91_rtt.0: rtc0: SET TIME!
i2c /dev entries driver
i2c-gpio: probe of i2c-gpio failed with error -16
Registered led device: led1
Registered led device: led2
Registered led device: led3
Advanced Linux Sound Architecture Driver Version 1.0.20.
at73c213 spi0.3: at73c213: supported bitrate is 48500 (64 divider)
usb 1-1: new full speed USB device using at91_ohci and address 2
usb 1-1: New USB device found, idVendor=0457, idProduct=0151
usb 1-1: New USB device strings: Mfr=0, Product=2, SerialNumber=3
usb 1-1: Product: USB Mass Storage Device
usb 1-1: SerialNumber: 8d54bd8186b42c
usb 1-1: configuration #1 chosen from 1 choice
scsi0 : SCSI emulation for USB Mass Storage devices
ALSA device list:
#0: SAM9-L9261 external DAC on irq 15
TCP cubic registered
NET: Registered protocol family 17
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
rtc-at91sam9 at91_rtt.0: hctosys: unable to read the hardware clock
RAMDISK: ext2 filesystem found at block 0
RAMDISK: Loading 4096KiB [1 disk] into ram disk... done.
EXT2-fs warning: mounting unchecked fs, running e2fsck is recommended
VFS: Mounted root (ext2 filesystem) on device 1:0.
Freeing init memory: 132K
Failed to execute /init. Attempting defaults...
Kernel panic - not syncing: No init found. Try passing init= option to kernel.
[<c002f414>] (unwind_backtrace+0x0/0xdc) from [<c025bd34>] (panic+0x40/0x110)
[<c025bd34>] (panic+0x40/0x110) from [<c0029500>] (init_post+0xd0/0xf8)
[<c0029500>] (init_post+0xd0/0xf8) from [<c00085a0>] (kernel_init+0xbc/0xe4)
[<c00085a0>] (kernel_init+0xbc/0xe4) from [<c0041998>] (do_exit+0x0/0x5ac)
[<c0041998>] (do_exit+0x0/0x5ac) from [<00000001>] (0x1)
I plan to rebuild busybox and try again, but as my current ramdisk image works when I mount it as loop I don't have too much confidence it will change something.
I'm out of ideas. I've been trying the whole day to get this working.
Help is much appreciated.
Thanks.
Missing libraries were the root cause for the non-executable init placed on the ramdisk.
Using chroot turned out to be extremely useful. With this issue I learned how to use chroot and simulate a jail.
Another trick was to use user_debug=31 in the command line so that the kernel will output a message saying that the file is not found.
It looks like the "file not found" does not really point to a missing file, but to a failure to read the file system due to busybox not executing properly (missing libraries).
In parallel I have compiled dynamically the busybox 1.20.02 for my arm architecture and the ramdisk worked properly (without libs).
This user_debug=31 turned out to be again useful when I compiled and ran busybox, as it was also failing after mounting the ramdisk, but it thrown out an "undefined exception" which led me to a wrong "arch" value used for compiling busybox. After changing it everything was fine.

AVRISP MKII doesn't work with AVRDUDE on Linux

The system sees something is plugged in when I plug and unplug it:
bluehat#Matapan:/dev$ tail -f /var/log/syslog
Mar 23 15:36:35 Matapan kernel: [156082.112874] usb 7-1: new full speed USB device using uhci_hcd and address 6
Mar 23 15:47:19 Matapan kernel: [156726.248081] usb 7-1: USB disconnect, address 6
Mar 23 15:47:29 Matapan kernel: [156736.200148] usb 6-1: new full speed USB device using uhci_hcd and address 3
AVRISP MKII should rely on cdc-acm:
bluehat#Matapan:/dev$ modinfo cdc-acm -V
module-init-tools version 3.12
So it should be able to see it just fine, and yet I am unable to write to it.
avrdude -p m1280 -c avrispmkII -P usb -U test.hex
Returns
avrdude: usb_open(): cannot read serial number "error sending control message: Operation not permitted"
avrdude: usb_open(): cannot read product name "error sending control message: Operation not permitted"
avrdude: usbdev_open(): error setting configuration 1: could not set config 1: Operation not permitted
avrdude: usbdev_open(): did not find any USB device "usb"
It turns out that Ubuntu will acknowledge that the object is there but not play nicely with it until you fix up some of your udev rules. Thanks to http://steve.kargs.net/bacnet/avr-isp-mkii-on-ubuntu-hardy/ which provided files that only needed a little updating.
Create new file /etc/udev/avrisp.rules
SUBSYSTEM!="usb", ACTION!="add", GOTO="avrisp_end"
# Atmel Corp. JTAG ICE mkII
ATTR{idVendor}=="03eb", ATTR{idProduct}=="2103", MODE="660", GROUP="dialout"
# Atmel Corp. AVRISP mkII
ATTR{idVendor}=="03eb", ATTR{idProduct}=="2104", MODE="660", GROUP="dialout"
# Atmel Corp. Dragon
ATTR{idVendor}=="03eb", ATTR{idProduct}=="2107", MODE="660", GROUP="dialout"
LABEL="avrisp_end"
Now create a virtual link to the file and give it a rule priority
cd /etc/udev/rules.d
sudo ln ../avrisp.rules 60-avrisp.rules
Check you're in the dialout group
groups
Restart udev
sudo service udev restart
Hooray!
For Ubuntu 12.04, there's a minor change that must be carried out to the configuration that Katy posted:
All occurrences of SYSFS should be replaced with ATTR
Additionally, if you're still having problems, make sure you have installed all the required dependent libraries. I found that I had to install the uisp package as well.
If restarting udev doesn't make a difference, unplugging the programmer and plugging it in back in does.
Updated rule that works for 13.10:
SUBSYSTEM!="usb", ACTION!="add", GOTO="avrisp_end"
# Atmel Corp. JTAG ICE mkII
ATTR{idVendor}=="03eb", ATTR{idProduct}=="2103", MODE="660", GROUP="dialout"
# Atmel Corp. AVRISP mkII
ATTR{idVendor}=="03eb", ATTR{idProduct}=="2104", MODE="660", GROUP="dialout"
# Atmel Corp. Dragon
ATTR{idVendor}=="03eb", ATTR{idProduct}=="2107", MODE="660", GROUP="dialout"
LABEL="avrisp_end"
Based on previous posts about changes.
Seems they changed it again in 12.10
The Subsystem is now "usb"
I found a command which shows what you need.
For that you just need to know the Bus and Device number from the plugged device
(use lsusb)
Bus 003 Device 010: ID 03eb:
lsusb
So my Bus number from the isp is 003 and Device is 010
(edit the end /003/010 to your needs)
udevadm info --attribute-walk --name=bus/usb/003/010
shows among many other things
SUBSYSTEM=="usb"
ATTR{idVendor}=="03eb"
ATTR{idProduct}=="2104"
Replace/change the created rule above and everything should work
If there are other Problems the Command will show them to you, it checks the rules (found a typo that way :))
If there is no error it won't show anything (Didn't realise for some time)
I used the following udev rules file to get it working on Fedora 19:
SUBSYSTEM!="usb", ACTION!="add", GOTO="avrisp_end"
# Atmel Corp. JTAG ICE mkII
ATTR{idVendor}=="03eb", ATTR{idProduct}=="2103", MODE="660", GROUP="dialout"
# Atmel Corp. AVRISP mkII
ATTR{idVendor}=="03eb", ATTR{idProduct}=="2104", MODE="660", GROUP="dialout"
# Atmel Corp. Dragon
ATTR{idVendor}=="03eb", ATTR{idProduct}=="2107", MODE="660", GROUP="dialout"
LABEL="avrisp_end"
As you can see, some minor things are different from what is suggested above. Also I had to restart the computer. Using "udevadm control --reload" was not enough.

Hacking USB devices: Any programs out there?

I would like to (A) run something under windows to eavesdrop on the communication between a USB device and windows, so I can then (B) write something to communicate with the USB device, under Linux. Can anybody recommend a program to do (A)?
Your best bet for watching USB traffic on Windows is Snoopy Pro which is based on USB Snoopy.
Once you move over to implementing your driver for Linux, you will want to make sure that usbmon is enabled in your kernel so you can get at the same information on your Linux box.
Make sure your kernel includes the necessary components:
$ cat /boot/config-`uname -r` | grep -P "CONFIG_USB_(MON|DEVICEFS)
CONFIG_USB_DEVICEFS=y
CONFIG_USB_MON=y
Mount the usbmon file system and make sure there is stuff in the usbmon directory:
$ sudo mount -t debugfs none_debugs /sys/kernel/debug
$ ls /sys/kernel/debug/usbmon/
0s 0u 1s 1t 1u 2s 2t 2u 3s 3t 3u 4s 4t 4u 5s 5t 5u 6s 6t 6u
Use lsusb to find the bus number of the device you are interested in:
$ lsusb
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 002: ID 045e:00d1 Microsoft Corp. Optical Mouse with Tilt Wheel
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 002: ID 0a5c:2110 Broadcom Corp. Bluetooth Controller
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Start listening on the bus of your choice (I am listening on bus 4 below):
$ sudo cat /sys/kernel/debug/usbmon/4u > ~/Desktop/usbmon.txt
Stop collecting data with Control-C.
You can try:
usbsnoop
and
usbsnoopy
usbmon: http://biot.com/blog/usb-sniffing-on-linux

Resources