Commit Graph

2377 Commits

Author SHA1 Message Date
dragonmux 1f87ede6b6 misc: Added advice on how `typedef`s should work and the naming strategy we expect 2022-08-28 14:25:04 -07:00
dragonmux 7db11e1186 misc: Added advice on how the project expects include guard macros to work 2022-08-28 14:25:04 -07:00
L. E. Segovia 5e98f30ff4 target: fix weak aliasing of probe NOPs on macOS
AppleClang has several incompatibilities with __attribute__((weak,
alias)) that prevent sane GCC-like usage on macOS:

- it does not support __attribute__((alias)) at all, only the #pragma
  weak symbol1 = symbol2 syntax [1]

- the compiler removes unused static functions prior to aliasing, which
  renders the above into an error [2].

To fix this, I implemented weak aliasing using the #pragma directive and
the recommended indirection macros from the GCC docs [3] and removing
the static inline specifiers from the functions if building under macOS.

Fixes #1204

[1]: See, for instance, https://sourceforge.net/p/openocd/tickets/304/
and Google "error: aliases are not supported on darwin".

[2]: https://bugs.llvm.org/show_bug.cgi?id=17775

[3]: https://gcc.gnu.org/onlinedocs/cpp/Pragmas.html
2022-08-28 15:56:50 -04:00
L. E. Segovia a26fa8f6f1 target/cortex: include alloca.h instead of malloc.h on *nix systems 2022-08-28 15:56:50 -04:00
L. E. Segovia bb058d8f35 macOS: do not use -Wno-format-truncation, AppleClang does not support it 2022-08-28 15:56:50 -04:00
Rafael Silva a23ba218a7 target/renesas: flash read write return bool 2022-08-26 13:32:06 -04:00
Rafael Silva 6cafdeaa73 target_flash: enter_flash_mode return type fix 2022-08-26 13:32:06 -04:00
Rafael Silva 8b03038b44 target/renesas: remove extra flash write check 2022-08-26 13:32:06 -04:00
Rafael Silva 2f3c2c20a1 target/renesas: split flash preparation and termination logic to prepare/done functions 2022-08-26 13:32:06 -04:00
Rafael Silva 78296deffb target/renesas: remove alignment checks 2022-08-26 13:32:06 -04:00
Rafael Silva 3a28b58aa9 target/renesas: add enter_flash_mode function 2022-08-26 13:32:06 -04:00
Rafael Silva 31856f028f target/renesas: add rv40 flash error check 2022-08-26 13:32:06 -04:00
Rafael Silva 01cd733745 target/renesas: simplify rv40 block erase logic 2022-08-26 13:32:06 -04:00
Rafael Silva fcfbc0fdf1 target/renesas: add rv40 flash support 2022-08-26 13:32:06 -04:00
Rafael Silva a67fe703e4 target: add Renesas initial support 2022-08-26 13:32:06 -04:00
Sean Cross c8edad4ed3 sam4l: fix debug formatting
SAM4L added a DEBUG_INFO command that uses insufficiently-specific formatting.
This breaks compiles on ESP32.

Use specific formatters. Additionally, ensure that FLASHCALW_BASE is
defined as a long int, which allows it to be formatted with "%x".

Signed-off-by: Sean Cross <sean@xobs.io>
2022-08-25 23:08:45 -04:00
Mikaela Szekely 7e701add55 Apply header include guard cleanup from #1209 to gdb_reg.h 2022-08-25 18:29:57 -04:00
Mikaela Szekely 9576d13cf7 misc: rename ARRAY_SIZE to ARRAY_LENGTH and guard it 2022-08-25 18:29:57 -04:00
Mikaela Szekely 6217da4eab clang-format on cortexa.c, cortexm.c, gdb_reg.c, and gdb_reg.h 2022-08-25 18:29:57 -04:00
Mikaela Szekely bc5a41530e target/cortex: we remembered calloc() exists and saved another 16 bytes 2022-08-25 18:29:57 -04:00
Mikaela Szekely 2cf1aff698 target/cortex: malloc/free tdesc on attach/detach instead of once on probe 2022-08-25 18:29:57 -04:00
Mikaela Szekely 8f4a8ab593 target/cortex: fix -Wconversion warnings in dynamic tdesc generation 2022-08-25 18:29:57 -04:00
Mikaela Szekely d16b0f8b47 misc: move ARRAY_SIZE macro into general.h 2022-08-25 18:29:57 -04:00
Mikaela Szekely c136b919cd target/cortex: dynamically generate tdesc strings to save code size
This commit removes the previous tdesc_cortex_a, tdesc_cortex_m, and
tdesc_cortex_mf XML string literals used for target description to GDB,
now instead programmatically generating them at runtime to significantly
deduplicate the characters that get embedded into the binary.

