cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
liwenz
Explorer
Explorer
3,488 Views
Registered: ‎10-09-2017

how to install and test usb disk on petalinux

My zynq 7010 has the usb interface. 

I make the petalinux and work fine.It could install SD card and read the files. I hope to install and test usb disk. How should I do?

I have connect the usb disk with 32G, 8G. 

0 Kudos
12 Replies
aravindb
Moderator
Moderator
3,447 Views
Registered: ‎02-07-2018

Hi @liwenz

 

By default kernel configured for USB host mode only. if you connect the USB pendrive it has to detect directly if the Jumper are set to USB host mode.

Please refer this link for jumper settings :https://www.xilinx.com/support/documentation/boards_and_kits/zc702_zvik/ug850-zc702-eval-bd.pdf   (page no:23 , Table 1-6)

 

Check the dmesg logs when you insert the pendrive & if it is showing usb node, please mount that node in case if it is not auto mounted.

 

For more info refer this link:https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842272/Zynq+Linux+USB+Device+Driver

 

 

Thanks & regards

Aravind

 

----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
----------------------------------------------------------------------------------------------

 

 

liwenz
Explorer
Explorer
3,429 Views
Registered: ‎10-09-2017

Thanks for your reply and link. I follow the link , I could petalinux-config. But after I petalinux-build, I can't find any .ko.

My petalinux is 2018.2, zynq 7010. I could boot from qspi or SD. 

Should I add the devicetree to which file?

Is device-tree.bbappend right?

I tried it and got an error when petalinux-build as follow:

...

Loaded 3424 entries from dependency cache.
ERROR: ParseError at /home/liwenz/pro/gpio/project-spec/meta-user/recipes-bsp/device-tree/device-tree.bbappend:6: unparsed line: 'usb_0: usb@e0002000 {'

 

When I test, do I need mount ? what's the name?

0 Kudos
aravindb
Moderator
Moderator
3,418 Views
Registered: ‎02-07-2018

HI @liwenz,

 

For USB Host mode , there is no .ko files generated, all are configured as static only.

Can you convert your system.dtb to system.dts using below command and check the usb_0 node, is that dr_mode="host" or different, if you are not changed anything, by default it will be 

 

dtc -I dtb -O dts -o system.dts  system.dtb

 

Thanks & regards

Aravind

 

----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
----------------------------------------------------------------------------------------------

0 Kudos
liwenz
Explorer
Explorer
3,404 Views
Registered: ‎10-09-2017

In my ubuntu16 and petalinux, I can't run  command.

My petalinux-config -c kernel is same with your link in last reply.

Maybe I need mount something which I don't know. I only hope to read/write files on usb disk. but I could find it anyway. 

 

0% [Working]^C
root@ubuntu:/home/liwenz/pro/gpio/images/linux# sudo apt install device-tree-compiler
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
device-tree-compiler
0 upgraded, 1 newly installed, 0 to remove and 67 not upgraded.
Need to get 356 kB of archives.
After this operation, 522 kB of additional disk space will be used.
Err:1 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 device-tree-compiler amd64 1.4.0+dfsg-2
Temporary failure resolving 'us.archive.ubuntu.com'
E: Failed to fetch http://us.archive.ubuntu.com/ubuntu/pool/main/d/device-tree-compiler/device-tree-compiler_1.4.0+dfsg-2_amd64.deb Temporary failure resolving 'us.archive.ubuntu.com'

E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
root@ubuntu:/home/liwenz/pro/gpio/images/linux# dtc -I dtb -O dts -o system.dts system.dtb
The program 'dtc' is currently not installed. You can install it by typing:
apt install device-tree-compiler
root@ubuntu:/home/liwenz/pro/gpio/images/linux#

0 Kudos
liwenz
Explorer
Explorer
3,380 Views
Registered: ‎10-09-2017

I find from file zynq-7000.dtsi in work/components/plnx_workplace/device-tree/device-tree

Does that mean I need change something?

 

usb0: usb@e0002000 {
compatible = "xlnx,zynq-usb-2.20a", "chipidea,usb2";
status = "disabled";
clocks = <&clkc 28>;
interrupt-parent = <&intc>;
interrupts = <0 21 4>;
reg = <0xe0002000 0x1000>;
phy_type = "ulpi";
};

usb1: usb@e0003000 {
compatible = "xlnx,zynq-usb-2.20a", "chipidea,usb2";
status = "disabled";
clocks = <&clkc 29>;
interrupt-parent = <&intc>;
interrupts = <0 44 4>;
reg = <0xe0003000 0x1000>;
phy_type = "ulpi";
};

0 Kudos
aravindb
Moderator
Moderator
3,374 Views
Registered: ‎02-07-2018

Hi @liwenz

 

Please follow below steps.

 

1 . Open system-user.dtsi and add below device tree changes.

 

vim project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi

 

/include/ "system-conf.dtsi"
/ {
};

&usb0 {
dr_mode = "host";
status = "okay";
};

 

&usb1 {
dr_mode = "host";
status = "okay";
};

 

petalinux-build

 

Thanks & regards

Aravind

 

----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
----------------------------------------------------------------------------------------------

 

 

 

0 Kudos
liwenz
Explorer
Explorer
3,352 Views
Registered: ‎10-09-2017

Thanks for your reply. But I have not got.

I do as you told me.

could you check my /dev, which one is usb disk. I guess it is mmcblk0, as mmcblk0p1 is sd, I show it in after change figure.

Does usb support 8g,32g , or other volumn?

 

fig:1 before change

beforeusb.png

 

after change:

usbafter.png

0 Kudos
liwenz
Explorer
Explorer
3,281 Views
Registered: ‎10-09-2017

After append your code, it petalinux-build ok. But the zynq-7000.dtsi has not changed. 

I also find that 

uart0: serial@e0000000 {
compatible = "xlnx,xuartps", "cdns,uart-r1p8";
status = "disabled";
clocks = <&clkc 23>, <&clkc 40>;
clock-names = "uart_clk", "pclk";
reg = <0xE0000000 0x1000>;
interrupts = <0 27 4>;
};

uart1: serial@e0001000 {
compatible = "xlnx,xuartps", "cdns,uart-r1p8";
status = "disabled";
clocks = <&clkc 24>, <&clkc 41>;
clock-names = "uart_clk", "pclk";
reg = <0xE0001000 0x1000>;
interrupts = <0 50 4>;
};

 

all the status are "disabled", but they could be used.

 

in the follow petalinux-config,  I could not find the last one:

USB Physical Layer drivers --->
        <*> Generic ULPI Transceiver Driver
others are set as it is.
 

 

Kernel Configuration

Ensure the below config parameters are selected

Device Drivers
USB support
    <*> Support for Host-side USB
    <*> EHCI HCD (USB 2.0) support
    <*> USB Mass Storage support
    <*> ChipIdea Highspeed Dual Role Controller
    <*> ChipIdea host controller
        USB Physical Layer drivers --->
        <*> Generic ULPI Transceiver Driver

 

in the pcw.dtsi

 

&usb0 {
phy_type = "ulpi";
status = "okay";
usb-reset = <&gpio0 46 0>;
};

 

lsusb shows nothing.

0 Kudos
aravindb
Moderator
Moderator
3,268 Views
Registered: ‎02-07-2018

Hi @liwenz

 

By default in zynq-7000.dtsi nodes status disabled only but when you add below nodes and build ,it will update in system.dtb file.

Covert the system.dtb to system.dts file and check. If the dr_mode=host then please check your USB host mode jumper settings  as per the link:https://www.xilinx.com/support/documentation/boards_and_kits/zc702_zvik/ug850-zc702-eval-bd.pdf (page no:23)

 

vim project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi

 

/include/ "system-conf.dtsi"
/ {
};

&usb0 {
dr_mode = "host";
status = "okay";
};

 

&usb1 {
dr_mode = "host";
status = "okay";
};

 

 

 

Thanks & regards

Aravind

 

----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
----------------------------------------------------------------------------------------------

0 Kudos
liwenz
Explorer
Explorer
3,186 Views
Registered: ‎10-09-2017

After liwenz@ubuntu:~/alinx/gpio/images/linux$ dtc -I dtb -O dts -o system.dts system.dtb
 

in system.dtb file:

 

usb@e0002000 {
compatible = "xlnx,zynq-usb-2.20a", "chipidea,usb2";
status = "okay";
clocks = <0x1 0x1c>;
interrupt-parent = <0x4>;
interrupts = <0x0 0x15 0x4>;
reg = <0xe0002000 0x1000>;
phy_type = "ulpi";
usb-reset = <0x6 0x2e 0x0>;
dr_mode = "host";
};

usb@e0003000 {
compatible = "xlnx,zynq-usb-2.20a", "chipidea,usb2";
status = "disabled";
clocks = <0x1 0x1d>;
interrupt-parent = <0x4>;
interrupts = <0x0 0x2c 0x4>;
reg = <0xe0003000 0x1000>;
phy_type = "ulpi";
};

 

When petalinux-config -c kernel , I can't find next option:

petalinux 2018.2

USB Physical Layer drivers --->
        <*> Generic ULPI Transceiver Driver

 I find it and it is enable.

0 Kudos
liwenz
Explorer
Explorer
3,179 Views
Registered: ‎10-09-2017

When I change the file as :

 

/include/ "system-conf.dtsi"
/ {
};
/{
usb_phy0: usb_phy@0 {
compatible = "usb-nop-xceiv";
#phy-cells = <0>;
};
};

&usb0 {
dr_mode = "host";
usb-phy = <&usb_phy0>;
};

 

lsusb has some information:

root@gpio:~# lsusb
Bus 001 Device 001: ID 1d6b:0002

0 Kudos
liwenz
Explorer
Explorer
3,171 Views
Registered: ‎10-09-2017

Thanks for your help. 

Now I could see the usb disk.

 

root@gpio:~# random: crng init done
usb 1-1: USB disconnect, device number 2
lsusb
Bus 001 Device 001: ID 1d6b:0002
root@gpio:~# usb 1-1: new high-speed USB device number 3 using ci_hdrc
usb 1-1: New USB device found, idVendor=058f, idProduct=6387
usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1: Product: Mass Storage
usb 1-1: Manufacturer: Generic
usb 1-1: SerialNumber: 086027D0
usb-storage 1-1:1.0: USB Mass Storage device detected
scsi host0: usb-storage 1-1:1.0
scsi 0:0:0:0: Direct-Access Generic Flash Disk 8.07 PQ: 0 ANSI: 4
sd 0:0:0:0: Attached scsi generic sg0 type 0
sd 0:0:0:0: [sda] 61440000 512-byte logical blocks: (31.5 GB/29.3 GiB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
sda: sda1
sd 0:0:0:0: [sda] Attached SCSI removable disk
FAT-fs (sda1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
ls
root@gpio:~# ls /mnt
root@gpio:~# mount /dev/sda1 /mnt
root@gpio:~# ls /mnt
System Volume Information boot bootmgr.efi setup.exe support
autorun.inf bootmgr efi sources
root@gpio:~#

 

the file is as follow:

 

 

/include/ "system-conf.dtsi"
/ {
};
/{
usb_phy0: usb_phy@0 {
compatible = "usb-nop-xceiv";
#phy-cells = <0>;
//reg = <0xe0002000 0x1000>;
//view-port = <0x170>;
//drv-vbus;
};
};

&usb0 {
//compatible = "xlnx,zynq-usb-2.20.a", "chipidea,usb2";
//clocks = <&&clkc 28>
dr_mode = "host";
//reg = <0xe0002000 0x1000>;
usb-phy = <&usb_phy0>;
};

 

I don't understand compatible = "usb-nop-xceiv";

As I could not see the u disk, I change the file as your link. 

compatible = "ulpi-phy"; then it could not boot.

Then I change it back. I don't know why I could see the usb disk.

0 Kudos