From: Mauro Condarelli Date: Fri, 2 Oct 2020 10:59:00 +0200 Subject: Problems with large amount of partitions on SD Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de I am having huge problems with my system *possibly* due to fact I have 10 partitions on a single SD card. I'm getting an unreliable behavior (issuing the same commands do *not* result in consistent behavior) which *seem* to point to some overwrite/cache problem. First of all: is a configuration with 10 partitions on SD supported? I tried perusing files in disk/part*, but I failed to see where extended partitions are handled. Here follows one (typical) example: This is one example of a boot after a long time off, no key touched: ================================================================================ > U-Boot SPL 2020.10-rc5 (Oct 01 2020 - 17:14:04 +0200) > Trying to boot from NOR > > > U-Boot 2020.10-rc5 (Oct 01 2020 - 17:14:04 +0200) > > CPU: MediaTek MT7628A ver:1 eco:2 > Boot: DDR2, SPI-NOR 3-Byte Addr, CPU clock from XTAL > Clock: CPU: 580MHz, Bus: 193MHz, XTAL: 40MHz > DRAM: 128 MiB > WDT: Started with servicing (60s timeout) > MMC: mmc at 10130000: 0 > Loading Environment from SPIFlash... SF: Detected w25q128 with page size 256 Bytes, erase size 4 KiB, total 16 MiB > OK > In: uart2 at e00 > Out: uart2 at e00 > Err: uart2 at e00 > Model: VoCore2 > Net: > Warning: eth at 10110000 (eth0) using random MAC address - 0a:92:ae:d0:9b:c2 > eth0: eth at 10110000 > Hit any key to stop autoboot: 0 > Loading System B > > Partition Map for MMC device 0 -- Partition Type: DOS > > Part Start Sector Num Sectors UUID Type > 1 2048 262144 30f8737b-01 0c > 2 264192 4194304 30f8737b-02 83 > 3 4458496 32768 30f8737b-03 83 > 4 4491264 11268096 30f8737b-04 05 Extd > ** Can't read partition table on 0:4491264 ** > ** Can't read partition table on 0:4902912 ** > ** Invalid partition 7 ** > Loading Recovery ================================================================================ here recovery system is loaded from Flash, not mmc. After a "reboot" from linux I get: ================================================================================ > [48634.981029] reboot: Restarting system > [48634.984764] ralink_restart > > U-Boot SPL 2020.10-rc5 (Oct 01 2020 - 17:14:04 +0200) > Trying to boot from NOR > > > U-Boot 2020.10-rc5 (Oct 01 2020 - 17:14:04 +0200) > > CPU: MediaTek MT7628A ver:1 eco:2 > Boot: DDR2, SPI-NOR 3-Byte Addr, CPU clock from XTAL > Clock: CPU: 580MHz, Bus: 193MHz, XTAL: 40MHz > DRAM: 128 MiB > WDT: Started with servicing (60s timeout) > MMC: mmc at 10130000: 0 > Loading Environment from SPIFlash... SF: Detected w25q128 with page size 256 Bytes, erase size 4 KiB, total 16 MiB > OK > In: uart2 at e00 > Out: uart2 at e00 > Err: uart2 at e00 > Model: VoCore2 > Net: > Warning: eth at 10110000 (eth0) using random MAC address - be:c5:7e:06:ca:a1 > eth0: eth at 10110000 > Hit any key to stop autoboot: 0 ================================================================================ Here I stop autoboot. This is my complete environment. ================================================================================ > => printenv > BOOT_CURRENT=B > SYSTEM_R=/dev/mtdblock5 > arch=mips > baudrate=115200 > board=vocore2 > board_name=vocore2 > boot_a=echo "Loading System A";part=6;run boot_x > boot_b=echo "Loading System B";part=7;run boot_x > boot_now=if test "${BOOT_CURRENT}" = A; then run boot_a; elif test "${BOOT_CURRENT}" = B; then run boot_b; fi; if env exists BOOT_A_GOOD; then run boot_a; fi; if env exists BOOT_B_GOOD; then run boot_b; fi; run boot_r > boot_r=echo "Loading Recovery"; setenv bootargs "${default_bootargs} mtdparts=${mtdparts} root=/dev/mtdblock5"; bootm bc050000 > boot_x=mmc rescan && mmc part && ls mmc 0:${part} && load mmc 0:${part} 85000000 /boot/uImage && setenv bootargs "${default_bootargs} mtdparts=${mtdparts} root=/dev/mmcblk0p${part}" && bootm ${fileaddr} > bootcmd=mmc rescan && sleep 1 && run do_boot > bootcount=1 > bootdelay=2 > cpu=mips32 > default_bootargs=earlyprintk rootwait console=ttyS2,115200 > do_boot=test ${bootcount} -gt 1 && run remove_boot; run boot_now > fdtcontroladdr=86f6d350 > fileaddr=85000000 > filesize=268c63 > fupdate=mmc rescan && load mmc 0:1 84000000 uboot.scr && fatrm mmc 0:1 uboot.scr && source 84000000 && echo Flash updated > mtdids=nor0=spi0.0 > mtdparts=spi0.0:312k(u-boot),4k(env),4k(factory),2368k(kernel),-(filesystem) > remove_boot=if env exists BOOT_CURRENT; then setenv BOOT_CURRENT; saveenv; elif env exists BOOT_A_GOOD; then setenv BOOT_A_GOOD; saveenv; elif env exists BOOT_B_GOOD; then setenv BOOT_B_GOOD; saveenv; fi > soc=mt7628 > stderr=uart2 at e00 > stdin=uart2 at e00 > stdout=uart2 at e00 > vendor=vocore > ver=U-Boot 2020.10-rc5 (Oct 01 2020 - 17:14:04 +0200) > > Environment size: 1558/4092 bytes ================================================================================ I have two full systems on SD (partitions 6 and 7) and a fallback on Flash. Idea is to try to boot from BOOT_CURRENT System, if possible, fallback to the other, if "GOOD" and boot Recovery as last resort. I modified "boot_x"to do some printouts before booting (first 3 commands) Here I manually start "B" system boot: ================================================================================ > => run boot_b > Loading System B > > Partition Map for MMC device 0 -- Partition Type: DOS > > Part Start Sector Num Sectors UUID Type > 1 2048 262144 30f8737b-01 0c > 2 264192 4194304 30f8737b-02 83 > 3 4458496 32768 30f8737b-03 83 > 4 4491264 11268096 30f8737b-04 05 Extd > 5 4493312 409600 30f8737b-05 83 > 6 4904960 102400 30f8737b-06 83 > 7 5009408 102400 30f8737b-07 83 > 8 5113856 102400 30f8737b-08 83 > 9 5218304 102400 30f8737b-09 83 > 10 5322752 4194304 30f8737b-0a 83 > bin/ > boot/ > dev/ > etc/ > lib/ > lib32 > media/ > mnt/ > opt/ > over/ > proc/ > root/ > run/ > sbin/ > sys/ > tmp/ > usr/ > var/ > > 1 file(s), 17 dir(s) > > Error: too many data blocks to be read. > Failed to load '/boot/uImage' ================================================================================ ... which fails in a different way. I do again the same command (nothing in between) ================================================================================ > => run boot_b > Loading System B > > Partition Map for MMC device 0 -- Partition Type: DOS > > Part Start Sector Num Sectors UUID Type > 1 2048 262144 30f8737b-01 0c > 2 264192 4194304 30f8737b-02 83 > 3 4458496 32768 30f8737b-03 83 > 4 4491264 11268096 30f8737b-04 05 Extd > 5 4493312 409600 30f8737b-05 83 > 6 4904960 102400 30f8737b-06 83 > 7 5009408 102400 30f8737b-07 83 > 8 5113856 102400 30f8737b-08 83 > 9 5218304 102400 30f8737b-09 83 > 10 5322752 4194304 30f8737b-0a 83 > bin/ > boot/ > dev/ > etc/ > lib/ > lib32 > media/ > mnt/ > opt/ > over/ > proc/ > root/ > run/ > sbin/ > sys/ > tmp/ > usr/ > var/ > > 1 file(s), 17 dir(s) > > 2526307 bytes read in 260 ms (9.3 MiB/s) > ## Booting kernel from Legacy Image at 85000000 ... > Image Name: Linux-5.8.0 > Image Type: MIPS Linux Kernel Image (gzip compressed) ================================================================================ ... and it succeeds. I originally blamed this to my tweaks to SquashFS (part 6 and 7 are SquashFS), but it seems problem happens at partition level, before filesystem is touched. Please advise. Mauro