Skip to content

Commit f653234

Browse files
committed
added two new apps
added tock-dpl-hello and tock-welcomes-dpl. The first app is a simple c_hello analog that prints a message and terminates on boot. The second app is a helper app that installs tock-dpl-hello on the board during runtime. These apps were made to test the dynamic process loading using hw-ci.
1 parent e09a687 commit f653234

File tree

10 files changed

+828
-3
lines changed

10 files changed

+828
-3
lines changed

examples/tests/app_loader/Makefile renamed to examples/tests/app_loader/button-press-loading/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Makefile for user application
22

33
# Specify this directory relative to the current application.
4-
TOCK_USERLAND_BASE_DIR = ../../..
4+
TOCK_USERLAND_BASE_DIR = ../../../..
55

66
# Which files to compile.
77
C_SRCS := $(wildcard *.c)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Makefile for user application
2+
3+
# Specify this directory relative to the current application.
4+
TOCK_USERLAND_BASE_DIR = ../../../../
5+
6+
# Which files to compile.
7+
C_SRCS := $(wildcard *.c)
8+
9+
# Include userland master makefile. Contains rules and flags for actually
10+
# building the application.
11+
include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* vim: set sw=2 expandtab tw=80: */
2+
3+
#include <stdio.h>
4+
#include <stdlib.h>
5+
#include <string.h>
6+
#include <unistd.h>
7+
8+
#include <console.h>
9+
10+
char hello[] = "Tock now supports dynamic app installs!\r\n";
11+
12+
static void nop(
13+
int a __attribute__((unused)),
14+
int b __attribute__((unused)),
15+
int c __attribute__((unused)),
16+
void* d __attribute__((unused))) {}
17+
18+
int main(void) {
19+
putnstr_async(hello, strlen(hello), nop, NULL);
20+
// Because we used the async method (as opposed to something synchronous,
21+
// such as printf), we must explicitly wait for the asynchronous write to complete.
22+
yield();
23+
// Now we are done.
24+
return 0;
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Makefile for user application
2+
3+
# Specify this directory relative to the current application.
4+
TOCK_USERLAND_BASE_DIR = ../../../..
5+
6+
# Which files to compile.
7+
C_SRCS := $(wildcard *.c)
8+
9+
# Include userland master makefile. Contains rules and flags for actually
10+
# building the application.
11+
include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Dynamic App Loader (HW-CLI Test App)
2+
======================================
3+
4+
This app installs a new `tock-welcomes-dpl` app upon boot.
5+
This new app prints `Tock now supports dynamic application installs and updates!`
6+
before terminating.
7+
8+
#### Outcomes:
9+
The app requests the capsule to load the new app. There are only two outcomes:
10+
11+
1. The `tock-welcomes-dpl` app is loaded successfully and functions without requiring a restart.
12+
2. The load process failed somewhere, and the app is erased.

examples/tests/app_loader/tock-welcomes-dpl/main.c

+766
Large diffs are not rendered by default.

libtock/internal/app_loader.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ extern "C"
88
#include "tock.h"
99

1010
// Driver number for system call
11-
#define DRIVER_NUM_APP_LOADER 0x50004
11+
#define DRIVER_NUM_APP_LOADER 0x10001
1212

1313
#define BUTTON1 0
1414
#define BUTTON2 1

tools/dynamic_app_loader/tab_to_binary_array.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def print_hex_array(hex_array):
2424
print() # Add a new line if the last line is not complete
2525

2626

27-
file_name = 'examples/adc/build/cortex-m4/cortex-m4.tbf'
27+
file_name = 'examples/tests/app_loader/tock-dpl-hello/build/cortex-m4/cortex-m4.tbf'
2828
binary_data = read_binary_file(file_name)
2929
hex_array = binary_to_array(binary_data)
3030
print_hex_array(hex_array)

0 commit comments

Comments
 (0)