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

Samsung B310E #9

Open
ms2010gamer opened this issue Nov 5, 2024 · 76 comments
Open

Samsung B310E #9

ms2010gamer opened this issue Nov 5, 2024 · 76 comments

Comments

@ms2010gamer
Copy link

ms2010gamer commented Nov 5, 2024

I have been trying to run doom on my Samsung B310E
I have no idea where to start
everything runs successfully but my samsung is just stuck at a black screen even though
I've done everything right (both Duke3D and Doom)
I'm on linux right now and only used the prebuilt binaries

if you want me to test anything I'd be happy to (running of RAM no sd card)

@ilyakurdyukov
Copy link
Owner

Try running usb/fptest.bin first.

You complain, but you don't give specifics on what stage the problem occurs.

everything runs successfully

Everything - what exactly?

You run some command, you get some output. Something happens, or maybe it doesn't happen. Describe it.

@ms2010gamer
Copy link
Author

ms2010gamer commented Nov 5, 2024

I just ran usb/fptest.bin and the command spd_dump ran successfully but the phone is still just a black screen

command:
./spd_dump --wait 1000000 fdl nor_fdl1.bin 0x40004000 fdl usb/fptest.bin ram

output:

BSL_REP_VER: "SPRD3\0"
BSL_REP_VER: "Custom FDL1: CHIP ID = 0x6530c000\0"

@ilyakurdyukov
Copy link
Owner

Because you need to compile the program from the libc_server folder. And run it after spd_dump.

This is my template script for launching games:

#!/bin/bash

game="test"

run_game() {
	./spd_dump \
		fdl nor_fdl1.bin 0x40004000 \
		fdl fp$game.bin ram
	test $? = 0 && cd workdir && {
		../libc_server -- $@
		cd ..
	}
}

make all && {
	args="$game 123 456 789"
	run_game --bright 50 --charge 2 $args
}

The current directory should contain:

spd_dump - host binary
libc_server - host binary
fptest.bin - binary for phone, compiled for USB mode
workdir - folder, files from which libc_server will transfer to fptest.bin running on the phone.

@ms2010gamer
Copy link
Author

ms2010gamer commented Nov 5, 2024

make: *** No rule to make target 'all'.  Stop.

I had a run_doom.sh and I copied ur commands to it
how can I use ur script? (I never use bash I always use makefile)

@ilyakurdyukov
Copy link
Owner

make all

Makefile is something like this. But you can just manually move the listed files.

.PHONY: all clean

all: spd_dump/spd_dump libc_server/libc_server

clean:
	$(MAKE) -C spd_dump clean
	$(MAKE) -C libc_server clean

spd_dump/spd_dump:
	$(MAKE) -C spd_dump

libc_server/libc_server:
	$(MAKE) -C libc_server

Example script for launching Doom:

#!/bin/bash

game="doom"

run_game() {
	./spd_dump \
		fdl nor_fdl1.bin 0x40004000 \
		fdl fp$game.bin ram
	test $? = 0 && cd workdir && {
		../libc_server -- $@
		cd ..
	}
}

make all && {
	#args="$game -timedemo demo1"
	args="$game"
	run_game --bright 50 --rotate 3 --charge 2 $args
}

You must have a .wad resource file in your workdir that is compatible with vanilla Doom sources. For example doom1.wad from the shareware version.

@ilyakurdyukov
Copy link
Owner

This makefile does not match the script paths. I just have many different script variants around.

The script corresponding to this makefile will be like this:

#!/bin/bash

game="doom"

run_game() {
	spd_dump/spd_dump \
		fdl nor_fdl1.bin 0x40004000 \
		fdl fp$game.bin ram
	test $? = 0 && cd workdir_$game && {
		../libc_server/libc_server -- $@
		cd ..
	}
}

make && {
	args="$game"
	run_game --bright 50 --rotate 3 --charge 2 $args
}

@ms2010gamer
Copy link
Author

ms2010gamer commented Nov 5, 2024

running this (without make cuz it not work messed up directories)

#!/bin/bash

game="doom"

run_game() {
	./spd_dump \
		fdl nor_fdl1.bin 0x40004000 \
		fdl fp$game.bin ram
	test $? = 0 && cd workdir && {
		../libc_server -- $@
		cd ..
	}
}

args="$game 123 456 789"
run_game --bright 50 --charge 2 $args

and this time I would get this:

Waiting for connection (300s)
BSL_REP_VER: "SPRD3\0"
BSL_REP_VER: "Custom FDL1: CHIP ID = 0x6530c000\0"
timeout reached

note: I have the shareware doom1.wad in my workdir ;)

@ilyakurdyukov
Copy link
Owner

This is strange, the "timeout reached" message can only be output by spd_dump, so libc_server doesn't even start.

@ilyakurdyukov
Copy link
Owner

Add --verbose 2 to the spd_dump call:

./spd_dump --verbose 2 \

Don't put all the output (there will be a lot) in the response, just the last lines.

If everything is correct it should end like this:

recv (8):
7e 00 80 00 00 ff 7f 7e                          |~......~|
send (8):
7e 00 03 00 00 ff fc 7e                          |~......~|
recv (8):
7e 00 80 00 00 ff 7f 7e                          |~......~|
send (8):
7e 00 04 00 00 ff fb 7e                          |~......~|
recv (8):
7e 00 80 00 00 ff 7f 7e                          |~......~|

@ms2010gamer
Copy link
Author

ms2010gamer commented Nov 5, 2024

actually I did this before (the --verbose 2)
here is the final output:

recv (8):
7e 00 80 00 00 ff 7f 7e                          |~......~|
send (8):
7e 00 03 00 00 ff fc 7e                          |~......~|
recv (8):
7e 00 80 00 00 ff 7f 7e                          |~......~|
send (8):
7e 00 04 00 00 ff fb 7e                          |~......~|
timeout reached

it never did this timeout thing before...

@ilyakurdyukov
Copy link
Owner

send (8):
7e 00 04 00 00 ff fb 7e 

This is:

	BSL_CMD_EXEC_DATA            = 0x04, /* Execute from a certain address */

Means that the game binary is loaded into the phone's RAM and is running, but it is not responding.

Are you sure you are using the USB binary and not the one from the sdcard/fpbin folder?

Try running fptest.bin first.

@ms2010gamer
Copy link
Author

ms2010gamer commented Nov 5, 2024

I have been literally using the sd card one lol
but now we are back to square one... the libc_server works but still a black screen
(usb/fptest.bin)

output:

recv (8):
7e 00 80 00 00 ff 7f 7e                          |~......~|
send (88):
7e 00 02 00 50 82 53 00 00 80 00 82 20 00 00 80  |~...P.S.........|
00 82 21 00 00 80 00 80 22 00 80 00 82 03 10 00  |..!.....".......|
80 02 82 10 00 00 80 02 82 11 00 00 80 02 82 12  |................|
00 00 80 02 82 13 00 00 80 02 82 00 00 00 80 02  |................|
82 01 00 00 80 02 80 02 00 05 70 a3 92 1d f1 97  |..........p.....|
3d 20 90 00 00 98 14 7e                          |=......~|
recv (8):
7e 00 80 00 00 ff 7f 7e                          |~......~|
send (8):
7e 00 03 00 00 ff fc 7e                          |~......~|
recv (8):
7e 00 80 00 00 ff 7f 7e                          |~......~|
send (8):
7e 00 04 00 00 ff fb 7e                          |~......~|
recv (8):
7e 00 80 00 00 ff 7f 7e                          |~......~|
!!! entry
malloc heap: 4147364 bytes
keymap = 0x300cf154
pinmap = 0x300cf1d4
scan_firmware: 461ms
chip_id: num = 0x6530c000
chip_id: ver = 0x90001
chip_id: adi = 0x1130c000
connection closed

@ilyakurdyukov
Copy link
Owner

There were similar problems in issue 8, when the code hung at the start.

On my B310E, the log starts like this and continues:

BSL_REP_VER: "SPRD3\0"
BSL_REP_VER: "Custom FDL1: CHIP ID = 0x6530c000\0"
!!! entry
malloc heap: 4147364 bytes
keymap = 0x300ca3b8
pinmap = 0x300ca438
scan_firmware: 447ms
chip_id: num = 0x6530c000
chip_id: ver = 0x90001
chip_id: adi = 0x1130c000
LCD: clk_rate = 104000000
LCD: id = 0x5ca1f1
argc = 4
[0] = test
[1] = 123
[2] = 456
[3] = 789
362 frames in 1002 ms
1 frame in 2.767 ms
361.277 frames per second

@ilyakurdyukov
Copy link
Owner

Can you compile the fptest binary yourself and put some prints around?

@ms2010gamer
Copy link
Author

I have only made a simple game in C and Raylib
as I said, I have only used the precompiled binaries

@ms2010gamer
Copy link
Author

ms2010gamer commented Nov 5, 2024

should I enable something like SPI?
(enabling that did nothing)

@ilyakurdyukov
Copy link
Owner

Get android-ndk-r26d-linux.zip (same version I'm using) from here:

Extract it anywhere. Create a link to android-ndk-r26d in your home folder.

Now use this script, let's call it build_test.sh, if you put the fpdoom source repository in the current directory, it will build fptest.bin.

#!/bin/bash
NDK=$HOME/android-ndk-r26d
TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm
CLANG=$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi21-clang

cd fpdoom

test -f pack_reloc/pack_reloc || make -C pack_reloc

cd fptest && {
	make clean all TOOLCHAIN=$TOOLCHAIN CC=$CLANG LIBC_SDIO=0 2>&1 | tee ../../build.log
	cp fptest.bin ../..
}

@ms2010gamer
Copy link
Author

ms2010gamer commented Nov 5, 2024

just did that and used the manually compiled fptest.bin and now it's still as before

@ilyakurdyukov
Copy link
Owner

Now to the last messages in the log.

They are from the init_chip_id() function, which completed successfully:

fpdoom/fpdoom/syscode.c

Lines 934 to 946 in 8169157

void sys_init(void) {
init_charger();
init_chip_id();
pin_init();
lcd_init(lcm_init());
lcd_appinit();
lcdc_init();
if (sys_data.keymap_addr) {
keypad_init();
keytrn_init();
}
sys_data.init_done = 1;
}

After that pin_init() is called, probably it's stuck there. Similar to issue 8.

Try making the following changes to syscode.c and recompiling fptest.bin:

#endif
 			MEM4(addr) = val;
 		} else break;
+		DBG_LOG("pinmap_trace: 0x%08x, 0x%08x\n", addr, val);
+		sys_wait_ms(500);
 	}
 	if (sys_data.gpio_init)
 		gpio_init((void*)pinmap);

@ilyakurdyukov
Copy link
Owner

DBG_LOG("pinmap_trace: 0x%08x, 0x%08x\n", addr, val);
sys_wait_ms(500);

This will print out how the CPU pins are initializing. It will wait half a second after each change. So we'll find what was last before the hang.

@ms2010gamer
Copy link
Author

I pressed Ctrl+C thinking it was infinite, sorry will do again and give u result ;)

@ms2010gamer
Copy link
Author

Waiting for connection (300s)
BSL_REP_VER: "SPRD3\0"
BSL_REP_VER: "Custom FDL1: CHIP ID = 0x6530c000\0"
!!! entry
malloc heap: 4147308 bytes
keymap = 0x300cf154
pinmap = 0x300cf1d4
scan_firmware: 462ms
chip_id: num = 0x6530c000
chip_id: ver = 0x90001
chip_id: adi = 0x1130c000
pinmap_trace: 0x8c000000, 0x0001ffff
pinmap_trace: 0x8c000044, 0x00000134
pinmap_trace: 0x8c000048, 0x00000134
pinmap_trace: 0x8c00004c, 0x00000104
pinmap_trace: 0x8c000050, 0x00000104
pinmap_trace: 0x8c000054, 0x00000104
pinmap_trace: 0x8c000058, 0x00000104
pinmap_trace: 0x8c00005c, 0x00000104
pinmap_trace: 0x8c000060, 0x00000104
pinmap_trace: 0x8c000064, 0x00000104
pinmap_trace: 0x8c000068, 0x00000104
pinmap_trace: 0x8c00006c, 0x00000104
pinmap_trace: 0x8c000070, 0x00000104
pinmap_trace: 0x8c000074, 0x00000104
pinmap_trace: 0x8c000078, 0x00000104
pinmap_trace: 0x8c000084, 0x00000140
pinmap_trace: 0x8c000090, 0x00000101
pinmap_trace: 0x8c000098, 0x00000201
pinmap_trace: 0x8c0000a0, 0x00000201
pinmap_trace: 0x8c0000a4, 0x00000101
pinmap_trace: 0x8c0000a8, 0x00000106
pinmap_trace: 0x8c0000ac, 0x00000106
pinmap_trace: 0x8c0000b0, 0x00000106
pinmap_trace: 0x8c0000b4, 0x00000106
pinmap_trace: 0x8c0000b8, 0x00000106
pinmap_trace: 0x8c0000bc, 0x00000106
pinmap_trace: 0x8c0000c0, 0x00000106
pinmap_trace: 0x8c0000c4, 0x00000106
pinmap_trace: 0x8c0000c8, 0x00000106
pinmap_trace: 0x8c0000cc, 0x00000106
pinmap_trace: 0x8c0000d0, 0x00000106
pinmap_trace: 0x8c0000d4, 0x00000106
pinmap_trace: 0x8c0000d8, 0x00000106
pinmap_trace: 0x8c0000dc, 0x00000106
pinmap_trace: 0x8c0000e0, 0x00000106
pinmap_trace: 0x8c0000e4, 0x00000106
pinmap_trace: 0x8c0000e8, 0x00000104
pinmap_trace: 0x8c0000ec, 0x00000104
pinmap_trace: 0x8c0000f0, 0x00000104
pinmap_trace: 0x8c0000f4, 0x00000104
pinmap_trace: 0x8c0000f8, 0x00000104
pinmap_trace: 0x8c0000fc, 0x00000104
pinmap_trace: 0x8c000100, 0x00000104
pinmap_trace: 0x8c000104, 0x00000104
pinmap_trace: 0x8c000108, 0x00000104
pinmap_trace: 0x8c00010c, 0x00000101
pinmap_trace: 0x8c000110, 0x00000101
pinmap_trace: 0x8c00011c, 0x00000101
pinmap_trace: 0x8c000120, 0x00000106
pinmap_trace: 0x8c000124, 0x00000101
pinmap_trace: 0x8c000128, 0x00000104
pinmap_trace: 0x8c00012c, 0x00000101
pinmap_trace: 0x8c0002bc, 0x00000101
pinmap_trace: 0x8c000130, 0x00000104
pinmap_trace: 0x8c000134, 0x00000104
pinmap_trace: 0x8c000138, 0x00000104
pinmap_trace: 0x8c00013c, 0x00000104
pinmap_trace: 0x8c000144, 0x0000018a
pinmap_trace: 0x8c000148, 0x0000018a
pinmap_trace: 0x8c000150, 0x00000101
pinmap_trace: 0x8c000154, 0x00000140
pinmap_trace: 0x8c000158, 0x00000140
pinmap_trace: 0x8c00015c, 0x00000140
pinmap_trace: 0x8c000160, 0x00000102
pinmap_trace: 0x8c00016c, 0x000001ba
pinmap_trace: 0x8c000170, 0x00000131
pinmap_trace: 0x8c000174, 0x00000175
pinmap_trace: 0x8c000178, 0x000001ba
pinmap_trace: 0x8c00017c, 0x00000140
pinmap_trace: 0x8c000180, 0x0000018a
pinmap_trace: 0x8c000184, 0x0000018a
pinmap_trace: 0x8c000188, 0x0000018a
pinmap_trace: 0x8c00018c, 0x0000018a
pinmap_trace: 0x8c000190, 0x0000018a
pinmap_trace: 0x8c000194, 0x00000131
pinmap_trace: 0x8c000198, 0x00000198
pinmap_trace: 0x8c00019c, 0x00000198
pinmap_trace: 0x8c0001a0, 0x00000101
pinmap_trace: 0x8c0001a4, 0x00000101
pinmap_trace: 0x8c0001a8, 0x00000101
pinmap_trace: 0x8c0001ac, 0x00000101
pinmap_trace: 0x8c0001b0, 0x00000101
pinmap_trace: 0x8c0001b4, 0x00000140
pinmap_trace: 0x8c0001b8, 0x00000176
pinmap_trace: 0x8c0001bc, 0x00000104
pinmap_trace: 0x8c0001c0, 0x00000101
pinmap_trace: 0x8c0001c4, 0x000001b2
pinmap_trace: 0x8c0001c8, 0x00000104
pinmap_trace: 0x8c0001cc, 0x00000104
pinmap_trace: 0x8c0001d0, 0x00000104
pinmap_trace: 0x8c0001d4, 0x00000104
pinmap_trace: 0x8c0001d8, 0x00000104
pinmap_trace: 0x8c0001dc, 0x00000104
pinmap_trace: 0x8c0001e0, 0x00000104
pinmap_trace: 0x8c0001e4, 0x00000104
pinmap_trace: 0x8c0001e8, 0x00000104
pinmap_trace: 0x8c0001ec, 0x00000104
pinmap_trace: 0x8c0001f0, 0x00000101
pinmap_trace: 0x8c0001f4, 0x00000104
pinmap_trace: 0x8c0002d4, 0x00000144
pinmap_trace: 0x8c0002d8, 0x00000144
pinmap_trace: 0x8c0002dc, 0x00000144
pinmap_trace: 0x8c0002e0, 0x00000144
pinmap_trace: 0x8c000200, 0x00000100
pinmap_trace: 0x8c0001fc, 0x00000188
pinmap_trace: 0x8c0001f8, 0x00000188
pinmap_trace: 0x8c000204, 0x00000188
pinmap_trace: 0x8c000208, 0x00000188
pinmap_trace: 0x8c00020c, 0x00000140
pinmap_trace: 0x8c000210, 0x00000140
pinmap_trace: 0x8c000228, 0x00000140
pinmap_trace: 0x8c000214, 0x00000101
pinmap_trace: 0x8c000218, 0x00000101
pinmap_trace: 0x8c00021c, 0x00000101
pinmap_trace: 0x8c00022c, 0x00000141
pinmap_trace: 0x8c000230, 0x00000132
pinmap_trace: 0x8c000234, 0x00000140
pinmap_trace: 0x8c000220, 0x00000101
pinmap_trace: 0x8c000224, 0x00000101
pinmap_trace: 0x8c000248, 0x00000188
pinmap_trace: 0x8c00024c, 0x00000188
pinmap_trace: 0x8c000250, 0x00000100
pinmap_trace: 0x8c000254, 0x00000240
pinmap_trace: 0x8c000258, 0x00000100
pinmap_trace: 0x8c00025c, 0x00000100
pinmap_trace: 0x8c000260, 0x00000100
pinmap_trace: 0x8c000264, 0x00000100
pinmap_trace: 0x8c000268, 0x00000100
pinmap_trace: 0x8c00026c, 0x00000101
pinmap_trace: 0x8c000278, 0x00000188
pinmap_trace: 0x8c000284, 0x00000101
pinmap_trace: 0x8c000270, 0x00000101
pinmap_trace: 0x8c00027c, 0x00000188
pinmap_trace: 0x8c000288, 0x00000101
pinmap_trace: 0x8c000274, 0x00000101
pinmap_trace: 0x8c000280, 0x00000188
pinmap_trace: 0x8c00028c, 0x00000101
pinmap_trace: 0x8c000294, 0x00000170
pinmap_trace: 0x8c000298, 0x0000019a
pinmap_trace: 0x8c00029c, 0x00000111
pinmap_trace: 0x8c0002a0, 0x00000140
pinmap_trace: 0x8c0002a4, 0x00000231
connection closed

@ilyakurdyukov
Copy link
Owner

pinmap_trace: 0x8c000298, 0x0000019a
pinmap_trace: 0x8c00029c, 0x00000111
pinmap_trace: 0x8c0002a0, 0x00000140
pinmap_trace: 0x8c0002a4, 0x00000231
connection closed

Next there should be the following values ​​(judging by the firmware of my B310E, the previous ones match):

pinmap_trace: 0x82001874, 0x0000018a
pinmap_trace: 0x82001850, 0x0000018a
pinmap_trace: 0x82001878, 0x0000010a
pinmap_trace: 0x8200187c, 0x00000100
pinmap_trace: 0x82001884, 0x00000100
pinmap_trace: 0x82001880, 0x00000101

Which are different because 0x82001xxx are analog die registers.

At the beginning of syscode.c there are the following lines:

#ifndef CHECK_ADI
#define CHECK_ADI 0
#endif

Try replacing CHECK_ADI 0 with CHECK_ADI 1.

I'll try to find what these registers refer to.

@ms2010gamer
Copy link
Author

ms2010gamer commented Nov 5, 2024

I just changed CHECK_ADI to 1 and compiled the code... same exact output!

@ilyakurdyukov
Copy link
Owner

I've noticed some weird code in the firmware for the SC6530 that doesn't seem to do anything, but may be needed for some versions of the chip:

#if 0 // what's this?
MEM4(0x8b0000a0) = -2;
MEM4(0x8b0000a8) = -2;
#endif

Try changing #if 0 with #if 1.

If this doesn't change anything, try skipping the initialization of these pins:

		} else break;
		DBG_LOG("pinmap_trace: 0x%08x, 0x%08x\n", addr, val);
-		sys_wait_ms(500);
+		//sys_wait_ms(500);
+		if (addr == 0x8c0002a4) break;
	}

@ms2010gamer
Copy link
Author

ms2010gamer commented Nov 5, 2024

ok so the second one didn't change anything but the first one (the #if one) actually did this:

Waiting for connection (300s)
BSL_REP_VER: "SPRD3\0"
BSL_REP_VER: "Custom FDL1: CHIP ID = 0x6530c000\0"
!!! entry
malloc heap: 4147072 bytes
keymap = 0x300cf154
pinmap = 0x300cf1d4
scan_firmware: 463ms
chip_id: num = 0x6530c000
chip_id: ver = 0x90001
chip_id: adi = 0x1130c000
pinmap_trace: 0x8c000000, 0x0001ffff
pinmap_trace: 0x8c000044, 0x00000134
pinmap_trace: 0x8c000048, 0x00000134
pinmap_trace: 0x8c00004c, 0x00000104
pinmap_trace: 0x8c000050, 0x00000104
pinmap_trace: 0x8c000054, 0x00000104
pinmap_trace: 0x8c000058, 0x00000104
pinmap_trace: 0x8c00005c, 0x00000104
pinmap_trace: 0x8c000060, 0x00000104
pinmap_trace: 0x8c000064, 0x00000104
pinmap_trace: 0x8c000068, 0x00000104
pinmap_trace: 0x8c00006c, 0x00000104
pinmap_trace: 0x8c000070, 0x00000104
pinmap_trace: 0x8c000074, 0x00000104
pinmap_trace: 0x8c000078, 0x00000104
pinmap_trace: 0x8c000084, 0x00000140
pinmap_trace: 0x8c000090, 0x00000101
pinmap_trace: 0x8c000098, 0x00000201
pinmap_trace: 0x8c0000a0, 0x00000201
pinmap_trace: 0x8c0000a4, 0x00000101
pinmap_trace: 0x8c0000a8, 0x00000106
pinmap_trace: 0x8c0000ac, 0x00000106
pinmap_trace: 0x8c0000b0, 0x00000106
pinmap_trace: 0x8c0000b4, 0x00000106
pinmap_trace: 0x8c0000b8, 0x00000106
pinmap_trace: 0x8c0000bc, 0x00000106
pinmap_trace: 0x8c0000c0, 0x00000106
pinmap_trace: 0x8c0000c4, 0x00000106
pinmap_trace: 0x8c0000c8, 0x00000106
pinmap_trace: 0x8c0000cc, 0x00000106
pinmap_trace: 0x8c0000d0, 0x00000106
pinmap_trace: 0x8c0000d4, 0x00000106
pinmap_trace: 0x8c0000d8, 0x00000106
pinmap_trace: 0x8c0000dc, 0x00000106
pinmap_trace: 0x8c0000e0, 0x00000106
pinmap_trace: 0x8c0000e4, 0x00000106
pinmap_trace: 0x8c0000e8, 0x00000104
pinmap_trace: 0x8c0000ec, 0x00000104
pinmap_trace: 0x8c0000f0, 0x00000104
pinmap_trace: 0x8c0000f4, 0x00000104
pinmap_trace: 0x8c0000f8, 0x00000104
pinmap_trace: 0x8c0000fc, 0x00000104
pinmap_trace: 0x8c000100, 0x00000104
pinmap_trace: 0x8c000104, 0x00000104
pinmap_trace: 0x8c000108, 0x00000104
pinmap_trace: 0x8c00010c, 0x00000101
pinmap_trace: 0x8c000110, 0x00000101
pinmap_trace: 0x8c00011c, 0x00000101
pinmap_trace: 0x8c000120, 0x00000106
pinmap_trace: 0x8c000124, 0x00000101
pinmap_trace: 0x8c000128, 0x00000104
pinmap_trace: 0x8c00012c, 0x00000101
pinmap_trace: 0x8c0002bc, 0x00000101
pinmap_trace: 0x8c000130, 0x00000104
pinmap_trace: 0x8c000134, 0x00000104
pinmap_trace: 0x8c000138, 0x00000104
pinmap_trace: 0x8c00013c, 0x00000104
pinmap_trace: 0x8c000144, 0x0000018a
pinmap_trace: 0x8c000148, 0x0000018a
pinmap_trace: 0x8c000150, 0x00000101
pinmap_trace: 0x8c000154, 0x00000140
pinmap_trace: 0x8c000158, 0x00000140
pinmap_trace: 0x8c00015c, 0x00000140
pinmap_trace: 0x8c000160, 0x00000102
pinmap_trace: 0x8c00016c, 0x000001ba
pinmap_trace: 0x8c000170, 0x00000131
pinmap_trace: 0x8c000174, 0x00000175
pinmap_trace: 0x8c000178, 0x000001ba
pinmap_trace: 0x8c00017c, 0x00000140
pinmap_trace: 0x8c000180, 0x0000018a
pinmap_trace: 0x8c000184, 0x0000018a
pinmap_trace: 0x8c000188, 0x0000018a
pinmap_trace: 0x8c00018c, 0x0000018a
pinmap_trace: 0x8c000190, 0x0000018a
pinmap_trace: 0x8c000194, 0x00000131
pinmap_trace: 0x8c000198, 0x00000198
pinmap_trace: 0x8c00019c, 0x00000198
pinmap_trace: 0x8c0001a0, 0x00000101
pinmap_trace: 0x8c0001a4, 0x00000101
pinmap_trace: 0x8c0001a8, 0x00000101
pinmap_trace: 0x8c0001ac, 0x00000101
pinmap_trace: 0x8c0001b0, 0x00000101
pinmap_trace: 0x8c0001b4, 0x00000140
pinmap_trace: 0x8c0001b8, 0x00000176
pinmap_trace: 0x8c0001bc, 0x00000104
pinmap_trace: 0x8c0001c0, 0x00000101
pinmap_trace: 0x8c0001c4, 0x000001b2
pinmap_trace: 0x8c0001c8, 0x00000104
pinmap_trace: 0x8c0001cc, 0x00000104
pinmap_trace: 0x8c0001d0, 0x00000104
pinmap_trace: 0x8c0001d4, 0x00000104
pinmap_trace: 0x8c0001d8, 0x00000104
pinmap_trace: 0x8c0001dc, 0x00000104
pinmap_trace: 0x8c0001e0, 0x00000104
pinmap_trace: 0x8c0001e4, 0x00000104
pinmap_trace: 0x8c0001e8, 0x00000104
pinmap_trace: 0x8c0001ec, 0x00000104
pinmap_trace: 0x8c0001f0, 0x00000101
pinmap_trace: 0x8c0001f4, 0x00000104
pinmap_trace: 0x8c0002d4, 0x00000144
pinmap_trace: 0x8c0002d8, 0x00000144
pinmap_trace: 0x8c0002dc, 0x00000144
pinmap_trace: 0x8c0002e0, 0x00000144
pinmap_trace: 0x8c000200, 0x00000100
pinmap_trace: 0x8c0001fc, 0x00000188
pinmap_trace: 0x8c0001f8, 0x00000188
pinmap_trace: 0x8c000204, 0x00000188
pinmap_trace: 0x8c000208, 0x00000188
pinmap_trace: 0x8c00020c, 0x00000140
pinmap_trace: 0x8c000210, 0x00000140
pinmap_trace: 0x8c000228, 0x00000140
pinmap_trace: 0x8c000214, 0x00000101
pinmap_trace: 0x8c000218, 0x00000101
pinmap_trace: 0x8c00021c, 0x00000101
pinmap_trace: 0x8c00022c, 0x00000141
pinmap_trace: 0x8c000230, 0x00000132
pinmap_trace: 0x8c000234, 0x00000140
pinmap_trace: 0x8c000220, 0x00000101
pinmap_trace: 0x8c000224, 0x00000101
pinmap_trace: 0x8c000248, 0x00000188
pinmap_trace: 0x8c00024c, 0x00000188
pinmap_trace: 0x8c000250, 0x00000100
pinmap_trace: 0x8c000254, 0x00000240
pinmap_trace: 0x8c000258, 0x00000100
pinmap_trace: 0x8c00025c, 0x00000100
pinmap_trace: 0x8c000260, 0x00000100
pinmap_trace: 0x8c000264, 0x00000100
pinmap_trace: 0x8c000268, 0x00000100
pinmap_trace: 0x8c00026c, 0x00000101
pinmap_trace: 0x8c000278, 0x00000188
pinmap_trace: 0x8c000284, 0x00000101
pinmap_trace: 0x8c000270, 0x00000101
pinmap_trace: 0x8c00027c, 0x00000188
pinmap_trace: 0x8c000288, 0x00000101
pinmap_trace: 0x8c000274, 0x00000101
pinmap_trace: 0x8c000280, 0x00000188
pinmap_trace: 0x8c00028c, 0x00000101
pinmap_trace: 0x8c000294, 0x00000170
pinmap_trace: 0x8c000298, 0x0000019a
pinmap_trace: 0x8c00029c, 0x00000111
pinmap_trace: 0x8c0002a0, 0x00000140
pinmap_trace: 0x8c0002a4, 0x00000231
pinmap_trace: 0x82001874, 0x0000018a
pinmap_trace: 0x82001850, 0x0000018a
pinmap_trace: 0x82001878, 0x0000010a
pinmap_trace: 0x8200187c, 0x00000100
pinmap_trace: 0x82001884, 0x00000100
pinmap_trace: 0x82001880, 0x00000101
connection closed

different output! but still black screen

@ms2010gamer
Copy link
Author

I'm just a simple C guy who made an x86 OS that prints hi (using 0xb8000)
while you're someone who started from nothing to fully working ports of games to phones
I thought I'd just throw in the trash!
I wish I could be like you who actually knows what he is doing!

@ilyakurdyukov
Copy link
Owner

Try putting a trace print here. For example like this:

DBG_LOG("lcm_init trace 1\n");

Check if the execution reaches this point.

If it does, then place prints between the following lines to find where it hangs. In fact, we are now doing printf debugging, which many people despise. But we do not have any tools to do it differently.

@ms2010gamer
Copy link
Author

ngl the printf debugging method is the best in my opinion
it's time consuming but at least it u can spot problems with it

@ilyakurdyukov
Copy link
Owner

In issue 8, execution would get to this point and hang due to initialization of a certain pin, which would cause a hang after a short time. That's why I suggested putting a wait between trace prints when initializing pins. The pins are initialized according to the table from the firmware, because phones can be very different with different settings.

@ms2010gamer
Copy link
Author

so we activate it?

@ms2010gamer
Copy link
Author

I think communicating using github issues is way too slow
can we use something like discord and when u discover the solution we post it here for everybody else?

@ilyakurdyukov
Copy link
Owner

Try inserting an infinite timer report before pin_init(). How long will it last? Will it run forever? Or will it stop at some value? If it stops, will it always stop at the same time? Or does it only stop after or during pin_init() but not before?

 void sys_init(void) {
 	init_charger();
 	init_chip_id();
+	for (;;) {
+		DBG_LOG("time: %u ms\n", sys_timer_ms());
+		sys_wait_ms(50);
+	}
 	pin_init();

@ms2010gamer
Copy link
Author

ms2010gamer commented Nov 5, 2024

it looks like the timer is going forever...
note: I deleted the pin 1 second thing

@ms2010gamer
Copy link
Author

since doom is working on your b310e can you send me your files? (nor_fdl1.bin, fpdoom.bin, etc...)

@ms2010gamer
Copy link
Author

disabling the timer made the fptest.bin work??? I have no idea but thanks for ur help!

@ms2010gamer
Copy link
Author

to anyone who was wondering... just fix the damn watchdog timer!!! or check the pin that's causing issues and skip it maybe
thanks now everything for some reason just works out of the box!

@ilyakurdyukov
Copy link
Owner

ilyakurdyukov commented Nov 6, 2024

disabling the timer made the fptest.bin work??? I have no idea but thanks for ur help!

Did you get it working? What did you do exactly? Did you use my examples on disabling the watchdog timer from issue 8?

@ms2010gamer
Copy link
Author

ms2010gamer commented Nov 6, 2024

Actually have no idea! here is the whole code:

syscode.c:
<deleted 966 lines>
and init_sc6530.h
<deleted 72 lines>

diff --git a/fpdoom/init_sc6530.h b/fpdoom/init_sc6530.h
index 5d52872..4aca5ac 100644
--- a/fpdoom/init_sc6530.h
+++ b/fpdoom/init_sc6530.h
@@ -43,7 +43,7 @@ static void sc6530_init_smc(void) {
 
 static void sc6530_init_freq(void) {
 	uint32_t a;
-#if 0 // what's this?
+#if 1 // what's this?
 	MEM4(0x8b0000a0) = -2;
 	MEM4(0x8b0000a8) = -2;
 #endif
diff --git a/fpdoom/syscode.c b/fpdoom/syscode.c
index 15a005f..5d17745 100644
--- a/fpdoom/syscode.c
+++ b/fpdoom/syscode.c
@@ -16,7 +16,7 @@
 #define IS_SC6530 (_chip == 3)
 
 #ifndef CHECK_ADI
-#define CHECK_ADI 0
+#define CHECK_ADI 1
 #endif
 
 #if CHECK_ADI
@@ -175,7 +175,8 @@ static void pin_init(void) {
 		if (addr - 0x82001000 < 0x1000) {
 			adi_write(addr, val & 0xffff);
 		} else if (addr >> 12 == 0x8c000) {
-			if (addr == sc6530_fix) continue;
+			//if (addr == sc6530_fix) continue;
+			if (addr == 0x8c0002a4) continue;
 			if (_chip == 1 && addr - 0x8c000114 <= 0x18) {
 				// ANA_LDO_SF_REG0
 				if (adi_read(0x8200148c) & 1 << 9)
@@ -185,6 +186,9 @@ static void pin_init(void) {
 			}
 			MEM4(addr) = val;
 		} else break;
+		DBG_LOG("pinmap_trace: 0x%08x, 0x%08x\n", addr, val);
+		//sys_wait_ms(1000);
+		if (addr == 0xc0002a4) break;
 	}
 	if (sys_data.gpio_init)
 		gpio_init((void*)pinmap);
@@ -499,7 +503,9 @@ static const lcd_config_t* lcm_init(void) {
 	LCM_CR(0x10) = 1;
 	LCM_CR(0x14) = 0xa50100;
 
-	if (IS_SC6530 || !is_whtled_on()) lcm_reset(32, 0);
+	//if (IS_SC6530 || !is_whtled_on()) lcm_reset(32, 0);
+
+	DBG_LOG("lcm_init trace 1\n");
 
 	clk_rate = get_ahb_freq();
 	DBG_LOG("LCD: clk_rate = %u\n", clk_rate);
@@ -934,6 +940,10 @@ static void init_charger(void) {
 void sys_init(void) {
 	init_charger();
 	init_chip_id();
+	//for (;;) {	// uncomment to test timer
+	//	DBG_LOG("time: %u ms\n", sys_timer_ms());
+	//	sys_wait_ms(50);
+	//}
 	pin_init();
 	lcd_init(lcm_init());
 	lcd_appinit();

@ms2010gamer
Copy link
Author

also can you walk me through using the SD card? (using fpmenu)
idk how to compile all the games using LIBC_SDIO=3

@ilyakurdyukov
Copy link
Owner

Actually have no idea! here is the whole code:

Please don't post all thousand lines of code, that's what git diff is for.

If the old binaries now work for you, then the problem and its solution have nothing to do with these changes.

@ms2010gamer
Copy link
Author

no the old ones don't work the ones compiled with the code I sent u do work

@ilyakurdyukov
Copy link
Owner

Here is a script that will recompile all the binaries (will be in the fpdoom/release directory):

#!/bin/bash
NDK=$HOME/android-ndk-r26d
TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm
CLANG=$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi21-clang

cd fpdoom && {
	test -f pack_reloc/pack_reloc || make -C pack_reloc
	make -f release.make clean all ZIPDIR=../zipdir TOOLCHAIN=$TOOLCHAIN CC=$CLANG 2>&1 | tee ../build-release.log
}

A zipdir directory will be created, into which all the necessary game sources will be downloaded.

@ms2010gamer
Copy link
Author

I just defined LIBC_SDIO=3 to the make command

@ms2010gamer
Copy link
Author

I'm goin to school but I don't have much today so I'll be back around 3 hours later
if there is anything I have to do to make the sdcard boot working tell me

@ilyakurdyukov
Copy link
Owner

if there is anything I have to do to make the sdcard boot working tell me

Use the script from this comment to rebuild all binaries.

Read sdboot/README.md.

Find a microSD card up to 32GB, it must be formatted in FAT32, some new cards come formatted in exFAT.

Write the fpbin directory from releases/sdcard to the card.

Write games/doom1/doom1.wad to the card, then Doom will work from the menu. You will understand about other games if you read fpbin/config.txt.

To check, insert the card into the phone and run via USB:

./spd_dump fdl sdboot3.bin 0x40004000

How to patch the firmware is written in sdboot/README.md.

@ms2010gamer
Copy link
Author

so I have an 8GB sd card that I formatted in FAT32, the menu works but when I enter doom 1 the screen is black... then the backlight turns off then finally it goes to charging mode
my sd card:
|----- fbbin/ # with the compiled sdcard .bin files
|
|-----games/doom/doom1.wad

@ms2010gamer
Copy link
Author

ms2010gamer commented Nov 6, 2024

I see now... I should rename games/doom/doom1.wad to games/doom1/doom1.wad
it works perfectly now!

@ilyakurdyukov
Copy link
Owner

games/doom/doom1.wad

Should be "games/doom1/doom1.wad".

The directory name is specified in fpbin/config.txt.

|Doom 1| $doom --dir games/doom1 doom # -timedemo demo1

@ms2010gamer
Copy link
Author

I just used the fphelper sdboot guide but now I how do I boot into the sd card instead of the normal OS?

@ilyakurdyukov
Copy link
Owner

This is explained in the sdboot/README.md.

Then use the fphelper utility from the spreadtrum_flash set:

./fphelper flash.bin scan

This will scan the firmware and among various information will tell you what the phone's boot key is, as well as the keys for booting from the SD card. For example:

0x71b0c: keymap, bootkey = 0x08 (LSOFT), sdboot keys = 0x2a 0x01 0x30 (STAR, DIAL, 0)

For B310E should be this:

keymap, bootkey = 0x0d (CENTER), sdboot keys = 0x31 0x01 0x32 (1, DIAL, 2)

Turn off the phone, then hold one of the sdboot keys, and then hold the power key.

@ms2010gamer
Copy link
Author

it works now but the nes emulator keeps crashing... I'll see what I can do and if I can't figure out the problem I'll post here

@ms2010gamer
Copy link
Author

I got it working now (another path issue)
quick question, what are your future ports for this repo?

@ilyakurdyukov
Copy link
Owner

I'm porting Snes9x now.

@ms2010gamer
Copy link
Author

ms2010gamer commented Nov 6, 2024

I wanna port stuff like u
where should I start?
(maybe even contribute to this repo)

@ilyakurdyukov
Copy link
Owner

You can examine the fptest code to see how display and keypad access works.

Try to minimize the changes required to the B310E. Remove all changes (make a backup of the current fpdoom folder and make a new one without changes) and try the fixes below separately. Are both really needed or just one?

fpdoom/init_sc6530.h:

 static void sc6530_init_freq(void) {
 	uint32_t a;
-#if 0 // what's this?
+#if 1 // what's this?
 	MEM4(0x8b0000a0) = -2;
 	MEM4(0x8b0000a8) = -2;
 #endif

fpdoom/syscode.c:

 		} else if (addr >> 12 == 0x8c000) {
-			if (addr == sc6530_fix) continue;
+			if (addr == 0x8c0002a4) continue;
 			if (_chip == 1 && addr - 0x8c000114 <= 0x18) {

@ms2010gamer
Copy link
Author

trying...

@ms2010gamer
Copy link
Author

happy news! the syscode.c one worked prefectly!!!
while the init_sc6530.h did nothing

@ilyakurdyukov
Copy link
Owner

0x2a4 is the UART TX pin.

Try this pin_init():

static void pin_init(void) {
	const volatile uint32_t *pinmap = pinmap_addr;
	// skip specific pin for SC6530/SC6530C
	// hangs shortly after this pin is enabled
	// the value that causes the hang is 0x231
	uint32_t sc6530_fix = 0;
	if (IS_SC6530) {
		// workaround for Samsung GT-E1272
		sc6530_fix = 0x8c000290; // SPI0 pin
		if (MEM4(0x205003fc) << 16) // SC6530C
			// workaround for Samsung B310E
			sc6530_fix += 0x2a4 - 0x290; // UART TX pin
	}

	for (;;) {
		uint32_t addr = pinmap[0], val = pinmap[1];
		pinmap += 2;
		if (addr - 0x82001000 < 0x1000) {
			adi_write(addr, val & 0xffff);
		} else if (addr >> 12 == 0x8c000) {
			if (addr == sc6530_fix) continue;
			if (_chip == 1 && addr - 0x8c000114 <= 0x18) {
				// ANA_LDO_SF_REG0
				if (adi_read(0x8200148c) & 1 << 9)
					val |= 0x200000;
				else if (sys_data.chip_id.ver == 0xa0001)
					val |= 0x280000;
			}
			MEM4(addr) = val;
		} else break;
	}
	if (sys_data.gpio_init)
		gpio_init((void*)pinmap);
}

@ilyakurdyukov
Copy link
Owner

Maybe it happens because UART is enabled when its pin is reconfigured.
Also try this pin_init() that disables UART.

static void pin_init(void) {
	const volatile uint32_t *pinmap = pinmap_addr;
	uint32_t sc6530_fix = 0;
	if (IS_SC6530) {
		sc6530_fix = 0x8c000290; // SPI0 pin
		MEM4(0x8b0000a4) = 0xc00; // disable UART
	}

	for (;;) {
		uint32_t addr = pinmap[0], val = pinmap[1];
		pinmap += 2;
		if (addr - 0x82001000 < 0x1000) {
			adi_write(addr, val & 0xffff);
		} else if (addr >> 12 == 0x8c000) {
			if (addr == sc6530_fix) continue;
			if (_chip == 1 && addr - 0x8c000114 <= 0x18) {
				// ANA_LDO_SF_REG0
				if (adi_read(0x8200148c) & 1 << 9)
					val |= 0x200000;
				else if (sys_data.chip_id.ver == 0xa0001)
					val |= 0x280000;
			}
			MEM4(addr) = val;
		} else break;
	}
	if (sys_data.gpio_init)
		gpio_init((void*)pinmap);
}

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