Skip to content

Instantly share code, notes, and snippets.

@jinleileiking
Created July 3, 2012 06:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jinleileiking/3038030 to your computer and use it in GitHub Desktop.
Save jinleileiking/3038030 to your computer and use it in GitHub Desktop.
dm370 将xloader,uboot,kernel,fs移到nand

flash x-loader & uboot to nandflash.

from TMS320DM3730_Software_Developers_Guide.pdf:

How to create an SD card
This section explained the procedure required for creating SD card image for DM3730 and the steps has been
verified on 2GB and 4GB SD cards.
1.  Plug an SD card on Linux host machine.
2.  Run dmesg command to check the device node. Triple check this to ensure you do not damage your HDD
contents!
host $ dmesg
   [14365.272631] sd 6:0:0:1: [sdc] 3862528 512-byte logical blocks: (1.97 GB/1.84 GiB)
   [14365.310602] sd 6:0:0:1: [sdc] Assuming drive cache: write through
   [14365.325542] sd 6:0:0:1: [sdc] Assuming drive cache: write through
   [14365.325571]  sdc: sdc1 sdc2
In this example, SD card is detected on /dev/sdc.
3.  Run mksdboot script installed in DVSDK as show below
host $ sudo ${DVSDK}/bin/mksdboot.sh --device /dev/sdc --sdk ${DVSDK}
TMS320DM3730 Software Developers Guide
 How to create an SD card 29Wait for script to complete. On successful completion, remove the SD card from the host PC.
NOTE: When creating a bootable SD card, the mksdboot script uses the pre-built root filesystem, kernel and
bootloader images provided in the DVSDK installation.
4.  Power OFF the DM3730 EVM.
5.  Set the SW4 switch to boot from SD.
SW4 = 00100111 (high to low, i.e. SW4.1 = 1) • 
1 = "On" position on the switch • 
6.  Insert the SD card into the DM3730 EVM.
7.  Power ON the EVM.
Note! If your flash already has a u-boot environment stored, this will get picked up even while booting from
SD-card. If this is the case, halt the u-boot auto boot process and enter the following command to erase the
entire NAND:
u-boot :> nand erase 
Note! If you want to recreate the full SD card with a separate partition for the DVSDK installer execute the
following:
host $ sudo ${DVSDK}/bin/mksdboot.sh --device /dev/sdc --sdk ${DVSDK} \
/path/to/dvsdk_dm3730-evm_4_xx_xx_xx_xx_setuplinux
This takes significant extra time so it's not part of the default instructions.
How to copy boot loaders to NAND flash
This section explains the procedure required for copying boot loaders (x-loader and u-boot) on NAND flash.
The steps assumes that you have a working SD card image.
1.  Boot the DM3730 EVM with SD card. See #How to create an SD card
2.  Halt the u-boot auto boot process and enter the following commands to copy x-loader (i.e MLO) and
u-boot from SD card to NAND flash.
u-boot :> nand erase 
u-boot :> nandecc hw 2
u-boot :> mmc init
u-boot :> fatload mmc 0 0x81600000 MLO
u-boot :> nand write.i 0x81600000 0 20000
u-boot :> nandecc hw 2
u-boot :> fatload mmc 0 0x81600000 u-boot.bin
u-boot :> nand write.i 0x81600000 80000 40000
TMS320DM3730 Software Developers Guide
 How to copy boot loaders to NAND flash 303.  Power OFF the EVM and remove the SD card.
4.  Set the SW4 switch to boot from NAND (1 = "On" position on the switch):
SW4 = 00101010 (high to low, i.e. SW4.1 = 0) 
5.  Power ON the EVM.

flash kernel to nand, boot fs from mmc

from http://processors.wiki.ti.com/index.php/How_to_Flash_Linux_System_from_U-boot

mw.b 0x81600000 0xff 0x1400000;nand erase 280000 400000;mmc init;fatload mmc 0 0x81600000 uImage;nandecc sw; nand write.i 0x81600000 280000 400000 

setenv nand_kernel 'nand read.i ${loadaddr} 280000 400000'
setenv nand_mmc_boot 'nandecc sw;run nand_kernel;setenv bootargs ${mmcargs}; bootm'
run nand_mmc_boot

changed 300000 -> 400000, because the kernel size is bigger than 3m.

flash fs to nand, boot fs from nand

[prompt]$ flash_eraseall –j /dev/mtd4
[prompt]$ mount /dev/mtdblock4 /media/nand –t jffs2
[prompt]$ cd /media/nand
[prompt]$ tar xzf /media/mmcxxxxxpx/rootfs.tar.gz
[prompt]$ reboot –f

modify uboot:

bootdelay=10
baudrate=115200
bootfile=uImage
loadaddr=0x82000000
usbtty=cdc_acm
console=ttyO0,115200n8
mmcargs=setenv bootargs console=${console} root=/dev/mmcblk0p2 rw rootfstype=ext3 rootwait omap_vout.vid1_static_vrfb_alloc=y
nandargs=setenv bootargs console=${console} root=/dev/mtdblock4 rw rootfstype=jffs2
loadbootscript=fatload mmc 0 ${loadaddr} boot.scr
bootscript=echo Running bootscript from mmc ...; source ${loadaddr}
loaduimage=fatload mmc 0 ${loadaddr} uImage
mmcboot=echo Booting from mmc ...; run mmcargs; bootm ${loadaddr}
nandboot=echo Booting from nand ...; run nandargs; onenand read ${loadaddr} 280000 400000; bootm ${loadaddr}
dieid#=60e000229ff80000016071640a00b00d
ethact=smc911x-0
bootcmd_original=if mmc init; then if run loadbootscript; then run bootscript; else if run loaduimage; then run mmcboot; else run nandboot; fi; fi; else run nandboot; fi
nand_kernel=nand read.i ${loadaddr} 280000 400000
nand_mmc_boot=nandecc sw;run nand_kernel;setenv bootargs ${mmcargs}; bootm
nand_boot=nandecc sw;run nand_kernel;bootm
bootcmd=run nand_boot
filesize=12E
bootargs=mem=128M console=ttyO0,115200n8 noinitrd root=/dev/mtdblock4 rw rootfstype=jffs2
stdin=serial
stdout=serial
stderr=serial
loadaddr=0x82000000
nand_kernel=nand read.i ${loadaddr} 280000 400000
bootcmd=run nand_boot
nand_boot=nandecc sw;run nand_kernel;bootm
bootargs=mem=128M console=ttyO0,115200n8 noinitrd root=/dev/mtdblock4 rw rootfstype=jffs2

总结

nand地址分配

  • 0x00000-0x20000 x-loader
  • 0x80000-0x80000+0x40000 uboot
  • 0x280000-0x280000+0x400000 linux
  • mtdblock4 fs

nandecc

这个命令是选择你选用了哪块nand分区, hw 是xloader/uboot, sw是linux

uboot启动

  • uboot启动后,运行boot_cmd,带参数bootargs
  • console是ttySO0

ps

  • 0x100000 = 1m
  • 0x400 = 1k
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment