Author Topic: FNIRSI-1013D "100MHz" tablet oscilloscope  (Read 389185 times)

mleyden, madori and 7 Guests are viewing this topic.

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 3623
  • Country: nl
Re: FNIRSI-1013D "100MHz" tablet oscilloscope
« Reply #600 on: April 10, 2021, 05:29:56 pm »
As I'm walking multiple paths in getting to the bottom of the scope I added some new stuff to the repository. (https://github.com/pecostm32/FNIRSI-1013D-Hack/tree/main/Software%20reverse%20engineering/Analysis)

I'm dissecting the listings into smaller parts and try to make some flow analysis of where the different ports are being controlled. In the 2nd executable I'm looking for interaction with 0x01C20800 which is the address of port A, which is used for handling the touch screen.

In the SPL I'm looking for interaction with 0x01C2086C (port D, display) and 0x01C20890 (port E, FPGA). Also found that 0x01C25000 (UART0) is being used, so maybe it is used to control the FPGA.

I'm fairly certain that FUN_00017D8 is a set pin ctrl function. It is called many times with the port config register addresses.

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 3623
  • Country: nl
Re: FNIRSI-1013D "100MHz" tablet oscilloscope
« Reply #601 on: April 10, 2021, 05:38:18 pm »
Just tried it again with the sdcard.img you uploaded to github, and still no uart on any of the ports (tried uart0 and uart1)... Weird... However, by removing the sd card the oscilloscope boots normally, so it's not broken.

I also tried flashing the card with Win32DiskImager and with dd from Linux, same result. Very strange.

Indeed strange. I used a small (128MB) micro sd card, and within the scope it boots to linux without problems. When I insert the sd card in my card reader connected to my linux computer it opens two partitions, showing the boot image and the root file system.

Which version of the scope do you have? The one with the 16Mbit flash or the one with the 32Mbit flash?

I can also mount the image file on my linux mint system with the same result. Two partitions. See picture.
« Last Edit: April 10, 2021, 05:46:28 pm by pcprogrammer »
 

Offline iscle

  • Regular Contributor
  • *
  • Posts: 60
  • Country: es
Re: FNIRSI-1013D "100MHz" tablet oscilloscope
« Reply #602 on: April 10, 2021, 06:16:36 pm »
Just tried it again with the sdcard.img you uploaded to github, and still no uart on any of the ports (tried uart0 and uart1)... Weird... However, by removing the sd card the oscilloscope boots normally, so it's not broken.

I also tried flashing the card with Win32DiskImager and with dd from Linux, same result. Very strange.

Indeed strange. I used a small (128MB) micro sd card, and within the scope it boots to linux without problems. When I insert the sd card in my card reader connected to my linux computer it opens two partitions, showing the boot image and the root file system.

Which version of the scope do you have? The one with the 16Mbit flash or the one with the 32Mbit flash?

I can also mount the image file on my linux mint system with the same result. Two partitions. See picture.

Yep I can mount the partitions too on Ubuntu. I tried using a 2GB SD card which booted U-Boot at one point in time, and also the one that came with the scope which is 1GB. Neither of them output anything to UART1.

I have the old version of the scope, with 16Mb flash.

I'm running out of ideas on what could be happening :(
 

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 3623
  • Country: nl
Re: FNIRSI-1013D "100MHz" tablet oscilloscope
« Reply #603 on: April 10, 2021, 07:36:00 pm »
Could there be such a difference between the two versions that it is causing this to happen? I think eljot was able to run his new version with the old 16Mbit firmware so no problem there.

Do you have some pointers on where to look for getting u-boot changed completely to uart1? Besides from the devicetree stuff, because that is what I changed and I can verify by looking at the generated dtb file for the boot section.

I have no idea of how the whole linux system sticks together. As said before it is al new to me.

Do you have another scope to do measurements on the signals?

There is one thing I noticed on the lichee nano with the image. Have to test it again tomorrow, but with the usb to serial adapter connected to uart1 (port a) it did not start into linux directly. After connecting to uart0 and rebooting I got the uboot sequence output and then I could connect to uart1 to get the linux prompt (actualy the password prompt), but not the linux startup messages.
In the scope on the other hand I do see the linux startup messages on uart1 and it runs to the login as prompt. It takes a bit of time before it spits out messages, which I have to measure to see how long it actually is.

Will update on this tomorrow

« Last Edit: April 10, 2021, 07:46:24 pm by pcprogrammer »
 

