tiny210 (s5pv210) porting U-boot (based on 2014.4 version number)--nand boot

Source: Internet
Author: User
Tags spl

We know that there are a lot of s5pv210 start-up methods, SD card and NAND flash boot is the two of them, the previous implementation is based on the SD card boot, this section we started to implement from NAND Flash:

Booting U-boot from NAND requires BL1 to initialize the NAND controller and then BL2 from the NAND copy to the DDR memory. The BL1 here is the u-boot-spl.bin,bl2 we transplanted, the u-boot.bin we transplanted. The NAND driver in U-boot.bin is relatively large, it includes very versatile, and u-boot-spl.bin only needs to BL2 from the NAND copy to the DDR, so we can do a simple NAND controller initialization in U-boot-spl.bin , and then use the NAND copy function provided by Samsung with 8-bit hardware ECC to copy U-boot.bin to DDR memory. We change the Copy_bl2_to_ram function in board/samsung/tiny210/tiny210.c, in which we first infer whether the current is starting from the SD card or the NAND, assuming that the NAND is initialized from the NAND, and then from N and copy the BL2 to DDR memory, assuming it is booting from the SD card, copy the BL2 from the SD card to the DDR memory. We infer from which device the s5pv210 is currently booting by reading the OMR register. Reference manual table 6-3, the manual does not say the address of the OM register, I am the reference to the Samsung original U-boot code. There are specific stares in the code, see the code for details:

void Copy_bl2_to_ram (void) {/*** ch: Channel * * SB: Starting block * * BS: Block size * * DST: Destination * * I: whether to initialize */#define COPYSDMMCTOMEM (CH, SB, BS, DS T, i) (((U8 (*) (int, u32, unsigned short, u32*, U8)) (* ((U32 *) 0xd0037f98))) (CH, SB, BS, DST, i)) #define MP0_1CON (* (Volati Le u32 *) 0xe02002e0) #defineMP0_3CON (* (volatile u32 *) 0xe0200320) #defineMP0_6CON (* (volatile u32 *) 0xe0200380) #define N F8_readpage_adv (A,b,c) (((Int (*) (U32, U32, u8*)) (* ((U32) 0xd0037f90))) (a,b,c)) u32 bl2size = * 1024;//250ku32 OM = * ( Volatile u32 *) (0xe0000004);//om registerom &= 0x1f;//take low 5-bit if (om = = 0x2)/NAND 2 KB, 5cycle 8-bit ecc{u32 cfg = 0;s Truct S5pv210_nand *nand_reg = (struct S5pv210_nand *) (struct S5pv210_nand *) Samsung_get_base_nand ();/* Initialize Hardware *//* Hclk_psys=133mhz (7.5ns) */cfg = (0x1 << 23°c) |/* Disable 1-bit and 4-bit ECC *//* The following 3 time parameters are slightly larger than the calculated values (i Add 1 in turn), otherwise read/write unstable */(0x3 << |/*) 7.5ns * 2 > 12ns tALS TCLS */(0x2 << 8) | /* (+) * 7.5ns > 12ns (TWP) */(0x1 << 4) | /* (0+1) *7.5 > 5ns (TCLH/TALH) */(0x0 << 3) | /* SLC NAND Flash */(0x0 << 2) |/* 2kbytes/page */(0x1 << 1);/* 5 address cycle */writel (CFG, &AMP;NAND_REG-&G t;nfconf); Writel ((0x1 << 1) | (0x1 << 0), &nand_reg->nfcont);/* Disable chip Select and Enable NAND Flash Controller *//* Config GPIO */mp0 _1con &= ~ (0xFFFF << 8); Mp0_1con |= (0x3333 << 8); Mp0_3con = 0x22222222; Mp0_6con = 0x22222222;int i = 0;int pages = bl2size/2048;//number of pages int offset = 0x4000/2048;//u-boot.bin offset address in NAND (page address) u  8 *p = (U8 *) config_sys_sdram_base;for (; i < pages; i++, p + = 2048, offset + = 1) nf8_readpage_adv (OFFSET/64, offset% (p);} else if (OM = = 0xC)//Sd/mmc{u32 v210_sdmmc_base = * (Volatile u32 *) (0xd0037488);//V210_sdmmc_baseu8 ch = 0;/* references s5pv210 hand Brochure 7.9.1 sd/mmc REGISTER MAP */if (v210_sdmmc_base = = 0xeb000000)//Channel 0ch = 0;else if (v210_sdmmc_base = = 0xeb200000)//channel 2c h = 2; COPYSDMMCTOMEM (CH, +, bl2size/512, (U32 *) config_sys_sdram_base, 0);}}

compile again, but before compiling the header file to be added to NAND: #include <asm/arch/nand_reg.h> successfully generate Spl/tiny210-spl.bin and u-boot.bin, copy them all to the TFTP server folder, and then you can then use the U-boot from the previous section to burn the latest u-boot to NAND FLASH.

Start the Development Board from the SD card first and erase the entire NAND FLASH:


Use Tftpboot to download the Tiny210-spl.bin to DDR start address 0x20000000


Burn write Tiny210-spl.bin to NAND 0 address:


Use Tftpboot to download the U-boot.bin to DDR start address 0x20000000


Burn write U-boot.bin to NAND FLASH's 0x4000 address (0x0~0x3fff reserved for tiny210-spl.bin)


Toggle the dial switch, from the NAND start the Development Board, can observe u-boot normal start, and now our u-boot function basically realized, I put the code here, interested friends can see: tiny210_u-boot_201404_ v2.0, then we can all code and function intact.



tiny210 (s5pv210) porting U-boot (based on 2014.4 version number)--nand boot

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.