Skip to content
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

Feature: component hosted #2305

Merged
merged 28 commits into from
Apr 20, 2021
Merged

Conversation

slaff
Copy link
Contributor

@slaff slaff commented Apr 16, 2021

The hosted component allows Sming's host emulator to run parts of the commands on an actual microcontroller.
The communication is done via simplePRC and the microcontroller has to be flashed with a special application.

Overview

Sming's host emulator allows easier debugging and development of embedded applications. This component named "Hosted" extends the host emulator and facilitates testing functionality that only a real microcontroller can provide as for example digital I/O operations or SPI operations.

For example in order to run the Basic_Blink application under the host emulator and run the actual blinking of a LED on a microcontroller
we can compile the application using the following directives::

make SMING_ARCH=Host ENABLE_HOSTED=tcp HOSTED_SERVER_IP=192.168.4.1

SMING_ARCH=Host instructs the build system to build the application for the Host architecture.
ENABLE_HOSTED=tcp instructs the host emulator to communication with the real microcontroller using TCP
HOSTED_SERVER_IP=192.168.4.1 instructs the host emulator to connect to IP 192.168.4.1.

In the sub-directory samples inside this component you will find the sample applications that will turn your microcontroller into
a remote RCP server.

The compilation and flashing for ESP32, for example, can be done using the following commands:

cd samples/tcp
make SMING_ARCH=Esp32 WIFI_SSID=YourSSID WIFI_PWD=YourPassword
make flash

If you replace SMING_ARCH=Esp32 with SMING_ARCH=Esp8266 then the hosted application will be compiled and flashed on a ESP8266 microcontroller.
Make sure to replace the values of  WIFI_SSID and WIFI_PWD with the actual name and password for the Access Point (AP).

@@ -12,6 +12,11 @@ LDFLAGS += \
# Executable
TARGET_OUT_0 := $(FW_BASE)/$(APP_NAME)$(TOOL_EXT)

# Hosted Settings
ifneq ($(ENABLE_HOSTED),)
COMPONENTS_AR := $(USER_LIBDIR)/$(CLIB_PREFIX)Hosted-$(CMP_Hosted_LIBHASH).a $(USER_LIBDIR)/$(CLIB_PREFIX)Hosted-Lib-$(CMP_Hosted-Lib_LIBHASH).a $(COMPONENTS_AR)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mikee47 Is it possible with the existing build system for a component to put its library at the front of the list of compiled libraries?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably the only way. I'm guessing the reason for this is to get the linkage with weak functions working properly? Note that weak functions won't work at all in Windows! Function wrappers are more reliable - the malloc_count Component uses these a lot so a good reference.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function wrappers are more reliable - the malloc_count Component uses these a lot so a good reference.

Ok, thanks for pointing this out. The host_init weak function is replaced with wrapper.

@slaff slaff added this to the 4.3.1 milestone Apr 16, 2021
@slaff slaff requested a review from mikee47 April 16, 2021 06:46
@slaff slaff force-pushed the feature/rpc-with-simplerpc branch 6 times, most recently from e7d5de6 to 3ae47cd Compare April 16, 2021 07:33
@slaff slaff force-pushed the feature/rpc-with-simplerpc branch from 3ae47cd to b51536a Compare April 16, 2021 07:47
Comment on lines 30 to 47
class SPIClass : public SPIBase
{
public:
bool begin() override
{
return false;
}
bool begin() override;

void end() override
{
}

using SPIBase::beginTransaction;
using SPIBase::transfer;
void transfer(uint8_t* buffer, size_t numberBytes) override
{
}
void transfer(uint8_t* buffer, size_t numberBytes) override;

protected:
void prepare(SPISettings& settings) override
{
}
void prepare(SPISettings& settings) override;
};

/** @brief Global instance of SPI class */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You've added SPI.cpp but not made any changes to the code. Revert SPI.cpp and SPI.h.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have split them into header and implementation to make it easier for the hosted component to replace the real implementation with its own implementation. I would prefer to leave it as it is and add the SPI hosted implementation in a separate PR if that is ok for you.

Sming/Components/Hosted/samples/tcp/app/application.cpp Outdated Show resolved Hide resolved
@@ -12,6 +12,11 @@ LDFLAGS += \
# Executable
TARGET_OUT_0 := $(FW_BASE)/$(APP_NAME)$(TOOL_EXT)

# Hosted Settings
ifneq ($(ENABLE_HOSTED),)
COMPONENTS_AR := $(USER_LIBDIR)/$(CLIB_PREFIX)Hosted-$(CMP_Hosted_LIBHASH).a $(USER_LIBDIR)/$(CLIB_PREFIX)Hosted-Lib-$(CMP_Hosted-Lib_LIBHASH).a $(COMPONENTS_AR)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably the only way. I'm guessing the reason for this is to get the linkage with weak functions working properly? Note that weak functions won't work at all in Windows! Function wrappers are more reliable - the malloc_count Component uses these a lot so a good reference.

@slaff slaff merged commit 07ecd3b into SmingHub:develop Apr 20, 2021
@slaff slaff changed the title [WIP] Feature: component hosted Feature: component hosted Apr 20, 2021
@slaff slaff removed the 3 - Review label Apr 20, 2021
@slaff slaff mentioned this pull request Apr 20, 2021
5 tasks
@slaff slaff deleted the feature/rpc-with-simplerpc branch July 9, 2021 09:03
slaff added a commit that referenced this pull request Sep 27, 2021
The hosted component allows Sming's host emulator to run parts of the commands on an actual microcontroller.
The communication is done via [simplePRC](https://simplerpc.readthedocs.io)  and the microcontroller has to be flashed with a special application.

Overview
--------
Sming's host emulator allows easier debugging and development of embedded applications. This component named "Hosted" extends the host emulator and facilitates testing functionality that only a real microcontroller can provide as for example digital I/O operations or SPI operations.

For example in order to run the Basic_Blink application under the host emulator and run the actual blinking of a LED on a microcontroller
we can compile the application using the following directives::
```
make SMING_ARCH=Host ENABLE_HOSTED=tcp HOSTED_SERVER_IP=192.168.4.1
```
`SMING_ARCH=Host` instructs the build system to build the application for the Host architecture.
`ENABLE_HOSTED=tcp` instructs the host emulator to communication with the real microcontroller using TCP
`HOSTED_SERVER_IP=192.168.4.1` instructs the host emulator to connect to IP `192.168.4.1`.

In the sub-directory ``samples`` inside this component you will find the sample applications that will turn your microcontroller into
a remote RCP server.

The compilation and flashing for ESP32, for example, can be done using the following commands:

```
cd samples/tcp
make SMING_ARCH=Esp32 WIFI_SSID=YourSSID WIFI_PWD=YourPassword
make flash
```

If you replace ``SMING_ARCH=Esp32`` with ``SMING_ARCH=Esp8266`` then the hosted application will be compiled and flashed on a ESP8266 microcontroller.
Make sure to replace the values of  WIFI_SSID and WIFI_PWD with the actual name and password for the Access Point (AP).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants