Yi 4k (Z16VxxL) custom firmware and more (UPDATE : 20/12/20 - Release 1.10.52 - Ethernet-over-USB)

psolyca

Member
Joined
Jul 30, 2018
Messages
65
Reaction score
27
Country
France
TESTED ONLY ON Yi 4k i.e. Z16V13/14L**, should work on all Z16V12L to Z16V18L.

To control my cam, I prefer to use the station mode of Wi-Fi cause I do not want to switch between wifi tethering and wifi station on my phone everytime I want to use my cam.

I needed a way to unpack and repack my firmware easily, thus I have created python scripts heavely inspired from dji-firmware-tools.
Get it here : https://raw.githubusercontent.com/p...a/unpacker/firmware_unpacker/amba_fwpak_yi.py (only for 4k not 4k+)
I also modified the script to extract romfs (ROMFS or DSP uCode ) : https://raw.githubusercontent.com/p...a/unpacker/firmware_unpacker/amba_romfs_yi.py

Custom firmware - Copy the firmware on the SDCard and rename it firmware.bin
Firmware 1.10.52 based on 1.10.9​
Firmware have now a custom number when installing.
To be able to debug please add the firmware version to any question (see "menu/hardware information/version").
The first of that kind is the 1.10.50.
This firmware run a python script in the background when events manager is loading, I did not test battery discharge.


Changelog
General information
If you want to make your own firmware, feel free to grab a diff and patch your firmware.​

This firmware has also the ability to load a script named Wifi.sh on STA.DEBUG or AP.DEBUG folders on the SDCard essentially for debugging purpose (station and AP mode).​

Wi-fi instructions
Instruction on the wiki

Events manager instructions
Instruction on the wiki

Scripts booting
For events boot, a file called "events_boot.py" should be created in the events folder (file template)
For bash script, a file called "bootcmd.sh" should be created on the root of the SDCard (no file template)

More to come.../ Todo list
  • update to 1.10.9 firmware
  • clean uneeded files unless other hardware configuration exist,
  • BT control by phone, do not know if possible,
  • Launch script(s) on USB connection (power or other)
  • custom shutter speed in video mode instead of auto
  • loops (recorded in 10x slowmotion :) ) to be shorter
  • other ?
Github repositories :
Update :
  • 20/12/20 : Wifi scripts redone, custom connections, Ethernet-over-USB
  • 20/07/15 : Stuffs and bug fixes
  • 18/11/07 : Add boot scripts
  • 18/09/13 : Add events callback (aka event manager)
  • 18/08/25 : Fix EOL for configuration files on the SDCard
  • 18/08/22 : Add instructions for wifi configuration
  • 18/08/08 : Fix station mode for 1.10.9 firmware (fix loop if configured AP is not found)
  • 18/07/30 : New 1.10.9 firmware
Thanks :
 
Last edited:
Hi,

I got the firmware loaded successfully and am having trouble getting the camera to join my network. Do you have an example conf that I need to use/ any instructions on how to get the camera to join a wifi network. I'm trying to get them to all join my AP so I can telnet and start them all remotely. With this firmware I've tried multiple conf and sh file attempts and got no luck the wifi would flash and eventually become solid but I wouldn't see it on my DHCP client list. Thanks!
 
Hello,

Thanks to try it.

First to know if it is a configuration or a script trouble, you go to the configuration menu -> Wifi -> Wifi information
  • If the SSID is FAKE, it is a configuration trouble,
  • If the SSID is YDXJ_AP_xxxxx, it is a script trouble.
Cause FAKE is used if the AP is not found and YDXJ_AP_xxxxx is a default value if the script fails.

To configure properly the wifi (I will update the OP with these instructions) :
  • Create a file called wifi.conf at the root of your SDCard (case sensitive so wifi.conf not Wifi.conf)
  • To connect to an AP (your case), add these parameters (minimal) :
Code:
##### STA mode configuration ##########################################
# ESSID
ESSID=your_AP_SSID
# Passphrase. Leave empty at no security mode
PASSWORD=your_AP_password
# Device Name for AMBA Discovery Protocol (optional)
STA_DEVICE_NAME=the_name_you_want_to_use_for_your_cam (different for each cam)
  • To create an AP, add these parameters :
Code:
##### SoftAP configuration ##########################################
# SSID (1 ~ 32 characters) default name is YDXJ_AP which is followed by random number, different each time, so change it to the name you want
AP_SSID=the_name_you_want
# IP address (default one)
LOCAL_IP=192.168.42.1
# IP subnet mask
LOCAL_NETMASK=255.255.255.0
# IP pool starting address of DHCP server
DHCP_IP_START=192.168.42.2
# IP pool end address of DHCP server (should be DHCP_IP_START + AP_MAXSTA - 1)
DHCP_IP_END=192.168.42.6
# Wifi channel number, set 0 to use Auto Channel Selection
AP_CHANNEL=0
# Wifi channel 5G/2.4G, set 0 to use 2.4G Channel/set 1 to use 5G
AP_CHANNEL_5G=0
# Maximum number of stations allowed in station table
AP_MAXSTA=5
# If you say yes here, all WPA/WEP settings will be ignored
AP_PUBLIC=no
# WPA Passphrase (8 ~ 63 characters)
AP_PASSWD=the_password_you_want

Both parameters could be used in the same wifi.conf file.
The choice is done in the wifi menu, station mode (your case, to connect to an AP) or AP mode (to create an AP).

To debug the wifi if it is a script problem, you can provide your wifi.log file created on your SDCard root.
I will give you more instructions later if needed.
 
Thank's you psolyca !

I tried your firmware with a correct wifi.conf but it doesn't work. By the way, nothing is written in my empty wifi.log created on SDCard
But my Yi 4K action camera is Z16V14L not Z16V13L, do you think it's a problem ?

With an other YI 4K action camera ( older i think, maybe Z16V13L i have to check) , i success to connect a camera to an AP, but with firmware 1.3.0 and sta.conf on SDCard but, this solution doesn't work for my new camera...
if you have any idea ?

thank's
 
Hey !

Following your message, I tried to see if Z16V14L has the same based firmware and they are the same. I have also seen that there are Z16V12L to Z16V18L revisions of the cam but each time I have the same firmware proposed to download.

With my firmware, does your cam freeze when you try the wifi.conf ? What is the SSID in wifi information menu ?
Empty wifi.log could be a result of bad script launch.

Could you create these empty files on your SDCard root : console_enable.script and save_log_enable.script.
You will have more log files on your SDCard root i.e. RtosActive.log, RtosOlder.log ... could you provide them, I will check.

I will also try, this weekend, to provide you a script to get all relevant information.
 
no freezing, the wifi icon is blinking, and when it stop , i can see "FAKE" on the wifi info menu

If i try to chage 5Gz to 2.4Gz, the camera is busy, impossible to change
wifi.log :
Code:
=================================================================
Call_Time: Fri Aug 24 14:36:52 UTC 2018
Call_Script: /usr/local/share/script/wifi_configure.sh AP_CHANNEL_5G=1 AP_SSID=YDXJ_4032405_5G AP_PASSWD=1234567890 AP_COUNTRY=US WIFI_MAC=58:70:C6:3D:87:95 WIFI_MODE=sta CHIP_TYPE=43340
=================================================================
SET Wi-Fi Config > AP_CHANNEL_5G=1
SET Wi-Fi Config > AP_SSID=YDXJ_4032405_5G
SET Wi-Fi Config > AP_PASSWD=1234567890
SET Wi-Fi Config > AP_COUNTRY=US
SET Wi-Fi Config > WIFI_MAC=58:70:C6:3D:87:95
SET Wi-Fi Config > WIFI_MODE=sta
SET Wi-Fi Config > CHIP_TYPE=43340

----------------------------call result ok-----------------------



=================================================================
Call_Time: Fri Aug 24 14:36:52 UTC 2018
Call_Script: /usr/local/share/script/wifi_xc_restart.sh ctype=1 dscantime=0 drestart=0
=================================================================
stop Wi-Fi ...
killall hostapd dnsmasq udhcpc wpa_supplicant wpa_cli wpa_event.sh
t gpio 124 sw out0
start Wi-Fi from system ...
Load wifi.conf from SDCard ...
restart Wi-Fi finished ...





bt.log
Code:
=================================================================
Call_Time: Fri Aug 24 14:27:40 UTC 2018
Call_Time: Fri Aug 24 14:27:40 UTC 2018
Call_Script: /usr/local/share/script/bt_configure.sh addr= type= name=
Call_Script: /usr/local/share/script/bsa_start.sh 58:70:C6:92:DC:EA 43340
=================================================================
=================================================================
SET BT Config > addr=
get mac from rtos : 58:70:C6:92:DC:EA
open buletooh bsa
SET BT Config > type=
t gpio 12 sw out0
SET BT Config > name=

----------------------------call result ok-----------------------
 
If the SSID is FAKE, it is a configuration file trouble usually.

First, as I see you are french, try to change your country code in your cam menu to "FR" OR add a line to your configuration file AP_COUNTRY=FR
Edit your wifi.conf file with notepad++ and change encoding to 'UTF-8 without BOM' and EOL Conversion to 'UNIX/OSX Format', in case.

BTW, when you create the empty files as I mention earlier, you have to boot twice to be able to have new log files.
I do not see any error message in your wifi.log file as it should be.
 
it work's !!!!
it was because of Windows end of line. With Unix, it's ok ( strange, i use Fedora and gedit and it was windows EOL! )

Thank you very much ;)
 
Ok, thanks for the feedback.

I have the right command to handle the conversion automatically for all files editable on the SDCard.
 
Is there a way to create a car mode for Yi 4k/4k+? A script to turn camera on and start recording when it detects power and to stop recording and shut off after 5 sec when it stops receiving power?
 
I do not think so.
Cause to be able to turn the camera on when the power is connected, your cam have to be in a standby mode to wait for the connection and then start the script. But cam do not have this ability.
By the way, if your cam is already switch on, maybe you can launch a script which detect a USB connection and then launch everything you want.

I can add this in my ToDo list but I have some trouble with Bluetooth mod.
 
I figured as much. Without changing firmware, we're forced to use scripts at start. I am guessing car mode like in ThiEye E7 or ELE Explorer K is not possible without redoing the full firmware.

It would be nice to allow the camera to start recording when it detects power while it's on then when it loses power to go into sleep mode until it detects power again. I don't know if there's even a 'sleep/standby' mode which can be done with scripts.

I look forward seeing what you can do with this stuff. Good luck.
 
It is on my ToDo list.

I am thinking out loud
We need to redo the firmware but just create an init script (better way I think than modifying an existing script) that is able to launch all scripts in a particular folder (like for WIFI debug).
This script could be launch after all others (init behaviour, i.e. S99-afterstart.sh).
Autoexec.ash is a good way also but to dependent on the RTOS and commands are to long (t rpc ...).

I will see, maybe sooner than I think, Bluetooth is a headhache, I have to create an app to be able to control it with my phone as I do not have a remote control.
 
A little backlog of my job on the firmware.

I am on my way to launch scripts at start.

First I needed a way to control the cam from the Linux part cause all controls are natively done by the RTOS.
So the only easy way is by using the remote API in local mode and it is a success. Maybe a better way is the native amba soft but I am looking for a basic implementation.
I have two solutions then using only bash scripts and for now it is not a success or python scripts and it is ok (console mode).

Then for your special need @Leo_SF , there is no simple way to check the USB connection from within Linux part as only power is transmitted (I have to investigate more). I may have found a way with the remote API and a cron job.
 
Hi! Is there a way to increase the bitrate of videos broadcast using live mode? I would love to be able to pick an arbitrary bitrate between 1Mbps and 10Mbps (in 0.5 increments). 1080p looks horrible at 1.5Mbps which is the current maximum.
 
Hey !

Sorry, for now I did not look after video parameters and modifications. Live stream should depend of wifi speed I think. so do not know if you can rise the max bitrate.

Envoyé de mon EVA-L09 en utilisant Tapatalk
 
6Mbps should be easy as that translates to less than 1 MB/sec. It's just frustrating when you see people on other livestreaming sites using cameras such as the X3000 or DSLRs connected to an HDMI encoder, and then uploading at 3Mbps or higher on the cellular network. Yi is 90% of the way there -- the only thing that needs to change are the available bitrates.

I tried messing with the QR codes, putting in values greater than 3 in the "rate" parameter, but it doesn't seem to have an effect. I'm guessing that these numbers or corresponding rates are just hardcoded in the firmware somewhere, and it shouldn't be too difficult to add additional values.
 
BTW, if it is hardcoded in the RTOS, it will be more difficult to modify it. The only way is for now autoexec.ash and memory hacking. I could add it to my todo list or if someone wants to help, every thing is on my repository to easily decompress a firmware [emoji14][emoji14]

Edit: you can not add something by memory hacking, you can only modify existing values as I understand.
Envoyé de mon EVA-L09 en utilisant Tapatalk
 
Well - I kinda figured it out. I found in the squashfs Linux partition where it sends commands to the RTOS to configure the bitrate. My question is how can I figure out which memory addresses to look at and modify based on this info?

I documented what I found here: https://github.com/irungentoo/Xiaomi_Yi_4k_Camera/issues/83

RTSP_CONF()
{
if [ "${RTMP_CONFIG_SIZE}" == "720p" ]; then
/usr/bin/SendToRTOS rtmp 80
elif [ "${RTMP_CONFIG_SIZE}" == "1080p" ]; then
/usr/bin/SendToRTOS rtmp 81
elif [ "${RTMP_CONFIG_SIZE}" == "360p" ]; then
/usr/bin/SendToRTOS rtmp 83
else
/usr/bin/SendToRTOS rtmp 82
fi

if [ "${RTMP_CONFIG_RATE}" -eq 3 ]; then
/usr/bin/SendToRTOS rtmp 96
elif [ "${RTMP_CONFIG_RATE}" -eq 2 ]; then
/usr/bin/SendToRTOS rtmp 97
elif [ "${RTMP_CONFIG_RATE}" -eq 1 ]; then
/usr/bin/SendToRTOS rtmp 98
else
/usr/bin/SendToRTOS rtmp 99
fi
}
 
@reedog117 Thanks for the information. I will try to look at this after for my firmware 1.1.

@Leo_SF here is a teaser of my current job, launching command on event from the cam.
For now it is just from my computer but everything is ready to be pushed on the cam, just some bash scripting left.

Bash:
2018-09-11 22:43:20,207 -- root -- INFO -- Wait...
2018-09-11 22:43:20,209 -- root -- INFO -- Res {u'rtsp': u'rtsp://192.168.42.1/live', u'model': u'Z16', u'rval': 0, u'msg_id': 257, u'param': 10}
2018-09-11 22:43:20,209 -- root -- INFO -- Callback
2018-09-11 22:43:20,710 -- root -- INFO -- Wait...
2018-09-11 22:43:23,921 -- root -- INFO -- Res {u'msg_id': 7, u'type': u'adapter_status', u'param': u'1'} <=== adaptater connected
2018-09-11 22:43:23,921 -- root -- INFO -- Callback static
2018-09-11 22:43:23,923 -- root -- INFO -- Event: adapter_status, 1
2018-09-11 22:43:24,430 -- root -- INFO -- Wait...
2018-09-11 22:43:24,433 -- root -- INFO -- Res {u'type': u'rec_mode', u'rval': 0, u'msg_id': 2, u'related': 1, u'param': u'record'} <=== change mode to video
2018-09-11 22:43:24,433 -- root -- INFO -- Callback
2018-09-11 22:43:24,436 -- root -- INFO -- setRecordMode: 0, record
2018-09-11 22:43:24,940 -- root -- INFO -- Wait...
2018-09-11 22:43:25,233 -- root -- INFO -- Res {u'rval': 0, u'msg_id': 513} <=== start recording
2018-09-11 22:43:25,233 -- root -- INFO -- Callback
2018-09-11 22:43:25,236 -- root -- INFO -- startRecording: None
2018-09-11 22:43:25,739 -- root -- INFO -- Wait...
2018-09-11 22:43:25,740 -- root -- INFO -- Res {u'msg_id': 7, u'type': u'start_video_record'}
2018-09-11 22:43:25,742 -- root -- INFO -- Callback static
2018-09-11 22:43:25,743 -- root -- INFO -- Event: start_video_record
2018-09-11 22:43:25,755 -- root -- INFO -- Res {u'msg_id': 7, u'type': u'battery_status', u'param': u'0'}
2018-09-11 22:43:25,756 -- root -- INFO -- Callback static
2018-09-11 22:43:25,756 -- root -- INFO -- Event: battery_status, 0
2018-09-11 22:43:25,766 -- root -- INFO -- Res {u'msg_id': 7, u'type': u'adapter', u'param': u'58'}
2018-09-11 22:43:25,766 -- root -- INFO -- Callback static
2018-09-11 22:43:25,767 -- root -- INFO -- Event: adapter, 58
2018-09-11 22:43:26,273 -- root -- INFO -- Wait...
2018-09-11 22:43:35,683 -- root -- INFO -- Res {u'msg_id': 7, u'type': u'adapter_status', u'param': u'0'} <==== adaptater disconnected
2018-09-11 22:43:35,684 -- root -- INFO -- Callback static
2018-09-11 22:43:35,684 -- root -- INFO -- Event: adapter_status, 0
2018-09-11 22:43:36,188 -- root -- INFO -- Wait...
2018-09-11 22:43:36,190 -- root -- INFO -- Res {u'rval': 0, u'msg_id': 514} <=== stop recording
2018-09-11 22:43:36,190 -- root -- INFO -- Callback
2018-09-11 22:43:36,690 -- root -- INFO -- Wait...
2018-09-11 22:43:36,691 -- root -- INFO -- Res {u'msg_id': 7, u'type': u'battery_status', u'param': u'0'}
2018-09-11 22:43:37,193 -- root -- INFO -- Wait...
2018-09-11 22:43:37,312 -- root -- INFO -- Res {u'msg_id': 7, u'type': u'battery_status', u'param': u'0'}
2018-09-11 22:43:37,812 -- root -- INFO -- Wait...
2018-09-11 22:43:37,813 -- root -- INFO -- Res {u'sdate': u'2018-09-11 22:43:20', u'mdate': u'2018-09-11 22:43:20', u'sub': u'/tmp/fuse_d/DCIM/100MEDIA/YDXJ0239.SEC', u'msg_id': 7, u'param': u'/tmp/fuse_d/DCIM/100MEDIA/YDXJ0239.MP4', u'msize': 98958691, u'type': u'video_record_complete', u'ssize': 1498147}
2018-09-11 22:43:37,815 -- root -- INFO -- Callback
2018-09-11 22:43:37,818 -- root -- INFO -- stopRecording: /tmp/fuse_d/DCIM/100MEDIA/YDXJ0239.MP4
2018-09-11 22:43:38,319 -- root -- INFO -- Wait...
2018-09-11 22:43:38,319 -- root -- INFO -- Res {u'msg_id': 7, u'type': u'vf_start'}
2018-09-11 22:43:38,321 -- root -- INFO -- Res {u'msg_id': 7, u'type': u'battery', u'param': u'58'}
2018-09-11 22:43:38,322 -- root -- INFO -- Callback static
2018-09-11 22:43:38,322 -- root -- INFO -- Event: battery, 58
2018-09-11 22:43:38,834 -- root -- INFO -- Wait...

All API commands are availabled.
To be continued...
 
Back
Top