mirror of
https://github.com/sipeed/MaixCDK.git
synced 2026-09-10 21:59:54 -05:00
* build hello world on ax630c
This commit is contained in:
@@ -18,6 +18,8 @@ if(PLATFORM_LINUX)
|
||||
append_srcs_dir(ADD_SRCS "port/linux")
|
||||
elseif(PLATFORM_MAIXCAM)
|
||||
append_srcs_dir(ADD_SRCS "port/maixcam")
|
||||
elseif(PLATFORM_MAIXCAM2)
|
||||
append_srcs_dir(ADD_SRCS "port/maixcam2")
|
||||
endif()
|
||||
|
||||
# list(REMOVE_ITEM COMPONENT_SRCS "src/test.c")
|
||||
|
||||
23
components/basic/port/maixcam2/maix_sys_maixcam2.cpp
Normal file
23
components/basic/port/maixcam2/maix_sys_maixcam2.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "maix_sys.hpp"
|
||||
#include "maix_app.hpp"
|
||||
#include "signal.h"
|
||||
|
||||
namespace maix::sys
|
||||
{
|
||||
static void signal_handle(int signal)
|
||||
{
|
||||
switch (signal) {
|
||||
case SIGINT:
|
||||
maix::app::set_exit_flag(true);
|
||||
#if CONFIG_BUILD_WITH_MAIXPY
|
||||
raise(SIGINT);
|
||||
#endif
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
void register_default_signal_handle() {
|
||||
signal(SIGINT, signal_handle);
|
||||
}
|
||||
}
|
||||
70
components/basic/port/maixcam2/maix_thread_maixcam2.cpp
Normal file
70
components/basic/port/maixcam2/maix_thread_maixcam2.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
#include "maix_thread.hpp"
|
||||
|
||||
#define THREAD_USE_PTHREAD 0
|
||||
|
||||
#if THREAD_USE_PTHREAD
|
||||
#include <pthread.h>
|
||||
#else
|
||||
#include <thread>
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
namespace maix::thread
|
||||
{
|
||||
Thread::Thread(std::function<void(void*)> func, void *args)
|
||||
{
|
||||
this->_func = func;
|
||||
this->_args = args;
|
||||
#if THREAD_USE_PTHREAD
|
||||
this->_thread = new pthread_t;
|
||||
pthread_create((pthread_t *)this->_thread, NULL, (void *(*)(void *))func, args);
|
||||
#else
|
||||
this->_thread = new std::thread(func, args);
|
||||
#endif
|
||||
}
|
||||
|
||||
Thread::~Thread()
|
||||
{
|
||||
delete (std::thread *)this->_thread;
|
||||
}
|
||||
|
||||
void Thread::join()
|
||||
{
|
||||
#if THREAD_USE_PTHREAD
|
||||
pthread_join(*(pthread_t *)this->_thread, NULL);
|
||||
#else
|
||||
if (((std::thread *)this->_thread)->joinable())
|
||||
{
|
||||
((std::thread *)this->_thread)->join();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Thread::detach()
|
||||
{
|
||||
#if THREAD_USE_PTHREAD
|
||||
pthread_detach(*(pthread_t *)this->_thread);
|
||||
#else
|
||||
((std::thread *)this->_thread)->detach();
|
||||
#endif
|
||||
}
|
||||
|
||||
void sleep_ms(uint32_t ms)
|
||||
{
|
||||
#if THREAD_USE_PTHREAD
|
||||
usleep(ms * 1000);
|
||||
#else
|
||||
this_thread::sleep_for(chrono::milliseconds(ms));
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Thread::joinable()
|
||||
{
|
||||
#if THREAD_USE_PTHREAD
|
||||
return true;
|
||||
#else
|
||||
return ((std::thread *)this->_thread)->joinable();
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace maix::thread
|
||||
66
components/basic/port/maixcam2/maix_util_maixcam2.cpp
Normal file
66
components/basic/port/maixcam2/maix_util_maixcam2.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
#include "maix_util.hpp"
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <vector>
|
||||
|
||||
namespace maix::util
|
||||
{
|
||||
void disable_kernel_debug() {
|
||||
char name[] = "/dev/tty1";
|
||||
int fd = open(name, O_RDONLY | O_WRONLY);
|
||||
if (fd < 0) {
|
||||
log::warn("open %s failed!\r\n", name);
|
||||
return;
|
||||
}
|
||||
if (0 < ioctl(fd, TIOCCONS)) {
|
||||
log::warn("ioctl(fd, TIOCCONS) failed!\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
||||
system("echo 0 > /proc/sys/kernel/printk");
|
||||
}
|
||||
|
||||
void enable_kernel_debug() {
|
||||
char name[] = "/dev/console";
|
||||
int fd = open(name, O_RDONLY | O_WRONLY);
|
||||
if (fd < 0) {
|
||||
log::warn("open %s failed!\r\n", name);
|
||||
return;
|
||||
}
|
||||
if (0 < ioctl(fd, TIOCCONS)) {
|
||||
log::warn("ioctl(fd, TIOCCONS) failed!\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
||||
system("echo 9 > /proc/sys/kernel/printk");
|
||||
}
|
||||
|
||||
static std::vector<void(*)()> *exit_function_list;
|
||||
|
||||
void register_exit_function(void (*process)(void)) {
|
||||
if (exit_function_list == nullptr) {
|
||||
exit_function_list = new std::vector<void(*)()>;
|
||||
}
|
||||
exit_function_list->push_back(process);
|
||||
}
|
||||
|
||||
void do_exit_function() {
|
||||
if (exit_function_list) {
|
||||
for (auto& func : *exit_function_list) {
|
||||
func();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void register_atexit() {
|
||||
atexit(do_exit_function);
|
||||
}
|
||||
}
|
||||
|
||||
14
platforms/maixcam2.yaml
Normal file
14
platforms/maixcam2.yaml
Normal file
@@ -0,0 +1,14 @@
|
||||
toolchain:
|
||||
- name: ARM toolchain
|
||||
id: gcc-arm-9.10
|
||||
default: true
|
||||
url: https://developer.arm.com/-/media/Files/downloads/gnu-a/9.2-2019.12/binrel/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz
|
||||
urls:
|
||||
sites:
|
||||
sha256sum: 8dfe681531f0bd04fb9c53cf3c0a3368c616aa85d48938eebe2b516376e06a66
|
||||
filename: gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz
|
||||
path: toolchains/maixcam2
|
||||
bin_path: toolchains/maixcam2/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu/bin
|
||||
prefix: aarch64-none-linux-gnu-
|
||||
c_flags: ''
|
||||
cxx_flags: ''
|
||||
Reference in New Issue
Block a user