ericpaulbishop / gargoyle

Gargoyle Router Management Utility
http://www.gargoyle-router.com
468 stars 221 forks source link

SD Card cannot be used as extended fs #843

Closed looxonline closed 4 years ago

looxonline commented 4 years ago

Hi,

I'm using the 30/10/19 build of 1.11 on a Youku YK-L1. All is good except one issue; I cannot get the SD card to be used as an extended FS.

When I insert the SD card the OS mounts it to some temp directory but as soon as I unmount it something odd happens. I can format it for ext4 via the cli but I cannot mount it again thereafter and neither can fdisk read the size of the disk.

root@Gargoyle:/# block info /dev/mtdblock5: UUID="ae8fd6b9-65c3ecb7-39e6b381-d77c2a27" VERSION="4.0" MOUNT="/rom" TYPE="squashfs" /dev/mtdblock6: MOUNT="/overlay" TYPE="jffs2" /dev/mmcblk0p1: UUID="5DD9-4D2D" LABEL="Untitled" TYPE="exfat" /dev/sda1: UUID="5BE4-623F" LABEL="L HARRISON" TYPE="exfat"

`fdisk -l Disk /dev/mmcblk0: 29.9 GiB, 32044482560 bytes, 62586880 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 Disklabel type: dos Disk identifier: 0x00000000

Device Boot Start End Sectors Size Id Type /dev/mmcblk0p1 * 8192 62586879 62578688 29.9G 7 HPFS/NTFS/exFAT`

root@Gargoyle:/# fdisk -s /dev/mmcblk0p fdisk: cannot open /dev/mmcblk0p: No such file or directory

since fdisk cannot read the size of the drive the usb_storage.sh haserl script fails in the GUI when clicking on the USB storage tab. If I eject and re-insert the SD card so that the OS mounts it to the tmp directory then the script runs but I can never unmount and make it part of the overlay.

If I run the USB script via cli this is the result:

root@Gargoyle:/# ./usb.sh var driveSizes = []; var storageDrives = []; var physicalDrives = []; var drivesWithNoMounts = []; drivesWithNoMounts.push( [ "/dev/sda", "31641829376" ] ); fdisk: cannot open /dev/mmcblk0p: No such file or directory ./usb.sh: line 22: arithmetic syntax error

Working with drives in *nix is not my strong suite as you may have noticed but I am willing to dig in and work with the devs to try and figure this one out.

obsy commented 4 years ago

/dev/mmcblk0p1 not /dev/mmcblk0p /dev/mmcblk0 <- this is sd card /dev/mmcblk0p1 <- this is partition 1

looxonline commented 4 years ago

/dev/mmcblk0p1 not /dev/mmcblk0p /dev/mmcblk0 <- this is sd card /dev/mmcblk0p1 <- this is partition 1

Yes well that is really part of the problem. You see, the usb_storage.sh script that runs when you click on the USB storage tab in the GUI references the SD card directly and not the partition and therefore it fails when it attempts the fdisk -s commend. The result of this is that the user gets a blank screen in the GUI. If you run fdisk -s on the partition it returns a valid size. Interestingly if you run fdisk -s on a USB thumb drive it returns a valid size for the drive and the partition which is why I am assuming the usb_storage.sh script has been written in the way that it has been.

lantis1008 commented 4 years ago

I don't have an SD card reader so I'll do my best here but will need you to do the leg work.

Can you please provide cat /tmp/drives_found.txt Before you insert it, after you insert it (auto mount) and after you unmount it? I expect the last two will be identical.

The output of blkid also thanks.

And I'll finish by saying the plugin is called usb storage, not SD storage, so any errors are probably par for the course at this stage :stuck_out_tongue:

lantis1008 commented 4 years ago

@looxonline did you intend to continue debugging this?

looxonline commented 4 years ago

Absolutely. Just been a bit of a crazy week. Hoping to get stuck into it tomorrow.

lantis1008 commented 4 years ago

Sounds good

looxonline commented 4 years ago

So this router uses a MediaTek MT7620A ver:2 eco:6 architecture which has had a WiFi bug since 2017 and has only JUST been fixed in the 19.07RC1. See https://github.com/openwrt/mt76/issues/302 and https://github.com/openwrt/mt76/issues/145. Because of this, when I load Gargoyle the WiFi drops out every hour or so. Since this is our primary router I am starting to get it from my wife so digging into this issue is proving to be challenging for me at the moment. I have ordered another one off aliexpress on Monday of this week gone by and I expect it to be here in about 3 weeks. Perhaps we can pick up on this when the second one arrives and I don't have to incur the wrath of my little lady? BTW the router is this one which is insanely cheap for something that has 32MB ROM and 128MB RAM as well as a reasonably beefy chipset, USB and an SD card holder internally. Really just a great little device.https://www.aliexpress.com/item/32820902708.html

