Skip to content

Translated sandbox #431

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

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
114 changes: 114 additions & 0 deletions translated_sandbox/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# sandbox-fpv
Sandbox for FPV experiments. Telegram-group: `https://t.me/+BMyMoolVOpkzNWUy` | [link](https://t.me/+BMyMoolVOpkzNWUy)

## News
* `26.07.2023` - FPV link setup via 4G modem .

* `01.07.2023` - A short note about the imx335 gk7205v300 camera . About baud for telemetry .

* `22.06.2023` - Finally, the problem with the picture being jerky at 30fps was resolved .

* `06.04.2023` - Added coupler firmware for ivg-g2s with u-boot on board.

* `05.04.2023` - Added functionality to rcjoystick for displaying packet losses (link quality) in rssi.

* `04.04.2023` - OpenIPC has added the majestic streamer, now the ivg-g2s camera runs h265 cbr (constant bitrate). This gave a cleaner picture and a significant reduction in noise. At the same time, changes were made to the link launch process. The main service is now S98datalinkwith the config /etc/datalink.conf, and wfb is now launched via /usr/bin/wifibroadcast. The articles have been corrected to accommodate this innovation.

* `01.04.2023` - Due to certain circumstances, wfb-ng was replaced in my camera and recorder with an alternative from OpenHD . Here is the package for assembly in buildroot OpenIPC. The shell wrappers take into account both options, due to the presence of a parameter link_idthat is not required in the OpenHD implementation. Archive with binaries of both options.

## Notes

* [Notes on setting up the link on the gk7205v200 camera and hi3536ev100 (dv100) recorder](notes_link_gk7205v200_hi3536ev100.md)
* [Notes on camera firmware gk7205v200 on OpenIPC](notes_start_ivg-g2s.md)
* [Notes on firmware for hi3536ev100 recorder on OpenIPC](notes_start_hi3536ev100.md)
* [A note about the imx335 gk7205v300 camera](notes_imx335_gk7205v300.md)
* [Adding smoothness to video on goke/hisilicon cameras](gkrcparams.md)
* [A note about controlling the camera via RC channels from the ground](notes_cam_control.md)
* [Switch between two cameras in the air](note-two-cameras-switched.md)
* [Loader for telemetry for gk7502v200, which does not hang the camera upon reboot](gk7205v200_u-boot-7502v200-for-telemetry.md)
* [Controlling buttons from the front panel on the recorder](nvr_gpio.md)
* [Connecting and setting up a tablet or smartphone for video and OSD via USB](usb-tethering.md)
* [Connecting the tablet to the recorder via wifi via the tablet's AP](note-nvr-tab-ap.md)
* [Connecting the tablet to the recorder via ethernet-usb-device](usb-eth-modem.md)
* [Using the hardware as a joystick to transmit RC channels via mavlink](rcjoystick.md)
* [About the analogue of RSSI](rcjoystick.md#rssi)
* [SBUS-to-USB joystick for using any equipment with an sbus receiver](sbus-to-usb-joystick)
* [FPV link setup via 4G modem](lte-fpv.md)
* [Installing usb_modeswitch on a camera with fpv, lite firmware](usb-modeswitch.md)

#### Miscellaneous
* [mavfwd for inav (one way msp) for camera](user_TipoMan/mavfwd_mavlink2.tar?raw=true)
* [Displaying video on windows and MP](gstlaunch_on_windows.md)
* [Disabling watchdog on the hi3536dv100 recorder](note_nvr_wdt.md)
* [Different from 115200 baud on camera uart for telemetry](note_telemetry_baud.md)

## Road map
* ~~Starting video with transfer from the recorder to the PC.~~
* ~~Launch one- and two-way telemetry.~~
* ~~Starting video transfer via usb tethering to an Android tablet.~~
* ~~Building and testing LTE firmware on e3372h + zerotier~~
* ~~Starting telemetry routing via mavlink-router.~~
* ~~Finding ways to control the camera through mavlink.~~.
* Finding ways to output video and osd via hdmi.
* ~~~Switching between several cameras, where one is the master with wfb-ng, and the rest are slaves.~~~
* Development of expansion board for camera: bec 5v/3.3v; usb hub, uart, wifi/modem power transistor, microSD.
* Development of a zoom lens control board and a method for controlling commercially available boards.
* Development of a stabilizing gimbal controlled from the ground via wfb-ng.



## Russians:

## Новое
* `26.07.2023` - Настройка FPV-линка [через 4G модем](lte-fpv.md).

* `01.07.2023` - Короткая заметка о камере [imx335 gk7205v300](notes_imx335_gk7205v300.md). О [baud для телеметрии](note_telemetry_baud.md).

* `22.06.2023` - Наконец [решилась](gkrcparams.md) проблема с дерганностью картинки на 30fps.

* `06.04.2023` - Добавлена [прошивка coupler](notes_start_ivg-g2s.md#L33) для ivg-g2s с u-boot на борту.

* `05.04.2023` - В rcjoystick [добавлен](rcjoystick.md#rssi) функционал для целей отображения потерь пакетов (качества линка) в rssi.

* `04.04.2023` - В OpenIPC "допилили" стример majestic, теперь на камере ivg-g2s работает h265 cbr (постоянный битрейт). Это дало более чистую картинку и значительное уменьшение шума. Вместе с этим были внесены изменения в процесс запуска линка. Основным сервисом теперь является `S98datalink` с конфигом `/etc/datalink.conf`, а запуск wfb теперь производится через `/usr/bin/wifibroadcast`. Статьи были исправлены под это нововведение.

* `01.04.2023` - В связи с некоторыми обстоятельствами, wfb-ng был заменен в моих камере и регистраторе на альтернативу от [OpenHD](https://github.com/OpenHD/wifibroadcast/). [Тут](wfbopenhd.zip) пакет для сборки в buildroot OpenIPC. В шелл-обертках учтены оба варианта, по наличию параметра `link_id` который не требуется в реализации от OpenHD. [Архив](https://github.com/OpenIPC/sandbox-fpv/blob/master/wfb.zip) с бинарниками обоих вариантов.

## Заметки

* [Заметки о настройке линка на камере gk7205v200 и регистраторе hi3536ev100 (dv100)](notes_link_gk7205v200_hi3536ev100.md)
* [Заметки о прошивке камеры gk7205v200 на OpenIPC](notes_start_ivg-g2s.md)
* [Заметки о прошивке регистратора hi3536ev100 на OpenIPC](notes_start_hi3536ev100.md)
* [Заметка о камере imx335 gk7205v300](notes_imx335_gk7205v300.md)
* [Добавляем плавности видео на goke/hisilicon камерах](gkrcparams.md)
* [Заметка о управлении камерой через RC каналы с наземки](notes_cam_control.md)
* [Переключение между двумя камерами в воздухе](note-two-cameras-switched.md)
* [Загрузчик под телеметрию для gk7502v200, который не вешает камеру при ребуте](gk7205v200_u-boot-7502v200-for-telemetry.md)
* [Управление кнопками с front panel на регистраторе](nvr_gpio.md)
* [Подключение и настройка планшета или смартфона для видео и OSD по USB](usb-tethering.md)
* [Подключение планшета к регистратору по wifi через AP планшета](note-nvr-tab-ap.md)
* [Подключение планшета к регистратору через ethernet-usb-device](usb-eth-modem.md)
* [Использование аппаратуры как джойстика для передачи каналов RC через mavlink](rcjoystick.md)
* [Про аналог RSSI](rcjoystick.md#rssi)
* [SBUS-to-USB joystick для использования любой аппаратуры с sbus приемником](sbus-to-usb-joystick)
* [Настройка FPV-линка через 4G модем](lte-fpv.md)
* [Установка usb_modeswitch на камеру с прошивкой fpv, lite](usb-modeswitch.md)

#### Разное
* [mavfwd для inav (односторонний msp) для камеры](user_TipoMan/mavfwd_mavlink2.tar?raw=true)
* [Отображение видео на windows и в MP](gstlaunch_on_windows.md)
* [Отключение watchdog на регистраторе hi3536dv100](note_nvr_wdt.md)
* [Отличный от 115200 baud на uartе камеры для телеметрии](note_telemetry_baud.md)

## Дорожная карта
* ~~Запуск видео с передачей с регистратора на пк.~~
* ~~Запуск одно-и двусторонней телеметрии.~~
* ~~Запуск передачи видео через usb tethering на android-планшет.~~
* ~~Сборка и тестирование прошивки LTE на e3372h + zerotier~~
* ~~Запуск маршрутизации телеметрии через mavlink-router.~~
* ~~Поиск путей управления камерой сквозь mavlink~~.
* Поиск способов вывода видео и osd через hdmi.
* ~~~Переключение между несколькими камерами, где одна ведущая с wfb-ng, а остальные ведомые.~~~
* Разработка платы расширения для камеры: bec 5v/3.3v; usb hub, uart, транзистор питания wifi/modem, microSD.
* Разработка платы управления зум-объективом и способа управления имеющимися в продаже платами.
* Разработка стабилизирующего подвеса, управляемого с земли сквозь wfb-ng.
56 changes: 56 additions & 0 deletions translated_sandbox/en_notes_start_hi3536ev100.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
### Notes on NVR hi3536ev100 firmware on OpenIPC for FPV purposes
[RU](notes_start_hi3536ev100.md)

<details>
<summary>How memory works</summary>
To begin with, you need to figure out how the memory of the recorder (and the camera too) works and what needs to be flashed. Data is stored on spi-flash 16mb in the form of mtd blocks:

```
cat /proc/cmdline
mem=150M console=ttyAMA0,115200 panic=20 root=/dev/mtdblock3 rootfstype=squashfs init=/init mtdparts=hi_sfc:256k(boot),64k(env),2048k(kernel),8192k(rootfs),-(rootfs_data)
ls /dev/mtdb*
/dev/mtdblock0 /dev/mtdblock1 /dev/mtdblock2 /dev/mtdblock3 /dev/mtdblock4
```
As follows from the output, block zero is the u-boot bootloader; Next comes a block for storing environment variables (`printenv`, `setenv` commands are written to RAM, and `saveenv` saves it in this block); next is the uImage core; then rootfs.squashfs (immutable file system image); and finally rootfs_data or also overlay - a changeable part where differences from rootfs are written if you change any files. Thus, by clearing the overlay, we will reset the file system to default:
```
sf probe 0 #select a device
sf erase 0xA50000 0x500000 #we clean
reset #reboot nvr
```
It's even easier to reset the firmware to factory defaults using the `firstboot` command.

An address calculator for commands is available [here](https://openipc.org/tools/firmware-partitions-calculation). In our case, the rootfs partition: 8192kB, which means the start address of the overlay will be 0xA50000. For a camera with a flash of 8mB and a rootfs size of 5120kB, the addresses will be different, including environment variables!
</details>

The bootloader of this recorder does not have a password, and you can access it via uart/115200 baud by pressing Ctrl+C several times at startup while connected to the debug-uart port of the recorder via a usb-uart 3v3 adapter (ftdi, ch340). Debug uart is located opposite the VGA connector on the opposite edge of the board and is labeled gnd/tx/rx. We don't need to flash the bootloader, we don't need burn. Our ENVs (environment variables) are different from the factory ones, but they are easier to install directly from the bootloader line by line:
```
setenv ipaddr '192.168.0.222' #here is the ip in your subnet from the free ones
setenv serverip '192.168.0.107' #PC address with tftp server
setenv netmask '255.255.255.0'
setenv bootcmd 'sf probe 0; sf read 0x82000000 0x50000 0x200000; bootm 0x82000000'
setenv uk 'mw.b 0x82000000 ff 1000000;tftp 0x82000000 uImage.${soc}; sf probe 0; sf erase 0x50000 0x200000; sf write 0x82000000 0x50000 ${filesize}'
setenv ur 'mw.b 0x82000000 ff 1000000;tftp 0x82000000 rootfs.squashfs.${soc}; sf probe 0; sf erase 0x250000 0x800000; sf write 0x82000000 0x250000 ${filesize}'
setenv bootargs 'mem=192M console=ttyAMA0,115200 panic=20 root=/dev/mtdblock3 rootfstype=squashfs init=/init mtdparts=hi_sfc:256k(boot),64k(env),2048k(kernel),8192k(rootfs) ,-(rootfs_data)'
setenv osmem '192M'
setenv totalmem '256M'
setenv soc 'hi3536dv100'
#here we clear variables that are no longer needed
setenvda; setenv du; setenv dr; setenv dw; setenv dl; setenv dc; setenv up; setenv tk; setenvdd; setenv de; setenv jpeg_addr; setenv jpeg_size; setenv vobuf; setenv loadlogo; setenv appVideoStandard; setenv appSystemLanguage; setenv appCloudExAbility
saveenv #save the new variable environment
printenv #see if everything is ok
```
The original env and full dump of the chip (16mb backup of factory firmware in case of recovery) are available [here](https://github.com/OpenIPC/sandbox-fpv/tree/master/hi3536dv100/original_firmware).

As you may have noticed, the uk and ur variables store macros for the uImage and rootfs downloading them from [tftp server](https://pjo2.github.io/tftpd64/) specified in serverip variable. All addresses correspond to the bootargs variable, the contents of which specify the file system layout for the kernel at boot. The layout is different from the usual for goke/hisilicone cameras, our core is the same as lite/fpv, 2MB in size, but the file system is 8MB in size, like ultimate. The remaining ~5MB are used by the overlay (your changes to the files relative to the original rootfs). For firmware, use official builds from the releases page [openipc/firmware](https://github.com/OpenIPC/firmware/releases/download/latest/openipc.hi3536dv100-nor-fpv.tgz). The archive contains the kernel and file system.

So, after setting the variables, you can start flashing the remaining part. Start the tftpd server, put uImage.hi3536dv100 and rootfs.squashfs.hi3536dv100 in its root, select the appropriate network interface and run the macro in the bootloader: `run uk`. A series of commands must be executed, the output of which should indicate that the uImage file has been downloaded and flashed into flash. Similarly, run `run ur` to flash rootfs. If the addresses are set correctly, but the download is stuck at "Downloading", change the registrar address to a nearby free one: `setenv ipaddr '192.168.0.223'`.
If everything went without errors, do a `reset` and boot into the operating system, login root, password 12345.

The configs from the hi3536dv100 catalog are not relevant, but they may be of interest regarding connecting the tablet via usb/wifi/ethernet hotspot; you can transfer them, by analogy, to the configs of the official firmware or use separate bash scripts. Usually the essence of these changes is to determine the address of the connected tablet (which is the gateway for the registrar in cases where the tablet has a dhcp server) and specifying this address in an additional instance of wfb_rx for the video stream and for telemetry streams.

The firmware is updated via the Internet using the command `sysupgrade -r -k -n`.

<details>
<summary>Update without internet from /tmp</summary>
In the future, you can update the recorder's firmware by uploading the kernel and rootfs into the `/tmp` directory via WinSCP and running `sysupgrade --kernel=/tmp/uImage.hi3536dv100 --rootfs=/tmp/rootfs.squashfs.hi3536dv100 -z` . The `-z` parameter is needed if you do not have an Internet connection (does not update the sysupgrade script), `-n` will clear the user fs (overlay).
</details>
Binary file not shown.
Binary file added translated_sandbox/gk7205v200/88XXau.ko_8812_8821
Binary file not shown.
84 changes: 84 additions & 0 deletions translated_sandbox/gk7205v200/etc/init.d/S95majestic
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/bin/sh

DAEMON="majestic"
PIDFILE="/var/run/$DAEMON.pid"

DAEMON_ARGS="-s"

# shellcheck source=/dev/null
[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"

load_majestic() {
printf 'Starting %s: ' "$DAEMON"
[ -f /usr/bin/$DAEMON ] || echo -en "DISABLED, "
# shellcheck disable=SC2086 # we need the word splitting
[ -f /etc/coredump.conf ] && . /etc/coredump.conf
if [ "$coredump_enabled" ]; then
[ "$(cli -g .watchdog.timeout)" -lt "30" ] && cli -s .watchdog.timeout 30
ulimit -c unlimited && echo "|/usr/sbin/sendcoredump.sh" >/proc/sys/kernel/core_pattern
fi

cli -s .isp.sensorConfig /etc/sensors/imx307_i2c_2l_1080p.ini
cli -s .video0.size 1920x1080
cli -s .video0.fps 30

start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/usr/bin/$DAEMON" -- $DAEMON_ARGS

sleep .5

cli -s .isp.sensorConfig /etc/sensors/imx307_i2c_2l_720p_50fps.ini
cli -s .video0.size 1280x720
cli -s .video0.fps 50

killall -1 majestic

sleep 1
gkrcparams --MaxQp 30 --MaxI 2

status=$?
if [ "$status" -eq 0 ]; then
echo "OK"
else
echo "FAIL"
fi
return "$status"
}

# The daemon does not create a pidfile, and use "-m" to instruct start-stop-daemon to create one.
start() {
logger -s -p daemon.info -t $(ipcinfo -v) "Loading video system has started..."
export SENSOR=$(fw_printenv -n sensor)
load_majestic
}

stop() {
printf 'Stopping %s: ' "$DAEMON"
[ -f /usr/bin/$DAEMON ] || echo -en "DISABLED, "
start-stop-daemon -K -q -p "$PIDFILE"
status=$?
if [ "$status" -eq 0 ]; then
rm -f "$PIDFILE"
echo "OK"
else
echo "FAIL"
fi
return "$status"
}

restart() {
stop
sleep 1
reload
}

reload() {
load_majestic
}

case "$1" in
start|stop|restart|reload)
"$1";;
*)
echo "Usage: $0 {start|stop|restart|reload}"
exit 1
esac
77 changes: 77 additions & 0 deletions translated_sandbox/gk7205v200/etc/init.d/S98datalink
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/sh
#
# Start fpv datalink
#

. /etc/datalink.conf

chip=$(ipcinfo -c)
fw=$(grep "BUILD_OPTION" "/etc/os-release" | cut -d= -f2)

start() {
if ! [ -f /etc/system.ok ]; then
killall majestic
tweaksys ${chip}
fi

echo "Starting FPV datalink..."
if ! [ -f /etc/servicemode ]; then
echo "Start wlan0 in Service Mode (connect to your AP)"
rm -f /etc/servicemode
wpa_passphrase "ssid" "password" >/tmp/wpa_supplicant.conf
sed -i '2i \\tscan_ssid=1' /tmp/wpa_supplicant.conf
sleep 3
wpa_supplicant -B -D nl80211 -i wlan0 -c /tmp/wpa_supplicant.conf
ifconfig wlan0 up
udhcpc -x hostname:openipc-servicemode -T 1 -t 5 -R -b -O search -i wlan0
else
if [ ${fw} = "lte" ]; then
if [ ${usb_modem} = "true" ]; then
echo "Starting lte modem configuration..."
echo "ToDo: Running usb_modeswitch or other shit here..."
fi
# for the future
#cli -s .outgoing.url1 udp://${gs_ipaddr}:${gs_port}
if [ ${use_zt} = "true" ]; then
echo "Starting ZeroTier-One daemon..."
/usr/sbin/zerotier-one -d &
if [ ! -f /var/lib/zerotier-one/networks.d/${zt_netid}.conf ]; then
sleep 8
zerotier-cli join ${zt_netid} &> /dev/null
echo "Don't forget authorize in the my.zerotier.com!"
fi
fi
if [ ${telemetry} = "true" ]; then
/usr/bin/telemetry start
fi
else
echo "Starting wifibroadcast service..."
/usr/bin/wifibroadcast start
fi
fi
}

stop() {
echo "Stopping all services..."
kill -9 $(pidof wfb_tx)
kill -9 $(pidof telemetry_rx)
kill -9 $(pidof telemetry_tx)
kill -9 $(pidof mavlink-routerd)
kill -9 $(pidof mavfwd)
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
Loading