Offline tv84

  • Super Contributor
  • ***
  • Posts: 3212
  • Country: pt
Re: FNIRSI-1013D "100MHz" tablet oscilloscope
« Reply #604 on: April 10, 2021, 08:03:10 pm »
@pcprogrammer, are you doing the analysis in ASM??!?

Why don't you do the analysis in pseudo-C?

Code: [Select]
int sub_800167A0()
{
  sub_8001764C(0x1C20890, 0, 0);
  sub_8001764C(0x1C20890, 1u, 0);
  sub_8001764C(0x1C20890, 2u, 0);
  sub_8001764C(0x1C20890, 3u, 0);
  sub_8001764C(0x1C20890, 4u, 0);
  sub_8001764C(0x1C20890, 5u, 0);
  sub_8001764C(0x1C20890, 6u, 0);
  return sub_8001764C(0x1C20890, 7u, 0);
}

int __fastcall sub_800168FC(unsigned __int8 a1)
{
  unsigned __int8 v1; // r4@1

  v1 = a1;
  sub_8001764C(0x1C20890, 0, 1);
  sub_8001764C(0x1C20890, 1u, 1);
  sub_8001764C(0x1C20890, 2u, 1);
  sub_8001764C(0x1C20890, 3u, 1);
  sub_8001764C(0x1C20890, 4u, 1);
  sub_8001764C(0x1C20890, 5u, 1);
  sub_8001764C(0x1C20890, 6u, 1);
  sub_8001764C(0x1C20890, 7u, 1);
  sub_8001774C(0x1C20890, 9);
  sub_80017738(0x1C20890, 10);
  v1C208A0 = v1 | v1C208A0 & 0xFFFFFF00;
  sub_80017738(0x1C20890, 8);
  return sub_8001774C(0x1C20890, 8);
}
 

Offline iscle

  • Regular Contributor
  • *
  • Posts: 60
  • Country: es
Re: FNIRSI-1013D "100MHz" tablet oscilloscope
« Reply #605 on: April 10, 2021, 08:05:39 pm »
Interesting.

I do have some linux experience. Maybe the issue you're having with U-boot is that the code to enable UART1 has not been added (port configuration, multiplexer config, etc). I'll take a look and see if I can get it to output on UART1 and work from there. I'm tired of soldering the FPGA pins with wirewrap just to get the U-boot uart :P

I have managed to boot u-boot again, both for your image, my image and a licheepi nano image, but no linux seen at the moment.

We'll manage to do it, I'm sure!
 

Offline tv84

  • Super Contributor
  • ***
  • Posts: 3212
  • Country: pt
Re: FNIRSI-1013D "100MHz" tablet oscilloscope
« Reply #606 on: April 10, 2021, 08:32:18 pm »
Here is the dump of ST 25P16VP... (this is FPGA stream data and connected to dedicated FPGA pins)
I don't think that it is useful for anyone, just let it be for history...
I2C I guess for store settings.
https://mega.nz/file/MGY3FI5b#wURGvOJB9Zb6dqilI2w5TRbJWrP3fHHG5muqNXtb-r4

Below is the output of my crude parser of this FPGA flashing file (just the basic envelope):

Code: [Select]
WARNING: the .RBF file has the bytes bit-reversed!  Reversing...
FPGA - RBF/RPD (Raw Binary File) - Filesize: 16 777 216 bits (00200000 bytes)
00000000 - Start of File  (Type 1)

         [00000048                      00000021]
Bit 7  - 1111111111111111111111111111111111111111       FFFFFFFFFF
Bit 6  - 1111111111111111111111111111111111111111       FFFFFFFFFF
Bit 5  - 1111111111111111111111111111111111111111       FFFFFFFFFF
Bit 4  - 1111111111111111111111111111111111111111       FFFFFFFFFF
Bit 3  - 1111111111111111111111111110111010000000       FFFFFFEE80
Bit 2  - 0000011100110011001011111000000000111111       07332F803F
Bit 1  - 1100000000000111100011000000010111111111       C0078C05FF
Bit 0  - 0000000000010101000100010110110111111111       0015116DFF
Bits 0080 - EPCS/EPCQ ID check: Enabled
Bits 005F - Stream size: 943 711 bits  (0001CCCC bytes)  Compression Bit ON  (+1)       Size NOT OK
Bits 0056 - 0000 0000 : 0x56-0x5D
Bits 004C - Programming Mode: Active Serial (AS x1)
Bits 003B - IDCode (Version+Part Number only): 0x020F1  (-> 0x024F1)
Bits 0008 - Usercode: 0015116D
00000049 - Header CRC-16_MODBUS: 0033  [00000021-00000048]        CRC OK
0000004B - Data Framesize: 207  [0000004B-000000F1]
000000F2 - 4-byte words: 1260  [000000F2-000014A1]
00000000 - Stream Size (Uncompressed): 15 610 872 bits
000014A2 - CRC Framesize: 207+0     # Data Frames: 1727  [000014A2-00059D4F]
Start address: 00000000
00059D50 - Post-device bitstream pad bytes (0xFF): 1583407  [00059D50-001DC67E]
File Checksum: 1E469589


