Added example for the elfloader on the MB851 platform, taken from sky-shell-exec example.

This commit is contained in:
salvopitru 2010-12-15 15:33:30 +00:00
parent d0db3fc39a
commit d86b7c4592
4 changed files with 187 additions and 0 deletions

View File

@ -0,0 +1,27 @@
CONTIKI_PROJECT = shell-exec-test
all: $(CONTIKI_PROJECT)
TARGET=mb851
COFFEE=1
ELF_LOADER=1
DEFINES=ELFLOADER_DATAMEMORY_SIZE=0x100,ELFLOADER_TEXTMEMORY_SIZE=0x100
APPS = serial-shell
PROJECT_SOURCEFILES = shell-exec.c
CONTIKI = ../../..
include $(CONTIKI)/Makefile.include
%.shell-upload: %.ce
(echo; sleep 4; echo "~K"; sleep 4; \
echo "dec64 | write $*.ce | null"; sleep 4; \
../../../tools/base64-encode < $<; sleep 4; \
echo ""; echo "~K"; echo "read $*.ce | size"; sleep 4) | make login
.PHONY: compile-executable upload-executable
compile-executable: hello-world.ce
echo Compiled Contiki executable: $<
upload-executable: hello-world.shell-upload
echo Uploaded Contiki executable: $<

View File

@ -0,0 +1,46 @@
ELFloader and shell command 'exec' example for MB851 (STM32W) platform
-----------------------------------------------------------
Compiles the Contiki hello-world application as a Contiki executable (.ce).
The Contiki executable is then uploaded to the MB851 platform via serial, and
is stored in the filesystem.
Finally, the executable is loaded via the shell command 'exec'.
NOTE:
You may have to reduce the ELF loader memory usage (/platform/sky/contiki-conf.h).
Since hello-world uses very little memory:
#define ELFLOADER_CONF_DATAMEMORY_SIZE 0x100
#define ELFLOADER_CONF_TEXTMEMORY_SIZE 0x100
1. Upload Sky shell with 'exec' command and symbols (requires several recompilations to generate correct symbols):
> make
> make CORE=shell-exec-test.mb851
> make shell-exec-test.flash CORE=shell-exec-test.mb851 PORT=AUTO
2. Verify access to the shell and the filesystem:
> make login DEV=/dev/comX
SHELL> echo hello shell
SHELL> echo test | write mytest.txt
SHELL> ls
SHELL> read mytest.txt
[CTRL-C] to exit the shell
3. Upload Contiki executable hello-world.ce:
> make upload-executable DEV=/dev/comX
[CTRL-C] to exit the shell when the entire file has been uploaded (after ~30 sec)
4. Verify that hello-world.ce exists in CFS:
> make login DEV=/dev/comX
SHELL> ls
SHELL> read hello-world.ce | size
The last command output should equal the size of hello-world.ce in this directory!
5. Load and start hello world:
SHELL> exec hello-world.ce
The program should now start: the output 'Hello, World' appears.

View File

@ -0,0 +1,56 @@
/*
* Copyright (c) 2006, Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the Contiki operating system.
*
* $Id: hello-world.c,v 1.1 2010/12/15 15:33:30 salvopitru Exp $
*/
/**
* \file
* A very simple Contiki application showing how Contiki programs look
* \author
* Adam Dunkels <adam@sics.se>
*/
#include "contiki.h"
#include <stdio.h> /* For printf() */
/*---------------------------------------------------------------------------*/
PROCESS(hello_world_process, "Hello world process");
AUTOSTART_PROCESSES(&hello_world_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(hello_world_process, ev, data)
{
PROCESS_BEGIN();
printf("Hello, world\n");
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View File

@ -0,0 +1,58 @@
/*
* Copyright (c) 2009, Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the Contiki operating system.
*
* $Id: shell-exec-test.c,v 1.1 2010/12/15 15:33:30 salvopitru Exp $
*/
#include "contiki.h"
#include "shell.h"
#include "serial-shell.h"
#include "dev/watchdog.h"
/*---------------------------------------------------------------------------*/
PROCESS(shell_test_process, "Contiki shell");
AUTOSTART_PROCESSES(&shell_test_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_test_process, ev, data)
{
PROCESS_BEGIN();
serial_shell_init();
shell_file_init();
shell_coffee_init();
shell_text_init();
shell_exec_init();
shell_base64_init();
PROCESS_END();
}
/*---------------------------------------------------------------------------*/