我想在U-Boot和Linux内核中添加自定义的atag变量。
我如何才能做到这一点?
是否有在U-Boot和Linux中添加ATAG变量的过程
发布于 2013-07-16 15:27:43
请按照以下步骤操作:
为了实现这个目标,有两个部分需要修改。一个是U-Boot,另一个是Linux内核。
1. U-Boot changes required :
A. Make sure the CONFIG_CMDLINE_TAG/CONFIG_SETUP_MEMORY_TAGS/CONFIG_INITRD_TAG are defined in you project definition header file ( u-boot/include/configs/am335x_evm.h ), and we can add our own tag here, eg. CONFIG_CUSTOM_TAG.
B. Add the structure definition you wanna append w/ ATAG in u-boot/include/asm-arm/setup.h, eg.
#define ATAG_CUSTOM 0x5441000a
struct tag_custom{
unsigned char mac_addr[6];
};
C. Add the struct at the tail of "u"...
struct tag {
struct tag_header hdr;
union {
struct tag_core core;
struct tag_mem32 mem;
struct tag_videotext videotext;
struct tag_ramdisk ramdisk;
struct tag_initrd initrd;
struct tag_serialnr serialnr;
struct tag_revision revision;
struct tag_videolfb videolfb;
struct tag_cmdline cmdline;
/*
* Acorn specific
*/
struct tag_acorn acorn;
/*
* DC21285 specific
*/
struct tag_memclk memclk;
/****** INFOTECH Custom TAG ********/
struct tag_custom custom;
} u;
};
D. Add implementation code in lib_arm/bootm.c:
static void setup_custom_tag(bd_t *bd);
static void setup_custom_tag(bd_t *bd) {
params->hdr.tag = ATAG_CUSTOM;
params->hdr.size = tag_size (tag_macaddr);
params->u.custom.cmd =0;
params = tag_next (params);
}
E. Add "#ifdef CONFIG_CUSTOM_TAG / #endif" at every place you change the code.
F. Done of U-Boot modification.
2. Linux Changes required:
A. Add parse tag code in linux/arch/arm/kernel/setup.c:
int cmd;
static int __init parse_tag_custom(const struct tag *tag){
printk("u.custom.cmd=%d\n",tag->u.custom.cmd);
return 0;
}
__tagtable(ATAG_MACADDR, parse_tag_custom);
B. Add the structure declaration as U-Boot did in linux/include/asm-arm/setup.h:
#define ATAG_MACADDR 0x5441000a
struct tag_custom {
int cmd;
};
C. Add the struct at the tail of "u"...
struct tag {
struct tag_header hdr;
union {
struct tag_core core;
struct tag_mem32 mem;
struct tag_videotext videotext;
struct tag_ramdisk ramdisk;
struct tag_initrd initrd;
struct tag_serialnr serialnr;
struct tag_revision revision;
struct tag_videolfb videolfb;
struct tag_cmdline cmdline;
/*
* Acorn specific
*/
struct tag_acorn acorn;
/*
* DC21285 specific
*/
struct tag_memclk memclk;
/* Add Infotech custom tag */
struct tag_custom custom;
} u;
};
D. Done w/ Kernel parts.发布于 2013-07-16 08:54:45
最新的Linux内核正试图通过设备树来淘汰ATAGS。但是,setup.h文件定义了不同的ATAG值和结构。要解析它们,您需要添加类似以下内容的内容:
static int __init parse_tag_custom(const struct tag *tag)
{
if (tag->hdr.size > CUSTOM_SIZE) {
/* Use, storing or acting on passed values */
tag->u.custom;
}
return 0;
}
__tagtable(ATAG_CUSTOM, parse_tag_custom);在atags_parse.c中可以找到。当然,您需要将这些值添加到setup.h中的值。
u-boot可能定义较少,因为在大多数情况下,它通过内核命令行传递参数,因为这不是ARM特定的。命令参数或设备树可能是首选方法。如果你举一个例子说明你需要什么类型的配置,别人可能会给你更好的指导。
发布于 2013-10-26 02:34:55
需要更改
确保在你的项目定义头文件(u- CONFIG_CMDLINE_TAG/CONFIG_SETUP_MEMORY_TAGS/CONFIG_INITRD_TAG /include/configs/AM335xevm.h )中定义了引导,我们可以在这里添加我们自己的标签,例如。CONFIG_CUSTOM_TAG。B.在u-boot/include/asm-arm/setup.h中添加要附加w/ ATAG的结构定义,例如。#define ATAG_CUSTOM 0x5441000a结构tag_custom{ unsigned char mac_addr6;};C.在“u”的尾部添加结构...结构标签{结构tag_header hdr;联合{结构tag_core核心;结构tag_mem32内存;结构tag_videotext视频文本;结构tag_ramdisk内存磁盘;结构tag_initrd初始化;结构tag_serialnr序列号;结构tag_revision修订版;struct tag_videolfb videolfb;struct tag_cmdline cmdline;/* * Acorn */ struct tag_acorn acorn;/* * DC21285 specific */ struct tag_memclk memclk;/****** INFOTECH自定义标签*/ struct tag_custom自定义;} u;};D.在lib_arm/bootm.c中添加实现代码: static void setup_custom_tag(bd_t *bd);static void setup_custom_tag(bd_t *bd) { params->hdr.tag = ATAG_CUSTOM;params->hdr.size = tag_size (tag_macaddr);params->u.custom.cmd =0;params = tag_next (params);} E.在您更改代码的每个位置添加"#ifdef CONFIG_CUSTOM_TAG / #endif“。F.完成U-Boot修改。
1. Linux Changes required:A.在linux/arch/arm/kernel/setup.c中添加解析标签代码:
int cmd;static int __init parse_tag_custom(const struct tag *tag){ printk("u.custom.cmd=%d\n",tag->u.custom.cmd);return 0;} __tagtable(ATAG_MACADDR,parse_tag_custom);
B.添加结构声明,如U-Boot在linux/include/asm-arm/setup.h中所做的那样:
#定义ATAG_MACADDR 0x5441000a结构tag_custom { int cmd;};
C.在“u”的尾部添加结构...
结构标签{结构tag_header hdr;联合{结构tag_core核心;结构tag_mem32内存;结构tag_videotext视频文本;结构tag_ramdisk内存磁盘;结构tag_initrd初始化磁盘;结构tag_serialnr序列号;结构tag_revision修订版;结构tag_videolfb视频mem;结构tag_cmdline命令行;/* *橡子专用*/结构tag_acorn acorn;/* * DC21285专用*/结构tag_memclk memclk;/*添加Infotech自定义标签*/结构tag_custom自定义;} u;};
D.使用内核部件完成。
https://stackoverflow.com/questions/17661550
复制相似问题