cancel
Showing results for 
Search instead for 
Did you mean: 

How can I boot from NAND if SDcard is not populated?

cfilipescu
Senior

I am trying to create a custom board that boots from SDcard if an SDcard is plugged in, however, if the SDcard is not plugged in I would like the board to boot from the NAND. I want to do this programmable without the boot switch.

Is this possible? Is there a sample project somewhere or some documentation?

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Kevin HUBER​ 

I was actually able to flash the NAND flash using dd as long as I place the images at the same offset as the tsv file. I got stuck on generating the UBIFS image as it is more work than it's worth. For the final design, I will use eMMC since it's much easier to generate an image and to flash it using dd.

As a side note programming, the NAND using the Programmer is not a good solution since it is very slow (about 30min for 300MB). From a manufacturing point of view that is expensive and time-consuming.

View solution in original post

9 REPLIES 9
PatrickF
ST Employee

Hi @cfilipescu​ ,

you should fuse OTP WORD3. e.g. to define a primary boot source as SD-Card and secondary boot source as NAND. You could probably still have SD-Card present for data storage if no valid FSBL header is present on it.

See https://wiki.st.com/stm32mpu/wiki/STM32MP15_ROM_code_overview#Boot_interface_selection

See also penultimate row of https://wiki.st.com/stm32mpu/wiki/STM32MP15_ROM_code_overview#Boot_device_selection_via_the_boot_pins_and_OTP .

Warning that OTP fusing is permanent.

Regards.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
cfilipescu
Senior

Hi @PatrickF​ ,

So if I understand correctly the following sequence would work for my use case:

  1. set boot switch = b101
  2. first boot plugin sdcard
  3. boot from sdcard
  4. fuse OTP primary to Sdcard and secondary to NAND
  5. subsequent boots will use the OTP priority

Is this correct?

If yes, can the OTP fuses be programmed from the kernel or only from uboot?

Are there any scratch OTP fuses that can be used to test out code?

On the EV1 board is the NAND a device available in the kernel in the default image?

cfilipescu
Senior

My question is also how can I make an image that boots from the NAND? Is there anything different that needs to exist in the device tree?

Hi,

yes, this sequence should be ok.

Fuses should be done either with CubeProgrammer (which use uBoot) or directly with uBoot commands/scripts.

Unfortunately, there is no scratch OTP to do trials, you should for instance use sockets on development boards of your products (this is how most customers do).

I assume your talk about NAND for parallel raw-NAND (note: there is no serial-NAND on EV1).

On EV1 Starter package, images for Raw-NAND are provided.

Regards.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
cfilipescu
Senior

@PatrickF​ 

I still can't understand how to generate a custom image and flash the NAND using the dd command.

I tried copying the sdcard image over to the NAND but nothing happened when I tried to boot from it.

Is there any documentation?

On the wiki I found something that looks promising but I can't access it:

https://wiki.st.com/stm32mpu/wiki/How_to_add_a_new_parallel_or_serial_NAND_memory_device_in_Yocto

For reference, I am using an EV1 board.

Hello @cfilipescu​ ,

You can't use dd to flash a NAND flash. DD is a tool made to be used with block devices and it realizes the copy block by block.

Which is not the case of a NAND flash that is a RAW device.

On the wiki, you can see the SDCard memory mapping: https://wiki.st.com/stm32mpu/wiki/STM32MP15_Flash_mapping#SD_card_memory_mapping

It is explained that the partitions bootfs, vendorfs, rootfs and userfs use an EXT4 file system.

Which is not the case with the NAND mapping: https://wiki.st.com/stm32mpu/wiki/STM32MP15_Flash_mapping#NAND_memory_mapping

Where these partitions are using UBIFS.

UBIFS is filesystem made to work on top of RAW flash and has nothing to do with block devices -> http://www.linux-mtd.infradead.org/doc/ubifs.html.

So it is not possible to copy the image of your SDCard to your NAND flash.

The page that you do not have access yet explains how to modify yocto to generate the UBIFS part. This page is in review and will be available later.

But the UBIFS part is only one part of the NAND mapping.

To flash the NAND device, you have to use the STM32CubeProgrammer: https://wiki.st.com/stm32mpu/wiki/STM32CubeProgrammer_flashlayout#NAND_Flash_memory_with_FIP

As explained by Patrick in its previous message, ST provides in the Starter Package for EV1, a RAW-NAND tsv and the related binaries.

If you haven't fuse the OTP yet, I advise you for your test, to populate the SDCard with STM32CubeProgrammer and the sdcard tsv layout then to populate your NAND with STM32CubeProgrammer and the nand tsv layout.

Then you can use the boot switches to verify that everything is ok and that your two sources are booting.

Once you are sure about your setup, you can fuse OTP primary to Sdcard and secondary to NAND.

Hope it helps,

Regards,

Kevin

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Hi @Kevin HUBER​ 

I was actually able to flash the NAND flash using dd as long as I place the images at the same offset as the tsv file. I got stuck on generating the UBIFS image as it is more work than it's worth. For the final design, I will use eMMC since it's much easier to generate an image and to flash it using dd.

As a side note programming, the NAND using the Programmer is not a good solution since it is very slow (about 30min for 300MB). From a manufacturing point of view that is expensive and time-consuming.

Hello @cfilipescu​ ,

Yes, you are right the CubeProgrammer is a tool for development purpose, it is not made for mass production

ST recommend to use the ST partner solution from Elprotonics : the gangflasher-st with

 https://www.elprotronic.com/pages/gangflasher-st.

Regards,

Kevin

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Hello @cfilipescu​ ,

In order to give better visibility on the answered topics, please click on 'Select as Best' on the reply which solved your issue or answered your question. See also 'Best Answers'

Regards,

Kevin

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.