UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Visitor kg.calrec
Visitor
11,017 Views
Registered: ‎11-09-2015

Stuck trying to get JFFS2 working

I have a petalinux system running very nicely on Initramfs, which is the default. I'm now trying to change to JFFS2 so that I can have a writable filesystem. Initramfs and JFFS2 both appear to be officially supported in Petalinux, so this should be an easy transition.

 

Here's what I did:

  1. Added support for JFFS2 filesystems to the kernel
  2. Configured Petalinux to use JFFS2 as it's root filesystem
  3. Added a "jffs2" partition to the Petalinux partition tree.
  4. Adjusted the erase block size in the config to match my flash chip, 256 Kib.
  5. Compiled using "petalinux-build". This now creates an additional image file, rootfs.jffs2
  6. Previously I would use "petalinux-package --boot" to create an MCS file that I could write to flash. However the "petalinux-package" utility doesn't include the option to add the JFFS2 image to the MCS. So instead I built the MCS without the JFFS2 image, then added it to the MCS using external tools. I now have an MCS that includes bitstream, block ram, U-Boot, linux kernel, and JFFS2 filesystem.
  7. Write this MCS to the flash chip using Vivado. (NOTE: I'm convinced that the literal rootfs,jffs2 file now resides at the correct place in flash, but Is this a valid thing to do? Is there a wrapper or header in the file I should be removing?)
  8. Try to boot

Here's the result:

  1. FS-Boot starts and loads U-Boot from flash
  2. U-Boot detects the flash, loads the kernel image, and starts it booting
  3. The kernel gets to the point where it tries to access the filesystem, and fails with this message:
VFS: Cannot open root device "(null)" or unknown-block(0,0): error -6
Please append a correct "root=" boot option; here are the available partitions:
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
---[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)

I'm clearly doing something wrong, but I can't find any documented step I'm not following. The error message appears to suggest that I need to manually edit the boot args that U-Boot passes to the kernel. Is this true? What value should I set? None of the documentation I can find seems to go this far.

 

Thanks.

Tags (2)
19 Replies
Visitor kg.calrec
Visitor
10,616 Views
Registered: ‎11-09-2015

Re: Stuck trying to get JFFS2 working

Bump. 400 views and not a single response? I thought XIlinx were supposed to to have experts working in each forum.

0 Kudos
Xilinx Employee
Xilinx Employee
10,597 Views
Registered: ‎09-10-2008

Re: Stuck trying to get JFFS2 working

Hi,

 

To help get people more interested in helping it may help to show what you've learned in another post such that it appears you're still digging and trying.

 

It's been a while for me since I did JFFS2.  For most filesystem things like this I would try to boot off of the ramdisk and then try to mount the filesystem rather than booting from it, just my methods as easier to debug sometimes.  I'm giving you hints here as I've not tried to reproduce it all.

 

A quick google shows some details that look worthwhile.  This is generally not Xilinx specific, just normal booting from JFFS2 as all others do also.

 

http://www.denx.de/wiki/view/DULG/RootFileSystemOnAJFFS2FileSystem

https://forums.xilinx.com/t5/Embedded-Linux/Creating-JFFS2-file-system/td-p/658133

 

The kernel command line does need to be altered to specify the root filesystem as shown in that 1st link. You can alter them in Petalinux configuration or alter the device tree if you know how to override the existing bootargs section.

 

Are you sure the package command in Petalinux won't add the JFFS image also?

 

--jffs2[=] Update JFFS2 partition with JFFS2IMG (default images/jffs2.img)

 

Thanks

John

Observer naveeng
Observer
10,458 Views
Registered: ‎11-25-2015

Re: Stuck trying to get JFFS2 working

Hi,

 

Kernel is failing to mount your jffs2 root filesystem, There might also be the reason that mtd drivers are not enabled in your kernel and are needed for mounting your filesystem.

 

Can you please verify it?

 

Was your jffs2 compilation and mtd partitioning successful without any warnings?

 

Thanks,

Naveen

 

 

0 Kudos
Visitor kg.calrec
Visitor
10,450 Views
Registered: ‎11-09-2015

Re: Stuck trying to get JFFS2 working

Hi Naveen

 

Yes you're right the mtd system is failing to initialise, I'm not sure why. As far as I can tell it compiles without problem, I've attached the verbose compile output producd by "petalinux-build". I'm also attaching the kernel, rootfs, and generic configs from "petalinux-config".

 

Please let me know if you need me to provide something else.

 

Thanks for your help Naveen, it's much appreciated.

 

Keith

0 Kudos
Visitor kg.calrec
Visitor
10,449 Views
Registered: ‎11-09-2015

Re: Stuck trying to get JFFS2 working

Also here's the device tree files...

0 Kudos
Observer naveeng
Observer
10,298 Views
Registered: ‎11-25-2015

Re: Stuck trying to get JFFS2 working

Hi Keith,


Let's look into your configuration files step by step:

STEP 1: Enabling the MTD support
To enable MTD support in your kernel, go to Kernel configuration -> Device Drivers and enable “MTD support” (CONFIG_MTD).

Below is the snippet from your kernel config file:
#
# Bus devices
#
# CONFIG_CONNECTOR is not set
CONFIG_MTD=y
# CONFIG_MTD_TESTS is not set
# CONFIG_MTD_REDBOOT_PARTS is not set

Dependancies:
CONFIG_GENERIC_IO=y

MTD support and dependancies are enabled.

 

 

STEP 2: Choosing the appropriate Chip driver

Based on the type of flash device, we need to enable support for it. To do this, in Kernel configuration -> Device Drivers -> MTD support -> go to sub-menu for RAM/ROM chip drivers and enable the specific chip driver. Chip drivers implement low level support for the NAND and NOR flash devices. MTD has drivers for the NOR flash devices that implement standard specifications such as CFI and JEDEC. MTD supports various CFI command sets defined by CFI specification, as kernel modules. The command set supported by a flash device can be enabled from the kernel configuration (Device Drivers -> MTD support -> go to sub-menu for RAM/ROM chip drivers)

Below is the snippet from your kernel config file:
#
# RAM/ROM/Flash chip drivers
#
CONFIG_MTD_CFI=y
CONFIG_MTD_JEDECPROBE=y
CONFIG_MTD_GEN_PROBE=y
CONFIG_MTD_CFI_ADV_OPTIONS=y
CONFIG_MTD_CFI_NOSWAP=y

Dependancies:
CONFIG_MTD=y

 


You have enbaled for CFI compliant(CONFIG_MTD_CFI) as well as non-compliant(CONFIG_MTD_JEDECPROBE) flash devices.


STEP 3: Choosing the Map driver
The MTD subsystem uses map drivers to access the flash devices. A map driver maps the flash device for CPU access and informs the MTD about the storage partitions available on the flash device. We can either use the existing map drivers in the MTD or write our own drivers, to access a standard flash device.

The cfi flash connected to a EMC core on Xilinx boards can be accessed in one of the following two ways.
1. CFI Flash device in physical memory map - Select this option if you want to physically configure the flash device for CPU access.
In Kernel configuration -> Device Drivers -> MTD support -> go to sub-menu for “Mapping Drivers for chip access” and enable “Flash device in physical memory map” (CONFIG_MTD_PHYSMAP) and specify the physical start address, physical length, and bank width from again selecting 'Physmap compat support'. This option uses physmap.c (/drivers/mtd/maps/) driver to register the flash device.
You need to again go to Kernel configuration -> Device Drivers -> MTD support -> RAM/ROM chip drivers and enable ‘Flash chip driver advanced configuration options’-> ‘Specific CFI flash geometry selection’ and enter the bus width and chip interleave based on your hardware configuration.

2. Flash device in physical memory map based on OF description - Select this option if you want the map driver to configure the flash device for CPU access, based on device tree.
This is the preferred method of accessing the EMC flash, as it doesn’t involve any overhead. The associated driver (drivers/mtd/maps/physmap_of.c) parses the device tree and registers the EMC flash, based on the information from the device tree.
In Kernel configuration -> Device Drivers -> MTD support -> go to sub-menu for “Mapping Drivers for chip access” and enable “Memory device in physical memory map based on OF description” (CONFIG_MTD_PHYSMAP_OF).

 


From your kernel config snippet as below, you have enabled both the above methods. Generally you can choose either one of them. (Please also check for dependancies from help bar on each configurable feature before selecting to resolve any dependancies)
#
# Mapping drivers for chip access
#
CONFIG_MTD_COMPLEX_MAPPINGS=y
CONFIG_MTD_PHYSMAP=y
# CONFIG_MTD_PHYSMAP_COMPAT is not set
CONFIG_MTD_PHYSMAP_OF=y
# CONFIG_MTD_GPIO_ADDR is not set
# CONFIG_MTD_PLATRAM is not set
# CONFIG_MTD_LATCH_ADDR is not set

 

 

STEP 4: Creating partitions on the flash

To create partitions, enable “MTD partitioning support” (CONFIG_MTD_PARTITIONS) in Kernel configuration -> Device Drivers -> MTD support. Partitions can be dynamically created on the flash device through one of the following three ways.
I. Command Line partition table parsing
II. Redboot partition table parsing
III. Flash partition map based on OF description


To create partitions on the flash through command line do the following.
• In MTD support, enable “Command line partition table parsing” (CONFIG_MTD_CMDLINE_PARTS).


From your kernel config snippet, you have selected I and III options(CONFIG_MTD_CMDLINE_PARTS, CONFIG_MTD_OF_PARTS) :
#
# Bus devices
#
# CONFIG_CONNECTOR is not set
CONFIG_MTD=y
# CONFIG_MTD_TESTS is not set
# CONFIG_MTD_REDBOOT_PARTS is not set
CONFIG_MTD_CMDLINE_PARTS=y
CONFIG_MTD_OF_PARTS=y
# CONFIG_MTD_AR7_PARTS is not set

 

I. To use the 1st method, in the device tree, add the partition table to “bootargs”. The format for the command line partition table is as follows:
   mtdparts=<mtddef>[;<mtddef]
  where:
<mtddef>  := <mtd-id>:<partdef>[,<partdef>]
<mtd-id>  := unique id used in mapping driver/device
<partdef> := <size>[@offset][<name>][ro]
<size>    := standard linux memsize OR "-" to denote all remaining space
<name>    := (NAME)

Ex: Let’s assume that you have a cfi-flash, of size 8MB, mapped to physical memory at 0x80800000 and have enabled CONFIG_MTD_PHYSMAP_OF. If you want to create three partitions named bootloader (size=512K), kernel (size=1M) and rootfs (size=rest of the flash), then add the following to the kernel command line. The parameter ro makes a partition read-only.

mtdparts=80800000.flash: 512K(bootloader)ro,1M(kernel)ro, -(rootfs)


II. Redboot partition table parsing
The Redboot bootloader maintains a partition table that holds flash layout, so if you are using Redboot on your embedded device, you can configure your flash partitions in the bootloader. To do this, turn on CONFIG_MTD_REDBOOT_PARTS along with the MTD partitioning support during kernel configuration.


III. Flash partition map based on OF description
To create partitions from device tree, enable CONFIG_MTD_OF_PARTS in the kernel configuration. The partitions have to be manually defined in the device tree. The map driver parses the device tree and creates partitions accordingly.
Ex:
FLASH_2Mx32: flash@80800000 {
bank-width = <4>;
compatible = "xlnx,xps-mch-emc-1.00.a", "cfi-flash";
reg = < 80800000 800000 >;
partition@0 {
  label = "fs";
  reg = <0 380000>; };
 partition@380000 {
  label = "firmware";
  reg = <380000 480000>;
  read-only;   };
};
 

As per your dts file, your partitioning is method III from above.

 


STEP 5: Enabling specific filesystem. You have also enabled JFFS2 filesystem support
#
# Pseudo filesystems
#
CONFIG_PROC_FS=y
# CONFIG_EFS_FS is not set
CONFIG_JFFS2_FS=y
CONFIG_JFFS2_FS_DEBUG=1
CONFIG_JFFS2_FS_WRITEBUFFER=y
# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
CONFIG_JFFS2_SUMMARY=y

 


STEP 6: From your rootfs config, you have not enabled mtd-utils-jffs2
You can enable in rootfs Configuration --> Filesystem Packages --> base --> mtd-utils-jffs2

CONFIG_ROOTFS_PACKAGES_MTD_UTILS=y.
# CONFIG_ROOTFS_PACKAGES_MTD_UTILS_JFFS2 is not set


Your config.txt looks fine. From steps 1 through 5, it seems you are not missing anything. The only thing from my side your are missing is STEP 6.

Can you please also enable step 6 and check once. If still any errors persist, please check for any dependancies you might be missing from above steps.(By clicking on 'help' while selecting each feature during configuration will show dependancies)

Please also make sure of existence of compatible drivers in kernel for your flash device or else you need to write your own drivers!


Thanks,
Naveen

0 Kudos
Observer naveeng
Observer
10,266 Views
Registered: ‎11-25-2015

Re: Stuck trying to get JFFS2 working

Are we missing anything?

 

Your system-conf.dtsi.txt file shows up the configuration that you have selected i.e., qspi device. And also at the same time, I have found no SPI drivers are enabled in your kernel config:

#
# SPI Master Controller Drivers
#
# CONFIG_SPI_ALTERA is not set
CONFIG_SPI_BITBANG=y
# CONFIG_SPI_GPIO is not set
# CONFIG_SPI_FSL_SPI is not set
# CONFIG_SPI_OC_TINY is not set
# CONFIG_SPI_PXA2XX_PCI is not set
# CONFIG_SPI_SC18IS602 is not set
# CONFIG_SPI_XCOMM is not set
CONFIG_SPI_XILINX=y
# CONFIG_SPI_XILINX_GQSPI is not set
# CONFIG_SPI_DESIGNWARE is not set

#
# SPI Protocol Masters
#
# CONFIG_SPI_SPIDEV is not set
# CONFIG_SPI_TLE62X0 is not set
# CONFIG_SPMI is not set
# CONFIG_HSI is not set

 

For Xilinx zynq qspi, your petalinux kernel config should have CONFIG_SPI_ZYNQ_QSPI and CONFIG_SPI_ZYNQ_QSPI_DUAL_STACKED(based on the qspi mode you prefer) enabled. These flags seems missing from your kernel config file. You can find these in your kernel config --> Device Drivers --> SPI support --> Xilinx Zynq QSPI Dual stacked configuration. (qspi-mode - Currenlty unused. 0 if single, 1 if parallel and 2 if stacked, is-dual - Set if parallel. Reset if single or stacked)

 

Can you also specify in your device tree file about which qspi mode you are using as below example?
qspi: qspi@e000d000 {
      compatible = "xlnx,zynq-qspi-1.0";
      clock-names = "ref_clk", "pclk";
      clocks = <&clkc 10>, <&clkc 43>;
      interrupt-parent = <&ps7_scugic_0>;
      interrupts = <0 19 4>;
      is-dual = <0>;
      num-cs = <1>;
      reg = <0xe000d000 0x1000>;
      xlnx,fb-clk = <0x1>;
      xlnx,qspi-mode = <0x0>;
      #address-cells = <1>;
      #size-cells = <0>;
      flash@0 {
              compatible = "n25q128";
              reg = <0x0>;
              spi-tx-bus-width = <1>;
              spi-rx-bus-width = <4>;
              spi-max-frequency = <50000000>;
              #address-cells = <1>;
              #size-cells = <1>;
              partition@qspi-fsbl-uboot {
                        label = "qspi-fsbl-uboot";
                        reg = <0x0 0x100000>;
              };
              partition@qspi-linux {
                        label = "qspi-linux";
                        reg = <0x100000 0x500000>;
              };
              partition@qspi-device-tree {
                        label = "qspi-device-tree";
                        reg = <0x600000 0x20000>;
              };
              partition@qspi-rootfs {
                        label = "qspi-rootfs";
                        reg = <0x620000 0x5E0000>;
              };
              partition@qspi-bitstream {
                        label = "qspi-bitstream";
                        reg = <0xC00000 0x400000>;
              };
      };
};

 

0 Kudos
Highlighted
Observer naveeng
Observer
10,260 Views
Registered: ‎11-25-2015

Re: Stuck trying to get JFFS2 working

Hope the above info should be helpful to you!

0 Kudos
Visitor kg.calrec
Visitor
10,254 Views
Registered: ‎11-09-2015

Re: Stuck trying to get JFFS2 working

Thanks for your help naveeng. I got one of my collegues to look into the issue. He discovered that 2015.2 was putting the wrong "compatible" string into the device tree for the flash. 2015.4 generates a substantially different device tree from the HDF and that has the correct "compatible" string.

 

He's now got it boting from Initramfs with a separate UBIFS partition for persistancy. Ideally we'd like to be able to boot from UBIFS so we can update OS elements in the field. DO you have any tips on how we can do that?

 

Thanks again.

 

Keith.

0 Kudos
Observer naveeng
Observer
8,496 Views
Registered: ‎11-25-2015

Re: Stuck trying to get JFFS2 working

Hi Keith,

 

Fine!

 

Here are the steps:

1. Enable UBI support in your kernel. Go to Kernel configuration -> Device Drivers -> MTD support ->  select “Enable UBI” (CONFIG_MTD_UBI). To start of with, enable UBI debugging (CONFIG_MTD_UBI_DEBUG).

 

2. UBI utilities are available as a part of MTD utilities or can be downloaded from git://git.infradead.org/mtd-utils.git repository

E.g. ubinfo(provides info on UBI installation, devices & volumes on the system) , ubiattach(attaches mtd devices to UBI), ubidetach(detaches MTD devices from UBI devices), ubimkvol(creates UBI volumes on UBI devices), ubirmvol(removes UBI volumes from UBI devices), ubinize(generates UBI iamges), ubiformat (formats or erases flash)

 

3. Attaching a MTD device to UBI

If UBI is compiled as a kernel module, specify the MTD device to attach, in module arguments.

modprobe ubi mtd=0

 

If UBI is compiled into the kernel, specify the MTD device to attach, in the kernel boot parameters.

ubi.mtd=0

MTD devices can be attached or detached to/from UBI anytime using ubiattach and ubidetach utilities.

 

4. Creating UBI Volumes:

UBI volumes can be created dynamically using ubimkvol and ubirmvol utilities.

            ubimkvol /dev/ubi0 –N rootfs –s 128MiB

creates a 128MB UBI volume on UBI device 0 and names it rootfs.

   

  ubirmvol /dev/ubi0 –n 0

deletes a UBI volume with volume-id 0 from UBI device 0.

 

5. Mounting JFFS2 on UBI Volume

UBI can emulate MTD devices on UBI volumes and JFFS2 can be mounted on these emulated MTD devices. Enable “Emulate MTD devices” in Device Drivers-> MTD support-> Enable UBI --> MTD device emulation driver, to ask the UBI to create one MTD device for each UBI volume.

 

Mounting jffs2 filesystem:

I. Erase the flash through the flash_eraseall utility (use the –j option).

flash_eraseall –j /dev/mtd0

This formats the flash for jffs2 (assuming that /dev/mtd0 is your MTD device).

 

II. Create a jffs2 image of the directory you want to put under jffs2.

mkfs.jffs2 -d root_folder -o image_name -e sector_erase_size

where, root_folder is the directory you want to put under jffs2

image_name is the name of the resultant jffs2 image

sector_erase_size is the sector erase size of your flash device

 

III. Write the image on to the flash.

cat image_name > /dev/mtd0

 

IV. Mount the jffs2 filesystem on to the flash.

mount -t jffs2 /dev/mtdblock0 /mnt/jffs2

 

Also enable JFFS2 filesystem and MTD drivers in the kernel as in previous posts on this thread.

 

Thanks,

Naveen

0 Kudos
8,467 Views
Registered: ‎01-22-2016

Re: Stuck trying to get JFFS2 working

We got it working in the end, albeit slowly :

- The original problem wasd just that the compatible string was wrong, and did not match our flash chip. Once this was changed in the system top dts, we were able to see the flash and boot from the jffs2 image produced by petalinux.

 

- In the end, we decided to use Yocto to produce a ubi file system. We already have a lot of Yocto experience in the company, and it took us no time to produce a full ubi rootfs with all the tools we needed. I can add the ubi volume using petalinux-package ... --add ... --offset... to produce the MCS file to flash the device,

 

We still have performance issue, because we are using the SPI in standard mode, not quad spi, but I think it's an issue with the way the FPGA is setup. 

 

0 Kudos
Participant gauss_work
Participant
7,193 Views
Registered: ‎03-06-2016

Re: Stuck trying to get JFFS2 working

Hi: - The original problem wasd just that the compatible string was wrong, and did not match our flash chip.

 

could you please point out the correct compatible string.I am also stuck in this problem.Your reply indicates that the vivado 2015.2 has some bug ?

thanks!

0 Kudos
Explorer
Explorer
7,181 Views
Registered: ‎11-22-2015

Re: Stuck trying to get JFFS2 working

Did you check the boot log? I had an issue like this and the boot log told me that the part didn't match the string. Then it was just a matter at looking at the part on our board and what was supported in the driver and changing the compat string.

jeff
0 Kudos
Participant gauss_work
Participant
7,174 Views
Registered: ‎03-06-2016

Re: Stuck trying to get JFFS2 working

After a few days'work,I get petalinux booting with jffs2.
I'm using Vivado 2015.2/Petalinux 2015.2.1 ,and ZC706.
the device tree file system-conf.dtsi has a bug which should be fixed by xilinx

compatible = "micron,n25q128";
should be replaced by compatible = "micron,n25q128a13";
I hope this will help someone who met with the same issue.
Visitor sampovilus
Visitor
6,516 Views
Registered: ‎02-09-2015

Re: Stuck trying to get JFFS2 working

@gauss_work I had this exact issue and spend at least a week until i found this post, you are a god, thank you so much for taking the time to come back and post your solution. 

0 Kudos
Adventurer
Adventurer
5,382 Views
Registered: ‎09-28-2016

Re: Stuck trying to get JFFS2 working

Hi,

    I am making JFFS2 on ZC706, I am so confuse,it seem that 

 

 

0 Kudos
Visitor kg.calrec
Visitor
5,369 Views
Registered: ‎11-09-2015

Re: Stuck trying to get JFFS2 working

Yocto supports Xilinx processors now (including the Microblaze, which this thread was originally about). In the end we took FS-BOOT (the 1st stage bootloader) and UBOOT from Petalinux, then used Yocto to build the Linux environment instead of Petalinux.
0 Kudos
Adventurer
Adventurer
5,358 Views
Registered: ‎09-28-2016

Re: Stuck trying to get JFFS2 working

Hi, kg.calrec

 

Thank your for your reply.I want to consult you that have you boot JFFS2 on the qspi flash with the Yocto successfully? if I used Yocto to build Linux kernel and rootfs instead of Petalinux, what should I concern?

 

Thanks again

 

Tom

0 Kudos
1,750 Views
Registered: ‎06-18-2018

Re: Stuck trying to get JFFS2 working

@gauss_work thanks a lot for pointing out this! You are genius!

Btw, how do you narrow down the problem and figure out where the issue might be?

0 Kudos