-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from SPRESENSE/release-v1.3.200
Merge develop into new-master for v1.3.200 release
- Loading branch information
Showing
26 changed files
with
766 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
CONFIGURED_APPS += __app_name__ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Application makefile | ||
|
||
# Command name (Public function 'int <APPNAME>_main(void)' required) | ||
APPNAME = | ||
|
||
# Application execute priority (Range: 0 ~ 255, Default: 100) | ||
PRIORITY = | ||
|
||
# Application stack memory size (Default: 2048) | ||
STACKSIZE = | ||
|
||
# Main source code | ||
MAINSRC = | ||
|
||
# Additional C source files (*.c) | ||
CSRCS = | ||
|
||
# Additional C++ source files (*.cxx) | ||
CXXSRCS = | ||
|
||
# Additional assembler source files (*.S) | ||
ASRCS = | ||
|
||
# C compiler flags | ||
CFLAGS = | ||
|
||
# C++ compiler flags | ||
CXXFLAGS = | ||
|
||
include $(SPRESENSE_HOME)/.vscode/application.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include <sdk/config.h> | ||
#include <stdio.h> | ||
|
||
int __app_name___main(int argc, char *argv[]) | ||
{ | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
CONFIGURED_APPS += __app_name__ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Application makefile | ||
|
||
# Command name (Public function 'int <APPNAME>_main(void)' required) | ||
APPNAME = | ||
|
||
# Application execute priority (Range: 0 ~ 255, Default: 100) | ||
PRIORITY = | ||
|
||
# Application stack memory size (Default: 2048) | ||
STACKSIZE = | ||
|
||
# Main source code | ||
MAINSRC = | ||
|
||
# Additional C source files (*.c) | ||
CSRCS = | ||
|
||
# Additional C++ source files (*.cxx) | ||
CXXSRCS = | ||
|
||
# Additional assembler source files (*.S) | ||
ASRCS = | ||
|
||
# C compiler flags | ||
CFLAGS = | ||
|
||
# C++ compiler flags | ||
CXXFLAGS = | ||
|
||
include $(SPRESENSE_HOME)/.vscode/application.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
#include <sdk/config.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
#include <asmp/asmp.h> | ||
#include <asmp/mptask.h> | ||
#include <asmp/mpshm.h> | ||
#include <asmp/mpmq.h> | ||
#include <asmp/mpmutex.h> | ||
|
||
/* Include worker header */ | ||
#include "__worker_name__.h" | ||
|
||
/* Worker ELF path */ | ||
#define WORKER_FILE "/mnt/spif/__worker_name__" | ||
|
||
#define message(format, ...) printf(format, ##__VA_ARGS__) | ||
#define err(format, ...) fprintf(stderr, format, ##__VA_ARGS__) | ||
|
||
int __app_name___main(int argc, char *argv[]) | ||
{ | ||
mptask_t mptask; | ||
mpmutex_t mutex; | ||
mpshm_t shm; | ||
mpmq_t mq; | ||
uint32_t msgdata; | ||
int data = 0x1234; | ||
int ret, wret; | ||
char *buf; | ||
|
||
/* Initialize MP task */ | ||
|
||
ret = mptask_init(&mptask, WORKER_FILE); | ||
if (ret != 0) | ||
{ | ||
err("mptask_init() failure. %d\n", ret); | ||
return ret; | ||
} | ||
|
||
ret = mptask_assign(&mptask); | ||
if (ret != 0) | ||
{ | ||
err("mptask_assign() failure. %d\n", ret); | ||
return ret; | ||
} | ||
|
||
/* Initialize MP mutex and bind it to MP task */ | ||
|
||
ret = mpmutex_init(&mutex, __WORKER_NAME__KEY_MUTEX); | ||
if (ret < 0) | ||
{ | ||
err("mpmutex_init() failure. %d\n", ret); | ||
return ret; | ||
} | ||
ret = mptask_bindobj(&mptask, &mutex); | ||
if (ret < 0) | ||
{ | ||
err("mptask_bindobj(mutex) failure. %d\n", ret); | ||
return ret; | ||
} | ||
|
||
/* Initialize MP message queue with assigned CPU ID, and bind it to MP task */ | ||
|
||
ret = mpmq_init(&mq, __WORKER_NAME__KEY_MQ, mptask_getcpuid(&mptask)); | ||
if (ret < 0) | ||
{ | ||
err("mpmq_init() failure. %d\n", ret); | ||
return ret; | ||
} | ||
ret = mptask_bindobj(&mptask, &mq); | ||
if (ret < 0) | ||
{ | ||
err("mptask_bindobj(mq) failure. %d\n", ret); | ||
return ret; | ||
} | ||
|
||
/* Initialize MP shared memory and bind it to MP task */ | ||
|
||
ret = mpshm_init(&shm, __WORKER_NAME__KEY_SHM, 1024); | ||
if (ret < 0) | ||
{ | ||
err("mpshm_init() failure. %d\n", ret); | ||
return ret; | ||
} | ||
ret = mptask_bindobj(&mptask, &shm); | ||
if (ret < 0) | ||
{ | ||
err("mptask_binobj(shm) failure. %d\n", ret); | ||
return ret; | ||
} | ||
|
||
/* Map shared memory to virtual space */ | ||
|
||
buf = mpshm_attach(&shm, 0); | ||
if (!buf) | ||
{ | ||
err("mpshm_attach() failure.\n"); | ||
return ret; | ||
} | ||
message("attached at %08x\n", (uintptr_t)buf); | ||
memset(buf, 0, 1024); | ||
|
||
/* Run worker */ | ||
|
||
ret = mptask_exec(&mptask); | ||
if (ret < 0) | ||
{ | ||
err("mptask_exec() failure. %d\n", ret); | ||
return ret; | ||
} | ||
|
||
/* Send command to worker */ | ||
ret = mpmq_send(&mq, MSG_ID___WORKER_NAME__, (uint32_t) &data); | ||
if (ret < 0) | ||
{ | ||
err("mpmq_send() failure. %d\n", ret); | ||
return ret; | ||
} | ||
|
||
/* Wait for worker message */ | ||
|
||
ret = mpmq_receive(&mq, &msgdata); | ||
if (ret < 0) | ||
{ | ||
err("mpmq_recieve() failure. %d\n", ret); | ||
return ret; | ||
} | ||
message("Worker response: ID = %d, data = %x\n", | ||
ret, *((int *)msgdata)); | ||
|
||
/* Show worker copied data */ | ||
|
||
/* Lock mutex for synchronize with worker after it's started */ | ||
|
||
mpmutex_lock(&mutex); | ||
|
||
message("Worker said: %s\n", buf); | ||
|
||
mpmutex_unlock(&mutex); | ||
|
||
/* Destroy worker */ | ||
|
||
wret = -1; | ||
ret = mptask_destroy(&mptask, false, &wret); | ||
if (ret < 0) | ||
{ | ||
err("mptask_destroy() failure. %d\n", ret); | ||
return ret; | ||
} | ||
|
||
message("Worker exit status = %d\n", wret); | ||
|
||
/* Finalize all of MP objects */ | ||
|
||
mpshm_detach(&shm); | ||
mpshm_destroy(&shm); | ||
mpmutex_destroy(&mutex); | ||
mpmq_destroy(&mq); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
NAME=__app_name__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Worker makefile | ||
|
||
# Additional C source files (*.c) | ||
CSRCS = | ||
|
||
# Additional assembler source files (*.S) | ||
ASRCS = | ||
|
||
# C compiler flags | ||
CELFFLAGS = | ||
|
||
include $(SPRESENSE_HOME)/.vscode/worker.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* MP object keys. Must be synchronized with supervisor. */ | ||
|
||
#define __APP_NAME__KEY_SHM 1 | ||
#define __APP_NAME__KEY_MQ 2 | ||
#define __APP_NAME__KEY_MUTEX 3 | ||
|
||
#define MSG_ID___APP_NAME__ 1 |
Oops, something went wrong.