main: Add RELEASE mode features

- Hide console by default unless booting in verbose mode.
- In verbose mode, enable USB early and poll for connection before
  launching payloads.
- Show console on fallback to proxy.

Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
Hector Martin 2022-02-21 16:07:01 +09:00
parent a9088e2278
commit 5aaedef975
3 changed files with 61 additions and 2 deletions

View file

@ -35,6 +35,10 @@ CFLAGS := -O2 -Wall -g -Wundef -Werror=strict-prototypes -fno-common -fno-PIE \
-fno-stack-protector -mgeneral-regs-only -mstrict-align -march=armv8.2-a \ -fno-stack-protector -mgeneral-regs-only -mstrict-align -march=armv8.2-a \
$(EXTRA_CFLAGS) $(EXTRA_CFLAGS)
ifeq ($(RELEASE),1)
CFLAGS += -DRELEASE
endif
LDFLAGS := -EL -maarch64elf --no-undefined -X -Bsymbolic \ LDFLAGS := -EL -maarch64elf --no-undefined -X -Bsymbolic \
-z notext --no-apply-dynamic-relocs --orphan-handling=warn \ -z notext --no-apply-dynamic-relocs --orphan-handling=warn \
-z nocopyreloc --gc-sections -pie -z nocopyreloc --gc-sections -pie

View file

@ -3,11 +3,22 @@
#ifndef CONFIG_H #ifndef CONFIG_H
#define CONFIG_H #define CONFIG_H
// Enable framebuffer console
#define USE_FB #define USE_FB
// Disable framebuffer console unless verbose boot is enabled
//#define FB_SILENT_MODE
// Initialize USB early and break into proxy if device is opened within this time (sec)
//#define EARLY_PROXY_TIMEOUT 5
// Print RTKit logs to the console
//#define RTKIT_SYSLOG //#define RTKIT_SYSLOG
// Target for device-specific debug builds // Target for device-specific debug builds
//#define TARGET T8103 //#define TARGET T8103
#ifdef RELEASE
# define FB_SILENT_MODE
# define EARLY_PROXY_TIMEOUT 5
#endif
#endif #endif

View file

@ -58,6 +58,42 @@ void get_device_info(void)
void run_actions(void) void run_actions(void)
{ {
bool usb_up = false;
#ifdef EARLY_PROXY_TIMEOUT
if (!cur_boot_args.video.display) {
printf("Bringing up USB for early debug...\n");
usb_init();
usb_iodev_init();
usb_up = true;
printf("Waiting for proxy connection... ");
for (int i = 0; i < EARLY_PROXY_TIMEOUT * 100; i++) {
for (int j = 0; j < USB_IODEV_COUNT; j++) {
iodev_id_t iodev = IODEV_USB0 + j;
if (!(iodev_get_usage(iodev) & USAGE_UARTPROXY))
continue;
usb_iodev_vuart_setup(iodev);
iodev_handle_events(iodev);
if (iodev_can_write(iodev) || iodev_can_write(IODEV_USB_VUART)) {
printf(" Connected!\n");
uartproxy_run(NULL);
return;
}
}
mdelay(10);
if (i % 100 == 99)
printf(".");
}
printf(" Timed out\n");
}
#endif
printf("Checking for payloads...\n"); printf("Checking for payloads...\n");
if (payload_run() == 0) { if (payload_run() == 0) {
@ -65,10 +101,14 @@ void run_actions(void)
return; return;
} }
fb_set_active(true);
printf("No valid payload found\n"); printf("No valid payload found\n");
usb_init(); if (!usb_up) {
usb_iodev_init(); usb_init();
usb_iodev_init();
}
printf("Running proxy...\n"); printf("Running proxy...\n");
@ -94,7 +134,11 @@ void m1n1_main(void)
display_init(); display_init();
fb_init(); fb_init();
fb_display_logo(); fb_display_logo();
#ifdef FB_SILENT_MODE
fb_set_active(!cur_boot_args.video.display);
#else
fb_set_active(true); fb_set_active(true);
#endif
#endif #endif
aic_init(); aic_init();