简体   繁体   English

如何使用U-Boot API?

[英]How to use the U-Boot API?

I am working with the customized atmel version of U-Boot (u-boot-at91) on an atmel evalboard at91sam9x5ek. 我正在atmel评估板at91sam9x5ek上使用U-Boot的定制atmel版本(u-boot-at91)。 I use U-Boot to start Linux which is working fine. 我使用U-Boot启动运行良好的Linux。 I want to implement a simple C application that reads and changes some data from the ram. 我想实现一个简单的C应用程序,该应用程序可以读取和更改ram中的某些数据。 I was able to compile and run the hello_world example from the examples/standalone/ folder. 我能够从examples/standalone/文件夹编译并运行hello_world示例。 My problem is that I can't figure out how to access the api-functions made available by glue.h in the examples/api/ folder. 我的问题是我无法弄清楚如何访问examples/api/文件夹中glue.h提供的api函数。 I can include the file but get the following error message on compiling: 我可以包含该文件,但在编译时会收到以下错误消息:

u-boot-at91/examples/standalone/hello_world.c:34: undefined reference to `ub_env_set'

I added #define CONFIG_API to my boards header file so the api is build. 我将#define CONFIG_API添加到了我的板子头文件中,从而构建了api。

The function ub_env_set() is implemented in glue.c, here's what it looks like: 函数ub_env_set()是在gum.c中实现的,它看起来像这样:

void ub_env_set(const char *name, char *value)
{
    syscall(API_ENV_SET, NULL, (uint32_t)name, (uint32_t)value);
}

One option would be to compile and link glue.c into your executable. 一种选择是将胶水.c编译并链接到您的可执行文件中。

Another option would be to just add a copy of ub_env_set() to your code and make sure you're including api_public.h as follows: 另一个选择是将ub_env_set()的副本添加到您的代码中,并确保包含api_public.h,如下所示:

#include <api_public.h>

then you should be able to compile. 那么您应该可以编译。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM