Olimex Support Forum

OLinuXino Android / Linux boards and System On Modules => A20 => Topic started by: djagab on February 24, 2016, 02:19:25 PM

Title: How to boot from NAND with an SD card still inserted?
Post by: djagab on February 24, 2016, 02:19:25 PM
I have an Olinuxino-micro 4G board with the latest debian image installed to NAND and made it read-only.
The parts that need writing are moved to SD (via symbolic links or directly). On the SD card I have one partition that
is mounted at boot time (via Fstab). Unfortunately the olinuxino reads the SD card at boot time and decides to wait for valid boot material in TFTP mode in stead of switching over to NAND. Without the SD card the olinuxino is capable of booting to NAND just fine. I would like to be able to boot from NAND without having to remove and re-insert the SD card right after boot (when the green light starts flashing), is this possible?

Thanks in advance....
Title: Re: How to boot from NAND with an SD card still inserted?
Post by: djagab on February 25, 2016, 11:12:21 AM
Any one??
Title: Re: How to boot from NAND with an SD card still inserted?
Post by: JohnS on February 25, 2016, 01:19:20 PM
http://linux-sunxi.org/BROM

You'd have to put code on the SD to boot from NAND or omit boot code from the SD.

John
Title: Re: How to boot from NAND with an SD card still inserted?
Post by: djagab on February 26, 2016, 12:23:01 PM
Thanks for you reply.
I read the sunxi page you supplied via the link.
But, could you be more specific as to which code to add to SD or better... to remove?
Title: Re: How to boot from NAND with an SD card still inserted?
Post by: JohnS on February 26, 2016, 01:05:02 PM
So the idea is pick one of:
1. make the SD non-bootable so the BROM goes on to the NAND
2. put a bootloader on the SD that jumps to the NAND

I fancy #1 more than #2.

Have a look at the BROM etc.  I think it wants a magic pattern on the SD.  If so you just need to make sure your SD does not have it.

Try a blank SD.  If the BROM goes past it to the NAND then you know this idea is workable, but not yet the part it checks.  That'll be on the sunxi site, maybe on the BROM page.

Now bear in mind that almost any image for an SD that you find will be making sure it DOES have that pattern.  So if you use one of those you'll have to overwrite the magic part.  (dd is good for this stuff.)

John
Title: Re: How to boot from NAND with an SD card still inserted?
Post by: djagab on February 26, 2016, 02:36:39 PM
Thanks.
By magic pattern you mean the files like u-boot.bin and sunxi-spl.bin that are written outside the bounds of any partition, right?
Title: Re: How to boot from NAND with an SD card still inserted?
Post by: JohnS on February 26, 2016, 02:58:10 PM
Probably not.  Hunt around the linux-sunxi site for how BROM works.

John
Title: Re: How to boot from NAND with an SD card still inserted?
Post by: JoseQ on February 26, 2016, 02:59:22 PM
Is there a way to force to boot from NAND "if" the image on the SD card is corrupted?

I did some tests in the A20-Lime2: Debian in NAND, Debian in uSD card.

I intentionally corrupted the image on the SD card, and it gets blocked, UART outputs this:


  reading uEnv.txt
  ** unable to read file uEnv.txt
  Failed to mount ext2 filesystem
  ** Unrecognized filesystem type
  reading boot.scr
  ** unable to read file boot.scr
  Failed to mount ext2 filesystem
  reading uImage
  ** Booting kernel from Legacy Image at 480000000 ...
    Image Name: Linux-3.5.90
  ...
  ...
  ...
  verifying Checksum ... Bad Data CRC
ERROR: can't get kernel image!
sun7i#


Probably not, but I would like to hear your opinions.

Thank you guys!
Title: Re: How to boot from NAND with an SD card still inserted?
Post by: JohnS on February 26, 2016, 03:04:31 PM
grrr.... I just answered your other version of the question!!

John
Title: Re: How to boot from NAND with an SD card still inserted?
Post by: JoseQ on February 26, 2016, 03:08:07 PM
Thank you JohnS,

And sorry, I've just read your answer.
Title: Re: How to boot from NAND with an SD card still inserted?
Post by: JoseQ on February 26, 2016, 03:13:15 PM
JohnS,
As you pointed:
It boots with a blank SD card.
And also in the case of a corrupted SD card, the bootloader starts and it looks that there is no way to "fallback" and boot from NAND.

Thank you!
Title: Re: How to boot from NAND with an SD card still inserted?
Post by: djagab on February 26, 2016, 03:21:19 PM
By using the following command: dd if=/dev/zero of=/dev/sdc bs=1k count=1023 seek=1
I was able to remove the thing that John calls 'magic' while keeping the partition table in tact.
The board boots from NAND and my SD partition gets mounted right.
Thanks for pointing me in the right direction. Still would like to know the facts behind 'magic pattern', though. ;)
Title: Re: How to boot from NAND with an SD card still inserted?
Post by: JohnS on February 26, 2016, 03:50:54 PM
Almost for sure is on linux-sunxi.org

Hunt around with words like
boot
rom
brom

Fallback can probably be done if you think more (and read more of that site)...

John