2023年11月29日 星期三

LS1046A

(1)U587 
1: off 
2: off 

 S1 
1: on 
2: on 
3: off 
4: on 
5: on 
6: on 
7: off 
8: on 
9: on 
10: on 

(2) USB flash drive with two partitions First partition: FAT-32 recommended to store Linux kernel/device tree blob/etc. Second partition: EXT-4 used for rootfs 

(3) Extract the ubuntu rootfs to second partition 
sudo mount /dev/sd?2 /mnt 
cd /mnt sudo tar xf rootfs_lsdk2012_ubuntu_main_arm64.tgz 
sudo umount /mnt 

U-boot 
(1) Power on the board and stop in u-boot command prompt 
(2) Run the following command to => mmc rescan 
(3) Use the following command to set bootargs to use USB rootfs 
=> setenv bootargs root=/dev/sda2 rw rootwait rootfstype=ext4 earlycon=uart8250,mmio,0x21c0500 console=ttyS0,115200 loglevel=8 nohz=off 
 (4) Use the following commands to load Linux kernel and device tree blob from USB 
=> usb start 
=> fatload usb 0:1 0x8f000000 fsl-ls1046a-db-sdk.dtb 
=> fatload usb 0:1 0x81000000 Image (5) Use the following command to boot the Linux kernel 
=> booti 0x81000000 - 0x8f000000


2022年5月11日 星期三

AMD64 Ubuntu rootfs howto

 1. Preparing the packages in host

sudo apt-get install  debootstrap qemu-user-static

2. Download the packages for ubuntu rootfs
debootstrap_dir=ubuntu-arm64-jammy
sudo debootstrap --arch arm64 --foreign jammy "$debootstrap_dir" http://ports.ubuntu.com/ubuntu-ports

3. Install the packages/ second-stage
sudo mkdir -p "${debootstrap_dir}/usr/bin"
sudo cp "$(which qemu-aarch64-static)" "${debootstrap_dir}/usr/bin"
sudo chroot "$debootstrap_dir" /debootstrap/debootstrap --second-stage

4. Remove the passwd of root
sudo chroot "$debootstrap_dir"
Edit /etc/passwd and /etc/shadow, remove the "*" in between ":" and ":" in root:....

5. Enable UART console
sudo chroot ${debootstrap_dir}
ln  -sf /lib/systemd/system/serial-getty\@.service /lib/systemd/system/getty.target.wants/

6. /etc/network/interfaces
sudo apt install ifupdown
vi /etc/network/interface
-----
source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

# The intranet network interface
auto eth1
iface eth1 inet static
     address 10.19.132.49
     netmask 255.255.254.0

7. Add locale
sudo vi /etc/locale.gen
umakrk en_US.UTF-8 UTF-8 and zh_TW.UTF-8 UTF-8
sudo locale-gen


source.list
==================================================
deb http://tw.ports.ubuntu.com/ bionic main restricted universe multiverse
deb http://tw.ports.ubuntu.com/ bionic-updates main restricted universe multiverse

deb http://tw.ports.ubuntu.com/ubuntu-ports bionic main restricted
deb http://tw.ports.ubuntu.com/ubuntu-ports bionic-updates main restricted
deb-src http://tw.ports.ubuntu.com/ubuntu-ports bionic main restricted universe multiverse
deb-src http://tw.ports.ubuntu.com/ubuntu-ports bionic-updates main restricted universe multiverse
deb http://tw.ports.ubuntu.com/ubuntu-ports bionic universe
deb http://tw.ports.ubuntu.com/ubuntu-ports bionic-updates universe
deb http://tw.ports.ubuntu.com/ubuntu-ports bionic multiverse
deb http://tw.ports.ubuntu.com/ubuntu-ports bionic-updates multiverse

deb http://tw.ports.ubuntu.com/ bionic-security main restricted universe multiverse

SNAT
================================
echo "Setting IP Masquerading...."
echo 1 > /proc/sys/net/ipv4/ip_forward
WAN_IP=`ifconfig eth0 | grep "inet addr:" | cut -d ":" -f 2 | cut -d " " -f 1`

echo "Setting iptables..... "
/sbin/iptables -F
/sbin/iptables -t nat -F
/sbin/iptables -P FORWARD DROP

# Block access to 208.46.65.0/24
/sbin/iptables -A OUTPUT -d 208.48.65.0/24 -j DROP

/sbin/iptables -A FORWARD -s 192.168.0.0/24 -j ACCEPT
/sbin/iptables -A FORWARD -d 192.168.0.0/24 -j ACCEPT
/sbin/iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -j SNAT --to-source ${WAN_IP}

#172.23.68.32
/sbin/iptables -A FORWARD -s 172.23.68.32 -j ACCEPT
/sbin/iptables -A FORWARD -d 172.23.68.32 -j ACCEPT
/sbin/iptables -t nat -A POSTROUTING -s 172.23.68.32 -j SNAT --to-source ${WAN_IP}

Route table
============================
ip route add 10.0.0.0/8 via 10.19.132.1
ip route del default
ip route add default via 10.19.132.49(Z2X)

rc.local
=============
ln -fs /lib/systemd/system/rc-local.service /etc/systemd/system/rc-local.service

touch /etc/rc.local

chmod 755 /etc/rc.local

EDIT /etc/rc.local
-----
#!/bin/bash

echo "test rc " > /var/test.log

exit 0


2021年12月9日 星期四

Hostapd example

 


interface=wlan0       # the interface used by the AP
hw_mode=a             # a simply means 5GHz
channel=0             # the channel to use, 
                      # 0 means the AP will search for the channel with the 
                      # least interferences 
ieee80211d=1          # limit the frequencies used to those allowed in the country
country_code=TW       # the country code
ieee80211n=1          # 802.11n support
ieee80211ac=1         # 802.11ac support
wmm_enabled=1         # QoS support

ssid=SSID             # the name of the AP
auth_algs=1           # 1=wpa, 2=wep, 3=both
wpa=2                 # WPA2 only
wpa_key_mgmt=WPA-PSK 
rsn_pairwise=CCMP
wpa_passphrase=passwd

2020年3月13日 星期五

wpa_cli-setup-example

sudo wpa_cli -i wlp2s0 scan
sudo wpa_cli -i wlp2s0 scan_result
sudo wpa_cli -i wlp2s0 add_network
sudo wpa_cli -i wlp2s0 set_network 0 ssid '"bk5"'
sudo wpa_cli -i wlp2s0 set_network 0 psk '"nxp12345678"'
sudo wpa_cli -i wlp2s0 enable_network 0
sudo wpa_cli -i wlp2s0 list_network
sudo wpa_cli -i wlp2s0 select_network 0
sudo wpa_cli -i wlp2s0 status
sudo dhclient -i wlp2s0
ip a
## list all network
sudo wpa_cli -i wlp2s0 list_network
## disconnect
sudo wpa_cli -i wlp2s0 disable_network 0
## delete network
sudo wpa_cli -i wlp2s0 remove_network 0

2019年10月18日 星期五

2019年7月2日 星期二

mldonkey/transmission PORT Redirection


       
#Enable the module proxy for http
a2enmod proxy
a2enmod proxy_http  

#Restart apache2

systemctl restart apache2

-----------------------------------
#/etc/apache2/sites-available/000-default.conf


       # The ServerName directive sets the request scheme, hostname and port that
       # the server uses to identify itself. This is used when creating
       # redirection URLs. In the context of virtual hosts, the ServerName
       # specifies what hostname must appear in the request's Host: header to
       # match this virtual host. For the default virtual host (this file) this
       # value is not decisive as it is used as a last resort host regardless.
       # However, you must set it for any further virtual host explicitly.
       #ServerName www.example.com

       ServerAdmin webmaster@localhost
       DocumentRoot /var/www/html

       # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
       # error, crit, alert, emerg.
       # It is also possible to configure the loglevel for particular
       # modules, e.g.
       #LogLevel info ssl:warn

       ErrorLog ${APACHE_LOG_DIR}/error.log
       CustomLog ${APACHE_LOG_DIR}/access.log combined

       # For most configuration files from conf-available/, which are
       # enabled or disabled at a global level, it is possible to
       # include a line for only one particular virtual host. For example the
       # following line enables the CGI configuration for this host only
       # after it has been globally disabled with "a2disconf".
       #Include conf-available/serve-cgi-bin.conf

       # Allow port 4080
               Allow from all
       
# Redirection
       RewriteEngine On
       RewriteRule ^/mldonkey$ /mldonkey/ [R]
       RewriteRule ^/mldonkey/(.*) http://localhost:4080/$1 [P]

       RewriteEngine On
       ### BELOW FOR TRANSMISSION WEB INTERFACE ###

       # Redirect requests to /transmission/ to /transmission/web/
       RewriteRule /transmission[/]?$ /transmission/web/ [R=permanent]

       # Forward all requests for /transmission to transmission-daemon
       ProxyPass /transmission http://127.0.0.1:9091/transmission
       ProxyPassReverse /transmission http://127.0.0.1:9091/transmission
       redirect 301 /transmission/transmission/web/ /transmission/web/
       redirect 301 /transmission/ /transmission/web/
       redirect 301 /transmission /transmission/
       ### END TRANSMISSION WEB INTERFACE ###



# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

2018年12月12日 星期三

Debian rootfs for Arm64



https://wiki.debian.org/Arm64Port

sudo qemu-debootstrap --arch=arm64 --keyring /usr/share/keyrings/debian-archive-keyring.gpg --variant=buildd --exclude=debfoster stretch  debian-arm64
http://ftp.debian.org/debian