EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

GNU compiler and memory on HCS12

Started by Steve Auch-Schwelk June 19, 2004
I have a tboard eval. with the HCS12 MC mounted. It came with a 30
day trial of the ICC compiler, but I decided to try GCC.

My program has now grown to over 12K, and I am having trouble
fiddling my memory.x to get the program to load.

the default memory map looks like this:

$03FF $0000 Control Registers
$0400 $0FFF 4KB EEPROM (Area $0000-$03FF = 1KB hidden by Control
Registers)
$3FFF 1000 12KB RAM
$7FFF $4000 16KB Flash(equals Page $3E)
$BFFF $8000 16KB Flash (any Page $30..$3F, controlled by PPAGE)
$FFFF $C000 16KB Flash(equals Page $3F)
the DBUG12 Monitor/loader is also squeezed in there at e000-ffff

Originally I had everything in RAM and my memory.x looked something
like this:
MEMORY
{
page0 (rwx) : ORIGIN = 0x0000, LENGTH = 256
text (rx) : ORIGIN = 0x1000, LENGTH = 4K
data : ORIGIN = 0x2000, LENGTH = 6K
}
/* Setup the stack on the top of the data memory bank. */
PROVIDE (_stack = 0x3c00);

Now that the program has grown to over 12K (I have still to look into
WHY it's so big. I haven't written so much code: but that comes
later), I need to somehow plug the program code into Flash I presume.
But I don't seem to be able to convince the linker to do it. Or If
the linker agrees, my loader either says "Can't write Target memory",
or just stops loading at some stage.
(Among Others) this is my current memory.x:
MEMORY
{
page0 (rwx) : ORIGIN = 0x0000, LENGTH = 256
text (rx) : ORIGIN = 0x4000, LENGTH = 0x3000
data : ORIGIN = 0x1000, LENGTH = 0x1000
}
/* Setup the stack on the top of the data memory bank. */
PROVIDE (_stack = 0x3FFF);

Am I missing something basic here? How should I be loading my program?

thanks in advance...



OK. So 1 more day of dtudying, and the basic thing that I was missing
is that the bootloader doesn't do flash. Does anyone know why? I
mean, the code is available, and loading the s-record wouldn't be a
major problem. I will now write my own bootloader which does this,
and post it here if anyone is interested. > Am I missing something basic here? How should I be loading my
program?
>
> thanks in advance...





--- In , "Steve Auch-Schwelk"
<steve_auch@y...> wrote:
> OK. So 1 more day of dtudying, and the basic thing that I was
missing
> is that the bootloader doesn't do flash. Does anyone know why? I
> mean, the code is available, and loading the s-record wouldn't be
a
> major problem.

I think the bootloader will program flash if you overwrite the d-
bug12 monitor with your program. Which board do you have?

You also need to pay attention to the format of the S-Records if you
want to program flash using the bootloader. See this document:
http://www.geocities.com/englere_geo/intro.txt

You might want to switch to the gcc group for questions on the gcc
compiler:
http://groups.yahoo.com/group/gnu-m68hc11/

And you might like my EmbeddedGNU IDE if you use Windows:
http://www.geocities.com/englere_geo/index.html

Eric



Thanks for the tips Eric.
I have the t-board http://www.elektronikladen.de/en_hcs12tb.html
I don't quite understand why the dbug12 monitor did not want to download my s-record. I tried "both" commands. The normal "load" command didn't work, and the "fload" command gave the error "not available in EVB mode".
Having said that, I tried the "loader mode" because I thought this might be especially for eeprom. So I'm not sure what the problem was.

As an asside, the problem has been deferred, since I found that one command, a long long divide ( I know I shouldn't have been using it anyway, I was just lazy at the time) was adding 10K to my source code size. from approx 1k, to over 11k with one command. Eric Engler <> wrote:
--- In , "Steve Auch-Schwelk"
<steve_auch@y...> wrote:
> OK. So 1 more day of dtudying, and the basic thing that I was
missing
> is that the bootloader doesn't do flash. Does anyone know why? I
> mean, the code is available, and loading the s-record wouldn't be
a
> major problem.

I think the bootloader will program flash if you overwrite the d-
bug12 monitor with your program. Which board do you have?

You also need to pay attention to the format of the S-Records if you
want to program flash using the bootloader. See this document:
http://www.geocities.com/englere_geo/intro.txt

You might want to switch to the gcc group for questions on the gcc
compiler:
http://groups.yahoo.com/group/gnu-m68hc11/

And you might like my EmbeddedGNU IDE if you use Windows:
http://www.geocities.com/englere_geo/index.html

Eric
--------------------To learn more about Motorola Microcontrollers, please visit
http://www.motorola.com/mcu
o learn more about Motorola Microcontrollers, please visit
http://www.motorola.com/mcu
---------------------------------
Yahoo! Groups Links

To
---------------------------------
ALL-NEW Yahoo! Messenger - sooooo many all-new ways to express yourself




Hi Steve,

D-Bug12 is occupying all Flash of the MCU when running in EVB mode, so
you can use RAM only to download your application.

There is a 'DG256 version of the TwinPEEKs monitor which only occupies
4KB of Flash. It has only few debugging capabilities, but provides an
easy way for downloading code to Flash/EEPROM and/or RAM. If you are
interested in a copy please contact me off-list.

Please be aware that you will need a BDM-pod (or a 2nd HCS12 T-Board etc.
running D-Bug12) to establish the alternative bootloader/monitor.

Happy HCS12ing!
Oliver
> I have a tboard eval. with the HCS12 MC mounted. It came with a 30
> day trial of the ICC compiler, but I decided to try GCC.
>
> My program has now grown to over 12K, and I am having trouble
> fiddling my memory.x to get the program to load.
>
> the default memory map looks like this:
>
> $03FF $0000 Control Registers
> $0400 $0FFF 4KB EEPROM (Area $0000-$03FF = 1KB hidden by Control
> Registers)
> $3FFF 1000 12KB RAM
> $7FFF $4000 16KB Flash(equals Page $3E)
> $BFFF $8000 16KB Flash (any Page $30..$3F, controlled by PPAGE)
> $FFFF $C000 16KB Flash(equals Page $3F)
> the DBUG12 Monitor/loader is also squeezed in there at e000-ffff
>
> Originally I had everything in RAM and my memory.x looked something
> like this:
> MEMORY
> {
> page0 (rwx) : ORIGIN = 0x0000, LENGTH = 256
> text (rx) : ORIGIN = 0x1000, LENGTH = 4K
> data : ORIGIN = 0x2000, LENGTH = 6K
> }
> /* Setup the stack on the top of the data memory bank. */
> PROVIDE (_stack = 0x3c00);
>
> Now that the program has grown to over 12K (I have still to look into
> WHY it's so big. I haven't written so much code: but that comes
> later), I need to somehow plug the program code into Flash I presume.
> But I don't seem to be able to convince the linker to do it. Or If
> the linker agrees, my loader either says "Can't write Target memory",
> or just stops loading at some stage.
> (Among Others) this is my current memory.x:
> MEMORY
> {
> page0 (rwx) : ORIGIN = 0x0000, LENGTH = 256
> text (rx) : ORIGIN = 0x4000, LENGTH = 0x3000
> data : ORIGIN = 0x1000, LENGTH = 0x1000
> }
> /* Setup the stack on the top of the data memory bank. */
> PROVIDE (_stack = 0x3FFF);
>
> Am I missing something basic here? How should I be loading my program?
>
> thanks in advance... >
>
> --------------------To learn more about Motorola Microcontrollers, please visit
> http://www.motorola.com/mcu
> o learn more about Motorola Microcontrollers, please visit
> http://www.motorola.com/mcu
>
> Yahoo! Groups Links >
>


--- In , Stevie <steve_auch@y...> wrote:
> I don't quite understand why the dbug12 monitor did not want to
download my s-record. I tried "both" commands. The normal "load"
command didn't work, and the "fload" command gave the error "not
available in EVB mode".

If you want to use fload, you have to switch to the bootloader mode
(normally using DIP switches on the board), and reset. The
bootloader is not actually part of d-bug12. If you boot up in the
bootloader mode, you can use the fload command to overwrite d-bug12
with your program.

When you overwrite d-bug12 you have full control of the processor.
You'll have to program the PLL if you want to run at full speed. You
also have full control of the serial port(s), since there will not
be any monitor. Of course this comes at a price - you don't have any
of the services of the monitor, and you have to write code for
everything you want to do. You also need your own interupt handlers
for reset, watchdog, etc.

Of course, you want to make sure you have a copy of d-bug12 in
an .s19 file so you can reprogram it if you need to.

Eric



I believe that sooner or later I will have to get rid of the monitor,
so that I can use all of the features, not to mention memory, of the
MC. But I would still like to have the routines that I am using (eg
serial comms, printf, and the necessary watchdog & PLL stuff)

To this end, is there some source code for a HCS12 monitor program,
that I could canibalise to use only the parts that I need.

I suppose I could disassemble the current code DBUG12, but this would
be error prone and tedious. I would prefer it in C, but assembler
would be almost as good I suppose.

I know that DBUG12 is freely distributed, but I havent seen any souce
code for it.

thanks

Steve

--- In , "Eric Engler" <englere.geo@y...> wrote:
> --- In , Stevie <steve_auch@y...> wrote:
> > I don't quite understand why the dbug12 monitor did not want to
> download my s-record. I tried "both" commands. The normal "load"
> command didn't work, and the "fload" command gave the error "not
> available in EVB mode".
>
> If you want to use fload, you have to switch to the bootloader mode
> (normally using DIP switches on the board), and reset. The
> bootloader is not actually part of d-bug12. If you boot up in the
> bootloader mode, you can use the fload command to overwrite d-bug12
> with your program.
>
> When you overwrite d-bug12 you have full control of the processor.
> You'll have to program the PLL if you want to run at full speed.
You
> also have full control of the serial port(s), since there will not
> be any monitor. Of course this comes at a price - you don't have
any
> of the services of the monitor, and you have to write code for
> everything you want to do. You also need your own interupt handlers
> for reset, watchdog, etc.
>
> Of course, you want to make sure you have a copy of d-bug12 in
> an .s19 file so you can reprogram it if you need to.
>
> Eric





Steve,

The source-code for DBUG12 is not available.

My advise for you is - buy a BDM - even just a simple and cheap BDM. You
are trying to save money - but you are actually loosing time (money)
because you are spending your time to reinvent the wheel. Your time must
worth some money too, even if you are just a student or a hobbyist. BDM
release all the HCS12 internal resources, to be used by the application,
and doesn't require any code monitor as part of your program.

Since the BDMs and emulator we (Nohau) make are for high-end users where
time matters a lot, you will probably want to look into using another
cheaper BDM.

Hope this helps,
Doron
Nohau Corporation
HC12 In-Circuit Emulators
www.nohau.com/emul12pc.html At 14:59 23/06/2004 +0000, you wrote:
>I believe that sooner or later I will have to get rid of the monitor,
>so that I can use all of the features, not to mention memory, of the
>MC. But I would still like to have the routines that I am using (eg
>serial comms, printf, and the necessary watchdog & PLL stuff)
>
>To this end, is there some source code for a HCS12 monitor program,
>that I could canibalise to use only the parts that I need.
>
>I suppose I could disassemble the current code DBUG12, but this would
>be error prone and tedious. I would prefer it in C, but assembler
>would be almost as good I suppose.
>
>I know that DBUG12 is freely distributed, but I havent seen any souce
>code for it.
>
>thanks
>
>Steve





Thanks for the advice Doron. You are probably right that I would save
time buying a DBM, but I see it as overkill to need a DBM just to
download some software.

If I am not mistaken (and please correct me if I'm wrong), I will
still have to implement my own interrupt handlers, program the PLL,
and do all of the other things that the monitor program is doing now.
The only advantage I get is to be able to debug inline (and I'm more
the trace statement type anyway).

So to recap, I only want a monitor which will download my software,
setup the HCS12 to run (standard interrupt routeins, PLL, anything
else?), and the use of one com port as trace IO. Does anyone know if
this is available somewhere? I think I'll start a new thread for this
request..... --- In , Doron Fael <doronf@n...> wrote:
> Steve,
>
> The source-code for DBUG12 is not available.
>
> My advise for you is - buy a BDM - even just a simple and cheap
BDM. You
> are trying to save money - but you are actually loosing time
(money)
> because you are spending your time to reinvent the wheel. Your time
must
> worth some money too, even if you are just a student or a hobbyist.
BDM
> release all the HCS12 internal resources, to be used by the
application,
> and doesn't require any code monitor as part of your program.
>
> Since the BDMs and emulator we (Nohau) make are for high-end users
where
> time matters a lot, you will probably want to look into using
another
> cheaper BDM.
>
> Hope this helps,
> Doron
> Nohau Corporation
> HC12 In-Circuit Emulators
> www.nohau.com/emul12pc.html > At 14:59 23/06/2004 +0000, you wrote:
> >I believe that sooner or later I will have to get rid of the
monitor,
> >so that I can use all of the features, not to mention memory, of
the
> >MC. But I would still like to have the routines that I am using (eg
> >serial comms, printf, and the necessary watchdog & PLL stuff)
> >
> >To this end, is there some source code for a HCS12 monitor program,
> >that I could canibalise to use only the parts that I need.
> >
> >I suppose I could disassemble the current code DBUG12, but this
would
> >be error prone and tedious. I would prefer it in C, but assembler
> >would be almost as good I suppose.
> >
> >I know that DBUG12 is freely distributed, but I havent seen any
souce
> >code for it.
> >
> >thanks
> >
> >Steve >





The 2024 Embedded Online Conference