v3hil: eZ-FET 3.8(r) working; 3.12(y) and 3.15 TODO
This commit is contained in:
parent
4db31c4287
commit
fc79881203
|
@ -16,13 +16,22 @@
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include "bytes.h"
|
#include "bytes.h"
|
||||||
#include "v3hil.h"
|
#include "v3hil.h"
|
||||||
#include "dis.h"
|
#include "dis.h"
|
||||||
#include "output.h"
|
#include "output.h"
|
||||||
#include "opdb.h"
|
#include "opdb.h"
|
||||||
|
|
||||||
|
/*map: 1e -> 43
|
||||||
|
map: 14 -> 3c*/
|
||||||
|
/* tilib:
|
||||||
|
* 3f; 43; 40; 3c; 04; 3b; 42; 40; 3d; 3f; 5a; 40...; 07...; 3f; 43; 40; 3c;
|
||||||
|
* 06; HAL92
|
||||||
|
*/
|
||||||
|
|
||||||
/* HAL function IDs */
|
/* HAL function IDs */
|
||||||
typedef enum {
|
typedef enum {
|
||||||
HAL_PROTO_FID_INIT = 0x01,
|
HAL_PROTO_FID_INIT = 0x01,
|
||||||
|
@ -165,9 +174,26 @@ typedef enum {
|
||||||
|
|
||||||
static hal_proto_fid_t map_fid(const struct v3hil *h, hal_proto_fid_t src)
|
static hal_proto_fid_t map_fid(const struct v3hil *h, hal_proto_fid_t src)
|
||||||
{
|
{
|
||||||
hal_proto_fid_t dst = h->chip->v3_functions[src];
|
hal_proto_fid_t src2 = src, dst, dst2;
|
||||||
|
|
||||||
return dst ? dst : src;
|
if (src > HAL_PROTO_FID_GET_DEVICE_ID_PTR && false) {
|
||||||
|
src2 = src - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
dst = h->chip->v3_functions[src2];
|
||||||
|
|
||||||
|
if (dst) {
|
||||||
|
if (h->proto_ver == 3 && dst >= HAL_PROTO_FID_GET_DEVICE_ID_PTR && false) {
|
||||||
|
dst2 = dst + 1;
|
||||||
|
} else {
|
||||||
|
dst2 = dst;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dst2 = src;
|
||||||
|
}
|
||||||
|
|
||||||
|
printc_err("map: %02x -> %02x\n", src, dst2);
|
||||||
|
return dst2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void v3hil_init(struct v3hil *h, transport_t trans,
|
void v3hil_init(struct v3hil *h, transport_t trans,
|
||||||
|
@ -231,6 +257,8 @@ int v3hil_comm_init(struct v3hil *h)
|
||||||
printc_dbg("Version: %d.%d.%d.%d Core version: 0x%02x, HIL version: 0x%02x, HW: 0x%04x\n",
|
printc_dbg("Version: %d.%d.%d.%d Core version: 0x%02x, HIL version: 0x%02x, HW: 0x%04x\n",
|
||||||
major, minor, patch, build,
|
major, minor, patch, build,
|
||||||
core_version, hil_version, hw_thing);
|
core_version, hil_version, hw_thing);
|
||||||
|
|
||||||
|
h->proto_ver = major;
|
||||||
} else {
|
} else {
|
||||||
const uint8_t major = h->hal.payload[1] >> 6;
|
const uint8_t major = h->hal.payload[1] >> 6;
|
||||||
const uint8_t minor = h->hal.payload[1] & 0x3f;
|
const uint8_t minor = h->hal.payload[1] & 0x3f;
|
||||||
|
@ -240,6 +268,8 @@ int v3hil_comm_init(struct v3hil *h)
|
||||||
printc_dbg("Version: %d.%d.%d.%d, HW: 0x%04x\n",
|
printc_dbg("Version: %d.%d.%d.%d, HW: 0x%04x\n",
|
||||||
major, minor, patch, flavour,
|
major, minor, patch, flavour,
|
||||||
r32le(h->hal.payload + 4));
|
r32le(h->hal.payload + 4));
|
||||||
|
|
||||||
|
h->proto_ver = major;
|
||||||
}
|
}
|
||||||
|
|
||||||
printc_dbg("Reset firmware...\n");
|
printc_dbg("Reset firmware...\n");
|
||||||
|
@ -276,7 +306,19 @@ int v3hil_start_jtag(struct v3hil *h, v3hil_jtag_type_t type)
|
||||||
|
|
||||||
int v3hil_stop_jtag(struct v3hil *h)
|
int v3hil_stop_jtag(struct v3hil *h)
|
||||||
{
|
{
|
||||||
return hal_proto_execute(&h->hal, HAL_PROTO_FID_STOP_JTAG, NULL, 0);
|
//printc_dbg("Stop JTAG...\n");
|
||||||
|
if (hal_proto_execute(&h->hal, HAL_PROTO_FID_STOP_JTAG, NULL, 0) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
//printc_dbg("Reset communications...\n");
|
||||||
|
h->hal.ref_id = 0;
|
||||||
|
if (hal_proto_send(&h->hal, HAL_PROTO_TYPE_EXCEPTION, NULL, 0) < 0) {
|
||||||
|
h->hal.ref_id = 0;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
h->hal.ref_id = 0;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int v3hil_sync(struct v3hil *h)
|
int v3hil_sync(struct v3hil *h)
|
||||||
|
|
|
@ -44,6 +44,9 @@ struct v3hil {
|
||||||
/* Lower 8 bits of saved WDTCTL */
|
/* Lower 8 bits of saved WDTCTL */
|
||||||
uint8_t wdtctl;
|
uint8_t wdtctl;
|
||||||
|
|
||||||
|
/* Is this a v2 or v3 firmware running on the eZ-FET? */
|
||||||
|
uint8_t proto_ver;
|
||||||
|
|
||||||
/* Register cache: this must be flushed before restoring context
|
/* Register cache: this must be flushed before restoring context
|
||||||
* and updated after saving context.
|
* and updated after saving context.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue