All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Cercueil <paul@crapouillou.net>
To: linux-remoteproc@vger.kernel.org
Subject: Doc to write firmware?
Date: Wed, 23 Dec 2020 10:57:09 +0000	[thread overview]
Message-ID: <93HSLQ.5D3DAYSGVCVP@crapouillou.net> (raw)

Hi,

Having written the ingenic-remoteproc driver I am trying now to write 
something a bit more advanced than a hello-world. Something like a 
case-invert program for starters. However I'm having a hard time trying 
to figure out how things work.

My resource table is as follows:

----------------------------
struct resource_table_hdr {
 struct resource_table header;

 uint32_t offset[3];

 struct {
  struct fw_rsc_hdr header;
  struct fw_rsc_carveout carveout;
 } carveout;

 struct {
  struct fw_rsc_hdr header;
  struct fw_rsc_trace trace;
 } trace;

 struct {
  struct fw_rsc_hdr header;
  struct fw_rsc_vdev vdev;
  struct fw_rsc_vdev_vring vrings[2];
  uint8_t config[0xc];
 } vdev;
};

const struct resource_table_hdr resource_table
__attribute__((used, section (".resource_table"))) = {
 .header = {
  .ver = 1,
  .num = ARRAY_SIZE(resource_table.offset), /* Number of resources */
 },

 .offset[0] = offsetof(struct resource_table_hdr, carveout),
 .offset[1] = offsetof(struct resource_table_hdr, trace),
 .offset[2] = offsetof(struct resource_table_hdr, vdev),

 .carveout = {
  .header = {
   .type = RSC_CARVEOUT,
  },
  .carveout = {
   .da = 0xf4000000,
   .len = 0x2000,
   .name = "firmware",
  },
 },

 /* Trace resource to printf() into */
 .trace = {
  .header = {
   .type = RSC_TRACE,
  },
  .trace = {
   .da = (uint32_t)trace_buf,
   .len = TRACE_BUFFER_SIZE,
   .name = "trace",
  },
 },

 /* VirtIO device */
 .vdev = {
  .header = {
   .type = RSC_VDEV,
  },
  .vdev = {
   .id = VIRTIO_ID_RPROC_SERIAL,
   .notifyid = 0,
   .dfeatures = 0,
   .config_len = 0xc,
   .num_of_vrings = 2,
  },
  .vrings = {
   [0] = {
    .align = 0x10,
    .num = 0x4,
    .notifyid = 0,
   },
   [1] = {
    .align = 0x10,
    .num = 0x4,
    .notifyid = 0,
   },
  },
 },
};
----------------------------

The firmware is properly loaded and I get debug prints in my trace 
buffer. However, my vrings' .da fields don't seem to be initialized to 
anything meaningful at all. Then I use the virtio/vring code from 
(https://github.com/MIPS/mips-rproc-example/blob/master/firmware/common/include/vring.h), 
and calling vring_print() shows that my vring_desc's addresses are 
garbage as well.

Is there an example on how to write a basic I/O remoteproc program?

Cheers,
-Paul



             reply	other threads:[~2020-12-23 10:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-23 10:57 Paul Cercueil [this message]
2021-01-06 21:52 ` Doc to write firmware? Mathieu Poirier

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=93HSLQ.5D3DAYSGVCVP@crapouillou.net \
    --to=paul@crapouillou.net \
    --cc=linux-remoteproc@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.