cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
se17828
Adventurer
Adventurer
3,864 Views
Registered: ‎09-02-2010

custom bootloader

Hi, I am working with the SP605 board and i have written a custom bootloader that reads the compact flash and searches for a files called IMAGE.BIN (FAT32 filesystem) and copies it to the RAM (starting at 0x88000000 and so on). What I have done is compile the code I whant to execute (taking into account that it will be placed on the RAM by using the linker script editor) and then convert the ELF to BIN with the mb-objcopy tool.

The bootloader actually finds the file and loads it correctly to the RAM (I have opened the .bin files created with mb-objcopy with a hex editor and the contents match the ones of the RAM at address 0x88000000) the problem I am having is that once this is done I don't really know how to jump to the first instruction 0x88000000. Should i reset all 32 registers and set PC to 0x88000000 and if so, how do i do that? I have already tried with the "goto" instruction and any other that i could think of. 

I have found some bootloaders intended mainly for loading linux images that do the following:


typedef void (*void_fn)(char *);
char *cmdline = "console=ttyS0";

  

   LOAD PROGRAM TO MEMORY


kernel_start = (void_fn)XPAR_MCB_DDR3_MPMC_BASEADDR;
(*kernel_start)(cmdline);
cleanup_platform();

 

This does not work for me and I assume it is because it is though to be used with linux images. What should I do? when transforming the .elf to .bin i got some "insuficient space in device" which i solved by using a rather elaborate way of getting the image.bin image, those commands were:


./mb-objcopy -O binary -j .vectors.reset -j .vectors.sw_exception -j .vectors.interrupt -j .vectors.hw_exception IMAGE.elf IMAGE.BIN

./mb-objcopy -O binary -R .vectors.reset -R .vectors.sw_exception -R .vectors.interrupt -R .vectors.hw_exception IMAGE.elf IMAGE2.BIN

cat IMAGE.BIN >> IMAGE2.BIN

 

Please help me... It is very frustrating to have managed to read FAT32 files without any upper-level libraries and be stuck right at the end....

0 Kudos
3 Replies
se17828
Adventurer
Adventurer
3,836 Views
Registered: ‎09-02-2010

Please someone help me... Is it really that hard to make MicroBlaze jump to an specific memory address??

0 Kudos
cayla
Visitor
Visitor
3,819 Views
Registered: ‎03-23-2009

Hi,

 

i use this macro from Petalinux FS-boot for my bootloader

 

#define GO(addr) { ((void(*)(void))(addr))();  }

 

GO(XPAR_SDR_SDRAM_CUSTOM_B_MPMC_BASEADDR);

 

For passing command line arguments an DTB, you could check to

 

http://www.monstr.eu/wiki/doku.php?id=fdt:fdt

 

Regards

Stéphane

0 Kudos
jsdean
Visitor
Visitor
3,726 Views
Registered: ‎02-15-2010

You need to define an address like this:

 void (*laddr)();

Then you need to set the address (addr is a Xuint32):

laddr = (void (*)())addr;

Then you need to call:

 

(*laddr)();

 

 

It's weird but that's what works for me

0 Kudos