Output of ld's --print-memory-usage during final link before:
Memory region         Used Size  Region Size  %age Used
             rom:      116388 B       128 KB     88.80%
             ram:        3348 B        20 KB     16.35%

Output of ld's --print-memory-usage during final link now:
Memory region         Used Size  Region Size  %age Used
             rom:      113032 B       128 KB     86.24%
             ram:        3376 B        20 KB     16.48%

So all in all this saves 3356 bytes of flash.

Note: the exact size saved when compiled on your machine may differ, as
the size of the build seems at least partially non-deterministic.
We've gotten slightly different sizes (within 15 bytes of each other)
at different times, with the only differences being things like which
files were rebuilt in an incremental rebuild, or the order object files
were given to the linker command line. The numbers given above were the
numbers we got when testing the final builds from scratch, but all the
sizes we got were extremely similar to the sizes listed above.
2022-08-25 18:29:57 -04:00
Rafael Silva 42145f708b target/stm32l0: macro cleanup 2022-08-25 18:10:41 -04:00
Rafael Silva 085dcb7bc9 target/stm: flash read write return bool 2022-08-25 18:10:41 -04:00
Rafael Silva 67c9f3f6e2 target/sam: flash read write return bool 2022-08-25 18:10:41 -04:00
Rafael Silva 44f7984c58 target/rp: flash read write return bool 2022-08-25 18:10:41 -04:00
Rafael Silva ac6aaaeab0 target/nxpke04: flash read write return bool 2022-08-25 18:10:41 -04:00
Rafael Silva 220293abc6 target/nrf51: flash read write return bool 2022-08-25 18:10:41 -04:00
Rafael Silva 232b6dd376 target/msp432: flash read write return bool 2022-08-25 18:10:41 -04:00
Rafael Silva f0c955432b target/lpc: flash read write return bool 2022-08-25 18:10:41 -04:00
Rafael Silva 50057d3f55 target/lmi: flash read write return bool 2022-08-25 18:10:41 -04:00
Rafael Silva b78818b9ee target/kinetis: flash read write return bool 2022-08-25 18:10:41 -04:00
Rafael Silva a6e5b18707 target/efm32: flash read write return bool 2022-08-25 18:10:41 -04:00
Rafael Silva cf28b352a7 target/ch32f1: flash read write return bool 2022-08-25 18:10:41 -04:00
Rafael Silva e968fc956c target_flash: flash read write return bool 2022-08-25 18:10:41 -04:00
Rafael Silva 664d09786a workflows: add size diff workflow 2022-08-24 17:24:28 -04:00
Rafael Silva deb6198921 target_flash: swap while for forloop in buffered flush 2022-08-24 16:03:40 -04:00
Rafael Silva 1a1f4b76ff target_flash: change return types to bool 2022-08-24 16:03:40 -04:00
Rafael Silva aec7460426 target_flash: use new variable for buf size
in cases where blocksize is very large, the allocation may fail due to its size, allow specifying smaller buffer sizes
2022-08-24 16:03:40 -04:00
Rafael Silva be4b07f5ef target_flash: optimize flash prepare/done calls on erase 2022-08-24 16:03:40 -04:00
Rafael Silva 7f25846d36 target_flash: rework buffered writes
ensures aligned writes (aligned to ->writesize)
allows writes to flash smaller than buffer size
deallocate buffer only when done flashing
ensure flashing when writing intermittent blocks of data
new "prepare -> write -> done" function call flow
2022-08-24 16:03:40 -04:00
Rafael Silva 44a028344a target_flash: add prepare routine and extra return checks 2022-08-24 16:03:40 -04:00
Rafael Silva e72edc0579 target_flash: abstract target flash mode/flash preparation 2022-08-24 16:03:40 -04:00
Rafael Silva 520be57e3d target: split target flash functions into seperate file 2022-08-24 16:03:40 -04:00
Rafael Silva 3d3dd21d48 target: ensure aligned erases 2022-08-24 16:03:40 -04:00
Rafael Silva 89a5c2a8a2 target: target_addr type name cleanup 2022-08-24 16:03:40 -04:00
Rafael Silva 21922676f9 target: target_flash type cleanup 2022-08-24 16:03:40 -04:00
Piotr Esden-Tempski 31adb2f94d misc: Cleanup include guards.
Using underscore prefixes is not allowed for include guards as all
defines starting with underscore are reserved. At the same time made
file ends and spacing and style of include guards consistent in all
headers.

The new style of include guards also includes the directory of the
include file relative to `src` directory to prevent potential future
issues where we might end up with a name clash across directories.
2022-08-23 15:06:21 -04:00