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

Add QEMU Control handling #132

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add QEMU Control handling #132

wants to merge 1 commit into from

Conversation

Helco
Copy link
Collaborator

@Helco Helco commented Nov 4, 2018

Using the pebble_control peripheral already integrated into QEMU we can use the existing tools to push hardware events like accelerator samples to the emulated RebbleOS by communicating via TCP (or other QEMU serial devices). On the firmware side USART2 is used to read and process the packets.

My motivation for this was to eventually develop a (ngfx) testrunner; RebbleOS would request test images and send (parts of) the framebuffer to the host. All tests should be executable then without worrying about resource size or RAM usage.

  • PoC - QEMU and some external script can communicate (the script I used)
  • Using USART RXNE interrupt instead of delayed loop
  • Useful initial protocol handler (e.g. buttons)
  • Make variable to opt out/in

I would be grateful for a review as to prevent terrible mistakes I might have made with FreeRTOS / Hardware stuff.

@Helco Helco added the PR-WIP label Nov 4, 2018
@Helco Helco self-assigned this Nov 4, 2018
Copy link
Owner

@ginge ginge left a comment

Choose a reason for hiding this comment

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

Looks great as a first scan. I'll have a good look at this very very soon
Thanks!

@@ -57,7 +57,7 @@ void power_update_battery(void)
{
_bat_voltage = hw_power_get_bat_mv();
_bat_pct = map_range(_bat_voltage, 2600, 3500, 0, 100);
SYS_LOG("PWR", APP_LOG_LEVEL_INFO, "VBAT %ldmV %d%%", _bat_voltage, _bat_pct);
Copy link
Owner

Choose a reason for hiding this comment

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

I guess this was annoying

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes :)
I also left my debug spews in for now

{
if (hw_qemu_has_data())
_qemu_handle_packet();
vTaskDelay(pdMS_TO_TICKS(16));
Copy link
Owner

Choose a reason for hiding this comment

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

Is the qemu CTS pin connected? Would be nice to use an interrupt for this.
maybe a define for the 16ms? Does this affect performance?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For this test I just wanted to get something working, an interrupt I would strongly prefer as well.
I guess this brute force method will affect performance much more than we want

230400
};

static StaticSemaphore_t _usart2_mutex_mem;
Copy link
Owner

Choose a reason for hiding this comment

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

I know this is very WIP, but as a general rule any RTOS specific code such as a mutex/semaphore thread etc live in /rcore

This allows for a little clearer separation and when it comes to getting tintin ready it will make this a bit easier.

I'm sure you know already, but just a gentle tap

Copy link
Owner

Choose a reason for hiding this comment

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

I'll clarify in that locking usually happens in rcore. in this case rcore/qemu.c looks likely

const QemuEndpoint *endpoint = qemu_endpoints;
while (endpoint->handler != NULL)
{
if (endpoint->protocol == protocol)
Copy link
Owner

Choose a reason for hiding this comment

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

If this is not true do we end up looping forever? What circumstance could cause this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants