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

Fix SITL target build and runtime segfaults #9342

Merged
merged 1 commit into from Jan 13, 2020

Conversation

metametaclass
Copy link
Contributor

SITL target segfaults in several places after running because of absent motorPwmDevice functions.
Target cannot be built with DEBUG=GDB option because of absent uartPinConfigure and IOConfigGPIO function calls.
Entering CLI tab in connected to SITL configurator also causes segfault because of some OSD cli settings placed outside of #ifdef USE_OSD

ledvinap
ledvinap previously approved these changes Jan 6, 2020

{ "osd_rcchannels", VAR_INT8 | MASTER_VALUE | MODE_ARRAY, .config.array.length = OSD_RCCHANNELS_COUNT, PG_OSD_CONFIG, offsetof(osdConfig_t, rcChannels) },
{ "osd_camera_frame_width", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { OSD_CAMERA_FRAME_MIN_WIDTH, OSD_CAMERA_FRAME_MAX_WIDTH }, PG_OSD_CONFIG, offsetof(osdConfig_t, camera_frame_width) },
{ "osd_camera_frame_height", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { OSD_CAMERA_FRAME_MIN_HEIGHT, OSD_CAMERA_FRAME_MAX_HEIGHT }, PG_OSD_CONFIG, offsetof(osdConfig_t, camera_frame_height) },
#endif // end of #ifdef USE_OSD
Copy link
Contributor

Choose a reason for hiding this comment

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

Unrelated to this PR, but valid

Copy link
Member

Choose a reason for hiding this comment

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

Good find - but can this please be extracted into a separate pull request to keep track of it?

@@ -538,7 +538,7 @@ void init(void)
busSwitchInit();
#endif

#if defined(USE_UART)
#if defined(USE_UART) && !defined(SIMULATOR_BUILD)
Copy link
Contributor

Choose a reason for hiding this comment

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

There is stub uartPinConfigure for SIMULATOR_BUILD

Copy link
Member

Choose a reason for hiding this comment

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

We should either remove this, or remove the stub.

@etracer65 etracer65 mentioned this pull request Jan 11, 2020
{
UNUSED(io);
UNUSED(cfg);
printf("IOConfigGPIO\n");
Copy link
Contributor

@s-ol s-ol Jan 11, 2020

Choose a reason for hiding this comment

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

alternatively, it's possible to add #undef's for USE_PINIO, USE_PINIOBOX, USE_PIN_PULL_UP_DOWN (see https://github.com/betaflight/betaflight/pull/9352/files#diff-f682e0332717b305936b703833517366)

Copy link
Member

Choose a reason for hiding this comment

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

I am surprised that this even built before these stubs were added - are we missing some compiler settings to make this fail for the default build?

Copy link
Contributor

Choose a reason for hiding this comment

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

@mikeller for me it didn't build without my change - I think it just hasn't been attempted to build in a while.

Copy link
Member

Choose a reason for hiding this comment

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

It is built as part of our CI on Travis and on Jenkins (see https://ci.betaflight.tech/job/Betaflight/2018/artifact/obj/betaflight_4.2.0_SITL-2018-6433aaa68.hex). Unfortunately we do not have strong checks in place for the compiler suite version used for this target, so I suspect the build problems are gcc version dependent.

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 am surprised that this even built before these stubs were added - are we missing some compiler settings to make this fail for the default build?

It builds with make TARGET=SITL, but fails with make TARGET=SITL DEBUG=GDB. I think that in release build some of PINIO-related calls is optimized away.

@s-ol
Copy link
Contributor

s-ol commented Jan 11, 2020

I've been passing through joystick input via MSP on a second TCP-UART, but I'm seeing some crazy latency in the receiver tab in the configurator. Is that the SITL build being slow, the TCP bridge being crappy, or the python MSP implementation I'm using being late?

I also haven't been able to get any PWM data out, I'm trying to listen using netcat: nc -luk 9002


{ "osd_rcchannels", VAR_INT8 | MASTER_VALUE | MODE_ARRAY, .config.array.length = OSD_RCCHANNELS_COUNT, PG_OSD_CONFIG, offsetof(osdConfig_t, rcChannels) },
{ "osd_camera_frame_width", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { OSD_CAMERA_FRAME_MIN_WIDTH, OSD_CAMERA_FRAME_MAX_WIDTH }, PG_OSD_CONFIG, offsetof(osdConfig_t, camera_frame_width) },
{ "osd_camera_frame_height", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { OSD_CAMERA_FRAME_MIN_HEIGHT, OSD_CAMERA_FRAME_MAX_HEIGHT }, PG_OSD_CONFIG, offsetof(osdConfig_t, camera_frame_height) },
#endif // end of #ifdef USE_OSD
Copy link
Member

Choose a reason for hiding this comment

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

Good find - but can this please be extracted into a separate pull request to keep track of it?

@@ -538,7 +538,7 @@ void init(void)
busSwitchInit();
#endif

#if defined(USE_UART)
#if defined(USE_UART) && !defined(SIMULATOR_BUILD)
Copy link
Member

Choose a reason for hiding this comment

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

We should either remove this, or remove the stub.

{
UNUSED(io);
UNUSED(cfg);
printf("IOConfigGPIO\n");
Copy link
Member

Choose a reason for hiding this comment

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

I am surprised that this even built before these stubs were added - are we missing some compiler settings to make this fail for the default build?

mikeller
mikeller previously approved these changes Jan 12, 2020
@mikeller
Copy link
Member

Can you please rebase / squash these changes into one commit?

@metametaclass
Copy link
Contributor Author

Can you please rebase / squash these changes into one commit?
Done.

@mikeller mikeller merged commit b5237bb into betaflight:master Jan 13, 2020
mikeller added a commit that referenced this pull request Jan 13, 2020
Fix SITL target build and runtime segfaults
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants