Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/flickernoise
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 66e5947
Choose a base ref
...
head repository: m-labs/flickernoise
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 002aa33
Choose a head ref
  • 3 commits
  • 2 files changed
  • 1 contributor

Commits on Mar 3, 2012

  1. usb load: show how many bytes were loaded

    Not having this seemingly redundant information caused quite the
    ghost hunt when we loaded only the first 4 kB, chopping off some
    code at the end.
    wpwrak committed Mar 3, 2012
    Copy the full SHA
    58b27b0 View commit details
  2. usb debug: emit a newline only before returning to the shell

    Before, we ended the line each time usb_debug_flush returned, causing
    "usb debug wait" to potentially produce very choppy output.
    wpwrak committed Mar 3, 2012
    Copy the full SHA
    73b5506 View commit details
  3. Copy the full SHA
    002aa33 View commit details
Showing with 19 additions and 8 deletions.
  1. +15 −3 src/shellext.c
  2. +4 −5 src/usbfirmware.c
18 changes: 15 additions & 3 deletions src/shellext.c
Original file line number Diff line number Diff line change
@@ -251,10 +251,10 @@ static int main_pfpu(int argc, char **argv)

static uint8_t debug_consume = 0;
static volatile int keypress_wait;
static int nl = 1;

static void usb_debug_flush(void)
{
int nl = 1;
char c;

while(debug_consume != COMLOC_DEBUG_PRODUCE) {
@@ -263,8 +263,14 @@ static void usb_debug_flush(void)
nl = c == '\n';
debug_consume++;
}
if(!nl)
}

static void end_line(void)
{
if(!nl) {
putchar('\n');
nl = 1;
}
}

static rtems_task keypress_task(rtems_task_argument argument)
@@ -283,6 +289,7 @@ static int usb_debug(int argc, char **argv)

if(argc == 1) {
usb_debug_flush();
end_line();
return 0;
}

@@ -301,16 +308,21 @@ static int usb_debug(int argc, char **argv)
rtems_task_wake_after(1);
}
while(keypress_wait);
end_line();

return 0;
}

static int usb_load(int argc, char **argv)
{
if(!load_usb_firmware_file(argv[1])) {
int size;

size = load_usb_firmware_file(argv[1]);
if(size < 0) {
fprintf(stderr, "load failed\n");
return 2;
}
printf("loaded %d byte%s\n", size, size == 1 ? "" : "s");
debug_consume = 0;
return 0;
}
9 changes: 4 additions & 5 deletions src/usbfirmware.c
Original file line number Diff line number Diff line change
@@ -63,11 +63,10 @@ int load_usb_firmware_file(const char *name)

file = fopen(name, "r");
if(!file)
return 0;
return -1;
dsc.length = fread(buf, 1, sizeof(buf), file);
fclose(file);
if(dsc.length <= 0)
return 0;
do_load_usb_firmware(&dsc);
return 1;
if(dsc.length >= 0)
do_load_usb_firmware(&dsc);
return dsc.length;
}