Reversing the programming: only in God mode...
 

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 3623
  • Country: nl
Re: FNIRSI-1013D "100MHz" tablet oscilloscope
« Reply #607 on: April 11, 2021, 05:30:14 am »
@pcprogrammer, are you doing the analysis in ASM??!?

Why don't you do the analysis in pseudo-C?

I just started with it, and did not think of a good format just yet. Yours looks like a good idea. It will take its time because it is a lot of work.

And for the fpga, yes that won't be an easy task either, but who knows :D

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 3623
  • Country: nl
Re: FNIRSI-1013D "100MHz" tablet oscilloscope
« Reply #608 on: April 11, 2021, 07:22:21 am »
Interesting.

I do have some linux experience. Maybe the issue you're having with U-boot is that the code to enable UART1 has not been added (port configuration, multiplexer config, etc). I'll take a look and see if I can get it to output on UART1 and work from there. I'm tired of soldering the FPGA pins with wirewrap just to get the U-boot uart :P

I have managed to boot u-boot again, both for your image, my image and a licheepi nano image, but no linux seen at the moment.

We'll manage to do it, I'm sure!

It is interesting indeed, and strange.

I did some tests with the lichee nano and when uart0 RX (PE0) is left floating it will not boot. Tried it several times with constant results. When I pull it down to ground via 2K2 resistor it works. Takes about 4 seconds before it comes with the linux messages via uart1.

Decided to put some more wires and a level converter into action to connect both ports. This way I can see the u-boot startup on uart0 and then the linux startup on uart1.

The image with u-boot on uart1 still does not start beyond the first three lines it sends to uart0.
« Last Edit: April 11, 2021, 07:38:30 am by pcprogrammer »
 

Offline tv84

  • Super Contributor
  • ***
  • Posts: 3212
  • Country: pt
Re: FNIRSI-1013D "100MHz" tablet oscilloscope
« Reply #609 on: April 11, 2021, 07:47:24 am »
We'll manage to do it, I'm sure!

I would also be interested in understanding this uart part because this absence of output is present in the majority of equipments around here.

If you have any hints that deserve analysis tell me, maybe I can help.
 

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 3623
  • Country: nl
Re: FNIRSI-1013D "100MHz" tablet oscilloscope
« Reply #610 on: April 11, 2021, 09:10:57 am »
I added the image with u-boot on uart1 that fails in the repository. Also added the tar.gz of the uboot source I used and changed. (https://github.com/pecostm32/FNIRSI-1013D-Hack/tree/main/Linux/changed%20packages/Using%20uart1%20(uboot%20fail))

The linux tar.gz is to big (159MiB) and has to many files to get it in the repository. The only changes I made are the files described in an earlier post and these are in the repository.

So tv84 maybe you can take a look at the uboot and figure out where it uses uart0 to output the first three lines, and why it won't continue after that.

Today I'm going to try to check what ser8989 pointed out about the GT911 coordinates reversal via the sensors. Thought is to capture the I2C from the scope with a STM32 and do the conversion there and forward the data to the touch screen. All other data needs to be passed through directly. It is not intended as a solution but as a proof of concept :) All part of the hobby.

Offline tv84

  • Super Contributor
  • ***
  • Posts: 3212
  • Country: pt
Re: FNIRSI-1013D "100MHz" tablet oscilloscope
« Reply #611 on: April 11, 2021, 10:05:56 am »
I added the image with u-boot on uart1 that fails in the repository. Also added the tar.gz of the uboot source I used and changed. (https://github.com/pecostm32/FNIRSI-1013D-Hack/tree/main/Linux/changed%20packages/Using%20uart1%20(uboot%20fail))

Correct link.
« Last Edit: April 11, 2021, 10:21:18 am by tv84 »
 

Offline tv84

  • Super Contributor
  • ***
  • Posts: 3212
  • Country: pt
Re: FNIRSI-1013D "100MHz" tablet oscilloscope
« Reply #612 on: April 11, 2021, 10:22:35 am »
Do the UART (tx, rx) lines go through the FPGA?
 

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 3623
  • Country: nl
Re: FNIRSI-1013D "100MHz" tablet oscilloscope
« Reply #613 on: April 11, 2021, 10:28:17 am »
In the scope the uart0 lines are connected to the fpga, but they don't come out of it. The uart1 lines are connected to the touch panel (bit banged I2C) I did not connect to uart0 (iscle did) and for uart1 I disconnected the touch panel and used a 6pin 0.5mm fpc breakout board (found here: https://nl.aliexpress.com/item/4000099171451.html?spm=a2g0s.9042311.0.0.27424c4dBdVfUz)

On the lichee nano both uarts are connected to io pins and can easily be connected to usb serial adapters.

Offline tv84

  • Super Contributor
  • ***
  • Posts: 3212
  • Country: pt
Re: FNIRSI-1013D "100MHz" tablet oscilloscope
« Reply #614 on: April 11, 2021, 10:31:18 am »
Is it possible for the FPGA to ground the lines, disabling the output?
 

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 3623
  • Country: nl
Re: FNIRSI-1013D "100MHz" tablet oscilloscope
« Reply #615 on: April 11, 2021, 10:52:12 am »
I measured the lines in my scope with my MSO5074 while booting the linux and they go up and down, but it did not look like normal serial where the signals are high and go low for transmission. Might be that in the new version of the scope the RX line is held low at the right moment to allow u-boot to start.

The schematics I made of the scope are also in the repository, so all the connections are in there. Only the capacitors are mostly wrong, since they are not marked and it is hard to measure them in circuit.
« Last Edit: April 11, 2021, 11:00:31 am by pcprogrammer »
 

Offline iscle

  • Regular Contributor
  • *
  • Posts: 60
  • Country: es
Re: FNIRSI-1013D "100MHz" tablet oscilloscope
« Reply #616 on: April 11, 2021, 11:30:55 am »
Quick update before I go to eat. I can give a more detailed reply later during the evening.

The u-boot souce code is indeed not prepared for output on UART1. The following link shows how the pin configuration is only available for UART0:
https://github.com/Lichee-Pi/u-boot/blob/013ca457fd64b72444a0f5f480b1bbdd8b7481eb/arch/arm/mach-sunxi/board.c#L86
(this is only pin multiplexer configuration, it won't enable uart1 output even if configured for port A)

Also, in order to get the backlight working under linux, what I do is boot the scope without an SD card inserted, then when it powers up the backlight, I insert the SD card and reset the CPU by pulling the reset pin to GND briefly. This will keep the backlight on, and I think that the FPGA pins are kept high-z because it did not finish initializing it.

Also, thanks for pointing out that u-boot will hang when the RX pin is left floating. This makes sense because the way UART works is having a pull-up by the transmitter, and if the receiver is left open then it might be seeing junk and stopping the boot process. Can you try pulling it to 3.3v instead of GND?
 

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 3623
  • Country: nl
Re: FNIRSI-1013D "100MHz" tablet oscilloscope
« Reply #617 on: April 11, 2021, 12:23:16 pm »
Yes, you are right. The RX pin has to be stable and wether it is high or low that does not matter. Come to think of it this is logical, because when the usb to serial adapter is turned on it will be on a high level too. When it is off the level will be low, and this is how I initially tested it.

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 3623
  • Country: nl
Re: FNIRSI-1013D "100MHz" tablet oscilloscope
« Reply #618 on: April 11, 2021, 01:08:32 pm »
The u-boot souce code is indeed not prepared for output on UART1. The following link shows how the pin configuration is only available for UART0:
https://github.com/Lichee-Pi/u-boot/blob/013ca457fd64b72444a0f5f480b1bbdd8b7481eb/arch/arm/mach-sunxi/board.c#L86
(this is only pin multiplexer configuration, it won't enable uart1 output even if configured for port A)

Also, in order to get the backlight working under linux, what I do is boot the scope without an SD card inserted, then when it powers up the backlight, I insert the SD card and reset the CPU by pulling the reset pin to GND briefly. This will keep the backlight on, and I think that the FPGA pins are kept high-z because it did not finish initializing it.

Thanks for the pointer. I made some modifications to the u-boot stuff and started a new build. Fingers crossed :popcorn: and see what happens.

Got an error in building u-boot. Needed to edit one more file. Got a new image, so on the the test bench :-DMM

Succes!!!!! :-DD
The lichee nano starts with everything via uart1, even with uart0 rx floating. Next step is testing in the scope. (But that has to wait till after dinner)


Resetting the MCU in the new version is a bit tricky. There is no neat pcb pad like in the old version, but a tiny smd resistor to touch with a wire. I will give it a try if the new build works.
« Last Edit: April 11, 2021, 02:01:05 pm by pcprogrammer »
 

Offline iscle

  • Regular Contributor
  • *
  • Posts: 60
  • Country: es
Re: FNIRSI-1013D "100MHz" tablet oscilloscope
« Reply #619 on: April 11, 2021, 02:11:14 pm »
Awesome! What modifications did you end up doing?

If you can upload the sdcard.img, I'll test it
 

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 3623
  • Country: nl
Re: FNIRSI-1013D "100MHz" tablet oscilloscope
« Reply #620 on: April 11, 2021, 03:11:08 pm »
Hmm, it works in the scope, but was not able to use the reset trick. When I pull reset low it freezes the display in a weird pattern, waits for a while and starts in scope mode again. So no telling if the display works, because of no back-light.

The image is in the repository (https://github.com/pecostm32/FNIRSI-1013D-Hack/tree/main/Linux/images/lichee_nano_both_uart1) as is the changed u-boot package
(https://github.com/pecostm32/FNIRSI-1013D-Hack/tree/main/Linux/changed%20packages/Using%20uart1)

I had to change four files to get the uart1 in there:

1) /uboot-nano-v2018.01/arch/arm/mach-sunxi/board.c
Added:
#elif CONFIG_CONS_INDEX == 2 && defined(CONFIG_MACH_SUNIV)
   sunxi_gpio_set_cfgpin(SUNXI_GPA(2), SUNIV_GPA_UART1);
   sunxi_gpio_set_cfgpin(SUNXI_GPA(3), SUNIV_GPA_UART1);
   sunxi_gpio_set_pull(SUNXI_GPA(3), SUNXI_GPIO_PULL_UP);

2) /uboot-nano-v2018.01/include/asm/arch-sunxi/gpio.h
Added:
#define SUNIV_GPA_UART1      5

3) /uboot-nano-v2018.01/include/configs/sunxi-common.h
Added:
#elif CONFIG_CONS_INDEX == 2 && defined(CONFIG_MACH_SUNIV)
#define OF_STDOUT_PATH      "/soc@01c00000/serial@01c25400:115200"

4) /uboot-nano-v2018.01/configs/lichee_nano_defconfig
Added:
CONFIG_CONS_INDEX=2


« Last Edit: April 11, 2021, 03:14:29 pm by pcprogrammer »
 
The following users thanked this post: iscle

Offline iscle

  • Regular Contributor
  • *
  • Posts: 60
  • Country: es
Re: FNIRSI-1013D "100MHz" tablet oscilloscope
« Reply #621 on: April 11, 2021, 03:49:53 pm »
It works!

I'm able to pull the reset trick, however the display is not working. The dts has to be edited to include the proper display timings. Our display is "innolux,at070tn92", already included in the mainline kernel, after setting it in the dts, it *should* work :)
 

Offline tv84

  • Super Contributor
  • ***
  • Posts: 3212
  • Country: pt
Re: FNIRSI-1013D "100MHz" tablet oscilloscope
« Reply #622 on: April 11, 2021, 03:52:31 pm »
Nice job. Can you point me to an image compiled without those changes and one with the changes?
 

Offline iscle

  • Regular Contributor
  • *
  • Posts: 60
  • Country: es
Re: FNIRSI-1013D "100MHz" tablet oscilloscope
« Reply #623 on: April 11, 2021, 03:54:37 pm »
And, we've got image!

 

Offline iscle

  • Regular Contributor
  • *
  • Posts: 60
  • Country: es
Re: FNIRSI-1013D "100MHz" tablet oscilloscope
« Reply #624 on: April 11, 2021, 03:58:05 pm »
Nice job. Can you point me to an image compiled without those changes and one with the changes?

Everything's in this github repository: https://github.com/pecostm32/FNIRSI-1013D-Hack/tree/main/Linux/images/
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf