[PATCH] [RFC] mtd/uclinux: support ROM and allow passing the base address

Uwe Kleine-König u.kleine-koenig at pengutronix.de
Fri Oct 12 03:22:21 EDT 2012


Hello,

On Fri, Oct 12, 2012 at 03:57:59PM +1000, Greg Ungerer wrote:
> >so to be clear, Uwe's patch hasn't been picked up by anyone yet so we
> >can get it fixed first ?
ok, so for blackfin uclinux_ram_map must not be static because it is
used in arch/blackfin/kernel/setup.c. If I tried to introduce such code
for an ARM platform people would run away scared maybe after telling me
I should fix my boot loader.  I really don't know the situation on
blackfin, but this really has potential for generalisation. But I don't
even know if you have/need a boot loader at all there. Here is what I
found quickly:

diff --git a/arch/blackfin/kernel/setup.c b/arch/blackfin/kernel/setup.c
index fb96e60..24478a2 100644
--- a/arch/blackfin/kernel/setup.c
+++ b/arch/blackfin/kernel/setup.c
@@ -583,7 +583,7 @@ static __init void memory_setup(void)
 
 #ifdef CONFIG_MPU
 	/* Round up to multiple of 4MB */
-	memory_start = (_ramstart + 0x3fffff) & ~0x3fffff;
+	memory_start = ALIGN(_ramstart, 0x400000);
 #else
 	memory_start = PAGE_ALIGN(_ramstart);
 #endif
@@ -593,6 +593,13 @@ static __init void memory_setup(void)
 	memory_mtd_end = memory_end;
 
 	mtd_phys = _ramstart;
+
+	/*
+	 * Since the default MTD_UCLINUX has no magic number, we just blindly
+	 * read 8 past the end of the kernel's image, and look at it.
+	 * When no image is attached, mtd_size is set to a random number.
+	 * So do some basic sanity checks before operating on things.
+	 */
 	mtd_size = PAGE_ALIGN(*((unsigned long *)(mtd_phys + 8)));
 
 # if defined(CONFIG_EXT2_FS) || defined(CONFIG_EXT3_FS)
@@ -621,11 +628,6 @@ static __init void memory_setup(void)
 	}
 # endif				/* CONFIG_ROMFS_FS */
 
-	/* Since the default MTD_UCLINUX has no magic number, we just blindly
-	 * read 8 past the end of the kernel's image, and look at it.
-	 * When no image is attached, mtd_size is set to a random number
-	 * Do some basic sanity checks before operating on things
-	 */
 	if (mtd_size == 0 || memory_end <= mtd_size) {
 		pr_emerg("Could not find valid ram mtd attached.\n");
 	} else {

If you had a boot loader, my patch (making the location of the uclinux
map settable by a kernel parameter) should be a move in the right
direction for you, too.

I will fix my patch keeping uclinux_ram_map non-static and resend.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |



More information about the linux-mtd mailing list