I have cross-compiled the latest commit of tslib from github ( https://github.com/kergoth/tslib/commits/master ). My touchscreen is hooked up to my embedded board and I enabled the drivers from the vendor. When I boot and look at the output of 'cat /dev/input/touchscreen' I can see plenty of output being generated from moving my fingers around the screen. The Kernel also outputs to the console nicely formatted messages for 'finger1' and 'finger2'.
I am not able to calibrate however. When I set my environment variables like shown below and run ts_calibrate, it spits out the message 'xres = 640, yres = 480 tslib: Selected device is not a touchscreen (must support ABS and KEY event types)' and does nothing more...
So Linux knows that my device exists and I can see scrolling output, but tslib can't calibrate. What am I doing wrong and how can I fix this?
# ls -rlt /dev/input/touchscreen
lrwxrwxrwx 1 root root 6 Jan 17 21:06 /dev/input/touchscreen -> event1
# chmod 777 /dev/input/touchscreen
# chmod 777 /dev/input/event1
# cat /dev/input/touchscreen | hexdump
0000000 9011 3883 565f 0001 0003 0030 0001 0000
0000010 9011 3883 565f 0001 0003 0032 0001 0000
0000020 9011 3883 565f 0001 0003 0035 04c9 0000
0000030 9011 3883 565f 0001 0003 0036 0c3f 0000
0000040 9011 3883 565f 0001 0000 0002 0000 0000
0000050 9011 3883 565f 0001 0000 0000 0000 0000
0000060 9011 3883 90a9 0001 0003 0030 0001 0000
0000070 9011 3883 90a9 0001 0003 0032 0001 0000
# cat /sys/devices/virtual/input/input1/uevent
PRODUCT=0/0/0/0
NAME="aura-touchscreen"
PROP=0
EV=9
ABS=650000 0
MODALIAS=input:b0000v0000p0000e0000-e0,3,kra30,32,35,36,mlsfw
# cat /etc/ts.conf
# Uncomment if you wish to use the linux input layer event interface
module_raw input
module pthres pmin=1
module variance delta=30
module dejitter delta=100
module linear
export TSLIB_TSEVENTTYPE=INPUT
export TSLIB_TSDEVICE=/dev/input/touchscreen
export TSLIB_CALIBFILE=/etc/pointercal
export TSLIB_CONFFILE=/etc/ts.conf
export TSLIB_PLUGINDIR=/usr/lib/ts
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_CONSOLEDEVICE=none
export TSTS_INFO_FILE=/sys/devices/virtual/input/input1/uevent
export QWS_MOUSE_PROTO=tslib:/dev/input/touchscreen
export PATH=$PATH:/usr/bin
ts_calibrate
xres = 640, yres = 480
tslib: Selected device is not a touchscreen (must support ABS and KEY event types)
Interesting if I do 'cat /proc/bus/input/devices' then I can see my touchscreen but there is only an ABS entry ( no KEY ) and tslib says I need both. Can I somehow assign a 'KEY' entry here?
# cat /proc/bus/input/devices
I: Bus=0019 Vendor=0001 Product=0001 Version=0003
N: Name="TWL4030 Keypad"
P: Phys=twl4030_keypad/input0
S: Sysfs=/devices/platform/omap/omap_i2c.1/i2c-1/1-004a/twl4030_keypad/input/input0
U: Uniq=
H: Handlers=kbd event0
B: PROP=0
B: EV=100013
B: KEY=ffc
B: MSC=10
I: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name="aura-touchscreen"
P: Phys=
S: Sysfs=/devices/virtual/input/input1
U: Uniq=
H: Handlers=event1
B: PROP=0
B: EV=9
B: ABS=650000 0
Try to add
input_dev = input_allocate_device();
[..]
set_bit(EV_ABS, input_dev->evbit);
set_bit(EV_KEY, input_dev->evbit);
So that the tslib sees the device as supporting both EV_ABS and EV_KEY events (even if it does not actually send both of those).
You know how to reach me if you have more questions... ;)
I have the same exact problem
tslib: Selected device is not a touchscreen (must support ABS and KEY event types)
I added
set_bit(EV_SYN, aura.input_dev->evbit);
set_bit(EV_ABS, aura.input_dev->evbit);
set_bit(EV_KEY, aura.input_dev->evbit);
# I had to add this line so that tslib was happy
in my touch screen driver but still having the same problem. I can't able to calibrate the touch screen. please give suggestion.
static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
s32 ret = -1;
struct goodix_ts_data *ts;
u16 version_info;
GTP_DEBUG_FUNC();
set_bit(EV_SYN, aura.input_dev->evbit);
set_bit(EV_ABS, aura.input_dev->evbit);
set_bit(EV_KEY, aura.input_dev->evbit); # I had to add this line so that tslib was happy
//do NOT remove these output log
GTP_INFO("GTP Driver Version:%s",GTP_DRIVER_VERSION);
GTP_INFO("GTP Driver build#%s,%s", __TIME__,__DATE__);
GTP_INFO("GTP I2C Address:0x%02x", client->addr);
i2c_connect_client = client;
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
{
GTP_ERROR("I2C check functionality failed.");
return -ENODEV;
}
ts = kzalloc(sizeof(*ts), GFP_KERNEL);
if (ts == NULL)
{
GTP_ERROR("Alloc GFP_KERNEL memory failed.");
return -ENOMEM;
}
memset(ts, 0, sizeof(*ts));
INIT_WORK(&ts->work, goodix_ts_work_func);
ts->client = client;
i2c_set_clientdata(client, ts);
ts->irq_lock = SPIN_LOCK_UNLOCKED;
ts->gtp_rawdiff_mode = 0;
ret = gtp_request_io_port(ts);
if (ret < 0)
{
GTP_ERROR("GTP request IO port failed.");
kfree(ts);
return ret;
}
ret = gtp_i2c_test(client);
if (ret < 0)
{
GTP_ERROR("I2C communication ERROR!");
}
#if GTP_AUTO_UPDATE
//ret = gup_init_update_proc(ts);
//if (ret < 0)
//{
//GTP_ERROR("Create update thread error.");
//}
#endif
ret = gtp_init_panel(ts);
if (ret < 0)
{
GTP_ERROR("GTP init panel failed.");
}
ret = gtp_request_input_dev(ts);
if (ret < 0)
{
GTP_ERROR("GTP request input dev failed");
}
ret = gtp_request_irq(ts);
if (ret < 0)
{
GTP_INFO("GTP works in polling mode.");
}
else
{
GTP_INFO("GTP works in interrupt mode.");
}
ret = gtp_read_version(client, &version_info);
if (ret < 0)
{
GTP_ERROR("Read version failed.");
}
spin_lock_init(&ts->irq_lock);
ts->irq_lock = SPIN_LOCK_UNLOCKED;
gtp_irq_enable(ts);
#if GTP_CREATE_WR_NODE
//init_wr_node(client);
#endif
#if GTP_ESD_PROTECT
INIT_DELAYED_WORK(>p_esd_check_work, gtp_esd_check_func);
gtp_esd_check_workqueue = create_workqueue("gtp_esd_check");
queue_delayed_work(gtp_esd_check_workqueue, >p_esd_check_work, GTP_ESD_CHECK_CIRCLE);
#endif
return 0;
}
This basically is a bug in old versions of tslib. A recent version should work without problems.
Related
Hello i'm new at filterdriver writing so i'm apologizing for my basic question , i try to get the file name from a pre read function and check if it's equal to my file name and do some logic according to this info.
this is my function:
FLT_PREOP_CALLBACK_STATUS SwapPreReadBuffers( _Inout_ PFLT_CALLBACK_DATA Data, _In_ PCFLT_RELATED_OBJECTS FltObjects, _Flt_CompletionContext_Outptr_ PVOID *CompletionContext )
{
PFLT_IO_PARAMETER_BLOCK iopb = Data->Iopb;
FLT_PREOP_CALLBACK_STATUS retValue = FLT_PREOP_SUCCESS_NO_CALLBACK;
PVOID newBuf = NULL;
PMDL newMdl = NULL;
PVOLUME_CONTEXT volCtx = NULL;
PPRE_2_POST_CONTEXT p2pCtx;
NTSTATUS status;
ULONG readLen = iopb->Parameters.Read.Length;
PFLT_FILE_NAME_INFORMATION NameInfo = NULL;
UNICODE_STRING FILE_NAME;
//
// Skip IRP_PAGING_IO, IRP_SYNCHRONOUS_PAGING_IO and
// TopLevelIrp.
//
if ((Data->Iopb->IrpFlags & IRP_PAGING_IO) || (Data->Iopb->IrpFlags & IRP_SYNCHRONOUS_PAGING_IO) || IoGetTopLevelIrp())
{
return FLT_PREOP_SUCCESS_NO_CALLBACK;
}
RtlInitUnicodeString( & FILE_NAME, L"my_file.txt" );
status = FltGetFileNameInformation( Data, FLT_FILE_NAME_NORMALIZED |
FLT_FILE_NAME_QUERY_DEFAULT, &NameInfo );
if (!NT_SUCCESS( status ))
{
DbgPrint("[-] SwapPreReadBuffers we couldn't extract %wZ info\n", Data->Iopb->TargetFileObject->FileName);
}
status = FltParseFileNameInformation( NameInfo );
if (!NT_SUCCESS( status ))
{
DbgPrint("[-] SwapPreReadBuffers we couldn't pars %wZ info\n", Data->Iopb->TargetFileObject->FileName);
}
DbgPrint("[+] pars gets me Name: %wZ extention: %wZ perentDir: %wZ volume: %wZ \n", NameInfo->Name, NameInfo->Extension, NameInfo->ParentDir, NameInfo->Volume);
if (RtlPrefixUnicodeString( &FILE_NAME, &NameInfo->Name, TRUE )) /* here i'm getting the blue screen*/
{
DbgPrint("[***] SwapPreReadBuffers we are at calles thats related to our file %wZ \n", Data->Iopb->TargetFileObject->FileName);
}
/* continue of the code*/
}
my problem is i getting a blue screen when i try to check if the file name is equal to my wanted file name.
why the driver get here a blue screen?
Thank you
pit
edit:
i updated my code to this:
FLT_PREOP_CALLBACK_STATUS SwapPreReadBuffers( _Inout_ PFLT_CALLBACK_DATA Data, _In_ PCFLT_RELATED_OBJECTS FltObjects, _Flt_CompletionContext_Outptr_ PVOID *CompletionContext )
{
PFLT_IO_PARAMETER_BLOCK iopb = Data->Iopb;
FLT_PREOP_CALLBACK_STATUS retValue = FLT_PREOP_SUCCESS_NO_CALLBACK;
PVOID newBuf = NULL;
PMDL newMdl = NULL;
PVOLUME_CONTEXT volCtx = NULL;
NTSTATUS CbStatus = FLT_PREOP_SUCCESS_NO_CALLBACK;
PPRE_2_POST_CONTEXT p2pCtx;
NTSTATUS status;
ULONG readLen = iopb->Parameters.Read.Length;
PFLT_FILE_NAME_INFORMATION NameInfo = NULL;
UNICODE_STRING FILE_NAME;
//
// Skip IRP_PAGING_IO, IRP_SYNCHRONOUS_PAGING_IO and
// TopLevelIrp.
//
if ((Data->Iopb->IrpFlags & IRP_PAGING_IO) ||
(Data->Iopb->IrpFlags & IRP_SYNCHRONOUS_PAGING_IO) ||
IoGetTopLevelIrp()) {
DbgPrint("[-] SwapPreReadBuffers we out , this call not for us\n");
return FLT_PREOP_SUCCESS_NO_CALLBACK;
}
status = FltGetFileNameInformation( Data,
FLT_FILE_NAME_NORMALIZED
| FLT_FILE_NAME_QUERY_DEFAULT,
&NameInfo );
if (!NT_SUCCESS( status ))
{
DbgPrint("[-] SwapPreReadBuffers we couldn't extract info\n");
goto PreReadCleanup;
}
status = FltParseFileNameInformation( NameInfo );
if (!NT_SUCCESS( status ))
{
DbgPrint("[-] SwapPreReadBuffers we couldn't pars info\n");
goto PreReadCleanup;
}
if (NULL == NameInfo)
{
DbgPrint("[---] name info is actally 0\n");
}
else
{
DbgPrint("[*] address of name is %x:%x and address of extansion is %x:%x -> buffers are: name %x , extension: %x \nsize of info %d size of extension %d\n",NameInfo->Extension , &NameInfo->Extension, EXTENTION, &EXTENTION, NameInfo->Extension.Buffer , EXTENTION.Buffer ,NameInfo->Extension.Length , EXTENTION.Length);
}
if ((0 == RtlCompareUnicodeString( &EXTENTION, &NameInfo->Extension, TRUE ))) {
DbgPrint("[***] SwapPreReadBuffers we are at calles thats related to our file %wZ \n", &Data->Iopb->TargetFileObject->FileName);
DbgPrint("[+] pass parse\n");
DbgPrint("[+] pars gets me Name: %wZ\n extention: %wZ\n perentDir: %wZ\n volume: %wZ\n", &NameInfo->Name, &NameInfo->Extension, &NameInfo->ParentDir, &NameInfo->Volume);
}
else{
DbgPrint("[*] we pass compration check\n");
goto PreReadCleanup;
}
//
// Clean up
//
PreReadCleanup:
if (NameInfo) {
FltReleaseFileNameInformation( NameInfo );
}
return retValue;
}
and again i got a blue screen , this is the analized core dump:
kd> !analyze -v
*******************************************************************************
* *
* Bugcheck Analysis *
* *
*******************************************************************************
PAGE_FAULT_IN_NONPAGED_AREA (50)
Invalid system memory was referenced. This cannot be protected by try-except,
it must be protected by a Probe. Typically the address is just plain bad or it
is pointing at freed memory.
Arguments:
Arg1: 994af2a4, memory referenced.
Arg2: 00000000, value 0 = read operation, 1 = write operation.
Arg3: 82a72a17, If non-zero, the instruction address which referenced the bad memory
address.
Arg4: 00000000, (reserved)
Debugging Details:
------------------
READ_ADDRESS: GetPointerFromAddress: unable to read from 829a5718
Unable to read MiSystemVaType memory at 829851a0
994af2a4
FAULTING_IP:
nt!RtlCompareUnicodeStrings+3c
82a72a17 0fb706 movzx eax,word ptr [esi]
MM_INTERNAL_CODE: 0
CUSTOMER_CRASH_COUNT: 1
DEFAULT_BUCKET_ID: WIN7_DRIVER_FAULT
BUGCHECK_STR: 0x50
PROCESS_NAME: cmd.exe
CURRENT_IRQL: 0
TRAP_FRAME: a72b7974 -- (.trap 0xffffffffa72b7974)
ErrCode = 00000000
eax=00000003 ebx=994af2aa ecx=8da2064c edx=000000bf esi=994af2a4 edi=137f5b5e
eip=82a72a17 esp=a72b79e8 ebp=a72b79f4 iopl=0 nv up ei pl nz ac po nc
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00010212
nt!RtlCompareUnicodeStrings+0x3c:
82a72a17 0fb706 movzx eax,word ptr [esi] ds:0023:994af2a4=????
Resetting default scope
LAST_CONTROL_TRANSFER: from 8287c3d8 to 828c941b
STACK_TEXT:
a72b795c 8287c3d8 00000000 994af2a4 00000000 nt!MmAccessFault+0x106
a72b795c 82a72a17 00000000 994af2a4 00000000 nt!KiTrap0E+0xdc
a72b79f4 82a72b0f 994af2aa 00000003 acca4e02 nt!RtlCompareUnicodeStrings+0x3c
a72b7a10 994a9105 994ad090 acca4d6c 00000001 nt!RtlCompareUnicodeString+0x25
WARNING: Stack unwind information not available. Following frames may be wrong.
a72b7a6c 8b756aeb 87587068 a72b7a8c a72b7ab8 MyDriver2+0x1105
a72b7ad8 8b7599f0 a72b7b2c 87435e48 00000000 fltmgr!FltpPerformPreCallbacks+0x34d
a72b7af0 8b759f01 a72b7b2c 00000000 862ff240 fltmgr!FltpPassThroughInternal+0x40
a72b7b14 8b75a3ba 032b7b00 862ff240 00000000 fltmgr!FltpPassThrough+0x203
a72b7b44 82872593 862ff240 87435e48 87435e48 fltmgr!FltpDispatch+0xb4
a72b7b5c 82a6699f 87435e48 87435fd8 87590d98 nt!IofCallDriver+0x63
a72b7b7c 82a9f2da 862ff240 87590d98 00000001 nt!IopSynchronousServiceTail+0x1f8
a72b7c08 828791ea 862ff240 87435e48 00000000 nt!NtReadFile+0x644
a72b7c08 773e70b4 862ff240 87435e48 00000000 nt!KiFastCallEntry+0x12a
0013f014 00000000 00000000 00000000 00000000 0x773e70b4
STACK_COMMAND: kb
FOLLOWUP_IP:
MyDriver2+1105
994a9105 ?? ???
SYMBOL_STACK_INDEX: 4
SYMBOL_NAME: MyDriver2+1105
FOLLOWUP_NAME: MachineOwner
MODULE_NAME: MyDriver2
IMAGE_NAME: MyDriver2.sys
DEBUG_FLR_IMAGE_TIMESTAMP: 597b0358
FAILURE_BUCKET_ID: 0x50_MyDriver2+1105
BUCKET_ID: 0x50_MyDriver2+1105
Followup: MachineOwner
---------
so the crush is indead in the RtlCompareUnicodeString function (or in prefix version before) but i have no idea why it's crush there, it's look like i did every thing o.k.
your bug not in call RtlPrefixUnicodeString( &FILE_NAME, &NameInfo->Name, TRUE )) - here all ok. your bug in previous line:
DbgPrint("[+] pars gets me Name: %wZ extention: %wZ perentDir: %wZ volume: %wZ \n",
NameInfo->Name,
NameInfo->Extension,
NameInfo->ParentDir,
NameInfo->Volume);
the %wZ format require pointer to UNICODE_STRING - so must be
DbgPrint("[+] pars gets me Name: %wZ extention: %wZ perentDir: %wZ volume: %wZ \n",
&NameInfo->Name,
&NameInfo->Extension,
&NameInfo->ParentDir,
&NameInfo->Volume);
also if FltGetFileNameInformation fail - you must not use NameInfo after that (it will be 0 or undefined). but you not do this in code
and usually swap buffers need do when and only when Data->Iopb->IrpFlags & IRP_NOCACHE - so when data readed or writed to storage
There are a lot of mistakes here.
First of all don't print things that could be NULL, check them first.
Go through the FLT_FILE_NAME_INFORMATION structure and make sure all the data you want to print is actually there.
Fix your symbols in the debugger. Make sure your debugger has the symbol path set to the folder where your .pdb is.
Don't query the name in PreRead. There are several reasons not to do this, but I will tell you what you should do:
In Post IRP_MJ_CREATE query the name of the file that has been opened. Check if it is the file you are interested in. If no, just return flt postop finished processing otherwise, if it is a file you are interested in create a context for it and store the FileNameInformation there as well while you're at it.
Now in PreRead, when you are called simply ask for the context of the file object. If one is present, that means it is a file you are interested in so then you do your processing, otherwise you simply skip the read.
Be aware of string processing routines and IRQL. Don't use static stack strings for comparison like L"my_file.txt"
Also please show how your variable EXTENSION is initialized.
I have two programs, one is custom bootloader which will be located in BANK A and the other one is the main program which will be located in external spifi flash.
Both programs I load and debug from eclipse.
Currently I can jump from the bootloader to the main program, I can start debug with jtag from the reset handler in the main program but sometimes is continues to main and sometimes it breaks after the first step.
From the bootloader I do the following for jumping to main program:
halInit(); // init my hal functions
chSysInit(); // init my OS
chThdSleepMilliseconds(1000);
flashInit(); // init the spifi driver
uint32_t NewAddressOfNewVectorTable = 0x14000000;
__disable_irq();
/** Load new Vector Table **/
SCB->VTOR = AddressOfNewVectorTable;
__set_MSP(*(uint32_t*)(AddressOfNewVectorTable));
LPC_CREG->M4MEMMAP = AddressOfNewVectorTable;
/**
* Jump to Reset Vector of new Vector Table
* -> thats the second word (hence fourth byte).
*/
((user_code_pointer_t)(*((uint32_t*)(AddressOfNewVectorTable + 4))))();
This seems to work alright and it jumps to the 0x14000000 address.
Then when I start to debug with JTAG the app, it will come first in the reset handler.
I firstly had to disable __early_init() for the main app which configures the clocks, this would make all crash.
Is this correct?
Then sometimes I can step through all into the main() function.
But also regularly it crashes after doing the first step with JTAG with the following output:
SEGGER J-Link GDB Server V5.02l Command Line Version
JLinkARM.dll V5.02l (DLL compiled Nov 24 2015 09:36:30)
-----GDB Server start settings-----
GDBInit file: none
GDB Server Listening port: 2331
SWO raw output listening port: 2332
Terminal I/O port: 2333
Accept remote connection: localhost only
Generate logfile: off
Verify download: on
Init regs on start: on
Silent mode: off
Single run mode: on
Target connection timeout: 0 ms
------J-Link related settings------
J-Link Host interface: USB
J-Link script: none
J-Link settings file: none
------Target related settings------
Target device: LPC4357_M4
Target interface: SWD
Target interface speed: 1000kHz
Target endian: little
Connecting to J-Link...
J-Link is connected.
Firmware: J-Link V9 compiled Oct 9 2015 20:34:47
Hardware: V9.30
S/N: 269301849
OEM: SEGGER-EDU
Feature(s): FlashBP, GDB
Checking target voltage...
Target voltage: 3.31 V
Listening on TCP/IP port 2331
Connecting to target...Connected to target
Waiting for GDB connection...Connected to 127.0.0.1
Reading all registers
WARNING: Failed to read memory # address 0x00000000
Target interface speed set to 1000 kHz
Resetting target
Halting target CPU...
...Target halted (PC = 0x1A000140)
R0 = 1A000000, R1 = 1A000000, R2 = 400F1FC0, R3 = 12345678
R4 = 40045000, R5 = 1008000C, R6 = 00000000, R7 = 00000000
R8 = 00000000, R9 = 00000000, R10= 00000000, R11= 00000000
R12= 00000000, R13= 10000200, MSP= 10000200, PSP= 00000000
R14(LR) = 10405B25, R15(PC) = 1A000140
XPSR 41000000, APSR 40000000, EPSR 01000000, IPSR 00000000
CFBP 00000000, CONTROL 00, FAULTMASK 00, BASEPRI 00, PRIMASK 00
Reading all registers
Select auto target interface speed (2000 kHz)
Flash breakpoints enabled
Semi-hosting enabled (Handle on BKPT)
Semihosting I/O set to TELNET Client
SWO disabled succesfully.
SWO enabled succesfully.
Downloading 276 bytes # address 0x14000000 - Verified OK
Downloading 16192 bytes # address 0x14000120 - Verified OK
Downloading 16080 bytes # address 0x14004060 - Verified OK
Downloading 16176 bytes # address 0x14007F30 - Verified OK
Downloading 16064 bytes # address 0x1400BE60 - Verified OK
Downloading 16096 bytes # address 0x1400FD20 - Verified OK
Downloading 16096 bytes # address 0x14013C00 - Verified OK
Downloading 16112 bytes # address 0x14017AE0 - Verified OK
Downloading 8492 bytes # address 0x1401B9D0 - Verified OK
Downloading 8 bytes # address 0x1401DAFC - Verified OK
Downloading 2308 bytes # address 0x1401DB08 - Verified OK
Comparing flash [....................] Done.
Verifying flash [....................] Done.
Writing register (PC = 0x14000120)
Read 4 bytes # address 0x14000120 (Data = 0x4100F081)
Read 2 bytes # address 0x14015764 (Data = 0x2300)
Read 2 bytes # address 0x140157C8 (Data = 0x2300)
Read 2 bytes # address 0x140166D8 (Data = 0x2300)
Read 2 bytes # address 0x140166DC (Data = 0x4818)
Read 2 bytes # address 0x14001370 (Data = 0xB672)
Read 2 bytes # address 0x140013E8 (Data = 0xF015)
Read 2 bytes # address 0x140166D8 (Data = 0x2300)
Read 2 bytes # address 0x1401670E (Data = 0xAB03)
Read 2 bytes # address 0x14001370 (Data = 0xB672)
Read 2 bytes # address 0x14001370 (Data = 0xB672)
Read 2 bytes # address 0x14016764 (Data = 0xF7EC)
Read 2 bytes # address 0x14016764 (Data = 0xF7EC)
Read 2 bytes # address 0x14001370 (Data = 0xB672)
Read 2 bytes # address 0x140013D4 (Data = 0xF7FF)
Read 2 bytes # address 0x14015764 (Data = 0x2300)
Read 2 bytes # address 0x140157BA (Data = 0x4850)
Read 2 bytes # address 0x1400ACB8 (Data = 0x4806)
Read 2 bytes # address 0x1400ACBA (Data = 0x4907)
Read 2 bytes # address 0x1400ACC4 (Data = 0x4B05)
Resetting target
Halting target CPU...
...Target halted (PC = 0x1A000140)
Read 2 bytes # address 0x14016764 (Data = 0xF7EC)
Read 2 bytes # address 0x14016764 (Data = 0xF7EC)
Read 2 bytes # address 0x14016764 (Data = 0xF7EC)
R0 = 1A000000, R1 = 1A000000, R2 = 400F1FC0, R3 = 12345678
R4 = 40045000, R5 = 1008000C, R6 = 00000000, R7 = 00000000
R8 = 00000000, R9 = 00000000, R10= 00000000, R11= 00000000
R12= 00000000, R13= 10000200, MSP= 10000200, PSP= 00000000
R14(LR) = 10405B25, R15(PC) = 1A000140
XPSR 41000000, APSR 40000000, EPSR 01000000, IPSR 00000000
CFBP 00000000, CONTROL 00, FAULTMASK 00, BASEPRI 00, PRIMASK 00
Reading all registers
Read 4 bytes # address 0x1A000140 (Data = 0x4C24B672)
Setting breakpoint # address 0x14001370, Size = 2, BPHandle = 0x0001
Setting breakpoint # address 0x140013D4, Size = 2, BPHandle = 0x0002
Setting breakpoint # address 0x140013E8, Size = 2, BPHandle = 0x0003
Setting breakpoint # address 0x1400ACC4, Size = 2, BPHandle = 0x0004
Setting breakpoint # address 0x140166DC, Size = 2, BPHandle = 0x0005
Setting breakpoint # address 0x1401670E, Size = 2, BPHandle = 0x0006
Setting breakpoint # address 0x14016764, Size = 2, BPHandle = 0x0007
Starting target CPU...
Erasing flash [....................] Done.
Programming flash [....................] Done.
Verifying flash [....................] Done.
...Breakpoint reached # address 0x14001370
Reading all registers
Removing breakpoint # address 0x14001370, Size = 2
Removing breakpoint # address 0x140013D4, Size = 2
Removing breakpoint # address 0x140013E8, Size = 2
Removing breakpoint # address 0x1400ACC4, Size = 2
Removing breakpoint # address 0x140166DC, Size = 2
Removing breakpoint # address 0x1401670E, Size = 2
Removing breakpoint # address 0x14016764, Size = 2
Read 4 bytes # address 0x14001370 (Data = 0x4C23B672)
Read 4 bytes # address 0x1A0025B4 (Data = 0xF8D39B03)
Read 4 bytes # address 0x1A0025B4 (Data = 0xF8D39B03)
Performing single step...
...Target halted (PC = 0xFFFFFFFE)
Reading all registers
WARNING: Failed to read memory # address 0xFFFFFFFE
Read 4 bytes # address 0x1000041C (Data = 0x00000000)
Reading 64 bytes # address 0x10000400
Read 4 bytes # address 0x00000000 (Data = 0x10000400)
Read 4 bytes # address 0x00000000 (Data = 0x10000400)
Am I missing something that is needed after the jump to external flash?
Or can anyone give me a pointer why this is not functioning properly all the time?
I'm attempting to send a scsi ReadCapacity16 (0x9E) to a volume on Windows using D. The CDBs are to spec and my ReadCapacity16 works on Linux and scsi Inquiries work on Windows. Only the not-inquiry calls on Windows fail to work with an "incorrect function" from the windows kernel.
Since only inquiries work, is there a trick to sending not-inquiries through the Windows kernel? Any tips on getting this to work? I've researched a couple weeks and haven't solved this.
This is an example of the CDB:
\\.\physicaldrive0
CDB buffer contents:
9e 10 00 00 00 00 00 00 - 00 00 00 00 00 20 00 00
sgio.exceptions.IoctlFailException#sgio\exceptions.d(13): ioctl error code is 1. Incorrect function.
Here is where the CDB is copied to a buffer for the DeviceIoControl call, and this is the same code path which successfully sends the Inquiry commands (but fails for readcap). Code in github pasted below:
void sgio_execute(ubyte[] cdb_buf, ubyte[] dataout_buf, ubyte[] datain_buf, ubyte[] sense_buf)
version (Windows)
{
const uint SENSE_LENGTH = 196;
ubyte[512] iobuffer = 0;
DWORD amountTransferred = -1;
SCSI_PASS_THROUGH_DIRECT scsiPassThrough = {0};
scsiPassThrough.Cdb[] = 0;
uint size = cast(uint)((cdb_buf.length <= scsiPassThrough.Cdb.length ?
cdb_buf.length : scsiPassThrough.Cdb.length));
scsiPassThrough.Cdb[0..size] = cdb_buf[0..size];
scsiPassThrough.Length = SCSI_PASS_THROUGH_DIRECT.sizeof;
scsiPassThrough.ScsiStatus = 0x00;
scsiPassThrough.TimeOutValue = 0x40;
scsiPassThrough.CdbLength = cast(ubyte)(size);
scsiPassThrough.SenseInfoOffset = SCSI_PASS_THROUGH_DIRECT.sizeof;
scsiPassThrough.SenseInfoLength = SENSE_LENGTH;
scsiPassThrough.DataIn = SCSI_IOCTL_DATA_IN;
scsiPassThrough.DataBuffer = datain_buf.ptr;
scsiPassThrough.DataTransferLength = bigEndianToNative!ushort(cast(ubyte[2]) cdb_buf[3..5]);
int status = DeviceIoControl( m_device,
IOCTL_SCSI_PASS_THROUGH_DIRECT,
&scsiPassThrough,
iobuffer.length, //scsiPassThrough.sizeof,
&iobuffer,
iobuffer.length,
&amountTransferred,
null);
if (status == 0)
{
int errorCode = GetLastError();
// build error message ...
throw new IoctlFailException(exceptionMessage);
}
}
}
Reading the Windows SCSI_PASS_THROUGH_DIRECT structure documentation very closely I noticed this:
DataTransferLength: Indicates the size in bytes of the data buffer.
Many devices transfer chunks of data of predefined length. The value
in DataTransferLength must be an integral multiple of this predefined,
minimum length that is specified by the device. If an underrun occurs,
the miniport driver must update this member to the number of bytes
actually transferred.
I changed the code to use 512 bytes for DataTransferLength, by increasing the size of datain_buffer, and the code now works just fine.
I'm trying to create my own library for the ENC28J60. Yes, I know that there are several ready to use libraries out there, but I like to do thing from scratch, so I understand what is going on, how it works.
So, I'm only at the beging and already found someting that I don't understand.
My first test was to send the RCR command to read BANK0. I've recived mixed results.
Over UART(HyperTerminal) I'm getting the following results back:
USART Ready
SPI Ready
1 RCR-ERDPTL Send: 0 "(sending RCR|ERDPTL = 0 over SPI)"
0 11111010 11111010 OK
1 101 101 OK
2 0 0 OK
3 0 0 OK
4 0 0 OK
5 0 0 OK
6 0 0 OK
7 0 0 OK
8 1000 11111010 ERROR
9 101 101 OK
10 11111111 11111111 OK
11 11111 11111 OK
12 110001 11111010 ERROR
13 110011 101 ERROR
14 0 0 OK
15 0 0 OK
The first column is the byte number or the number of the register of BANK0,
The second column is the value that I'm getting from the ENC chip(according to the datasheet),
The third is tha value I should get,
And the fouth is just a simple check to find a mismatch.
As you can see there are 3 values that do not correspond with the datasheet.
Why?
My code is the following:
#include <define.h>
#include <ENC28J60.h>
#define ENC28J60 PB3
#define ENC28J61 PB4
#define DUMMY 0x00
unsigned char i, data, data0[] = {}, data1[] = {}, data2[] = {},
data3[16] = {0b11111010, 0b00000101, 0,0,0,0,0,0,0b11111010,0b00000101,255,0b00011111,0b11111010,0b00000101,0,0};
void ENC28J60_CS(void) // ENC28J60 Select
{
SPI_PORT &= ~(1<<ENC28J60);
}
void ENC28J60_DS(void) // ENC28J60 DeSelect
{
SPI_PORT |= (1<<ENC28J60);
}
void ENC28J61_CS(void) // ENC28J60 Select
{
SPI_PORT &= ~(1<<ENC28J61);
}
void ENC28J61_DS(void) // ENC28J60 DeSelect
{
SPI_PORT |= (1<<ENC28J61);
}
void ENC28J60_SRC(void) // System Reset Command (Soft Reset)
{
ENC28J60_CS(); // Enable
SPIWR(0xFF);
ENC28J60_DS(); // Disable
_delay_ms(50);
}
int main(void)
{
_delay_ms(3000);
USART0_Init(12);
USART0_TX_String("USART Ready");
USART0_TXD(10);
USART0_TXD(13);
SPI_Init();
PORTB ^= 1<<PINB0;
USART0_TX_String("SPI Ready");
USART0_TXD(10);
USART0_TXD(13);
ENC28J60_DS();
ENC28J61_DS();
_delay_ms(250);
ENC28J60_SRC();
ENC28J61_CS(); // Enable
SPIWR(0xFF);
ENC28J61_DS(); // Disable
_delay_ms(250);
ENC28J60_CS();
SPIWR(RCR|ERDPTL);
PORTB ^= 1<<PINB0;
USART0_TX_String("1 RCR-ERDPTL Send: ");
itoa(RCR|ERDPTL, StringA, 10);
USART0_TX_String(StringA);
USART0_TXD(10);
USART0_TXD(13);
data = SPIWRD(0xFF);
for(i = 0;i<15;i++)
{
data0[i] = SPIWRD(0xFF);
}
ENC28J60_DS();
for(i = 0;i<16;i++)
{
PORTB ^= 1<<PINB0;
itoa(i, StringA, 10);
USART0_TX_String(StringA);
USART0_TXD(9);
itoa(data0[i], StringA, 2);
USART0_TX_String(StringA);
USART0_TXD(9);
USART0_TXD(9);
itoa(data3[i], StringA, 2);
USART0_TX_String(StringA);
USART0_TXD(9);
if(data0[i] == data3[i])
{
USART0_TX_String("OK");
}
else
{
USART0_TX_String("ERROR");
}
USART0_TXD(10);
USART0_TXD(13);
}
PORTB |= 1<<PINB0;
while(1)
{
}
}
There is another matter that gives me headaches.
I ha to add an extra SPI junk transmission on line 71, because if I had not done this, I would get the first result twice and so the rest would get out of line.
According to the datasheet(section 4.2.1) only by reading from the MAC or MII registers should I get a dummy byte.
What's up whit that?
I'm using AVR ATMega1284P with WinAVR.
It seems the problem is yet again in the code.
In the declaration of my variables(data0 to 2) I have not set the size of them:
unsigned char i, data, data0[] = {}, data1[] = {}, data2[] = {},
data3[16] = {0b11111010, 0b00000101,0,0,0,0,0,0,0b11111010,0b00000101,
255,0b00011111,0b11111010,0b00000101,0,0};
I should have done this:
unsigned char i, data, data0[16] = {}, data1[16] = {}, data2[16] = {},
data3[16] = {0b11111010, 0b00000101, 0,0,0,0,0,0,0b11111010,0b00000101,
255,0b00011111,0b11111010,0b00000101,0,0};
I'm trying to batch convert images to binary strings for use in Adobe ExtendScript Panels. The result I'm want to get is a String that looks like this:
\u0089PNG\r\n\x1A\n\x00\x00\x00\rIHDR\x00\x00\x00\x0F\x00\x00\x00\x0F\b\x06\x00\x00\x00;\u00D6\u0095J\x00\x00\x00IIDAT(\u0091c`\x18~ --\u00ED?\x0E\u00BC\u009F\x18\u00CD\r8p\x026\u00C5\x06#\u00EC#\x046 \u00C5\u0099\u0084\u009D\r\x14,\u00C0\u00E3T\u00FC\u00CE&\u00C1\x10\u00BC\u009AIw6\u0092f\u00D2\x02\f\u00E4\x14\"\u00FD\u008B\u00E9l\u0090S(\nm\u00BA\x02\x00\u009Dp\u00B2N\u00F1d\x1D\u00FD\x00\x00\x00\x00IEND\u00AEB`\u0082
But my code generates this:
c289 504e 470d 1a0d 0000 000d 4948 4452
0000 000f 0000 000f 0806 0000 003b c396
c295 4a00 0000 4949 4441 5428 c291 6360
187e 202d 2dc3 ad3f 0ec2 bcc2 9f18 c38d
0d38 7002 36c3 8506 40c3 ac40 0436 20c3
85c2 99c2 84c2 9d0d 142c c380 c3a3 54c3
bcc3 8e26 c381 10c2 bcc2 9a49 7736 c292
66c3 9202 0cc3 a414 22c3 bdc2 8bc3 a96c
c290 5328 0d6d c2ba 0200 c29d 70c2 b24e
c3b1 641d c3bd 0000 0000 4945 4e44 c2ae
4260 c282
What do I have to do to get soemthing like the first string? This is my code (adobe extendscript). If somebody has a solution in a different language I would also take it.
var allImages = loadFiles("*.png");// load files is my own function
if(allImages == null) return;
var folder = allImages[0].parent;
for(var i = 0; i < allImages.length;i++){
var curfile = File (allImages[i]);
curfile.open ('r');
curfile.encoding = 'BINARY';
var str = curfile.read();
curfile.close();
var newfile = new File (folder.fsName + '/' + curfile.name + '.txt');
newfile.open('w');
newfile.encoding = 'UTF-8';
newfile.write(str);
newfile.close();
} // end loop i
Maybe you should the image convert it to Base64.
Here are two threads here on stackoverflow about that option. At both I find the second answer more interesting.
How can you encode to Base64 using Javascript?
JSON encode/decode base64 encode/decode in JavaScript
I just have to write the file content toSource().
var allImages = loadFiles("*.png");// load files is my own function
if(allImages == null) return;
var folder = allImages[0].parent;
for(var i = 0; i < allImages.length;i++){
var curfile = File (allImages[i]);
curfile.open ('r');
curfile.encoding = 'BINARY';
var str = curfile.read();
curfile.close();
var newfile = new File (folder.fsName + '/' + curfile.name + '.txt');
newfile.open('w');
newfile.encoding = 'UTF-8';
newfile.write(str.Source()); // <-- Thats the trick
newfile.close();
} // end loop i
This will result in a file with this content.
(new String("\u0089PNG\r\n\x1A\n\x00\x00\x00\rIHDR\x00\x00\x00\x1E\x00\x00\x00\x19\b\x06\x00\x00\x00&5\u009E\x1A\x00\x00\x00\u008DIDATx\u00DA\u00ED\u00D2\u00BB\r\u00C0 \fE\u00D1\f\u00C9\x00\u00B4H\u00F44\x14)\u00A0\u00A0\u00A1c\x00f`#Go\x01>r$+\u0091\u008B\u00DB\u00D9\x1C\u00C5\u00CA\u00E5\u009C\u00BB%\x02L\x12)\u00AC\u00B0<\\J\u00A11\u00C6,\u00CC\u0088\u00C1?8u\u00CE\u0099j\u00AD'a\u0087\x0F\u00F7\u00DEq\u00C6\u0093\u00B0\u00C3\u0087C\b\x14c<\t;k\u00D8\x18C;Yk\u00C9{?\r3\u009B\u00EF\u00ED\u00C3)\u00A5\u00D5\u00891\u00F3:\u008C/\u00C2\u00C3\u00B30\u00C3\u0084\u00F9\u00F1\u00E1\u00D6\u00DA\u00E9_\u008D\u009D\u00AF\u00C1\u00FC\x14VX\x0E~\x00i\u0096r%\u00B0\u00FF\x1E\x14\x00\x00\x00\x00IEND\u00AEB`\u0082"))