Skip to content

Commit

Permalink
cmd: mbr: Allow 4 MBR partitions without need for extended
Browse files Browse the repository at this point in the history
Current code allows up to 3 MBR partitions without extended one.
If more than 3 partitions are required, then extended partition(s)
must be used.
This commit allows up to 4 primary MBR partitions without the
need for extended partition.

Add mbr test unit. In order to run the test manually, mmc6.img file
of size 12 MiB or greater is required in the same directory as u-boot.
Test also runs automatically via ./test/py/test.py tool.
Running mbr test is only supported in sandbox mode.

Signed-off-by: Alex Gendin <[email protected]>
[ And due to some further changes for testing ]
Signed-off-by: Simon Glass <[email protected]>
  • Loading branch information
Alexander Gendin authored and trini committed Oct 24, 2023
1 parent 9859edd commit 04291ee
Show file tree
Hide file tree
Showing 10 changed files with 506 additions and 4 deletions.
2 changes: 2 additions & 0 deletions arch/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ config SANDBOX
imply PHYSMEM
imply GENERATE_ACPI_TABLE
imply BINMAN
imply CMD_MBR
imply CMD_MMC

config SH
bool "SuperH architecture"
Expand Down
8 changes: 8 additions & 0 deletions arch/sandbox/dts/test.dts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
mmc3 = "/mmc3";
mmc4 = "/mmc4";
mmc5 = "/mmc5";
mmc6 = "/mmc6";
pci0 = &pci0;
pci1 = &pci1;
pci2 = &pci2;
Expand Down Expand Up @@ -1102,6 +1103,13 @@
filename = "mmc5.img";
};

/* This is used for mbr tests */
mmc6 {
status = "disabled";
compatible = "sandbox,mmc";
filename = "mmc6.img";
};

pch {
compatible = "sandbox,pch";
};
Expand Down
2 changes: 0 additions & 2 deletions configs/sandbox_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ CONFIG_CMD_IDE=y
CONFIG_CMD_I2C=y
CONFIG_CMD_LOADM=y
CONFIG_CMD_LSBLK=y
CONFIG_CMD_MBR=y
CONFIG_CMD_MMC=y
CONFIG_CMD_MUX=y
CONFIG_CMD_OSD=y
CONFIG_CMD_PCI=y
Expand Down
2 changes: 2 additions & 0 deletions configs/sandbox_flattree_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ CONFIG_CMD_MBR=y
CONFIG_CMD_MMC=y
CONFIG_CMD_OSD=y
CONFIG_CMD_PCI=y
CONFIG_CMD_READ=y
CONFIG_CMD_REMOTEPROC=y
CONFIG_CMD_SPI=y
CONFIG_CMD_TEMPERATURE=y
CONFIG_CMD_USB=y
CONFIG_CMD_WRITE=y
CONFIG_BOOTP_DNS2=y
CONFIG_CMD_TFTPPUT=y
CONFIG_CMD_TFTPSRV=y
Expand Down
2 changes: 1 addition & 1 deletion disk/part_dos.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ int layout_mbr_partitions(struct disk_partition *p, int count,
ext = &p[i];
}

if (count < 4)
if (count <= 4)
return 0;

if (!ext) {
Expand Down
1 change: 1 addition & 0 deletions include/test/suites.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ int do_ut_font(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
int do_ut_lib(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
int do_ut_loadm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
int do_ut_log(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]);
int do_ut_mbr(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
int do_ut_mem(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
int do_ut_optee(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
int do_ut_overlay(struct cmd_tbl *cmdtp, int flag, int argc,
Expand Down
1 change: 1 addition & 0 deletions test/cmd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ obj-$(CONFIG_CMD_PINMUX) += pinmux.o
obj-$(CONFIG_CMD_PWM) += pwm.o
obj-$(CONFIG_CMD_SEAMA) += seama.o
ifdef CONFIG_SANDBOX
obj-$(CONFIG_CMD_MBR) += mbr.o
obj-$(CONFIG_CMD_READ) += rw.o
obj-$(CONFIG_CMD_SETEXPR) += setexpr.o
obj-$(CONFIG_ARM_FFA_TRANSPORT) += armffa.o
Expand Down
Loading

0 comments on commit 04291ee

Please sign in to comment.