Extracting default ngw linux root

Go To Last Post
12 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

I'm using OpenSuse 10.1 and am starting development using the ngw100. I can build a kernel, busybox and u-boot with no problems. When I want to bring them together, I follow the instructions to copy the file to an sd card, but get the following

mount -o loop /tmp/ngw_jffs_root.img /tmp/avr32_image
/tmp/ngw_jffs_root.img: No such file or directory

both the directory and the file DO exist!
Is there some other way of extracting the root image to get a development starting point, or am I missing something?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Are you sure you have the file located there? And not in ~/tmp ?
to be sure you can do the following:

ls -l /tmp/ngw_jffs_root.img

I think you'll need root privileges to mount a filesystem image under alle distros.

11011110101011011100000011011110

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the reply. it's definitely there. When I try it (as root) without the -o loop option, it returns 'special device /tmp/ngw_jffs_root.img does not exist'. It's possible that the problem is something to do with the mount in OpenSuse. Is there a different way of reading the file?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You usually need to specify -tjffs2 to be able to mount jffs2 filesystems. Not sure why.

Of course, you also need jffs2 support in the kernel, and you may need some kind of block device or ram-based emulation layer since most PCs can't deal with flash-based filesystems directly...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks again for the reply, got a bit further

Complains about an attempt to mount non-MTD device.

Is there somewhere else to get a target root filesystem directory tree? I'm surprised it's not on the BSP CD.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I stuck my SD card in my NGW and executed the following commands to clone the flash to my SD card:

# mount /dev/mmcblk0p1 /mnt
# cp -a /dev /mnt/
# cp -a /bin /mnt/
# cp -a /sbin /mnt/
# cp -a /etc /mnt/
# cp -a /usr /mnt/
# cp -a /var /mnt/
# cp -a /lib /mnt/
# cp -a /home /mnt/
# cp -a /root /mnt/
# cp -a /www /mnt/
# mkdir /mnt/sys
# mkdir /mnt/tmp
# mkdir /mnt/proc
# mkdir /mnt/config
# mkdir /mnt/media
# mkdir /mnt/mnt
# cp -a /uImage /mnt/
# cp -a /linuxrc /mnt/

I think that covers every dir and file needed. I do not remember the exact commands I used, so the above is from memory. Obviously before I put the card in my NGW I formatted it ext2 on my linux system.

Oh, BTW, unless you build your own kernel set to have the MMC driver built in and nt as a module, you will not be able to boot off it and be able to mount the root filesystem on it as the mmc driver is not loaded.

If anyone wants, I can make available an image of my SD card. It has the 2.6.21 kernel on it and boots fine off MMC.

Mike

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just found out that all this can be done via the script and reference image on the bsp CD.

see "make script compile all components" thread in this forum

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,
I work with ubuntu and I can't mount the ngw_jffs2_root.img to get a filesystem, I tried many things but i always get an error, is there a way to do that?
Thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

xavier@diateam wrote:
Hello,
I work with ubuntu and I can't mount the ngw_jffs2_root.img to get a filesystem, I tried many things but i always get an error, is there a way to do that?

There's always a way, but in this case it's a difficult one involving hacking the jffs2 driver on the host to use big endian instead of the host's native endianness.

I've never done this myself, but there was a thread about it on linux-mtd a week ago or so.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you for the reply.
I just want to try the root filesystem from www.atmel.no/beta_ware/ because i have recompiled a kernel and it boots but it doesn't find the console or init so i would like to try with the official root filesystem. (or there is maybe a problem with nfs mount but it seems ok).
Does anybody have a filesystem? (i erase my flash...)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Mounting of jff2 image (for big endian system) on PC is bit challenging, but it is possible.

1) Firstly you must convert a jffs2 image to Little Endian

jffs2dump -b -e le.img ngw_jffs2_root.img

2) Now setup loopback device for this image

losetup /dev/loop0 le.img

3) Next you use MTD block emulation device, with correct erase_size for given image (for usr image is valid value 8448, see https://www.avrfreaks.net/wiki/index.php/Documentation:AVR32_Linux_Development/Building_flash_filesystems_for_the_Network_Gateway

modprobe block2mtd block2mtd=/dev/loop0,65536

4) Last, you can mount device. Note that mounting with read-only flag is considerably faster.
mount -t jffs2 -o ro /dev/mtdblock0 /mnt/jffs2
5) Finally, it is good practice to perform cleanup.

umount /mnt/jffs2
rmmod block2mtd
losetup -d /dev/loop0

PS: On older system (linux version <= 2.6.17) the mtd block device has name "blkmtd" and parameters are different, see also http://handhelds.org/moin/moin.cgi/FamiliarBackupHowto

Petr

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

petrbo wrote:
Mounting of jff2 image (for big endian system) on PC is bit challenging, but it is possible.

[...snip nice walkthrough...]


Awesome, cheers Petr.

If you've got a spare millisecond do you feel like reworking that a little for our wiki here? If not I'm sure some grateful onlooker will do it.

-S.