lantis1008 commented 4 years ago

No problem at all. If you're so inclined, you could try building your own version of the 19.07 development branch: https://github.com/ericpaulbishop/gargoyle/tree/base_on_openwrt_1907

This is what is likely to eventually become 1.13.x, and will be based on the official 19.07 release when that happens. It is currently based on 19.07.0-rc1 if i recall correctly, and i'll do some work soon to move to rc2 now that it has been tagged.

looxonline commented 4 years ago

Ah I didn't even see that you had that branch. I'll definitely make a build for my arch sometime this week and carry on the work using that.

looxonline commented 4 years ago

So I built using this command line:

make ramips FULL_BUILD=true

Expecting to find an image for the Youku YK1 but when I listed the contents of the images directory all I found was this:

gargoyle_1.13.x-ramips-mt7620-alfa-network_ac1200rm-initramfs-kernel.bin gargoyle_1.13.x-ramips-mt7620-phicomm_k2g-squashfs-sysupgrade.bin gargoyle_1.13.x-ramips-mt7620-alfa-network_ac1200rm-squashfs-sysupgrade.bin gargoyle_1.13.x-ramips-mt7620-ravpower_wd03-initramfs-kernel.bin gargoyle_1.13.x-ramips-mt7620-dlink_dwr-921-c1-squashfs-factory.bin gargoyle_1.13.x-ramips-mt7620-ravpower_wd03-squashfs-sysupgrade.bin gargoyle_1.13.x-ramips-mt7620-dlink_dwr-921-c1-squashfs-sysupgrade.bin gargoyle_1.13.x-ramips-mt7621-xiaomi_mir3g-initramfs-kernel.bin gargoyle_1.13.x-ramips-mt7620-dlink_dwr-921-c3-squashfs-factory.bin gargoyle_1.13.x-ramips-mt7621-xiaomi_mir3g-squashfs-kernel1.bin gargoyle_1.13.x-ramips-mt7620-dlink_dwr-921-c3-squashfs-sysupgrade.bin gargoyle_1.13.x-ramips-mt7621-xiaomi_mir3g-squashfs-rootfs0.bin gargoyle_1.13.x-ramips-mt7620-phicomm_k2g-initramfs-kernel.bin gargoyle_1.13.x-ramips-mt7621-xiaomi_mir3g-squashfs-sysupgrade.bin

First time I've built gargoyle from source so I'm looking for some guidance on how to get the image I need out of the build.

lantis1008 commented 4 years ago

Running a test build overnight to see why it's not building. Will come back to you.

looxonline commented 4 years ago

Good stuff.

looxonline commented 4 years ago

Running a test build overnight to see why it's not building. Will come back to you.

Did the build finish up?

lantis1008 commented 4 years ago

Yes. You can retrieve your file from ramips-src/bin/targets/ramips/mt7620/ The wrong name is in the targets/ramips/profiles/mt7620_usb/profile_images Was youku_yk1, should be youku-yk1.

looxonline commented 4 years ago

Yes. You can retrieve your file from ramips-src/bin/targets/ramips/mt7620/ The wrong name is in the targets/ramips/profiles/mt7620_usb/profile_images Was youku_yk1, should be youku-yk1.

Thanks. Going to rebuild with the RC2 source and then give it a try.

lantis1008 commented 4 years ago

Cool. I've just pushed another commit, but it's not worth cancelling your build and starting again (if you have already). Minor kernel bump and the aforementioned image name fixes.

looxonline commented 4 years ago

Build is 5 minutes in so I'll start a new one. Will probably be able to build the single profile with the fixes so could be quicker to cancel.

obsy commented 4 years ago

Got it. Problem is in line: drives="$(awk -F':' '$1 ~ /^\/dev\// { sub(/[0-9]+$/, "", $1); arr[$1]; } END { for (x in arr) { print x; } }' /tmp/drives_found.txt)" in /www/usb_storage.sh uSD slot is recognized as

/dev/mmcblk0
/dev/mmcblk0p1
/dev/mmcblk0p2

So my proposed changes: drives="$(awk -F':' '$1 ~ /^\/dev\/sda[a-z]/ { sub(/[0-9]+$/, "", $1); arr[$1]; } /\/dev\/mmcblk/{sub(/p[0-9]+$/, "", $1); arr[$1];} END { for (x in arr) { print x; } }' /tmp/drives_found.txt)"

@looxonline : please change it and test, I will do it in the evening.

lantis1008 commented 4 years ago

@looxonline please close as this is now resolved

looxonline commented 4 years ago

Thanks mate. Sorry about the delay from my side. It's that time of year where things get a bit crazy and personal projects get put on the back burner. Will still test on the YK1 and provide feedback in this thread after it is closed.

Once again, thanks for working on this.

lantis1008 commented 4 years ago

No trouble, and it's thanks to @obsy for this one :)