cc-tool
cc-tool copied to clipboard
First byte of the data passed to libusb
Hi, I am adding functions to be able to send other debug commands with cc_tool. I am trying to figure out what is the first byte of the data sent to the debugger.
For example, in cc_unit_driver.cpp, write_sfr() uint8_t header[] = { 0x40, 0x55, 0x00, };
the 0x55 0x00
are for DEBUG_INSTR NOP
, but what is 0x40
?
Similarly, in read_debug_config, uint8_t command[] = { 0x1F, DEBUG_COMMAND_RD_CONFIG };
, what is 0x1F
?
These bytes are not a part of debug protocol and I could not find anything special about the first byte in any of the libusb examples.
Thank you
Some definitions here. Not sure what 0x1f is but it could be all those config flags added: 0x1+0x2+0x4+0x8+0x10 (not sure what 0x10 flag is though)
Thank you for responding. Those are the DEBUG_STATUS bits though. READ_status command returns the byte that's decoded in those bits.
I've looked at more of data and there is an extra byte right before the every debug command. For example, in this sequence from read_xdata_memory
uint8_t header[] = {
0x40, 0x55, 0x00, 0x72, 0x56, 0xE5, 0x92, 0xBE, 0x57, 0x75,
0x92, 0x00, 0x74, 0x56, 0xE5, 0x83, 0x76, 0x56, 0xE5, 0x82 };
There is a NOP
, three MOV A, direct
instructions and a MOV direct,#data
instruction.
The three MOV A, direct
instruction sequences 0x72, 0x56, 0xE5, 0x92,
, 0x74, 0x56, 0xE5, 0x83,
, and 0x76, 0x56, 0xE5, 0x82
they are all with slightly different operands and they have 0x72
, 0x74
, and 0x76
before the DEBUG_INSTR command.
Looks like there is always 0x40
before a NOP
but 0x5E
before both, MOVX @DPTR,A
and INC DPTR
instructions. There is a hardcoded bytes before instruction the operands of which are passed in to the function as arguments, so can't be anything like parity or checksum. Does not look like byte count. I'll stare at it some more over the weekend
Thanks