Cross compile TestDisk for Synology NAS

From CGSecurity
Jump to navigation Jump to search

En.png English It.png Italiano


Before beginning

  • https://synocommunity.com/ is hosting a testdisk package for most Synologie, you may not have to compile it for yourself.
  • spksrc is a cross compilation framework intended to compile and package software for Synology NAS devices. Using the docker image from https://github.com/SynoCommunity/spksrc may be a faster way to grab the necessary toochain.

Otherwise, to compile TestDisk & PhotoRec for a Synology NAS on a Linux computer,

  • Read DSM Developer Guide
  • Identify the model/processor, example CS/RS407, DS207+, DS107+ Marvell 5281 ARM Little Endian 2.6

CS/RS407, DS207+, DS107+ Marvell 5281 ARM Little Endian 2.6

  • Download the corresponding toolchain files, example gcc343_glibc232_88f5281.tar.gz
  • Install the tool chain

as root,

tar xpzf gcc343_glibc232_88f5281.tar.gz -C /usr/local
  • Create symbolic links for the tool chain
sudo ln -s /usr/local/arm-marvell-linux-gnu/bin/arm-marvell-linux-gnu-gcc /usr/local/bin
sudo ln -s /usr/local/arm-marvell-linux-gnu/bin/arm-marvell-linux-gnu-ld /usr/local/bin
sudo ln -s /usr/local/arm-marvell-linux-gnu/bin/arm-marvell-linux-gnu-ranlib /usr/local/bin
  • Download and decompress TestDisk & PhotoRec (Latest version is usually recommended).
wget -N https://www.cgsecurity.org/testdisk-7.0.tar.bz2
tar xjf testdisk-7.0.tar.bz2
  • Compilation
cd testdisk-7.0
./compile.sh arm-marvell-linux-gnu

Synology DS-409 Slim

Let's gather the information

  • Synology 409slim / CPU: Marvell 6281 / ARCH: ARM / Little Endian
  • Linux Version: 2.6.24
  • DSM Version: 3.2-1922
  • DSM Tool Chain: gcc421_glibc25_88f628x.tgz

Now we have everything to start.

  • Download the corresponding tool chain: gcc421_glibc25_88f628x.tgz
  • Install the tool chain

as root,

tar xpzf gcc421_glibc25_88f628x.tgz -C /usr/local
  • Create symbolic links for the tool chain
sudo ln -s /usr/local/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-gcc /usr/local/bin/
sudo ln -s /usr/local/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-ld /usr/local/bin/
sudo ln -s /usr/local/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-ranlib /usr/local/bin/
sudo ln -s /usr/local/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-strip /usr/local/bin/
  • Download and decompress TestDisk & PhotoRec source code
wget -N https://www.cgsecurity.org/testdisk-6.12.tar.bz2
tar xjf testdisk-6.12.tar.bz2
  • Compilation
cd testdisk-6.12
./compile.sh arm-none-linux-gnueabi