EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Initializing static variables (GNU gcc tools for H8S/2633)

Started by Robert Bielik April 15, 2004
Hi all,

I have "inherited" a project with a H8S/2633F MPU (using the GNU gcc
toolchain). I need static variables. Problem is that there is no init
code for static variables in the bootloader code. I.e. the initial
static data is correctly placed in the FLASH ROM, but the data is
never transferred at startup to the RAM. I have searched everywhere
for a simple example showing how to do it but have come up empty so
far.

Does anyone have a (asm) code snippet for this ?? I guess any MPU in
the 26xx series would do...

If you do, please send a copy to my email address also.

TIA
/Rob
On 14 Apr, in article
     <33b863b3.0404142211.7efd984f@posting.google.com>
     robert.bielik@gyros.com "Robert Bielik" wrote:

>Hi all, > >I have "inherited" a project with a H8S/2633F MPU (using the GNU gcc >toolchain). I need static variables. Problem is that there is no init >code for static variables in the bootloader code. I.e. the initial >static data is correctly placed in the FLASH ROM, but the data is >never transferred at startup to the RAM. I have searched everywhere >for a simple example showing how to do it but have come up empty so >far. > >Does anyone have a (asm) code snippet for this ?? I guess any MPU in >the 26xx series would do...
The code for 26xx is the same as any H8S series code and even the H8 using assembler code. Have a look at <http://www.eclectic-web.co.uk/index.php?jump=mike/esource/h8300-dev.htm> For a H8S starter for the Cygwin port of the GNU GCC compiler. <http://www.gnuh8.org.uk/> for several examples and links for H8/H8S using GNU GCC <http://www.renesas-eu.com/> for application data and other links due to a change a while back on the website, I do not have the URL for the startup code example. -- Paul Carpenter | paul@pcserv.demon.co.uk <http://www.pcserv.demon.co.uk/> Main Site <http://www.gnuh8.org.uk/> GNU H8 & mailing list info. <http://www.badweb.org.uk/> For those web sites you hate.
"Robert Bielik" <robert.bielik@gyros.com> wrote in message
news:33b863b3.0404142211.7efd984f@posting.google.com...
> I have "inherited" a project with a H8S/2633F MPU (using the GNU gcc > toolchain). I need static variables. Problem is that there is no init > code for static variables in the bootloader code. I.e. the initial > static data is correctly placed in the FLASH ROM, but the data is > never transferred at startup to the RAM. I have searched everywhere > for a simple example showing how to do it but have come up empty so > far.
I don't know about the gcc code, but Hitachi's H8 compilers traditionally make the variable initialisation startup phase optional. I would be shocked if the gcc H8 compiler didn't init the variables, or at least provide a means for this code to be included - since, without it, the compiler could be considered to be broken. HTH, and suspect it doesn't, Steve http://www.sfdesign.co.uk http://www.fivetrees.com
On 2004-04-15, Steve at fivetrees <steve@NOSPAMTAfivetrees.com> wrote:

> I would be shocked if the gcc H8 compiler didn't init the > variables,
It does: it produces initialized data records in the object file.
> or at least provide a means for this code to be included - > since, without it, the compiler could be considered to be > broken.
You expect the compiler to write your startup code? How is it supposed to know how you want things done? All you have to do is tell the linker the load address for the .data section (presumably somewhere in ROM). Then you write 4-5 lines of code in your startup routine to copy bytes from the .data section's load address to its virtual address. -- Grant Edwards grante Yow! The LOGARITHM of at an ISOCELES TRIANGLE is visi.com TUESDAY WELD!!
On Thursday, in article
     <407eb3d2$0$95319$65c69314@mercury.nildram.net>
     steve@NOSPAMTAfivetrees.com "Steve at fivetrees" wrote:

