Skip to content

Commit

Permalink
tests: add riotboot bootloader test
Browse files Browse the repository at this point in the history
The tests overrides the target all to be tested by the CI.
All the instructions how to use it are in README.md
The test is successful if the image boots and displays
information about the image and running slot.
  • Loading branch information
kYc0o committed Sep 27, 2018
1 parent a019da9 commit a6721e5
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/riotboot/Makefile
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions tests/riotboot/README.md
Original file line number Diff line number Diff line change
@@ -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.
41 changes: 41 additions & 0 deletions tests/riotboot/main.c
Original file line number Diff line number Diff line change
@@ -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 <kaspar@schleiser.de>
* @author Ludwig Knüpfer <ludwig.knuepfer@fu-berlin.de>
*
* @}
*/

#include <stdio.h>

#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;
}

0 comments on commit a6721e5

Please sign in to comment.