ant-thomas / zsgx1hacks

Hacks for ZS-GX1 IP Camera and various Goke GK7102 based IP Cameras
363 stars 102 forks source link

GK710X Linux SDK ver. 2.0.0 #124

Open paus56 opened 4 years ago

paus56 commented 4 years ago

Linux SDK for our cameras on the GK710X

GK710X_SDK_v2_01 GK710X_SDK_v2_04

Download the Linux SDK

alesimoes commented 4 years ago

Thank you. where do you found that SDK?

aalm commented 4 years ago

Thanks, was good enough for me to build my own kernel w/builtin support for ext2, ext3 and ext4. I had setup root-on-NFS working before, and was really missing for this!

Now i still gotta figure out why i get "detect sflash fail" during boot + empty /proc/mtd with custom kernel, and then i think it's good enough to replace the one provided by vendor on flash.

ps. you can use GK710X_LinuxSDK_v2.0.0/linux/kernel/3.4.43/scripts/extract-ikconfig for dumping the kernel config from (iirc. likely) /dev/mtdblock2

biot commented 4 years ago

@aalm how did you manage to build a working kernel with that SDK? Mine hangs at boot, both with the Goke GCC and a regular one. Which GCC did you use?

This would really help me! I'm trying to get a mainline kernel running on the GK7101, documented here, and all help is welcome!

Incidentally @paus56 I would very much like to know how you got that SDK, and is there any more? An older version (to match what's on the camera), or a datasheet...

aalm commented 4 years ago

GCC from the SDK did work for me, i'm using debian(i686/32bit) in a vm as my build host.

At which point does it exactly hang? Does it print anything? How are you loading it from u-boot?

i also have ip001_linux.rar[0] in which i haven't yet ran diff over to v2 SDK, but it does look very close to same, just stripped to include less than v2 SDK, and different set of old .configs. iirc. i found the link to it from 4pda.ru forums.

[0] sha256: 7B42BE862CF720788F9B8643249DAE7DFB4767DB2F1A39CEBF6E926492FF520E

biot commented 4 years ago

GCC from the SDK did work for me, i'm using debian(i686/32bit) in a vm as my build host.

I tried natively, and in a debian trusty VM but also 64 bit. I'll try a 32-bit VM.

At which point does it exactly hang? Does it print anything? How are you loading it from u-boot?

Just "Uncompressing Linux... done, booting the kernel.". That's the decompressor, using its own UART driver. No output from the actual kernel.

Loading it from U-Boot with "dhcp; bootm". Feeding it the stock kernel from the tftp server that way makes it boot, so the method is ok.

i also have ip001_linux.rar[0] in which i haven't yet ran diff over to v2 SDK, but it does look very close to same, just stripped to include less than v2 SDK, and different set of old .configs. iirc. i found the link to it from 4pda.ru forums.

Found it, thanks. Building that kernel within the SDK environment results in a kernel which hangs after the decompressor, exactly like the SDK kernel.

aalm commented 4 years ago

Did you try with a .config as is extracted from your original vendor kernel?

iirc. both SDKs were preconfigured for "GK710XS", so i guess you you should atleast switch to "GK710X", if using the .config(s) those SDKs ship with.

oh, i only just now noticed the link to your blog, interesting :]

biot commented 4 years ago

Yes, did a manual config to GK7101 earlier, and tried with the extracted config from the booting kernel. The result was the same.

alesimoes commented 4 years ago

Hi Bert, did you have tested the sample applications in your build? I trying to make the sample applications work using the kernel that come in the camera but not working. I'm creating a p2pcloud for those cameras.

biot commented 4 years ago

@alesimoes no, I'm only working on the kernel.

paus56 commented 4 years ago

alesimoes

I'm creating a p2pcloud for those cameras.

лучше использовать портированную прошивку оттуда: https://github.com/ant-thomas/zsgx1hacks/issues/129

alesimoes commented 4 years ago

Hi @paus56, I could see your posts in 4pda.ru and thanks for share the SDK. I'm able to build and write my application in camera but it is incompatible with adi lib. I think this SDK have an adi lib different of the cameras that I'm working on.

My cloud works with H264 baseline profile, but the firmware have the Main profile. do you know how can I solve this issue?

biot commented 4 years ago

@aalm still no luck with a 32-bit VM, but that was always voodoo :) Any chance I could get a custom kernel of yours to try? Also, can I have a copy of your VM (with any account of yours sanitized of course)?

aalm commented 4 years ago

Sure, we can try something. I could start by compiling with your .config, if you share it via ie. http://ix.io or similar pastebin.

biot commented 4 years ago

.config extracted from vendor kernel on mtdblock2: https://paste.ubuntu.com/p/2CYG2R4sY4/ .config I made manually and tried with SDK build: https://paste.ubuntu.com/p/JQ3zZMkSCw/

aalm commented 4 years ago

didn't figure out better way to share the zImage[0]. built the extracted .config(after make mrproper), and answered GK710X for the system(ARCH_), and "y" for the rest of new config options(minor differences between your&sdk option names).

[0] https://github.com/aalm/gk710x-tools/tree/zImage_v1

biot commented 4 years ago

Ok, that kernel also doesn't boot for me, hangs at the same point. Somehow my test platform doesn't like these... I do have some other GK710x gear, will try on those.

aalm commented 4 years ago

I wonder if the v1 (or v1.1.2 w/e the previous SDK version was) would work for that SoC better.

fwiw., i found out that atleast for me, the ip001_linux.rar version is more correct one to use, as it has entry for "XM25QH64" in sflash_devices_supported.

biot commented 4 years ago

This SDK 2.0 is definitely ahead of what my hardware runs, I've found some differences in hardware writes and even hw_ops fields. Definitely would like to get my hands on an earlier SDK version.

Which GK7101 hardware are you using by the way?

aalm commented 4 years ago

The camera i have is actually with GK7102S.

biot commented 4 years ago

Do you have a link to it? I might get one to try out.

aalm commented 4 years ago

Do you have a link to it? I might get one to try out.

Missed your Q earlier; no, and unfortunately i wasn't able to find the product again.

But I just found something i think you might find interesting: https://github.com/RT-Thread/rt-thread/tree/master/bsp/gkipc/armv6

and there was more under ../bsp/gkipc/, but with a quick look it seems like above dir contains most of machdep bootstrap.

I hope you will continue your blog, it got me into trying out ghidra... i already knew about it, but oh wow, reversing something above the size of kernel... is actually fun with a tool like ghidra!!

i got a script for ghidra allowing saving modified bytes under selection back into the elf, which does work out-of-box for only raw/flat binaries. made ghidra more powerful for reversing/modifying the userland "firmware", but if someone will get things running with mainline, that might not be necessary in the end.

i've found enough "worth adapting" srcs w/reasonable licenses to cover most of the features these cameras have/could use.. Repo(or a fork of it) linked below might turn into a thing "hosting" such tools. https://github.com/bolshevik/goke-GK7102-customizer

biot commented 4 years ago

But I just found something i think you might find interesting: https://github.com/RT-Thread/rt-thread/tree/master/bsp/gkipc/armv6

and there was more under ../bsp/gkipc/, but with a quick look it seems like above dir contains most of machdep bootstrap.

That whole gkipc directory is specifically a port of RT-Thread to the Goke 710x platform (gkipc = Goke IP camera). It's easy to build, but... doesn't work. No interrupts. I've also ported ChibiOS to the gk7101, as it's small/easy to control. No interrupts. Nothing works :-(

i got a script for ghidra allowing saving modified bytes under selection back into the elf, which does work out-of-box for only raw/flat binaries. made ghidra more powerful for reversing/modifying the userland "firmware", but if someone will get things running with mainline, that might not be necessary in the end.

Yeah, I don't see serious problems on the userspace end, or even in porting kernel drivers (it's just a lot of work). But there's no way to even get started until I have a basic mainline kernel running, and that's where I'm stuck.

aalm commented 4 years ago

Yeah, I don't see serious problems on the userspace end, or even in porting kernel drivers (it's just a lot of work). But there's no way to even get started until I have a basic mainline kernel running, and that's where I'm stuck.

my best guess atm. is, that you might be running into a situation possibly referred here. i mean, for using !"gk-sio" you'd want the "interrupt_may_hang=true" behaviour, which apparently doesn't exist by that name in mainline anymore, oh well. at least iirc. gk-sio appeared to have somewhat similar 'watchdog' for (these?) issues..

innerfire3 commented 4 years ago

Hello Everyone, Can someone help me to build own binaries compatible with this camera, I'm using this SDK but when I try to execute the file, I get segmentation failed.

maartenjd commented 4 years ago

