Hi,
As the title suggest I am trying to find a way create a kernel with the data address at "0x81001000" instead of "0x80001000". The reason behind it is that the stock bootloader of the device only accepts compressed kernel with the load address mentionned above.
After days of messing with the different files I managed to make it work but obvioulsy not the best way as it affects all the other devices (and probably won't let them boot). This is to evantually be abel to send a pull request to be added to the master tree.
The changes I made were in the ramips/image/Makefile
loadaddr-$(CONFIG_TARGET_ramips_mt7621) := 0x81001000
then in the same file
define Build/loader-common
rm -rf $@.src
$(MAKE) -C lzma-loader \
PKG_BUILD_DIR="$@.src" \
TARGET_DIR="$(dir $@)" LOADER_NAME="$(notdir $@)" \
BOARD="$(BOARDNAME)" PLATFORM="$(LOADER_PLATFORM)" \
LZMA_TEXT_START=0x82800000 LOADADDR=0x80001000 \
$(1) compile loader.$(LOADER_TYPE)
mv "$@.$(LOADER_TYPE)" "$@"
rm -rf $@.src
endef
And finally in the same file
define Device/uimage-lzma-loader-s3
LOADER_TYPE := bin
KERNEL := kernel-bin | append-dtb | lzma | loader-kernel | lzma | uImage lzma
endef
This "just from looking at the boot process" made a loader-kernel with the address at 0x81001000 which then in turns loads a kernel at 0x8001000.
Kernel Addr: 0xbc400100
## Booting image at bc400100 ...
Image Name: MIPS OpenWrt Linux-5.4.111
Image Type: MIPS Linux Kernel Image (lzma compressed)
Data Size: 2382013 Bytes = 2.3 MB
Load Address: 81001000
Entry Point: 81001000
Verifying Checksum ... OK
Uncompressing Kernel Image ... OK
kernel addr: 0xBC400100
No initrd
## Transferring control to Linux (at address 81001000) ...
## Giving linux memsize in MB, 256
Starting kernel ...
OpenWrt kernel loader for MIPS based SoC
Copyright (C) 2011 Gabor Juhos < juhosg@openwrt.org >
Decompressing kernel ... done!
Starting kernel at 80001000 ...
[0.000000] Linux version 5.4.111 ( builder @ buildhost ) (gcc version 8.4.0 (OpenWrt GCC 8.4.0 r16046-59980f7aaf)) # 0 SMP Sun Apr 18 10:06:57 2021
[ 0.000000] SoC Type: MediaTek MT7621 ver: 1 eco: 3
[0.000000] printk: bootconsole [early0] enabled
[0.000000] CPU0 revision is: 0001992f (MIPS 1004Kc)
kar200
May 24, 2021, 11:44am
2
Just in case someone comes across the same issue. I have created a copy of the loader.
I am not sure about how the whole thing work with the loader-kernel but I had to change the LZMA_TEXT_START.
I just made a separate loader and added the kernel address.
image/Makefile
define Build/loader-common-s3
rm -rf $@.src
$(MAKE) -C lzma-loader \
PKG_BUILD_DIR="$@.src" \
TARGET_DIR="$(dir $@)" LOADER_NAME="$(notdir $@)" \
BOARD="$(BOARDNAME)" PLATFORM="$(LOADER_PLATFORM)" \
LZMA_TEXT_START=0x82800000 LOADADDR=0x80001000 \
$(1) compile loader.$(LOADER_TYPE)
mv "$@.$(LOADER_TYPE)" "$@"
rm -rf $@.src
endef
define Build/loader-kernel-s3
$(call Build/loader-common-s3,LOADER_DATA="$@")
endef
define Device/uimage-lzma-loader-s3
KERNEL_LOADADDR = 0x81001000
LOADER_TYPE := bin
KERNEL := kernel-bin | append-dtb | lzma | loader-kernel-s3 | lzma | uImage lzma
endef
And this in the mt7621.mk
define Device/sercomm_s3
$(Device/uimage-lzma-loader-s3)
BLOCKSIZE := 128k
PAGESIZE := 2048
KERNEL_SIZE := 4096k
UBINIZE_OPTS := -E 5
IMAGES += kernel0.bin rootfs0.bin
IMAGE/kernel0.bin := append-kernel
IMAGE/rootfs0.bin := append-ubi
DEVICE_VENDOR := Sercomm
DEVICE_MODEL := S3
DEVICE_PACKAGES := kmod-mt7603 kmod-mt7615e kmod-mt7615-firmware kmod-usb3 \
kmod-usb-ledtrig-usbport
endef
TARGET_DEVICES += sercomm_s3
dts
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
#include "mt7621.dtsi"
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
/ {
compatible = "sercomm,s3", "mediatek,mt7621-soc";
model = "Sercomm S3";
aliases {
led-boot = &led_status_blue;
led-failsafe = &led_status_red;
led-running = &led_status_green;
led-upgrade = &led_status_red;
label-mac-device = &gmac0;
};
chosen {
bootargs = "console=ttyS0,57600n8";
};
leds {
compatible = "gpio-leds";
led_status_blue: status_blue {
label = "blue:status";
gpios = <&gpio 13 GPIO_ACTIVE_HIGH>;
};
led_status_green: status_green {
label = "green:status";
gpios = <&gpio 15 GPIO_ACTIVE_HIGH>;
};
led_status_red: status_red {
label = "red:status";
gpios = <&gpio 16 GPIO_ACTIVE_HIGH>;
};
};
keys {
compatible = "gpio-keys";
wps {
label = "wps";
gpios = <&gpio 11 GPIO_ACTIVE_LOW>;
linux,code = <KEY_WPS_BUTTON>;
};
reset {
label = "reset";
gpios = <&gpio 14 GPIO_ACTIVE_LOW>;
linux,code = <KEY_RESTART>;
};
};
};
&nand {
status = "okay";
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
partition@0 {
label = "bootloader";
reg = <0x0 0x100000>;
};
partition@100000{
label = "part_map ";
reg = <0x100000 0x100000 >;
};
factory:partition@200000 {
label = "factory-data";
reg = <0x200000 0x100000>;
};
partition@300000 {
label = "bootflag";
reg = <0x300000 0x100000>;
};
partition@400000 {
label = "kernel0";
reg = <0x400000 0x600000>;
};
partition@a00000 {
label = "kernel1";
reg = <0xa00000 0x600000>;
};
partition@1000000 {
label = "ubi";
reg = <0x1000000 0x2000000>;
};
partition@3000000 {
label = "rootfs1";
reg = <0x3000000 0x2000000>;
};
partition@5000000{
label = "config-log";
reg = <0x5000000 0x1400000>;
};
partition@6400000 {
label = "reserved";
reg = <0x6400000 0x1b80000>;
};
};
};
&pcie {
status = "okay";
};
&pcie0 {
wifi@0,0 {
compatible = "pci14c3,7615";
reg = <0x0000 0 0 0 0>;
mediatek,mtd-eeprom = <&factory 0x8000>;
ieee80211-freq-limit = <5000000 6000000>;
mtd-mac-address = <&factory 0x21000>;
mtd-mac-address-increment = <2>;
};
};
&pcie1 {
wifi@0,0 {
compatible = "pci14c3,7603";
reg = <0x0000 0 0 0 0>;
mediatek,mtd-eeprom = <&factory 0x0000>;
ieee80211-freq-limit = <2400000 2500000>;
mtd-mac-address = <&factory 0x21000>;
mtd-mac-address-increment = <3>;
};
};
&gmac0 {
mtd-mac-address = <&factory 0x21000>;
};
&switch0 {
ports {
port@0 {
status = "okay";
label = "wan";
mtd-mac-address = <&factory 0x21000>;
mtd-mac-address-increment = <1>;
};
port@1 {
status = "okay";
label = "lan1";
};
port@2 {
status = "okay";
label = "lan2";
};
port@3 {
status = "okay";
label = "lan3";
};
port@4 {
status = "okay";
label = "lan4";
};
};
};
&state_default {
gpio {
groups = "uart2", "jtag";
function = "gpio";
};
};
1 Like
system
Closed
June 3, 2021, 11:45am
3
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.