Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First byte of the data passed to libusb #29

Open
xparkm opened this issue Dec 16, 2022 · 2 comments
Open

First byte of the data passed to libusb #29

xparkm opened this issue Dec 16, 2022 · 2 comments

Comments

@xparkm
Copy link

xparkm commented Dec 16, 2022

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

@dashesy
Copy link
Owner

dashesy commented Dec 17, 2022

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)

@xparkm
Copy link
Author

xparkm commented Dec 17, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants