public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Henrique Coser <henrique.coser@tex.com.br>
To: David Brown <david.brown@hesbynett.no>,
	Martin Sebor <msebor@gmail.com>,
	"gcc-help@gcc.gnu.org" <gcc-help@gcc.gnu.org>
Subject: RE: Constant at fixed address
Date: Mon, 28 Feb 2022 15:16:06 +0000	[thread overview]
Message-ID: <FR1PR80MB4744B152F96E3E4AA911B922BD019@FR1PR80MB4744.lamprd80.prod.outlook.com> (raw)
In-Reply-To: <16a27a10-fef4-c561-a01a-dbd3a03d1e8f@hesbynett.no>

David,

Sorry, I was not clear enough about my system.

The Atmel , sam3s4b that I use has more memmory than that.
I have limited the flash since this part of code is a boot loader that is separeted of main application.
During firmware upgrade only the main application is erased and the boot loader  remains in the memmory.

Boot loader area must be lower than 5KB (0x1400) to keep space enough for main application.
So If I change the script as you propoused, I will not have space enough for boot loader.

The section is not declared into the script, is declared as a linker parameter :

 -Wl,-section-start=.bootversion=0x00401000

I have already tried to make a "hole" in memmory.
Imagine that you have a splited flash, like if you have two memmory banks, how should I change the script to automatically distribute the code between these two "memmory banks"?

If I find a way to make this split , I can put the boot loader version in the middle.
What I wanted is something that can do this as easy as Keil does.
I know that Keil will make it and will work, but since is the trial version, I can not embed this solution using Keil.

Thank you very much for all attention that you gave.



Henrique Coser

Engenharia



TEX Equip.Eletronicos Ind.e Com.Ltda.

Fone: (+5511) 4591-2825

henrique.coser@tex.com.br<mailto:compras@tex.com.br>

MEDIR PARA MELHORAR!
________________________________
De: David Brown <david.brown@hesbynett.no>
Enviado: 26 de fevereiro de 2022 15:57
Para: Henrique Coser <henrique.coser@tex.com.br>; Martin Sebor <msebor@gmail.com>; gcc-help@gcc.gnu.org <gcc-help@gcc.gnu.org>
Assunto: Re: Constant at fixed address

On 25/02/2022 22:37, Henrique Coser wrote:
> Martin and David,  thank you for your answers.
>
> Attached is the linker script that I use.
>
> In Keil, where I did the first version of the boot loader I can assure you that a constant value is placed and correctly filled when use __attribute__((at(0x0401000)))
> I don't know how they do this but they do!
>
> I would be grateful If you could help me editting this script.
>
> Thank you very much.
>
>

The length of your "rom" space in sam3s4b_flash.ld does not make much
sense.  I haven't used Atmel's SAM devices, but I'd be surprised to see
one with a little under 12 K flash.

The linker files you attached are not, I think, the ones you used when
you got the link error - they don't have any mention of the
".bootversion" section.  So all I can do is show a typical way to have
this set up in a linker file.



Your "rom" section starts with :

   .text :
    {
        . = ALIGN(4);
        _sfixed = .;
        KEEP(*(.vectors .vectors.*))
        *(.text .text.* .gnu.linkonce.t.*)
        ...
    } > rom

That will put the ".vectors" section(s) first, at the start of rom, then
everything after it.

What you need to have is the fixed sections, then everything that can be
freely allocated:

   .headers :
    {
        FILL(0xff)
        . = ALIGN(4);
        _sfixed = .;
        KEEP(*(.vectors .vectors.*))
        . = 0x1000;
        KEEP(*(.bootversion .bootversion.*))
    } > rom

   .text :
    {
        . = ALIGN(4);
        *(.text .text.* .gnu.linkonce.t.*)
        ...
    } > rom


Then the main ".text" and other flash sections get put after the
bootversion section, and you don't get an overlap.

This wastes the space between the vectors and the fixed .bootversion
section, but you could put other data there if you like (maybe some of
the arrays used for constructors or initialisation).  Don't bother
unless you are tight for space.

  reply	other threads:[~2022-02-28 15:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-25 16:01 Henrique Coser
2022-02-25 16:45 ` Martin Sebor
2022-02-25 17:56   ` David Brown
2022-02-25 18:18     ` AW: " stefan
2022-02-26 18:56       ` David Brown
2022-02-25 21:37     ` Henrique Coser
2022-02-26 18:57       ` David Brown
2022-02-28 15:16         ` Henrique Coser [this message]
2022-02-28 15:50           ` David Brown

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=FR1PR80MB4744B152F96E3E4AA911B922BD019@FR1PR80MB4744.lamprd80.prod.outlook.com \
    --to=henrique.coser@tex.com.br \
    --cc=david.brown@hesbynett.no \
    --cc=gcc-help@gcc.gnu.org \
    --cc=msebor@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).