2

New to script writing, new to bash, new to firmware modifications, but... enthusiastic as all get out.

Here's the link to my camera's firmware.

I'm trying to edit and replace the bitrate values specific to recording on this camera and I need some help. I've used a hex editor to find the bitrate values but I haven't found them yet. Still looking... In the meantime I'd like to see if I could change the value of the firmware version using the script, just to test it out and see if it actually works.

I believe the firmware version information is stored in the paramdef file. If you open it in hex and search for the firmware version you'll find it in D0B0 (at the bottom of the hex). I want to change the 3 to a 4 value in a bash file and see if it works in the camera when I boot it with a test.sh bash script.

  1. I need to know how to reference the hex line in the bash script
  2. I need to know how to replace the value in the hex line with my bash script

I'm thinking if I can get some positive traction on this script I'll eventually be able to edit the bitrate values of my camera.

I'm also not able to flash the same firmware to my camera over and over. It'll only flash a new version. I'm wondering if it's something to do with the system script at the beginning of the firmware files:

From config.file:

setenv bootargs 'mem=96M quiet console=ttyAMA0,115200 clk_ignore_unused rw root=/dev/mtdblock5 rootfstype=jffs2 mtdparts=hi_sfc:384K(u-boot-GR01V2_2_2GDDR3.bin),64K(rawparam),64K(rawparambak),2944K(media_app_zip.bin),2560K(uImage),1920K(rootfs.jffs2),8064K(appfs.jffs2)'
setenv bootcmd 'sf probe 0;sf read 0x84000000 0x60000 0x10000;sf read 0x84100000 0x70000 0x10000;cread 0x84000000 0x84100000 0x10000 0x80100000;go_cpu1 0x80200000 0x89000000 0x80000 0x2e0000;sf read 0x84000000 0x360000 0x280000;bootm 0x84000000'
setenv swverv2 'S2_GR01V2_2_2GDDR3_0303111844'

Edit: I still haven't found what I'm looking for (u2...)... I'm beginning to think it might be found in the U-boot commands? The Config file has the setenv command which I believe is read by the Linux command structure??? I wanted to see if it would just work on boot and I created a bash.sh file that reads: ''' echo 'This is a test' > foo.txt '''

2
  • This is as far as I've gotten: chmod +x ~/test.sh ~/myscript.sh $ sed '' 's/\xD0\xB0\ Jul 2, 2020 at 12:43
  • I can't edit the firmware then reflash to the camera right now...every time I try to reflash it doesn't load...so I figured I'd go with a bash Jul 2, 2020 at 14:05

2 Answers 2

0

Using xxd, dd and printf:

The version number V2.1.0.3-A can be found here (lines 3339-3340):

$ xxd paramdef
...
0000d0a0: 0000 0000 0000 0000 0056 322e 312e 322e  .........V2.1.2.
0000d0b0: 332d 4200 0000 0000 0000 0000 0000 0000  3-B.............
...

and the string begins at d0a9 hex = 53417 dec (converted using printf '%d' 0xd0a9).

Let's overwrite the version string with V2.1.2.3-B:

printf 'V2.1.2.3-B' | dd of=paramdef bs=1 seek=53417 conv=notrunc

Or the equivalent using hex data:

# helper output
$ printf 'V2.1.2.3-B' | xxd -p
56322e312e322e332d42

$ xxd -r -p <<<'56322e312e322e332d42' | dd of=paramdef bs=1 seek=53417 conv=notrunc

To change 3 to 4 at d0b0 in a one-liner:

printf '4' | dd of=paramdef bs=1 seek=$(printf '%d' 0xd0b0) conv=notrunc
2
  • SO something like this? drive.google.com/file/d/1ATZZu2eFjD5oLSpJieW0baLHjcifJbp3/… Jul 2, 2020 at 17:23
  • To change the 3 to 4 you only need the line printf '4' | dd of=paramdef bs=1 seek=$(printf '%d' 0xd0b0) conv=notrunc in your script. And don't forget to add a shebang #!/bin/bash as the first line of your bash script. The remaining stuff in my answer are just examples including output printed to the terminal. The chmod +x ~/test.sh should be done in the terminal to make your script executable, it doesn't belong in your script. And of course make a backup of paramdef before you modify it.
    – Freddy
    Jul 2, 2020 at 17:36
0

So I'm still working on this:

I'm trying to edit the firmware loading file which wouldn't make any sense...so I need to actually edit the executable files within the action camera...

So I've done some research and I've come up with the following codes: constexpr static const VENC_H265_CBR_S defH265Cbr = { .u32Gop = 50, .u32StatTime = 5, .u32SrcFrameRate = 25, .fr32DstFrameRate = 25, .u32BitRate = 20480 };

constexpr static const VENC_H265_VBR_S defH265Vbr =
{
    .u32Gop                 = 50,
    .u32StatTime            = 5,
    .u32SrcFrameRate        = 25,
    .fr32DstFrameRate       = 25,
    .u32MaxBitRate          = 20480

Do I need to create a bash script to search for this exact line item within a specific file or can I just write the bash somehow to edit the .u32MaxBitRate?

2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .