Giter Site home page Giter Site logo

hackpascal / mt7621-boot-spi-nand Goto Github PK

View Code? Open in Web Editor NEW
53.0 5.0 28.0 41.93 MB

A bootloader that allows MT7621 to boot directly from Micron SPI-NAND

License: BSD 3-Clause "New" or "Revised" License

Makefile 3.03% Assembly 9.27% C 87.17% C++ 0.53%

mt7621-boot-spi-nand's Introduction

Introduction

This s a standalone program / bootloader used for booting directly from Micron SPI-NAND on MediaTek MT7621 platform.

Prerequisites

  • The bootstrap of MT7621 board is set to "Boot from SPI 3-byte address".
  • A Micron SPI-NAND flash chip with "SPI NOR Read Configuration" enabled.

Toolchain

Prebuilt toolchain for Windows 64-bit platform is provided (use it with MSYS2).
You can also build your own toolchain, but remember to enable LTO (--enable-lto)

Binary structure

1st stage loader

The 1st stage loader only occupies the first page of the SPI-NAND flash.
It's used to setup a basic environment to load 2nd stage loader into locked L2 cache and transfer control to 2nd stage loader.
The size of 1st stage loader must not be greater than the page size of the SPI-NAND flash (i.e. 2KB or 4KB).

2nd stage loader

The 2nd stage loader runs in locked L2 cache and will do all initializations that 1st stage loader can not do (CPU/DDR initialization & cache reset).
The 2nd stage loader then loads 3rd stage loader into memory and transfer control.
The size of 2nd stage loader must not be greater than 192KB (3/4 of 256KB L2 cache).

3rd stage loader

The 3rd stage loader will not be provided by this code.
You can use you customized bootloader (Breed, U-Boot or whatever) to act as the 3rd stage loader.
The 3rd stage loader must have a image header to describe its size/load address/entry point/compression.
Accepted headers are: Breed private header and U-Boot legacy image header. Accepted compression is LZMA.

Output image

The 1st and 2nd stage loaders will be concatenate in to one binary file.

Compilation

make CROSS_COMPILE=<toolchain-prefix>

Optional make parameters (passed to make commandline):

Name Arg type Default value Description
BAUDRATE int 115200 Baudrate of the UART console output
_4K_PAGE_SUPPORT bool (1 for true) Build for SPI-NAND with 4KB page size & 256KB block size
STAGE3_OFFSET hex The offset of 3rd-stage image in NAND
STAGE3_PAYLOAD string Automatically concatenate 3rd-stage image after final output image

If STAGE3_PAYLOAD is specified, STAGE3_OFFSET will be ignored, and the offset of 3rd stage will be set to the size of final output image

Final output image

build/target/output-loader.bin

CPU/DDR configuration

Please edit src/mt7621/stage2/entry.S

EXPORT(_dramc_cpu_freq)
	.word	880
EXPORT(_dramc_ddr_freq)
	.word	1

EXPORT(_dramc_ddr2_act_sel)
	.word	2
EXPORT(_dramc_ddr3_act_sel)
	.word	2

CPU frequency

As-is, 880 stands for 880MHz, step is 20MHz

DDR frequency

1 - 1200MHz
2 - 1066MHz (actual 1040MHz)
3 - 800MHz
4 - 400MHz

DDR2 AC timing selection

0 - 512Mb (Generic 64MB)
1 - 512Mb (Optimized for W9751G6KB_A02, DDR frequency is 1066MHz)
2 - 1024Mb (Generic 128MB)
3 - 1024Mb (Optimized for W971GG6KB25, DDR frequency is 800MHz)
4 - 1024Mb (Optimized for W971GG6KB18, DDR frequency is 1066MHz)

DDR3 AC timing selection

0 - 1024Mb (Generic 128MB)
1 - 1024Mb (Optimized for MT7621DA, integrated DDR KGD)
2 - 2048Mb (Generic 256MB)
3 - 4096Mb (Generic 512MB)

License

BSD-3-Clause

mt7621-boot-spi-nand's People

Contributors

hackpascal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

mt7621-boot-spi-nand's Issues

MT29F2G01ABA这个芯片可否?

想用K2P试试这个功能,不知道这个spi nand芯片能不能成功。PDFN8封装的1gb/2gb芯片不好找,看了看也就这个还行。

H大您好,小米路由3G在使用breed 1.2时遇到问题

设备:小米路由 3G V1。
固件:OpenWrt 22.03 最新快照(08/14)自编译。
Kernel1 映像 2.7MB,rootfs0 映像 23MB。
BREED版本:1.2。

步骤:
我在 breed 1.1 中选择“布局1”,刷入官方 22.03 rc6 的 initramfs 映像,正常启动后登录 SSH 后台,
使用 ubiformat /dev/mtd9 格式化 ubi 分区,随后使用 sysupgrade -F /自编译映像.bin 等重启后直接进入 breed,随后在 breed 中更新 breed 到 1.2 版本。

然后我使用 telnet 登录 breed 后台,使用命令:

flash erase 0x200000 0x400000
flash erase 0x600000 0x400000
wget 下载 kernel 1
flash write 0x200000 0x80001000 0x400000
flash write 0x600000 0x80001000 0x400000

刷写 kernel。

问题:
直接重启无法正常启动,表现为蓝色 LED 常亮,必须手动进入 breed 后登录 telnet 后台,使用 boot flash 0x600000 或 sfp autoboot 才能正常启动。直接使用命令 autoboot 会提示 Unable to locate firmware。我看 sfp info xiaomi_r3g_openwrt 中分区 label 写的是 kernel1,但是 openwrt 官方会将 kernel1 分区更名为 kernel,kernel0 分区更名为 kernel_stock,为了排除是因为固件中分区 label 为 kernel 导致 breed 找不到 label 是 kernel1 的分区造成无法启动,我特地将固件中的 kernel 修改为 kernel1,随后按上述步骤刷入,但仍然无法正常启动。

补充:

root@[OpenWrt:/tmp#](http://openwrt/tmp#) cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00080000 00020000 "Bootloader"
mtd1: 00040000 00020000 "Config"
mtd2: 00040000 00020000 "Bdata"
mtd3: 00040000 00020000 "factory"
mtd4: 00040000 00020000 "crash"
mtd5: 00040000 00020000 "crash_syslog"
mtd6: 00040000 00020000 "reserved0"
mtd7: 00400000 00020000 "kernel_stock"
mtd8: 00400000 00020000 "kernel"
mtd9: 07580000 00020000 "ubi"

Build a bootloader for MT7621AT with reset GPIO14

Hi friend.
I ask you to build a bootloader with specific parameters for the SerComm ODM router:

Board name: Smart Box Turbo+
CPU: MediaTek MT7621AT 880 MHz
RAM: DDR3 1200MHz
Reset GPIO: 14, active level low - this GPIO for Breed enter
FLA: SPI NOR 16 MiB (3-byte address)
BAUDRATE: 57600

I found one Breed bootloader for Buffalo M1 (https://breed.hackpascal.net/breed-mt7621-pbr-m1.bin), but this bootloader use a GPIO18 for Reset and BAUDRATE is 115200.

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.