Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Mark Kettenis <mark.kettenis@xs4all.nl>
To: jimb@codesourcery.com
Cc: gdb@sourceware.org
Subject: Re: GDB support for Flash memory programming
Date: Sat, 17 Jun 2006 20:07:00 -0000	[thread overview]
Message-ID: <200606171959.k5HJxABZ003460@elgar.sibelius.xs4all.nl> (raw)
In-Reply-To: <vt2k68c48rp.fsf@theseus.home.> (message from Jim Blandy on Tue, 	23 May 2006 16:32:42 -0700)

> From: Jim Blandy <jimb@codesourcery.com>
> Date: Tue, 23 May 2006 16:32:42 -0700
> 
> One of the problems GDB has in the embedded development world is its
> lack of support for loading programs into flash memory.  After some
> conversation amongst ourselves to weed out patently stupid stuff (none
> of the text below is mine... hey), we at CodeSourcery put together the
> following proposal for general comments and criticism.
>
> We'd like to reach consensus on what the user interface should be
> before we worry about implementation details --- possible remote
> protocol changes, and so on --- so let's leave those topics aside for
> the time being.
> 
> What do folks think?

I don't think the gdb user interface should depend on the sort of
memory you're targeting, i.e. the interface should be the same for all
memory whether it is RAM, EEPROM or flash.  So I think "write-flash"
is the the wrong name for the command.

Looks like what you really want is some sort of command to (partially)
write-protect (parts of) memory.

> 
> ---
> 
> Background
> 
> Flash memory is a popular form of non-volatile memory. When reading,
> it is byte-addressable, like traditional RAM or ROM. An entire block
> (many kilobytes, typically) of flash can be erased with a single
> command. Individual bytes can be written only if they have been
> erased, but not subsequently written. Therefore, to write a single
> byte, without changing other bytes in the same block, one must read
> the block, erase the block, and then re-write the block using the
> previously read data, as modified by the intended write.
> 
> Flash is typically used for program storage. On some systems, flash is
> in fact the only place to store programs. For example, some systems
> have have relatively large amounts of flash, but very small amounts of
> RAM.
> 
> If the flash memory controller has a JTAG interface (most do) then the
> flash memory can typically be programmed using the same ICE/BDM unit
> that is used for debugging.
> 
> Because GDB already communicates with these ICE units (typically via a
> GDB stub), and because GDB already supports loading programs onto
> embedded systems (via the load command), it is natural that GDB
> support loading programs into flash memory as well. This document
> proposes a GDB user interface for loading programs into flash memory.
> 
> In what follows, the term "GDB" refers to the user's view of GDB,
> which includes GDB, any applicable stub, the ICE units, etc. Thus
> statements like "GDB must do X" are not meant to imply that GDB proper
> must do X, but rather that GDB must cause X to occur.  Program Images
> 
> If the program image loaded by the load command will result in any
> portion of the program image being placed in flash memory, then GDB is
> responsible for modifying the flash accordingly. GDB must not modify
> bytes outside of the program image itself. Therefore, if the program
> image occupies only a portion of a flash sector, GDB is responsible
> for arranging flash read/erase/write commands appropriately so as to
> avoid changing unmodified portions of the sector.
> 
> If the target hardware requires any other modifications to special
> memory addresses (such as placing the initial value of the program
> counter at a specified address), then it is the responsibility of the
> programmer to ensure that the program image contains appropriate
> values at those addresses; GDB's responsibility is simply to
> accurately copy the program image to the target.
> 
> The rationale for using load (rather than an alternative flash
> command) is that, on a system in which programs are located in flash,
> loading a program implies placing it in flash. Furthermore, GUIs,
> scripts, etc., that use load (or the MI equivalent thereof) will not
> require change to work with flash systems.  Variables and Data
> 
> By default, variables and other data located in flash may not be
> modified by the user, other than by use of the load command. For
> example, if i is located in flash, then:
> 
>     set var i = 10
> 
> will result in an error message. (As a consequence, GDB must be able
> to determine which addresses lie in flash; otherwise, GDB, using a
> stub with a 100% transparent interface to flash, would not be able to
> issue an error.)
> 
> The rationale for forbidding modification of variables is that most
> such attempted modifications probably represent user
> error. Furthermore, because setting a single variable requires erasing
> and writing an entire flash sector, there might be some noticable
> delay in implementing this request.  Customization
> 
> GDB will have a new write-flash variable. This variable will have
> three possible states:
> 
>     * on
> 
>       All writes to flash, including those to variables/data, are
>       permitted. This mode may be used to permit explicit "poke"
>       operations, like the assignment above.
> 
>     * load
> 
>       The load command may write to flash; no other commands may write
>       to flash. This mode is the default.
> 
>     * off
> 
>       No commands may write to flash. This mode may be used for safety
>       when debugging a production system.
> 


  parent reply	other threads:[~2006-06-17 20:00 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-24  1:44 Jim Blandy
2006-05-24  2:03 ` Steven Johnson
2006-05-24 22:07   ` Jim Blandy
2006-05-25  2:35     ` Steven Johnson
2006-05-24  4:43 ` Nathan J. Williams
2006-05-24 22:17   ` Jim Blandy
2006-05-24  8:03 ` Russell Shaw
2006-05-25  0:22   ` Jim Blandy
2006-05-25  3:05     ` Russell Shaw
2006-05-25  0:39   ` GDB and remote protocols Daniel Jacobowitz
2006-05-25  3:04     ` Russell Shaw
2006-05-25  0:52 ` GDB support for Flash memory programming Steven Johnson
2006-05-25  1:11   ` Peter Barada
2006-05-25  2:18   ` Jim Blandy
2006-05-25  3:29     ` Steven Johnson
2006-05-26 18:42       ` Jim Blandy
2006-05-27  0:02         ` Steven Johnson
2006-06-17 20:07 ` Mark Kettenis [this message]
2006-06-18  9:55   ` Jim Blandy

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=200606171959.k5HJxABZ003460@elgar.sibelius.xs4all.nl \
    --to=mark.kettenis@xs4all.nl \
    --cc=gdb@sourceware.org \
    --cc=jimb@codesourcery.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