cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Visitor
Visitor
276 Views
Registered: ‎07-30-2020

Position independent code in Microblaze

Hi.

I'm building a Microblaze cluster on Versal device, where I'll have 4 similar Microblaze cores that will run the same firmware.
I want to be able to generate a single firmware for all of them, one that is loaded to a different location in memory.

I thought about using -FPIC option, which is something I used in shared libraries, but never as a complete firmware.

Did anyone did anything similar ?

 

Thanks,

Ramon

0 Kudos
Reply
1 Reply
Moderator
Moderator
35 Views
Registered: ‎09-12-2007

Yes, you can use the fPIC on Microblaze. I think it might even be added by default?

 

Main other thing is that you update the C_BASE_VECTORS in the Microblaze configuration in the BD.

This tell the Microblaze where to fetch its instructions from upon coming out of reset. This is also used to generate your linker script in Vitis.

 

You mentioned Versal, will you be planning on using the DDR via the NoC? If so, you will need to

have a bootloop here if you want to debug in Vitis. Or, you will need to hold the Microblaze in reset until there is valid instructions at the C_BASE_VECTORS address.

If you enable the discrete pins in the Microblaze configuration in the BD you will set the reset_mode, and the wakeup pins.

You can set the reset_mode to 01, which you can use a constant IP to do this for you. You can then control the wakeup via the GPIO pins on the CIPS.

reset_mode.PNG

https://www.xilinx.com/support/documentation/sw_manuals/xilinx2020_2/ug984-vivado-microblaze-ref.pdf

 

If you want to add the bootloop, then navigate to the .runs_0/impl_1 folder in the Vivado project directory and open the BIF file and append the content below (inside the last }):

 

 image
  {
   name = mb_bootloder
   id = 0xdeadbee
   partition
   {
    id = 0x11
    type = cdo
    file = gen_files/mb_bootloop_le.elf
   }
 }
 

 

Note: the bootloop will be specific to your C_BASE_VECTORS address.

Then use the command below to regenerate the PDI file:

  • bootgen -arch versal -image design_1_wrapper.bif -w -o design_1_wrapper.pdi
  • File -> Export Hardware (Include Device Image)
  • Tools -> Launch Vitis IDE

Then the XSA file will have the bootloops for each microblaze placed in the correct location in memory. Obviously, when you are finished you can replace this with your own 

firmware.