Memory leaking when using nandsim and mounting a file system on it when using cache_file argument [closed]

My expectation was that when nandsim is passed the cache_file argument that nandsim would use the cache file to back the simulated memory instead of RAM. What I am observing though when I dd create files on a volume mounted against the nandsim mtd device is that Free RAM is being consumed that is at least as large as the file created. The cache_file grows by the expected amount with each dd file write. And the cache_file contains the contents of the files that are created.

I first experienced this when using nandsim on a ZC706 board and using yaffs2 as the file system.
To help diagnose this was not a issue with the ZC706 setup I was able to recreate the issue using a lab machine with a old version of linux on it and using ubifs instead of yaffs2. The behavior was the same.

Has anyone experienced this and have any advice – it would be appreciated?

The setup I will describe is what I performed on the lab machine with a old linux version.

uname -r

2.6.32-754.24.3.el6.x86_64

Found the linux source for it online and downloaded it.
Then uncompressed it using.

rpm2cpio kernel-2.6.32-754.24.3.el6.src.rpm | cpio –idmv

Then untar.

tar xvf kernel.tar.bz2

If I tried to only build the nandsim ko I had signature issues trying to load it. It would fail to insert and using dmesg indicated signature issue. modprobe -f didn’t help.
(with make drivers/mtd/nandsim.ko)

To work around that I needed to do the following:
Tried doing a full compile of linux and it reported key.h was missing.
run make menuconfig.

  1. Select “Enable loadable module support”, then “Module signature verification (EXPERIMENTAL)”. Disable it.
  2. Then go back to the main menu, select “Cryptographic API” then “In-kernel signature checker (EXPERIMENTAL)” and disable that one too.
    Then go back again, save your config and make your kernel. At least, it will pass this phase successfully.

modprobe would still not insert for me. what I found to work was this sequence:

sudo insmod nand_ids.ko

sudo insmod nand_ecc.ko

sudo insmod nand.ko

sudo insmod nandsim.ko first_id_byte=0x01 second_id_byte=0xd5 third_id_byte=0x80 fourth_id_byte=0x1d cache_file=/home/user/cache_file

(I think I needed to use abs path for this instead of ~ but not sure – just beware) (creates 2GB device)
The first byte is the manufacturer ID.
The second byte is the chip ID.
The third byte is the bus width.
The other bytes I think are optional.
(to see the chips that nandsim knows about look at the nand_ids.c file – and you can google for listing of nand parameters for chips) The chip ID parameter is hardcoded in that file for each device.

cat /proc/mtd shows the simulated mtd device.

cache_file will be empty until files are put on the device.

My computer did not have ubifs in /proc/filesystems.
I was able to get it to appear by insmod the ubi.ko and ubifs.ko that were produced when I built the linux kernel.

Next I need the ubi userspace apps from mtd-utils.
git clone https://git.infraroot.at/mtd-utils.git

When running autogen.sh on old linux version the configure script had problems with fi’s in it.
To get around that I ran autogen.sh on my desktop machine and then tarred the mtd-utils up and put it on the lab machine.

configure would then run – but mkdir path was incorrect. I edited that in configure.
then did make. and sys/random.h was missing. found that I could avoid building the heavy mtd parts by specifying just the apps I wanted by doing these:

make ubiformat

make ubiattach

make flash_erase

make ubidetach

make ubimkvol

My simulated device appeared as mtd0 be careful with your setup as it might not be mtd0 in your case.

The following steps get it to where ubifs is mounted on nandsim.

flash_erase /dev/mtd0 0 0

ubiformat /dev/mtd0

ubiattach -p /dev/mtd0

mkdir -p ~/mnt/nandsim

mount -t ubifs /dev/ubi0 ~/mnt/nandsim

(this would fail with wrong fs type)
dmesg said it couldnt find /dev/ubi0 but it is there for sure.

I detached to be sure I wasn’t fooling myself and that worked.

ubidetach –d 0

Made /dev/ubi0 go away.

I attached again.

ubiattach -p /dev/mtd0

Googling around I found this step to create a volume.

ubimkvol /dev/ubi0 -N test_volume -s 1GiB

mount -t ubifs ubi0:test_volume ~/mnt/nandsim

Whew ok so now it will exist.

Here’s the part where the memory leaking happens. Or maybe it’s just that nandsim uses RAM always even when the cache_file option is specified.

cd ~/mnt/nandsim

Run this command over and over and you will notice the Free memory drops by at least the size of the file created.

dd if=/dev/urandom of=test1.bin bs=1M count=1 ; cat /proc/meminfo | grep MemFree

The reason I am going through all this is because I want to simulate a very large nand device on a ZC706 and it does not have enough RAM. It does however have a large SDCARD which I point the cache_file at – and I used ext2 to mount the SDCARD so that one very large file is possible that can represent the very large nand device.

Because of the memory leaking or nandsim using the cache_file and RAM – I run out of RAM before I am able to fill up the file system mount with data that would be the same size as the large nand device. If I keep writing and let the Free memory keep going down eventually a crash will occur and the backtrace will be point back to dd and nandsim.

Sorry it is so long and if I made any mistakes in describing the setup.

If anyone has any advice on this it would be appreciated.

Thank you.

New contributor

jonzerStyle is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật