Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
20 years ago

Program entry point

hello

we are using nios ii 5.1. we are had create a custom bootloader for remote firmware updates via custom interface (no jtag cable will be available on fw update process). previosly, in nios1, there was the bootloadder, but as we are know, altera does not recomend to use the legacy components so we are had created custom bootloader. boot loader must to know entry point of main program.

but, after compiling a program for memory, that differ to boot address, compiler does NOT make any code at offset address 0 for target memory. hex file starts from exception offset address 0x20. but program entry point is somewhere in targed memory and that address included in resilting hex file as 0x05 record type.

why it doesnot make from offset address 0?

and is it possible to change some setting to make the compiler to generate entry point at address 0?

3 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi m_fox,

    > why it doesnot make from offset address 0?

    Because your .text section is not in the same memory as your reset address.

    Roughly speaking, if your .text _is_ in the same memory as your reset address,

    system.h defines ALT_NO_BOOTLOADER. This in turn causes the reset code to

    be included and placed in the .entry section. It goes like this:

    -- The symbol "__reset" (and reset code) is located in section .entry.

    -- The section .entry is located in the memory block named "reset".

    -- The memory block "reset" has its origin at the system reset address.

    > and is it possible to change some setting to make the compiler to generate

    > entry point at address 0?

    There are a bunch of ways you could do this. I would probably just leave all

    the automated stuff alone and add a small assembly module that jumps

    to _start, that's in section .entry. Then just use objcopy to create the binary ...

    so you don't have to create custom linker scripts, change syslib properties,

    etc. etc.

    Regards,

    --Scott
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    > I would probably just leave all the automated stuff alone and add a small

    > assembly module ....

    Actually, I take that back 8-P ... you can achieve the same by simply adding

    ALT_NO_BOOTLOADER to your system library compiler preprocessor defs. Then

    when you use objcopy to create the binary, just adjust the .entry section VMA.

    Regards,

    --Scott
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi

    I'm new to the Nios processor and I'm trying to understand the workings of the boot process.

    If I understand you correctly, then this is very interesting information...

    So - if I have a situation where there is an internal ROM containing a bootloader that can receive an application from an external device (port or other memory) to be run from SDRAM... then the easiest way to prepare the application to download or load, is to add ALT_NO_BOOTLOADER to the system library compiler preprocessor definitions and then use objcopy to move the .entry to a more useful place than the reset vector address... ?

    Could you please give an example of the commandline used to do this relocation of the .entry section!

    Thanks in advance

    Palle