# Rebuild Pynq image failed

**URL:** https://discuss.pynq.io/t/rebuild-pynq-image-failed/120
**Category:** Support
**Created:** [May 22, 2019, 8:45pm UTC](https://discuss.pynq.io/t/rebuild-pynq-image-failed/120 "2019-05-22T20:45:46Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![aminous](https://avatars.discourse-cdn.com/v4/letter/a/35a633/32.png) [@aminous](https://discuss.pynq.io/u/aminous)
#### Post date: [May 22, 2019, 8:45pm UTC](https://discuss.pynq.io/t/rebuild-pynq-image-failed/120/1 "2019-05-22T20:45:47Z")

</div>

My goal is to simply rebuild the PYNQ image for Pynq-Z1. I have cloned the PYNQ repo but I don’t know what version of PYNQ is it (perhaps 2.3). The Vivado, SDx and Petalinux version is 2018.3 and I’m using Ubuntu 16.04 in an VMware environment. Before everything I ran the setup\_host.sh script. And finally I ran `make BOARDS=Pynq-Z1` command in the sdbuild directory. After some time I came up with the following error:

```
+ mount_points=($(sudo kpartx -av $image_file | cut -d ' ' -f 3))
++ sudo kpartx -av /home/user/Desktop/PYNQ/sdbuild/build/bionic.arm.stage1.img
++ cut -d ' ' -f 3
+ echo loop2p1
loop2p1
+ echo loop2p2
loop2p2
+ root_part=/dev/mapper/loop2p2
+ boot_part=/dev/mapper/loop2p1
+ sleep 1
+ sudo chroot / mkfs -t fat /dev/mapper/loop2p1
mkfs.fat 3.0.28 (2015-05-16)
/dev/mapper/loop2p1: No such file or directory
Makefile:299: recipe for target '/home/user/Desktop/PYNQ/sdbuild/build/bionic.arm.stage1.img' failed
make: *** [/home/user/Desktop/PYNQ/sdbuild/build/bionic.arm.stage1.img] Error 1

```

How can I solve this issue?

---

<div class="post-metadata">

### Author: ![rock](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/rock/32/32_2.png) [@rock](https://discuss.pynq.io/u/rock)
#### Post date: [May 23, 2019, 12:02am UTC](https://discuss.pynq.io/t/rebuild-pynq-image-failed/120/2 "2019-05-23T00:02:28Z")

</div>

I have seen this problem before. It is related to the actual speed when you mount/unmount the image.  
You need some patch like this:

> <https://github.com/Xilinx/PYNQ/commit/62cf7b17c9078967c1ed9e55eea463e26dafe271>

---

<div class="post-metadata">

### Author: ![aminous](https://avatars.discourse-cdn.com/v4/letter/a/35a633/32.png) [@aminous](https://discuss.pynq.io/u/aminous)
#### Post date: [May 23, 2019, 12:31pm UTC](https://discuss.pynq.io/t/rebuild-pynq-image-failed/120/3 "2019-05-23T12:31:50Z")

</div>

Thanks Rock!  
Where should I apply `sleep` command?

---

<div class="post-metadata">

### Author: ![gpcus](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/gpcus/32/54_2.png) [@gpcus](https://discuss.pynq.io/u/gpcus)
#### Post date: [May 23, 2019, 1:18pm UTC](https://discuss.pynq.io/t/rebuild-pynq-image-failed/120/4 "2019-05-23T13:18:52Z")

</div>

if you follow the link it will open the gitHub page and you have four modified lines in three files.  
In particular you must change:

- sleep 2 → sleep 5 [/sdbuild/scripts/resize\_umount.sh@line15]
- sleep 1 → sleep 5 [/sdbuild/scripts/create\_mount\_img.sh@line18]
- sleep 2 → sleep 5 [/sdbuild/scripts/create\_mount\_img.sh@line26]
- sleep 1 → sleep 5 [/sdbuild/scripts/unmount\_image.sh@line10]

I believe Rock is not GMT time, so it may take some time to reply

---

<div class="post-metadata">

### Author: ![gpcus](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/gpcus/32/54_2.png) [@gpcus](https://discuss.pynq.io/u/gpcus)
#### Post date: [May 23, 2019, 4:01pm UTC](https://discuss.pynq.io/t/rebuild-pynq-image-failed/120/5 "2019-05-23T16:01:48Z")

</div>

I made the suggested changes and it failed again. The latest output is saved in attachment.  
[new 1.txt](https://discuss.pynq.io/uploads/short-url/oI33tOw1P2WhrvlzZN5HjLCUEMw.txt) (124.8 KB)  
I understand it goes:

- all the way down to line#1931- the makefile line#263 is being executed
- #1932 - makefile line#264 i.e. run mount\_images.sh
- #1933/34 - echo of the mount\_points from inside mount\_image.sh
- #1935 - makefile line#265 i.e run install\_packages.sh  
then, after set -x, it start listing install\_package.sh, and anything else called by it, while executing until line #2021, when pynq/qemu.sh line#31 spits an output about invalid user…

and then I lose it 😡 I can’t follow it after “ **unmount special** ”  
A function called by trap in install\_packages.sh…  
I would say there s some problem installing packages?  
Please help!  
Best regards

---

<div class="post-metadata">

### Author: ![rock](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/rock/32/32_2.png) [@rock](https://discuss.pynq.io/u/rock)
#### Post date: [May 23, 2019, 5:17pm UTC](https://discuss.pynq.io/t/rebuild-pynq-image-failed/120/6 "2019-05-23T17:17:04Z")

</div>

The failure looks better than last time. At least you got pandas and sigrok built successfully.

The error seems to be invalid user for chown command. Let me clarify a few things: 1. are you using a prebuilt rootfs image, or building the rootfs image from scratch? 2. did you run `make clean` before you run any make?

---

<div class="post-metadata">

### Author: ![aminous](https://avatars.discourse-cdn.com/v4/letter/a/35a633/32.png) [@aminous](https://discuss.pynq.io/u/aminous)
#### Post date: [May 24, 2019, 5:28am UTC](https://discuss.pynq.io/t/rebuild-pynq-image-failed/120/7 "2019-05-24T05:28:09Z")

</div>

I followed your instruction, but my problem differs from that of gpcus!  
I also unmounted every image the previous process made and did a make clean before performing the new make.  
Now the error is:

```
cp --sparse=always /home/user/Desktop/PYNQ/sdbuild/build/bionic.arm.stage1.img 
/home/user/Desktop/PYNQ/sdbuild/build/bionic.arm.stage2.img
/home/user/Desktop/PYNQ/sdbuild/scripts/mount_image.sh 
/home/user/Desktop/PYNQ/sdbuild/build/bionic.arm.stage2.img 
/home/user/Desktop/PYNQ/sdbuild/build/bionic.arm
loop0p1
loop0p2
mount: special device /dev/mapper/loop0p2 does not exist
mount: mount point /home/user/Desktop/PYNQ/sdbuild/build/bionic.arm/boot does not exist
QEMU_EXE=/opt/qemu/bin/qemu-arm-static PYNQ_BOARD=Unknown ARCH=arm / 
home/user/Desktop/PYNQ/sdbuild/scripts/install_packages.sh 
/home/user/Desktop/PYNQ/sdbuild/build/bionic.arm gcc-mb python_packages_bionic libsds 
jupyter phantomjs-fix pandas sigrok
+ target=/home/user/Desktop/PYNQ/sdbuild/build/bionic.arm
+ shift
+ fss='proc run dev'
+ for fs in '$fss'
+ sudo mount -o bind /proc /home/user/Desktop/PYNQ/sdbuild/build/bionic.arm/proc
mount: mount point /home/user/Desktop/PYNQ/sdbuild/build/bionic.arm/proc does not exist
Makefile:299: recipe for target ' 
/home/user/Desktop/PYNQ/sdbuild/build/bionic.arm.stage2.img' failed
make: *** [/home/user/Desktop/PYNQ/sdbuild/build/bionic.arm.stage2.img] Error 32

```

By the way, addressing your first question, I’m using `make` command instead of image\_from\_prebuilt.sh so I think I’m building the Pynq-Z1 image from scratch (which should be a trivial task!).

---

<div class="post-metadata">

### Author: ![gpcus](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/gpcus/32/54_2.png) [@gpcus](https://discuss.pynq.io/u/gpcus)
#### Post date: [May 24, 2019, 8:09am UTC](https://discuss.pynq.io/t/rebuild-pynq-image-failed/120/8 "2019-05-24T08:09:42Z")

</div>

Hello Rock, unfortunately we are on different time, I am based in UK, so there is always a significant slack between replies.

1. I believe I am building from scratch.

- I set up the VM as instructed
- I am running **make BOARDDIR=_myBoardPath_**

1. I run **make clean** before

xilinx user is added in create\_rootfs.sh. I am now looking at it… it is run at makefile#271.  
unfortunately it must be so far back that nothing of it was logged…  
I attach a new, longer log, showing xilinx user being added at an earlier stage.  
[putty.1st.log](https://discuss.pynq.io/uploads/short-url/2E4eruCxjYlV6ia7B3tWpWNxleE.log) (3.4 MB)

Best regards

---

<div class="post-metadata">

### Author: ![rock](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/rock/32/32_2.png) [@rock](https://discuss.pynq.io/u/rock)
#### Post date: [May 24, 2019, 4:28pm UTC](https://discuss.pynq.io/t/rebuild-pynq-image-failed/120/9 "2019-05-24T16:28:23Z")

</div>

Can you check if you have enough disk space on your VM? It seems that when you mount stage 2 image, there is an error.

---

<div class="post-metadata">

### Author: ![rock](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/rock/32/32_2.png) [@rock](https://discuss.pynq.io/u/rock)
#### Post date: [May 24, 2019, 5:11pm UTC](https://discuss.pynq.io/t/rebuild-pynq-image-failed/120/10 "2019-05-24T17:11:30Z")

</div>

For this type of error, it looks similar to [https://github.com/Xilinx/PYNQ/issues/643](https://github.com/Xilinx/PYNQ/issues/643)

One thing to make sure, is to unmount all the images before running a `make clean`. So before running make again, make sure `sudo losetup -a` returns nothing. If there is an image mounted, use

```auto
sudo umount build/bionic.<board>/boot
sudo umount build/bionic.<board>
sudo kpartx -d <image_file>

```

The disk to unmount depends on at which stage you failed. Did you do that?

---

<div class="post-metadata">

### Author: ![gpcus](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/gpcus/32/54_2.png) [@gpcus](https://discuss.pynq.io/u/gpcus)
#### Post date: [May 24, 2019, 7:12pm UTC](https://discuss.pynq.io/t/rebuild-pynq-image-failed/120/11 "2019-05-24T19:12:05Z")

</div>

Hi Rock,  
Can you point me to where, in the log file attached in the previous reply, I got an error mounting the stage 2 image?  
I have no disk space problem, the VM is 200GB on a server, not on my workstation  
Thanks

---

<div class="post-metadata">

### Author: ![gpcus](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/gpcus/32/54_2.png) [@gpcus](https://discuss.pynq.io/u/gpcus)
#### Post date: [May 24, 2019, 7:23pm UTC](https://discuss.pynq.io/t/rebuild-pynq-image-failed/120/12 "2019-05-24T19:23:08Z")

</div>

Hello there,  
I normally do a build on clean machine after power up, there is nothing mounted and there is no build/bionic.arm/boot, no build/bionic.arm. The link you mention above is of interest, though, exactly the same error! On monday I’ll see if I can progress further. Do you think the four chmod lines in pynq qemu.sh where the make fails are of paramount importance? Worth to comment it out and see where how far it goes?  
Best regards

---

<div class="post-metadata">

### Author: ![gpcus](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/gpcus/32/54_2.png) [@gpcus](https://discuss.pynq.io/u/gpcus)
#### Post date: [May 24, 2019, 7:31pm UTC](https://discuss.pynq.io/t/rebuild-pynq-image-failed/120/13 "2019-05-24T19:31:13Z")

</div>

By the way, should I create a new issue and attach the complete make log to the GitHub repository? Or you have already done that?  
Regards

---

<div class="post-metadata">

### Author: ![rock](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/rock/32/32_2.png) [@rock](https://discuss.pynq.io/u/rock)
#### Post date: [May 24, 2019, 7:58pm UTC](https://discuss.pynq.io/t/rebuild-pynq-image-failed/120/14 "2019-05-24T19:58:00Z")

</div>

No need to open that issue. I am curious about how it failed. It looks pretty normal when you finished installing pynq package, then you unmount all the disks, that error message is not clear to me how it failed.

One thing to try, is to manually go through those package installation to see why the package failed. I think you can leverage the mount\_image.sh, install\_package.sh, and unmount\_image.sh, just like what the Makefile is doing.

---

<div class="post-metadata">

### Author: ![rock](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/rock/32/32_2.png) [@rock](https://discuss.pynq.io/u/rock)
#### Post date: [May 24, 2019, 8:00pm UTC](https://discuss.pynq.io/t/rebuild-pynq-image-failed/120/15 "2019-05-24T20:00:24Z")

</div>

Ok. Now I understand your environment. How did you setup passwordless sudo on your VM?

---

<div class="post-metadata">

### Author: ![gpcus](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/gpcus/32/54_2.png) [@gpcus](https://discuss.pynq.io/u/gpcus)
#### Post date: [May 24, 2019, 8:26pm UTC](https://discuss.pynq.io/t/rebuild-pynq-image-failed/120/16 "2019-05-24T20:26:53Z")

</div>

I didn’t do it myself. The VM was setup from IT, I only installed software, run setup\_host.sh, cloned GitHub and installed few bits and bobs setup\_host miss (cython and dlibz:i386)  
The fact that I can sudo without having to enter a password seems sufficient to say it is ok.

---

<div class="post-metadata">

### Author: ![rock](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/rock/32/32_2.png) [@rock](https://discuss.pynq.io/u/rock)
#### Post date: [May 24, 2019, 8:48pm UTC](https://discuss.pynq.io/t/rebuild-pynq-image-failed/120/17 "2019-05-24T20:48:23Z")

</div>

The relevant part of your log:

```auto
+ hostname DL-POC-TBI-366-PYNQ
+ rm -rf pynq_git
+ rm -rf jupyter_notebooks_2019_05_24_13_17_04 jupyter_notebooks_2019_05_24_13_17_16
+ cd /root
++ pip3 show pynq
++ cut -d : -f 2
++ grep '^Location'
+ pynq_dir=' /usr/local/lib/python3.6/dist-packages/pynq'
+ '[' '!' -e /home/xilinx/pynq ']'
+ ln -s /usr/local/lib/python3.6/dist-packages/pynq /home/xilinx/pynq
+ chown xilinx:xilinx /home/xilinx/REVISION
/bin/chown: invalid user: ‘xilinx:xilinx’
+ unmount_special
+ for fs in '$fss'
+ sudo umount -l /home/guido/PYNQ/sdbuild/build/bionic.arm/proc
+ for fs in '$fss'
+ sudo umount -l /home/guido/PYNQ/sdbuild/build/bionic.arm/run
+ for fs in '$fss'
+ sudo umount -l /home/guido/PYNQ/sdbuild/build/bionic.arm/dev
+ sudo umount -l /home/guido/PYNQ/sdbuild/build/bionic.arm/ccache
+ rmdir /home/guido/PYNQ/sdbuild/build/bionic.arm/ccache
Makefile:299: recipe for target '/home/guido/PYNQ/sdbuild/output/bionic.arm.2.4.img' failed
make: *** [/home/guido/PYNQ/sdbuild/output/bionic.arm.2.4.img] Error 1

```

If you follow your log, it is the first time when you install pynq where the make flow failed. [https://github.com/Xilinx/PYNQ/blob/master/sdbuild/ubuntu/bionic/arm/config#L3](https://github.com/Xilinx/PYNQ/blob/master/sdbuild/ubuntu/bionic/arm/config#L3)  
You can see your pandas and sigrok have been installed successfully.

The only suspicious thing I see is this line:

```auto
/bin/chown: invalid user: ‘xilinx:xilinx’

```

in your log file. One thing to try quickly, is to disable those 4 chown commands (for some reasons they failed, and you only see the first chown command)

> <https://github.com/Xilinx/PYNQ/blob/master/sdbuild/packages/pynq/qemu.sh#L31>

Is there any restrictions on your sudo rights? Also, if you know how to chroot to your image, you can do a quick try of `chown` call by itself. I think it might be related to your environment.

P.S. to chroot to your image, when the make fails, do not unmount it or delete it, just do this command immediately:

```auto
sudo -E chroot /home/guido/PYNQ/sdbuild/build/bionic.arm/ bash

```

This will bring you onto the QEMU environment. You can exit it by typing `exit` anytime. While in the QEMU environment, try to make a folder somewhere and `chown xilinx:xilinx <your_folder>` to see if it works.

---

<div class="post-metadata">

### Author: ![aminous](https://avatars.discourse-cdn.com/v4/letter/a/35a633/32.png) [@aminous](https://discuss.pynq.io/u/aminous)
#### Post date: [May 24, 2019, 9:05pm UTC](https://discuss.pynq.io/t/rebuild-pynq-image-failed/120/18 "2019-05-24T21:05:04Z")

</div>

I have 30GB left for whole this process, and upon failing (on mounting stage2) the VM has 17GB disk space. Do you this might cause the issue?

---

<div class="post-metadata">

### Author: ![rock](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/rock/32/32_2.png) [@rock](https://discuss.pynq.io/u/rock)
#### Post date: [May 24, 2019, 9:08pm UTC](https://discuss.pynq.io/t/rebuild-pynq-image-failed/120/19 "2019-05-24T21:08:18Z")

</div>

This is fine. Keep in mind that you will have to unmount all the old images before you run a make. Easier way might be restart your VM, run a make clean, then run make.

---

<div class="post-metadata">

### Author: ![aminous](https://avatars.discourse-cdn.com/v4/letter/a/35a633/32.png) [@aminous](https://discuss.pynq.io/u/aminous)
#### Post date: [May 27, 2019, 7:39pm UTC](https://discuss.pynq.io/t/rebuild-pynq-image-failed/120/20 "2019-05-27T19:39:45Z")

</div>

Hi Rock,

Unfortunately I could not achieve any further progress in running make BOARDS=Pynq-Z1 command. However, as my final goal is to rebuild the PYNQ image for ZC706 board, I used the image\_from\_prebuilt.sh script to make an image from a prebuilt generic arm image.  
Fortunately this script finished successfully. The problem is I cannot connect to the board via ethernet port (I communicate with board through serial port). When I run ifconfig command in the Pynq running on the ZC706 board I just see the `lo` (loopback):

```
xilinx@pynq:~$ ifconfig
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 90 bytes 6376 (6.3 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 90 bytes 6376 (6.3 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

```

and when I run `ifconfig -a` I get:

```
eth0: flags=4098<BROADCAST,MULTICAST> mtu 1500
    ether 52:5d:af:d7:69:03 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
    device interrupt 28 base 0xb000

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
    inet 127.0.0.1 netmask 255.0.0.0
    inet6 ::1 prefixlen 128 scopeid 0x10<host>
    loop txqueuelen 1000 (Local Loopback)
    RX packets 444 bytes 35260 (35.2 KB)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 444 bytes 35260 (35.2 KB)
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

sit0: flags=128<NOARP> mtu 1480
    sit txqueuelen 1000 (IPv6-in-IPv4)
    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

```

How can make the ethernet of board functional?

Thanks

[Next page](https://discuss.pynq.io/t/rebuild-pynq-image-failed/120.md?page=2)
