New fixes feedback - Xiaomi Mi Router 4A Gigabit Edition (R4AG/R4A Gigabit)

Once again thanks! I'll try and hopefully upload an image if i manage to do it in case anyone needs sqm.

@db260179 Thanks for these instructions. Trying them now. Should the build-min image match the md5sum of your uploaded v1.2 release?

It looks like the ./run-build.sh script needs to be called as './run-build.sh start-min' for the minimal image.

So build the docker image first - './run-build.sh build-image' then build the code inside - './run-build.sh start-min' - for minimal xiaomi image or start-full for lots of features etc

The built images/packages files will be in the 'bin/targets/mt7621' folder

Also as a tip for anyone doing this, put your 'dl' folder outside of this openwrt directory so that you can store all of the downloaded packages and not remove them on a cleanup. i.e. ln -s ../dl dl (symlink the dl folder in your user home folder to keep)

@db260179 Either I'm doing something wrong, or I think something has broken with your stable combo of build.sh / Dockerfile / run-build. I'm just learning docker a little to troubleshoot. Is it possible you are using a previously built docker image with a newer run-build script and your build image has extra files? Basically I'm building the build image (which works fine), then when trying to build openwrt image it exits quickly with a guid output. It looks like build.sh is missing in the or maybe just a path issue? I also noticed one of your commits removed the dl symlink creation so another possible cause?

Not sure if this is related too:

@Brett Interesting issue, so i've just git cloned on my ubuntu 18.04 machine and then cd into the docker folder: ./run-build.sh build-image (this will create a user in the image called buser based on your current runing linux user UID and GID), then i run the ./run-build.sh start-min. No issues?

So my question is what OS are you running on, version etc?
Your docker setup, have you added the current working user to the docker group?
No need to run as root, just a standard user in the docker group.

I don't know if this works reliably on windows or macosx? I only use linux machines.

Can you post the errors you are getting?

If its windows or macosx, those OS dont understand symlinks, most likely - so it cant find the ./build.sh script in the Dockerfile entrypoint.
As the openwrt symlink folder in the docker folder points to the current code in the parent folder. Its possible win/osx wont work? - feel free to change it to work on win/osx.

Thanks for quick reply, I'm using:

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.3 LTS"

My user is within the docker group.

I only get an error if I try to run the run-build.sh from folder above, for example:

~/xiaomi-m4a$ ./docker/run-build.sh build-min
d88027429572bf915f55f7761ba5987469ec33725ebb3d84251a91685de2bac9
docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"./build.sh\": stat ./build.sh: no such file or directory": unknown.

Otherwise I just get the guid output with nothing happening.
docker ps show's nothing running.
docker images show the mi4a-imagebuild image available.

~/xiaomi-m4a$ ./docker/run-build.sh build-min

This wont work, you need to

'cd docker', then run './run-build.sh build-min'

as the symlink is in this docker folder

Sorry should have been clearer, I've tried that and I just get a GUID back.
I then tried from folder above and then see the error posted.
I'm about to try with fresh clone and removing the container to start from scratch...

@db260179 Same issue after starting fresh:

~/xiaomi-m4a/docker$ ./run-build.sh start-min
6fd1659deb9810844934536ecc0d10fd57d2829dca98b986bcf2d3bcb94c2110
~/xiaomi-m4a/docker$

so do a bash -x -c './run-build.sh start-min

then you can run, change YOURUSERNAME to the user from the first output

docker run --name mi4a-openwrt-imagebuild -d --cap-add NET_ADMIN -v /home/*YOURUSERNAME*/xiaomi-m4a/docker/openwrt:/home/buser/openwrt mi4a-imagebuild:latest build-min

Then share the output
You can do a docker logs mi4a-openwrt-imagebuild, to see what the error is coming out as?

Incase you are not aware, the build starts in the background, so you will need to do a

docker logs mi4a-openwrt-imagebuild -f if you want to watch it build

