/*
---------------------------------------------------------------
File name: NBOOT.c
Description: Perform Nand Bootloader operation
---------------------------------------------------------------
*/
#include "S3C244x.h"
#include "UART.h"
#include "Global.h"
#include "TOC.h"
#include "Nand.h"
#include "MMU.h"
#define TOC_BLOCK (2) //TOC occupies 2 blocks
#define SECTOR_SIZE 512 //Page size: 512 bytes
#define SECTOR_PER_BLOCK 256 //How many pages does each block contain
/**********************************************************
*File name: ReadNandImageToRam
*Input: unEntry entry point
*Output: WINCE image jump address
0 is invalid
*Function description: Load WINCE image from NAND FLASH to SDRAM
***********************************************************/
UINT32 ReadNandImageToRam(UINT32 unEntry)
{
UINT32 unSectorsNeeded;
UINT32 unSector,unLength;
UINT32 unRam,i;
PTOC pTOC=(PTOC)0x33F00000;//If TOC type definition is used, no need to assign address by yourself
//If PTOC type definition is used, the address given by compiler to pTOC variable is unknown
//Therefore, it is necessary to force to assign its address
NandReadSector(TOC_BLOCK*SECTOR_PER_BLOCK,(UINT8 *)pTOC);//Read the content of the 512th sector and assign it to TOC
if(!TOCIsValid(pTOC))
{
DEBUGMSG("\r\nTOC is not valid\r\n");
return 0;
}
DEBUGMSG("\r\nTOC is valid\r\n");
//Parameter dwEntry defines the entry mode, whether to directly enter the WinCE kernel or start Eboot
if(!(pTOC->id[unEntry].dwImageType &IMAGE_TYPE_RAMIMAGE))
{
return 0;
}
DEBUGMSG("\r\nImage is RamImage\r\n");
unSectorsNeeded= pTOC->id[unEntry].dwTtlSectors; //Total number of sectors occupied by the image
unRam=VIRTUAL_TO_PHYSICAL(pTOC->id[unEntry].dwLoadAddress);//Virtual address converted to physical address
DEBUGMSGEx("\r\nSectors Total=",pTOC->id[unEntry].dwTtlSectors ,10);
DEBUGMSGEx("\r\nVirtual Load Address =",pTOC->id[unEntry].dwLoadAddress,16);
DEBUGMSGEx("\r\nPhysical Load Address =",unRam,16);
i=0;
while(unSectorsNeeded && i
unSector = pTOC->id[unEntry].sgList[i].dwSector;
unLength = pTOC->id[unEntry].sgList[i].dwLength;
while(unLength)
{
if(unSector % SECTOR_PER_BLOCK == 0)//256页检查一次坏块
{
if(!NandCheckBadBlock(unSector/SECTOR_PER_BLOCK))
{
unSector+=SECTOR_PER_BLOCK;//Bad block exists
continue;//Do not perform the following operation
}
DEBUGMSG(".");
}
if(!NandReadSector(unSector,(UINT8 *)unRam))
{
DEBUGMSG("\r\nCan't Load WINCE Image\r\n");
while(1);
}
unSector++;
unLength--;
unRam+=SECTOR_SIZE;
}
unSectorsNeeded-=pTOC->id[unEntry].sgList[i].dwLength;
i++;
}
return (pTOC->id[unEntry].dwJumpAddress?VIRTUAL_TO_PHYSICAL(pTOC->id[unEntry].dwJumpAddress) ://获取加载镜像完成后的跳转地址
VIRTUAL_TO_PHYSICAL(pTOC->id[unEntry].dwLoadAddress));
}
void PORTInit(void)
{
rGPACON = 0x7fffff;
rGPDCON = 0xaaaaaaaa;
rGPDUP = 0xffff; // The pull up function is disabled GPD[15:0]
rGPECON = 0xaaaaaaaa;
rGPEUP = 0xffff;
rGPFUP = 0xff;
rGPGCON = 0xFD000000;
rGPGUP = 0xffff;
rGPHCON = 0x02faaa;
rGPHUP = 0x7ff;
rEXTINT0 = 0x22222222; // EINT[7:0]
rEXTINT1 = 0x22222222; // EINT[15:8]
rEXTINT2 = 0x22222222; // EINT[23:16]
}
#define BSP_ARGS_ADDR 0x30020800
#define BSP_ARGS_SIZE 0x800
/*
ARGS内存空间的注解
在WINCE的EBOOT中
ARGS 80028000 00000800 RESERVED
自0x80028000处,大小为0x00000800的空间被命名为ARGS,这个空间类型为
RESERVED,用于保存Bootloader和操作系统之间的共享数据
总之在0x30020800地址处必须要对其进行初始化为0,否则WINCE不能够正常激活
以下选自2440的BSP上的代码。
在BSP中,boot loader和OAL之间有一些数据可以共享
这段数据被存放在(BSP_ARGS *) IMAGE_SHARE_ARGS_UA_START这块内存里。
#define IMAGE_SHARE_ARGS_UA_START 0xA0020000
#define IMAGE_SHARE_ARGS_CA_START 0x80020800
#define IMAGE_SHARE_ARGS_SIZE 0x00000800
可以看出来,IMAGE_SHARE_ARGS_UA_START指向的是虚拟内存中的Uncached段,而IMAGE_SHARE_ARGS_CA_START指向虚拟内存中的Cached段。
我的g_oalAddressTable中这样定义:
DCD 0x80000000, 0x30000000, 64 ; 32 MB DRAM BANK 6
因此,它们分别是指向物理地址0x30020000和0x30020800。
然后看config.bib中,可以看到有这段定义:
; Common RAM areas
AUD_DMA 80002000 00000800 RESERVED
SDIO_DMA 80010000 00010000 RESERVED
ARGS 80020800 00000800 RESERVED
DBGSER_DMA 80022000 00002000 RESERVED
SER_DMA 80024000 00002000 RESERVED
IR_DMA 80026000 00002000 RESERVED
SLEEP 80028000 00002000 RESERVED
EDBG 80030000 00020000 RESERVED
DISPLAY 80100000 00100000 RESERVED
The physical address 0x30020800 corresponding to ARGS is reserved for IMAGE_SHARE_ARGS_CA_START. _BSPArgs Memory\r\n" ); BufClr( (
char*) BSP_ARGS_ADDR, BSP_ARGS_SIZE); //The address and length of pBSPArgs need to be determined according to the BSP package DEBUGMSG("\r\nLoading BSPArgs Memory\r\n" ); //The IO port must be initialized, otherwise the serial port cannot work properly UARTInit(S3C2440PCLK,115200); NandInit(); DEBUGMSGEx("\r\n\r\nPhysical BSPArgs Address = ",BSP_ARGS_ADDR,16); DEBUGMSGEx("\r\nBSPArgs Size = ",BSP_ARGS_SIZE,16); DEBUGMSG("\r\nClearing BSPArgs Memory\r\n"); BufClr((char*)BSP_ARGS_ADDR, BSP_ARGS_SIZE); //The address and length of pBSPArgs need to be determined according to the BSP package DEBUGMSG("\r\nLoading WINCE\r\n"); RunWINCE=(void(*)(void))ReadNandImageToRam(1); DEBUGMSGEx("\r\nPhysical Jump Address =",(UINT32)RunWINCE,16); DEBUGMSGEx("\r\n Virtual Jump Address =",PHYSICAL_TO_VIRTUAL((UINT32)RunWINCE),16); if(Run WINCE) { DEBUGMSG("\r\nLoad WINCE Successfully\r\n"); RunWINCE(); } while(1); return 0; }
Previous article:NBOOT Analysis - S3C244xInit.s (1)
Next article:ARM9 interrupt debugging (1)
- Popular Resources
- Popular amplifiers
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
- Share: Differences in power of wireless charging mobile phones and EMC rectification measures
- Pipeline water leakage monitor based on sound waves] Material unpacking-ESP32-S3-DEVKITC+STM32L496 Discovery kit
- [ESK32-360 Review] Potentiometer to adjust LCD text color
- [liklon plays with GD32F350] 4. SPI0 reads and writes spiflash
- 74 series integrated circuit names and functions
- Selling ZYNQ 7020 and other idle development boards
- Fiber Optic Components
- During the Mid-Autumn Festival, engineers will not work overtime!
- How to add relative path of header file in ccs?
- Different types of pin headers