1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/tests/riotboot/main.c
Francisco Acosta f1c57b21ec tests: add riotboot bootloader test
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.

Co-authored-by: Federico Pellegrin <fede@evolware.org>
2018-12-18 19:31:35 +01:00

100 lines
2.3 KiB
C

/*
* Copyright (C) 2018 Inria
* Federico Pellegrin <fede@evolware.org>
*
* 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 tests
* @{
*
* @file
* @brief riotboot bootloader test
*
* @author Francisco Acosta <francisco.acosta@inria.fr>
* @author Federico Pellegrin <fede@evolware.org>
*
* @}
*/
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include "riotboot/slot.h"
#include "shell.h"
static int cmd_print_slot_nr(int argc, char **argv)
{
(void)argc;
(void)argv;
printf("Current slot=%d\n", riotboot_slot_current());
return 0;
}
static int cmd_print_slot_hdr(int argc, char **argv)
{
(void)argc;
(void)argv;
int current_slot = riotboot_slot_current();
riotboot_slot_print_hdr(current_slot);
return 0;
}
static int cmd_print_slot_addr(int argc, char **argv)
{
(void)argc;
int reqslot=atoi(argv[1]);
printf("Slot %d address=0x%08" PRIx32 "\n",
reqslot, riotboot_slot_get_image_startaddr(reqslot));
return 0;
}
static int cmd_dumpaddrs(int argc, char **argv)
{
(void)argc;
(void)argv;
riotboot_slot_dump_addrs();
return 0;
}
static const shell_command_t shell_commands[] = {
{ "curslotnr", "Print current slot number", cmd_print_slot_nr },
{ "curslothdr", "Print current slot header", cmd_print_slot_hdr },
{ "getslotaddr", "Print address of requested slot", cmd_print_slot_addr },
{ "dumpaddrs", "Prints all slot data in header", cmd_dumpaddrs },
{ NULL, NULL, NULL }
};
int main(void)
{
int current_slot;
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 */
current_slot = riotboot_slot_current();
if (current_slot != -1) {
printf("riotboot_test: running from slot %d\n", current_slot);
riotboot_slot_print_hdr(current_slot);
}
else {
printf("[FAILED] You're not running riotboot\n");
}
/* run the shell */
char line_buf[SHELL_DEFAULT_BUFSIZE];
shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE);
return 0;
}