[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [microblaze-uclinux] microblaze: Fix compiled-in rootfs
Steve Magnani wrote:
> Michal,
>
> The patch doesn't work. I couldn't get it to apply so I modified the code
> by hand. With the patch in place, the cramfs isn't detected anymore:
>
> Found romfs @ 0x20248000 (0x00000000)
> #### klimit 2025d000 ####
>
> If I change __bss_start to __init_end the patch works as far as it goes;
> without the change to init.c, the cramfs still gets corrupted.
>
> Found romfs @ 0x20247204 (0x0023e000)
> #### klimit 2025d000 ####
> Moved 0x0023e000 bytes from 0x20247204 to 0x2025c914
> New klimit: 0x2049b000
I haven't fixed cramfs. I just looked at compiled-in romfs rootfs.
Your romfs.img starts at __init_end and my at __bss_start - I understand that this can't work
together.
John: I tested this issue by hand - below is my explanation
question is where should be placed compiled-in image? I think that in bss section as was in past
and should be now too.
Script which is below(in my previous email - I extract it from petalinux) add romfs.img to
__bss_start and create image.elf and I did
microblaze-uclinux-objcopy -O binary image.elf image.bin
which takes romfs at __bss_start.
And I checked it in petalinux and there is one other secret step which add romfs.img to __init_end.
The main thing is that image.bin is not generated from image.elf which is the same for me too
but it is just cat command below which takes romfs at the end of linux.bin which should be __init_end.
cat linux.bin romfs.img > image.bin
(vendor/PetaLogix/common/common.mak: line 403)
Anyway in pre MMU version was .init.ramfs section aligned with the same boundary as bss section.
This mean that symbols __init_end and __bss_start was the same.
If you look at arch/microblaze/kernel/vmlinux.lds.S you can see there that comment.
167: /* FIXME this can break initramfs for MMU */
168: /* . = ALIGN(4096);*//* Pad init.ramfs up to page boundary, so
169: that __init_end == __bss_start. This will
170: make image.elf consistent with the image.bin */
From petalinux side we have got inconsistence between image.elf and linux.bin which were caused my
mmu merge to petalinux. That's why for you (Steve) work __init_end instead of __bss_start.
bss section is aligned to 4k. That means that image will be for __bss_start instance in the worst
case longer for 4k.
Here is my confirmation:
Image Name: kernel s rootfs __bss_start
Created: Wed May 20 08:56:35 2009
Image Type: MicroBlaze Linux Kernel Image (uncompressed)
Data Size: 4352000 Bytes = 4250.00 kB = 4.15 MB
Load Address: 90000000
Entry Point: 90000000
Image Name: kernel s rootfs __init_end
Created: Wed May 20 08:56:36 2009
Image Type: MicroBlaze Linux Kernel Image (uncompressed)
Data Size: 4347908 Bytes = 4246.00 kB = 4.15 MB
Load Address: 90000000
Entry Point: 90000000
There are some solution how to solve it.
1. Check both location __init_end first
2. in petalinux generate image.bin from image.elf and remove that cat command from common.mak
IMHO we should use the first version. I paste patch for it below + part of log for both cases.
Thanks,
Michal
init_end
## Transferring control to Linux (at address 90000000), 0x00000000 ramdisk 0x00000000, FDT 0x90780000...
early_printk_console is enabled at 0x84000000
Ramdisk addr 0x00000000, FDT 0x90780000
Found romfs @ 0x90271004 (0x001b5000)
#### klimit 902c2000 ####
Moved 0x001b5000 bytes from 0x90271004 to 0x902c1b28
New klimit: 0x90477000
Found FDT at 0x90780000
bss_start
## Transferring control to Linux (at address 90000000), 0x00000000 ramdisk 0x00000000, FDT 0x90780000...
early_printk_console is enabled at 0x84000000
Ramdisk addr 0x00000000, FDT 0x90780000
Found romfs @ 0x90272000 (0x001b5000)
#### klimit 902c2000 ####
Moved 0x001b5000 bytes from 0x90272000 to 0x902c1b28
New klimit: 0x90477000
Found FDT at 0x90780000
diff --git a/arch/microblaze/kernel/setup.c b/arch/microblaze/kernel/setup.c
index eb6b417..6eacd62 100644
--- a/arch/microblaze/kernel/setup.c
+++ b/arch/microblaze/kernel/setup.c
@@ -101,6 +101,27 @@ void __init machine_early_init(const char *cmdline, unsigned int ram,
unsigned int fdt)
{
unsigned long *src, *dst = (unsigned long *)0x0;
+#ifdef CONFIG_MTD_UCLINUX
+ int romfs_size;
+ unsigned int romfs_base;
+ char *old_klimit = klimit;
+
+ /* Move ROMFS out of BSS before clearing it */
+ romfs_base = (ram ? ram : (unsigned int)&__init_end);
+ /* if CONFIG_MTD_UCLINUX_EBSS is defined, assume ROMFS is at the
+ * end of kernel, which is ROMFS_LOCATION defined above.
+ */
+ romfs_size = PAGE_ALIGN(get_romfs_len((unsigned *)romfs_base));
+ if (!romfs_size) {
+ romfs_base = (unsigned int)&__bss_start;
+ romfs_size = PAGE_ALIGN(get_romfs_len((unsigned *)romfs_base));
+ }
+
+ if (romfs_size > 0) {
+ memmove(&_ebss, (int *)romfs_base, romfs_size);
+ klimit += PAGE_ALIGN(romfs_size);
+ }
+#endif
/* clearing bss section */
memset(__bss_start, 0, __bss_stop-__bss_start);
@@ -126,27 +147,15 @@ void __init machine_early_init(const char *cmdline, unsigned int ram,
printk(KERN_NOTICE "Found FDT at 0x%08x\n", fdt);
#ifdef CONFIG_MTD_UCLINUX
- {
- int size;
- unsigned int romfs_base;
- romfs_base = (ram ? ram : (unsigned int)&__init_end);
- /* if CONFIG_MTD_UCLINUX_EBSS is defined, assume ROMFS is at the
- * end of kernel, which is ROMFS_LOCATION defined above. */
- size = PAGE_ALIGN(get_romfs_len((unsigned *)romfs_base));
- early_printk("Found romfs @ 0x%08x (0x%08x)\n",
- romfs_base, size);
- early_printk("#### klimit %p ####\n", klimit);
- BUG_ON(size < 0); /* What else can we do? */
-
- /* Use memmove to handle likely case of memory overlap */
- early_printk("Moving 0x%08x bytes from 0x%08x to 0x%08x\n",
- size, romfs_base, (unsigned)&_ebss);
- memmove(&_ebss, (int *)romfs_base, size);
-
- /* update klimit */
- klimit += PAGE_ALIGN(size);
- early_printk("New klimit: 0x%08x\n", (unsigned)klimit);
- }
+ early_printk("Found romfs @ 0x%08x (0x%08x)\n",
+ romfs_base, romfs_size);
+ early_printk("#### klimit %p ####\n", old_klimit);
+ BUG_ON(romfs_size < 0); /* What else can we do? */
+
+ early_printk("Moved 0x%08x bytes from 0x%08x to 0x%08x\n",
+ romfs_size, romfs_base, (unsigned)&_ebss);
+
+ early_printk("New klimit: 0x%08x\n", (unsigned)klimit);
#endif
for (src = __ivt_start; src < __ivt_end; src++, dst++)
>
> Steve
>
> -----Original Message-----
> From: Michal Simek <monstr@xxxxxxxxx>
> To: microblaze-uclinux@xxxxxxxxxxxxxx
> Cc: steve@xxxxxxxxxxxxxxx, john.williams@xxxxxxxxxxxxx
> Date: Tue, 19 May 2009 14:55:02 +0200
> Subject: [microblaze-uclinux] microblaze: Fix compiled-in rootfs
>
>> Hi All,
>>
>> I looked at Steve's patches again and I did some tests with it.
>> I am not sure (please correct me if I am wrong) but rootfs should
>> be placed to BSS and then is this section zeroed.
>>
>> In Steve's patches (or in latest version) was for this case used
>> __init_end symbol but we should use bss section start (__bss_start
>> symbol).
>> For my case these two symbols don't match. This is caused by
>> aligned bss section.
>>
>> [monstr@monstr linux-monstr.eu-commit]$ cat System.map | grep
>> "__init_end$"
>> 90271004 A __init_end
>> [monstr@monstr linux-monstr.eu-commit]$ cat System.map | grep bss_start
>> 90272000 B __bss_start
>>
>> Here is part of my script for generation compiled-in rootfs
>> inside vmlinux and then create U-BOOT file format. (romfs.img is from
>> petalinux and is romfs)
>>
>> echo $CROSS_COMPILE
>> BSS=`${CROSS_COMPILE}objdump --headers vmlinux | grep "\.bss"`;
>> ADDR=`set -- ${BSS} ; echo 0x${5}`;
>> echo ${ADDR}
>>
>> [ ! -f romfs.img ] && exit -1
>> ${CROSS_COMPILE}objcopy --add-section=.romfs=romfs.img \
>> --adjust-section-vma=.romfs=${ADDR} --no-adjust-warnings \
>> --set-section-flags=.romfs=alloc,load,data \
>> vmlinux linux.elf
>> ${CROSS_COMPILE}objcopy -O binary linux.elf linux.bin
>> mkimage -A microblaze -O linux -T kernel -C none -a $addr -e $addr -n
>> "kernel s rootfs" -d linux.bin /tftpboot/image2.ub
>>
>> Steve: Could you please tested it? If is OK, I'll add your sign-off-by
>> line.
>>
>>
>> Below is my bootlog for fixes-for-linus branch + this patch.
>>
>> And on this site you can find my log of initramfs case.
>> http://monstr.eu/wiki/doku.php?id=fdt:fdt:logs:2.6.30-rc5-nommu-initram
>> fs
>>
>> I'll add my logs to that site too.
>>
>>
>> Thanks,
>> Michal
>>
>>
>> SDRAM :
>> Icache:OK
>> Dcache:OK
>> U-Boot Start:0x9ffc0000
>> FLASH: 32 MB
>> MAC:00:E0:0C:00:00:FD
>> eth0: Xilinx XPS LocalLink Tri-Mode Ether MAC #0 at 0x81C00000.
>> Unsupported mode
>> U-Boot-mONStR> run b
>> TFTP from server 192.168.0.102; our IP address is 192.168.0.3
>> Filename 'image2.ub'.
>> Load address: 0x90800000
>> Loading: 100BASE-T/FD
>> #################################################################
>>
>> #################################################################
>>
>> #################################################################
>>
>> #################################################################
>> #####################################
>> done
>> Bytes transferred = 4352064 (426840 hex)
>> TFTP from server 192.168.0.102; our IP address is 192.168.0.3
>> Filename 'system.dtb'.
>> Load address: 0x90780000
>> Loading: 100BASE-T/FD
>> #
>> done
>> Bytes transferred = 9121 (23a1 hex)
>> ## Booting kernel from Legacy Image at 90800000 ...
>> Image Name: kernel s rootfs
>> Image Type: MicroBlaze Linux Kernel Image (uncompressed)
>> Data Size: 4352000 Bytes = 4.2 MB
>> Load Address: 90000000
>> Entry Point: 90000000
>> Verifying Checksum ... OK
>> Loading Kernel Image ... OK
>> OK
>> ## Flattened Device Tree blob at 90780000
>> Booting using the fdt blob at 0x90780000
>> ## Transferring control to Linux (at address 90000000), 0x00000000
>> ramdisk 0x00000000, FDT 0x90780000...
>> early_printk_console is enabled at 0x84000000
>> Ramdisk addr 0x00000000, FDT 0x90780000
>> Found romfs @ 0x90272000 (0x001b5000)
>> #### klimit 902c2000 ####
>> Moved 0x001b5000 bytes from 0x90272000 to 0x902c1b28
>> New klimit: 0x90477000
>> Found FDT at 0x90780000
>> Linux version 2.6.30-rc6-00348-g7b7210d-dirty (monstr@xxxxxxxxx) (gcc
>> version 4.1.2) #15 Tue May 19 14:30:36 CEST 2009
>> setup_cpuinfo: initialising
>> setup_cpuinfo: Using full CPU PVR support
>> setup_memory: Main mem: 0x90000000-0xa0000000, size 0x10000000
>> setup_memory: kernel addr=0x90000000-0x90477000 size=0x00477000
>> setup_memory: max_mapnr: 0x10000
>> setup_memory: min_low_pfn: 0x90000
>> setup_memory: max_low_pfn: 0xa0000
>> On node 0 totalpages: 65536
>> free_area_init_node: node 0, pgdat 90255d64, node_mem_map 90477000
>> Normal zone: 512 pages used for memmap
>> Normal zone: 0 pages reserved
>> Normal zone: 65024 pages, LIFO batch:0
>> Built 1 zonelists in Zone order, mobility grouping on. Total pages:
>> 65024
>> Kernel command line: console=ttyUL0,115200 highres=on
>> root=/dev/mtdblock0
>> NR_IRQS:32
>> xlnx,xps-intc-1.00.a #0 at 0x81800000, num_irq=9, edge=0x100
>> PID hash table entries: 1024 (order: 10, 4096 bytes)
>> xlnx,xps-timer-1.00.a #0 at 0x83c00000, irq=3
>> Heartbeat GPIO at 0x81400000
>> microblaze_timer_set_mode: shutdown
>> microblaze_timer_set_mode: periodic
>> Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)
>> Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
>> Memory: 255324k/262144k available
>> ODEBUG: 3 of 3 active objects replaced
>> ODEBUG: selftest passed
>> Calibrating delay loop... 61.03 BogoMIPS (lpj=305152)
>> Mount-cache hash table entries: 512
>> net_namespace: 544 bytes
>> NET: Registered protocol family 16
>> bio: create slab <bio-0> at 0
>> microblaze_timer_set_mode: oneshot
>> Switched to high resolution mode on CPU 0
>> NET: Registered protocol family 2
>> IP route cache hash table entries: 2048 (order: 1, 8192 bytes)
>> TCP established hash table entries: 8192 (order: 4, 65536 bytes)
>> TCP bind hash table entries: 8192 (order: 3, 32768 bytes)
>> TCP: Hash tables configured (established 8192 bind 8192)
>> TCP reno registered
>> NET: Registered protocol family 1
>> ROMFS MTD (C) 2007 Red Hat, Inc.
>> msgmni has been set to 498
>> io scheduler noop registered
>> io scheduler anticipatory registered
>> io scheduler deadline registered
>> io scheduler cfq registered (default)
>> 84000000.serial: ttyUL0 at MMIO 0x84000003 (irq = 8) is a uartlite
>> console [ttyUL0] enabled
>> brd: module loaded
>> nbd: registered device at major 43
>> uclinux[mtd]: RAM probe address=0x902c1b28 size=0x1b5000
>> Creating 1 MTD partitions on "RAM":
>> 0x000000000000-0x0000001b5000 : "ROMfs"
>> TCP cubic registered
>> NET: Registered protocol family 17
>> RPC: Registered udp transport module.
>> RPC: Registered tcp transport module.
>> VFS: Mounted root (romfs filesystem) readonly on device 31:0.
>> Freeing unused kernel memory: 92k freed
>> Mounting proc:
>> Mounting var:
>> Populating /var:
>> Running local start scripts.
>> Mounting /etc/config:
>> Populating /etc/config:
>> flatfsd: Nonexistent or bad flatfs (-48), creating new one...
>> flatfsd: Failed to write flatfs (-48): No such device
>> flatfsd: Created 5 configuration files (185 bytes)
>> Mounting sysfs:
>> Setting hostname:
>> Setting up interface lo:
>> Setting up interface eth0:
>> SIOCSIFADDR: No such device
>> Starting portmap:
>> Starting thttpd:
>>
>> uclinux login:
>>
>>
>> or you can separate kernel and rootfs and it works on similar base
>>
>>
>> SDRAM :
>> Icache:OK
>> Dcache:OK
>> U-Boot Start:0x9ffc0000
>> FLASH: 32 MB
>> MAC:00:E0:0C:00:00:FD
>> eth0: Xilinx XPS LocalLink Tri-Mode Ether MAC #0 at 0x81C00000.
>> Unsupported mode
>> U-Boot-mONStR> run ml505
>> TFTP from server 192.168.0.102; our IP address is 192.168.0.3
>> Filename 'image.ub'.
>> Load address: 0x90800000
>> Loading: 100BASE-T/FD
>> #################################################################
>>
>> #################################################################
>> #############################################
>> done
>> Bytes transferred = 2560068 (271044 hex)
>> TFTP from server 192.168.0.102; our IP address is 192.168.0.3
>> Filename 'system.dtb'.
>> Load address: 0x90780000
>> Loading: 100BASE-T/FD
>> #
>> done
>> Bytes transferred = 9121 (23a1 hex)
>> TFTP from server 192.168.0.102; our IP address is 192.168.0.3
>> Filename 'romfs.ub'.
>> Load address: 0x90c80000
>> Loading: 100BASE-T/FD
>> #################################################################
>> #########################################################
>> done
>> Bytes transferred = 1787968 (1b4840 hex)
>> ## Booting kernel from Legacy Image at 90800000 ...
>> Image Name: kernel bez FS
>> Image Type: MicroBlaze Linux Kernel Image (uncompressed)
>> Data Size: 2560004 Bytes = 2.4 MB
>> Load Address: 90000000
>> Entry Point: 90000000
>> Verifying Checksum ... OK
>> ## Loading init Ramdisk from Legacy Image at 90c80000 ...
>> Image Name: fs v no network
>> Image Type: MicroBlaze Linux RAMDisk Image (uncompressed)
>> Data Size: 1787904 Bytes = 1.7 MB
>> Load Address: 00000000
>> Entry Point: 00000000
>> Verifying Checksum ... OK
>> Loading Kernel Image ... OK
>> OK
>> ## Flattened Device Tree blob at 90780000
>> Booting using the fdt blob at 0x90780000
>> ## Loading init Ramdisk from Legacy Image at 90c80000 ...
>> Image Name: fs v no network
>> Image Type: MicroBlaze Linux RAMDisk Image (uncompressed)
>> Data Size: 1787904 Bytes = 1.7 MB
>> Load Address: 00000000
>> Entry Point: 00000000
>> Verifying Checksum ... OK
>> ## Transferring control to Linux (at address 90000000), 0x00000000
>> ramdisk 0x90c80040, FDT 0x90780000...
>> early_printk_console is enabled at 0x84000000
>> Ramdisk addr 0x90c80040, FDT 0x90780000
>> Found romfs @ 0x90c80040 (0x001b5000)
>> #### klimit 902c2000 ####
>> Moved 0x001b5000 bytes from 0x90c80040 to 0x902c1b28
>> New klimit: 0x90477000
>> Found FDT at 0x90780000
>> Linux version 2.6.30-rc6-00348-g7b7210d-dirty (monstr@xxxxxxxxx) (gcc
>> version 4.1.2) #15 Tue May 19 14:30:36 CEST 2009
>> setup_cpuinfo: initialising
>> setup_cpuinfo: Using full CPU PVR support
>> setup_memory: Main mem: 0x90000000-0xa0000000, size 0x10000000
>> setup_memory: kernel addr=0x90000000-0x90477000 size=0x00477000
>> setup_memory: max_mapnr: 0x10000
>> setup_memory: min_low_pfn: 0x90000
>> setup_memory: max_low_pfn: 0xa0000
>> On node 0 totalpages: 65536
>> free_area_init_node: node 0, pgdat 90255d64, node_mem_map 90477000
>> Normal zone: 512 pages used for memmap
>> Normal zone: 0 pages reserved
>> Normal zone: 65024 pages, LIFO batch:0
>> Built 1 zonelists in Zone order, mobility grouping on. Total pages:
>> 65024
>> Kernel command line: console=ttyUL0,115200 highres=on
>> root=/dev/mtdblock0
>> NR_IRQS:32
>> xlnx,xps-intc-1.00.a #0 at 0x81800000, num_irq=9, edge=0x100
>> PID hash table entries: 1024 (order: 10, 4096 bytes)
>> xlnx,xps-timer-1.00.a #0 at 0x83c00000, irq=3
>> Heartbeat GPIO at 0x81400000
>> microblaze_timer_set_mode: shutdown
>> microblaze_timer_set_mode: periodic
>> Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)
>> Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
>> Memory: 255324k/262144k available
>> ODEBUG: 3 of 3 active objects replaced
>> ODEBUG: selftest passed
>> Calibrating delay loop... 61.03 BogoMIPS (lpj=305152)
>> Mount-cache hash table entries: 512
>> net_namespace: 544 bytes
>> NET: Registered protocol family 16
>> bio: create slab <bio-0> at 0
>> microblaze_timer_set_mode: oneshot
>> Switched to high resolution mode on CPU 0
>> NET: Registered protocol family 2
>> IP route cache hash table entries: 2048 (order: 1, 8192 bytes)
>> TCP established hash table entries: 8192 (order: 4, 65536 bytes)
>> TCP bind hash table entries: 8192 (order: 3, 32768 bytes)
>> TCP: Hash tables configured (established 8192 bind 8192)
>> TCP reno registered
>> NET: Registered protocol family 1
>> ROMFS MTD (C) 2007 Red Hat, Inc.
>> msgmni has been set to 498
>> io scheduler noop registered
>> io scheduler anticipatory registered
>> io scheduler deadline registered
>> io scheduler cfq registered (default)
>> 84000000.serial: ttyUL0 at MMIO 0x84000003 (irq = 8) is a uartlite
>> console [ttyUL0] enabled
>> brd: module loaded
>> nbd: registered device at major 43
>> uclinux[mtd]: RAM probe address=0x902c1b28 size=0x1b5000
>> Creating 1 MTD partitions on "RAM":
>> 0x000000000000-0x0000001b5000 : "ROMfs"
>> TCP cubic registered
>> NET: Registered protocol family 17
>> RPC: Registered udp transport module.
>> RPC: Registered tcp transport module.
>> VFS: Mounted root (romfs filesystem) readonly on device 31:0.
>> Freeing unused kernel memory: 92k freed
>> Mounting proc:
>> Mounting var:
>> Populating /var:
>> Running local start scripts.
>> Mounting /etc/config:
>> Populating /etc/config:
>> flatfsd: Nonexistent or bad flatfs (-48), creating new one...
>> flatfsd: Failed to write flatfs (-48): No such device
>> flatfsd: Created 5 configuration files (185 bytes)
>> Mounting sysfs:
>> Setting hostname:
>> Setting up interface lo:
>> Setting up interface eth0:
>> SIOCSIFADDR: No such device
>> Starting portmap:
>> Starting thttpd:
>>
>> uclinux login:
>>
>>
>>
>>
>>
>> ___________________________
>> microblaze-uclinux mailing list
>> microblaze-uclinux@xxxxxxxxxxxxxx
>> Project Home Page : http://www.itee.uq.edu.au/~jwilliams/mblaze-uclinux
>> Mailing List Archive :
>> http://www.itee.uq.edu.au/~listarch/microblaze-uclinux/
>>
>
>
> ___________________________
> microblaze-uclinux mailing list
> microblaze-uclinux@xxxxxxxxxxxxxx
> Project Home Page : http://www.itee.uq.edu.au/~jwilliams/mblaze-uclinux
> Mailing List Archive : http://www.itee.uq.edu.au/~listarch/microblaze-uclinux/
>
>
--
Michal Simek, Ing. (M.Eng)
PetaLogix - Linux Solutions for a Reconfigurable World
w: www.petalogix.com p: +61-7-30090663,+42-0-721842854 f: +61-7-30090663
___________________________
microblaze-uclinux mailing list
microblaze-uclinux@xxxxxxxxxxxxxx
Project Home Page : http://www.itee.uq.edu.au/~jwilliams/mblaze-uclinux
Mailing List Archive : http://www.itee.uq.edu.au/~listarch/microblaze-uclinux/