[uClinux-dev] Populating blkmem

Thomas Eschenbacher Thomas.Eschenbacher at gmx.de
Mon Mar 31 00:18:07 EST 2003

John Williams wrote:
 > [...]
 > The following snippet is at the end of my link script:
>        .blkmem ALIGN (4096) : {
>                __blkmem_0_start = . ;
>                *(.blkmem0)
>                __blkmem_0_end = . ;
>        } > RAM
> How do I populate the blkmem device or memory region to start with?  Do 
> I create a romfs image (with genromfs?) and cat it on the end of the 
> kernel image?  If so, how do the symbols blkmem_0_start and blkmem_0_end 
> get set after the fact?

Instead of appending it to the binary with "cat", I link it into the ELF
binary. This has the advantage that you can let your romfs be loaded
into RAM through gdb and that you have the possibility to link it at
a certain fixed memory location instead of just somewhere at the end
of the kernel.

I did the following:

1. added a section to the linker script (like you already have done)

2. add a rule to convert the romfs.img into romfs.o to the Makefile:

romfs.o: romfs.img
     ${OBJCOPY} \
     -v -I binary -O elf32-bigarm -B arm \
     --rename-section .data=.blkmem,alloc,load,readonly,data,contents \
     romfs.img romfs.o

(depending on your objcopy/binutils you might have to replace the
-B option and the --rename-section stuff, the above works with

3. add the romfs.o to the list of .o files, for example in the
    toplevel Makefile and link it together with the kernel.

Now your romfs is linked into the ELF file, you can verify that with
readelf, you should see your .blkmem section.

Thomas Eschenbacher <Thomas.Eschenbacher at gmx.de> [LANG=de_DE | en_EN]

More information about the uClinux-dev mailing list