>"Robert Bielik" <robert.bielik@gyros.com> wrote in message >news:33b863b3.0404142211.7efd984f@posting.google.com... >> I have "inherited" a project with a H8S/2633F MPU (using the GNU gcc >> toolchain). I need static variables. Problem is that there is no init >> code for static variables in the bootloader code. I.e. the initial >> static data is correctly placed in the FLASH ROM, but the data is >> never transferred at startup to the RAM. I have searched everywhere >> for a simple example showing how to do it but have come up empty so >> far. > >I don't know about the gcc code, but Hitachi's H8 compilers traditionally >make the variable initialisation startup phase optional.
Hitachi as such a) does not exist the semiconductor division is Renesas, b) They themselves don't write compilers.
>I would be shocked if the gcc H8 compiler didn't init the variables, or at >least provide a means for this code to be included - since, without it, the >compiler could be considered to be broken.
Remember the GCC compiler is multi-target and multi-platform compiler and unless there is a defined crt0.o, it does not know which embedded scenario it is compiling for. There are plenty of examples of startup code from simple to complicated around.
>HTH, and suspect it doesn't, > >Steve >http://www.sfdesign.co.uk >http://www.fivetrees.com
-- Paul Carpenter | paul@pcserv.demon.co.uk <http://www.pcserv.demon.co.uk/> Main Site <http://www.gnuh8.org.uk/> GNU H8 & mailing list info. <http://www.badweb.org.uk/> For those web sites you hate.
"Grant Edwards" <grante@visi.com> wrote in message
news:407edbe4$0$17256$a1866201@newsreader.visi.com...
> You expect the compiler to write your startup code? How is it > supposed to know how you want things done?
Point taken - although initialising variables by copying from one known segment to another known segment is perhaps something I'd expect to be standard. (Although I can certainly imagine cases where this would indeed need to be turned off.)
> All you have to do is tell the linker the load address for the > .data section (presumably somewhere in ROM). Then you write 4-5 > lines of code in your startup routine to copy bytes from the > .data section's load address to its virtual address.
... which is the bit I (clearly naively) expected to be standard. Thanks for the info. Steve http://www.sfdesign.co.uk http://www.fivetrees.com
"Paul Carpenter" <paul$@pcserv.demon.co.uk> wrote in message
news:20040415.1956.298209snz@pcserv.demon.co.uk...
> >I don't know about the gcc code, but Hitachi's H8 compilers traditionally > >make the variable initialisation startup phase optional. > > Hitachi as such a) does not exist the semiconductor division is Renesas, > b) They themselves don't write compilers.
<sigh> Re a) - yes, I know. I'm a dinosaur who's been using H8s (and before that, other Hitachi CPUs) for far too long. Re b) - interesting point, that. When they changed over from the IAR compiler chain to "their own", the Hitachi reps here in the UK would refer to the two available toolchains as "IAR" and "Hitachi". This was a few years back. Have the real compiler writers now stood up and taken a bow? I almost missed the Renesas merger - have I missed something re the compilers? Wouldn't be too surprised... Steve http://www.sfdesign.co.uk http://www.fivetrees.com
On Thu, 15 Apr 2004 21:23:15 +0100, "Steve at fivetrees"
<steve@NOSPAMTAfivetrees.com> wrote:

>"Grant Edwards" <grante@visi.com> wrote in message >news:407edbe4$0$17256$a1866201@newsreader.visi.com... >> You expect the compiler to write your startup code? How is it >> supposed to know how you want things done? > >Point taken - although initialising variables by copying from one known >segment to another known segment is perhaps something I'd expect to be >standard. (Although I can certainly imagine cases where this would indeed >need to be turned off.) > >> All you have to do is tell the linker the load address for the >> .data section (presumably somewhere in ROM). Then you write 4-5 >> lines of code in your startup routine to copy bytes from the >> .data section's load address to its virtual address. > >... which is the bit I (clearly naively) expected to be standard. Thanks for >the info.
FWIW, the compilers I have that target micros with integrated memory (e.g., PIC, AVR, HC908) _do_ variable initialization by default in their startup code. In an old 80186 project (external memory only), however, I had to write my own code to initialize the chip selects and memory controller hardware before RAM could even be accessed. Every compiler I have except the one targetting the PIC allow me to edit or replace the standard startup code. Regards, -=Dave -- Change is inevitable, progress is not.
On Thursday, in article
     <407ef10e$0$95327$65c69314@mercury.nildram.net>
     steve@NOSPAMTAfivetrees.com "Steve at fivetrees" wrote:

