Open ReimuNotMoe opened 3 years ago
Does execute with sudo
help?
Does execute with
sudo
help?
I'm using the root account directly. So there shouldn't be any permission-related problems.
I tried the Windows version of NuWriter in VirtualBox VM and it worked.
I noticed the following behavior: When the NUC980 is firstly connected to PC, it will appear as a USB device with no strings at all.
[2505754.777819] usb 3-1.4.1: New USB device found, idVendor=0416, idProduct=5963, bcdDevice= 1.00
[2505754.777825] usb 3-1.4.1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
And after opening the Windows version of NuWriter in VM, the NUC980 disconnected and reconnected with a USB device with Product
and Mfr
strings.
[2505755.315372] usb 3-1.4.1: reset full-speed USB device number 17 using xhci_hcd
[2505771.296785] usb 3-1.4.1: USB disconnect, device number 17
[2505771.475256] usb 3-1.4.1: new full-speed USB device number 18 using xhci_hcd
[2505771.557161] usb 3-1.4.1: not running at top speed; connect to a high speed hub
[2505771.562162] usb 3-1.4.1: New USB device found, idVendor=0416, idProduct=5963, bcdDevice= 1.00
[2505771.562170] usb 3-1.4.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[2505771.562174] usb 3-1.4.1: Product: Nuvoton ARM
[2505771.562177] usb 3-1.4.1: Manufacturer: USB Dev
I guess this is a necessary step before actually flashing the image. However, I haven't observed this behavior when running the Linux version of NuWriter. This may be the problem.
I guess this is a necessary step before actually flashing the image. However, I haven't observed this behavior when running the Linux version of NuWriter. This may be the problem.
That's right. The flash stage is performed by xusb.bin. If you unplug/plug USB cable after program failed, can you see the correct USB device using lsusb commnad?
I guess this is a necessary step before actually flashing the image. However, I haven't observed this behavior when running the Linux version of NuWriter. This may be the problem.
That's right. The flash stage is performed by xusb.bin. If you unplug/plug USB cable after program failed, can you see the correct USB device using lsusb commnad?
Yes, I can.
Today I plugged the NUC980 to a different USB Hub (it's a special one made by me and uses the TI TUSB8041 chip, other hubs generally use VIA or GenesysLogic ones), and now the Linux NuWriter can get through the first step. But it still says Failed. I guess it may be a timing problem?
Or it can be caused by the ASMedia USB controller of my motherboard (Gigabyte X399 AORUS PRO, AMD platform), which is known for not correctly detecting some USB U2F/FIDO Keys. But I haven't encountered any difficulties using MCU programmers like STLink and JLink with it in the past. And the Windows NuWriter is working.
Update: I tried it on my laptop with an Intel CPU, and it worked.
So it may have something to do with compatibility of different USB controllers.
Strace logs (two computers are using the same run.ini
and 980uimage
):
USB controllers on my AMD desktop PC (they're actually made by ASMedia):
01:00.0 USB controller [0c03]: Advanced Micro Devices, Inc. [AMD] X399 Series Chipset USB 3.1 xHCI Controller [1022:43ba] (rev 02)
0a:00.3 USB controller [0c03]: Advanced Micro Devices, Inc. [AMD] USB 3.0 Host controller [1022:145f]
44:00.3 USB controller [0c03]: Advanced Micro Devices, Inc. [AMD] USB 3.0 Host controller [1022:145f]
USB controllers on my Intel laptop:
00:14.0 USB controller [0c03]: Intel Corporation Cannon Lake PCH USB 3.1 xHCI Host Controller [8086:a36d] (rev 10) (prog-if 30 [XHCI])
01:00.2 USB controller [0c03]: NVIDIA Corporation TU116 USB 3.1 Host Controller [10de:1aec] (rev a1) (prog-if 30 [XHCI])
Hi,
We cannot reproduce this problem with our PC. Can you add a delay in nuwriter_cmd/parse.c
and see if it works?
sprintf(XUSB,"%s/%s",NUDATA_PATH,read_xusb_name(nudata.ddr_path));
xbuf=load_xusb(XUSB,&xlen);
MSG_DEBUG("XUSB=%s,len=%d\n",XUSB,xlen);
if(xbuf==NULL) {
printf("Cannot find xusb.bin\n");
ret=-1;
goto EXIT;
}
if(XUSBtoDevice(xbuf,xlen)<0) {
printf("Burn XUSB to Device failed\n");
ret=-1;
goto EXIT;
}
NUC_CloseUsb();
sleep(1); //==========================>Add this line
while(get_device_num_with_vid_pid(ctx,USB_VENDOR_ID, USB_PRODUCT_ID)!=dev_count) {
sleep(1);
}
ret=NUC_OpenUsb();
if(ret<0) return -1;
EXIT:
The problem is actually in function UXmodem_SPINAND
in UXmodem.c
.
The value ack
is always zero.
Do you have an idea of what happened?
I turned on your debug macro and added some prints.
And here are the outputs:
argv[1]=run.ini
id=3,mode=SPINAND
DDR ini = NONE/share/nudata/sys_cfg/NUC980DK61Y.ini
nudata.image_num=1
image0_type=0
image0_path=./980uimage
image0_exe_addr=0x00000000
image0_start_offset=0x00200000
ParsingIni END
(bus 3, device 75)
get count=1
(bus 3, device 75)
usb port is 3.3.1
head.address=0x00000010,head.filelen=368
write 8/8 bytes to device
write 368/368 bytes to device
receive 4/4 bytes from device
receive 4/4 bytes from device
ack=0x55aa55aa
XUSB=NONE/share/nudata/xusb64.bin,len=54376
sizeof(XBINHEAD)=16
passed xbinhead->address=3f00040
file_len=54360
write 8/8 bytes to device
write 4096/4096 bytes to device
receive 4/4 bytes from device
write 4096/4096 bytes to device
receive 4/4 bytes from device
write 4096/4096 bytes to device
receive 4/4 bytes from device
write 4096/4096 bytes to device
receive 4/4 bytes from device
write 4096/4096 bytes to device
receive 4/4 bytes from device
write 4096/4096 bytes to device
receive 4/4 bytes from device
write 4096/4096 bytes to device
receive 4/4 bytes from device
write 4096/4096 bytes to device
receive 4/4 bytes from device
write 4096/4096 bytes to device
receive 4/4 bytes from device
write 4096/4096 bytes to device
receive 4/4 bytes from device
write 4096/4096 bytes to device
receive 4/4 bytes from device
write 4096/4096 bytes to device
receive 4/4 bytes from device
write 4096/4096 bytes to device
receive 4/4 bytes from device
write 1112/1112 bytes to device
receive 4/4 bytes from device
XUSBtoDevice rcnt=1112,ack=1112
(bus 3, device 76)
get count=1
(bus 3, device 76)
usb port is 3.3.1
InfoFromDevice
sizeof(INFO_T) 84 INFO(10)
write 84/84 bytes to device
receive 80/84 bytes from device
receive 4/4 bytes from device
Parsing Run mode
ParseFlashType-SPINAND_M
image0 ./980uimage
write 56/56 bytes to device
receive 4/4 bytes from device
write 4096/4096 bytes to device
receive 4/4 bytes from device
bResult: 0, ack: 0
Failed
The 80/84 mismatch happened here:
Any updates on this?
Do you have other tools to get more information, eg. USB Protocol Analyzer
OS: Debian 10 Kernel: 5.9.10
I tried
mode=SDRAM
andmode=SPINAND
, and none of them worked.Program output:
NUC980 UART output:
Some relevant strace logs: