How to flash the SPI NOR Flash with just U-boot

Hello,

I am trying to flash just the U-boot bootloader to the SPI Flash on the Jetson-TK1 board. I am doing this with the command:

sudo ./nvflash --bct PM375_Hynix_2GB_H5TC4G63AFR_H5TC4G63CFR_RDA_924MHz.cfg --setbct --configfile flash.cfg --create --bl fastboot.bin --odmdata 0x6009C000 --go

Where the flash.cfg has most partitions removed except for BCT and EBT. My flash.cfg looks like this:

[device]
type=spi
instance=3

[partition]
name=BCT
id=2
type=boot_config_table
allocation_policy=sequential
filesystem_type=basic
size=10016
file_system_attribute=0
partition_attribute=0
allocation_attribute=8
percent_reserved=0

[partition]
name=EBT
id=5
type=bootloader
allocation_policy=sequential
filesystem_type=basic
size=440000
file_system_attribute=0
partition_attribute=0
allocation_attribute=8
percent_reserved=0
filename=u-boot.bin

The SPI Flash has about 4MB of space so these partition sizes should fit.

Here is the output of the nvflash command I showed above:

austin@austin-VirtualBox:~/Desktop/Tegra/Linux_for_Tegra/bootloader$ sudo ./nvflash --bct PM375_Hynix_2GB_H5TC4G63AFR_H5TC4G63CFR_RDA_924MHz.cfg --setbct --configfile flash.cfg --create --bl fastboot.bin --odmdata 0x6009C000 --go
Nvflash 4.13.0000 started
BR_CID: 0x34001001741141021c00000015fc8400
rcm version 0X400001
Skipping BoardID read at miniloader level
System Information:
   chip name: unknown
   chip id: 0x40 major: 1 minor: 1
   chip sku: 0x0
   chip uid: 0x00000001741141021c00000015fc8400
   macrovision: disabled
   hdcp: disabled
   jtag: disabled
   sbk burned: false
   board id: 0
   warranty fuse: 0
   dk burned: false
   boot device: spi
   operating mode: 3
   device config strap: 0
   device config fuse: 0
   sdram config strap: 0

RCM communication completed
Unsupported parameters
failed executing command 4 NvError 0x4 
setbct failed NvError 0x0
command failure/warning: bootloader download failed

And here is what the Miniloader is showing on the other side:

[0000.000] [TegraBoot] (version UNDEF_BUILD)
[0000.004] Reset reason: power on reset
[0000.007] Processing in recovery mode
[0000.011] Established communication link with host

What is interesting is that when I use a different device within the flash.cfg (sdmmc):

[device]
type=sdmmc
instance=3

[partition]
name=BCT
id=2
type=boot_config_table
allocation_policy=sequential
filesystem_type=basic
size=10016
file_system_attribute=0
partition_attribute=0
allocation_attribute=8
percent_reserved=0

[partition]
name=EBT
id=5
type=bootloader
allocation_policy=sequential
filesystem_type=basic
size=440000
file_system_attribute=0
partition_attribute=0
allocation_attribute=8
percent_reserved=0
filename=u-boot.bin

I get further along in the flashing process but it still fails to flash. With the sdmmc as the type of device in the flash.cfg, here is the host nvflash and target output respectively.

HOST

austin@austin-VirtualBox:~/Desktop/Tegra/Linux_for_Tegra/bootloader$ sudo ./nvflash --bct PM375_Hynix_2GB_H5TC4G63AFR_H5TC4G63CFR_RDA_924MHz.cfg --setbct --configfile flash.cfg --create --bl fastboot.bin --odmdata 0x6009C000 --go
Nvflash 4.13.0000 started
BR_CID: 0x34001001741141021c00000015fc8400
rcm version 0X400001
Skipping BoardID read at miniloader level
System Information:
   chip name: unknown
   chip id: 0x40 major: 1 minor: 1
   chip sku: 0x0
   chip uid: 0x00000001741141021c00000015fc8400
   macrovision: disabled
   hdcp: disabled
   jtag: disabled
   sbk burned: false
   board id: 0
   warranty fuse: 0
   dk burned: false
   boot device: spi
   operating mode: 3
   device config strap: 0
   device config fuse: 0
   sdram config strap: 0

RCM communication completed
Unsupported parameters
BCT sent successfully
odm data: 0x6009c000
downloading bootloader -- load address: 0x83d88000 entry point: 0x83d88000
sending file: fastboot.bin
- 594363/594363 bytes sent
fastboot.bin sent successfully
waiting for bootloader to initialize
bootloader downloaded successfully
ML execution and Cpu Handover took 1 Secs
Partition backup took 0 Secs
setting device: 2 3
deleting device partitions
creating partition: BCT
failed executing command 17 NvError 0x120002
command failure/warning: create failed (bad data)
bootloader status: specified device is invalid (code: 6) message: nverror:0x4 (0x4) CreatePartition 1756 flags: 0

TARGET

[0000.000] [TegraBoot] (version UNDEF_BUILD)
[0000.004] Reset reason: power on reset
[0000.007] Processing in recovery mode
[0000.011] Established communication link with host
[0001.031] Downloaded bct successfully 
[0001.058] No Battery Present
[0001.062] Sdram initialization is successful 
[0001.152] Downloaded bootloader successfully 
[0001.156] CPU-bootloader entry address: 0x83d88000 
[0001.161] BoardId: 375
[0001.163] Vpr Carveout Base=0x0f4600000 Size=0x00ba00000
[0001.168] Tsec Carveout Base=0x0f2600000 Size=0x002000000
[0001.173] Lp0 Carveout Base=0x0f25ff000 Size=0x000001000
[0001.178] Xusb Carveout Base=0x0f2300000 Size=0x000200000
[0001.183] Platform-DebugCarveout: 0
[0001.210] CPU power rail is up 
[0001.213] Performing RAM repair
[0001.216] CPU clock init successful 
[0001.220] Starting CPU & Halting co-processor
NVRM Initialized shmoo database
NVRM CLOCKS: PLLX0:      696000 Khz
NVRM CLOCKS: PLLM0:      924000 Khz
NVRM CLOCKS: PLLC0:      0 Khz
NVRM CLOCKS: PLLP0:      408000 Khz
NVRM CLOCKS: PLLA0:      11289 Khz
NVRM CLOCKS: CPU:        696000 Khz
NVRM CLOCKS: AVP:        48000 Khz
NVRM CLOCKS: System Bus: 48000 Khz
NVRM CLOCKS: Memory Controller: 924000
NVRM CLOCKS: External Memory Controller: 924000
EEPROM instance-5: No slave at this instance.
EEPROM instance-0: No slave at this instance.
EEPROM instance-0: Querying board info from BCT.
EEPROM instance-0: No board info available for this instance in BCT.
EEPROM instance-1: No slave at this instance.
EEPROM instance-1: Querying board info from BCT.
EEPROM instance-1: Board info present in BCT is invalid.
EEPROM instance-2: No slave at this instance.
EEPROM instance-2: Querying board info from BCT.
EEPROM instance-2: No board info available for this instance in BCT.
EEPROM instance-3: No slave at this instance.
EEPROM instance-3: Querying board info from BCT.
EEPROM instance-3: No board info available for this instance in BCT.
EEPROM instance-4: No slave at this instance.
EEPROM instance-4: Querying board info from BCT.
EEPROM instance-4: Board info present in BCT is invalid.
EEPROM instance-5: No slave at this instance.
EEPROM instance-5: Querying board info from BCT.
EEPROM instance-5: Board info present in BCT is invalid.
EEPROM instance-6: BoardInfo: 0x0001:0x0007:0375:0000:03:B:00:0xff:0xff:0xff:0xff:0xff:0xff
EEPROM instance-7: No slave at this instance.
EEPROM instance-7: Querying board info from BCT.
EEPROM instance-7: No board info available for this instance in BCT.
Final BoardID: proc: 375 and pmu 375
ADJUSTED CLOCKS:
MC clock is set to 924000 KHz
EMC clock is set to 924000 KHz (DDR clock is at 924000 KHz)
PLLX0 clock is set to 696000 KHz
PLLC0 clock is set to      0 KHz
CPU clock is set to 696000 KHz
System and AVP clock is set to  48000 KHz
GraphicsHost clock is set to 163200 KHz
MSENC clock is set to  92400 KHz
Vde clock is set to 204000 KHz

Bootloader-Cpu Init at (time stamp): 10005511 us

Pinmux changes applied in kernel way

[bootloader] (version UNDEF_BUILD)
Platform Pre Boot configuration...
NvDdkUsbhBlockDevInit..
Initializing Display
The proc BoardInfo: 0x0177:0x0000:0x03:0x42:0x00
The proc BoardInfo: 0x0177:0x0000:0x03:0x42:0x00
This Pmu Module is not present.
The best display mode is 2560x1600/60Hz, pclk: 268627Khz

DSI PAD calibration done

DSI PAD calibration done

DSI PAD calibration done

DSI PAD calibration done
Entering NvFlash recovery mode / Nv3p Server

Nv3pServer Version 4.13.0000

***: DecodeCSD:
   : readBlkBits=9, readBlkSize=512 Bytes
   : nSectors=(CSIZE+1)*(2**(CSizeMult+2))=4096 * 512 = 2097152 Sectors
   : writeBlkBits=9, writeBlkSize=512 Bytes
   : ERASE_GRP_SIZE=31, ERASE_GRP_MULT=31
   : EraseGrpSize=(31+1)*(31+1)=1024 Sectors (524288 Bytes)
   : WPGrpSize=31744 Sectors (16252928 Bytes)
***: ReadExtCSD:
   : overriding USER Sectors = 30777344 Sectors
   : keep CSD EraseGrpSize = 1024 Sectors (524288 Bytes)
   : keep CSD WPGrpSize = 31744 wBlks (16252928 Bytes)
   : BootPartSize = 4194304 Bytes (8192 Sectors)
***: SetBlockSize to 512 Bytes SKIPPED because CMD16 is illegal for DDR50...
***: SdGetDevInfo: PagesPerBlock = 32 pages (256 Sectors)
***: SdGetDevInfo: TotSecs=TotBlk(120288)*PgPerBlk(32)*SecsPerPg(8)=30793728
Region=1 SD Erase start 512B-sector=0,512B-sector-num=8192 
Region=2 SD Erase start 512B-sector=0,512B-sector-num=8192 
Region=0 SD Erase start 512B-sector=0,512B-sector-num=30777344 
CreatePartition failed. NvError 4 NvStatus 6

Hi aowens, please attach flash.cfg for reference.

So you don’t boot to Linux kernel in your case? What is the purpose? We have implementation based on Linux and it may not work if it only boots to bootloader.

Hi DaneLLL,

I thought I was already displaying the flash.cfg?

I do plan on booting to Linux, but the SPI flash is too small to fit a the kernel and rootfs on. As a result, I was planning on flashing the SPI Flash with U-Boot and once U-Boot is up and running, I was going to use U-Boot’s UMS (USB Mass Storage) support to flash the eMMC over USB.

So flashing would be something like this:

  1. Miniloader gets fastboot from host (Fastboot now running on target)
  2. Fastboot flashes SPI flash with bare minimum required to get U-Boot up and running.
  3. Go into U-Boot shell and flash eMMC with whats required to get Linux and rootfs up and running

Booting would be something like this:

  1. Boot ROM code executes and loads up U-Boot
  2. U-Boot finds kernel in eMMC
  3. U-Boot launches kernel

Hi aowens,
Please refer to
https://devtalk.nvidia.com/default/topic/865125/jetson-tk1/is-the-spi-boot-flash-on-jetson-in-use-/post/4728455/#4728455

Hi DaneLLL,

Yes, I have already seen that thread before and it does not help me. I have already configured the boot strap resistors accordingly.

I feel the responses to the question on that thread was rather open-ended. GE_Chen seems to primarily be talking about accessing SPI through userspace by modifying the device tree source to have the spidev driver probe the dts file to make a device driver within /dev. I have done this before but that fix doesn’t seem to apply to this particular problem where the kernel is not currently booting up and a dts is not being utilized since this is before even u-boot runs.

Is there any recommendations you have for getting it to flash to SPI flash properly?

Hi aowens, I am sorry but this is not supported on r21.5

Hi DaneLLL,

Why put the SPI flash device on the Jetson board where Nvidia claims it can be used as a booting device, and even have boot strap resistors built into the design to boot from SPI flash, yet not have support to flash the device?

This is just speculation, but perhaps flash could be accomplished via a JTAG debugger (this is quite expensive, it wouldn’t necessarily work, but it would bypass needing the boot loader to do the work).

Hi linuxdev,

I was also thinking along those lines, but I wanted to prevent additional hardware dependencies when needing to flash the chip if at all possible.

Hi,
We have the hardware design, but the software is not ready in the public release r21.5.

Hi DaneLLL,

Thank you for this information. Can you provide a rough timeframe for when we can expect the software to support SPI ROM flashing via the TK1?

Thank you,
Sebastian

As of now we have no plan to support it on TK1.