diff --git a/tests/riotboot/Makefile b/tests/riotboot/Makefile new file mode 100644 index 0000000000000..3e49c4f0bd2df --- /dev/null +++ b/tests/riotboot/Makefile @@ -0,0 +1,23 @@ +include ../Makefile.tests_common + +# If no BOARD is found in the environment, use this default: +BOARD ?= samr21-xpro + +# Select the boards that were tested and work with riotboot +BOARD_WHITELIST += samr21-xpro iotlab-m3 + +# Include modules to test the bootloader +USEMODULE += slot_util +USEMODULE += riot_hdr + +# Comment this out to disable code in RIOT that does safety checking +# which is not needed in a production environment but helps in the +# development process: +DEVELHELP ?= 1 + +# Change this to 0 show compiler invocation lines by default: +QUIET ?= 1 + +all: riotboot + +include $(RIOTBASE)/Makefile.include diff --git a/tests/riotboot/README.md b/tests/riotboot/README.md new file mode 100644 index 0000000000000..09ae0e25f9fca --- /dev/null +++ b/tests/riotboot/README.md @@ -0,0 +1,18 @@ +RIOT bootloader test +==================== + +This is a basic example how to use RIOT bootloader in your embedded +application. + +This test should foremost give you an overview how to use riotboot: + + - `make all` build the test using the target riotboot, which generates + a binary file of the application with a header on top of it, used by + the bootloader to recognise a bootable image. + + - `make riotboot/flash` creates the binary files and flashes both + riotboot and the RIOT image with headers included. This should boot + as a normal application. + +In this test two modules `riot_hdr` and `slot_util` are used to showcase +the access to riotboot shared functions. diff --git a/tests/riotboot/main.c b/tests/riotboot/main.c new file mode 100644 index 0000000000000..4456cb676e35f --- /dev/null +++ b/tests/riotboot/main.c @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2014 Freie Universität Berlin + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup examples + * @{ + * + * @file + * @brief Hello World application + * + * @author Kaspar Schleiser + * @author Ludwig Knüpfer + * + * @} + */ + +#include + +#include "slot_util.h" +#include "riot_hdr.h" + +int main(void) +{ + puts("Hello riotboot!"); + + printf("You are running RIOT on a(n) %s board.\n", RIOT_BOARD); + printf("This board features a(n) %s MCU.\n", RIOT_MCU); + + /* print some information about the running image */ + unsigned current_slot = slot_util_current_slot(); + riot_hdr_t *riot_hdr = slot_util_get_hdr(current_slot); + printf("riot_hdr: running from slot %u\n", current_slot); + riot_hdr_print(riot_hdr); + + return 0; +}