Forums » Software Development »
Loading kernel to SPI flash and Root file system .jffs2 to NAND.
Added by Vivek Ponnani about 7 years ago
Hi,
I have a custom board with
1) MityDspl-138F module (with FPGA)
2) No Ethernet port
3) UART,USB,SD CARD interface
we have done following steps till date.
1) I have built VM with MityDSP Critical_Link_Unified_VM_14-04_04-2017.ova file from critical link.
2) I have successfully run the example programs.
3) I have build new kernel with Analog Expansion support. We followed https://support.criticallink.com/redmine/projects/90-000173/wiki for the build of new kernel.
4) I have prepared SD card and copy new Linux kernel and its file system. And also inserted the modules under /lib/modules/3.2.0+/extra as per the https://support.criticallink.com/redmine/projects/90-000173/wiki as below.
Preparing the devkit to use the example applications
To use the example applications, the modules built in previous steps must be inserted into the kernel. It will be assumed that the kernel modules were installed into the default location used by Linux. The path may vary according to the kernel version. To find your specific kernel version, use the command uname -a.
insmod /lib/modules/3.2.0+/extra/dsplinkk.ko
insmod /lib/modules/3.2.0+/extra/fpga_ctrl.ko
insmod /lib/modules/3.2.0+/extra/fpga_spi.ko
With the successful insertion of these modules you will see similar output as below.
root@mityomapl138:~# insmod /lib/modules/3.2.0+/extra/dsplinkk.ko
DSPLINK Module (1.65.00.03) created on Date: Jan 13 2014 Time: 16:10:29
root@mityomapl138:~# insmod /lib/modules/3.2.0+/extra/fpga_ctrl.ko
Disabling lock debugging due to kernel taint
fpga fpga_ctrl: loading the fpga_ctrl module.
root@mityomapl138:~# insmod /lib/modules/3.2.0+/extra/fpga_spi.ko
I belive these files are copy of the extra folder under /lib/modules/3.2.0/extra/ in SD card and that is from /MDK_2014-01-13/fs/mityomap-full.tgz.
Now, I want to load Linux kernel into SPI flash and its file system in .jffs2 format in NAND.
My queries are as below
1) I checked Installing the Kernel on SPI - FLASH topic under https://support.criticallink.com/redmine/projects/arm9-platforms/wiki/Linux_Kernel.
If you want to permanently flash the kernel image to SPI FLASH:
u-Boot> tftp 0xC0700000 192.168.0.23:/uImage
u-Boot> sf probe 0
u-Boot> sf erase 0x100000 0x300000
u-Boot> sf write 0xC0700000 0x100000 ${filesize}
Note: If your kernel size is larger than 0x300000, then you will of course need to change the erase size above as well as the bootcmd environment string (which is used to load the kernel from the SPI FLASH on startup, if this is your preferred approach).
You will then need to change your bootcmd to load the kernel from SPI FLASH by:
u-Boot> set bootcmd "sf probe 0; sf read 0xc0700000 0x100000 0x300000;bootm 0xc0700000"
u-Boot> saveenv
As per the guidline, we should first copy uImage to address 0xC0700000 of the RAM DDR2.
Currentely, I am also copying UImage from SD card to 0xC0700000 and running the image from that location only. From the above commands, I understand that after I copy uImage to 0xC0700000 I need to follow last three commands to copy my uImage to SPI flash, and which are
u-Boot> sf probe 0
u-Boot> sf erase 0x100000 0x300000
u-Boot> sf write 0xC0700000 0x100000 ${filesize}
and need to change bootcmd to load the kernel from SPI flash everytime power is on. Is that correct?
2) I checked Flashing Image to NAND of https://support.criticallink.com/redmine/projects/arm9-platforms/wiki/Linux_Root_File_System.
As I have build new kernel, I have to make new .jffs2 file and can not use existing /MDK_2014-01-13/fs/mityomap-full.jffs2. and according to below guidlines from the link,
I must have directory that is the top of the root filesystem (i.e contains directories etc, usr, boot, and such).
The following command example shows the necessary options for appropriately creating a JFFS2 format file system from a directory on your virtual machine (or whatever *nix host machine you are on):
sudo mkfs.jffs2 -x lzo --root=<your_mityomap_rootfs>/ --faketime --output=<rootfs_image_file>.jffs2 --little-endian --eraseblock=0x20000 -n
where <your_mityomap_rootfs> is the directory that is the top of the root filesystem (i.e contains directories etc, usr, boot, and such)
and <rootfs_image_file> can be whatever name you want, but is typically the same as <your_mityomap_rootfs>
i.e. You created a filesystem hierarchy on your build machine under /home/mitydsp/build/my_filesystem/ then <your_mityomap_rootfs> would be /home/mitydsp/build/my_filesystem
I don't see any directory which contains etc, usr, boot, and such sub directories. That are only in /MDK_2014-01-13/fs/mityomap-full.tgz.
So, could you please describe that how to build new .jffs2 file with new kernel and file system? And Once it is done, Can I simply copy it to SD card and then from SD card to NAND or some other process I have to follow? Please note that I don't have Ethernet port,so I have to use SD card.
3) From the link https://support.criticallink.com/redmine/projects/arm9-platforms/wiki/Linux_Root_File_System
u-Boot> mw.b 0xC2000000 0xFF 0x06000000
u-Boot> tftp 0xC2000000 myserver:/path/to/root_filesystem.jffs2
u-Boot> nand erase 0 0x8000000
u-Boot> nand write.jffs2 0xC2000000 0 0x<rounded_filesize>
I have query regarding to address 0xC2000000. I understand that this is DDR2 adrress and we are copying .jffs2 file to that address first. As per my understading DDR2 starts at 0xC0000000 and from U-Boot environment first 96M is allocated to ARM. So, if we start at 0xC2000000 and keep size of 0x06000000(96M),it will fall into another 32M part, is that ok?
4) If we want to load our application software image of DSP or ARM or FPGA Image into NAND, Is it required to convert the file into .jffs2 format? If yes, then How to do it?
Currently we are copying our application generated .out file to SD card and from SD card to tmp folder of root@mityomapl138:~#.
Thanks
-Vivek
Replies (1)
RE: Loading kernel to SPI flash and Root file system .jffs2 to NAND. - Added by Jonathan Cormier about 7 years ago
Vivek Ponnani wrote:
My queries are as below
1) I checked Installing the Kernel on SPI - FLASH topic under https://support.criticallink.com/redmine/projects/arm9-platforms/wiki/Linux_Kernel.
If you want to permanently flash the kernel image to SPI FLASH:
u-Boot> tftp 0xC0700000 192.168.0.23:/uImage
u-Boot> sf probe 0
u-Boot> sf erase 0x100000 0x300000
u-Boot> sf write 0xC0700000 0x100000 ${filesize}
Note: If your kernel size is larger than 0x300000, then you will of course need to change the erase size above as well as the bootcmd environment string (which is used to load the kernel from the SPI FLASH on startup, if this is your preferred approach).You will then need to change your bootcmd to load the kernel from SPI FLASH by:
u-Boot> set bootcmd "sf probe 0; sf read 0xc0700000 0x100000 0x300000;bootm 0xc0700000"
u-Boot> saveenvAs per the guidline, we should first copy uImage to address 0xC0700000 of the RAM DDR2.
Currentely, I am also copying UImage from SD card to 0xC0700000 and running the image from that location only. From the above commands, I understand that after I copy uImage to 0xC0700000 I need to follow last three commands to copy my uImage to SPI flash, and which are
u-Boot> sf probe 0
u-Boot> sf erase 0x100000 0x300000
u-Boot> sf write 0xC0700000 0x100000 ${filesize}and need to change bootcmd to load the kernel from SPI flash everytime power is on. Is that correct?
Looks fine.
2) I checked Flashing Image to NAND of https://support.criticallink.com/redmine/projects/arm9-platforms/wiki/Linux_Root_File_System.
As I have build new kernel, I have to make new .jffs2 file and can not use existing /MDK_2014-01-13/fs/mityomap-full.jffs2. and according to below guidlines from the link,
I must have directory that is the top of the root filesystem (i.e contains directories etc, usr, boot, and such).The following command example shows the necessary options for appropriately creating a JFFS2 format file system from a directory on your virtual machine (or whatever *nix host machine you are on):
sudo mkfs.jffs2 -x lzo --root=<your_mityomap_rootfs>/ --faketime --output=<rootfs_image_file>.jffs2 --little-endian --eraseblock=0x20000 -n
where <your_mityomap_rootfs> is the directory that is the top of the root filesystem (i.e contains directories etc, usr, boot, and such)
and <rootfs_image_file> can be whatever name you want, but is typically the same as <your_mityomap_rootfs>
i.e. You created a filesystem hierarchy on your build machine under /home/mitydsp/build/my_filesystem/ then <your_mityomap_rootfs> would be /home/mitydsp/build/my_filesystemI don't see any directory which contains etc, usr, boot, and such sub directories. That are only in /MDK_2014-01-13/fs/mityomap-full.tgz.
So, could you please describe that how to build new .jffs2 file with new kernel and file system? And Once it is done, Can I simply copy it to SD card and then from SD card to NAND or some other process I have to follow? Please note that I don't have Ethernet port,so I have to use SD card.
You'd want to extract the MDK filesystem, update the files and then generate the jffs2 image file. NOTE: We also generate a new tarball which we can archive or commit to revision control. Its very hard to modify a jffs2 file so its much easier to keep the tarball for future modifications.
mkdir mityomap-full cd mityomap-full sudo tar xaf ~/MDK_2014-01-13/fs/mityomap-full.tgz ... Customize filesystem sudo tar czf ../mityomap-full-custom.tgz * cd .. sudo mkfs.jffs2 -x lzo --root=mityomap-full/ --faketime --output=mityomap-full-custom.jffs2 --little-endian --eraseblock=0x20000 -n
3) From the link https://support.criticallink.com/redmine/projects/arm9-platforms/wiki/Linux_Root_File_System
u-Boot> mw.b 0xC2000000 0xFF 0x06000000
u-Boot> tftp 0xC2000000 myserver:/path/to/root_filesystem.jffs2
u-Boot> nand erase 0 0x8000000
u-Boot> nand write.jffs2 0xC2000000 0 0x<rounded_filesize>I have query regarding to address 0xC2000000. I understand that this is DDR2 address and we are copying .jffs2 file to that address first. As per my understanding DDR2 starts at 0xC0000000 and from U-Boot environment first 96M is allocated to ARM. So, if we start at 0xC2000000 and keep size of 0x06000000(96M),it will fall into another 32M part, is that ok?
At this stage of boot, only the ARM is running so we can use all 128MB of ram.
4) If we want to load our application software image of DSP or ARM or FPGA Image into NAND, Is it required to convert the file into .jffs2 format? If yes, then How to do it?
Currently we are copying our application generated .out file to SD card and from SD card to tmp folder of root@mityomapl138:~#.
If you just want these files in the filesystem, then you could add them per question 2 above.
If you want to load the fpga from u-boot, you can program the bin file into the nand. See https://support.criticallink.com/redmine/projects/arm9-platforms/wiki/Programming_the_FPGA#Using-u-Boot-to-load-the-FPGA