Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12604 Discussions

Exposing CV SOCkit dev as usb mass storage gadget, accessible from windows 7 machine

Altera_Forum
Honored Contributor II
2,053 Views

I am attempting to use sockit as an g_mass_storage device as a quick and dirty USB link.  

 

I get the error "could not insert 'g_mass_storage': no such device" when I run modprobe. 

 

I am creating the backing file with the following command:  

 

dd if=/dev/null of=./disk-file.img bs=1M seek=1024 count=0 

 

 

 

And attempting to load the the driver with the following command: 

 

modprobe g-mass-storage file=./disk-file.img 

 

I have looked at the device tree and the boot messages, it definitely looks like the Arm is aware of the OTG controller. 

 

Thanks in advance, 

Adam
0 Kudos
6 Replies
Altera_Forum
Honored Contributor II
956 Views

According to this page ... 

 

http://www.linux-usb.org/gadget/file_storage.html 

 

You need to partition the backing store before passing it off to the USB gadget driver. 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
956 Views

Dave, 

 

Thanks so much for your quick response. 

 

I had run through the partitioning earlier today with no luck. I did it again and got the same results. 

 

The fdisk parameters for the partition creation (n command if fdisk) are sector start/stop instead of cyclinder (which I see in the example). I will continue to cast about for a resolution to this. . . 

 

 

here is my terminal dump with the commands that i ran: 

 

root@arrow_sockit:~# dd bs=1M count=64 if=/dev/zero of=./backing_file 

64+0 records in 

64+0 records out 

root@arrow_sockit:~# fdisk backing_file 

Welcome to fdisk (util-linux 2.21.2). 

 

Changes will remain in memory only, until you decide to write them. 

Be careful before using the write command. 

 

Device does not contain a recognized partition table 

Building a new DOS disklabel with disk identifier 0xe3700929. 

 

Command (m for help): x 

 

Expert command (m for help): s 

Number of sectors (1-63, default 63): 8 

 

Expert command (m for help): h 

Number of heads (1-256, default 255): 16 

 

Expert command (m for help): c 

Number of cylinders (1-1048576, default 8): 1024 

 

Expert command (m for help): r 

 

Command (m for help): m 

Command action 

a toggle a bootable flag 

b edit bsd disklabel 

c toggle the dos compatibility flag 

d delete a partition 

l list known partition types 

m print this menu 

n add a new partition 

o create a new empty DOS partition table 

p print the partition table 

q quit without saving changes 

s create a new empty Sun disklabel 

t change a partition's system id 

u change display/entry units 

v verify the partition table 

w write table to disk and exit 

x extra functionality (experts only) 

 

Command (m for help): n 

Partition type: 

p primary (0 primary, 0 extended, 4 free) 

e extended 

Select (default p): p 

Partition number (1-4, default 1): 1 

First sector (2048-131071, default 2048): 1 

Value out of range. 

First sector (2048-131071, default 2048): 

Using default value 2048 

Last sector, +sectors or +size{K,M,G} (2048-131071, default 131071): 

Using default value 131071 

Partition 1 of type Linux and of size 63 MiB is set 

 

Command (m for help): t 

Selected partition 1 

Hex code (type L to list codes): b 

Changed system type of partition 1 to b (W95 FAT32) 

 

Command (m for help): p 

 

Disk backing_file: 67 MB, 67108864 bytes 

16 heads, 8 sectors/track, 1024 cylinders, total 131072 sectors 

Units = sectors of 1 * 512 = 512 bytes 

Sector size (logical/physical): 512 bytes / 512 bytes 

I/O size (minimum/optimal): 512 bytes / 512 bytes 

Disk identifier: 0xe3700929 

 

Device Boot Start End Blocks Id System 

backing_file1 2048 131071 64512 b W95 FAT32 

 

Command (m for help): w 

The partition table has been altered! 

 

 

WARNING: If you have created or modified any DOS 6.x 

partitions, please see the fdisk manual page for additional 

information. 

Syncing disks. 

 

root@arrow_sockit:~# modprobe g_mass_storage file=./backing_file 

ERROR: could not insert 'g_mass_storage': No such device 

root@arrow_sockit:~#
0 Kudos
Altera_Forum
Honored Contributor II
956 Views

Thanks for the quick response, Dave. 

 

I had tried the partitioning earlier and had no luck. The parmeters that fdisk asks for are not quite the same as the ones in the example, this bugs me. When I am partitioning it asks me for sector start/stop rather than cylinder. 

 

I get the same error with modprobe. 

 

Here is the full terminal dump: 

 

Sending discover... 

Sending discover... 

 

No lease, failing 

Starting portmap daemon... 

Sun Sep 29 01:40:00 UTC 2013 

INIT: Entering runlevel: 5 

Starting OpenBSD Secure Shell server: sshd 

NET: Registered protocol family 10 

IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready 

done. 

Starting syslogd/klogd: done 

Starting Lighttpd Web Server: lighttpd. 

Starting blinking LED server 

Stopping Bootlog daemon: bootlogd. 

 

_ ____ ____ _ ___ _ _ _____ _ 

/ \ _ __ _ __ _____ __ / ___| ___ / ___| |/ (_) |_ / |___ / / | 

/ _ \ | '__| '__/ _ \ \ /\ / / \___ \ / _ \| | | ' /| | __| | | |_ \ | | 

/ ___ \| | | | | (_) \ V V / ___) | (_) | |___| . \| | |_ | |___) || | 

/_/ \_\_| |_| \___/ \_/\_/ |____/ \___/ \____|_|\_\_|\__| |_|____(_)_| 

 

arrow_sockit login: root 

root@arrow_sockit:~# modprobe g_mass_storage 

ERROR: could not insert 'g_mass_storage': No such device 

root@arrow_sockit:~# modprobe g_mass_storage file=./backing_fi 

ERROR: could not insert 'g_mass_storage': No such device 

root@arrow_sockit:~# ls 

README disk-file.img readme 

adam_cool_beans disk_img.img soc_system.rbf 

altera hello sockit_golden_top.rbf 

backing_file hps_gpio test.txt 

bridgeoff.sh led_blink yipee_led 

bridgeon.sh led_blink_devices.sh 

clear_leds.sh my_first_hps 

root@arrow_sockit:~# modprobe g_mass_storage file=./backing_file 

ERROR: could not insert 'g_mass_storage': No such device 

root@arrow_sockit:~# modprobe g_mass_storag file=./backing_file 

FATAL: Module g_mass_storag not found. 

root@arrow_sockit:~# modprobe g_mass_storage file=./backing_file 

ERROR: could not insert 'g_mass_storage': No such device 

root@arrow_sockit:~# dd bs=1M count=64 if=/dev/zero of=./backing_file 

64+0 records in 

64+0 records out 

root@arrow_sockit:~# fdisk backing_file 

Welcome to fdisk (util-linux 2.21.2). 

 

Changes will remain in memory only, until you decide to write them. 

Be careful before using the write command. 

 

Device does not contain a recognized partition table 

Building a new DOS disklabel with disk identifier 0x5b98fcf9. 

 

Command (m for help): x 

 

Expert command (m for help): s 

Number of sectors (1-63, default 63): 8 

 

Expert command (m for help): h 

Number of heads (1-256, default 255): 16 

 

Expert command (m for help): c 

Number of cylinders (1-1048576, default 8): 1024 

 

Expert command (m for help): r 

 

Command (m for help): n 

Partition type: 

p primary (0 primary, 0 extended, 4 free) 

e extended 

Select (default p): p 

Partition number (1-4, default 1): 1 

First sector (2048-131071, default 2048): 

Using default value 2048 

Last sector, +sectors or +size{K,M,G} (2048-131071, default 131071): 

Using default value 131071 

Partition 1 of type Linux and of size 63 MiB is set 

 

Command (m for help): n 

Partition type: 

p primary (1 primary, 0 extended, 3 free) 

e extended 

Select (default p): p 

artition number (1-4, default 2): 

Using default value 2 

No free sectors available 

 

Command (m for help): exit 

e: unknown command 

Command action 

a toggle a bootable flag 

b edit bsd disklabel 

c toggle the dos compatibility flag 

d delete a partition 

l list known partition types 

m print this menu 

n add a new partition 

o create a new empty DOS partition table 

p print the partition table 

q quit without saving changes 

s create a new empty Sun disklabel 

t change a partition's system id 

u change display/entry units 

v verify the partition table 

w write table to disk and exit 

x extra functionality (experts only) 

 

Command (m for help): q 

 

root@arrow_sockit:~# dd bs=1M count=64 if=/dev/zero of=./backing_file 

64+0 records in 

64+0 records out 

root@arrow_sockit:~# fdisk backing_file 

Welcome to fdisk (util-linux 2.21.2). 

 

Changes will remain in memory only, until you decide to write them. 

Be careful before using the write command. 

 

Device does not contain a recognized partition table 

Building a new DOS disklabel with disk identifier 0xe3700929. 

 

Command (m for help): x 

 

Expert command (m for help): s 

Number of sectors (1-63, default 63): 8 

 

Expert command (m for help): h 

Number of heads (1-256, default 255): 16 

 

Expert command (m for help): c 

Number of cylinders (1-1048576, default 8): 1024 

 

Expert command (m for help): r 

 

Command (m for help): m 

Command action 

a toggle a bootable flag 

b edit bsd disklabel 

c toggle the dos compatibility flag 

d delete a partition 

l list known partition types 

m print this menu 

n add a new partition 

o create a new empty DOS partition table 

p print the partition table 

q quit without saving changes 

s create a new empty Sun disklabel 

t change a partition's system id 

u change display/entry units 

v verify the partition table 

w write table to disk and exit 

x extra functionality (experts only) 

 

Command (m for help): n 

Partition type: 

p primary (0 primary, 0 extended, 4 free) 

e extended 

Select (default p): p 

Partition number (1-4, default 1): 1 

First sector (2048-131071, default 2048): 1 

Value out of range. 

First sector (2048-131071, default 2048): 

Using default value 2048 

Last sector, +sectors or +size{K,M,G} (2048-131071, default 131071): 

Using default value 131071 

Partition 1 of type Linux and of size 63 MiB is set 

 

Command (m for help): t 

Selected partition 1 

Hex code (type L to list codes): b 

Changed system type of partition 1 to b (W95 FAT32) 

 

Command (m for help): p 

 

Disk backing_file: 67 MB, 67108864 bytes 

16 heads, 8 sectors/track, 1024 cylinders, total 131072 sectors 

Units = sectors of 1 * 512 = 512 bytes 

Sector size (logical/physical): 512 bytes / 512 bytes 

I/O size (minimum/optimal): 512 bytes / 512 bytes 

Disk identifier: 0xe3700929 

 

Device Boot Start End Blocks Id System 

backing_file1 2048 131071 64512 b W95 FAT32 

 

Command (m for help): w 

The partition table has been altered! 

 

 

WARNING: If you have created or modified any DOS 6.x 

partitions, please see the fdisk manual page for additional 

information. 

Syncing disks. 

root@arrow_sockit:~# modprobe g_mass_storage file=./backing_file 

ERROR: could not insert 'g_mass_storage': No such device 

root@arrow_sockit:~# root@arrow_sockit:~# modprobe g_mass_storage file=./backing_file 

-sh: root@arrow_sockit:~#: command not found 

root@arrow_sockit:~# ERROR: could not insert 'g_mass_storage': No such device 

-sh: ERROR:: command not found 

root@arrow_sockit:~# root@arrow_sockit:~# 

-sh: root@arrow_sockit:~#: command not found 

root@arrow_sockit:~#
0 Kudos
Altera_Forum
Honored Contributor II
956 Views

Hey Dave, 

 

Thanks for the quick response. I had tried to partition earlier with no luck. I tried again, with no luck. 

 

One insoncistency that I saw was that the when I use the "n" option in fdisk that it asks me for start/end sectors instead of cylinders that I see in the example.  

 

Thanks, 

Adam
0 Kudos
Altera_Forum
Honored Contributor II
956 Views

Here is the terminal dump for the commands that I used: 

 

root@arrow_sockit:~# dd bs=1M count=64 if=/dev/zero of=./backing_file 

64+0 records in 

64+0 records out 

root@arrow_sockit:~# fdisk -c=dos 

Usage: 

fdisk [options] <disk> change partition table 

fdisk [options] -l <disk> list partition table(s) 

fdisk -s <partition> give partition size(s) in blocks 

 

Options: 

-b <size> sector size (512, 1024, 2048 or 4096) 

-c[=<mode>] compatible mode: 'dos' or 'nondos' (default) 

-h print this help text 

-u[=<unit>] display units: 'cylinders' or 'sectors' (default) 

-v print program version 

-C <number> specify the number of cylinders 

-H <number> specify the number of heads 

-S <number> specify the number of sectors per track 

 

root@arrow_sockit:~# fdisk -c='dos' 

Usage: 

fdisk [options] <disk> change partition table 

fdisk [options] -l <disk> list partition table(s) 

fdisk -s <partition> give partition size(s) in blocks 

 

Options: 

-b <size> sector size (512, 1024, 2048 or 4096) 

-c[=<mode>] compatible mode: 'dos' or 'nondos' (default) 

-h print this help text 

-u[=<unit>] display units: 'cylinders' or 'sectors' (default) 

-v print program version 

-C <number> specify the number of cylinders 

-H <number> specify the number of heads 

-S <number> specify the number of sectors per track 

 

root@arrow_sockit:~# fdisk c=dos 

Welcome to fdisk (util-linux 2.21.2). 

 

Changes will remain in memory only, until you decide to write them. 

Be careful before using the write command. 

 

fdisk: unable to open c=dos: No such file or directory 

root@arrow_sockit:~# fdisk -c=dos ./backing_file 

Welcome to fdisk (util-linux 2.21.2). 

 

Changes will remain in memory only, until you decide to write them. 

Be careful before using the write command. 

 

Device does not contain a recognized partition table 

Building a new DOS disklabel with disk identifier 0xb4aa408e. 

 

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to 

switch off the mode (with command 'c'). 

Command (m for help): e 

e: unknown command 

Command action 

a toggle a bootable flag 

b edit bsd disklabel 

c toggle the dos compatibility flag 

d delete a partition 

l list known partition types 

m print this menu 

n add a new partition 

o create a new empty DOS partition table 

p print the partition table 

q quit without saving changes 

s create a new empty Sun disklabel 

t change a partition's system id 

u change display/entry units 

v verify the partition table 

w write table to disk and exit 

x extra functionality (experts only) 

 

Command (m for help): x 

 

Expert command (m for help): s 

Number of sectors (1-63, default 63): 8 

Warning: setting sector offset for DOS compatiblity 

 

Expert command (m for help): h 

Number of heads (1-256, default 255): 16 

 

Expert command (m for help): c 

Number of cylinders (1-1048576, default 8): 1024 

 

Expert command (m for help): r 

 

Command (m for help): n 

Partition type: 

p primary (0 primary, 0 extended, 4 free) 

e extended 

Select (default p): p 

Partition number (1-4, default 1): 1 

First sector (8-131071, default 8): 

Using default value 8 

Last sector, +sectors or +size{K,M,G} (8-131071, default 131071): 

Using default value 131071 

Partition 1 of type Linux and of size 64 MiB is set 

 

Command (m for help): t 

Selected partition 1 

Hex code (type L to list codes): b 

Changed system type of partition 1 to b (W95 FAT32) 

 

Command (m for help): o 

Building a new DOS disklabel with disk identifier 0xee0c56f2. 

 

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to 

switch off the mode (with command 'c'). 

Command (m for help): p 

 

Disk ./backing_file: 67 MB, 67108864 bytes 

16 heads, 8 sectors/track, 1024 cylinders, total 131072 sectors 

Units = sectors of 1 * 512 = 512 bytes 

Sector size (logical/physical): 512 bytes / 512 bytes 

I/O size (minimum/optimal): 512 bytes / 512 bytes 

Disk identifier: 0xee0c56f2 

 

Device Boot Start End Blocks Id System 

 

Command (m for help): w 

The partition table has been altered! 

 

 

WARNING: If you have created or modified any DOS 6.x 

partitions, please see the fdisk manual page for additional 

information. 

Syncing disks. 

root@arrow_sockit:~# modprobe g_mass_storage file=./backing_file
0 Kudos
Altera_Forum
Honored Contributor II
956 Views

Hi Adam, 

 

--- Quote Start ---  

 

I had tried to partition earlier with no luck. I tried again, with no luck. 

 

--- Quote End ---  

 

Sorry, your response is not clear; you had no luck partitioning the backing store, or you did partition it ok and had no luck with the USB gadget interface using it? 

 

I have an SoCKit ordered, but have not received it yet, so cannot try this yet. 

 

Cheers, 

Dave
0 Kudos
Reply