u-boot/mlo-ext2.patch

181 lines
4.9 KiB
Diff
Raw Normal View History

diff --git a/arch/arm/cpu/armv7/omap-common/spl_mmc.c b/arch/arm/cpu/armv7/omap-common/spl_mmc.c
index 6f5b43e..f369e47 100644
--- a/arch/arm/cpu/armv7/omap-common/spl_mmc.c
+++ b/arch/arm/cpu/armv7/omap-common/spl_mmc.c
@@ -83,6 +83,53 @@ end:
}
}
+static void mmc_load_image_ext2(struct mmc *mmc)
+{
+ s32 err;
+ struct image_header *header;
+ char *payloadname;
+ int filelen;
+
+ header = (struct image_header *)(CONFIG_SYS_TEXT_BASE -
+ sizeof(struct image_header));
+
+ err = ext2fs_set_blk_dev(&mmc->block_dev,
+ CONFIG_SYS_MMC_SD_FAT_BOOT_PARTITION);
+ if (!err) {
+ printf("spl: ext2fs register err - %d\n", err);
+ hang();
+ }
+
+ err = ext2fs_mount(0);
+ if (!err) {
+ printf("spl: ext2fs mount err - %d\n", err);
+ hang();
+ }
+
+
+ payloadname = "u-boot.bin";
+
+ filelen = err = ext2fs_open(payloadname);
+ if (err < 0) {
+ goto end;
+ }
+ err = ext2fs_read((u8 *)header, sizeof(struct image_header));
+ if (err <= 0) {
+ goto end;
+ }
+
+ spl_parse_image_header(header);
+
+ err = ext2fs_read((u8 *)spl_image.load_addr, filelen);
+
+end:
+ if (err <= 0) {
+ printf("spl: error reading image %s, err - %d\n",
+ payloadname, err);
+ hang();
+ }
+}
+
static void mmc_load_image_fat(struct mmc *mmc)
{
s32 err;
@@ -136,12 +183,14 @@ void spl_mmc_load_image(void)
hang();
}
boot_mode = omap_boot_mode();
+ boot_mode = MMCSD_MODE_FAT;
if (boot_mode == MMCSD_MODE_RAW) {
debug("boot mode - RAW\n");
mmc_load_image_raw(mmc);
} else if (boot_mode == MMCSD_MODE_FAT) {
debug("boot mode - FAT\n");
- mmc_load_image_fat(mmc);
+// mmc_load_image_fat(mmc);
+ mmc_load_image_ext2(mmc);
} else {
puts("spl: wrong MMC boot mode\n");
hang();
diff --git a/fs/ext2/ext2fs.c b/fs/ext2/ext2fs.c
index f621741..f38697c 100644
--- a/fs/ext2/ext2fs.c
+++ b/fs/ext2/ext2fs.c
@@ -25,9 +25,47 @@
#include <common.h>
#include <ext2fs.h>
-#include <malloc.h>
#include <asm/byteorder.h>
+#ifndef CONFIG_SPL_BUILD
+
+#include <malloc.h>
+
+#else
+
+/* compat stuff */
+
+void *free_buf;
+void *topmost_entry;
+int topmost_size;
+char heap[10240];
+
+static inline void *malloc(int size)
+{
+ void *r;
+ if (!free_buf)
+ free_buf = heap;
+ memset(free_buf, 0, size);
+ r = free_buf;
+ free_buf += size;
+ topmost_entry = r;
+ topmost_size = size;
+ return r;
+}
+
+static inline void free(void *p)
+{
+ if (p == topmost_entry) {
+ free_buf -= topmost_size;
+ topmost_entry = 0;
+ } else {
+ printf("leaked %d bytes\n", topmost_size);
+ }
+}
+
+#endif
+
+
extern int ext2fs_devread (int sector, int byte_offset, int byte_len,
char *buf);
diff --git a/include/configs/omap3_beagle.h b/include/configs/omap3_beagle.h
index ddeb414..0c46d5b 100644
--- a/include/configs/omap3_beagle.h
+++ b/include/configs/omap3_beagle.h
@@ -256,7 +256,7 @@
"root=${nandroot} " \
"rootfstype=${nandrootfstype}\0" \
"bootenv=uEnv.txt\0" \
- "loadbootenv=fatload mmc ${mmcdev} ${loadaddr} ${bootenv}\0" \
+ "loadbootenv=ext2load mmc ${mmcdev} ${loadaddr} ${bootenv}\0" \
"importbootenv=echo Importing environment from mmc ...; " \
"env import -t $loadaddr $filesize\0" \
"ramargs=setenv bootargs console=${console} " \
@@ -268,8 +268,8 @@
"omapdss.def_disp=${defaultdisplay} " \
"root=${ramroot} " \
"rootfstype=${ramrootfstype}\0" \
- "loadramdisk=fatload mmc ${mmcdev} ${rdaddr} ramdisk.gz\0" \
- "loaduimagefat=fatload mmc ${mmcdev} ${loadaddr} uImage\0" \
+ "loadramdisk=ext2load mmc ${mmcdev} ${rdaddr} ramdisk.gz\0" \
+ "loaduimagefat=ext2load mmc ${mmcdev} ${loadaddr} uImage\0" \
"loaduimage=ext2load mmc ${mmcdev}:2 ${loadaddr} /boot/uImage\0" \
"mmcboot=echo Booting from mmc ...; " \
"run mmcargs; " \
diff --git a/include/configs/omap4_common.h b/include/configs/omap4_common.h
index a989721..00578fe 100644
--- a/include/configs/omap4_common.h
+++ b/include/configs/omap4_common.h
@@ -160,10 +160,10 @@
"vram=${vram} " \
"root=${mmcroot} " \
"rootfstype=${mmcrootfstype}\0" \
- "loadbootscript=fatload mmc ${mmcdev} ${loadaddr} boot.scr\0" \
+ "loadbootscript=ext2load mmc ${mmcdev} ${loadaddr} boot.scr\0" \
"bootscript=echo Running bootscript from mmc${mmcdev} ...; " \
"source ${loadaddr}\0" \
- "loaduimage=fatload mmc ${mmcdev} ${loadaddr} uImage\0" \
+ "loaduimage=ext2load mmc ${mmcdev} ${loadaddr} uImage\0" \
"mmcboot=echo Booting from mmc${mmcdev} ...; " \
"run mmcargs; " \
"bootm ${loadaddr}\0" \
diff --git a/spl/Makefile b/spl/Makefile
index ea7d475..6abfd7e 100644
--- a/spl/Makefile
+++ b/spl/Makefile
@@ -51,6 +51,7 @@ LIBS-$(CONFIG_SPL_SERIAL_SUPPORT) += drivers/serial/libserial.o
LIBS-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += drivers/mtd/spi/libspi_flash.o
LIBS-$(CONFIG_SPL_SPI_SUPPORT) += drivers/spi/libspi.o
LIBS-$(CONFIG_SPL_FAT_SUPPORT) += fs/fat/libfat.o
+LIBS-$(CONFIG_SPL_FAT_SUPPORT) += fs/ext2/libext2fs.o
LIBS-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/libgeneric.o
LIBS-$(CONFIG_SPL_POWER_SUPPORT) += drivers/power/libpower.o
LIBS-$(CONFIG_SPL_NAND_SUPPORT) += drivers/mtd/nand/libnand.o