描述
This is a list of required items, necessary actions, and points to be considered, when debugging NAND programming and booting on Zynq UltraScale+ MPSoC.
Some UBIFS tips are included in this article.
解决方案
Before opening a Service Request, collect all of the information requested below.
Requirements are italicized below.
1) Is the NAND flash and configuration supported by Xilinx?
See (Xilinx Answer 65463) to determine the support category (Supported, known to work, Unverified, or Incompatible).
Note: For NAND requirements, see (UG1085) chapter 25.
Important: Please provide the full flash name, the configuration mode and the voltage. If the configuration is not "standard" (muxes, level shifters or other), provide also the board schematics.
2) Are the signals properly connected to the memory device?
The board needs to follow the instructions for NAND in (UG583).
To boot from NAND, MIO10 should be connected to ready/busy 0 of the NAND device.
Please provide a schematic of the NAND part and monitor the data signals on the board to verify what kind of words are read.
3) Is it Zynq Production Silicon?
Use XSCT to read:
- the IDCODE from 0xFFCA0040
- the PS_VERSION from 0xFFCA0044
Important: Please provide the IDCODE and PS_VERSION
4) Is the JTAG chain operating properly?
Use XSCT to try to connect to the CPU.
Below is a list of relevant Answer Records:
(Xilinx Answer 67740) | XSDB (or any other JTAG user) needs to hold TMS signal high for 5 TCK cycles to enable PL TAP linking to the JTAG chain. |
(Xilinx Answer 67818) | 2016.3 PMU firmware loading via JTAG / SD Boot Modes and Running An Example |
Important: Please provide JTAG chain description (how many devices on the chain, how many ZynqMP, ZynqMP in cascade or independent JTAG, any level shifter in the chain). Report any XSCT error.
5) In which phase of booting Zynq is failing? BootROM or FSBL?
For Known Issues related to FSBL and CSU Boot Rom, Please check (Xilinx Answer 65467)
In order to determine this, program an image with FSBL debug prints enabled.
To do this, include the following in xfsbl_debug.h
#define FSBL_DEBUG_DETAILED
If some printing comes out on the UART during boot:
Please provide a log of the FSBL print out on the UART. FSBL is a user application and can be easily debugged using SDK. Try to do a brief investigation before filing a Service Request.
If nothing comes out on the UART during boot, first double check the UART baudrate.
Please provide the status of INIT_B, PS_ERROR_OUT, CSU_BR_ERROR and BOOT_MODE_POR registers after the boot failure.
An easy way to provide this register dump is to use the attached .tcl script (boot_registers_log_revX_Y.tcl)
If the boot image was not programmed properly, continue to step 5.
6) Are SDK and Vivado failing to program?
- Vivado and SDK flash programmer use mini u-boot to program flash. NAND read/write support had been there in u-boot, but was not updated in Vivado/SDK 2017.2 and previous versions.
In Vivado/SDK 2017.3, the mini u-boot image will be updated. Please use Vivado/SDK 2017.3 and later versions to program NAND flash.
- For debug purposes, the Debug Environmental Variable XIL_CSE_ZYNQ_DISPLAY_UBOOT_MESSAGES can be set to 1.
See (Xilinx Answer 59272) for more details.
Please provide the version of the tool used. Be sure your image was built with the same version of the tool as was used to program.
Please provide the boot mode settings used for programming (booting from JTAG is recommended).
Please provide the log obtained using the XIL_CSE_ZYNQ_DISPLAY_UBOOT_MESSAGES variable.
7) Is it working using u-boot?
For known issues related to u-boot, Please check (Xilinx Answer 65467)
You can use PetaLinux to generate the u-boot elf. PetaLinux uses ZCU102 defconfig by default. NAND is not enabled in that configuration.
"CONFIG_CMD_NAND=y" and "CONFIG_NAND_ARASAN=y" should be set.
To do this, you can open u-boot menuconfig with the following command
petalinux-config -c u-boot
You can find the two parameters separately at the following menu locations:
"Command line interface > Device access commands > nand" and "Device Drivers > NAND Device Support > Configure Arasan Nand".
You can also use an open source flow to generate the u-boot elf by following the steps in http://www.wiki.xilinx.com/Build+U-Boot#Zynq
You need to set "CONFIG_CMD_NAND=y" and "CONFIG_NAND_ARASAN=y" in the selected defconfig file.
Download and run u-boot elf with xsct/xsdb according to the flow in (UG1209).
Use the below commands to test NAND flash.
nand info
nand erase 0 1000000
mw.b 1000000 a8 1000000
nand write 1000000 0 1000000
nand read 2000000 0 1000000
cmp.b 1000000 2000000 1000000
If the read data is same as the data written, NAND read/write should be good.
Please provide the log of the programming. Specify the u-boot version used.
If u-boot is working, use xsct/xsdb and the u-boot nand write command to program the NAND flash with the desired BOOT.bin.
8) Is the board design to support the NAND frequency used for programming?
Please provide the register settings and the calculation done to verify the NAND clock frequency.
9) Is the Xilinx stand-alone example working?
NAND examples are provided under the SDK install directory \data\embeddedsw\XilinxProcessorIPLib\drivers\nandpsu_v1_x\examples
Some Debug is needed to understand where the example is failing (through the SDK debugger or by adding debug prints).
Report the type of failure in the Xilinx standalone example
UBIFS support for NAND flash
UBI is an abstraction layer that works on top of MTD raw flash devices.
It is worth noting that raw flash is not the typical pen-drive, memory card, or SSD but it is a flash chip without a FTL (Flash Translation Layer).
UBI is usually used as a supporting layer for the UBIFS filesystem.
It is a successor to JJFS2 which does not use a supporting layer like UBI but works directly on MTD devices.
- http://www.linux-mtd.infradead.org/doc/ubifs.html
- http://www.linux-mtd.infradead.org/doc/ubi.html
- http://www.linux-mtd.infradead.org/faq/ubi.html
- http://www.linux-mtd.infradead.org/faq/ubifs.html
U-BOOT:
In 2017.2, u-boot supports UBIFS for ondie-ECC NAND flash. For NAND flash without ondie-ECC, UBIFS will be supported in u-boot 2018.1.
To use UBIFS in u-boot, we need enable UBI commands in u-boot configuration. To do this, we need run the following command to open u-boot configuration.
petalinux-config -c u-boot
Enable the UBI command at "Command Line interface > Enable UBI - Unsorted block images commands". Verify UBI is also enabled at "Device Drivers > UBI support".
With UBIFS configured in u-boot, PetaLinux 2017.2 fails to compile u-boot with a link error for the missing reference.
See (Xilinx Answer 69757) PetaLinux 2017.2 - PetaLinux fails to compile u-boot with link error after UBI command line is enabled.
Steps to create UBIFS image at host:
- Download "gen_fs_s.sh" "ubinize_s.cfg" "devtable.txt" "targetroot.zip" and extract the target root.
- Now generate the UBI image at the host using the script gen_fs_s.sh. Run it as ./gen_fs_s.sh
- Now, the UBI image will be created in the current directory. "rootfs_nand_s.ubi" is pre-built and ready for use.
u-boot commands to format, copy and mount ubifs:
setenv partition "nand0,3"
setenv mtdids "nand0=nand0.0"
setenv mtdparts "mtdparts=nand0.0:896k(boot),128k(env),7m(kernel),8m(rootfs)"
Note: Before running the below steps, as per the example here, download the image created above (rootfs_nand_s.ubi) to DDR at 0x100000.
nand erase 800000 800000
nand write 100000 800000 800000
ubi part rootfs
ubifsmount ubi0:myubifs
You can refer to uboot_ubifs.log for detail of each step.
To verify if ubifs works well, you can load the file in ubifs to memory in u-boot and compare with its source file.
Linux:
In 2017.2, PetaLinux cannot correctly generate the NAND partition node in the device tree, and Linux cannot recognize the partitions defined with petalinux-config menuconfig.
See this article for a work-around.
(Xilinx Answer 69759) 2017.2 - Device tree generator cannot generate the NAND partition node according to the arasan nand template.
- How do I enable UBI?
In the Linux configuration menu, go to "Device Drivers" > "Memory Technology Devices (MTD)" > "UBI - Unsorted block images", and mark the "Enable UBI" check-box.
- How do I enable UBIFS?
Because UBIFS works on top of UBI, you have to enable UBI first.
Then in the Linux configuration menu, go to "File systems" > "Miscellaneous filesystems", and mark the "UBIFS file system support" check-box.
How do I enable UBIFS command?
In PetaLinux ROOTFS configuration menu, go to "Filesystem Packages" > "base" > "mtd-utils", and mark the "mtd-utils-ubifs" check-box.
PetaLinux 2017.2 can support UBIFS for NAND flash with ondie-ECC or only HW-ECC.
The following demo shows the commands to create UBIFS on mtd0. You can create it on other partitions.
You can find "total LEB size" and "available LEB size" with the ubiattach command.
Make sure the "available LEB size" is big enough (likely more than 100MB).
If not, you can increase the partition size.
ZynqMP> ubiformat /dev/mtd0 -e 0 -y
ZynqMP> ubiattach -p /dev/mtd0
ZynqMP> ubimkvol -N data -m /dev/ubi0
ZynqMP> mount -t ubifs ubi0:data /mnt
With these commands, UBIFS has been created in mtd0. You can copy files to it and the files will be saved on flash.
After a power cycle, you can use the ubiattach command to attach the UBIFS and mount again.
ZynqMP> cp /bin/* /mnt
board power off
board power on
ZynqMP> ubiattach -p /dev/mtd0
ZynqMP> mount -t ubifs ubi0:data /mnt
ZynqMP> ls /mnt