All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christopher Preschern <christopher.preschern@tugraz.at>
To: u-boot@lists.denx.de
Subject: [U-Boot] Problems with Linker Symbols to make HAB on i.MX28 work
Date: Fri, 26 Apr 2013 07:46:44 +0200	[thread overview]
Message-ID: <517A14C4.5080704@tugraz.at> (raw)

Hi,

I want to make High Assurance Boot (HAB) for the Freescale i.MX28 with 
U-Boot 04/2012 work. To do that I have to link an Image Vector Table 
(IVT, consists of some boot image addresses which I insert by using 
linker symbols in the C-code) to the u-boot binary. My problem is, that 
the linker symbols are not inserted into the binary correctly (they 
always have the value 0).

Here is my code - I include the following to board/denx/m28evk/m28evk.c

/*IVT DEFINITION */
#define BASE_ADDRESS 0x00000100
extern unsigned int __hab_uboot_data; // defined in u-boot.lds
extern int __hab_uboot_end;           // defined in u-boot.lds
extern void* _start;
struct my_ivt {                       // IVT structur according to
     uint32_t header;                  // some Freescale manuals
     uint32_t *entry;
     uint32_t reserved1;
     uint32_t *dcd;
     uint32_t *boot_data;
     uint32_t *self;
     uint32_t *csf;
     uint32_t reserved2;
     uint32_t img_len;
};
const struct my_ivt input_ivt 
__attribute__((section(".ivt"),aligned(4))) = {
     0x402000d1                       //header
     (uint32_t*) (&_start),           //entry
     0,                               //reserved
     NULL,                            //DCD
     NULL,                            //boot data
     (uint32_t*) (&input_ivt),        //IVT address
     (uint32_t*) (&__hab_uboot_data), //CSF
     0,                               //reserved
     (uint32_t) (&__hab_uboot_end) - BASE_ADDRESS   //image length
};
/*END OF IVT DEFINITION*/

and I modify the linker file (arch/arm/cpu/u-boot.lds)

/*INSERTED RIGHT BEFORE THE BSS SECTION */
   . = ALIGN(4);
   __uboot_ivt = .;
   .ivt : { *(.ivt) }
   __hab_uboot_data = .;
   . = . + 0x2000;
   __hab_uboot_end = .;

With this code, the IVT should be written to the end of u-boot.bin. 
When looking at it with a hex-Editor I do see the IVT (e.g. the 
hard-coded header is there - in little-endian), but the values for the 
linker symbols (e.g. __hab_uboot_data) are 0.
D1002040 00010040 00000000 00000000
00000000 00900640 00000000 00000000
00FFFFFF

However, I think that the linker symbols are correctly included in the 
C-source, because the compiler does not complain that he cannot find the 
extern __hab_uboot_data variable and in all the forums/tutorials I 
googled I found the syntax I use. Also if I put
   printf("HAB-DEBUG: %x \n",(uint32_t)(&__hab_uboot_end));
somewhere in the code (e.g. into the board_init() in m28evk.c), I do get 
an address which is not 0 (although it is also not the address I expect 
? I get the expected address + the U-Boot relocation offset)

I appreciate any kind of help very much!

Best regards,
Christopher

                 reply	other threads:[~2013-04-26  5:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=517A14C4.5080704@tugraz.at \
    --to=christopher.preschern@tugraz.at \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.