[https://github.com/aalm]

Thanks, was good enough for me to build my own kernel w/builtin support for ext2, ext3 and ext4. I had setup root-on-NFS working before, and was really missing for this!

> Now i still gotta figure out why i get "detect sflash fail" during boot + empty /proc/mtd with custom kernel, and then i think it's good enough to replace the one provided by vendor on flash.

ps. you can use GK710X_LinuxSDK_v2.0.0/linux/kernel/3.4.43/scripts/extract-ikconfig for dumping the kernel config from (iirc. likely) /dev/mtdblock2

[https://github.com/aalm] I managed to build a kernel using the 2.0.0 SDK and the .config extracted from my mtd2 but have the same error detect sflash fail and that is why the mtd-partitions are not initialized. Did you ever find out why this happens or manage to solve this issue? Thanks

aalm commented 4 years ago

[https://github.com/aalm]

Thanks, was good enough for me to build my own kernel w/builtin support for ext2, ext3 and ext4. I had setup root-on-NFS working before, and was really missing for this!

> Now i still gotta figure out why i get "detect sflash fail" during boot + empty /proc/mtd with custom

kernel, and then i think it's good enough to replace the one provided by vendor on flash. ps. you can use GK710X_LinuxSDK_v2.0.0/linux/kernel/3.4.43/scripts/extract-ikconfig for dumping the kernel config from (iirc. likely) /dev/mtdblock2

[https://github.com/aalm] I managed to build a kernel using the 2.0.0 SDK and the .config extracted from my mtd2 but have the same error detect sflash fail and that is why the mtd-partitions are not initialized. Did you ever find out why this happens or manage to solve this issue? Thanks

sure, iirc. i took some sflash definitions from the ".rar sdk". i believe i've "documented" these changes somewhere, possibly linked to from here.

aalm commented 4 years ago

as it has entry for "XM25QH64" in sflash_devices_supported.

hmm, didn't find more than the quote from above, but it should be enough for grep to find the .c-file from the SDK that needs editing for your device.

maartenjd commented 4 years ago

as it has entry for "XM25QH64" in sflash_devices_supported.

hmm, didn't find more than the quote from above, but it should be enough for grep to find the .c-file from the SDK that needs editing for your device.

Set CONFIG_MTD_M25P80=y in .config.

Or do make menuconfig and go to Device Drivers > MTD Support > Self Contained MTD Device Drivers > Support most SPI Flash Chips (AT26DF, M25P, W25X, ...) and enable. And detect sflash fail is gone and mtd-partitions are properly created.

IMG_20200413_180124

kumarsanjeevdutt commented 3 years ago

i am not able to find the PTZ folder in the SDK ,could you please help me where i can find that file and how do i add it to my demo application. Thank You

csurf commented 3 years ago

Link to SDK download appears to be dead. I get 'invalid link code' message. Can someone pls provide a working link to download the SDK?

csurf commented 3 years ago

@paus56 or anyone else, could you please provide an updated download link for the 2.0.0 SDK?

AngeloGomes commented 2 years ago

Hi Guys, I´m trying to fix my cam. It seems to be in bootloop. After opening the case, I saw a Goke GK7101 chip and now I am trying to catch any info as much as possible. I noticed the SDK link is not working anymore. Can someone post a new link or share the SDK again. Thank you all.

0zoon0 commented 2 years ago

Hi @paus56, could you please fix the download link? Thank you.

paus56 commented 2 years ago

Download SDK: https://disk.yandex.ru/d/oJJyHwfsp7bnKA

sh4tteredd commented 2 years ago

Hi you all, does anyone know if can I build rtsp/onvif for my GK7101S based cameras (netvue vigil 2)? thanks

i'm trying to use this sdk but idk how it works...

csurf commented 1 year ago

Can someone please help me understand how to compile a complete firmware image that includes the u-boot bootloader?

I downloaded the SDK, ran make deploy and then make. The build seems to complete without any errors, but I don't see when or where the firmware image is created & stored. What make commands should I be running, and where is the built image stored?

Also, I've run into an issue where the only output on the serial console is UGKMC. In my case, the SPI flash chip on my camera died, and I was never able to get a full EEPROM backup (using 'ch341a' programmer). So, I replaced the flash chip & have tried flashing different images that I found on the 4pda.ru forum, but none of the images have worked. I'm guessing that none of these images include the bootloader, and so the GK7102 is unable to boot. Has anyone run into something like this?

Without a datasheet, it's extremely difficult to understand what's going on.

csurf commented 1 year ago

@maartenjd

Or do make menuconfig and go to Device Drivers > MTD Support > Self Contained MTD Device Drivers > Support most SPI Flash Chips (AT26DF, M25P, W25X, ...) and enable. And detect sflash fail is gone and mtd-partitions are properly created.

Where or how did you do this? I couldn't find any Makefiles in the SDK that supported any type of make config or make menuconfig

maartenjd commented 1 year ago

@csurf I gave up a long time ago so really don't remember anymore. When I have some time again, I will have a look. Sorry.

csurf commented 1 year ago

@aalm can you please help me figure out how to compile u-boot for the GK7102? I'm struggling to figure out how to get a working bootloader built. My original SPI flash chip died, and I didn't have a backup, so I need to build u-boot from scratch & load the u-boot image onto my flash chip. I've tried multiple build options for u-boot, but the processor won't boot. I simply get 'UGKMC' output on the serial console (UART0).

Wedmer commented 1 year ago

@csurf SDK creates uboot, kernel, and rootfs images. For the start you need to flash only uboot. Then get other parts via tftp and flash them via uboot.

jhony251 commented 3 months ago

Hi friends! this thread is for hacking cameras based on GK7101? i cant understand all you have said.

I have others cams based on GK7102 and copying some files in SDCard all start to works. could be possible to do something similar?

Thanks everyone.

easycome1981 commented 5 days ago

Can someone help me with a .bin tab for my ST-291-2M-AI camera, it uses GK7102S sensor 2053 Thank you.