-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Porting to Renesas MCU without OS #11
Comments
Threading isn't required, and in fact no OS primitive is used (except for network).
Defining the types:If I were you, I would try to find a specific preprocessor definition for your platform (something your compiler defines that other compiler don't. For example, on linux, we have Typically, in #elif defined(RA6M5)
#include <stdlib.h>
#include <string.h>
// We need BSD socket here and TCP_NODELAY
#include <whereis/socket.h> // We need close, connect, bind, setsockopt, getsockopt, fcntl
// We need gethostbyname or getaddrinfo
#include <whereis/netdb.h>
// We need va_args for printf like dump functions
#include <stdarg.h>
#ifndef DontWantUINT8
typedef unsigned char uint8;
#endif
#ifndef DontWantUINT32
typedef unsigned int uint32;
#endif
#ifndef DontWantUINT16
typedef unsigned short uint16;
#endif
#ifndef DontWantUINT64
typedef unsigned long long uint64;
#endif
#ifndef DontWantINT8
typedef signed char int8;
#endif
#ifndef DontWantINT32
typedef signed int int32;
#endif
#ifndef DontWantINT16
typedef signed short int16;
#endif
#ifndef DontWantINT64
typedef long long int64;
#endif
#ifndef DontWantNativeInt
typedef intptr_t nativeint;
#endif
#define PF_LLD "%lld"
#define PF_LLU "%llu"
/** Unless you run on embedded OS, you'll not need those functions
@return int value you need to pass to leaveAtomicSection */
extern "C" int enterAtomicSection() { return 0; } // You might need `asm volatile("": : :"memory")` here, if you use GCC
/** Unless you run on embedded OS, you'll not need those functions */
extern "C" void leaveAtomicSection(int) { }
#else // Previously: line 268 DebuggingIf you need to debug your code, the library will call #elif defined (RA6M5)
*(char*)42 = 0; // This will crash the CPU instantly. If the debugger is attached, this should trigger an exception, you need to find the return address for this function on the stack and jump back to the return address to find where it failed, or place a breakpoint on this line, skip the instruction and return step by step to find where it failed.
#else Wrapping the threadsIn #ifdef _WIN32
typedef HANDLE HTHREAD;
typedef HANDLE HMUTEX;
typedef HANDLE OEVENT;
#else
typedef pthread_t HTHREAD;
typedef pthread_mutex_t HMUTEX;
typedef pthread_mutex_t OEVENT;
#endif to this: #ifdef _WIN32
typedef HANDLE HTHREAD;
typedef HANDLE HMUTEX;
typedef HANDLE OEVENT;
#elif defined(RA6M5)
// This isn't used anywhere anyway
typedef void * HTHREAD;
typedef int HMUTEX;
typedef int OEVENT;
#else
typedef pthread_t HTHREAD;
typedef pthread_mutex_t HMUTEX;
typedef pthread_mutex_t OEVENT;
#endif That should be it. |
Hi,
I tried to port it to RA6M5 Renesas MCU. In
Types.hpp
, there is several pre-processors macro such as_WIN32
,_POSIX
, andESP_PLATFORM
. As RA6M5 is not fall under one of them, I'm not defining anything. When I tried to compile it, there is requirement to includepthreadRTOS.h
. Even after I make empty header file just to pass compilation, at the end of the day it still requires me to definepthread_t
.On README.md, it said that
This code is specialized for embedded system with or **without** an operating system
. AFAIK, to add thread into embedded system, we need to put Real Time OS (FreeRTOS, Azure RTOS, etc). So, my question is, how can I compile it without RTOS dependencies? Is there any pre-processor that I need to define? Or did I misinterpret something? Thank you for your assistance.The text was updated successfully, but these errors were encountered: