faq обучение настройка
Текущее время: Чт мар 28, 2024 14:30

Часовой пояс: UTC + 3 часа




Начать новую тему Ответить на тему  [ Сообщений: 20 ]  На страницу 1, 2  След.
Автор Сообщение
СообщениеДобавлено: Пт авг 08, 2014 22:37 
Не в сети

Зарегистрирован: Пт июн 27, 2008 12:20
Сообщений: 71
Откуда: Киев
Взялся собрать обновлённую прошивку для DNS-315. Вот только инструкция в исходниках не совсем понятна.
REDME:
Скрытый текст: показать
1.Please follow the below procedure to build a working f/w :
1.1 tar jxvf DNS-315_GPL_v1.00_01162012.tar.bz2
1.2 cd DNS-315_GPL/
1.3 source build_fw
Note :
a. the default name of generated F/W is : GPL/merge/DNS-315_firmware.
b. upload the DNS-315-firmware through device GUI

2. GPL Modules list :
2.1. crosstool.tar.bz2
2.2. afp_module.tar.bz2
2.3. attr-2.4.41.tar.bz2
2.4. avahi-0.6.30.tar.bz2
2.5. boost_1_44_0.tar.bz2
2.6. boost-jam-3.1.18.tgz
2.7. busybox-1.11.2.tar.bz2
2.8. cgic205.tar.bz2
2.9. chardetect.tar.bz2
2.10. coreutils-8.9.tar.bz2
2.11. curl-7.19.7.tar.bz2
2.12. DDNS_tools.tar.bz2
2.13. e2fsprogs-1.41.14.tar.bz2
2.14. e2fsprogs-libs-1.41.14.tar.bz2
2.15. expat-2.0.1.tar.bz2
2.16. fuse-2.8.4.tar.bz2
2.17. gd_cluster.tar.bz2
2.18. gdisk-0.6.13.tar.bz2
2.19. i2c-tools-3.0.2.tar.bz2
2.20. imgconvert.tar.bz2
2.21. inotify-tools-3.13.tar.bz2
2.22. iTunes_server.tar.bz2
2.23. jpeg-7.tar.bz2
2.24. libdaemon-0.14.tar.bz2
2.25. libgcrypt-1.5.0-beta1.tar.bz2
2.26. libgpg-error-1.10.tar.bz2
2.27. libiconv-1.9.2.tar.bz2
2.28. libid3tag-0.15.1b.tar.bz2
2.29. libpng-1.2.39.tar.bz2
2.30. libs3-1.4.tar.bz2
2.31. libtool-1.5.6.tar.bz2
2.32. libtorrent-rasterbar-0.15.4.tar.bz2
2.33. libusb-0.1.12.tar.bz2
2.34. libxml2-2.7.4.tar.bz2
2.35. lighttpd-1.4.28.tar.bz2
2.36. LLTD-PortingKit.tar.bz2
2.37. LPRng-3.8.10.tar.bz2
2.38. msmtp-1.4.15.tar.bz2
2.39. mtp.tar.bz2
2.40. mutt-1.5.18.tar.bz2
2.41. ncurses-5.5.tar.bz2
2.42. net-tools-1.60_p20110409135728.tar.bz2
2.43. nfs.tar.bz2
2.44. ntfs-3g-2010.3.6.tar.bz2
2.45. ntp-4.2.2p4.tar.bz2
2.46. nut-2.2.0.tar.bz2
2.47. openssh-5.0p1.tar.bz2
2.48. openssl-0.9.8m.tar.bz2
2.49. pcre-7.6.tar.bz2
2.50. Perl.tar.bz2
2.51. php-5.2.10.tar.bz2
2.52. popt-1.16.tar.bz2
2.53. pure-ftpd-1.0.29.tar.bz2
2.54. quota-tools-3.17.tar.bz2
2.55. rsync-3.0.7.tar.bz2
2.56. samba-3.5.6.tar.bz2
2.57. sg3_utils-1.28.tar.bz2
2.58. shadow-4.0.18.2.tar.bz2
2.59. smartmontools-5.39.1.tar.bz2
2.60. sqlite-3.6.14.1.tar.bz2
2.61. sysklogd-1.5.tar.bz2
2.62. tinylogin-1.4.tar.bz2
2.63. unzip60.tar.bz2
2.64. util-linux-ng-2.14.2.tar.bz2
2.65. wget-1.12.tar.bz2
2.66. zip30.tar.bz2
2.67. zlib-1.2.3.tar.bz2
2.68. linux-kernel.tar.bz2
2.69. bootcode.tar.bz2
2.70. Binary.tar.bz2
3. Non-GPL module list :
3.1 Binary.tgz include all binary codes which not related to GPL.

И по компиляции build_fw :
Скрытый текст: показать
WORKDIR=$(pwd)
echo $WORKDIR
if [ -e /opt/crosstool ];then
echo -e "\033[31m Toolchain have been installed \033[0m"
else
echo -e "\033[31m Toolchain installing ... \033[0m"
cd /opt
tar jxf $WORKDIR/GPL/crosstool.tar.bz2
echo -e "\033[31m Done \033[0m"
fi

cd $WORKDIR/GPL

export WORKDIR
PATH=/opt/crosstool/OXNAS820/gcc-4.2.4-glibc-2.7-toolchain/cross-tools/bin:$PATH
export PATH
export CROSS_COMPILE=arm-linux-
CC=${CROSS_COMPILE}gcc
AS=${CROSS_COMPILE}as
LD=${CROSS_COMPILE}ld
AR=${CROSS_COMPILE}ar
RANLIB=${CROSS_COMPILE}ranlib
CPP=${CROSS_COMPILE}cpp
CXX=${CROSS_COMPILE}g++
NM=${CROSS_COMPILE}nm
STRIP=${CROSS_COMPILE}strip
export CC AS LD AR RANLIB CPP CXX NM STRIP
echo -e "\033[31m CC AS LD AR RANLIB CPP CXX NM STRIP \033[0m"

echo $PWD
tar zxvf ramdisk.tgz
tar zxvf merge.tgz
cd merge
sudo cp ../ramdisk/uRamdisk .
./merge
Ну хоть немного попонятней расписали. Ну ладно я догадался что неоходим линух , установил Red Hat. Ну а что дальше только догадываться и юзать метод научного тыка . Может кто направит в нужное русло ??


Вернуться наверх
 Профиль  
 
СообщениеДобавлено: Пт авг 08, 2014 22:48 
Не в сети

Зарегистрирован: Пт июн 27, 2008 12:20
Сообщений: 71
Откуда: Киев
Нашол пример компиляции прошивки из исходников под Red Hat:
Скрытый текст: показать
I. Компиляция
Для закачки и установки необходимого софта потребуется ~500 MB свободного места на HDD.
Скачиваем исходники (~100 MB) с ftp-сервера D-Link:

[root@localhost gpl]# wget ftp://ftp.dlink.ru/pub/ADSL/GPL_source_ ... GPL.tar.gz


Распаковываем:

[root@localhost gpl]# gunzip -c RU_DSL-2640U_3-06-04-3C_GPL.tar.gz | tar xvf -
consumer_install
README
RU_DSL-2640U_3-06-04-3C_consumer.tar.gz
RU_DSL-2640U_3-06-04-3C_uclibc_crosstools_3.4.2_0.9.27.tar.gz



Читаем инструкцию:

[root@localhost gpl]# cat README
RU_DSL-2640U Open Source Release

This release contains all of the files needed to build a RU_DSL-2640U image.
To build an image, please follow the below process:

1. System Request:
Redhat Linux 9.0

2. All operations should be performed as the "root" user

3. Install tools and source code
#./consumer_install

4. Build image:
# cd RU_DSL-2640U_3-06-04-3C
# make PROFILE=RU_DSL-2640U

The final image is located in the targets/RU_DSL-2640U subdirectory.
Specify this image in the RU_DSL-2640U Web interface image upgrade
item in order to upgrade the device image.


Red Hat Linux 9.0:

[root@localhost gpl]# uname -a
Linux localhost.localdomain 2.4.20-8 #1 Thu Mar 13 17:54:28 EST 2003 i686 i686 i386 GNU/Linux
[root@localhost gpl]# gcc -v
gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)


Запускаем скрипт установки:

[root@localhost gpl]# ./consumer_install


Скрипт предлагает установить на ПК компоненты, необходимые для сборки firmware Broadcom DSL modem/router, нажимаем "y":

This script installs Broadcom DSL modem/router components onto your Linux PC.
The installation will overwrite existing files. You will be prompted before a
component is installed.

This script may create directories and overwrite existing files. Therefore,
you will need to have root privilages to run this script.

Press 'y' to continue: y


Теперь нам сообщают, что "исходники" будут установлены в /home/pudeev/gpl/Broadcom (для удобства я у себя переименовал длинные файлы начинающиеся на RU_DSL-2640U_3-06-04-3C_* в Broadcom), нажимаем "y":

The Broadcom DSL modem/router source files are ready to be installed at
/home/pudeev/gpl/Broadcom. Existing source files, in any, will be overwritten.

Press 'y' to install the Broadcom DSL modem/router source files: y


Ждем 2-3 минуты пока закончится процесс извлечения и копирования файлов из архива RU_DSL-2640U_3-06-04-3C_consumer.tar.gz (у меня это Broadcom_consumer.tar.gz) в каталог /home/pudeev/gpl/Broadcom.
Затем скрипт предлагает установить ПО Toolchain (кросс-компилятор для процессора с архитектурой MIPS для ОС Linux, библиотеки C для embedded Linux) в директорию /opt/toolchains, нажимаем "y":

The Broadcom DSL modem/router toolchain is ready to be installed at /opt/toolchains.
Existing toolchain files, if any, will be overwritten.

Press 'y' to install the Broadcom toolchain: y


Ждем несколько секунд пока установятся два rpm-пакета:

Installing files from /home/pudeev/gpl/Broadcom_uclibc_crosstools_3.4.2_0.9.27.tar.gz.

uclibc-crosstools-common.i386.rpm
uclibc-crosstools-mips.i386.rpm
Preparing... ########################################### [100%]
package uclibc-crosstools-common-3.4.2-12 is already installed
package uclibc-crosstools-mips-3.4.2-12 is already installed


Все. Процесс установки закончен. Теперь посмотрим что получилось:

[root@localhost gpl]# ls -l /home/pudeev/gpl/Broadcom

total 88
drwxrwxrwx 4 root root 4096 Nov 14 2007 bcmdrivers
drwxr-xr-x 3 root root 4096 Jul 29 13:06 hostTools
drwxr-xr-x 3 root root 4096 Jul 29 13:05 kernel
-rwxrwxrwx 1 root root 54093 Nov 14 2007 Makefile
drwxr-xr-x 3 root root 4096 Jul 29 13:06 shared
drwxr-xr-x 5 root root 4096 Jul 29 13:06 targets
drwxr-xr-x 4 root root 4096 Jul 29 13:06 userapps
-rwxrwxrwx 1 root root 68 Nov 5 2007 version.make


Информация о версии релиза (3-06-04-3C):

[root@localhost gpl]# cd Broadcom
[root@localhost Broadcom]# cat version.make
BRCM_VERSION=3
BRCM_RELEASE=06
BRCM_EXTRAVERSION=04
ASUS_RELEASE=3C



Настройка ядра:

[[root@localhost Broadcom]# cd kernel/linux
[root@localhost linux]# make menuconfig



Добавить/удалить утилиты в BusyBox:

[root@localhost Broadcom]# cd userapps/opensource/busybox
[root@localhost busybox]# make menuconfig
[root@localhost busybox]# mv brcm.config brcmconfig.old
[root@localhost busybox]# mv .config brcm.config
[root@localhost busybox]# chmod +x brcm.config



Для компиляции и сборки запускаем скрипт и ждем несколько минут:

[root@localhost gpl]# cd Broadcom
[root@localhost Broadcom]# make PROFILE=RU_DSL-2640U


Окончательный результат работы скрипта - готовый имидж прошивки:

[root@localhost Broadcom]# ls images/
RU_DSL-2640U_306043C00_cfe_fs_kernel_3.06L..

И пример компиляции под Ubuntu:
Скрытый текст: показать
ppcinside

Ставите на компьютер Oracle VirtualBox (https://www.virtualbox.org/wiki/Downloads) .
Качаете дистрибутив Ubuntu 10.04 i386 (например отсюда (http://mirror.yandex.ru/ubuntu-releases/10.04.4/ubuntu-10.04.4-desktop-i386.iso) ).
Создаете новую виртуальную машину и устанавливаете туда скачанную на шаге 2 систему. VirtualBox позволяет подставлять ISO-образы как носители для виртуальных машин.
Запускаете вашу новую виртуальную машину и заходите на нее.
Устанавливаете git -

код:

sudo apt-get install git

Создаете директорию, например ASUS, перемещаетесь в нее и даете команду

код:

mkdir ASUS
cd ./ASUS
git clone https://code.google.com/p/rt-n56u/

Эта команда копирует в созданную вами директорию все необходимые исходники, создает так называемый локальный git-репозиторий. Директория, которую вы создали, будет являться корнем git-репозитория.
Читаете файл path_to_your_dir/rt-n56u/readme.rus.txt, и устанавливаете все пакеты, которые там указаны

код:

sudo apt-get install build-essential gawk pkg-config gettext automake autoconf libtool bison flex zlib1g-dev libgmp3-dev libmpfr-dev libmpc-dev mc

mc (midnight commander, аналог Norton Commander для Linux) для сборки прошивки не нужен, но поможет вам перемещаться по каталогам, копировать и править файлы.
Копируем так называемый toolchain (набор для сборки прошивки) в директорию /opt

код:

cd path_to_your_dir/rt-n56u/
sudo cp -r ./toolchain-rt3883 /opt

Переходим в скопированную директорию и собираем toolchain

код:


cd /opt/toolchain-rt3883
sudo ./build_toolchain
sudo ./build_toolchain_new

В дальнейшем нам эти команды больше не понадобятся, если только не будет обновлен toolchain. Пункт 8 можно не делать, а собрать toolchain прямо в локальном репозитории. В этом случае исправьте путь до него в файле path_to_your_dir/rt-n56u/trunk/.config
Теперь переходим в директорию с исходниками прошивки

код:

cd path_to_your_dir/rt-n56u/trunk

и правим файл .config под свои нужды. Для роутера RT-N56U можно ничего не менять в нем. Для сборки прошивки, например, роутера RT-N65U раскомментируем (удаляем символ #) строку CONFIG_FIRMWARE_PRODUCT_ID="RT-N65U" и комментируем строку CONFIG_FIRMWARE_PRODUCT_ID="RT-N56U". Сохраняем файл.
Очищаем дерево исходников (всякий раз перед новой сборкой)

код:

sudo ./clear_tree

Собираем прошивку

код:

sudo ./build_firmware

Файл собранной прошивки будет лежать в директории ./path_to_your_dir/rt-n56u/trunk/images. Если хотите сохранить прошивку - скопируйте ее в другое место, команда clear_tree затирает директорию images.
Обновлять локальное дерево исходных кодов при появлении обновлений в репозитории http://code.google.com/p/rt-n56u/source/list надо командой

код:

git pull

Если вы делали какие-то изменения в локальном репозитории, то при обновлении дерева некоторые файлы могут не скопироваться. Тогда надо дать команду

код:

git stash
Буду пробывать...


Вернуться наверх
 Профиль  
 
СообщениеДобавлено: Сб авг 09, 2014 01:06 
Не в сети

Зарегистрирован: Пт июн 27, 2008 12:20
Сообщений: 71
Откуда: Киев
Потихоньку получается , обновляю исходный код отсюда: http://pkgs.fedoraproject.org/repo/pkgs , отсюда https://ftp.samba.org/pub и остсюда http://ftp.gnu.org/ вручную


Вернуться наверх
 Профиль  
 
СообщениеДобавлено: Сб авг 09, 2014 13:07 
Не в сети

Зарегистрирован: Пт июн 27, 2008 12:20
Сообщений: 71
Откуда: Киев
При запуске build_fw выдаёт такое:
Скрытый текст: показать
ubuntu-1404@ubuntu1404-VirtualBox:~$ WORKDIR=$(pwd)
ubuntu-1404@ubuntu1404-VirtualBox:~$ echo $WORKDIR
/home/ubuntu-1404
ubuntu-1404@ubuntu1404-VirtualBox:~$ if [ -e /opt/crosstool ];then
> echo -e "\033[31m Toolchain have been installed \033[0m"
> else
> echo -e "\033[31m Toolchain installing ... \033[0m"
> cd /opt
> tar jxf $WORKDIR/GPL/crosstool.tar.bz2
> echo -e "\033[31m Done \033[0m"
> fi
Toolchain installing ...
tar (child): /home/ubuntu-1404/GPL/crosstool.tar.bz2: Функция open завершилась с ошибкой: Нет такого файла или каталога
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
Done
ubuntu-1404@ubuntu1404-VirtualBox:/opt$
ubuntu-1404@ubuntu1404-VirtualBox:/opt$ cd $WORKDIR/GPL
bash: cd: /home/ubuntu-1404/GPL: Нет такого файла или каталога
ubuntu-1404@ubuntu1404-VirtualBox:/opt$
ubuntu-1404@ubuntu1404-VirtualBox:/opt$ export WORKDIR
ubuntu-1404@ubuntu1404-VirtualBox:/opt$ PATH=/opt/crosstool/OXNAS820/gcc-4.2.4-glibc-2.7-toolchain/cross-tools/bin:$PATH
ubuntu-1404@ubuntu1404-VirtualBox:/opt$ export PATH
ubuntu-1404@ubuntu1404-VirtualBox:/opt$ export CROSS_COMPILE=arm-linux-
ubuntu-1404@ubuntu1404-VirtualBox:/opt$ CC=${CROSS_COMPILE}gcc
ubuntu-1404@ubuntu1404-VirtualBox:/opt$ AS=${CROSS_COMPILE}as
ubuntu-1404@ubuntu1404-VirtualBox:/opt$ LD=${CROSS_COMPILE}ld
ubuntu-1404@ubuntu1404-VirtualBox:/opt$ AR=${CROSS_COMPILE}ar
ubuntu-1404@ubuntu1404-VirtualBox:/opt$ RANLIB=${CROSS_COMPILE}ranlib
ubuntu-1404@ubuntu1404-VirtualBox:/opt$ CPP=${CROSS_COMPILE}cppubuntu-1404@ubuntu1404-VirtualBox:/opt$ CXX=${CROSS_COMPILE}g++ubuntu-1404@ubuntu1404-VirtualBox:/opt$ NM=${CROSS_COMPILE}nm
ubuntu-1404@ubuntu1404-VirtualBox:/opt$ STRIP=${CROSS_COMPILE}strip
ubuntu-1404@ubuntu1404-VirtualBox:/opt$ export CC AS LD AR RANLIB CPP CXX NM STRIP
ubuntu-1404@ubuntu1404-VirtualBox:/opt$ echo -e "\033[31m CC AS LD AR RANLIB CPP CXX NM STRIP \033[0m"
CC AS LD AR RANLIB CPP CXX NM STRIP
ubuntu-1404@ubuntu1404-VirtualBox:/opt$
ubuntu-1404@ubuntu1404-VirtualBox:/opt$ echo $PWD
/opt
ubuntu-1404@ubuntu1404-VirtualBox:/opt$ tar zxvf ramdisk.tgz
tar (child): ramdisk.tgz: Функция open завершилась с ошибкой: Нет такого файла или каталога
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
ubuntu-1404@ubuntu1404-VirtualBox:/opt$ tar zxvf merge.tgz
tar (child): merge.tgz: Функция open завершилась с ошибкой: Нет такого файла или каталога
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
ubuntu-1404@ubuntu1404-VirtualBox:/opt$ cd merge
bash: cd: merge: Нет такого файла или каталога
ubuntu-1404@ubuntu1404-VirtualBox:/opt$ sudo cp ../ramdisk/uRamdisk .
[sudo] password for ubuntu-1404:
Очень жаль, попробуйте позже.
[sudo] password for ubuntu-1404:
cp: не удалось выполнить stat для «../ramdisk/uRamdisk»: Нет такого файла или каталога
ВСЕ папки и файлы есть. Не пойму в чём дело.


Вернуться наверх
 Профиль  
 
СообщениеДобавлено: Сб авг 09, 2014 19:30 
Не в сети

Зарегистрирован: Пт июн 27, 2008 12:20
Сообщений: 71
Откуда: Киев
Собрал первый вариант прошивки. Обновлены торрент клиент и самба: DNS-315_A1_FW_v1.00.02a . Кто поможет с тестированием ?


Вернуться наверх
 Профиль  
 
СообщениеДобавлено: Сб авг 09, 2014 19:55 
Не в сети

Зарегистрирован: Пт июн 27, 2008 12:20
Сообщений: 71
Откуда: Киев
Так как у девайса есть проблеммы с протоколом LLTD - решил тоже глянуть и понял что для меня это дебри . Может кто поможет ? Вот сам исходник: LLTD-PortingKit


Вернуться наверх
 Профиль  
 
СообщениеДобавлено: Сб авг 09, 2014 21:22 
Не в сети

Зарегистрирован: Пт июн 27, 2008 12:20
Сообщений: 71
Откуда: Киев
Собрал ещё один вариант прошивки с дополнительно обновлёнными службами файловых систем: DNS-315_A1_FW_v1.00.05a


Вернуться наверх
 Профиль  
 
СообщениеДобавлено: Пн авг 11, 2014 14:09 
Не в сети

Зарегистрирован: Пт июн 27, 2008 12:20
Сообщений: 71
Откуда: Киев
Ещё один неудачный вариант прошивки : DNS-315-firmware-05a2


Вернуться наверх
 Профиль  
 
СообщениеДобавлено: Ср авг 20, 2014 12:20 
Не в сети

Зарегистрирован: Пт июн 27, 2008 12:20
Сообщений: 71
Откуда: Киев
Нашол настройки SWAP:
swap
Скрытый текст: показать
/*
* linux/kernel/power/swap.c
*
* This file provides functions for reading the suspend image from
* and writing it to a swap partition.
*
* Copyright (C) 1998,2001-2005 Pavel Machek <pavel@suse.cz>
* Copyright (C) 2006 Rafael J. Wysocki <rjw@sisk.pl>
*
* This file is released under the GPLv2.
*
*/

#include <linux/module.h>
#include <linux/file.h>
#include <linux/utsname.h>
#include <linux/delay.h>
#include <linux/bitops.h>
#include <linux/genhd.h>
#include <linux/device.h>
#include <linux/buffer_head.h>
#include <linux/bio.h>
#include <linux/blkdev.h>
#include <linux/swap.h>
#include <linux/swapops.h>
#include <linux/pm.h>

#include "power.h"

#define SWSUSP_SIG "S1SUSPEND"

struct swsusp_header {
char reserved[PAGE_SIZE - 20 - sizeof(sector_t) - sizeof(int)];
sector_t image;
unsigned int flags; /* Flags to pass to the "boot" kernel */
char orig_sig[10];
char sig[10];
} __attribute__((packed));

static struct swsusp_header *swsusp_header;

/*
* General things
*/

static unsigned short root_swap = 0xffff;
static struct block_device *resume_bdev;

/**
* submit - submit BIO request.
* @rw: READ or WRITE.
* @off physical offset of page.
* @page: page we're reading or writing.
* @bio_chain: list of pending biod (for async reading)
*
* Straight from the textbook - allocate and initialize the bio.
* If we're reading, make sure the page is marked as dirty.
* Then submit it and, if @bio_chain == NULL, wait.
*/
static int submit(int rw, pgoff_t page_off, struct page *page,
struct bio **bio_chain)
{
const int bio_rw = rw | (1 << BIO_RW_SYNCIO) | (1 << BIO_RW_UNPLUG);
struct bio *bio;

bio = bio_alloc(__GFP_WAIT | __GFP_HIGH, 1);
bio->bi_sector = page_off * (PAGE_SIZE >> 9);
bio->bi_bdev = resume_bdev;
bio->bi_end_io = end_swap_bio_read;

if (bio_add_page(bio, page, PAGE_SIZE, 0) < PAGE_SIZE) {
printk(KERN_ERR "PM: Adding page to bio failed at %ld\n",
page_off);
bio_put(bio);
return -EFAULT;
}

lock_page(page);
bio_get(bio);

if (bio_chain == NULL) {
submit_bio(bio_rw, bio);
wait_on_page_locked(page);
if (rw == READ)
bio_set_pages_dirty(bio);
bio_put(bio);
} else {
if (rw == READ)
get_page(page); /* These pages are freed later */
bio->bi_private = *bio_chain;
*bio_chain = bio;
submit_bio(bio_rw, bio);
}
return 0;
}

static int bio_read_page(pgoff_t page_off, void *addr, struct bio **bio_chain)
{
return submit(READ, page_off, virt_to_page(addr), bio_chain);
}

static int bio_write_page(pgoff_t page_off, void *addr, struct bio **bio_chain)
{
return submit(WRITE, page_off, virt_to_page(addr), bio_chain);
}

static int wait_on_bio_chain(struct bio **bio_chain)
{
struct bio *bio;
struct bio *next_bio;
int ret = 0;

if (bio_chain == NULL)
return 0;

bio = *bio_chain;
if (bio == NULL)
return 0;
while (bio) {
struct page *page;

next_bio = bio->bi_private;
page = bio->bi_io_vec[0].bv_page;
wait_on_page_locked(page);
if (!PageUptodate(page) || PageError(page))
ret = -EIO;
put_page(page);
bio_put(bio);
bio = next_bio;
}
*bio_chain = NULL;
return ret;
}

/*
* Saving part
*/

static int mark_swapfiles(sector_t start, unsigned int flags)
{
int error;

bio_read_page(swsusp_resume_block, swsusp_header, NULL);
if (!memcmp("SWAP-SPACE",swsusp_header->sig, 10) ||
!memcmp("SWAPSPACE2",swsusp_header->sig, 10)) {
memcpy(swsusp_header->orig_sig,swsusp_header->sig, 10);
memcpy(swsusp_header->sig,SWSUSP_SIG, 10);
swsusp_header->image = start;
swsusp_header->flags = flags;
error = bio_write_page(swsusp_resume_block,
swsusp_header, NULL);
} else {
printk(KERN_ERR "PM: Swap header not found!\n");
error = -ENODEV;
}
return error;
}

/**
* swsusp_swap_check - check if the resume device is a swap device
* and get its index (if so)
*/

static int swsusp_swap_check(void) /* This is called before saving image */
{
int res;

res = swap_type_of(swsusp_resume_device, swsusp_resume_block,
&resume_bdev);
if (res < 0)
return res;

root_swap = res;
res = blkdev_get(resume_bdev, FMODE_WRITE);
if (res)
return res;

res = set_blocksize(resume_bdev, PAGE_SIZE);
if (res < 0)
blkdev_put(resume_bdev, FMODE_WRITE);

return res;
}

/**
* write_page - Write one page to given swap location.
* @buf: Address we're writing.
* @offset: Offset of the swap page we're writing to.
* @bio_chain: Link the next write BIO here
*/

static int write_page(void *buf, sector_t offset, struct bio **bio_chain)
{
void *src;

if (!offset)
return -ENOSPC;

if (bio_chain) {
src = (void *)__get_free_page(__GFP_WAIT | __GFP_HIGH);
if (src) {
memcpy(src, buf, PAGE_SIZE);
} else {
WARN_ON_ONCE(1);
bio_chain = NULL; /* Go synchronous */
src = buf;
}
} else {
src = buf;
}
return bio_write_page(offset, src, bio_chain);
}

/*
* The swap map is a data structure used for keeping track of each page
* written to a swap partition. It consists of many swap_map_page
* structures that contain each an array of MAP_PAGE_SIZE swap entries.
* These structures are stored on the swap and linked together with the
* help of the .next_swap member.
*
* The swap map is created during suspend. The swap map pages are
* allocated and populated one at a time, so we only need one memory
* page to set up the entire structure.
*
* During resume we also only need to use one swap_map_page structure
* at a time.
*/

#define MAP_PAGE_ENTRIES (PAGE_SIZE / sizeof(sector_t) - 1)

struct swap_map_page {
sector_t entries[MAP_PAGE_ENTRIES];
sector_t next_swap;
};

/**
* The swap_map_handle structure is used for handling swap in
* a file-alike way
*/

struct swap_map_handle {
struct swap_map_page *cur;
sector_t cur_swap;
unsigned int k;
};

static void release_swap_writer(struct swap_map_handle *handle)
{
if (handle->cur)
free_page((unsigned long)handle->cur);
handle->cur = NULL;
}

static int get_swap_writer(struct swap_map_handle *handle)
{
handle->cur = (struct swap_map_page *)get_zeroed_page(GFP_KERNEL);
if (!handle->cur)
return -ENOMEM;
handle->cur_swap = alloc_swapdev_block(root_swap);
if (!handle->cur_swap) {
release_swap_writer(handle);
return -ENOSPC;
}
handle->k = 0;
return 0;
}

static int swap_write_page(struct swap_map_handle *handle, void *buf,
struct bio **bio_chain)
{
int error = 0;
sector_t offset;

if (!handle->cur)
return -EINVAL;
offset = alloc_swapdev_block(root_swap);
error = write_page(buf, offset, bio_chain);
if (error)
return error;
handle->cur->entries[handle->k++] = offset;
if (handle->k >= MAP_PAGE_ENTRIES) {
error = wait_on_bio_chain(bio_chain);
if (error)
goto out;
offset = alloc_swapdev_block(root_swap);
if (!offset)
return -ENOSPC;
handle->cur->next_swap = offset;
error = write_page(handle->cur, handle->cur_swap, NULL);
if (error)
goto out;
memset(handle->cur, 0, PAGE_SIZE);
handle->cur_swap = offset;
handle->k = 0;
}
out:
return error;
}

static int flush_swap_writer(struct swap_map_handle *handle)
{
if (handle->cur && handle->cur_swap)
return write_page(handle->cur, handle->cur_swap, NULL);
else
return -EINVAL;
}

/**
* save_image - save the suspend image data
*/

static int save_image(struct swap_map_handle *handle,
struct snapshot_handle *snapshot,
unsigned int nr_to_write)
{
unsigned int m;
int ret;
int error = 0;
int nr_pages;
int err2;
struct bio *bio;
struct timeval start;
struct timeval stop;

printk(KERN_INFO "PM: Saving image data pages (%u pages) ... ",
nr_to_write);
m = nr_to_write / 100;
if (!m)
m = 1;
nr_pages = 0;
bio = NULL;
do_gettimeofday(&start);
do {
ret = snapshot_read_next(snapshot, PAGE_SIZE);
if (ret > 0) {
error = swap_write_page(handle, data_of(*snapshot),
&bio);
if (error)
break;
if (!(nr_pages % m))
printk("\b\b\b\b%3d%%", nr_pages / m);
nr_pages++;
}
} while (ret > 0);
err2 = wait_on_bio_chain(&bio);
do_gettimeofday(&stop);
if (!error)
error = err2;
if (!error)
printk("\b\b\b\bdone\n");
swsusp_show_speed(&start, &stop, nr_to_write, "Wrote");
return error;
}

/**
* enough_swap - Make sure we have enough swap to save the image.
*
* Returns TRUE or FALSE after checking the total amount of swap
* space avaiable from the resume partition.
*/

static int enough_swap(unsigned int nr_pages)
{
unsigned int free_swap = count_swap_pages(root_swap, 1);

pr_debug("PM: Free swap pages: %u\n", free_swap);
return free_swap > nr_pages + PAGES_FOR_IO;
}

/**
* swsusp_write - Write entire image and metadata.
* @flags: flags to pass to the "boot" kernel in the image header
*
* It is important _NOT_ to umount filesystems at this point. We want
* them synced (in case something goes wrong) but we DO not want to mark
* filesystem clean: it is not. (And it does not matter, if we resume
* correctly, we'll mark system clean, anyway.)
*/

int swsusp_write(unsigned int flags)
{
struct swap_map_handle handle;
struct snapshot_handle snapshot;
struct swsusp_info *header;
int error;

error = swsusp_swap_check();
if (error) {
printk(KERN_ERR "PM: Cannot find swap device, try "
"swapon -a.\n");
return error;
}
memset(&snapshot, 0, sizeof(struct snapshot_handle));
error = snapshot_read_next(&snapshot, PAGE_SIZE);
if (error < PAGE_SIZE) {
if (error >= 0)
error = -EFAULT;

goto out;
}
header = (struct swsusp_info *)data_of(snapshot);
if (!enough_swap(header->pages)) {
printk(KERN_ERR "PM: Not enough free swap\n");
error = -ENOSPC;
goto out;
}
error = get_swap_writer(&handle);
if (!error) {
sector_t start = handle.cur_swap;

error = swap_write_page(&handle, header, NULL);
if (!error)
error = save_image(&handle, &snapshot,
header->pages - 1);

if (!error) {
flush_swap_writer(&handle);
printk(KERN_INFO "PM: S");
error = mark_swapfiles(start, flags);
printk("|\n");
}
}
if (error)
free_all_swap_pages(root_swap);

release_swap_writer(&handle);
out:
swsusp_close(FMODE_WRITE);
return error;
}

/**
* The following functions allow us to read data using a swap map
* in a file-alike way
*/

static void release_swap_reader(struct swap_map_handle *handle)
{
if (handle->cur)
free_page((unsigned long)handle->cur);
handle->cur = NULL;
}

static int get_swap_reader(struct swap_map_handle *handle, sector_t start)
{
int error;

if (!start)
return -EINVAL;

handle->cur = (struct swap_map_page *)get_zeroed_page(__GFP_WAIT | __GFP_HIGH);
if (!handle->cur)
return -ENOMEM;

error = bio_read_page(start, handle->cur, NULL);
if (error) {
release_swap_reader(handle);
return error;
}
handle->k = 0;
return 0;
}

static int swap_read_page(struct swap_map_handle *handle, void *buf,
struct bio **bio_chain)
{
sector_t offset;
int error;

if (!handle->cur)
return -EINVAL;
offset = handle->cur->entries[handle->k];
if (!offset)
return -EFAULT;
error = bio_read_page(offset, buf, bio_chain);
if (error)
return error;
if (++handle->k >= MAP_PAGE_ENTRIES) {
error = wait_on_bio_chain(bio_chain);
handle->k = 0;
offset = handle->cur->next_swap;
if (!offset)
release_swap_reader(handle);
else if (!error)
error = bio_read_page(offset, handle->cur, NULL);
}
return error;
}

/**
* load_image - load the image using the swap map handle
* @handle and the snapshot handle @snapshot
* (assume there are @nr_pages pages to load)
*/

static int load_image(struct swap_map_handle *handle,
struct snapshot_handle *snapshot,
unsigned int nr_to_read)
{
unsigned int m;
int error = 0;
struct timeval start;
struct timeval stop;
struct bio *bio;
int err2;
unsigned nr_pages;

printk(KERN_INFO "PM: Loading image data pages (%u pages) ... ",
nr_to_read);
m = nr_to_read / 100;
if (!m)
m = 1;
nr_pages = 0;
bio = NULL;
do_gettimeofday(&start);
for ( ; ; ) {
error = snapshot_write_next(snapshot, PAGE_SIZE);
if (error <= 0)
break;
error = swap_read_page(handle, data_of(*snapshot), &bio);
if (error)
break;
if (snapshot->sync_read)
error = wait_on_bio_chain(&bio);
if (error)
break;
if (!(nr_pages % m))
printk("\b\b\b\b%3d%%", nr_pages / m);
nr_pages++;
}
err2 = wait_on_bio_chain(&bio);
do_gettimeofday(&stop);
if (!error)
error = err2;
if (!error) {
printk("\b\b\b\bdone\n");
snapshot_write_finalize(snapshot);
if (!snapshot_image_loaded(snapshot))
error = -ENODATA;
}
swsusp_show_speed(&start, &stop, nr_to_read, "Read");
return error;
}

/**
* swsusp_read - read the hibernation image.
* @flags_p: flags passed by the "frozen" kernel in the image header should
* be written into this memeory location
*/

int swsusp_read(unsigned int *flags_p)
{
int error;
struct swap_map_handle handle;
struct snapshot_handle snapshot;
struct swsusp_info *header;

*flags_p = swsusp_header->flags;
if (IS_ERR(resume_bdev)) {
pr_debug("PM: Image device not initialised\n");
return PTR_ERR(resume_bdev);
}

memset(&snapshot, 0, sizeof(struct snapshot_handle));
error = snapshot_write_next(&snapshot, PAGE_SIZE);
if (error < PAGE_SIZE)
return error < 0 ? error : -EFAULT;
header = (struct swsusp_info *)data_of(snapshot);
error = get_swap_reader(&handle, swsusp_header->image);
if (!error)
error = swap_read_page(&handle, header, NULL);
if (!error)
error = load_image(&handle, &snapshot, header->pages - 1);
release_swap_reader(&handle);

blkdev_put(resume_bdev, FMODE_READ);

if (!error)
pr_debug("PM: Image successfully loaded\n");
else
pr_debug("PM: Error %d resuming\n", error);
return error;
}

/**
* swsusp_check - Check for swsusp signature in the resume device
*/

int swsusp_check(void)
{
int error;

resume_bdev = open_by_devnum(swsusp_resume_device, FMODE_READ);
if (!IS_ERR(resume_bdev)) {
set_blocksize(resume_bdev, PAGE_SIZE);
memset(swsusp_header, 0, PAGE_SIZE);
error = bio_read_page(swsusp_resume_block,
swsusp_header, NULL);
if (error)
return error;

if (!memcmp(SWSUSP_SIG, swsusp_header->sig, 10)) {
memcpy(swsusp_header->sig, swsusp_header->orig_sig, 10);
/* Reset swap signature now */
error = bio_write_page(swsusp_resume_block,
swsusp_header, NULL);
} else {
return -EINVAL;
}
if (error)
blkdev_put(resume_bdev, FMODE_READ);
else
pr_debug("PM: Signature found, resuming\n");
} else {
error = PTR_ERR(resume_bdev);
}

if (error)
pr_debug("PM: Error %d checking image file\n", error);

return error;
}

/**
* swsusp_close - close swap device.
*/

void swsusp_close(fmode_t mode)
{
if (IS_ERR(resume_bdev)) {
pr_debug("PM: Image device not initialised\n");
return;
}

blkdev_put(resume_bdev, mode);
}

static int swsusp_header_init(void)
{
swsusp_header = (struct swsusp_header*) __get_free_page(GFP_KERNEL);
if (!swsusp_header)
panic("Could not allocate memory for swsusp_header\n");
return 0;
}

core_initcall(swsusp_header_init);
swsusp
Скрытый текст: показать
/*
* linux/kernel/power/swsusp.c
*
* This file provides code to write suspend image to swap and read it back.
*
* Copyright (C) 1998-2001 Gabor Kuti <seasons@fornax.hu>
* Copyright (C) 1998,2001-2005 Pavel Machek <pavel@suse.cz>
*
* This file is released under the GPLv2.
*
* I'd like to thank the following people for their work:
*
* Pavel Machek <pavel@ucw.cz>:
* Modifications, defectiveness pointing, being with me at the very beginning,
* suspend to swap space, stop all tasks. Port to 2.4.18-ac and 2.5.17.
*
* Steve Doddi <dirk@loth.demon.co.uk>:
* Support the possibility of hardware state restoring.
*
* Raph <grey.havens@earthling.net>:
* Support for preserving states of network devices and virtual console
* (including X and svgatextmode)
*
* Kurt Garloff <garloff@suse.de>:
* Straightened the critical function in order to prevent compilers from
* playing tricks with local variables.
*
* Andreas Mohr <a.mohr@mailto.de>
*
* Alex Badea <vampire@go.ro>:
* Fixed runaway init
*
* Rafael J. Wysocki <rjw@sisk.pl>
* Reworked the freeing of memory and the handling of swap
*
* More state savers are welcome. Especially for the scsi layer...
*
* For TODOs,FIXMEs also look in Documentation/power/swsusp.txt
*/

#include <linux/mm.h>
#include <linux/suspend.h>
#include <linux/spinlock.h>
#include <linux/kernel.h>
#include <linux/major.h>
#include <linux/swap.h>
#include <linux/pm.h>
#include <linux/swapops.h>
#include <linux/bootmem.h>
#include <linux/syscalls.h>
#include <linux/highmem.h>
#include <linux/time.h>
#include <linux/rbtree.h>
#include <linux/io.h>

#include "power.h"

int in_suspend __nosavedata = 0;

/**
* The following functions are used for tracing the allocated
* swap pages, so that they can be freed in case of an error.
*/

struct swsusp_extent {
struct rb_node node;
unsigned long start;
unsigned long end;
};

static struct rb_root swsusp_extents = RB_ROOT;

static int swsusp_extents_insert(unsigned long swap_offset)
{
struct rb_node **new = &(swsusp_extents.rb_node);
struct rb_node *parent = NULL;
struct swsusp_extent *ext;

/* Figure out where to put the new node */
while (*new) {
ext = container_of(*new, struct swsusp_extent, node);
parent = *new;
if (swap_offset < ext->start) {
/* Try to merge */
if (swap_offset == ext->start - 1) {
ext->start--;
return 0;
}
new = &((*new)->rb_left);
} else if (swap_offset > ext->end) {
/* Try to merge */
if (swap_offset == ext->end + 1) {
ext->end++;
return 0;
}
new = &((*new)->rb_right);
} else {
/* It already is in the tree */
return -EINVAL;
}
}
/* Add the new node and rebalance the tree. */
ext = kzalloc(sizeof(struct swsusp_extent), GFP_KERNEL);
if (!ext)
return -ENOMEM;

ext->start = swap_offset;
ext->end = swap_offset;
rb_link_node(&ext->node, parent, new);
rb_insert_color(&ext->node, &swsusp_extents);
return 0;
}

/**
* alloc_swapdev_block - allocate a swap page and register that it has
* been allocated, so that it can be freed in case of an error.
*/

sector_t alloc_swapdev_block(int swap)
{
unsigned long offset;

offset = swp_offset(get_swap_page_of_type(swap));
if (offset) {
if (swsusp_extents_insert(offset))
swap_free(swp_entry(swap, offset));
else
return swapdev_block(swap, offset);
}
return 0;
}

/**
* free_all_swap_pages - free swap pages allocated for saving image data.
* It also frees the extents used to register which swap entres had been
* allocated.
*/

void free_all_swap_pages(int swap)
{
struct rb_node *node;

while ((node = swsusp_extents.rb_node)) {
struct swsusp_extent *ext;
unsigned long offset;

ext = container_of(node, struct swsusp_extent, node);
rb_erase(node, &swsusp_extents);
for (offset = ext->start; offset <= ext->end; offset++)
swap_free(swp_entry(swap, offset));

kfree(ext);
}
}

int swsusp_swap_in_use(void)
{
return (swsusp_extents.rb_node != NULL);
}

/**
* swsusp_show_speed - print the time elapsed between two events represented by
* @start and @stop
*
* @nr_pages - number of pages processed between @start and @stop
* @msg - introductory message to print
*/

void swsusp_show_speed(struct timeval *start, struct timeval *stop,
unsigned nr_pages, char *msg)
{
s64 elapsed_centisecs64;
int centisecs;
int k;
int kps;

elapsed_centisecs64 = timeval_to_ns(stop) - timeval_to_ns(start);
do_div(elapsed_centisecs64, NSEC_PER_SEC / 100);
centisecs = elapsed_centisecs64;
if (centisecs == 0)
centisecs = 1; /* avoid div-by-zero */
k = nr_pages * (PAGE_SIZE / 1024);
kps = (k * 100) / centisecs;
printk(KERN_INFO "PM: %s %d kbytes in %d.%02d seconds (%d.%02d MB/s)\n",
msg, k,
centisecs / 100, centisecs % 100,
kps / 1000, (kps % 1000) / 10);
}

Не пойму как увеличить размер и больше освободить RAM


Вернуться наверх
 Профиль  
 
СообщениеДобавлено: Ср авг 20, 2014 12:32 
Не в сети

Зарегистрирован: Пт июн 27, 2008 12:20
Сообщений: 71
Откуда: Киев
Может в строках
Код:
k = nr_pages * (PAGE_SIZE / 1024);
   kps = (k * 100) / centisecs;
   printk(KERN_INFO "PM: %s %d kbytes in %d.%02d seconds (%d.%02d MB/s)\n",
         msg, k,
         centisecs / 100, centisecs % 100,
         kps / 1000, (kps % 1000) / 10);
поменять PAGE_SIZE / 1024 на PAGE_SIZE / 2048 ?


Вернуться наверх
 Профиль  
 
СообщениеДобавлено: Вт ноя 04, 2014 01:46 
Не в сети

Зарегистрирован: Сб мар 03, 2012 01:50
Сообщений: 64
Так ваша прошивка палит или как? ) А то у меня самба отваливаеться безконца в 1.02


Вернуться наверх
 Профиль  
 
СообщениеДобавлено: Ср апр 08, 2015 14:48 
Не в сети

Зарегистрирован: Вт янв 14, 2014 10:55
Сообщений: 115
sharahome писал(а):
Собрал ещё один вариант прошивки с дополнительно обновлёнными службами файловых систем: DNS-315_A1_FW_v1.00.05a

Хорошо что хоть один человек взялась за эту работу! Уважуха.
Так какая прошивка нормально работает? Так чтоб самба нормуль работала!!!


Вернуться наверх
 Профиль  
 
СообщениеДобавлено: Пт июн 26, 2015 02:42 
Не в сети

Зарегистрирован: Пт июн 26, 2015 02:29
Сообщений: 5
sharahome писал(а):
Ещё один неудачный вариант прошивки : DNS-315-firmware-05a2

А почему не удачная????
Решил рискнуть и поставить ее.
Пошли вторые сутки - полет отличный.
Прошивка жрет меньше ресурсов в памяти.
Единственное, что меня удивило, это то, что зачем то вырезан NFS, но впрочем это не проблема, так как поставил его из репозитария.

По мимо обычной SMB и NFS шары использую следующие службы:
Transmission (скачка\раздача 24\7 в месяц где-то 7 Тб набегает)
Telnet
SSH (5-7 туннелей в течении дня)

Посмотрим, как прошивка себя поведет дальше.


Вернуться наверх
 Профиль  
 
СообщениеДобавлено: Пт июн 26, 2015 03:01 
Не в сети

Зарегистрирован: Пт июн 26, 2015 02:29
Сообщений: 5
Прошивку DNS-315-firmware-05a2 брал отсюда:
Тут


Вернуться наверх
 Профиль  
 
СообщениеДобавлено: Вс июн 28, 2015 17:50 
Не в сети

Зарегистрирован: Вт янв 14, 2014 10:55
Сообщений: 115
vicar писал(а):
А почему не удачная????
Решил рискнуть и поставить ее.
Пошли вторые сутки - полет отличный.
Прошивка жрет меньше ресурсов в памяти.
Единственное, что меня удивило, это то, что зачем то вырезан NFS, но впрочем это не проблема, так как поставил его из репозитария.

По мимо обычной SMB и NFS шары использую следующие службы:
Transmission (скачка\раздача 24\7 в месяц где-то 7 Тб набегает)
Telnet
SSH (5-7 туннелей в течении дня)

Посмотрим, как прошивка себя поведет дальше.

Блин у меня самба отваливаеться через каждых 2 дня, когда включаю комп или ноут. А как у тебя дела с SMB?


Вернуться наверх
 Профиль  
 
Показать сообщения за:  Сортировать по:  
Начать новую тему Ответить на тему  [ Сообщений: 20 ]  На страницу 1, 2  След.

Часовой пояс: UTC + 3 часа


Кто сейчас на форуме

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 11


Вы не можете начинать темы
Вы не можете отвечать на сообщения
Вы не можете редактировать свои сообщения
Вы не можете удалять свои сообщения
Вы не можете добавлять вложения

Найти:
Перейти:  
Создано на основе phpBB® Forum Software © phpBB Group
Русская поддержка phpBB