Commit Graph

2400 Commits

Author SHA1 Message Date
James Turton cb17c9d8a8 rp: Fix argument parsing in reset_usb_boot 2022-09-19 09:53:28 -04:00
James Turton 5e06ef4015 rp: Don't aboard program when attaching
Reading the sfdp parameter table in the flash causes the spi peripheral
to be reconfigure, and, while the previous configuration is restored,
this causes the running program to be aboarded. Reading the sfdp table
before erasing the memory could be considered safe as we are going to be
modifying the flash anyway.
2022-09-19 09:53:28 -04:00
James Turton eb17a279a5 adiv5: Add comment to ap probe loop 2022-09-15 10:54:16 -04:00
James Turton 0d9ff6c4b1 rp: Revise logic for rp rescue dp
The rp2040 will clear the CDBGPWRUPREQ bit after the processor has
rebooted and halted so we shouldn't clear it ourselves. We can also
check when it has been cleared so we know this process has completed.
2022-09-15 10:54:16 -04:00
James Turton a9c2cb96eb target/adiv5: Resume targets that have been halted
Some targets have been halted while probing them, but the should be
resumed before we leave.
2022-09-15 10:54:16 -04:00
James Turton 32f441dd63 target/adiv5: Deassert CDBGRSTREQ after CDBGRSTACK
In B2.4 of the ADIv5 architecture specification it states that "If
CDBGRSTREQ is removed before the reset controller asserts CDBGRSTACK,
the behavior is UNPREDICTABLE.". Thus we should wait until after
checking for CDBGRSTACK before deasserting CDBGRSTREQ.
2022-09-15 10:54:16 -04:00
Uwe Bonnes 2922539772 stm32l0/stm32lx_nvm_busy_wait: Check for errors only after busy is released.
While busy, EOP(end of operation) is not yet set. But check for communication errors.
2022-09-14 13:15:01 -04:00
Thomas Bénéteau c0b7d4e2c4 rtt: Fix infinite loop in rtt_write 2022-09-13 09:56:45 -04:00
Sean Cross 3e8f296dd5 rp: invert success logic in rp_flash_write
Target write operations return boolean values: `true` indicates a write
was successful, while `false` indicates there was a failure.

Inside the rpi target, there is a delegate function `rp_rom_call` that
performs the heavy lifting. It also returns `true` on success and
`false` on failure.

The rp_flash_write() function was inverting this logic, which caused it
to return `false` on success and `true` on failure. This behaviour was
exhibited as only the first 0x89c bytes successfully write to the
device.

Invert this logic in order to get rpi working again.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-09-03 01:58:29 -04:00
Ben Tober 993c74bef4 lpc: Fix bugs related to flash on LPC MCUs
- A previous comment in lpc546xx.c was incorrect - one cannot rely on
resetting the target to leave the main clock set to the 12MHz FRO.
- A comparison in lpc_common.c was incorrect causing flash erase not to
work.
- The IAP API status field was not being explicitly initialized.  If
somehow an API call didn't execute properly (for example if it caused an
exception), we might not notice.  This is fixed by initializing the
status to a value that the API would never return.
2022-09-01 21:45:20 -04:00
Sean Cross 16afde7df4 cortexm: fix printf format for cpuid_partno
Use %04x instead of PRIx32. We can't use PRIx16, since apparently it
doesn't work reliably with ARM newlib.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-08-31 15:28:07 -04:00
Rafael Silva 665138f9e3 target/renesas: add known id for RA4M2 2022-08-31 09:21:37 -04:00
Rafael Silva d041e3a066 misc: fix malformed include guards 2022-08-30 13:58:25 -04:00
dragonmux 0edd8f0e67 cortexm: Refactored out the logic for reading the CPU ID into its own function 2022-08-29 14:58:35 -07:00
dragonmux 8d5caeaaff misc: Fixed the formatting of the main sources list in the main project makefile 2022-08-29 14:58:35 -07:00
dragonmux f4345e4714 adiv5: Fixed the Cortex-M23 and Cortex-M33 SCS definitions 2022-08-29 14:58:35 -07:00
dragonmux 9f9cc13401 adiv5: Cleanup and types fixes to fix some clang-tidy and stylistic lint 2022-08-29 14:58:35 -07:00
dragonmux cfa9e9858d adiv5: Revert f010a56 as it makes bad assumptions about APs that use the same base address 2022-08-29 14:58:35 -07:00
dragonmux e59ebb0e1d adiv5: Cleaned up and made use of the DP bank selection macros 2022-08-29 14:58:35 -07:00
dragonmux 0c708ffa48 command: Fixed the regression in the RTT command's formatting output caused by a bad refactor 2022-08-28 14:39:36 -07:00
dragonmux 48bda951fc misc: Cleaned up a stub `HACKING` file. 2022-08-28 14:25:04 -07:00
dragonmux 47940ed1e0 misc: Added advice on how contribution licensing should be done and works 2022-08-28 14:25:04 -07:00
dragonmux 5525e05ea2 misc: Added a ToC to the top of HACKING.md 2022-08-28 14:25:04 -07:00
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