commit c26905de84b9396512331de9d52e30e21fe49c7f
parent 2158159215595905e6cb3d71e7aef8b349427d52
Author: Brian Swetland <swetland@playground.global>
Date: Wed, 24 Feb 2016 16:47:12 -0800
debugger: correctly invoke agent:setup()
- pass pointer to flash_agent structure so setup can modify it as needed
- report setup result ERR_INVALID as "unsupported part"
Diffstat:
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/include/agent/flash.h b/include/agent/flash.h
@@ -100,6 +100,7 @@ int flash_agent_ioctl(u32 op, void *ptr, u32 arg0, u32 arg1);
// flash_addr, and flash_size are read back after this method
// returns success (to allow it to dynamically size flash based
// on part ID, etc).
+// - ERR_INVALID indicates an unsupported part
// fa.data_size must be a multiple of the minimum block size that
// fa.write requires, so that if the host has to issue a series
@@ -108,9 +109,9 @@ int flash_agent_ioctl(u32 op, void *ptr, u32 arg0, u32 arg1);
//
// fa.write() may round writes up the the minimum write block size
// as necessary, and should fill with 0s in that case.*
-//
+//
// fa.write() behaviour is undefined if the underlying flash has not
-// been erased first. It may fail (ERR_FAIL) or it may appear to
+// been erased first. It may fail (ERR_FAIL) or it may appear to
// succeed, but flash contents may be incorrect.
//
// fa.write() may fail (ERR_ALIGN) if the start address is not aligned
@@ -128,12 +129,12 @@ int flash_agent_ioctl(u32 op, void *ptr, u32 arg0, u32 arg1);
//
// Bogus parameters may cause failure (ERR_INVALID)
//
-// * In general, conveying the full complexity of embedded flash
+// * In general, conveying the full complexity of embedded flash
// configuration (which could include various banks of various sizes,
// with differing write and erase block size requirements) is not
// attempted. The goal is to provide an agent that can reasonably
// handle reasonable flash requests (eg the user knows what a sane
-// starting alignment, etc is, does not split logical "partitions"
+// starting alignment, etc is, does not split logical "partitions"
// across physical erase block boundaries, etc)
#endif
diff --git a/tools/debugger-commands.c b/tools/debugger-commands.c
@@ -697,6 +697,7 @@ int run_flash_agent(u32 flashaddr, void *data, size_t data_sz) {
u8 buffer[4096];
flash_agent *agent;
size_t agent_sz;
+ int r;
if (AGENT == NULL) {
xprintf(XCORE, "error: no flash agent selected\n");
@@ -737,7 +738,11 @@ int run_flash_agent(u32 flashaddr, void *data, size_t data_sz) {
xprintf(XCORE, "error: failed to download agent\n");
goto fail;
}
- if (invoke(agent->load_addr, agent->setup, 0, 0, 0, 0)) {
+ r = invoke(agent->load_addr, agent->setup, agent->load_addr, 0, 0, 0);
+ if (r != 0) {
+ if (r == ERR_INVALID) {
+ xprintf(XCORE, "agent: unsupported part\n");
+ }
goto fail;
}
if (swdp_ahb_read32(agent->load_addr + 16, (void*) &agent->data_addr, 4)) {
@@ -757,7 +762,8 @@ int run_flash_agent(u32 flashaddr, void *data, size_t data_sz) {
if ((flashaddr < agent->flash_addr) ||
(data_sz > agent->flash_size) ||
((flashaddr + data_sz) > (agent->flash_addr + agent->flash_size))) {
- xprintf(XCORE, "invalid flash address %08x\n", flashaddr);
+ xprintf(XCORE, "invalid flash address %08x..%08x\n",
+ flashaddr, flashaddr + data_sz);
goto fail;
}