Commit Graph

2409 Commits

Author SHA1 Message Date
James Turton ca867d0ee7 rp: Stylistic fixes 2022-09-19 09:53:28 -04:00
James Turton bf0302b076 rp: Run clang-format 2022-09-19 09:53:28 -04:00
James Turton 14882c61ab rp: Don't reset QSPI bank or flush XIP cache
We should do as little 'damage' when attaching to the processor, so
don't reset the entire QSPI IO and PADS subsystems. We can assume that
either the bootloader or the running program has setup the QSPI pins
into some kindn of useable mode. Similarly no need to clear the XIP
cache as we will not be making any cacheable XIP accesses.
2022-09-19 09:53:28 -04:00
James Turton 427fe1f698 rp: Implement own functions for handling flash
Using the fuctions provided by the bootrom to access the flash chip
causes an interuption in the program execution. Implementing our own
functions allows us to leave things exactly how the used to be, thus the
program can be continued after attaching.
2022-09-19 09:53:28 -04:00
James Turton 2f508b9f53 rp: Stylistic fixes 2022-09-19 09:53:28 -04:00
James Turton 4cc3eee154 rp: Define enter_flash_mode and exit_flash_mode
Defining these methods highly accelerates the flash loading time as we
no longer return the flash to XIP mode after each buffered write,
instead we wait until the entire transaction has finished before
returning to XIP mode.
2022-09-19 09:53:28 -04:00
James Turton 481aaee3a3 rp: Only read SFDP once 2022-09-19 09:53:28 -04:00
James Turton 23bc57d02f rp: Scan for SFDP table on attach
If no valid program is loaded in the flash then it's ok to read the SFDP
table. This is preferable over the JEDEC ID as it gives us more info.
2022-09-19 09:53:28 -04:00
James Turton 027a1779a6 rp: Use MAX_WRITE_CHUNK when defining flash 2022-09-19 09:53:28 -04:00
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