# Add hello app to buildroot ## 目的 希望能在能在[riscv64 buildroot](https://hackmd.io/@sysprog/ryHaBkrOE?type=view)的基礎的上面加入簡單的hello world 應用套件。 ## 作法 1. 在建立好的**buldroot**資料夾底下的**package**底下新增一個**hello**的資料夾 2. 在hello資料夾新增以下檔案 * hello.c ```bash= ``` * hello.mk ```bash= ################################################################################ # # hello # ################################################################################ HELLO_VERSION = 1.0 HELLO_SITE = ./package/hello HELLO_SITE_METHOD = local # HELLO_DEPENDENCIES += libdrm define HELLO_BUILD_CMDS $(MAKE) -C $(@D) $(TARGET_CONFIGURE_OPTS) endef define HELLO_INSTALL_TARGET_CMDS $(INSTALL) -D -m 0755 $(@D)/hello $(TARGET_DIR)/usr/bin endef $(eval $(generic-package)) ``` * hello.c ```bash= #include <stdio.h> int main(void) { puts("hello"); } ``` * Makefile ```bash= # CFLAGS_EXTRA = $(shell $(PKG_CONFIG) --cflags libdrm) # LIBS = $(shell $(PKG_CONFIG) --libs libdrm) .PHONY: clean hello: hello.c $(CC) $(CFLAGS) $(CFLAGS_EXTRA) -o '$@' '$<' $(LIBS) clean: rm hello ``` * Config.in ```bash= config BR2_PACKAGE_HELLO bool "hello" # depends on BR2_PACKAGE_LIBDRM help Hello world package. http://example.com ``` 3. 新增package底下的**Config.in**使其在**make menuconfig**之後出現Target packages下的Miscs裡面有hello的選項 ```bash= menu "User-provided options" depends on BR2_EXTERNAL != "support/dummy-external" source "$BR2_EXTERNAL/Config.in" endmenu #檔案最後 ``` 4. 之後使用temu去執行會出現以下結果  ## 修改套件內容 如果需要修改buildroot裡面的內容,在修改完之後需要將output/build底下模組相關的套件資料夾刪除之後再重新make之後才會有效。 以現在這個例子就是要刪掉output/build/hello-1.0之後在make ```bash= rm -r output/build/hello-1.0 make ``` --- ## 備份 如果需要備份需用指令**tar**指令打包,若是用指令**cp**直接複製在還原之後在**make**會失敗 --- ## 參考資料 [ Buildroot Add Package的一些坑](https://blog.csdn.net/z2066411585/article/details/84556978) [Ajouter un package dans Buildroot en 5 minutes](https://www.linuxembedded.fr/2011/03/ajouter-un-package-dans-buildroot-en-5-minutes/) [How to add an autotools package to Buildroot?](https://unix.stackexchange.com/questions/65623/how-to-add-an-autotools-package-to-buildroot) [How to add an autotools package to Buildroot?](https://unix.stackexchange.com/questions/65623/how-to-add-an-autotools-package-to-buildroot) [Buildroot Package How-to](https://cdcvs.fnal.gov/redmine/projects/ees-buildroot/wiki/Buildroot_Package_How-to) [cirosantilli/buildroot](https://github.com/cirosantilli/buildroot/tree/in-tree-package-master) [Buildroot: a deep dive into the core](https://elinux.org/images/0/05/Petazzoni--buildroot_a_deep_dive_into_the_core.pdf) ###### tags: `buildroot` `linux` `riscv`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up