nano pi M3 ; cannot swap

hatahata
Hi all .

root@NanoPi3:/home/fa# touch /SWAP

root@NanoPi3:/home/fa# dd if=/dev/zero of=/SWAP bs=1M count=128
128+0 records in
128+0 records out
134217728 bytes (134 MB) copied, 23.1655 s, 5.8 MB/s

root@NanoPi3:/home/fa# mkswap /SWAP
Setting up swapspace version 1, size = 131068 KiB
no label, UUID=15a0107d-f2a1-4ecd-ad91-8a76e7e92e4c

root@NanoPi3:/home/fa# swapon /SWAP
swapon: /SWAP: swapon failed: Function not implemented


how to conquer ' swapon failed: Function not implemented ' ?

-------------
regards

hatahata
from http://forum.odroid.com/viewtopic.php?f=22&t=871

enable CONFIG_SWAP on the kernel.

but for amature like me , iti is hard to do .
please  update linux image .

---
regards

davef
Beat me to it.

Have a look for sway on this forum:

http://billforums.station51.net/

davef
sway = swap

hatahata
thanks for advice .

but i cannot find sway in http://billforums.station51.net/.


---------
i follow
http://wiki.friendlyarm.com/wiki/index.php/NanoPi_M3#Compile_Linux_Kernel.

and 

after make menuconfig,

fa@NanoPi3:~/Kernel/linux-3.4.y$ diff .config .config-ori
53c53
< CONFIG_SWAP=y
---
> # CONFIG_SWAP is not set
96d95
< # CONFIG_CGROUP_MEM_RES_CTLR_SWAP is not set


by
wget -c
http://www.dragonwake.com/download/arm9-download/linux-toolchain/arm-lin...

but i cannot prepare to use arm-linux-gcc .

how to prepare arm-linux-gcc ?
-----
regards

davef
You need to download the toolchain on the FriendlyArm wiki for their
product.

hatahata
where can i get toolchain ?

hatahata
acoording your advice ,
i found https://github.com/friendlyarm/prebuilts/tree/master/gcc .

and
follow 
http://wiki.friendlyarm.com/wiki/index.php/How_to_build_the_Compiling_En...

but


fa@NanoPi3:~$ echo $PATH
/opt/FriendlyARM/toolschain/4.4.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/ga
mes:/usr/games:

but
fa@NanoPi3:~$ arm-linux-gcc -v
/opt/FriendlyARM/toolschain/4.4.3/bin/.arm-none-linux-gnueabi-gcc: 1:
/opt/FriendlyARM/toolschain/4.4.3/bin/.arm-none-linux-gnueabi-gcc: Syntax
error: "(" unexpected

how to cope with this ?

---
regards

hatahata
i may download the wrong file .
it is hard to download arm-linux-gcc-4.4.3.tar.gz of friendlyarm .
i must do some effort .

davef
Syntax error: "(" unexpected


Seen that mentioned before, search the specific error message.

Does the M3 require a 64 bit development environment?

hatahata
i did
git clone https://github.com/friendlyarm/prebuilts.git

now

md5sum arm-linux-gcc-4.4.3.tar.gz 
1be8415ee80ba0746baedce41a4b04ba  arm-linux-gcc-4.4.3.tar.gz

and 
ls /opt/FriendlyARM/toolschain/4.4.3/
arm-none-linux-gnueabi  bin  include  lib  libexec  share

and 
echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/opt/FriendlyARM/toolsc
hain/4.4.3/bin


arm-linux-gcc -v
/opt/FriendlyARM/toolschain/4.4.3/bin/.arm-none-linux-gnueabi-gcc: 1:
/opt/FriendlyARM/toolschain/4.4.3/bin/.arm-none-linux-gnueabi-gcc: Syntax
error: "(" unexpected


too hard !
i give up .

davef
Well, it might help if you answered my question.

You are running on a 64bit platform?

Also, why 4.4.3, when according to the wiki page you need 4.9.3

hatahata
default nano pi M3 , perhaps 64 bit .

i follow
http://wiki.friendlyarm.com/wiki/index.php/NanoPi_M3#Install_Cross_Compiler


but but
arm-linux-gcc -v

-bash: /opt/FriendlyARM/toolchain/4.9.3/bin/arm-linux-gcc: cannot execute
binary file: Exec format error

this is also hard wall to climb .
-----
regards

hatahata
i make mistakes .
this is a cross compiler !

i did i on debiandog 64 linux .

---
 Download the compiler package:

git clone https://github.com/friendlyarm/prebuilts.git
sudo mkdir -p /opt/FriendlyARM/toolchain
sudo tar xf prebuilts/gcc-x64/arm-cortexa9-linux-gnueabihf-4.9.3.tar.xz -C
/opt/FriendlyARM/toolchain/

Then add the compiler's directory to "PATH" by appending the following
lines in "~/.bashrc":

export PATH=/opt/FriendlyARM/toolchain/4.9.3/bin:$PATH
export GCC_COLORS=auto

Execute "~/.bashrc" to make the changes take effect. Note that there is a
space after the first ".":

. ~/.bashrc
----

then
arm-linux-gcc -v
&#32068;&#12415;&#36796;&#12415; spec
&#12434;&#20351;&#29992;&#12375;&#12390;&#12356;&#12414;&#12377;&#12290;
COLLECT_GCC=arm-linux-gcc
COLLECT_LTO_WRAPPER=/opt/FriendlyARM/toolchain/4.9.3/libexec/gcc/arm-cortexa9-li
nux-gnueabihf/4.9.3/lto-wrapper
&#12479;&#12540;&#12466;&#12483;&#12488;: arm-cortexa9-linux-gnueabihf
configure &#35373;&#23450;: /work/toolchain/build/src/gcc-4.9.3/configure
--build=x86_64-build_pc-linux-gnu --host=x86_64-build_pc-linux-gnu
--target=arm-cortexa9-linux-gnueabihf
--prefix=/opt/FriendlyARM/toolchain/4.9.3
--with-sysroot=/opt/FriendlyARM/toolchain/4.9.3/arm-cortexa9-linux-gnueabihf/sys
-root
--enable-languages=c,c++ --with-arch=armv7-a --with-tune=cortex-a9
--with-fpu=vfpv3 --with-float=hard --with-pkgversion=ctng-1.21.0-229g-FA
--with-bugurl=http://www.friendlyarm.com/ --enable-__cxa_atexit
--disable-libmudflap --disable-libgomp --disable-libssp
--disable-libquadmath --disable-libquadmath-support --disable-libsanitizer
--with-gmp=/work/toolchain/build/arm-cortexa9-linux-gnueabihf/buildtools
--with-mpfr=/work/toolchain/build/arm-cortexa9-linux-gnueabihf/buildtools
--with-mpc=/work/toolchain/build/arm-cortexa9-linux-gnueabihf/buildtools
--with-isl=/work/toolchain/build/arm-cortexa9-linux-gnueabihf/buildtools
--with-cloog=/work/toolchain/build/arm-cortexa9-linux-gnueabihf/buildtools
--with-libelf=/work/toolchain/build/arm-cortexa9-linux-gnueabihf/buildtools
--enable-lto --with-host-libstdcxx='-static-libgcc
-Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --enable-threads=posix
--enable-linker-build-id --with-linker-hash-style=gnu --enable-plugin
--enable-gold --disable-multilib
--with-local-prefix=/opt/FriendlyARM/toolchain/4.9.3/arm-cortexa9-linux-gnueabih
f/sys-root
--enable-long-long
&#12473;&#12524;&#12483;&#12489;&#12514;&#12487;&#12523;: posix
gcc &#12496;&#12540;&#12472;&#12519;&#12531; 4.9.3 (ctng-1.21.0-229g-FA) 

OK

hatahata
continued !

using debiandog 64 ( **not** nano pi M3)


git clone https://github.com/friendlyarm/linux-3.4.y.git
cd linux-3.4.y

$ ls
COPYING        MAINTAINERS     arch      fs       lib      security
CREDITS        Makefile        block     include  mm       sound
Documentation  README          crypto    init     net      tools
Kbuild         REPORTING-BUGS  drivers   ipc      samples  usr
Kconfig        android         firmware  kernel   scripts  virt


git checkout nanopi2-lollipop-mr1


touch .scmversion
make nanopi3_linux_defconfig

but 'make menuconfig' cannot be done .
so directly 
cp .config .config-ori
do `vi .config ' 


##
puppy@debian:~/linux-3.4.y$ make uImage

scripts/kconfig/conf --silentoldconfig Kconfig
.config:54:warning: override: reassigning to symbol SWAP
*
* Restart config...
*
*
* Control Group support
*
Control Group support (CGROUPS) [Y/n/?] y
  Example debug cgroup subsystem (CGROUP_DEBUG) [N/y/?] n
  Freezer cgroup subsystem (CGROUP_FREEZER) [Y/n/?] y
  Device controller for cgroups (CGROUP_DEVICE) [Y/n/?] y
  Cpuset support (CPUSETS) [Y/n/?] y
    Include legacy /proc/<pid>/cpuset file (PROC_PID_CPUSET) [Y/n] y
  Simple CPU accounting cgroup subsystem (CGROUP_CPUACCT) [Y/n/?] y
  Resource counters (RESOURCE_COUNTERS) [Y/n/?] y
    Memory Resource Controller for Control Groups (CGROUP_MEM_RES_CTLR)
[Y/n/?] y
      Memory Resource Controller Swap Extension (CGROUP_MEM_RES_CTLR_SWAP)
[N/y/?] (NEW) ^C/home/puppy/linux-3.4.y/scripts/kconfig/Makefile:33: recipe
for target 'silentoldconfig' failed


##

make uImage


but
  Kernel: arch/arm/boot/zImage is ready
  UIMAGE  arch/arm/boot/uImage
"mkimage" command not found - U-Boot images will not be built
/home/puppy/linux-3.4.y/arch/arm/boot/Makefile:101: recipe for target
'arch/arm/boot/uImage' failed
make[1]: *** [arch/arm/boot/uImage] Error 1
/home/puppy/linux-3.4.y/arch/arm/Makefile:291: recipe for target 'uImage'
failed
make: *** [uImage] Error 2

failed !!

-----------------
regards

hatahata
continued

SUCSESS!

1)
diff .config .config-ori 
53c53
< CONFIG_SWAP=y
---
> # CONFIG_SWAP is not set
96,97d95
< CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y
< CONFIG_CGROUP_MEM_RES_CTLR_SWAP_ENABLED=y

2)
aptitude install u-boot-tools


then

make uImage
  CHK     include/linux/version.h
  CHK     include/generated/utsrelease.h
make[1]: 'include/generated/mach-types.h' is up to date.
  CALL    scripts/checksyscalls.sh
  CHK     include/generated/compile.h
  Kernel: arch/arm/boot/Image is ready
  Kernel: arch/arm/boot/zImage is ready
  UIMAGE  arch/arm/boot/uImage
Image Name:   Linux-3.4.39-s5p6818
Created:      Sun Jul  3 05:17:04 2016
Image Type:   ARM Linux Kernel Image (uncompressed)
Data Size:    4395712 Bytes = 4292.69 kB = 4.19 MB
Load Address: 40008000
Entry Point:  40008000
  Image arch/arm/boot/uImage is ready


puppy@debian:~/linux-3.4.y$ ls -l arch/arm/boot/uImage
-rw-r--r-- 1 puppy puppy 4395776  7&#26376;  3 05:17 arch/arm/boot/uImage
puppy@debian:~/linux-3.4.y$ md5sum arch/arm/boot/uImage
6c33f23d631cea0e0ad5ae58ada02183  arch/arm/boot/uImage

---
regards

hatahata
aptitude install ncurses-dev

then
make menuconfig is OK

hatahata
all is written in http://akita-8core.blogspot.jp/2016/06/nano-pi-m3.html

hatahata
this morning , i try to  boot nano pi M3  by rebuilded uIimage .

nano pi M3 can boot , but

swapon /SWAP
swapon: /SWAP: swapon failed: Function not implemented

---

regards

jjm
1.The following commands can create a 128MB file to be for virtual memory
(swap)&#65292;of courses&#65292;you can modify the first command to change
size yourself.

dd if=/dev/zero of=/var/swapfile bs=1M count=128
chmod 0600 /var/swapfile
mkswap /var/swapfile
swapon -f /var/swapfile

2. You need to compile kernel to open swap partition&#65292;after using
supports open swap partition kernel to instead of old kernel that you can
excuse the above commands.