RPI U-boot Custom command
From arrizza.org wiki
Jump to navigation Jump to searchRaspberryPi ⇫ Up | RPI U-boot run sd card application ⇨ Next Topic | |
---|---|---|
Previous Page ⇦ RPI U-boot Example App |
Prepare application
There are many commands in u-boot-pi-rpi/common/cmd_*.c, choose one that is similar to your requirements and copy it. In the sample below I use "cmd_ja.c"
- Add the new source file to u-boot-pi-rpi/common directory
/* * JA: my stuff */ #include <common.h> #include <command.h> DECLARE_GLOBAL_DATA_PTR; static int do_ja(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { int rcode = 0; puts("in ja\n"); for (;;) { puts("\n--------------\n"); puts(" q quit\n"); puts(" a run 'a'\n"); puts(" b run 'b'\n"); puts(" c run 'c'\n"); puts("-- enter cmd: "); char c = getc(); switch (c) { case 'q': puts("bye\n"); return 0; case 'a': printf("doing 'a'!\n"); break; case 'b': printf("doing 'b'!\n"); break; case 'c': printf("doing 'c'!\n"); break; case '\r': break; default: printf("huh? don't know: '%c'\n", c); break; } } printf("exiting. rcode=%d\n\n", rcode); return rcode; } /***************************************************/ // name,#parms, isrepeatable?, cmd list, help text U_BOOT_CMD(ja, 1, 1, do_ja, "do cool things", "invoke the 'ja' application");
- Edit Common Makefile:
edit u-boot-pi-rpi/common/Makefile add the executable to the COBS-y variable 45,47d44 < #JA: add my own command < COBJS-y += cmd_ja.o
- re-compile
./doit
- the command is now in the u-boot executable, so load the sdcard as normal
./deployit
run it
U-Boot> ja in ja -------------- q quit a run 'a' b run 'b' c run 'c' -- enter cmd: doing 'a'! -------------- q quit a run 'a' b run 'b' c run 'c' -- enter cmd: huh? don't know: 'n'
-------------- q quit a run 'a' b run 'b' c run 'c' -- enter cmd: bye U-Boot>
Try help:
U-Boot> help <snip> itest - return true/false on integer compare ja - do cool thing load - load binary file from a filesystem <snip> U-Boot> help ja ja - do cool thing Usage: ja invoke the 'ja' application U-Boot>