>"Paul Carpenter" <paul$@pcserv.demon.co.uk> wrote in message >news:20040415.1956.298209snz@pcserv.demon.co.uk... >> >I don't know about the gcc code, but Hitachi's H8 compilers traditionally >> >make the variable initialisation startup phase optional. >> >> Hitachi as such a) does not exist the semiconductor division is Renesas, >> b) They themselves don't write compilers. > ><sigh> Re a) - yes, I know. I'm a dinosaur who's been using H8s (and before >that, other Hitachi CPUs) for far too long. Re b) - interesting point, that.
I have been using H8/H8S for a few years and set up the GNUH8 mailing list in 1998 !!! Also have a H8 Tiny and SH2 here I must get round to 'playing' with.
>When they changed over from the IAR compiler chain to "their own", the >Hitachi reps here in the UK would refer to the two available toolchains as >"IAR" and "Hitachi". This was a few years back. Have the real compiler >writers now stood up and taken a bow? I almost missed the Renesas merger - >have I missed something re the compilers? Wouldn't be too surprised...
I have never seen "Hitachi" compilers, just IAR from Hitachi/Renesas, with more recognition of GCC. -- Paul Carpenter | paul@pcserv.demon.co.uk <http://www.pcserv.demon.co.uk/> Main Site <http://www.gnuh8.org.uk/> GNU H8 & mailing list info. <http://www.badweb.org.uk/> For those web sites you hate.
On Thursday, in article
     <407efa1e.173522045@News.individual.net> iddw@hotmail.com
     "Dave Hansen" wrote:

>On Thu, 15 Apr 2004 21:23:15 +0100, "Steve at fivetrees" ><steve@NOSPAMTAfivetrees.com> wrote: >>"Grant Edwards" <grante@visi.com> wrote in message >>news:407edbe4$0$17256$a1866201@newsreader.visi.com... >>> You expect the compiler to write your startup code? How is it >>> supposed to know how you want things done? >> >>Point taken - although initialising variables by copying from one known >>segment to another known segment is perhaps something I'd expect to be >>standard. (Although I can certainly imagine cases where this would indeed >>need to be turned off.) >> >>> All you have to do is tell the linker the load address for the >>> .data section (presumably somewhere in ROM). Then you write 4-5 >>> lines of code in your startup routine to copy bytes from the >>> .data section's load address to its virtual address. >> >>... which is the bit I (clearly naively) expected to be standard. Thanks for >>the info. > >FWIW, the compilers I have that target micros with integrated memory >(e.g., PIC, AVR, HC908) _do_ variable initialization by default in >their startup code. In an old 80186 project (external memory only), >however, I had to write my own code to initialize the chip selects and >memory controller hardware before RAM could even be accessed.
The same is true for most H8xxx processors the default data could be being written to external RAM (considering a 16MB address space and only a relatively few KB internally).
>Every compiler I have except the one targetting the PIC allow me to >edit or replace the standard startup code.
Which GCC does allow you to do, but is a necessity for H8/H8S, Newlib makes it easier. See <http://www.gnuh8.org.uk/> it is an FAQ and series of linker and startup code questions there. -- Paul Carpenter | paul@pcserv.demon.co.uk <http://www.pcserv.demon.co.uk/> Main Site <http://www.gnuh8.org.uk/> GNU H8 & mailing list info. <http://www.badweb.org.uk/> For those web sites you hate.

The 2024 Embedded Online Conference