Skip to content

天楚锐齿

人工智能 云计算 大数据 物联网 IT 通信 嵌入式

天楚锐齿

  • 下载
  • 物联网
  • 云计算
  • 大数据
  • 人工智能
  • Linux&Android
  • 网络
  • 通信
  • 嵌入式
  • 杂七杂八

mini6410板uboot的Board.c

2018-03-13
/*
* To match the U-Boot user interface on ARM platforms to the U-Boot
* standard (as on PPC platforms), some messages with debug character
* are removed from the default U-Boot build.
*
* Define DEBUG here if you want additional info as shown below
* printed upon startup:
*
* U-Boot code: 00F00000 -> 00F3C774  BSS: -> 00FC3274
* IRQ Stack: 00ebff7c
* FIQ Stack: 00ebef7c
*/

#include <common.h>
#include <command.h>
#include <malloc.h>
#include <devices.h>
#include <version.h>
#include <net.h>
#include <asm/io.h>

#if defined(CONFIG_BOOT_MOVINAND)
#include <movi.h>
#endif

#ifdef CONFIG_DRIVER_SMC91111
#include “../drivers/smc91111.h”
#endif
#ifdef CONFIG_DRIVER_LAN91C96
#include “../drivers/lan91c96.h”
#endif

/* Note: volatile register variable is *NOT* volatile in gcc 4.5.1+ */
#if     0
DECLARE_GLOBAL_DATA_PTR;
#else
gd_t *gd;
#endif

#if (CONFIG_COMMANDS & CFG_CMD_NAND)
void nand_init (void);
#endif

#ifdef CONFIG_ONENAND
void onenand_init(void);
#endif

ulong monitor_flash_len;

#ifdef CONFIG_HAS_DATAFLASH
extern int  AT91F_DataflashInit(void);
extern void dataflash_print_info(void);
#endif

#ifndef CONFIG_IDENT_STRING
#define CONFIG_IDENT_STRING “”
#endif

const char version_string[] =
U_BOOT_VERSION” (” __DATE__ ” – ” __TIME__ “)”CONFIG_IDENT_STRING;

#ifdef CONFIG_DRIVER_CS8900
extern void cs8900_get_enetaddr (uchar * addr);
#endif

#ifdef CONFIG_DRIVER_RTL8019
extern void rtl8019_get_enetaddr (uchar * addr);
#endif

/*
* Begin and End of memory area for malloc(), and current “brk”
*/
static ulong mem_malloc_start = 0;
static ulong mem_malloc_end = 0;
static ulong mem_malloc_brk = 0;

static
void mem_malloc_init (ulong dest_addr)
{
mem_malloc_start = dest_addr;
mem_malloc_end = dest_addr + CFG_MALLOC_LEN;
mem_malloc_brk = mem_malloc_start;

/* memset ((void *) mem_malloc_start, 0,
mem_malloc_end – mem_malloc_start); */
}

void *sbrk (ptrdiff_t increment)
{
ulong old = mem_malloc_brk;
ulong new = old + increment;

if ((new < mem_malloc_start) || (new > mem_malloc_end)) {
return (NULL);
}
mem_malloc_brk = new;

return ((void *) old);
}

/************************************************************************
* Init Utilities                                   *
************************************************************************
* Some of this code should be moved into the core functions,
* or dropped completely,
* but let’s get it working (again) first…
*/

static int init_baudrate (void)
{
char tmp[64];     /* long enough for environment variables */
int i = getenv_r (“baudrate”, tmp, sizeof (tmp));
gd->bd->bi_baudrate = gd->baudrate = (i > 0)
? (int) simple_strtoul (tmp, NULL, 10)
: CONFIG_BAUDRATE;

return (0);
}

static int display_banner (void)
{
printf (“\n\n%s\n\n”, version_string);
debug (“U-Boot code: %08lX -> %08lX  BSS: -> %08lX\n”,
_armboot_start, _bss_start, _bss_end);
#ifdef CONFIG_MEMORY_UPPER_CODE /* by scsuh */
debug(“\t\bMalloc and Stack is above the U-Boot Code.\n”);
#else
debug(“\t\bMalloc and Stack is below the U-Boot Code.\n”);
#endif
#ifdef CONFIG_MODEM_SUPPORT
debug (“Modem Support enabled\n”);
#endif
#ifdef CONFIG_USE_IRQ
debug (“IRQ Stack: %08lx\n”, IRQ_STACK_START);
debug (“FIQ Stack: %08lx\n”, FIQ_STACK_START);
#endif

return (0);
}

/*
* WARNING: this code looks “cleaner” than the PowerPC version, but
* has the disadvantage that you either get nothing, or everything.
* On PowerPC, you might see “DRAM: ” before the system hangs – which
* gives a simple yet clear indication which part of the
* initialization if failing.
*/
static int display_dram_config (void)
{
int i;

#ifdef DEBUG
puts (“RAM Configuration:\n”);

for(i=0; i<CONFIG_NR_DRAM_BANKS; i++) {
printf (“Bank #%d: %08lx “, i, gd->bd->bi_dram[i].start);
print_size (gd->bd->bi_dram[i].size, “\n”);
}
#else
ulong size = 0;

for (i=0; i<CONFIG_NR_DRAM_BANKS; i++) {
size += gd->bd->bi_dram[i].size;
}

puts(“DRAM:    “);
print_size(size, “\n”);
#endif

return (0);
}

#ifndef CFG_NO_FLASH
static void display_flash_config (ulong size)
{
puts (“Flash:  “);
print_size (size, “\n”);
}
#endif /* CFG_NO_FLASH */

/*
* Breathe some life into the board…
*
* Initialize a serial port as console, and carry out some hardware
* tests.
*
* The first part of initialization is running from Flash memory;
* its main purpose is to initialize the RAM so that we
* can relocate the monitor code to RAM.
*/

/*
* All attempts to come up with a “common” initialization sequence
* that works for all boards and architectures failed: some of the
* requirements are just _too_ different. To get rid of the resulting
* mess of board dependent #ifdef’ed code we now make the whole
* initialization sequence configurable to the user.
*
* The requirements for any new initalization function is simple: it
* receives a pointer to the “global data” structure as it’s only
* argument, and returns an integer return code, where 0 means
* “continue” and != 0 means “fatal error, hang the system”.
*/
typedef int (init_fnc_t) (void);

int print_cpuinfo (void); /* test-only */

init_fnc_t *init_sequence[] = {
cpu_init,          /* basic cpu dependent setup */            设置栈地址
board_init,          /* basic board dependent setup */     初始化总线,为LCD设置GPIO,设置架构类型,启动参数保存位置0x50000000+0x100
interrupt_init,          /* set up exceptions */
env_init,          /* initialize environment */
init_baudrate,          /* initialze baudrate settings */
serial_init,          /* serial communications setup */
console_init_f,          /* stage 1 init of console */
display_banner,          /* say that we are here */
#if defined(CONFIG_DISPLAY_CPUINFO)
print_cpuinfo,          /* display cpu info (and speed) */
#endif
#if defined(CONFIG_DISPLAY_BOARDINFO)
checkboard,          /* display board info */
#endif
dram_init,          /* configure available RAM banks */
display_dram_config,
NULL,
};

void start_armboot (void)     /*################################# 汇编代码执行完之后第一个执行的c函数 ###################################*/
{
init_fnc_t **init_fnc_ptr;
char *s;
#ifndef CFG_NO_FLASH
ulong size;
#endif

#if defined(CONFIG_VFD) || defined(CONFIG_LCD)
unsigned long addr;
#endif

#if defined(CONFIG_BOOT_MOVINAND)
uint *magic = (uint *) (PHYS_SDRAM_1);
#endif

/* Pointer is writable since we allocated a register for it */
#ifdef CONFIG_MEMORY_UPPER_CODE /* by scsuh */                           /* 栈配置到代码的上面*/
ulong gd_base;

gd_base = CFG_UBOOT_BASE + CFG_UBOOT_SIZE – CFG_MALLOC_LEN – CFG_STACK_SIZE – sizeof(gd_t);  /*基地址0xc7e00000加上整个为uboot预留的大小,去掉malloc分配用的内存,去掉栈大小,去掉全局数据大小*/
#ifdef CONFIG_USE_IRQ
gd_base -= (CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ);          /*去掉IRQ和FIQ栈大小*/
#endif
gd = (gd_t*)gd_base;                                                                         /*在这个位置保存全局配置数据*/
#else
gd = (gd_t*)(_armboot_start – CFG_MALLOC_LEN – sizeof(gd_t));         /*如果栈在代码下面,则用0xc7e00000去掉malloc分配用内存,去掉全局数据大小,设置为全局配置数据位置。*/
#endif

/* compiler optimization barrier needed for GCC >= 3.4 */            /*告诉编译器,下面的代码不要优化。*/
__asm__ __volatile__(“”: : :”memory”);

memset ((void*)gd, 0, sizeof (gd_t));
gd->bd = (bd_t*)((char*)gd – sizeof(bd_t));                              /*gd下面存放的是bd_t。*/
memset (gd->bd, 0, sizeof (bd_t));

monitor_flash_len = _bss_start – _armboot_start;                      /*代码长度*/

for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) { /*按照顺序初始化各种硬件资源,见上面定义的init_sequence函数表。*/

          if ((*init_fnc_ptr)() != 0) {
hang ();
}
}

#ifndef CFG_NO_FLASH
/* configure available FLASH banks */
size = flash_init ();
display_flash_config (size);
#endif /* CFG_NO_FLASH */

#ifdef CONFIG_VFD
#     ifndef PAGE_SIZE
#       define PAGE_SIZE 4096
#     endif
/*
* reserve memory for VFD display (always full pages)
*/
/* bss_end is defined in the board-specific linker script */
addr = (_bss_end + (PAGE_SIZE – 1)) & ~(PAGE_SIZE – 1);
size = vfd_setmem (addr);
gd->fb_base = addr;
#endif /* CONFIG_VFD */

#ifdef CONFIG_LCD
#     ifndef PAGE_SIZE
#       define PAGE_SIZE 4096
#     endif
/*
* reserve memory for LCD display (always full pages)
*/
/* bss_end is defined in the board-specific linker script */
addr = (_bss_end + (PAGE_SIZE – 1)) & ~(PAGE_SIZE – 1);
size = lcd_setmem (addr);
gd->fb_base = addr;
#endif /* CONFIG_LCD */

/* armboot_start is defined in the board-specific linker script */
#ifdef CONFIG_MEMORY_UPPER_CODE /* by scsuh */
mem_malloc_init (CFG_UBOOT_BASE + CFG_UBOOT_SIZE – CFG_MALLOC_LEN – CFG_STACK_SIZE);
#else
mem_malloc_init (_armboot_start – CFG_MALLOC_LEN);
#endif

#if defined(CONFIG_SMDK6400) || defined(CONFIG_SMDK6410) || defined(CONFIG_SMDK6430) || defined(CONFIG_SMDK2450) || defined(CONFIG_SMDK2416) || \
defined(CONFIG_MINI6410)

#if defined(CONFIG_NAND)
puts (“NAND:    “);
nand_init();          /* go init the NAND */
#endif

#if defined(CONFIG_ONENAND)
puts (“OneNAND: “);
onenand_init();          /* go init the One-NAND */
#endif

#if defined(CONFIG_BOOT_MOVINAND)
puts (“MMC:     “);

if ((0x24564236 == magic[0]) && (0x20764316 == magic[1])) {
printf(“Boot up for burning\n”);
} else {
movi_set_capacity();
movi_set_ofs(MOVI_TOTAL_BLKCNT);
movi_init();
}
#endif

#else

#if (CONFIG_COMMANDS & CFG_CMD_NAND)
puts (“NAND:    “);
nand_init();          /* go init the NAND */
#endif

#endif

#ifdef CONFIG_HAS_DATAFLASH
AT91F_DataflashInit();
dataflash_print_info();
#endif

/* initialize environment */
env_relocate ();

#ifdef CONFIG_VFD
/* must do this after the framebuffer is allocated */
drv_vfd_init();
#endif /* CONFIG_VFD */

/* IP Address */
gd->bd->bi_ip_addr = getenv_IPaddr (“ipaddr”);

/* MAC Address */
{
int i;
ulong reg;
char *s, *e;
char tmp[64];

i = getenv_r (“ethaddr”, tmp, sizeof (tmp));
s = (i > 0) ? tmp : NULL;

for (reg = 0; reg < 6; ++reg) {
gd->bd->bi_enetaddr[reg] = s ? simple_strtoul (s, &e, 16) : 0;
if (s)
s = (*e) ? e + 1 : e;
}

#ifdef CONFIG_HAS_ETH1
i = getenv_r (“eth1addr”, tmp, sizeof (tmp));
s = (i > 0) ? tmp : NULL;

for (reg = 0; reg < 6; ++reg) {
gd->bd->bi_enet1addr[reg] = s ? simple_strtoul (s, &e, 16) : 0;
if (s)
s = (*e) ? e + 1 : e;
}
#endif
}

devices_init ();     /* get the devices list going. */

#ifdef CONFIG_CMC_PU2
load_sernum_ethaddr ();
#endif /* CONFIG_CMC_PU2 */

jumptable_init ();

console_init_r ();     /* fully init console as a device */

#if defined(CONFIG_MISC_INIT_R)
/* miscellaneous platform dependent initialisations */
misc_init_r ();
#endif

/* enable exceptions */
enable_interrupts ();

/* Perform network card initialisation if necessary */
#if defined(CONFIG_DRIVER_DM9000) && defined(CONFIG_DRIVER_DM9000_NO_EEPROM)
extern int eth_set_mac(bd_t * bd);
if (getenv (“ethaddr”)) {
eth_set_mac(gd->bd);
}
#endif

#ifdef CONFIG_DRIVER_CS8900
cs8900_get_enetaddr (gd->bd->bi_enetaddr);
#endif

#if defined(CONFIG_DRIVER_SMC91111) || defined (CONFIG_DRIVER_LAN91C96)
if (getenv (“ethaddr”)) {
smc_set_mac_addr(gd->bd->bi_enetaddr);
}
#endif /* CONFIG_DRIVER_SMC91111 || CONFIG_DRIVER_LAN91C96 */

/* Initialize from environment */
if ((s = getenv (“loadaddr”)) != NULL) {
load_addr = simple_strtoul (s, NULL, 16);
}
#if (CONFIG_COMMANDS & CFG_CMD_NET)
if ((s = getenv (“bootfile”)) != NULL) {
copy_filename (BootFile, s, sizeof (BootFile));
}
#endif     /* CFG_CMD_NET */

#ifdef BOARD_LATE_INIT
board_late_init ();
#endif
#if (CONFIG_COMMANDS & CFG_CMD_NET)
#if defined(CONFIG_NET_MULTI)
puts (“Net:     “);
#endif
eth_initialize(gd->bd);
#endif
/* main_loop() can return to retry autoboot, if so just run it again. */                /*进入主循环,执行一条一条的命令,定义在Main.C里面*/
for (;;) {
main_loop ();
}

/* NOTREACHED – no way out of command loop except booting */
}

void hang (void)
{
puts (“### ERROR ### Please RESET the board ###\n”);
for (;;);
}

#ifdef CONFIG_MODEM_SUPPORT
static inline void mdm_readline(char *buf, int bufsiz);

/* called from main loop (common/main.c) */
extern void  dbg(const char *fmt, …);
int mdm_init (void)
{
char env_str[16];
char *init_str;
int i;
extern char console_buffer[];
extern void enable_putc(void);
extern int hwflow_onoff(int);

enable_putc(); /* enable serial_putc() */

#ifdef CONFIG_HWFLOW
init_str = getenv(“mdm_flow_control”);
if (init_str && (strcmp(init_str, “rts/cts”) == 0))
hwflow_onoff (1);
else
hwflow_onoff(-1);
#endif

for (i = 1;;i++) {
sprintf(env_str, “mdm_init%d”, i);
if ((init_str = getenv(env_str)) != NULL) {
serial_puts(init_str);
serial_puts(“\n”);
for(;;) {
mdm_readline(console_buffer, CFG_CBSIZE);
dbg(“ini%d: [%s]”, i, console_buffer);

if ((strcmp(console_buffer, “OK”) == 0) ||
(strcmp(console_buffer, “ERROR”) == 0)) {
dbg(“ini%d: cmd done”, i);
break;
} else /* in case we are originating call … */
if (strncmp(console_buffer, “CONNECT”, 7) == 0) {
dbg(“ini%d: connect”, i);
return 0;
}
}
} else
break; /* no init string – stop modem init */

udelay(100000);
}

udelay(100000);

/* final stage – wait for connect */
for(;i > 1;) { /* if ‘i’ > 1 – wait for connection
message from modem */
mdm_readline(console_buffer, CFG_CBSIZE);
dbg(“ini_f: [%s]”, console_buffer);
if (strncmp(console_buffer, “CONNECT”, 7) == 0) {
dbg(“ini_f: connected”);
return 0;
}
}

return 0;
}

/* ‘inline’ – We have to do it fast */
static inline void mdm_readline(char *buf, int bufsiz)
{
char c;
char *p;
int n;

n = 0;
p = buf;
for(;;) {
c = serial_getc();

/*          dbg(“(%c)”, c); */

switch(c) {
case ‘\r’:
break;
case ‘\n’:
*p = ‘\0’;
return;

default:
if(n++ > bufsiz) {
*p = ‘\0’;
return; /* sanity check */
}
*p = c;
p++;
break;
}
}
}
#endif     /* CONFIG_MODEM_SUPPORT */

1,234次阅读

Post navigation

前一篇:

mini6410板uboot的Movi.c

后一篇:

mini6410板uboot的Cmd_bootm.c

发表回复 取消回复

要发表评论,您必须先登录。

个人介绍

需要么,有事情这里找联系方式:关于天楚锐齿

=== 美女同欣赏,好酒共品尝 ===

微信扫描二维码赞赏该文章:

扫描二维码分享该文章:

分类

  • Linux&Android (81)
  • Uncategorized (1)
  • 下载 (28)
  • 云计算 (38)
  • 人工智能 (9)
  • 大数据 (35)
  • 嵌入式 (34)
  • 杂七杂八 (35)
  • 物联网 (65)
  • 网络 (25)
  • 通信 (22)

归档

近期文章

  • 飞书机器人发送卡片interactive消息
  • Springboot JPA实现对数据库表统一的增删改查
  • WEB的内容安全策略CSP(Content-Security-Policy)
  • CSS利用@media和viewport实现响应式布局自动适配手机电脑等
  • VUE前端增加国际化支持

近期评论

  • linux爱好者 发表在《Linux策略路由及iptables mangle、ip rule、ip route关系及一种Network is unreachable错误》
  • maxshu 发表在《使用Android的HIDL+AIDL方式编写从HAL层到APP层的程序》
  • Ambition 发表在《使用Android的HIDL+AIDL方式编写从HAL层到APP层的程序》
  • Ambition 发表在《使用Android的HIDL+AIDL方式编写从HAL层到APP层的程序》
  • maxshu 发表在《Android9下用ethernet 的Tether模式来做路由器功能》

阅读量

  • 使用Android的HIDL+AIDL方式编写从HAL层到APP层的程序 - 23,810次阅读
  • 卸载深信服Ingress、SecurityDesktop客户端 - 18,519次阅读
  • 车机技术之车规级Linux-Automotive Grade Linux(AGL) - 10,569次阅读
  • linux下的unbound DNS服务器设置详解 - 9,323次阅读
  • 在Android9下用ndk编译vSomeIP和CommonAPI以及使用例子 - 9,136次阅读
  • linux的tee命令导致ssh客户端下的shell卡住不动 - 8,639次阅读
  • Linux策略路由及iptables mangle、ip rule、ip route关系及一种Network is unreachable错误 - 8,126次阅读
  • 车机技术之360°全景影像(环视)系统 - 8,088次阅读
  • 车机技术之Android Automotive - 7,940次阅读
  • Windows下安装QEMU并在qemu上安装ubuntu和debian - 7,840次阅读

其他操作

  • 注册
  • 登录
  • 条目 feed
  • 评论 feed
  • WordPress.org

联系方式

地址
深圳市科技园

时间
周一至周五:  9:00~12:00,14:00~18:00
周六和周日:10:00~12:00

标签

android AT命令 CAN centos docker Hadoop hdfs ip java kickstart linux mapreduce mini6410 modem nova OAuth openstack os python socket ssh uboot 内核 协议 安装 嵌入式 性能 报表 授权 操作系统 数据 数据库 月报 模型 汽车 深信服 源代码 统计 编译 脚本 虚拟机 调制解调器 车机 金融 鉴权
© 2025 天楚锐齿