久しぶりに、キャラクタ液晶をFONで制御しようと思って過去のやり方をもう一度やろうとしたらLinkももろも変更があって、そのままではできなかった。
再度、構築手順をまとめてみる。しばらくやらないと全く忘れているOrz.
まずは復習
Openwrtのソース取得→生成
クローンする
git clone -b openwrt-18.06 https://git.openwrt.org/openwrt/openwrt.git
または<git clone https://git.openwrt.org/openwrt/openwrt.git>
あるいは<git clone -b lede-17.01 https://git.openwrt.org/openwrt/openwrt.git>
場合によっては<git clone -b chaos_calmer git://git.openwrt.org/openwrt/svn-archive/openwrt.git>
cd openwrt
./scripts/feeds update -a
./scripts/feeds install -a
このあと、自分用にgogsにプッシュした。ブランチを作る
ブランチを作成し、移動する。
git checkout -b fon2405ekai-base
git branch
* fon2405ekai-base
master
また、.gitignoreから/.configを削除してカーネルコンフィグも記録対象にした。ベースとなる変更
とりあえず、必要最低限と思われる変更をしてみるソースの変更
ここに良い手順が書いてあった。https://openwrt.org/docs/guide-developer/adding_new_device
grep -lri fon2405ekai target/
target/linux/ramips/image/rt305x.mk
target/linux/ramips/dts/FON2405EKAI.dts
target/linux/ramips/base-files/etc/diag.sh
target/linux/ramips/base-files/lib/ramips.sh
target/linux/ramips/base-files/lib/upgrade/platform.sh
変更点の差分は
diff --git a/target/linux/ramips/base-files/etc/diag.sh b/target/linux/ramips/base-files/etc/diag.sh
index 2f51add..c076d18 100644
--- a/target/linux/ramips/base-files/etc/diag.sh
+++ b/target/linux/ramips/base-files/etc/diag.sh
@@ -26,6 +26,7 @@ get_status_led() {
ex2700|\
ex3700|\
fonera20n|\
+ fon2405ekai|\
firewrt|\
hg255d|\
iodata,wn-gx300gr|\
diff --git a/target/linux/ramips/base-files/lib/ramips.sh b/target/linux/ramips/base-files/lib/ramips.sh
index 5741cbd..ddf9a41 100755
--- a/target/linux/ramips/base-files/lib/ramips.sh
+++ b/target/linux/ramips/base-files/lib/ramips.sh
@@ -721,6 +721,9 @@ ramips_board_detect() {
*"YK1")
name="youku-yk1"
;;
+ *"FON2405E Kai")
+ name="fon2405ekai"
+ ;;
esac
# use generic board detect if no name is set
diff --git a/target/linux/ramips/base-files/lib/upgrade/platform.sh b/target/linux/ramips/base-files/lib/upgrade/platform.sh
index ffdc5e7..6785e92 100755
--- a/target/linux/ramips/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ramips/base-files/lib/upgrade/platform.sh
@@ -62,6 +62,7 @@ platform_check_image() {
f7c027|\
firewrt|\
fonera20n|\
+ fon2405ekai|\
freestation5|\
gnubee,gb-pc1|\
gnubee,gb-pc2|\
diff --git a/target/linux/ramips/dts/FON2405EKAI.dts b/target/linux/ramips/dts/FON2405EKAI.dts
new file mode 100644
index 0000000..18779c5
--- /dev/null
+++ b/target/linux/ramips/dts/FON2405EKAI.dts
@@ -0,0 +1,104 @@
+/dts-v1/;
+
+#include "rt3050.dtsi"
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+/ {
+ compatible = "fon,fon2405ekai", "ralink,rt3050-soc";
+ model = "FON2405E Kai";
+
+ aliases {
+ led-boot = &led_power_green;
+ led-failsafe = &led_power_green;
+ led-running = &led_power_green;
+ led-upgrade = &led_power_green;
+ };
+
+ gpio-keys-polled {
+ compatible = "gpio-keys-polled";
+ poll-interval = <20>;
+
+ reset {
+ label = "reset";
+ gpios = <&gpio0 10 GPIO_ACTIVE_LOW>;
+ linux,code = <KEY_RESTART>;
+ };
+
+ wps {
+ label = "wps";
+ gpios = <&gpio0 0 GPIO_ACTIVE_LOW>;
+ linux,code = <KEY_WPS_BUTTON>;
+ };
+ };
+ gpio-leds {
+ compatible = "gpio-leds";
+ wan {
+ label = "fon2405ekai:green:wan";
+ gpios = <&gpio0 12 GPIO_ACTIVE_LOW>;
+ };
+ led_power_green: lan {
+ label = "fon2405ekai:green:lan";
+ gpios = <&gpio0 11 GPIO_ACTIVE_LOW>;
+ };
+ wps {
+ label = "fon2405ekai:green:wps";
+ gpios = <&gpio0 14 GPIO_ACTIVE_LOW>;
+ };
+ };
+};
+
+&spi0 {
+ status = "okay";
+
+ m25p80@0 {
+ compatible = "jedec,spi-nor";
+ reg = <0>;
+ spi-max-frequency = <10000000>;
+
+ partitions {
+ compatible = "fixed-partitions";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ partition@0 {
+ label = "u-boot";
+ reg = <0x0 0x10000>;
+ read-only;
+ };
+
+ devconf: partition@10000 {
+ label = "devconf";
+ reg = <0x10000 0x10000>;
+ read-only;
+ };
+
+ firmware: partition@20000 {
+ label = "firmware";
+ reg = <0x20000 0x7b0000>;
+ };
+ };
+ };
+};
+
+&pinctrl {
+ state_default: pinctrl0 {
+ gpio {
+ ralink,group = "i2c", "jtag", "rgmii", "mdio", "uartf";
+ ralink,function = "gpio";
+ };
+ };
+};
+
+ðernet {
+ mtd-mac-address = <&devconf 0x4>;
+};
+
+&esw {
+ mediatek,portmap = <0x2f>;
+};
+
+&wmac {
+ ralink,mtd-eeprom = <&devconf 0>;
+};
diff --git a/target/linux/ramips/image/rt305x.mk b/target/linux/ramips/image/rt305x.mk
index 23a83f8..c807703 100644
--- a/target/linux/ramips/image/rt305x.mk
+++ b/target/linux/ramips/image/rt305x.mk
@@ -908,3 +908,11 @@ define Device/zorlik_zl5900v2
DEVICE_PACKAGES := kmod-usb-core kmod-usb-ohci kmod-usb2 kmod-ledtrig-netdev
endef
TARGET_DEVICES += zorlik_zl5900v2
+
+define Device/fon2405ekai
+ DTS := FON2405EKAI
+ BLOCKSIZE := 4k
+ IMAGE_SIZE := $(ralink_default_fw_size_8M)
+ DEVICE_TITLE := FON FON2405E KAI
+endef
+TARGET_DEVICES += fon2405ekai
Luciの有効化
lcuiについては、以下を参考にmake menuconfigで選択した。https://openwrt.org/docs/guide-user/luci/luci.essentials-tomerge
uhttpd
uhttpd-mod-ubus
luci-mod-admin-full
luci-theme-bootstrap
luci-app-firewall
luci-proto-core
libiwinfo-lua
デフォルトのLAN側IPアドレスの変更
uciの初期設定に入れておくことで変更可能みたいその他、シリアルコンソールログイン時にパスワード必要にしたり、
タイムゾーン変更したりといったものを入れておいた。
https://openwrt.org/docs/guide-user/base-system/uci
https://openwrt.org/docs/guide-user/base-system/system_configuration
https://openwrt.org/docs/guide-developer/uci-defaults
vi package/base-files/files/etc/uci-defaults/99_custom
#!/bin/sh
uci -q batch <<-EOT
set network.lan.ipaddr='192.168.2.1'
set system.@system[0].ttylogin='1'
set system.@system[0].zonename='Asia/Tokyo'
set system.@system[0].timezone='JST-9'
EOT
make menuconfig
make kernel_menuconfig
そしてカーネルイメージ作成
make -j4 V=99
ll bin/targets/ramips/rt305x
合計 6076
drwxr-xr-x 3 adeno adeno 4096 1月 10 01:04 ./
drwxr-xr-x 3 adeno adeno 4096 1月 10 00:57 ../
-rw-r--r-- 1 adeno adeno 21326 1月 10 00:57 config.seed
-rw-r--r-- 1 adeno adeno 2202 1月 10 01:04 openwrt-ramips-rt305x-device-fon2405ekai.manifest
-rw-r--r-- 1 adeno adeno 3075436 1月 10 01:04 openwrt-ramips-rt305x-fon2405ekai-initramfs-kernel.bin
-rw-r--r-- 1 adeno adeno 3097282 1月 10 01:04 openwrt-ramips-rt305x-fon2405ekai-squashfs-sysupgrade.bin
drwxr-xr-x 2 adeno adeno 4096 1月 10 01:04 packages/
-rw-r--r-- 1 adeno adeno 439 1月 10 01:04 sha256sums
u-bootを使って書き込む
[openwrt-ramips-rt305x-fon2405ekai-initramfs-kernel.bin]を使う。
書き込み手順はlinkと同じ。
具体的には以下の通り。
PC側にTFTPサーバー構築
以下を参考にhttps://askubuntu.com/questions/201505/how-do-i-install-and-run-a-tftp-server
http://blog.livedoor.jp/devslife-other/archives/1313413.html
69/UDPを使うのでファイアウォールで許可しておく
PC側と接続
IPは10.10.10.3とした(FONのU-Bootのデフォルトがそうだから) 。FON側はどっちのLANでもいいのかな? 黒い方(LAN側)に刺した。
書き込み
FONはリセットボタンを押しながら電源ONして、U-Bootの起動オプションで2を選択!その後、 コマンドラインからサーバーIPなどを入力する
U-Boot 1.1.3 (Jan 6 2010 - 07:10:30)
Board: Fonera
DRAM: 32 MB
relocate_code Pointer at: 81fac000
spi_wait_nsec: 3e
spi deice id: c2 20 17 c2 20 (2017c220)
find flash: mx25l6405d
raspi_read: from:41030000 len:1000
Using default environment
##### The CPU freq = 320 MHZ ####
SDRAM bus set to 16 bit
SDRAM size =32 Mbytes
Please choose the operation:
1: Boot system code via Flash (default).
2: Load system code then write to Flash via TFTP.
3: Entr boot command line interface.
reset pressed for 2 seconds
You selected 2
0
2: System Load Linux Kernel then write to Flash via TFTP.
Warning!! Erase Linux in Flash then burn new one. Are you sure?(Y/N)
Please Input new ones /or Ctrl-C to discard
Input device IP (10.10.10.200) ==:10.10.10.200
Input server IP (10.10.10.3) ==:10.10.10.3
Input Linux Kernel filename (fonita.img) ==:openwrt201901.bin
netboot_common, argc= 3
NetTxPacket = 0x81FE4DC0
Trying Eth0 (10/100-M)
ETH_STATE_ACTIVE!!
Using Eth0 (10/100-M) device
TFTP from server 10.10.10.3; our IP address is 10.10.10.200
Filename 'openwrt201901.bin'.
TIMEOUT_COUNT=10,Load address: 0x80100000
Loading: Got ARP REPLY, set server/gtwy eth addr (00:07:40:**:**:**)
Got it
T #
first block received
################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
################
done
Bytes transferred = 3542258 (360cf2 hex)
NetBootFileXferSize= 00360cf2
raspi_erase_write: offs:20000, count:360cf2
raspi_erase: offs:20000 len:360000
raspi_write: to:20000 len:360000
raspi_read: from:380000 len:10000
raspi_erase: offs:380000 len:10000
raspi_write: to:380000 len:10000
Done!
## Booting image at bf020000 ...
raspi_read: from:20000 len:40
Image Name: MIPS OpenWrt Linux-4.14.91
Created: 2019-01-13 9:13:18 UTC
Image Type: MIPS Linux Kernel Image (lzma compressed)
Data Size: 3542194 Bytes = 3.4 MB
Load Address: 80000000
Entry Point: 80000000
raspi_read: from:20040 len:360cb2
書き込みが完了したので、アクセスしてみる
OpenWrt login: root
BusyBox v1.28.4 () built-in shell (ash)
_______ ________ __
| |.-----.-----.-----.| | | |.----.| |_
| - || _ | -__| || | | || _|| _|
|_______|| __|_____|__|__||________||__| |____|
|__| W I R E L E S S F R E E D O M
-----------------------------------------------------
OpenWrt 18.06-SNAPSHOT, r0+7650-d58c6ae
if you can dream it, you can do it.
-----------------------------------------------------
=== WARNING! =====================================
There is no root password defined on this device!
Use the "passwd" command to set up a new password
in order to prevent unauthorized SSH logins.
--------------------------------------------------
root@OpenWrt:/#
なんか、markdown→stackedit→blogspotの連携がうまく行かない・・・。
0 件のコメント:
コメントを投稿