⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 Nand Flash (SAMSUNG_K9K1G08U0B) boot loader for i.Mx31 (freescale).
💻 C
字号:
#include <common/types.h>
#include <common/message.h>

#include <nand/nand_tool.h>
#include "MX31_HABTools.h"

extern unsigned int bottom_of_heap;     // defined in heap.s 
extern unsigned int top_of_stacks;
extern unsigned int buffer_start;
extern unsigned int buffer_end;
U32 _gchannel;


/**********************************************************************
	SDRAM / DDR 
-------------------------	Memory Start
|						|
|	Flash Library		|	=> FLASH_LIB_SIZE ( now, 0x10000)
.						.
.						.
|						|
-------------------------	MEM_STORE_SOURCE_ADDR
|	Src Addr			|
-------------------------	MEM_STORE_TARGET_ADDR
|	Target Addr			|
-------------------------	MEM_STORE_BYTE_COUNT
|	Byte Count			|
-------------------------	MEM_RESERVED
|	Reserved			|
-------------------------	SourceAddress
| Image to be download	|
|						|
.						.	
.						.
.						.
.						.	

**********************************************************************/

#define CSD0_BASE_ADDR 0x80000000 //   CSD0

#define PARAMETER_SIZE			0x10
#define FLASH_LIB_SIZE			(0x10000 - PARAMETER_SIZE)
#define MEM_STORE_SOURCE_ADDR	(CSD0_BASE_ADDR + FLASH_LIB_SIZE)
#define MEM_STORE_TARGET_ADDR	(MEM_STORE_SOURCE_ADDR + 0x4)
#define MEM_STORE_BYTE_COUNT	(MEM_STORE_SOURCE_ADDR + 0x8)
#define MEM_STORE_CHANNEL		(MEM_STORE_SOURCE_ADDR + 0xC)

#define MEM_STORE_ERASE_PARTITION_START	(CSD0_BASE_ADDR + FLASH_LIB_SIZE - 0x10)
#define MEM_STORE_ERASE_PARTITION_END	(CSD0_BASE_ADDR + FLASH_LIB_SIZE - 0xC)


void try(void)
{
  while(1);
}

int main(void)
{

#ifdef HABTOOLKIT_FLASH_LIB

	U32		SourceAddress	=  *(volatile U32*)(MEM_STORE_SOURCE_ADDR);
	U32		FlashAddress	=  *(volatile U32*)(MEM_STORE_TARGET_ADDR);
	U32		ByteSize		=  *(volatile U32*)(MEM_STORE_BYTE_COUNT);
	
	U32		ErasePartitionStart =  *(volatile U32*)(MEM_STORE_ERASE_PARTITION_START);
	U32		ErasePartitionEnd 	=  *(volatile U32*)(MEM_STORE_ERASE_PARTITION_END);
	
	
	_gchannel = 0xFF; //clear _gchannel

	_gchannel		=  *(volatile U32*)(MEM_STORE_CHANNEL);
	EP1OutCommandSetup();

#endif


#ifdef DEBUG
  u32 FlashAddress  = 0;
  u32 SourceAddress = 0x80010000;			//	(u32)&buffer_start;
  u32 ByteSize      = 1*1024*1024;
  u32 ErasePartitionStart= 0;
  u32 ErasePartitionEnd = 0;
#endif 
  
  NAND_Init();
  
#ifdef DEBUG
  NAND_Info();
#endif
  
  // erase partion only when the end address is >0
  if (ErasePartitionEnd)
  	NAND_Erase_Conditional(ErasePartitionStart, ErasePartitionEnd);
  
  NAND_Loader(FlashAddress, SourceAddress, ByteSize);
  
//  NAND_Test();


#ifdef DEBUG
  Message("Complete\n");
#endif
  while(1);

  return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -