mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Matthias Fend <Matthias.Fend@wolfvision.net>
To: "guenter.gebhardt@rafi.de" <guenter.gebhardt@rafi.de>,
	"barebox@lists.infradead.org" <barebox@lists.infradead.org>
Subject: AW: imx53 internal boot from NAND
Date: Mon, 26 Mar 2012 11:09:40 +0200	[thread overview]
Message-ID: <0769D45835157F4282BC17DF611B07F00D1ED6910B@wolfserver9> (raw)
In-Reply-To: <OFC5456862.5E2219B4-ONC12579CD.002FB0FF-C12579CD.00304E9A@o0802.rafi.inhouse>

[-- Attachment #1: Type: text/plain, Size: 1004 bytes --]

Hi,

For a quick start you can use the provided FCB (fcb.bin).
This FCB was generated with the attached tool (fcbgen.c) - note that the bad block handling is disabled.

Then you can "merge" your barebox image with the FCB with something like:
cat fcb.bin barebox-image > barebox-fcb.bin

This works at least on our custom i.MX53 hardware.

~Matthias

Von: barebox-bounces@lists.infradead.org [mailto:barebox-bounces@lists.infradead.org] Im Auftrag von guenter.gebhardt@rafi.de
Gesendet: Montag, 26. März 2012 10:48
An: barebox@lists.infradead.org
Betreff: imx53 internal boot from NAND

Hello, 

I tried to use barebox in order to boot from NAND. 

The ROM loader needs a FCB (Firmware Configuration Block) table at the beginning of the flash (according to chapter 7.5.2.2 of the reference manual). 
I looked at the existing imx53 boards within the barebox sources but I founx that no one used this mode there. 

Has someone done this or can give me some advice? 

-- Gebhardt

[-- Attachment #2: fcbgen.c --]
[-- Type: text/plain, Size: 1875 bytes --]

/*
 * generate firmware control block (FCB) - required to boot iMX53 from NAND
 *
 * only works for 2k page NANDs
 * bad block handling of ROM bootloader is disabled
 *
 * fcb length is 4kB (2 pages)
 * image start at page 2
 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>

struct fcb_entry
{
  uint32_t addr;
  uint32_t value;
};

struct fcb_entry fcb_entries[] =
{
  { 0x00, 0x00000000 }, // res.
  { 0x04, 0x46434220 }, // fingerprint #2 (ascii FCB)
  { 0x08, 0x01000000 }, // fingerprint #3 (version)
  { 0x68, 0x02000000 }, // primary image start page (page 2)
  { 0x6C, 0x02000000 }, // secondary image start page (page 2)
  { 0x78, 0x00000000 }, // Start page address of DBBT Search Area (0 means no bad blocks)
  { 0x7C, 0x00000000 }, // Bad Block Marker Offset in page data buffer
  { 0xAC, 0x00000000 }, // Bad Block Marker Swapping Enable
  { 0xB0, 0x00000000 }, // Bad Block Marker Offset to Spare Byte
};

int main()
{
  int i, ret;
  char *fname = "fcb.bin";
  FILE *fp;
  uint8_t fcbimage[4 * 1024];

  memset(fcbimage, 0, sizeof(fcbimage));

  for(i = 0; i < (int) (sizeof(fcb_entries) / sizeof(fcb_entries[0])); i++)
  {
    if((fcb_entries[i].addr + 3) >= sizeof(fcbimage))
    {
      printf("Invalid FCB entry (index:%d)\n", i);
      continue;
    }
    fcbimage[fcb_entries[i].addr + 0] = fcb_entries[i].value >> 24;
    fcbimage[fcb_entries[i].addr + 1] = fcb_entries[i].value >> 16;
    fcbimage[fcb_entries[i].addr + 2] = fcb_entries[i].value >> 8;
    fcbimage[fcb_entries[i].addr + 3] = fcb_entries[i].value >> 0;
  }

  if((fp = fopen(fname, "w")) == NULL)
  {
    printf("could not open %s!\n", fname);
    return -1;
  }

  ret = fwrite(fcbimage, 1, sizeof(fcbimage), fp);
  printf("wrote %d bytes.\n", ret);
  if(ret != sizeof(fcbimage))
    printf("error - incomplete file!\n");
  fclose(fp);

  return 0;
}

[-- Attachment #3: fcb.bin --]
[-- Type: application/octet-stream, Size: 4096 bytes --]

[-- Attachment #4: Type: text/plain, Size: 149 bytes --]

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2012-03-26  9:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-26  8:47 guenter.gebhardt
2012-03-26  9:09 ` Matthias Fend [this message]
2012-03-26 14:46   ` Antwort: AW: " guenter.gebhardt
2012-03-27  6:35     ` AW: " Matthias Fend
2012-03-27  5:32 ` Robert Schwebel

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=0769D45835157F4282BC17DF611B07F00D1ED6910B@wolfserver9 \
    --to=matthias.fend@wolfvision.net \
    --cc=barebox@lists.infradead.org \
    --cc=guenter.gebhardt@rafi.de \
    /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