Forums

Running from flash without the debugger support (DSP56F827)

Started by atid2 January 14, 2003
Hi all,

I'm having a hard time running my software directly from the flash
of the DSP56F827.
I'm using the serial bootloader to download the s-record file into
the flash, and then it runs ok (even if I push the reset button).
But the second I take out the electricity and re-plug it the
problems start:
1) First I had a problem reading from the DATA flash at the
beginning of the run (the application was halted there as if it was
waiting for the busy flash) - which disappeared when I disabled this
part in my software. I don't undersatand why I have a collision
between the data and program flash.
2) But then the DATA I sent to the LCD looked like garbage.

Another problem I encoutered is with the TOD interrupts, again when
running from flash. I had to add a delay inside the interrupt
procedure (of the TOD one second and alarm interrupts) in order for
it to occure on time (don't ask how I understood that and how long
did it take me to find that out).

PS - I'm running it with the JTAG port disabled (jumper JG1 set).

Thank you in advance,
Ari Tidhar



Ari,

Although there are many reasons that could cause the problems you are
seeing, I'll provide a suggestion here.

First of all, the issue may be hardware related but I don't have
enough insight to comment on that. If that is the case, i'm afraid I
don't have much to lend to that at this point.

However, from a software perspective, anytime that an application can
run fine when pushing the reset button but misbehaves when powering
off you should immediately begin to investigate whether or not you
are storing your initialized data properly and that you are copying
it from ROM to RAM at runtime thus allowing the compiler to be able
to access the data. You cannot store initialized non-constant data
in Flash at runtime because the memory is not writable (i'm sure you
know this, but I'm just making points here.). I would recommend you
do the following:

A) If you are using the Embedded SDK, run one of their examples which
will run in standalone in flash just fine (there are many to choose
from) for your specific processor (DSP56F827).
B) Take a look at the linker command file for this application and
compare it with your own and make sure that you are treating all of
your initialized and uninitialized data appropriately at loadtime
(when you download the code) and at runtime (when you actually run
the application).

Again, if you have non-constant initialized data in your application,
this data must be stored in flash at loadtime so that they will be
there for loss of power. However, they must be copied at runtime to
RAM so that they can be written to, this is done via the AT directive
within the linker command file which allows you to specify a loadtime
address and a runtime address to be copied to by your startup code.

To read more about the AT directive, checkout the
Targeting_DSP56800.pdf that is located within your CodeWarrior
installation on pgs. DSP-232 and DSP-233.

Also, checkout the documentation in the SDK. Specifically, I would
recommend you read Section 3.2.2 of the Targeting Motorola
DSP56F826/827 Platform manual which talks about the Memory
Configuration using the Linker Command File for an application that
is running in an Internal Memory (Flash and RAM) mode.

If you already know all of this, I apologize for repeating it, but
possibly this can help you get to the bottom of it.

Regards,
John

--- In , "atid2 <ari@a...>" <ari@a...>
wrote:
> Hi all,
>
> I'm having a hard time running my software directly from the flash
> of the DSP56F827.
> I'm using the serial bootloader to download the s-record file into
> the flash, and then it runs ok (even if I push the reset button).
> But the second I take out the electricity and re-plug it the
> problems start:
> 1) First I had a problem reading from the DATA flash at the
> beginning of the run (the application was halted there as if it was
> waiting for the busy flash) - which disappeared when I disabled
this
> part in my software. I don't undersatand why I have a collision
> between the data and program flash.
> 2) But then the DATA I sent to the LCD looked like garbage.
>
> Another problem I encoutered is with the TOD interrupts, again when
> running from flash. I had to add a delay inside the interrupt
> procedure (of the TOD one second and alarm interrupts) in order for
> it to occure on time (don't ask how I understood that and how long
> did it take me to find that out).
>
> PS - I'm running it with the JTAG port disabled (jumper JG1 set).
>
> Thank you in advance,
> Ari Tidhar





Thank you John for the extremely comprehensive answer.
Although I think I did most of what you described, I may have to
recheck my linker.cmd file.

Anyway if anybody has the time and will to look into my linker.cmd
file, please have a look at it and tell me what you think.
Have in mind that I use the internal P and X memories and the
external X memory as well.

Thanks again,
Ari

MY LINKER.CMD FILE:
======================

# Changed by Ari Tidhar - 23/10/2002
#********************************************
# Linker.cmd file for DSP56827EVM
# using internal & external data memory ( EX = 0, Boot
Mode 0A )
# DSP56F827 does not have a dedicated Boot Flash
Section. .bBootFlash section
# is part of .pFlash2.

#********************************************************************
***********
MEMORY {

.pInterruptVector (RX) : ORIGIN = 0x0000, LENGTH = 0x0086
.pFlash (RX) : ORIGIN = 0x0086, LENGTH =
0x7B7A
.pIntRAM (RWX) : ORIGIN = 0x7C00, LENGTH =
0x0400
.pIntRAM_Mirror (RWX) : ORIGIN = 0x7C00, LENGTH = 0x0400

.pFlash2 (RX) : ORIGIN = 0x8000, LENGTH = 0x7800
.pBootFlash (RX) : ORIGIN = 0xF800,
LENGTH = 0x0800 #Part of pFlash2

.xAvailable (RW) : ORIGIN = 0x0000, LENGTH = 0x0030
.xCWRegisters (RW) : ORIGIN = 0x0030, LENGTH = 0x0010
.xIntRAM_DynamicMem (RW) : ORIGIN = 0x0040, LENGTH = 0x0FC0
.xPeripherals (RW) : ORIGIN = 0x1000, LENGTH = 0x0400
.xReserved1 (R) : ORIGIN = 0x1400, LENGTH = 0x0C00
.xFlash (R) : ORIGIN = 0x2000, LENGTH =
0x1000
.xReserved2 (R) : ORIGIN = 0x3000, LENGTH = 0x1000
.xExtRAM (RW) : ORIGIN = 0x4000, LENGTH = 0xA000
.xExtRAM_DynamicMem (RW) : ORIGIN = 0xE000, LENGTH = 0x1200
.xStack (RW) : ORIGIN = 0xF200, LENGTH =
0x0D80
.xCoreRegisters (RW) : ORIGIN = 0xFF80, LENGTH = 0x0080
}
#********************************************************************
***********

FORCE_ACTIVE {FconfigInterruptVector}

SECTIONS {

#
# Data (X) Memory Layout
#
_EX_BIT = 0;

# Internal Memory Partitions (for mem.h partitions)

_NUM_IM_PARTITIONS = 1; # IM_ADDR_1 (no IM_ADDR_2 )

# External Memory Partition (for mem.h partitions)

_NUM_EM_PARTITIONS = 1; # EM_ADDR_1 #********************************************************************
***********
.ApplicationInterruptVector :
{
vector.c (.text)

} > .pInterruptVector
#********************************************************************
***********
.ApplicationCode :
{
# Place code into Program Flash 1

* (.text)
* (rtlib.text)
* (fp_engine.text)
* (user.text)

} > .pFlash
#********************************************************************
***********
.ApplicationCode2 :
{
# Place code into Program Flash 2
# It is necessary to have two Program Flash sections
for the 827
# since the memory map is not continuous from the
first Program Flash
# section to the second.

# Locate C functions by referencing the filename
# Example: Cfilename.c (.text)
# Locate Assembly functions by referencing the
section name
# Example: * (section_name.text)

} > .pFlash2
#********************************************************************
***********
.InitializedDataForProgramRAM : AT (ADDR(.pFlash) + 1 +
SIZEOF(.pFlash) / 2)
{
# Define variables for C initialization code of
Program RAM data

F_Pdata_start_addr_in_ROM = ADDR(.pFlash) + 1 +
SIZEOF(.pFlash) / 2;

F_Pdata_start_addr_in_RAM = .;
_P_DATA_ADDR = .; # SDK initialized data to be placed into Program RAM

pramdata.c (.data)
F_Pdata_ROMtoRAM_length = . - _P_DATA_ADDR;

} > .pIntRAM_Mirror
#********************************************************************
***********
.DataForProgramRAM :
{
# allocates space for .InitializedDataForPRogramRAM section

. = (ADDR(.pIntRAM_Mirror) + SIZEOF(.pIntRAM_Mirror) / 2) + 1;

# Define variables for C initialization code

F_Pbss_start_addr = .;
_P_BSS_ADDR = .;

# SDK uninitialized data to be placed into Program RAM

pramdata.c (.bss)

F_Pbss_length = . - _P_BSS_ADDR;

} > .pIntRAM
#********************************************************************
***********
.ApplicationData :
{
# Define variables for C initialization code

F_Xdata_start_addr_in_ROM = ADDR(.xFlash) + SIZEOF
(.xFlash) / 2;
F_StackAddr = ADDR(.xStack);
F_StackEndAddr = ADDR(.xStack) + SIZEOF
(.xStack) / 2 - 1;
F_Xdata_start_addr_in_RAM = .; # Define variables for SDK mem library

FmemEXbit = .;
WRITEH(_EX_BIT);
FmemNumIMpartitions = .;
WRITEH(_NUM_IM_PARTITIONS);
FmemNumEMpartitions = .;
WRITEH(_NUM_EM_PARTITIONS);
FmemIMpartitionList = .;
WRITEH(ADDR(.xIntRAM_DynamicMem));
WRITEH(SIZEOF(.xIntRAM_DynamicMem) / 2);
FmemEMpartitionList = .;
WRITEH(ADDR(.xExtRAM_DynamicMem));
WRITEH(SIZEOF(.xExtRAM_DynamicMem) /2);
# Place rest of the data into External RAM

* (.data)
* (fp_state.data)
* (rtlib.data)

F_Xdata_ROMtoRAM_length = 0;

F_Xbss_start_addr = .;
_X_BSS_ADDR = .;

* (rtlib.bss.lo)
* (rtlib.bss)
* (.bss)

F_Xbss_length = . - _X_BSS_ADDR; # Copy DATA

} > .xExtRAM
#********************************************************************
*********** FArchIO = ADDR(.xPeripherals);
FArchCore = ADDR(.xCoreRegisters);
} ================================================================

--- In , "jdw_atx <jdw_atx@y...>"
<jdw_atx@y...> wrote:
> Ari,
>
> Although there are many reasons that could cause the problems you
are
> seeing, I'll provide a suggestion here.
>
> First of all, the issue may be hardware related but I don't have
> enough insight to comment on that. If that is the case, i'm
afraid I
> don't have much to lend to that at this point.
>
> However, from a software perspective, anytime that an application
can
> run fine when pushing the reset button but misbehaves when
powering
> off you should immediately begin to investigate whether or not you
> are storing your initialized data properly and that you are
copying
> it from ROM to RAM at runtime thus allowing the compiler to be
able
> to access the data. You cannot store initialized non-constant
data
> in Flash at runtime because the memory is not writable (i'm sure
you
> know this, but I'm just making points here.). I would recommend
you
> do the following:
>
> A) If you are using the Embedded SDK, run one of their examples
which
> will run in standalone in flash just fine (there are many to
choose
> from) for your specific processor (DSP56F827).
> B) Take a look at the linker command file for this application and
> compare it with your own and make sure that you are treating all
of
> your initialized and uninitialized data appropriately at loadtime
> (when you download the code) and at runtime (when you actually run
> the application).
>
> Again, if you have non-constant initialized data in your
application,
> this data must be stored in flash at loadtime so that they will be
> there for loss of power. However, they must be copied at runtime
to
> RAM so that they can be written to, this is done via the AT
directive
> within the linker command file which allows you to specify a
loadtime
> address and a runtime address to be copied to by your startup code.
>
> To read more about the AT directive, checkout the
> Targeting_DSP56800.pdf that is located within your CodeWarrior
> installation on pgs. DSP-232 and DSP-233.
>
> Also, checkout the documentation in the SDK. Specifically, I
would
> recommend you read Section 3.2.2 of the Targeting Motorola
> DSP56F826/827 Platform manual which talks about the Memory
> Configuration using the Linker Command File for an application
that
> is running in an Internal Memory (Flash and RAM) mode.
>
> If you already know all of this, I apologize for repeating it, but
> possibly this can help you get to the bottom of it.
>
> Regards,
> John
>
> --- In , "atid2 <ari@a...>" <ari@a...>
> wrote:
> > Hi all,
> >
> > I'm having a hard time running my software directly from the
flash
> > of the DSP56F827.
> > I'm using the serial bootloader to download the s-record file
into
> > the flash, and then it runs ok (even if I push the reset
button).
> > But the second I take out the electricity and re-plug it the
> > problems start:
> > 1) First I had a problem reading from the DATA flash at the
> > beginning of the run (the application was halted there as if it
was
> > waiting for the busy flash) - which disappeared when I disabled
> this
> > part in my software. I don't undersatand why I have a collision
> > between the data and program flash.
> > 2) But then the DATA I sent to the LCD looked like garbage.
> >
> > Another problem I encoutered is with the TOD interrupts, again
when
> > running from flash. I had to add a delay inside the interrupt
> > procedure (of the TOD one second and alarm interrupts) in order
for
> > it to occure on time (don't ask how I understood that and how
long
> > did it take me to find that out).
> >
> > PS - I'm running it with the JTAG port disabled (jumper JG1 set).
> >
> > Thank you in advance,
> > Ari Tidhar





Hi Ari,

I have a similar problem with the processor (an 807, maybe not fully
applicable) not running when powering up. When I download with the
bootloader the unit starts running fine. If I reset the unit it runs
fine. But if I power up, the unit does not even start. The fix I
found is that I cannot run with a Bootloader Delay of less than 2.
When set to 2 the unit comes up just fine. (I also use a crystal
oscillator for reliable operation)

#define BSP_BOOTLOADER_DELAY 2

Give some different delays a whirl.

Good Luck,
Pete > > --- In , "atid2 <ari@a...>" <ari@a...>
> > wrote:
> > > Hi all,
> > >
> > > I'm having a hard time running my software directly from the
> flash
> > > of the DSP56F827.
> > > I'm using the serial bootloader to download the s-record file
> into
> > > the flash, and then it runs ok (even if I push the reset
> button).
> > > But the second I take out the electricity and re-plug it the
> > > problems start:
> > > 1) First I had a problem reading from the DATA flash at the
> > > beginning of the run (the application was halted there as if it
> was
> > > waiting for the busy flash) - which disappeared when I disabled
> > this
> > > part in my software. I don't undersatand why I have a collision
> > > between the data and program flash.
> > > 2) But then the DATA I sent to the LCD looked like garbage.
> > >
> > > Another problem I encoutered is with the TOD interrupts, again
> when
> > > running from flash. I had to add a delay inside the interrupt
> > > procedure (of the TOD one second and alarm interrupts) in order
> for
> > > it to occure on time (don't ask how I understood that and how
> long
> > > did it take me to find that out).
> > >
> > > PS - I'm running it with the JTAG port disabled (jumper JG1
set).
> > >
> > > Thank you in advance,
> > > Ari Tidhar



Hi Pete,

Thanks, but after I tried changing the bootloeader delay to 20 sec,
I am more convinced that my problem is in the linker.cmd file.
But thanks anyway :).
I still hope someone will see what is the problem with it (see it
below).

Cheers,
Ari

MY LINKER>CMD FILE:
===================

# Changed by Ari Tidhar - 23/10/2002
#********************************************
# Linker.cmd file for DSP56827EVM
# using internal & external data memory ( EX = 0, Boot
Mode 0A )
# DSP56F827 does not have a dedicated Boot Flash
Section. .bBootFlash section
# is part of .pFlash2.

#********************************************************************
***********
MEMORY {

.pInterruptVector (RX) : ORIGIN = 0x0000, LENGTH = 0x0086
.pFlash (RX) : ORIGIN = 0x0086, LENGTH =
0x7B7A
.pIntRAM (RWX) : ORIGIN = 0x7C00, LENGTH =
0x0400
.pIntRAM_Mirror (RWX) : ORIGIN = 0x7C00, LENGTH = 0x0400

.pFlash2 (RX) : ORIGIN = 0x8000, LENGTH = 0x7800
.pBootFlash (RX) : ORIGIN = 0xF800,
LENGTH = 0x0800 #Part of pFlash2

.xAvailable (RW) : ORIGIN = 0x0000, LENGTH = 0x0030
.xCWRegisters (RW) : ORIGIN = 0x0030, LENGTH = 0x0010
.xIntRAM_DynamicMem (RW) : ORIGIN = 0x0040, LENGTH = 0x0FC0
.xPeripherals (RW) : ORIGIN = 0x1000, LENGTH = 0x0400
.xReserved1 (R) : ORIGIN = 0x1400, LENGTH = 0x0C00
.xFlash (R) : ORIGIN = 0x2000, LENGTH =
0x1000
.xReserved2 (R) : ORIGIN = 0x3000, LENGTH = 0x1000
.xExtRAM (RW) : ORIGIN = 0x4000, LENGTH = 0xA000
.xExtRAM_DynamicMem (RW) : ORIGIN = 0xE000, LENGTH = 0x1200
.xStack (RW) : ORIGIN = 0xF200, LENGTH =
0x0D80
.xCoreRegisters (RW) : ORIGIN = 0xFF80, LENGTH = 0x0080
}
#********************************************************************
***********

FORCE_ACTIVE {FconfigInterruptVector}

SECTIONS {

#
# Data (X) Memory Layout
#
_EX_BIT = 0;

# Internal Memory Partitions (for mem.h partitions)

_NUM_IM_PARTITIONS = 1; # IM_ADDR_1 (no IM_ADDR_2 )

# External Memory Partition (for mem.h partitions)

_NUM_EM_PARTITIONS = 1; # EM_ADDR_1 #********************************************************************
***********
.ApplicationInterruptVector :
{
vector.c (.text)

} > .pInterruptVector
#********************************************************************
***********
.ApplicationCode :
{
# Place code into Program Flash 1

* (.text)
* (rtlib.text)
* (fp_engine.text)
* (user.text)

} > .pFlash
#********************************************************************
***********
.ApplicationCode2 :
{
# Place code into Program Flash 2
# It is necessary to have two Program Flash sections
for the 827
# since the memory map is not continuous from the
first Program Flash
# section to the second.

# Locate C functions by referencing the filename
# Example: Cfilename.c (.text)
# Locate Assembly functions by referencing the
section name
# Example: * (section_name.text)

} > .pFlash2
#********************************************************************
***********
.InitializedDataForProgramRAM : AT (ADDR(.pFlash) + 1 +
SIZEOF(.pFlash) / 2)
{
# Define variables for C initialization code of
Program RAM data

F_Pdata_start_addr_in_ROM = ADDR(.pFlash) + 1 +
SIZEOF(.pFlash) / 2;

F_Pdata_start_addr_in_RAM = .;
_P_DATA_ADDR = .; # SDK initialized data to be placed into Program RAM

pramdata.c (.data)
F_Pdata_ROMtoRAM_length = . - _P_DATA_ADDR;

} > .pIntRAM_Mirror
#********************************************************************
***********
.DataForProgramRAM :
{
# allocates space for .InitializedDataForPRogramRAM section

. = (ADDR(.pIntRAM_Mirror) + SIZEOF(.pIntRAM_Mirror) / 2) + 1;

# Define variables for C initialization code

F_Pbss_start_addr = .;
_P_BSS_ADDR = .;

# SDK uninitialized data to be placed into Program RAM

pramdata.c (.bss)

F_Pbss_length = . - _P_BSS_ADDR;

} > .pIntRAM
#********************************************************************
***********
.ApplicationData :
{
# Define variables for C initialization code

F_Xdata_start_addr_in_ROM = ADDR(.xFlash) + SIZEOF
(.xFlash) / 2;
F_StackAddr = ADDR(.xStack);
F_StackEndAddr = ADDR(.xStack) + SIZEOF
(.xStack) / 2 - 1;
F_Xdata_start_addr_in_RAM = .; # Define variables for SDK mem library

FmemEXbit = .;
WRITEH(_EX_BIT);
FmemNumIMpartitions = .;
WRITEH(_NUM_IM_PARTITIONS);
FmemNumEMpartitions = .;
WRITEH(_NUM_EM_PARTITIONS);
FmemIMpartitionList = .;
WRITEH(ADDR(.xIntRAM_DynamicMem));
WRITEH(SIZEOF(.xIntRAM_DynamicMem) / 2);
FmemEMpartitionList = .;
WRITEH(ADDR(.xExtRAM_DynamicMem));
WRITEH(SIZEOF(.xExtRAM_DynamicMem) /2);
# Place rest of the data into External RAM

* (.data)
* (fp_state.data)
* (rtlib.data)

F_Xdata_ROMtoRAM_length = 0;

F_Xbss_start_addr = .;
_X_BSS_ADDR = .;

* (rtlib.bss.lo)
* (rtlib.bss)
* (.bss)

F_Xbss_length = . - _X_BSS_ADDR; # Copy DATA

} > .xExtRAM
#********************************************************************
*********** FArchIO = ADDR(.xPeripherals);
FArchCore = ADDR(.xCoreRegisters);
} =====================================================================
=====================================================================

--- In , "Pete Becher <pbecher@d...>"
<pbecher@d...> wrote:
> Hi Ari,
>
> I have a similar problem with the processor (an 807, maybe not
fully
> applicable) not running when powering up. When I download with
the
> bootloader the unit starts running fine. If I reset the unit it
runs
> fine. But if I power up, the unit does not even start. The fix I
> found is that I cannot run with a Bootloader Delay of less than
2.
> When set to 2 the unit comes up just fine. (I also use a crystal
> oscillator for reliable operation)
>
> #define BSP_BOOTLOADER_DELAY 2
>
> Give some different delays a whirl.
>
> Good Luck,
> Pete > > > --- In , "atid2 <ari@a...>"
<ari@a...>
> > > wrote:
> > > > Hi all,
> > > >
> > > > I'm having a hard time running my software directly from the
> > flash
> > > > of the DSP56F827.
> > > > I'm using the serial bootloader to download the s-record
file
> > into
> > > > the flash, and then it runs ok (even if I push the reset
> > button).
> > > > But the second I take out the electricity and re-plug it the
> > > > problems start:
> > > > 1) First I had a problem reading from the DATA flash at the
> > > > beginning of the run (the application was halted there as if
it
> > was
> > > > waiting for the busy flash) - which disappeared when I
disabled
> > > this
> > > > part in my software. I don't undersatand why I have a
collision
> > > > between the data and program flash.
> > > > 2) But then the DATA I sent to the LCD looked like garbage.
> > > >
> > > > Another problem I encoutered is with the TOD interrupts,
again
> > when
> > > > running from flash. I had to add a delay inside the
interrupt
> > > > procedure (of the TOD one second and alarm interrupts) in
order
> > for
> > > > it to occure on time (don't ask how I understood that and
how
> > long
> > > > did it take me to find that out).
> > > >
> > > > PS - I'm running it with the JTAG port disabled (jumper JG1
> set).
> > > >
> > > > Thank you in advance,
> > > > Ari Tidhar