查看Buildroot Quick Start的源代码
←
Buildroot Quick Start
跳转到:
导航
,
搜索
因为以下原因,你没有权限编辑本页:
您刚才请求的操作只有这个用户组中的用户才能使用:
用户
您可以查看并复制此页面的源代码:
== Overview == 目录结构: <source lang=bash> comcat@jackslab:~/buildroot-2020.11.2$ ls arch board boot CHANGES Config.in Config.in.legacy configs COPYING DEVELOPERS dl docs fs linux Makefile Makefile.legacy output package README support system toolchain utils </source> Download package cache dir: <source lang=bash> dl/ </source> <br> == 添加包 == <source lang=bash> comcat@jackslab:~/buildroot-2020.11.2$ mkdir -p package/helloworld/ </source> 在该目录下新建 '''Config.in''': <source lang=bash> config BR2_PACKAGE_HELLOWORLD bool "helloworld" help hello world package </source> 新建 '''helloworld.mk''': <source lang=bash> comcat@lab:~/buildroot-2020.11.2$ cat package/helloworld/helloworld.mk HELLOWORLD_VERSION = 1.0.0 HELLOWORLD_SITE = $(TOPDIR)/../helloworld_src HELLOWORLD_SITE_METHOD = local define HELLOWORLD_BUILD_CMDS $(MAKE) $(TARGET_CONFIGURE_OPTS) -C $(@D) endef define HELLOWORLD_INSTALL_TARGET_CMDS $(INSTALL) -D -m 0755 $(@D)/helloworld $(TARGET_DIR)/usr/bin/helloworld #$(INSTALL) -D -m 0755 $(@D)/helloworld-init $(TARGET_DIR)/etc/init.d/S90helloworld #$(INSTALL) -D -m 0755 $(@D)/rx $(TARGET_DIR)/usr/bin/rx endef $(eval $(generic-package)) </source> * HELLOWORLD_SITE is the location of the helloworld.c, init script, and makefile. * $(TOPDIR) is the top directory, in our case ~/buildroot-2020.11.2 * $(@D) is the build directory. 编辑 ~/buildroot-2020.11.2/package/Config.in,增加如下内容: source "package/helloworld/Config.in" <br> == 准备代码 == <source lang=bash> $ mkdir ~/helloworld_src </source> 放入 helloworld.c Makefile: '''helloworld.c:''' <source lang=cpp> #include <stdio.h> #include <unistd.h> int main(int argc, int *argv[]) { while(1) { printf("Hello world\n"); sleep(1); } return 0; } </source> '''Makefile:''' <source lang=makefile> OBJS=helloworld.o all: helloworld helloworld: $(OBJS) $(CC) $(LDFLAGS) -o helloworld $(OBJS) $(OBJS): %.o: %.c $(CC) $(CFLAGS) -c -o $@ $< </source> or: <source lang=bash> all: tx rx loopback cad #CC=arm-linux-gnueabi-gcc tx: common.c tx.c $(CC) $(LDFLAGS) $(CFLAGS) -I./ $^ -o $@ rx: common.c rx.c $(CC) $(LDFLAGS) $(CFLAGS) -I./ $^ -o $@ clean: rm -f tx rx loopback cad </source> <br> == 编译构建 == <source lang=bash> comcat@jackslab:~/buildroot-2020.11.2$ make menuconfig comcat@jackslab:~/buildroot-2020.11.2$ make comcat@jackslab:~/buildroot-2020.11.2$ ls output/images/rootfs.tar output/images/rootfs.tar </source> <br>
返回到
Buildroot Quick Start
。
个人工具
登录
名字空间
页面
讨论
变换
查看
阅读
查看源代码
查看历史
操作
搜索
导航
首页
社区专页
新闻动态
最近更改
随机页面
帮助
工具箱
链入页面
相关更改
特殊页面