Hammer How to JFFS2 Root

From eLinux.org
Jump to: navigation, search

This tutorial assumes you are using Minicom to console to your Hammer Board.

This tutorial shows how to configure the Hammer Board software to boot from the flash partition (/dev/mtdblock1) instead of using an initrd in RAM. This should make more RAM available for applications.

Do these steps FIRST:

Turn off all initramfs and initrd support in your kernel
Make sure the .SIZE is set correctly in arch/arm/mach-s3c2410/mach-tct-hammer.c
Make sure the correct Default Kernel Commandline (in APEX, Environment) is set to point to /mnt/mtdblock1 as the root partition.

You may have to edit arch/arm/mach-s3c2410/mach-tct-hammer.c to change the value of .SIZE if your kernel is larger than 1 MB. The most common values for .SIZE are 0x140000 (1280k) and 0x200000 (2048k). These values should be more than large enough for most builds. The .SIZE variable has to be large enough for the boot loader and the kernel together.

In Buildroot do:

make menuconfig
uncheck ext2 in Target Options
check jffs2 in Target Options
Exit and save your new configuration

There will be a *.jffs2 image file in your buildroot/binaries/<project> directory - this is your JFFS2 rootfs image.


Copy the jffs2 file, the apex.bin (bootloader) file, and your zImage (kernel) file to where you have OpenOCD setup for use.
Edit your hammer.ocd flash script to comment out the initrd file flash command - you will upload your JFFS2 image later.
Do openocd -f hammer.cfg, which will flash the new bootloader and kernel image to your Hammer Board.


Press RESET on Hammer and Ctrl/C to get to the APEX command prompt
xreceive 0x30300000 (this is the address to upload to in memory)

In Minicom do:

Ctrl/A S
Select Xmodem
Browse to or enter the full path of the JFFS2 image to upload

In APEX do:

erase nor:1280k+0xEC0000 (that value is total amount of flash minus the amount of flash used for kernel and bootloader)

For the next step, you need to know the exact size in bytes of your JFFS2 file image. Replace <filesize> with the exact file size in bytes returned by doing

ls -l

at the shell prompt.

In APEX do:

copy 0x30300000+<filesize> nor:1280k

NOTE: This command may need changed based on the size allocated for kernel space. In Linux kernel the default allocated space in the mach file is 0x200000 (verify this before you type it). You will see this value in the size attribute of the MTD partitions labeled "System" in the mach-tct_hammer.c file in <kernel root>/arch/arm/s3c2410. So a more appropriate definition would be

copy 0x30300000+<filesize> nor:<system size>

If its 0x200000

copy 0x30300000+<filesize> nor:0x200000

To make the next change permanent, you need to go into the APEX configuration and set a parameter to tell APEX about your new root file system (JFFS2) and root (/dev/mtdblock1). There is a parameter in the Environment section called Default kernel command line, which you need to set to:

console=ttySAC0 rootfstype=jffs2 init=/linuxrc root=/dev/mtdblock1 rw

Then save your configuration, exit, and do:


This will rebuild the APEX bootloader. To make this change more temporary, until you reflash Hammer again, you can set the cmdline parameter in APEX by:

Rebooting Hammer and pressing Ctrl/C to get to the APEX prompt

In APEX do:

setenv cmdline = "console=ttySAC0 rootfstype=jffs2 root=/dev/mtdblock1"

This should show the change you just made. Now press RESET on your Hammer Carrier Board to reboot.