Files
cdba/cdba-power.c
T
Bjorn Andersson 6ef5e38a76 cdba-server: Allow booting into EDL mode
In order to implement flash support, as well as aid in maintenance
situations, support for requesting the board to be powered on into
EDL/flashing mode is useful.

So far the payload of the MSG_POWER_ON message has been ignored by the
server, so we can tread the absence of payload as "NORMAL" power on
request and introduce the power_on_mode enumeration to define the values
in this (optional) byte.

A new key definition is also added to the protocol, representing the
holding down the EDL "key", but not exposed on the client side yet.

The device logic is wired up such that the power-on sequence will now
request the drivers to hold the EDL key while powering on, if the
power-on mode is "EDL".

Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
2026-05-20 20:38:38 +00:00

88 lines
1.5 KiB
C

/*
* Copyright (c) 2024, Linaro Ltd.
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "cdba-server.h"
#include "device.h"
#include "device_parser.h"
#include "watch.h"
void cdba_send_buf(int type, size_t len, const void *buf)
{
/* ignore console messages */
}
static void usage(const char *name)
{
fprintf(stderr, "Usage: %s <board> on|off\n", name);
exit(EXIT_FAILURE);
}
static struct device *selected_device;
bool ready(void)
{
return device_is_running(selected_device);
}
int main(int argc, char **argv)
{
const char *home;
const char *name;
bool on;
int ret;
if (argc != 3)
usage(argv[0]);
if (!strcmp(argv[2], "on"))
on = true;
else if (!strcmp(argv[2], "off"))
on = false;
else
usage(argv[0]);
home = getenv("HOME");
if (home)
chdir(home);
ret = device_parser(".cdba");
if (ret) {
ret = device_parser("/etc/cdba");
if (ret) {
fprintf(stderr, "device parser: unable to open config file\n");
exit(1);
}
}
name = argv[1];
selected_device = device_open(name, "nobody");
if (!selected_device) {
fprintf(stderr, "failed to open %s\n", name);
exit(EXIT_FAILURE);
}
if (on) {
device_power_on(selected_device, MSG_POWER_ON_NORMAL);
watch_main_loop(ready);
selected_device->usb_always_on = true;
selected_device->power_always_on = true;
} else {
device_usb(selected_device, false);
device_power_off(selected_device);
}
device_close(selected_device);
return 0;
}