mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-17 19:33:34 +08:00
Major formatting/whitespace cleanup
This commit is contained in:
@@ -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);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user