Skip to content

Commit

Permalink
modules: Use dedicated workqueue for LED PWM handling
Browse files Browse the repository at this point in the history
After modem FOTA the download client thread tries to put the modem into
bootloader mode. However, this times out. Suspected reason is that the
LED PWM handling is blocking the download client thread due to being
scheduled in tight steps via the system workqueue (cooperative).

Also, reinstate eDRX setting in prj.conf that was removed by mistake.

AND, increase full modem test timeout to 30 minutes as it
occasionally times out. (Slow download)

Signed-off-by: Simen S. Røstad <[email protected]>
  • Loading branch information
simensrostad committed Sep 17, 2024
1 parent e5f413c commit a3ccac4
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 5 deletions.
6 changes: 6 additions & 0 deletions app/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ CONFIG_LTE_PSM_REQ_RPTAU_SECONDS=7200
# downlink data, there is no need for prolonged active paging after the RRC connection release.
CONFIG_LTE_PSM_REQ_RAT_SECONDS=6

# Enable eDRX (Extended Discontinuous Reception)
CONFIG_LTE_EDRX_REQ=y
# "0000" is 5.12 s
CONFIG_LTE_EDRX_REQ_VALUE_LTE_M="0000"
CONFIG_LTE_EDRX_REQ_VALUE_NBIOT="0000"

# Modem library
CONFIG_NRF_MODEM_LIB=y

Expand Down
1 change: 0 additions & 1 deletion app/src/modules/fota/fota.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ static void fota_status(enum nrf_cloud_fota_status status, const char *const sta
case NRF_CLOUD_FOTA_SUCCEEDED:
LOG_DBG("Firmware update succeeded");

/* Dont */
status_events_notify(FOTA_STATUS_STOP);
return;
default:
Expand Down
4 changes: 4 additions & 0 deletions app/src/modules/led/Kconfig.led
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ menuconfig APP_LED

if APP_LED

config APP_LED_PWM_WORKQUEUE_STACK_SIZE
int "LED PWM WQ stack size"
default 768

module = APP_LED
module-str = LED
source "subsys/logging/Kconfig.template.log_config"
Expand Down
14 changes: 12 additions & 2 deletions app/src/modules/led/led_pwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ static const struct pwm_dt_spec led2 = PWM_DT_SPEC_GET(PWM_LED2_NODE);
#error "Unsupported board: pwm-led 2 devicetree alias is not defined"
#endif

/* Define separate workqueue to offload led PWM handling */
static K_THREAD_STACK_DEFINE(stack_area, CONFIG_APP_LED_PWM_WORKQUEUE_STACK_SIZE);
static struct k_work_q led_pwm_queue;

struct led {
size_t id;
struct led_color color;
Expand Down Expand Up @@ -143,7 +147,7 @@ static void work_handler(struct k_work *work)
int32_t next_delay =
leds.effect->steps[leds.effect_step].substep_time;

k_work_reschedule(&leds.work, K_MSEC(next_delay));
k_work_reschedule_for_queue(&led_pwm_queue, &leds.work, K_MSEC(next_delay));
}
}

Expand All @@ -165,7 +169,7 @@ static void led_update(struct led *led)
int32_t next_delay =
led->effect->steps[led->effect_step].substep_time;

k_work_schedule(&led->work, K_MSEC(next_delay));
k_work_schedule_for_queue(&led_pwm_queue, &led->work, K_MSEC(next_delay));
} else {
LOG_DBG("LED effect with no effect");
}
Expand Down Expand Up @@ -268,6 +272,12 @@ int led_pwm_set_rgb(uint8_t red, uint8_t green, uint8_t blue)

static int led_pwm_init(void)
{
k_work_queue_init(&led_pwm_queue);
k_work_queue_start(&led_pwm_queue, stack_area,
K_THREAD_STACK_SIZEOF(stack_area),
K_LOWEST_APPLICATION_THREAD_PRIO,
NULL);

k_work_init_delayable(&leds.work, work_handler);

return 0;
Expand Down
2 changes: 1 addition & 1 deletion app/src/modules/transport/transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ static void state_running_entry(void *o)
k_work_queue_init(&transport_queue);
k_work_queue_start(&transport_queue, stack_area,
K_THREAD_STACK_SIZEOF(stack_area),
K_HIGHEST_APPLICATION_THREAD_PRIO,
K_LOWEST_APPLICATION_THREAD_PRIO,
NULL);

err = nrf_cloud_coap_init();
Expand Down
2 changes: 1 addition & 1 deletion tests/on_target/tests/test_fota.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

WAIT_FOR_FOTA_AVAILABLE = 60 * 4
APP_FOTA_TIMEOUT = 60 * 10
FULL_MFW_FOTA_TIMEOUT = 60 * 20
FULL_MFW_FOTA_TIMEOUT = 60 * 30


def wait_for_fota_available(t91x_board):
Expand Down

0 comments on commit a3ccac4

Please sign in to comment.