This doesn't product an output of a username. I get this:

:~/xiaomi-m4a/docker$ bash -x -c './run-build.sh start-min'
+ ./run-build.sh start-min
c270b97279dd43bf7146e51f24fd7982821904c273de10ea5a0a2fc7500866a7

Do you mean just replace YOURRUSERNAME with the user I'm logged on to Ubuntu with?

Correct, you running username, assuming the path is the same = /home/username/

Thanks, this is the troubleshooting tip I was missing with docker :smiley:
Here's the error:

~/xiaomi-m4a/docker$ docker logs mi4a-openwrt-imagebuild
Update feeds...
Unable to create the feeds directory at ./scripts/feeds line 824.
Install all packages from feeds...
mkdir: cannot create directory 'tmp': Permission denied
make[1]: *** [/home/buser/openwrt/include/toplevel.mk:176: staging_dir/host/.prereq-build] Error 1
make: *** [/home/buser/openwrt/include/toplevel.mk:83: prepare-tmpinfo] Error 2
Cannot open './tmp/.packageinfo': No such file or directory
Can't open file './tmp/.targetinfo': No such file or directory
Ignoring feed 'packages' - index missing
Ignoring feed 'luci' - index missing
Ignoring feed 'routing' - index missing
Ignoring feed 'telephony' - index missing
Installing all packages from feed packages.
Ignoring feed 'packages' - index missing
Installing all packages from feed luci.
Ignoring feed 'luci' - index missing
Installing all packages from feed routing.
Ignoring feed 'routing' - index missing
Installing all packages from feed telephony.
Ignoring feed 'telephony' - index missing
Copy default config min to make image
cp: cannot create regular file '.config': Permission denied
Set to use default config
mkdir: cannot create directory 'tmp': Permission denied
make: *** [/home/buser/openwrt/include/toplevel.mk:176: staging_dir/host/.prereq-build] Error 1
Download packages before build
mkdir: cannot create directory 'tmp': Permission denied
make: *** [/home/buser/openwrt/include/toplevel.mk:176: staging_dir/host/.prereq-build] Error 1
Start build and log to build.log
tee: build.log: Permission denied
mkdir: cannot create directory 'tmp': Permission denied
make[2]: *** [/home/buser/openwrt/include/toplevel.mk:176: staging_dir/host/.prereq-build] Error 1
make[1]: *** [/home/buser/openwrt/include/toplevel.mk:83: prepare-tmpinfo] Error 2
make: *** [/home/buser/openwrt/include/toplevel.mk:225: world] Error 2

ok, so check the /etc/fstab - its possible your username is not allowed permission.

Can you output your /etc/fstab?

 cat /etc/fstab
# CLOUD_IMG: This file was created/modified by the Cloud Image build process
UUID=7b4b88a7-6d85-44eb-9155-3132fd3d1cd8       /        ext4   defaults,discard        0 0
LABEL=UEFI      /boot/efi       vfat    defaults,discard        0 0
/dev/disk/cloud/azure_resource-part1    /mnt    auto    defaults,nofail,x-systemd.requires=cloud-init.service,comment=cloudconfig       0       2

FYI, I'm running using a VM on Azure, hence the CLOUD_IMG...

Yikes, azure ?

do a mount -v | grep /
and type 'id'

then share output

Just 'id' to show your current user details

ok, clear your posts, i will look at the image im using, i will add some commands to check current user and match id and gid to container image.

Cleared. Thanks, will test when commands ready.

Well i managed to compile an image eventually.Because i had problems with docker on my linux laptop(Ubuntu 20.10) i tried compiling using the build.sh script on xiaomi-m4a folder and it worked (took some time though). So in a terminal i typed "cd xiaomi-m4a" and then "./build.sh build-full" (using build-min compiler gave me some errors and couldnt compile , dont know why) and i have a fully working image right now with sqm working perfectly!
Here is the sysupgrade.bin in case anyone needs it :

3 Likes