Major formatting/whitespace cleanup

This commit is contained in:
px4dev
2012-10-23 23:51:13 -07:00
parent 34f99c7dca
commit 2fc1032069
50 changed files with 1112 additions and 810 deletions
+8
View File
@@ -67,10 +67,12 @@ bl_update_main(int argc, char *argv[])
setopt();
int fd = open(argv[1], O_RDONLY);
if (fd < 0)
err(1, "open %s", argv[1]);
struct stat s;
if (stat(argv[1], &s) < 0)
err(1, "stat %s", argv[1]);
@@ -79,14 +81,17 @@ bl_update_main(int argc, char *argv[])
errx(1, "%s: file too large", argv[1]);
uint8_t *buf = malloc(s.st_size);
if (buf == NULL)
errx(1, "failed to allocate %u bytes for firmware buffer", s.st_size);
if (read(fd, buf, s.st_size) != s.st_size)
err(1, "firmware read error");
close(fd);
uint32_t *hdr = (uint32_t *)buf;
if ((hdr[0] < 0x20000000) || /* stack not below RAM */
(hdr[0] > (0x20000000 + (128 * 1024))) || /* stack not above RAM */
(hdr[1] < 0x08000000) || /* entrypoint not below flash */
@@ -123,6 +128,7 @@ bl_update_main(int argc, char *argv[])
/* wait for the operation to complete */
while (*sr & 0x1000) {
}
if (*sr & 0xf2) {
warnx("WARNING: erase error 0x%02x", *sr);
goto flash_end;
@@ -148,6 +154,7 @@ bl_update_main(int argc, char *argv[])
/* wait for the operation to complete */
while (*sr & 0x1000) {
}
if (*sr & 0xf2) {
warnx("WARNING: program error 0x%02x", *sr);
goto flash_end;
@@ -203,6 +210,7 @@ setopt(void)
if ((*optcr & opt_mask) == opt_bits)
errx(0, "option bits set");
errx(1, "option bits setting failed; readback 0x%04x", *optcr);
}