Commit Graph

66 Commits

Author SHA1 Message Date
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 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
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
Rafael Silva 44f7984c58 target/rp: flash read write return bool 2022-08-25 18:10:41 -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
dragonmux 7107d14bbc sfdp: Moved the read debugging into the implementation 2022-08-08 14:43:29 -07:00
dragonmux 1556db88de rp: Made use of the extra information we pull back from the SFDP data in rp_flash_erase 2022-08-08 14:43:29 -07:00
dragonmux 09b044e351 rp: Cleanup in the Flash write/erase routines 2022-08-08 14:43:29 -07:00
dragonmux e69a79cecf rp: Types cleanup for the Flash erase/write routines 2022-08-08 14:43:29 -07:00
dragonmux 4630353be4 rp: Created a Flash container type for the SPI-specific configuration bits 2022-08-08 14:43:29 -07:00
dragonmux d883fd0cdc rp: Refactored the SPI Flash parameter and size readout into rp_add_flash() 2022-08-08 14:43:29 -07:00
dragonmux 8e99e8ec4d rp: Added some debugging to the SFDP read routine to aid with SFDP failures 2022-08-08 14:43:29 -07:00
dragonmux 298299d85b rp: Cleaned up some variable naming in the ROM function table reader 2022-08-08 14:43:29 -07:00
dragonmux 9681475ab5 rp: Made use of the SFDP routines to extract the necessary Flash parameters 2022-08-08 14:43:29 -07:00
dragonmux 253d0cc1d9 rp: Entirely rewrote the SPI Flash read routine so we can implement SFDP support 2022-08-08 14:43:29 -07:00
dragonmux 969c7c6c14 rp: Naming cleanup for the memory region base addresses and sizes 2022-08-08 14:43:29 -07:00
dragonmux ff30b66b3a rp: Cleaned up the RP register definitions for the SPI Flash and the chip select line control routine 2022-08-08 14:43:29 -07:00
dragonmux 2058725dd8 rp: Cleaned up and rewrote the ROM function table readout code to be more understandable and transparent
This saves 20 bytes of Flash
2022-08-08 14:43:29 -07:00
dragonmux a372cfd787 rp: Fixed the private structure naming and made a typedef for it 2022-08-08 14:43:29 -07:00
dragonmux 11b43a7c66 rp: Refactored the ROM table tags using a helper macro 2022-08-08 14:43:29 -07:00
dragonmux f2b0d3030c rp: Fixed the UB _-prefixed naming of the ROM routines 2022-08-08 14:43:29 -07:00
dragonmux 8d772d048b rp: Cleaned up ROM table function table readout 2022-08-08 14:43:29 -07:00
dragonmux 8382b0aa7d rp: Magic numbers cleanup using top of file definitions 2022-08-08 14:43:29 -07:00
dragonmux 0077d31be3 rp: Make the function naming scheme uniform 2022-07-31 16:23:31 -07:00
dragonmux 6288d5884d rp: Fixed another clang-tidy warning 2022-07-31 16:23:31 -07:00
dragonmux 7266e3cf54 rp: More code re-ordering to make the order of definitions make more sense 2022-07-31 16:23:31 -07:00
dragonmux 982d1ac847 rp: atoi() -> strtoul() to fix the clang-tidy warning and improve robustness and correctness 2022-07-31 16:23:31 -07:00
dragonmux efb2e99408 rp: re-grouped the target-specific commands to the bottom of the implementation 2022-07-31 16:23:31 -07:00
dragonmux ae982cae6b rp: Begun re-ordering the code to make it more like other targets 2022-07-31 16:23:31 -07:00
dragonmux 9015013195 rp: static correctness for several of the RP2040 routines 2022-07-31 16:23:31 -07:00
dragonmux f429898adb rp: Removed rp_detach as the function serves no purpose 2022-07-31 16:23:31 -07:00
Rafael Silva 8b5206fb8d target: add weak aliasing to allow disabling targets
Signed-off-by: Rafael Silva <perigoso@riseup.net>
2022-07-26 05:08:10 +01:00
dragonmux c530bd077b misc: Switched to using C11 2022-07-18 20:59:15 -07:00
dragonmux d64992ade8 rp: Cleanup in how we define some of the Flash constants 2022-07-13 19:34:57 -07:00
dragonmux e9b75ba4bc rp: Switched to the unified mass erase command and added progress dots to stop GDB timing out 2022-07-13 19:34:57 -07:00
Jonathan Giles 780ee7a2a8 Fix build error and logic ... 2022-06-28 06:31:16 -04:00
dragonmux aa9c80b37d misc: Formatting consistency 2022-06-26 16:51:58 -07:00
dragonmux b226c53d13 misc: Renamed CORTEXM_TOPT_INHIBIT_NRST to clarify usage and align naming 2022-06-26 16:51:58 -07:00
James Turton e702afad69 rp: Clean up code a little bit 2022-06-24 20:44:00 -04:00
James Turton e67cb9f43c rp: Update rp_get_flash_length algorithm
Try to look for repeating sectors before reverting to reading the
JEDEC ID of the flash chip. This way we don't interrupt the flash
execution if a valid program is running, but can detect the flash
size if the flash memory has been erased.
2022-06-24 20:44:00 -04:00
James Turton f2cb13cf36 rp: Add rp_attach and rp_detach callbacks
Query JEDEC ID of flash chip on attach to be able to decode flash
chip size.
2022-06-24 20:44:00 -04:00
James Turton 354e37fbad rp: Tidy up some other things 2022-06-24 20:44:00 -04:00
James Turton ce273889fc rp: Refector rp_flash_write
Fix typo in debug message
2022-06-24 20:44:00 -04:00
James Turton f4261c465e rp: Refactor rp_flash_erase
Always align erase length to 4k sector size.
Check that start address and length are actually inside the flash.
2022-06-24 20:44:00 -04:00
James Turton af48a343a8 rp: Add description for SPI flash commands 2022-06-11 11:54:34 -04:00